Răsfoiți Sursa

财务相关接口调整

skyline 1 an în urmă
părinte
comite
963016045d

+ 5 - 24
car-wash-admin/src/main/java/com/kym/admin/controller/CustomController.java

@@ -5,10 +5,11 @@ import com.kym.common.R;
 import com.kym.common.annotation.SysLog;
 import com.kym.entity.queryParams.CommonQueryParam;
 import com.kym.service.PayLogService;
-import com.kym.service.RefundLogService;
 import com.kym.service.UserService;
-import com.kym.service.wechat.WxPayService;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.ModelAttribute;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
 
 /**
  * 用户相关信息
@@ -23,15 +24,10 @@ public class CustomController {
     private final UserService customUserService;
     private final PayLogService payLogService;
 
-    private final RefundLogService refundLogService;
 
-    private final WxPayService wxPayService;
-
-    public CustomController(UserService customUserService, PayLogService payLogService, RefundLogService refundLogService, WxPayService wxPayService) {
+    public CustomController(UserService customUserService, PayLogService payLogService) {
         this.customUserService = customUserService;
         this.payLogService = payLogService;
-        this.refundLogService = refundLogService;
-        this.wxPayService = wxPayService;
     }
 
     @SaCheckPermission("account.list")
@@ -47,19 +43,4 @@ public class CustomController {
         return R.success(payLogService.listRecharge(params));
     }
 
-    @SysLog("退款记录列表")
-    @GetMapping("/listRefundLog")
-    public R<?> listRefundLog(@ModelAttribute CommonQueryParam params) {
-        return R.success(refundLogService.listRefundLog(params));
-    }
-
-
-    @SysLog("用户退款申请")
-    @PostMapping("/applyRefund")
-    @ResponseBody
-    R<?> wxAppRefund(@RequestParam String reason) {
-        wxPayService.applyWxRefund(reason);
-        return R.success();
-    }
-
 }

+ 55 - 8
car-wash-admin/src/main/java/com/kym/admin/controller/FinanceController.java

@@ -1,16 +1,15 @@
 package com.kym.admin.controller;
 
 import com.kym.common.R;
-import com.kym.entity.queryParams.SplitRecordQueryParams;
-import com.kym.entity.queryParams.StationQueryParam;
-import com.kym.entity.queryParams.WithdrawnQueryParam;
+import com.kym.common.annotation.SysLog;
+import com.kym.entity.queryParams.*;
+import com.kym.service.RefundLogService;
 import com.kym.service.SplitRecordService;
 import com.kym.service.StationAccountService;
 import com.kym.service.WithdrawnRecordService;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import com.kym.service.wechat.WxPayService;
+import jakarta.validation.Valid;
+import org.springframework.web.bind.annotation.*;
 
 /**
  * 财务
@@ -26,10 +25,17 @@ public class FinanceController {
     private final StationAccountService stationAccountService;
     private final WithdrawnRecordService withdrawnRecordService;
 
-    public FinanceController(SplitRecordService splitRecordService, StationAccountService stationAccountService, WithdrawnRecordService withdrawnRecordService) {
+    private final WxPayService wxPayService;
+
+    private final RefundLogService refundLogService;
+
+    public FinanceController(SplitRecordService splitRecordService, StationAccountService stationAccountService,
+                             WithdrawnRecordService withdrawnRecordService, WxPayService wxPayService, RefundLogService refundLogService) {
         this.splitRecordService = splitRecordService;
         this.stationAccountService = stationAccountService;
         this.withdrawnRecordService = withdrawnRecordService;
+        this.wxPayService = wxPayService;
+        this.refundLogService = refundLogService;
     }
 
     /**
@@ -102,4 +108,45 @@ public class FinanceController {
     }
 
 
+    /**
+     * 处理用户退款
+     *
+     * @param refundLogId
+     * @return
+     */
+    @SysLog("处理用户微信退款")
+    @GetMapping("/customWxRefund/{refundLogId}")
+    R<?> customWxRefund(@PathVariable("refundLogId") long refundLogId) {
+        wxPayService.wxRefund(refundLogId);
+        return R.success();
+    }
+
+    /**
+     * 退款记录列表
+     *
+     * @param params
+     * @return
+     */
+    @SysLog("退款记录列表")
+    @GetMapping("/listRefundLog")
+    public R<?> listRefundLog(@ModelAttribute CommonQueryParam params) {
+        return R.success(refundLogService.listRefundLog(params));
+    }
+
+
+    /**
+     * 处理用户退款
+     *
+     * @param param
+     * @return
+     */
+    @SysLog("用户退款申请")
+    @PostMapping("/applyRefund")
+    @ResponseBody
+    R<?> wxAppRefund(@Valid @RequestBody RefundParam param) {
+        wxPayService.applyWxRefund(param.getUserId(), param.getReason());
+        return R.success();
+    }
+
+
 }

+ 25 - 0
car-wash-entity/src/main/java/com/kym/entity/queryParams/RefundParam.java

@@ -0,0 +1,25 @@
+package com.kym.entity.queryParams;
+
+import jakarta.validation.Valid;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+/**
+ * 退款参数
+ */
+@Data
+@Accessors(chain = true)
+public class RefundParam {
+
+    /**
+     * 用户id
+     */
+    @NotNull
+    private Long userId;
+
+    /**
+     * 退款原因
+     */
+    private String reason;
+}

+ 2 - 1
car-wash-miniapp/src/main/java/com/kym/miniapp/controller/PaymentController.java

@@ -1,5 +1,6 @@
 package com.kym.miniapp.controller;
 
+import cn.dev33.satoken.stp.StpUtil;
 import com.kym.common.R;
 import com.kym.common.annotation.ApiLog;
 import com.kym.service.wechat.WxPayService;
@@ -49,7 +50,7 @@ public class PaymentController {
     @PostMapping("/wxApplyRefund")
     @ResponseBody
     R<?> wxAppRefund(@RequestParam String reason) {
-        wxPayService.applyWxRefund(reason);
+        wxPayService.applyWxRefund(StpUtil.getLoginIdAsLong(), reason);
         return R.success();
     }
 

+ 1 - 1
car-wash-service/src/main/java/com/kym/service/wechat/WxPayService.java

@@ -16,7 +16,7 @@ import java.util.Map;
  * @date 2023-08-11 19:05
  */
 public interface WxPayService {
-    void applyWxRefund(String reason);
+    void applyWxRefund(Long userId,String reason);
 
     void wxRefund(long refundLogId);
 

+ 2 - 2
car-wash-service/src/main/java/com/kym/service/wechat/impl/WxPayServiceImpl.java

@@ -402,8 +402,8 @@ public class WxPayServiceImpl implements WxPayService {
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void applyWxRefund(String reason) {
-        var userId = StpUtil.getLoginIdAsLong();
+    public void applyWxRefund(Long userId,String reason) {
+//        var userId = StpUtil.getLoginIdAsLong();
         var washOrder = washOrderService.getOrderInProgressByUserId(userId);
         // 洗车未完结订单校验
         if (washOrder != null) {