|
@@ -5,6 +5,8 @@ import cn.hutool.core.util.RandomUtil;
|
|
|
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
|
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
|
import cn.iocoder.yudao.framework.common.util.object.ObjectUtils;
|
|
|
+import cn.iocoder.yudao.framework.trade.core.dto.TradeAfterSaleLogDTO;
|
|
|
+import cn.iocoder.yudao.framework.trade.core.service.AfterSaleLogService;
|
|
|
import cn.iocoder.yudao.module.pay.api.refund.PayRefundApi;
|
|
|
import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO;
|
|
|
import cn.iocoder.yudao.module.trade.controller.admin.aftersale.vo.TradeAfterSaleDisagreeReqVO;
|
|
@@ -26,6 +28,8 @@ import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEn
|
|
|
import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum;
|
|
|
import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties;
|
|
|
import cn.iocoder.yudao.module.trade.service.order.TradeOrderService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.transaction.support.TransactionSynchronization;
|
|
@@ -43,9 +47,10 @@ import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*;
|
|
|
*
|
|
|
* @author 芋道源码
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
@Validated
|
|
|
-public class TradeAfterSaleServiceImpl implements TradeAfterSaleService {
|
|
|
+public class TradeAfterSaleServiceImpl implements TradeAfterSaleService, AfterSaleLogService {
|
|
|
|
|
|
@Resource
|
|
|
private TradeOrderService tradeOrderService;
|
|
@@ -80,7 +85,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService {
|
|
|
/**
|
|
|
* 校验交易订单项是否可以申请售后
|
|
|
*
|
|
|
- * @param userId 用户编号
|
|
|
+ * @param userId 用户编号
|
|
|
* @param createReqVO 售后创建信息
|
|
|
* @return 交易订单项
|
|
|
*/
|
|
@@ -117,7 +122,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService {
|
|
|
}
|
|
|
// 如果是【退货退款】的情况,需要额外校验是否发货
|
|
|
if (createReqVO.getWay().equals(TradeAfterSaleWayEnum.RETURN_AND_REFUND.getWay())
|
|
|
- && !TradeOrderStatusEnum.haveDelivered(order.getStatus())) {
|
|
|
+ && !TradeOrderStatusEnum.haveDelivered(order.getStatus())) {
|
|
|
throw exception(AFTER_SALE_CREATE_FAIL_ORDER_STATUS_NO_DELIVERED);
|
|
|
}
|
|
|
return orderItem;
|
|
@@ -133,7 +138,7 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService {
|
|
|
TradeOrderDO order = tradeOrderService.getOrder(orderItem.getUserId(), orderItem.getOrderId());
|
|
|
afterSale.setOrderNo(order.getNo()); // 记录 orderNo 订单流水,方便后续检索
|
|
|
afterSale.setType(TradeOrderStatusEnum.isCompleted(order.getStatus())
|
|
|
- ? TradeAfterSaleTypeEnum.AFTER_SALE.getType() : TradeAfterSaleTypeEnum.IN_SALE.getType());
|
|
|
+ ? TradeAfterSaleTypeEnum.AFTER_SALE.getType() : TradeAfterSaleTypeEnum.IN_SALE.getType());
|
|
|
// TODO 退还积分
|
|
|
tradeAfterSaleMapper.insert(afterSale);
|
|
|
|
|
@@ -380,13 +385,38 @@ public class TradeAfterSaleServiceImpl implements TradeAfterSaleService {
|
|
|
TradeOrderItemAfterSaleStatusEnum.NONE.getStatus(), null);
|
|
|
}
|
|
|
|
|
|
+ @Deprecated
|
|
|
private void createAfterSaleLog(Long userId, Integer userType, TradeAfterSaleDO afterSale,
|
|
|
Integer beforeStatus, Integer afterStatus) {
|
|
|
- TradeAfterSaleLogDO afterSaleLog = new TradeAfterSaleLogDO().setUserId(userId).setUserType(userType)
|
|
|
- .setAfterSaleId(afterSale.getId()).setOrderId(afterSale.getOrderId())
|
|
|
- .setOrderItemId(afterSale.getOrderItemId()).setBeforeStatus(beforeStatus).setAfterStatus(afterStatus)
|
|
|
- .setContent(TradeAfterSaleStatusEnum.valueOf(afterStatus).getContent());
|
|
|
- tradeAfterSaleLogMapper.insert(afterSaleLog);
|
|
|
+ TradeAfterSaleLogDTO logDTO = new TradeAfterSaleLogDTO()
|
|
|
+ .setUserId(userId)
|
|
|
+ .setUserType(userType)
|
|
|
+ .setAfterSaleId(afterSale.getId())
|
|
|
+ .setOperateType(afterStatus.toString());
|
|
|
+ // TODO 废弃,待删除
|
|
|
+ this.insert(logDTO);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 日志记录
|
|
|
+ *
|
|
|
+ * @param logDTO 日志记录
|
|
|
+ * @author 陈賝
|
|
|
+ * @date 2023/6/12 14:18
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @Async
|
|
|
+ public void insert(TradeAfterSaleLogDTO logDTO) {
|
|
|
+ try {
|
|
|
+ TradeAfterSaleLogDO afterSaleLog = new TradeAfterSaleLogDO()
|
|
|
+ .setUserId(logDTO.getUserId())
|
|
|
+ .setUserType(logDTO.getUserType())
|
|
|
+ .setAfterSaleId(logDTO.getAfterSaleId())
|
|
|
+ .setOperateType(logDTO.getOperateType())
|
|
|
+ .setContent(logDTO.getContent());
|
|
|
+ tradeAfterSaleLogMapper.insert(afterSaleLog);
|
|
|
+ }catch (Exception exception){
|
|
|
+ log.error("日志记录错误", exception);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|