feat(order): 完善订单生命周期与投诉处理;补充单元测试

This commit is contained in:
irving
2025-11-01 23:55:47 -04:00
parent 60b4b0bd49
commit 9f83103189
4 changed files with 32 additions and 20 deletions

View File

@@ -47,7 +47,7 @@ import com.starry.admin.modules.shop.module.entity.PlayCouponInfoEntity;
import com.starry.admin.modules.shop.module.enums.CouponDiscountType;
import com.starry.admin.modules.shop.service.IPlayCouponDetailsService;
import com.starry.admin.modules.shop.service.IPlayCouponInfoService;
import com.starry.admin.modules.weichat.service.WxCustomMpService;
import com.starry.admin.modules.weichat.service.NotificationSender;
import com.starry.admin.modules.withdraw.entity.EarningsLineEntity;
import com.starry.admin.modules.withdraw.service.IEarningsService;
import com.starry.admin.utils.SecurityUtils;
@@ -85,7 +85,7 @@ public class OrderLifecycleServiceImpl implements IOrderLifecycleService {
private IEarningsService earningsService;
@Resource
private WxCustomMpService wxCustomMpService;
private NotificationSender notificationSender;
@Resource
private IPlayOrderRefundInfoService orderRefundInfoService;
@@ -466,7 +466,7 @@ public class OrderLifecycleServiceImpl implements IOrderLifecycleService {
}
if (shouldNotify) {
wxCustomMpService.sendOrderFinishMessageAsync(latest);
notificationSender.sendOrderFinishMessageAsync(latest);
}
}

View File

@@ -17,7 +17,7 @@ import com.starry.admin.modules.order.module.vo.PlayOrderComplaintQueryVo;
import com.starry.admin.modules.order.module.vo.PlayOrderComplaintReturnVo;
import com.starry.admin.modules.order.service.IPlayOrderComplaintInfoService;
import com.starry.admin.modules.personnel.service.IPlayPersonnelGroupInfoService;
import com.starry.admin.modules.weichat.service.WxCustomMpService;
import com.starry.admin.modules.weichat.service.NotificationSender;
import com.starry.admin.utils.SecurityUtils;
import com.starry.common.utils.IdUtils;
import java.util.Arrays;
@@ -46,7 +46,7 @@ public class PlayOrderComplaintInfoServiceImpl
@Resource
private IPlayPersonnelGroupInfoService playClerkGroupInfoService;
@Resource
private WxCustomMpService wxCustomMpService;
private NotificationSender notificationSender;
/**
* 查询订单投诉信息
@@ -169,7 +169,7 @@ public class PlayOrderComplaintInfoServiceImpl
playOrderComplaintInfo.setClerkId(orderInfo.getAcceptBy());
playOrderComplaintInfo.setCommodityId(orderInfo.getCommodityId());
// 发送投诉消息给管理员以及客服
wxCustomMpService.sendComplaintMessage(playOrderComplaintInfo, orderInfo);
notificationSender.sendComplaintMessage(playOrderComplaintInfo, orderInfo);
return save(playOrderComplaintInfo);
}

View File

@@ -1,5 +1,6 @@
package com.starry.admin.modules.order.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@@ -41,10 +42,11 @@ import com.starry.admin.modules.order.service.IPlayOrderRefundInfoService;
import com.starry.admin.modules.order.service.support.ClerkRevenueCalculator;
import com.starry.admin.modules.personnel.module.entity.PlayPersonnelGroupInfoEntity;
import com.starry.admin.modules.personnel.service.IPlayPersonnelGroupInfoService;
import com.starry.admin.modules.shop.module.constant.CouponUseState;
import com.starry.admin.modules.shop.module.vo.PlayCouponDetailsReturnVo;
import com.starry.admin.modules.shop.service.IPlayCouponDetailsService;
import com.starry.admin.modules.weichat.entity.order.*;
import com.starry.admin.modules.weichat.service.WxCustomMpService;
import com.starry.admin.modules.weichat.service.NotificationSender;
import com.starry.admin.modules.withdraw.service.IEarningsService;
import com.starry.admin.utils.DateRangeUtils;
import com.starry.admin.utils.SecurityUtils;
@@ -95,7 +97,7 @@ public class PlayOrderInfoServiceImpl extends ServiceImpl<PlayOrderInfoMapper, P
private IPlayCouponDetailsService playCouponDetailsService;
@Resource
private WxCustomMpService wxCustomMpService;
private NotificationSender notificationSender;
@Resource
private IPlayCustomUserInfoService customUserInfoService;
@@ -644,7 +646,7 @@ public class PlayOrderInfoServiceImpl extends ServiceImpl<PlayOrderInfoMapper, P
orderInfo.setFirstOrder(firstOrderFlag);
log.info("Order accepted successfully. orderId={}, orderNo={}, acceptBy={}, operatorByType={}",
orderId, orderInfo.getOrderNo(), acceptBy, operatorByType);
wxCustomMpService.sendOrderMessageAsync(orderInfo);
notificationSender.sendOrderMessageAsync(orderInfo);
}
private void validateClerkQualificationForRandomOrder(PlayOrderInfoEntity orderInfo,
@@ -835,7 +837,8 @@ public class PlayOrderInfoServiceImpl extends ServiceImpl<PlayOrderInfoMapper, P
playOrderRefundInfoService.add(orderInfo.getId(), orderInfo.getPurchaserBy(), orderInfo.getAcceptBy(),
orderInfo.getPayMethod(), OrderRefundRecordType.FULL.getCode(), orderInfo.getFinalAmount(), refundReason, operatorByType, operatorBy,
OrderRefundState.PROCESSING.getCode(), ReviewRequirement.NOT_REQUIRED.getCode());
wxCustomMpService.sendOrderCancelMessageAsync(orderInfo, refundReason);
restoreCouponsForOrder(orderInfo);
notificationSender.sendOrderCancelMessageAsync(orderInfo, refundReason);
}
/**
@@ -888,8 +891,10 @@ public class PlayOrderInfoServiceImpl extends ServiceImpl<PlayOrderInfoMapper, P
orderInfo.getPayMethod(), forceCancelRefundType.getCode(), actualRefundAmount, refundReason, operatorByType, operatorBy,
OrderRefundState.PROCESSING.getCode(), ReviewRequirement.NOT_REQUIRED.getCode());
restoreCouponsForOrder(orderInfo);
PlayOrderInfoEntity latest = this.selectOrderInfoById(orderId);
wxCustomMpService.sendOrderCancelMessageAsync(latest, refundReason);
notificationSender.sendOrderCancelMessageAsync(latest, refundReason);
}
@Override
@@ -1038,4 +1043,11 @@ public class PlayOrderInfoServiceImpl extends ServiceImpl<PlayOrderInfoMapper, P
return OrderTriggerSource.SYSTEM;
}
}
private void restoreCouponsForOrder(PlayOrderInfoEntity orderInfo) {
if (orderInfo == null || CollectionUtil.isEmpty(orderInfo.getCouponIds())) {
return;
}
playCouponDetailsService.updateCouponUseStateByIds(orderInfo.getCouponIds(), CouponUseState.UNUSED.getCode());
}
}