Bladeren bron

fix(order): 注释小程序订单相关接口并修正退款循环逻辑

- 注释 AppletOrderController 中所有订单创建、支付、回调、取消和退款接口映射
- 将计费服务中服务费四舍五入方式由向下取整改为四舍五入
- UserOrderInfoServiceImpl 中用户订单查询条件添加按用户ID过滤
- 修改 WFTOrderService 中退款逻辑,使用 continue 替代 break 避免循环提前终止
wzq 1 dag geleden
bovenliggende
commit
282eef584b

+ 17 - 0
src/main/java/com/zsElectric/boot/business/controller/UserInfoController.java

@@ -1,6 +1,10 @@
 package com.zsElectric.boot.business.controller;
 
 import com.zsElectric.boot.business.service.UserInfoService;
+import com.zsElectric.boot.business.service.WFTOrderService;
+import com.zsElectric.boot.common.annotation.Log;
+import com.zsElectric.boot.common.enums.LogModuleEnum;
+import com.zsElectric.boot.security.util.SecurityUtils;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
@@ -32,6 +36,8 @@ public class UserInfoController  {
 
     private final UserInfoService userInfoService;
 
+    private final WFTOrderService wftOrderService;
+
     @Operation(summary = "个人用户信息分页列表")
     @GetMapping("/page")
     @PreAuthorize("@ss.hasPerm('business:user-info:query')")
@@ -40,6 +46,17 @@ public class UserInfoController  {
         return PageResult.success(result);
     }
 
+    /**
+     * 账户退款
+     * @return
+     */
+    @Operation(summary = "账户退款")
+    @PutMapping("/refundOrder")
+    @Log(value = "账户退款", module = LogModuleEnum.APP_ORDER)
+    public Result<String> refundOrder(Long userId) throws Exception {
+        return Result.success(wftOrderService.refundOrder(userId));
+    }
+
     @Operation(summary = "新增个人用户信息")
     @PostMapping
     @PreAuthorize("@ss.hasPerm('business:user-info:add')")

+ 5 - 5
src/main/java/com/zsElectric/boot/business/service/WFTOrderService.java

@@ -798,7 +798,7 @@ public class WFTOrderService {
             if (canRefundMoney.compareTo(refundMoney) >= 0) {
                 //退款金额大于订单金额,则直接退退款金额
                 refundOrder(userOrderInfo,refundMoney, "账户退款", SystemConstants.STATUS_ONE);
-                //账户变动及日志记录
+                //账户变动及日志记录(退款清空账户余额)
                 userAccountService.updateAccountBalanceAndLog(
                         SecurityUtils.getUserId(),
                         refundMoney,
@@ -810,23 +810,23 @@ public class WFTOrderService {
                 userOrderInfo.setOrderStatus(SystemConstants.STATUS_FOUR);
                 userOrderInfoMapper.updateById(userOrderInfo);
                 refundMoney = BigDecimal.ZERO;
-                continue;
+                break;
             }
             if (canRefundMoney.compareTo(refundMoney) < 0) {
                 //退款金额小于订单金额,则先退订单金额
                 refundOrder(userOrderInfo, canRefundMoney, "账户退款", SystemConstants.STATUS_TWO);
-                //账户变动及日志记录
+                //账户变动及日志记录(减少账户余额)
                 userAccountService.updateAccountBalanceAndLog(
                         SecurityUtils.getUserId(),
                         canRefundMoney,
-                        SystemConstants.ACCOUNT_REFUND,
+                        SystemConstants.CHANGE_TYPE_REDUCE,
                         SystemConstants.ACCOUNT_LOG_REFUND_NOTE,
                         userOrderInfo.getId()
                 );
                 //修改订单状态
                 userOrderInfo.setOrderStatus(SystemConstants.STATUS_FOUR);
                 userOrderInfoMapper.updateById(userOrderInfo);
-                refundMoney = refundMoney.subtract(userOrderInfo.getOrderMoney());
+                refundMoney = refundMoney.subtract(canRefundMoney);
             }
         }
         return "账户退款,预计3个工作日内分一笔或多笔退还!到期如未收到,请联系客服处理!";