Quellcode durchsuchen

优化微信退款

lighter vor 1 Jahr
Ursprung
Commit
e28b80159f

+ 2 - 0
src/main/java/thyyxxk/webserver/entity/outpatient/wxapi/RefundParam.java

@@ -19,6 +19,8 @@ public class RefundParam {
     // 总金额
     @DecimalMin(value = "0", message = "总金额不能小于等于零。")
     private BigDecimal totalFee;
+    @DecimalMin(value = "0", message = "总金额不能小于等于零。")
+    private BigDecimal cashpayAmt;
     // 交易订单号
     @NotBlank(message = "交易订单号不能为空。")
     private String tradeNo;

+ 4 - 0
src/main/java/thyyxxk/webserver/entity/outpatient/wxapi/WxPayOrder.java

@@ -17,6 +17,10 @@ public class WxPayOrder {
     private String openid;
     // 总金额
     private BigDecimal totalFee;
+    private BigDecimal fundpayAmt;
+    private BigDecimal acctpayAmt;
+    private BigDecimal couponAmt;
+    private BigDecimal cashpayAmt;
     // 门诊ID
     private String patientId;
     // 患者姓名

+ 6 - 5
src/main/java/thyyxxk/webserver/service/outpatient/wxapi/WxApiService.java

@@ -85,15 +85,16 @@ public class WxApiService {
         log.info("退款申请:{}", JSON.toJSONStringWithDateFormat(param, "yyyy-MM-dd HH:mm:ss"));
         String nonceStr = SnowFlakeId.instance().nextId();
         String outRefundNo = SnowFlakeId.instance().nextId();
-        String refundFee = DecimalUtil.moneyYuanToFen(param.getTotalFee());
+        String totalFee = DecimalUtil.moneyYuanToFen(param.getTotalFee());
+        String cashpayAmt = DecimalUtil.moneyYuanToFen(param.getCashpayAmt());
         TreeMap<String, String> map = new TreeMap<>();
         map.put("appid", WxCertUtil.APP_ID);
         map.put("mch_id", WxCertUtil.MERCHANT_ID);
         map.put("nonce_str", nonceStr);
         map.put("out_refund_no", outRefundNo);
         map.put("out_trade_no", param.getTradeNo());
-        map.put("refund_fee", refundFee);
-        map.put("total_fee", refundFee);
+        map.put("refund_fee", cashpayAmt);
+        map.put("total_fee", totalFee);
         String refundSign = Md5Util.createWxPaySign(map);
         String xml = "<xml>" +
                 "<appid>" + WxCertUtil.APP_ID + "</appid>" +
@@ -101,8 +102,8 @@ public class WxApiService {
                 "<nonce_str>" + nonceStr + "</nonce_str>" +
                 "<out_refund_no>" + outRefundNo + "</out_refund_no>" +
                 "<out_trade_no>" + param.getTradeNo() + "</out_trade_no>" +
-                "<refund_fee>" + refundFee + "</refund_fee>" +
-                "<total_fee>" + refundFee + "</total_fee>" +
+                "<refund_fee>" + cashpayAmt + "</refund_fee>" +
+                "<total_fee>" + totalFee + "</total_fee>" +
                 "<sign>" + refundSign + "</sign>" +
                 "</xml>";
         String str = requestWithSsl(xml);