Jelajahi Sumber

退款原因

skyline 2 tahun lalu
induk
melakukan
d39df72eeb

+ 3 - 3
miniapp/src/main/java/com/kym/miniapp/controller/PaymentController.java

@@ -41,10 +41,10 @@ public class PaymentController {
 
 
     @ApiLog("用户申请退款")
-    @GetMapping("/wxApplyRefund")
+    @PostMapping("/wxApplyRefund")
     @ResponseBody
-    R<?> wxAppRefund() {
-        wxPayService.applyWxRefund();
+    R<?> wxAppRefund(@RequestBody String reason) {
+        wxPayService.applyWxRefund(reason);
         return R.success();
     }
 

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

@@ -6,7 +6,6 @@ import com.kym.entity.wechat.*;
 import com.wechat.pay.java.service.payments.jsapi.model.PrepayWithRequestPaymentResponse;
 import com.wechat.pay.java.service.refund.model.Refund;
 import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
 import lombok.SneakyThrows;
 import org.springframework.http.ResponseEntity;
 
@@ -19,7 +18,7 @@ import java.util.Map;
  * @date 2023-08-11 19:05
  */
 public interface WxPayService {
-    void applyWxRefund();
+    void applyWxRefund(String reason);
 
     void wxRefund(long refundLogId);
 

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

@@ -371,7 +371,7 @@ public class WxPayServiceImpl implements WxPayService {
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public void applyWxRefund() {
+    public void applyWxRefund(String reason) {
         var userId = StpUtil.getLoginIdAsLong();
         var chargeOrder = chargeOrderService.getChargingOrderByUserId(userId);
         if (chargeOrder != null) {
@@ -451,6 +451,7 @@ public class WxPayServiceImpl implements WxPayService {
                     discountAmount = account.getDiscountAmount() - refundLogList.stream().mapToInt(RefundLog::getDiscountAmount).sum();
                 }
                 refundLog.setDiscountAmount(discountAmount);
+                refundLog.setReason(reason);
                 newRefundLogList.add(index, refundLog);
             }));