code review order

This commit is contained in:
zhijiantianya@gmail.com 2023-09-01 19:08:27 +08:00
parent 361ad2e22a
commit dd6adb8ee6
7 changed files with 46 additions and 22 deletions

View File

@ -24,6 +24,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Validated @Validated
public class AppDeliverPickUpStoreController { public class AppDeliverPickUpStoreController {
// TODO 待实现[门店自提]如果 latitudelongitude 非空计算经纬度并排序计算的库可以使用 hutool DistanceUtil 计算
@GetMapping("/list") @GetMapping("/list")
@Operation(summary = "获得自提门店列表") @Operation(summary = "获得自提门店列表")
public CommonResult<List<AppDeliveryPickUpStoreRespVO>> getDeliveryPickUpStoreList( public CommonResult<List<AppDeliveryPickUpStoreRespVO>> getDeliveryPickUpStoreList(
@ -50,6 +51,7 @@ public class AppDeliverPickUpStoreController {
return success(list); return success(list);
} }
// TODO 待实现[门店自提]
@GetMapping("/get") @GetMapping("/get")
@Operation(summary = "获得自提门店") @Operation(summary = "获得自提门店")
@Parameter(name = "id", description = "门店编号") @Parameter(name = "id", description = "门店编号")

View File

@ -49,9 +49,6 @@ public class AppTradeOrderController {
@Resource @Resource
private DeliveryExpressService deliveryExpressService; private DeliveryExpressService deliveryExpressService;
@Resource
private ProductPropertyValueApi productPropertyValueApi;
@Resource @Resource
private TradeOrderProperties tradeOrderProperties; private TradeOrderProperties tradeOrderProperties;
@ -78,6 +75,7 @@ public class AppTradeOrderController {
return success(true); return success(true);
} }
// TODO @芋艿如果拼团活动秒杀活动砍价活动时是不是要额外在返回活动之类的信息
@GetMapping("/get-detail") @GetMapping("/get-detail")
@Operation(summary = "获得交易订单") @Operation(summary = "获得交易订单")
@Parameter(name = "id", description = "交易订单编号") @Parameter(name = "id", description = "交易订单编号")
@ -93,6 +91,7 @@ public class AppTradeOrderController {
// 查询物流公司 // 查询物流公司
DeliveryExpressDO express = order.getLogisticsId() != null && order.getLogisticsId() > 0 ? DeliveryExpressDO express = order.getLogisticsId() != null && order.getLogisticsId() > 0 ?
deliveryExpressService.getDeliveryExpress(order.getLogisticsId()) : null; deliveryExpressService.getDeliveryExpress(order.getLogisticsId()) : null;
// TODO @puhui999如果门店自提信息的拼接
// 最终组合 // 最终组合
return success(TradeOrderConvert.INSTANCE.convert02(order, orderItems, tradeOrderProperties, express)); return success(TradeOrderConvert.INSTANCE.convert02(order, orderItems, tradeOrderProperties, express));
} }
@ -141,7 +140,7 @@ public class AppTradeOrderController {
@PutMapping("/receive") @PutMapping("/receive")
@Operation(summary = "确认交易订单收货") @Operation(summary = "确认交易订单收货")
@Parameter(name = "id", description = "交易订单编号") @Parameter(name = "id", description = "交易订单编号")
public CommonResult<Boolean> takeOrder(@RequestParam("id") Long id) { public CommonResult<Boolean> receiveOrder(@RequestParam("id") Long id) {
tradeOrderUpdateService.receiveOrder(getLoginUserId(), id); tradeOrderUpdateService.receiveOrder(getLoginUserId(), id);
return success(true); return success(true);
} }

View File

@ -143,6 +143,8 @@ public class TradeOrderItemDO extends BaseDO {
* 对应 taobao trade.point_fee 字段 * 对应 taobao trade.point_fee 字段
*/ */
private Integer pointPrice; private Integer pointPrice;
// TODO @芋艿如果商品 vip 折扣时到底是新增一个 vipPrice 记录优惠记录还是 vipDiscountPrice记录 vip 的优惠还是直接使用 vipPrice
// 目前 crmeb 的选择单独一个 vipPrice 记录优惠价格感觉不一定合理可以在看看有赞的
// ========== 售后基本信息 ========== // ========== 售后基本信息 ==========

View File

@ -98,6 +98,8 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSa
return afterSale; return afterSale;
} }
// TODO 芋艿拼团失败要不要发起售后的方式退款还是走取消逻辑
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public Long createAfterSale(Long userId, AppTradeAfterSaleCreateReqVO createReqVO) { public Long createAfterSale(Long userId, AppTradeAfterSaleCreateReqVO createReqVO) {

View File

@ -96,6 +96,8 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
private TradePriceService tradePriceService; private TradePriceService tradePriceService;
@Resource @Resource
private DeliveryExpressService deliveryExpressService; private DeliveryExpressService deliveryExpressService;
@Resource
private TradeMessageService tradeMessageService;
@Resource @Resource
private ProductSkuApi productSkuApi; private ProductSkuApi productSkuApi;
@ -105,27 +107,22 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
private AddressApi addressApi; private AddressApi addressApi;
@Resource @Resource
private CouponApi couponApi; private CouponApi couponApi;
@Resource
private CombinationRecordApi combinationRecordApi;
@Resource
private BargainRecordApi bargainRecordApi;
@Resource @Resource
private MemberUserApi memberUserApi; private MemberUserApi memberUserApi;
@Resource @Resource
private MemberLevelApi memberLevelApi; private MemberLevelApi memberLevelApi;
@Resource @Resource
private MemberPointApi memberPointApi; private MemberPointApi memberPointApi;
@Resource @Resource
private ProductCommentApi productCommentApi; private ProductCommentApi productCommentApi;
@Resource
private TradeMessageService tradeMessageService;
@Resource @Resource
private TradeOrderProperties tradeOrderProperties; private TradeOrderProperties tradeOrderProperties;
@Resource
private CombinationRecordApi combinationRecordApi;
@Resource
private BargainRecordApi bargainRecordApi;
// =================== Order =================== // =================== Order ===================
@Override @Override
@ -179,15 +176,17 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public TradeOrderDO createOrder(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO) { public TradeOrderDO createOrder(Long userId, String userIp, AppTradeOrderCreateReqVO createReqVO) {
// 2. 价格计算 // 1. 价格计算
TradePriceCalculateRespBO calculateRespBO = calculatePrice(userId, createReqVO); TradePriceCalculateRespBO calculateRespBO = calculatePrice(userId, createReqVO);
// 3.1 插入 TradeOrderDO 订单
// 2.1 插入 TradeOrderDO 订单
TradeOrderDO order = createTradeOrder(userId, userIp, createReqVO, calculateRespBO); TradeOrderDO order = createTradeOrder(userId, userIp, createReqVO, calculateRespBO);
// 3.2 插入 TradeOrderItemDO 订单项 // 2.2 插入 TradeOrderItemDO 订单项
List<TradeOrderItemDO> orderItems = createTradeOrderItems(order, calculateRespBO); List<TradeOrderItemDO> orderItems = createTradeOrderItems(order, calculateRespBO);
// 订单创建完后的逻辑
// 3. 订单创建完后的逻辑
afterCreateTradeOrder(userId, createReqVO, order, orderItems, calculateRespBO); afterCreateTradeOrder(userId, createReqVO, order, orderItems, calculateRespBO);
// 3.3 校验订单类型 // 3.1 拼团的特殊逻辑
// TODO @puhui999这个逻辑先抽个小方法未来要通过设计模式把这些拼团之类的逻辑抽象出去 // TODO @puhui999这个逻辑先抽个小方法未来要通过设计模式把这些拼团之类的逻辑抽象出去
// 拼团 // 拼团
if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) { if (Objects.equals(TradeOrderTypeEnum.COMBINATION.getType(), order.getType())) {
@ -205,15 +204,21 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
combinationRecordApi.createCombinationRecord(TradeOrderConvert.INSTANCE.convert(order, orderItemDO, createReqVO, user)); combinationRecordApi.createCombinationRecord(TradeOrderConvert.INSTANCE.convert(order, orderItemDO, createReqVO, user));
} }
// 3.2 秒杀的特殊逻辑
// TODO 秒杀扣减库存是下单就扣除还是等待订单支付成功再扣除 // TODO 秒杀扣减库存是下单就扣除还是等待订单支付成功再扣除
if (Objects.equals(TradeOrderTypeEnum.SECKILL.getType(), order.getType())) { if (Objects.equals(TradeOrderTypeEnum.SECKILL.getType(), order.getType())) {
} }
// 3.3 砍价的特殊逻辑
// TODO @LeeYan9: 是可以思考下, 订单的营销优惠记录, 应该记录在哪里, 微信讨论起来! // TODO @LeeYan9: 是可以思考下, 订单的营销优惠记录, 应该记录在哪里, 微信讨论起来!
return order; return order;
} }
// TODO @puhui999订单超时自动取消
// TODO @疯狂用户手动取消订单
/** /**
* 校验收件地址是否存在 * 校验收件地址是否存在
* *
@ -239,7 +244,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
} }
TradeOrderDO order = TradeOrderConvert.INSTANCE.convert(userId, clientIp, createReqVO, calculateRespBO, address); TradeOrderDO order = TradeOrderConvert.INSTANCE.convert(userId, clientIp, createReqVO, calculateRespBO, address);
order.setType(validateActivity(createReqVO)); order.setType(validateActivity(createReqVO));
order.setNo(IdUtil.getSnowflakeNextId() + ""); // TODO @LeeYan9: 思考下, 怎么生成好点哈; 这个是会展示给用户的; order.setNo(IdUtil.getSnowflakeNextId() + ""); // TODO @puhui999: 参考支付订单 no 生成哈;
order.setStatus(TradeOrderStatusEnum.UNPAID.getStatus()); order.setStatus(TradeOrderStatusEnum.UNPAID.getStatus());
order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()); order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus());
order.setProductCount(getSumValue(calculateRespBO.getItems(), TradePriceCalculateRespBO.OrderItem::getCount, Integer::sum)); order.setProductCount(getSumValue(calculateRespBO.getItems(), TradePriceCalculateRespBO.OrderItem::getCount, Integer::sum));
@ -251,6 +256,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
// 退款信息 // 退款信息
order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()).setRefundPrice(0); order.setRefundStatus(TradeOrderRefundStatusEnum.NONE.getStatus()).setRefundPrice(0);
tradeOrderMapper.insert(order); tradeOrderMapper.insert(order);
// TODO @puhui999如果是门店订单则需要生成核销码
return order; return order;
} }
@ -291,6 +297,10 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
TradeOrderDO tradeOrderDO, List<TradeOrderItemDO> orderItems, TradeOrderDO tradeOrderDO, List<TradeOrderItemDO> orderItems,
TradePriceCalculateRespBO calculateRespBO) { TradePriceCalculateRespBO calculateRespBO) {
// 下单时扣减商品库存 // 下单时扣减商品库存
// TODO @puhui999扣库存需要前置
// 1如果是秒杀商品额外扣减秒杀的库存
// 2如果是拼团活动额外扣减拼团的库存
// 3如果是砍价活动额外扣减砍价的库存
productSkuApi.updateSkuStock(TradeOrderConvert.INSTANCE.convert(orderItems)); productSkuApi.updateSkuStock(TradeOrderConvert.INSTANCE.convert(orderItems));
// 删除购物车商品 // 删除购物车商品
@ -299,9 +309,9 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
cartService.deleteCart(userId, cartIds); cartService.deleteCart(userId, cartIds);
} }
// 扣减积分 TODO 芋艿待实现 // 扣减积分 TODO 芋艿待实现需要前置
// 有使用优惠券时更新 // 有使用优惠券时更新 TODO 芋艿需要前置
if (createReqVO.getCouponId() != null) { if (createReqVO.getCouponId() != null) {
couponApi.useCoupon(new CouponUseReqDTO().setId(createReqVO.getCouponId()).setUserId(userId) couponApi.useCoupon(new CouponUseReqDTO().setId(createReqVO.getCouponId()).setUserId(userId)
.setOrderId(tradeOrderDO.getId())); .setOrderId(tradeOrderDO.getId()));
@ -510,6 +520,10 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
// TODO 芋艿lili 发送订单变化的消息 // TODO 芋艿lili 发送订单变化的消息
// TODO 芋艿lili 发送商品被购买完成的数据 // TODO 芋艿lili 发送商品被购买完成的数据
// TODO 芋艿销售佣金的记录
// TODO 芋艿获得积分
} }
@Override @Override
@ -529,11 +543,13 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
if (order.getPayStatus()) { if (order.getPayStatus()) {
throw exception(ORDER_UPDATE_PRICE_FAIL_PAID); throw exception(ORDER_UPDATE_PRICE_FAIL_PAID);
} }
// TODO @puhui999如果改价需要校验下是否真的变化
// 更新 // 更新
// TODO @puhui999TradeOrderItemDO 需要做 adjustPrice 的分摊另外支付订单那的价格需要 update // TODO @puhui999TradeOrderItemDO 需要做 adjustPrice 的分摊另外支付订单那的价格需要 update
TradeOrderDO update = TradeOrderConvert.INSTANCE.convert(reqVO); TradeOrderDO update = TradeOrderConvert.INSTANCE.convert(reqVO);
update.setPayPrice(update.getPayPrice() + update.getAdjustPrice()); update.setPayPrice(update.getPayPrice() + update.getAdjustPrice());
// TODO @芋艿改价时赠送的积分要不要做改动
tradeOrderMapper.updateById(update); tradeOrderMapper.updateById(update);
} }
@ -651,6 +667,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
List<TradeOrderItemDO> orderItems = tradeOrderItemMapper.selectListByOrderId(order.getId()); List<TradeOrderItemDO> orderItems = tradeOrderItemMapper.selectListByOrderId(order.getId());
if (!anyMatch(orderItems, item -> Objects.equals(item.getCommentStatus(), Boolean.FALSE))) { if (!anyMatch(orderItems, item -> Objects.equals(item.getCommentStatus(), Boolean.FALSE))) {
tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()).setCommentStatus(Boolean.TRUE)); tradeOrderMapper.updateById(new TradeOrderDO().setId(order.getId()).setCommentStatus(Boolean.TRUE));
// TODO 待实现已完成评价要不要写一条订单日志目前 crmeb 会写有赞可以研究下
} }
return comment; return comment;
} }

View File

@ -41,6 +41,7 @@ public class TradePriceServiceImpl implements TradePriceService {
@Resource @Resource
private List<TradePriceCalculator> priceCalculators; private List<TradePriceCalculator> priceCalculators;
// TODO @疯狂需要搞个 TradePriceCalculator计算赠送积分
@Override @Override
public TradePriceCalculateRespBO calculatePrice(TradePriceCalculateReqBO calculateReqBO) { public TradePriceCalculateRespBO calculatePrice(TradePriceCalculateReqBO calculateReqBO) {
// 1.1 获得商品 SKU 数组 // 1.1 获得商品 SKU 数组

View File

@ -42,6 +42,7 @@ public class TradeDeliveryPriceCalculator implements TradePriceCalculator {
@Override @Override
public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) { public void calculate(TradePriceCalculateReqBO param, TradePriceCalculateRespBO result) {
// TODO @芋艿如果门店自提需要校验是否开启
// 1.1 判断配送方式 // 1.1 判断配送方式
if (param.getDeliveryType() == null || DeliveryTypeEnum.PICK_UP.getMode().equals(param.getDeliveryType())) { if (param.getDeliveryType() == null || DeliveryTypeEnum.PICK_UP.getMode().equals(param.getDeliveryType())) {
return; return;