mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
code review order
This commit is contained in:
parent
361ad2e22a
commit
dd6adb8ee6
@ -24,6 +24,7 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|||||||
@Validated
|
@Validated
|
||||||
public class AppDeliverPickUpStoreController {
|
public class AppDeliverPickUpStoreController {
|
||||||
|
|
||||||
|
// TODO 待实现[门店自提]:如果 latitude、longitude 非空,计算经纬度,并排序。计算的库,可以使用 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 = "门店编号")
|
||||||
|
@ -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);
|
||||||
}
|
}
|
||||||
|
@ -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 记录优惠价格;感觉不一定合理,可以在看看有赞的;
|
||||||
|
|
||||||
// ========== 售后基本信息 ==========
|
// ========== 售后基本信息 ==========
|
||||||
|
|
||||||
|
@ -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) {
|
||||||
|
@ -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 @puhui999:TradeOrderItemDO 需要做 adjustPrice 的分摊;另外,支付订单那的价格,需要 update 下;
|
// TODO @puhui999:TradeOrderItemDO 需要做 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;
|
||||||
}
|
}
|
||||||
|
@ -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 数组
|
||||||
|
@ -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;
|
||||||
|
Loading…
Reference in New Issue
Block a user