diff --git a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/XktTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/XktTask.java index 47a99e430..01ebb18b5 100644 --- a/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/XktTask.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/XktTask.java @@ -989,8 +989,8 @@ public class XktTask { StoreOrderRefund storeOrderRefund = storeOrderService.prepareRefundByOriginOrder(storeOrderId); callRefund(storeOrderRefund); } catch (Exception e) { - log.error("自动完成订单异常", e); - fsNotice.sendMsg2DefaultChat("自动完成订单异常", "订单ID:" + storeOrderId); + log.error("自动订单退款异常", e); + fsNotice.sendMsg2DefaultChat("自动订单退款异常", "订单ID:" + storeOrderId); } } log.info("-------------自动订单退款结束-------------"); diff --git a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreOrderServiceImpl.java b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreOrderServiceImpl.java index 76f1a8553..3782d17ad 100644 --- a/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreOrderServiceImpl.java +++ b/xkt/src/main/java/com/ruoyi/xkt/service/impl/StoreOrderServiceImpl.java @@ -400,7 +400,7 @@ public class StoreOrderServiceImpl implements IStoreOrderService { List spIds = detailInfos.stream().map(StoreOrderDetailInfoDTO::getStoreProdId).distinct() .collect(Collectors.toList()); Map mainPicMap = storeProductFileMapper.selectMainPicByStoreProdIdList(spIds, - FileType.MAIN_PIC.getValue(), ORDER_NUM_1).stream() + FileType.MAIN_PIC.getValue(), ORDER_NUM_1).stream() .collect(Collectors.toMap(StoreProdMainPicDTO::getStoreProdId, StoreProdMainPicDTO::getFileUrl, (o, n) -> n)); for (StoreOrderDetailInfoDTO detailInfo : detailInfos) { @@ -444,8 +444,8 @@ public class StoreOrderServiceImpl implements IStoreOrderService { return ListUtil.empty(); } Map printTimeMap = expressShippingLabelMapper.selectList(Wrappers - .lambdaQuery(ExpressShippingLabel.class) - .in(ExpressShippingLabel::getExpressWaybillNo, expressWaybillNos)) + .lambdaQuery(ExpressShippingLabel.class) + .in(ExpressShippingLabel::getExpressWaybillNo, expressWaybillNos)) .stream() .collect(Collectors.toMap(ExpressShippingLabel::getExpressWaybillNo, ExpressShippingLabel::getLastPrintTime)); @@ -484,9 +484,9 @@ public class StoreOrderServiceImpl implements IStoreOrderService { //物流信息 Map expressNameMap = expressService.getAllExpressNameMap(); Map> expressWaybillGroupMap = storeOrderDetailMapper.selectList(Wrappers - .lambdaQuery(StoreOrderDetail.class) - .eq(StoreOrderDetail::getStoreOrderId, storeOrderId) - .eq(SimpleEntity::getDelFlag, Constants.UNDELETED)) + .lambdaQuery(StoreOrderDetail.class) + .eq(StoreOrderDetail::getStoreOrderId, storeOrderId) + .eq(SimpleEntity::getDelFlag, Constants.UNDELETED)) .stream() .filter(o -> StrUtil.isNotEmpty(o.getExpressWaybillNo())) .collect(Collectors.groupingBy(StoreOrderDetail::getExpressWaybillNo)); @@ -557,7 +557,7 @@ public class StoreOrderServiceImpl implements IStoreOrderService { List spIds = orderDetailList.stream().map(StoreOrderDetailInfoDTO::getStoreProdId).distinct() .collect(Collectors.toList()); Map mainPicMap = storeProductFileMapper.selectMainPicByStoreProdIdList(spIds, - FileType.MAIN_PIC.getValue(), ORDER_NUM_1).stream() + FileType.MAIN_PIC.getValue(), ORDER_NUM_1).stream() .collect(Collectors.toMap(StoreProdMainPicDTO::getStoreProdId, StoreProdMainPicDTO::getFileUrl, (o, n) -> n)); Map> orderDetailGroup = orderDetailList @@ -1130,9 +1130,9 @@ public class StoreOrderServiceImpl implements IStoreOrderService { List afterSaleOrderIds = afterSaleOrderList.stream().map(SimpleEntity::getId) .collect(Collectors.toList()); Map> afterSaleOrderDetailGroupMap = storeOrderDetailMapper.selectList( - Wrappers.lambdaQuery(StoreOrderDetail.class) - .in(StoreOrderDetail::getStoreOrderId, afterSaleOrderIds) - .eq(SimpleEntity::getDelFlag, Constants.UNDELETED)) + Wrappers.lambdaQuery(StoreOrderDetail.class) + .in(StoreOrderDetail::getStoreOrderId, afterSaleOrderIds) + .eq(SimpleEntity::getDelFlag, Constants.UNDELETED)) .stream() .filter(o -> { if (!EOrderStatus.AFTER_SALE_COMPLETED.getValue().equals(o.getDetailStatus())) { @@ -1477,17 +1477,21 @@ public class StoreOrderServiceImpl implements IStoreOrderService { throw new ServiceException(Constants.VERSION_LOCK_ERROR_COMMON_MSG); } } - order.setOrderStatus(EOrderStatus.CANCELLED.getValue()); - int orderSuccess = storeOrderMapper.updateById(prepareUpdate(order)); - if (orderSuccess == 0) { - throw new ServiceException(Constants.VERSION_LOCK_ERROR_COMMON_MSG); - } StoreOrderAfterSaleDTO applyDTO = new StoreOrderAfterSaleDTO(); applyDTO.setStoreOrderId(storeOrderId); applyDTO.setStoreOrderDetailIds(details.stream().map(SimpleEntity::getId).collect(Collectors.toList())); applyDTO.setOperatorId(-1L); applyDTO.setRefundReasonCode("超时未发货自动退款"); + //创建售后订单 AfterSaleApplyResultDTO applyResult = createAfterSaleOrder(applyDTO); + //创建售后订单会触发一次乐观锁 + order.setVersion(order.getVersion() + 1); + //原订单取消 + order.setOrderStatus(EOrderStatus.CANCELLED.getValue()); + int orderSuccess = storeOrderMapper.updateById(prepareUpdate(order)); + if (orderSuccess == 0) { + throw new ServiceException(Constants.VERSION_LOCK_ERROR_COMMON_MSG); + } StoreOrderRefundConfirmDTO confirmDTO = new StoreOrderRefundConfirmDTO(); confirmDTO.setStoreOrderId(applyResult.getStoreOrderId()); confirmDTO.setOperatorId(-1L); @@ -1499,9 +1503,9 @@ public class StoreOrderServiceImpl implements IStoreOrderService { public void refundSuccess(Long storeOrderId, List storeOrderDetailIds, Long operatorId) { StoreOrder order = getAndBaseCheck(storeOrderId); Map orderDetailMap = storeOrderDetailMapper.selectList(Wrappers - .lambdaQuery(StoreOrderDetail.class) - .eq(StoreOrderDetail::getStoreOrderId, order.getId()) - .eq(SimpleEntity::getDelFlag, Constants.UNDELETED)) + .lambdaQuery(StoreOrderDetail.class) + .eq(StoreOrderDetail::getStoreOrderId, order.getId()) + .eq(SimpleEntity::getDelFlag, Constants.UNDELETED)) .stream() .collect(Collectors.toMap(SimpleEntity::getId, Function.identity())); for (Long storeOrderDetailId : storeOrderDetailIds) { @@ -1881,8 +1885,8 @@ public class StoreOrderServiceImpl implements IStoreOrderService { .collect(Collectors.toMap(StoreProductColorSize::getId, o -> o)); //下单商品档口颜色 Map scMap = storeColorMapper.selectByIds(spcsMap.values().stream() - .map(StoreProductColorSize::getStoreColorId) - .collect(Collectors.toSet())).stream() + .map(StoreProductColorSize::getStoreColorId) + .collect(Collectors.toSet())).stream() .collect(Collectors.toMap(StoreColor::getId, Function.identity())); //下单商品 List spIdList = spcsMap.values().stream()