xin
2025-09-30 f851d945daefb90a476a71cb2769515298be5d77
oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderReturnServiceImpl.java
@@ -2,6 +2,7 @@
import com.oying.exception.BadRequestException;
import com.oying.modules.hwc.service.SwiftPassService;
import com.oying.modules.pc.product.service.ProductInventoryService;
import com.oying.modules.sh.domain.Order;
import com.oying.modules.sh.domain.OrderProductSnapshot;
import com.oying.modules.sh.domain.OrderReturn;
@@ -46,6 +47,7 @@
    private final RedisUtils redisUtils;
    private final SwiftPassService swiftPassService;
    private final OrderAddressSnapshotService addressSnapshotService;
    private final ProductInventoryService productInventoryService;
    private static final String ORDER_RETURN_KEY = "oying:order:refund";
    private static final String ORDER_CODE = "REFUND";
    public static final Integer DAY = 30;
@@ -79,7 +81,8 @@
    @Override
    @Transactional(rollbackFor = Exception.class)
    public synchronized void create(ReturnOrder resources) {
        Order order = orderService.queryByOrderNum(resources.getOrderNum());
        OrderResponse response = orderService.getByOrderNum(resources.getOrderNum());
        Order order = response.getOrder();
        if (order == null) {
            throw new BadRequestException("订单不存在!");
        }
@@ -102,8 +105,8 @@
        // 退款订单号
        String returnNum = redisUtils.generateSn(ORDER_RETURN_KEY, GenerateEnum.ORDER_RETURN.getKey());
        returnOrder.setReturnNum(returnNum);
        returnOrder.setReturnStatus(ReturnAuditEnum.ZERO.getKey());
        returnOrder.setReturnStatusDescribe(ReturnAuditEnum.ZERO.getValue());
        returnOrder.setReturnStatus(OrderStatusEnum.TEN.getKey());
        returnOrder.setReturnStatusDescribe(OrderStatusEnum.TEN.getValue());
        returnOrder.setOrderNum(resources.getOrderNum());
        returnOrder.setOrderTime(order.getOrderTime());
        returnOrder.setOrderStoreNum(order.getOrderStoreNum());
@@ -137,6 +140,7 @@
            }
        }
        productSnapshotService.saveBatch(productSnapshots);
        operationLogService.create(response, OrderStatusEnum.TEN, null);
    }
    private static OrderReturnProductSnapshot getSnapshot(OrderProductSnapshot snapshot, String returnNum) {
@@ -210,6 +214,7 @@
                switch (status) {
                    case HWC:
                    case HWC2:
                    case HWC3:
                        if (refund > 0) {
                            Map<String, String> re = swiftPassService.refund(orderReturn.getReturnNum(), orderReturn.getOrderNum(),
                                    resources.getMessage(), refund, total, status);
@@ -219,6 +224,9 @@
                    default:
                        throw new BadRequestException("暂未开通其余支付模式");
                }
                for (OrderReturnProductSnapshot snapshot : orderReturn.getProductSnapshots()) {
                    productInventoryService.increaseStock(snapshot.getProductId(), snapshot.getDetailCount());
                }
                break;
            default:
                throw new BadRequestException("审核状态错误");