|
|
@@ -1,6 +1,7 @@
|
|
|
package com.ylx.massage.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
@@ -37,6 +38,7 @@ import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.temporal.ChronoUnit;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* 商品订单信息Service实现类
|
|
|
@@ -598,6 +600,22 @@ public class ProductOrderInfoServiceImpl extends ServiceImpl<ProductOrderInfoMap
|
|
|
}
|
|
|
|
|
|
// 5. 修改售后单
|
|
|
+ // 先查询是否存在符合条件的售后单
|
|
|
+ LambdaQueryWrapper<AfterSaleOrder> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(AfterSaleOrder::getOrderId, productOrderInfo.getId())
|
|
|
+ .eq(AfterSaleOrder::getOpenId, loginUser.getCOpenid())
|
|
|
+ .ne(AfterSaleOrder::getAfterSaleStatus, AfterSaleStatusEnum.CANCELLED.getCode());
|
|
|
+
|
|
|
+ List<AfterSaleOrder> afterSaleOrders = this.afterSaleOrderService.list(queryWrapper);
|
|
|
+ log.info("订单{}的售后单列表:{}", productOrderInfo.getId(), afterSaleOrders);
|
|
|
+
|
|
|
+ if (CollectionUtil.isEmpty(afterSaleOrders)) {
|
|
|
+ log.warn("订单{}没有符合条件的售后单,跳过售后单状态更新", productOrderInfo.getId());
|
|
|
+ // 没有售后单的情况,不抛出异常,直接返回
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新售后单状态
|
|
|
LambdaUpdateWrapper<AfterSaleOrder> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper.eq(AfterSaleOrder::getOrderId, productOrderInfo.getId())
|
|
|
.eq(AfterSaleOrder::getOpenId, loginUser.getCOpenid())
|
|
|
@@ -607,8 +625,10 @@ public class ProductOrderInfoServiceImpl extends ServiceImpl<ProductOrderInfoMap
|
|
|
|
|
|
boolean afterSaleUpdateResult = this.afterSaleOrderService.update(updateWrapper);
|
|
|
if (!afterSaleUpdateResult) {
|
|
|
+ log.error("售后单状态变更失败,订单ID:{},售后单列表:{}", productOrderInfo.getId(), afterSaleOrders);
|
|
|
throw new ServiceException("售后单状态变更失败");
|
|
|
}
|
|
|
+ log.info("售后单状态更新成功,订单ID:{}", productOrderInfo.getId());
|
|
|
|
|
|
}
|
|
|
|