From 3e64a254550804933633fd88182f20d43dd2e718 Mon Sep 17 00:00:00 2001
From: xin <1099200748@qq.com>
Date: Thu, 25 Sep 2025 21:51:55 +0800
Subject: [PATCH] 订单-汇旺财多账户支付配置
---
oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderReturnServiceImpl.java | 100 ++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 80 insertions(+), 20 deletions(-)
diff --git a/oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderReturnServiceImpl.java b/oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderReturnServiceImpl.java
index 55473c5..a4d2a31 100644
--- a/oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderReturnServiceImpl.java
+++ b/oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderReturnServiceImpl.java
@@ -2,12 +2,17 @@
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;
+import com.oying.modules.sh.domain.OrderReturnProductSnapshot;
import com.oying.modules.sh.domain.request.AuditOrderReturn;
+import com.oying.modules.sh.domain.request.ProductOrder;
import com.oying.modules.sh.domain.request.ReturnOrder;
-import com.oying.modules.sh.service.OrderReturnProductSnapshotService;
-import com.oying.modules.sh.service.OrderService;
+import com.oying.modules.sh.domain.vo.OrderResponse;
+import com.oying.modules.sh.domain.vo.OrderReturnResponse;
+import com.oying.modules.sh.service.*;
import com.oying.utils.*;
import com.oying.utils.enums.GenerateEnum;
import com.oying.utils.enums.OrderStatusEnum;
@@ -16,7 +21,6 @@
import lombok.RequiredArgsConstructor;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.oying.modules.sh.service.OrderReturnService;
import com.oying.modules.sh.domain.dto.OrderReturnQueryCriteria;
import com.oying.modules.sh.mapper.OrderReturnMapper;
import org.springframework.stereotype.Service;
@@ -37,11 +41,16 @@
public class OrderReturnServiceImpl extends ServiceImpl<OrderReturnMapper, OrderReturn> implements OrderReturnService {
private final OrderReturnMapper orderReturnMapper;
+ private final OrderOperationLogService operationLogService;
private final OrderService orderService;
private final OrderReturnProductSnapshotService productSnapshotService;
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;
@Override
public PageResult<OrderReturn> queryAll(OrderReturnQueryCriteria criteria, Page<Object> page) {
@@ -57,19 +66,23 @@
}
@Override
- public OrderReturn getByReturnNum(String returnNum) {
- return orderReturnMapper.getByReturnNum(returnNum);
+ public OrderReturnResponse getByReturnNum(String returnNum) {
+ OrderReturn orderReturn = orderReturnMapper.getByReturnNum(returnNum);
+ return new OrderReturnResponse(orderReturn,
+ addressSnapshotService.queryByOrderNum(orderReturn.getOrderNum()),
+ operationLogService.getByOrderNum(orderReturn.getOrderNum(), ORDER_CODE));
}
@Override
- public void updatePayStatus(String returnNum, String status, String time) {
- orderReturnMapper.updatePayStatus(returnNum, status, time);
+ public void updatePayStatus(String returnNum, String refundStatus, String successTime) {
+ orderReturnMapper.updatePayStatus(returnNum, refundStatus, successTime);
}
@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("订单不存在!");
}
@@ -78,13 +91,13 @@
}
OrderReturn returnOrder1 = orderReturnMapper.getByOrderNum(resources.getOrderNum(), ReturnAuditEnum.ZERO.getKey());
if (returnOrder1 != null) {
- throw new BadRequestException("退款订单已提交");
+ throw new BadRequestException("申请已提交");
}
OrderReturn returnOrder2 = orderReturnMapper.getByOrderNum(resources.getOrderNum(), ReturnAuditEnum.TWO.getKey());
if (returnOrder2 != null) {
throw new BadRequestException("退款订单已处理");
}
- if (!DateUtil.isBefore(order.getPayTime(), DateUtil.DAY)) {
+ if (!DateUtil.isBefore(order.getPayTime(), DAY)) {
throw new BadRequestException("订单已超过售后有效期");
}
// 退款订单
@@ -92,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());
@@ -117,7 +130,56 @@
returnOrder.setPhotos(resources.getPhotos());
returnOrder.setAuditStatus(ReturnAuditEnum.ZERO.getKey());
orderReturnMapper.insert(returnOrder);
+ List<OrderReturnProductSnapshot> productSnapshots = new ArrayList<>();
+ for (ProductOrder productOrder : resources.getProductOrders()) {
+ for (OrderProductSnapshot snapshot : order.getProductSnapshots()) {
+ if (productOrder.getProductId().equals(snapshot.getProductId())) {
+ OrderReturnProductSnapshot productSnapshot = getSnapshot(snapshot, returnNum);
+ productSnapshots.add(productSnapshot);
+ }
+ }
+ }
+ productSnapshotService.saveBatch(productSnapshots);
+ operationLogService.create(response, OrderStatusEnum.TEN, null);
+ }
+ private static OrderReturnProductSnapshot getSnapshot(OrderProductSnapshot snapshot, String returnNum) {
+ OrderReturnProductSnapshot productSnapshot = new OrderReturnProductSnapshot();
+ productSnapshot.setReturnNum(returnNum);
+ productSnapshot.setStoreId(snapshot.getStoreId());
+ productSnapshot.setProductId(snapshot.getProductId());
+ productSnapshot.setProductCode(snapshot.getProductCode() != null ? snapshot.getProductCode() : null);
+ productSnapshot.setProductBarcode(snapshot.getProductBarcode());
+ productSnapshot.setProductName(snapshot.getProductName());
+ productSnapshot.setProductTitle(snapshot.getProductTitle());
+ productSnapshot.setProductMainImage(snapshot.getProductMainImage());
+ productSnapshot.setProductDescription(snapshot.getProductDescription());
+ productSnapshot.setParamData(snapshot.getParamData() != null ? snapshot.getParamData() : null);
+ productSnapshot.setUnitPrice(snapshot.getUnitPrice());
+ productSnapshot.setDetailCount(snapshot.getDetailCount());
+ productSnapshot.setOriginalPrice(snapshot.getOriginalPrice());
+ productSnapshot.setPaidPrice(snapshot.getPaidPrice());
+ productSnapshot.setActuallyPayPrice(snapshot.getActuallyPayPrice());
+ return productSnapshot;
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void cancel(String returnNum) {
+ OrderReturn orderReturn = orderReturnMapper.getByReturnNum(returnNum);
+ if (orderReturn == null) {
+ throw new BadRequestException("申请不存在!");
+ }
+ if (!orderReturn.getUserId().equals(SecurityUtils.getCurrentUserId())) {
+ throw new BadRequestException("不能修改他人申请");
+ }
+ if (orderReturn.getAuditStatus().equals(ReturnAuditEnum.ONE.getKey())) {
+ throw new BadRequestException("申请已拒绝");
+ }
+ orderReturnMapper.updateStatus(returnNum, OrderStatusEnum.FIFTEEN.getKey(), OrderStatusEnum.FIFTEEN.getValue(),
+ ReturnAuditEnum.THREE.getKey());
+ OrderResponse response = orderService.getByOrderNum(orderReturn.getOrderNum());
+ operationLogService.create(response, OrderStatusEnum.FIFTEEN, null);
}
@Override
@@ -133,10 +195,10 @@
public synchronized void audit(AuditOrderReturn resources) {
OrderReturn orderReturn = orderReturnMapper.getByReturnNum(resources.getReturnNum());
if (orderReturn == null) {
- throw new BadRequestException("订单不存在");
+ throw new BadRequestException("申请不存在!");
}
if (!Objects.equals(orderReturn.getReturnStatus(), ReturnAuditEnum.ZERO.getKey())) {
- throw new BadRequestException("订单已处理或取消");
+ throw new BadRequestException("申请已处理或取消");
}
if (resources.getAmount().compareTo(orderReturn.getActuallyPayPrice()) > 0) {
throw new BadRequestException("退款金额超过订单金额");
@@ -152,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);
@@ -160,6 +223,9 @@
break;
default:
throw new BadRequestException("暂未开通其余支付模式");
+ }
+ for (OrderReturnProductSnapshot snapshot : orderReturn.getProductSnapshots()) {
+ productInventoryService.increaseStock(snapshot.getProductId(), snapshot.getDetailCount());
}
break;
default:
@@ -174,12 +240,6 @@
// 审核信息
orderReturn.setAuditMessage(resources.getMessage());
orderReturnMapper.updateById(orderReturn);
- }
-
- @Override
- @Transactional(rollbackFor = Exception.class)
- public void deleteAll(List<Long> ids) {
- orderReturnMapper.deleteBatchIds(ids);
}
@Override
--
Gitblit v1.9.3