浏览代码

充值流程

wujiefeng 1 年之前
父节点
当前提交
09ac3de1a1

+ 35 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/model/param/AmountUpdateParam.java

@@ -0,0 +1,35 @@
+package com.zhongshu.payment.client.model.param;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+/**
+ * @author wjf
+ * @date 2024/7/29
+ */
+@Data
+public class AmountUpdateParam {
+
+    @Schema(description = "oid")
+    private String oid;
+
+    @Schema(description = "用户id")
+    private String userId;
+
+    @Schema(description = "商户id")
+    private String shopId;
+
+    @Schema(description = "学校id")
+    private String schoolId;
+
+    @Schema(description = "交易金额")
+    private BigDecimal total = BigDecimal.ZERO;
+
+    @Schema(description = "订单号")
+    private String outTradeNo;
+
+    @Schema(description = "附加信息")
+    private String attach;
+}

+ 6 - 3
PaymentClient/src/main/java/com/zhongshu/payment/client/model/param/RechargeParam.java

@@ -11,10 +11,13 @@ import lombok.Data;
 @Data
 public class RechargeParam {
 
-    @Schema(name = "oid", description = "项目id",required = true, example = "oid")
+    @Schema(name = "oid", description = "项目id",required = true, example = "")
     private String oid;
 
-    @Schema(name = "walletId", description = "钱包id",required = true, example = "oid")
+    @Schema(name = "oid", description = "学校id",required = true, example = "")
+    private String schoolId;
+
+    @Schema(name = "walletId", description = "钱包id",required = true, example = "")
     private String walletId;
 
     @Schema(name = "paymentType", description = "支付方式", required = true, example = "WeChat")
@@ -25,7 +28,7 @@ public class RechargeParam {
     private String description;
 
     // 订单金额(必填)
-    @Schema(name = "amount", description = "订单金额",required = true, example = "{\"total\":100,\"currency\":\"CNY\"}")
+    @Schema(name = "amount", description = "订单金额",required = true, example = "{\"total\":1,\"currency\":\"CNY\"}")
     private Integer total;
 
 //    @Schema(name = "jscode", description = "微信用户授权码", example = "123456")

+ 38 - 17
PaymentClient/src/main/java/com/zhongshu/payment/client/service/WalletFeignService.java

@@ -2,16 +2,16 @@ package com.zhongshu.payment.client.service;
 
 import com.zhongshu.payment.client.model.WalletFlowModel;
 import com.zhongshu.payment.client.model.WalletModel;
+import com.zhongshu.payment.client.model.param.AmountUpdateParam;
 import com.zhongshu.payment.client.ret.ResultContent;
-import com.zhongshu.payment.client.types.TradeType;
 import com.zhongshu.payment.client.types.WalletType;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestParam;
 
-import java.math.BigDecimal;
 import java.util.List;
 
 /**
@@ -25,25 +25,46 @@ public interface WalletFeignService {
     @RequestMapping(value = "getWallet", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
     WalletModel getWallet(@RequestParam("oid") String oid, @RequestParam("walletType") WalletType walletType, @RequestParam("shopId") String shopId, @RequestParam ("userId")String userId);
 
-//    /** 消费/退款 */
-//    @RequestMapping(value = "tradeWallet", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
-//    ResultContent tradeWallet(@RequestBody WalletFlowModel param);
+    /** 充值 */
+    @RequestMapping(value = "recharge", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
+    ResultContent recharge(@RequestBody AmountUpdateParam param);
+
+    /** 消费 */
+    @RequestMapping(value = "consume", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
+    ResultContent consume(@RequestBody AmountUpdateParam param);
+
+    /** 用户发起退款 */
+    @RequestMapping(value = "frozen", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
+    ResultContent frozen(@RequestBody AmountUpdateParam param);
 
-    /** 增加可用余额 */
-    @RequestMapping(value = "addAmount", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
-    ResultContent addAmount(@RequestParam("walletId")String walletId, @RequestParam("total") BigDecimal total, @RequestParam("outTradeNo") String outTradeNo, @RequestParam("type") TradeType type, @RequestParam("total")String attach);
+    /** 退款(审批失败/取消) */
+    @RequestMapping(value = "cancelFrozen", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
+    ResultContent cancelFrozen(@RequestBody AmountUpdateParam param);
 
-    /** 增加总金额 */
-    @RequestMapping(value = "addTotalAmount", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
-    ResultContent addTotalAmount(@RequestParam("walletId")String walletId, @RequestParam("total") BigDecimal total, @RequestParam("outTradeNo") String outTradeNo, @RequestParam("type") TradeType type, @RequestParam("total")String attach);
+    /** 退款(审批通过) */
+    @RequestMapping(value = "refund", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
+    ResultContent refund(@RequestBody AmountUpdateParam param);
 
-    /** 减少可用余额 */
-    @RequestMapping(value = "subtractAmount", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
-    ResultContent subtractAmount(@RequestParam("walletId")String walletId, @RequestParam("total") BigDecimal total, @RequestParam("outTradeNo") String outTradeNo, @RequestParam("type") TradeType type, @RequestParam("total")String attach);
 
-    /** 减少总金额 */
-    @RequestMapping(value = "subtractTotalAmount", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
-    ResultContent subtractTotalAmount(@RequestParam("walletId")String walletId, @RequestParam("total") BigDecimal total, @RequestParam("outTradeNo") String outTradeNo, @RequestParam("type") TradeType type, @RequestParam("total")String attach);
+//    /** 消费/退款 */
+//    @RequestMapping(value = "tradeWallet", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
+//    ResultContent tradeWallet(@RequestBody WalletFlowModel param);
+
+//    /** 增加可用余额 */
+//    @RequestMapping(value = "addAmount", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
+//    ResultContent addAmount(@RequestParam("walletId")String walletId, @RequestParam("total") BigDecimal total, @RequestParam("outTradeNo") String outTradeNo, @RequestParam("type") TradeType type, @RequestParam("attach")String attach);
+//
+//    /** 增加总金额 */
+//    @RequestMapping(value = "addTotalAmount", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
+//    ResultContent addTotalAmount(@RequestParam("walletId")String walletId, @RequestParam("total") BigDecimal total, @RequestParam("outTradeNo") String outTradeNo, @RequestParam("type") TradeType type, @RequestParam("attach")String attach);
+//
+//    /** 减少可用余额 */
+//    @RequestMapping(value = "subtractAmount", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
+//    ResultContent subtractAmount(@RequestParam("walletId")String walletId, @RequestParam("total") BigDecimal total, @RequestParam("outTradeNo") String outTradeNo, @RequestParam("type") TradeType type, @RequestParam("attach")String attach);
+//
+//    /** 减少总金额 */
+//    @RequestMapping(value = "subtractTotalAmount", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
+//    ResultContent subtractTotalAmount(@RequestParam("walletId")String walletId, @RequestParam("total") BigDecimal total, @RequestParam("outTradeNo") String outTradeNo, @RequestParam("type") TradeType type, @RequestParam("attach")String attach);
 
     /** 查询钱包流水 */
     List<WalletFlowModel> queryWalletFlow(String walletId);

+ 2 - 2
PaymentClient/src/main/java/com/zhongshu/payment/client/types/TradeType.java

@@ -10,12 +10,12 @@ import lombok.Getter;
 public enum TradeType {
 
     Pay("消费"),
-//    INCOME("收入"),
+    InCome("收入"),
     Refund("退款"),
     Frozen("冻结"),
     CancelFrozen("取消冻结"),
     Take("提现"),
-    InCome("充值")
+    Charge("充值")
     ;
 
     @Getter

+ 4 - 1
PaymentServer/src/main/java/com/zhongshu/payment/server/core/controller/WalletController.java

@@ -2,6 +2,7 @@ package com.zhongshu.payment.server.core.controller;
 
 import com.zhongshu.payment.client.types.WalletType;
 import com.zhongshu.payment.server.core.service.wallet.WalletService;
+import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,14 +22,16 @@ public class WalletController {
     WalletService walletService;
 
     /** 获取钱包微信授权状态 */
+    @Operation(summary = "获取钱包微信授权状态", description = "获取钱包微信授权状态")
     @GetMapping("getWeChatAuthState")
     public Object getWeChatAuthState(@RequestParam(name = "walletId") String walletId){
         return walletService.getWeChatAuthState(walletId);
     }
 
     /** 获取(开通)当前用户钱包信息 */
+    @Operation(summary = "获取(开通)当前用户钱包信息", description = "获取(开通)当前用户钱包信息")
     @PostMapping("getWallet")
-    public Object getWalletByUser(String oid, WalletType walletType){
+    public Object getWalletByUser(@RequestParam(name = "oid")String oid, @RequestParam(name = "walletType") WalletType walletType){
         return walletService.getWalletByUser(oid, walletType, null);
     }
 }

+ 2 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/controller/wxPaymentV3/WechatPayV3Controller.java

@@ -7,6 +7,7 @@ import com.zhongshu.card.client.service.ProjectPaySettingFeignService;
 import com.zhongshu.payment.client.model.param.WxPrepayParam;
 import com.zhongshu.payment.server.core.dataConfig.WxV3PayConfig;
 import com.zhongshu.payment.server.core.service.wxPaymentV3.WxPaymentService;
+import io.swagger.v3.oas.annotations.Hidden;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
 import io.swagger.v3.oas.annotations.tags.Tag;
@@ -24,6 +25,7 @@ import org.springframework.web.bind.annotation.*;
 @RestController
 @RequestMapping("/wechat/v3/pay")
 @Tag(name = "微信支付接口")
+@Hidden
 public class WechatPayV3Controller {
 
     @Autowired

+ 3 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/domain/wallet/RechargeRecord.java

@@ -25,6 +25,9 @@ public class RechargeRecord extends SuperEntity {
     @Schema(name = "userId", description = "用户id")
     private String userId;
 
+    @Schema(name = "schoolId", description = "学校id")
+    private String schoolId;
+
     @Schema(name = "钱包信息", description = "钱包信息")
     private Wallet wallet;
 

+ 3 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/domain/wallet/WalletFlow.java

@@ -20,6 +20,9 @@ public class WalletFlow extends SuperEntity {
     @DBRef(lazy = true)
     private Wallet wallet;
 
+    @Schema(description = "学校id")
+    private String schoolId;
+
     @Schema(description = "订单号")
     private String outTradeNo;
 

+ 141 - 40
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/impl/WalletFeignServiceImpl.java

@@ -2,6 +2,7 @@ package com.zhongshu.payment.server.core.service.impl;
 
 import com.zhongshu.payment.client.model.WalletFlowModel;
 import com.zhongshu.payment.client.model.WalletModel;
+import com.zhongshu.payment.client.model.param.AmountUpdateParam;
 import com.zhongshu.payment.client.ret.ResultContent;
 import com.zhongshu.payment.client.service.WalletFeignService;
 import com.zhongshu.payment.client.types.DataState;
@@ -12,6 +13,7 @@ import com.zhongshu.payment.server.core.dao.WalletFlowDao;
 import com.zhongshu.payment.server.core.domain.wallet.Wallet;
 import com.zhongshu.payment.server.core.domain.wallet.WalletFlow;
 import com.zhongshu.payment.server.core.utils.BeanUtils;
+import org.jetbrains.annotations.NotNull;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -34,6 +36,12 @@ public class WalletFeignServiceImpl implements WalletFeignService {
 
     @Override
     public WalletModel getWallet(String oid, WalletType walletType, String shopId, String userId) {
+
+        return toModel(findWallet(oid, walletType, shopId, userId));
+    }
+
+    @NotNull
+    private Wallet findWallet(String oid, @NotNull WalletType walletType, String shopId, String userId){
         Wallet wallet = null;
         if (walletType.equals(WalletType.User)){
             wallet = walletDao.findByUserIdAndOid(userId, oid);
@@ -42,7 +50,7 @@ public class WalletFeignServiceImpl implements WalletFeignService {
             wallet = walletDao.findByShopIdAndOid(shopId, oid);
         }
         if (wallet!=null){
-            return toModel(wallet);
+            return wallet;
         }
         wallet = new Wallet();
         wallet.setOid(oid);
@@ -53,69 +61,161 @@ public class WalletFeignServiceImpl implements WalletFeignService {
         wallet.setShopId(shopId);
         wallet.setUserId(userId);
         walletDao.save(wallet);
-        return toModel(wallet);
+        return wallet;
     }
 
+
+    /** 充值 */
     @Override
-    public ResultContent addAmount(String walletId, BigDecimal total, String outTradeNo, TradeType type, String attach) {
-        Wallet wallet = walletDao.findTop1ById(walletId);
-        if (wallet==null){
-            return ResultContent.buildFail("钱包未开通");
-        }
-        wallet.setAmount(wallet.getAmount().add(total));
+    public ResultContent recharge(AmountUpdateParam param){
+        Wallet wallet = findWallet(param.getOid(), WalletType.User, param.getShopId(), param.getUserId());
+        wallet.setAmount(wallet.getAmount().add(param.getTotal()));
+        wallet.setTotalAmount(wallet.getTotalAmount().add(param.getTotal()));
         walletDao.save(wallet);
-        createWalletFlow(walletId, total, outTradeNo, type, attach);
+        createWalletFlow(wallet.getId(), param.getTotal(), param.getOutTradeNo(), TradeType.Charge, param.getAttach(), param.getSchoolId());
         return ResultContent.buildSuccess();
     }
 
+    /** 消费 */
     @Override
-    public ResultContent addTotalAmount(String walletId, BigDecimal total, String outTradeNo, TradeType type, String attach) {
-        Wallet wallet = walletDao.findTop1ById(walletId);
-        if (wallet==null){
-            return ResultContent.buildFail("钱包未开通");
+    public ResultContent consume(AmountUpdateParam param){
+        Wallet userWallet = findWallet(param.getOid(), WalletType.User, param.getShopId(), param.getUserId());
+
+        if (userWallet.getAmount().compareTo(param.getTotal()) < 0 ){
+            return ResultContent.buildFail("可用余额不足");
         }
-        wallet.setTotalAmount(wallet.getTotalAmount().add(total));
-        walletDao.save(wallet);
-        createWalletFlow(walletId, total, outTradeNo, type, attach);
+        if (userWallet.getTotalAmount().compareTo(param.getTotal()) < 0 ){
+            return ResultContent.buildFail("总额不足");
+        }
+        userWallet.setAmount(userWallet.getAmount().subtract(param.getTotal()));
+        userWallet.setTotalAmount(userWallet.getTotalAmount().subtract(param.getTotal()));
+        walletDao.save(userWallet);
+        createWalletFlow(userWallet.getId(), param.getTotal(), param.getOutTradeNo(), TradeType.Pay, param.getAttach(), param.getSchoolId());
+
+        Wallet shopWallet = findWallet(param.getOid(), WalletType.Shop, param.getShopId(), param.getUserId());
+        shopWallet.setAmount(shopWallet.getAmount().add(param.getTotal()));
+        shopWallet.setTotalAmount(shopWallet.getTotalAmount().add(param.getTotal()));
+        walletDao.save(shopWallet);
+        createWalletFlow(shopWallet.getId(), param.getTotal(), param.getOutTradeNo(), TradeType.InCome, param.getAttach(), param.getSchoolId());
         return ResultContent.buildSuccess();
     }
 
-    @Override
-    public ResultContent subtractAmount(String walletId, BigDecimal total, String outTradeNo, TradeType type, String attach) {
-        Wallet wallet = walletDao.findTop1ById(walletId);
-        if (wallet==null){
-            return ResultContent.buildFail("钱包未开通");
-        }
-        if (wallet.getAmount().compareTo(total) < 0 ){
-            return ResultContent.buildFail("可用余额不足");
-        }
-        wallet.setAmount(wallet.getAmount().subtract(total));
-        walletDao.save(wallet);
-        createWalletFlow(walletId, total, outTradeNo, type, attach);
+    /** 发起退款 */
+    public ResultContent frozen(AmountUpdateParam param){
+        Wallet shopWallet = findWallet(param.getOid(), WalletType.Shop, param.getShopId(), param.getUserId());
+
+//        if (shopWallet.getAmount().compareTo(param.getTotal()) < 0 ){
+//            return ResultContent.buildFail("可用余额不足");
+//        }
+//        if (shopWallet.getTotalAmount().compareTo(param.getTotal()) < 0 ){
+//            return ResultContent.buildFail("总额不足");
+//        }
+
+
+        shopWallet.setAmount(shopWallet.getAmount().subtract(param.getTotal()));
+        walletDao.save(shopWallet);
+        createWalletFlow(shopWallet.getId(), param.getTotal(), param.getOutTradeNo(), TradeType.Frozen, param.getAttach(), param.getSchoolId());
         return ResultContent.buildSuccess();
     }
 
-    @Override
-    public ResultContent subtractTotalAmount(String walletId, BigDecimal total, String outTradeNo, TradeType type, String attach) {
-        Wallet wallet = walletDao.findTop1ById(walletId);
-        if (wallet==null){
-            return ResultContent.buildFail("钱包未开通");
-        }
-        if (wallet.getTotalAmount().compareTo(total) < 0 ){
-            return ResultContent.buildFail("总额不足");
+    /** 退款(审批失败) */
+    public ResultContent cancelFrozen(AmountUpdateParam param){
+        Wallet shopWallet = findWallet(param.getOid(), WalletType.Shop, param.getShopId(), param.getUserId());
+        shopWallet.setAmount(shopWallet.getAmount().add(param.getTotal()));
+        walletDao.save(shopWallet);
+        createWalletFlow(shopWallet.getId(), param.getTotal(), param.getOutTradeNo(), TradeType.CancelFrozen, param.getAttach(), param.getSchoolId());
+        return ResultContent.buildSuccess();
+    }
+
+    /** 退款(审批通过) */
+    public ResultContent refund(AmountUpdateParam param){
+        Wallet shopWallet = findWallet(param.getOid(), WalletType.Shop, param.getShopId(), param.getUserId());
+
+        BigDecimal amount = shopWallet.getAmount();
+        //加上冻结金额
+        BigDecimal _amount = amount.add(param.getTotal());
+        if (_amount.compareTo(param.getTotal()) < 0 ){
+            return ResultContent.buildFail("可用余额不足");
         }
-        wallet.setTotalAmount(wallet.getTotalAmount().subtract(total));
-        walletDao.save(wallet);
-        createWalletFlow(walletId, total, outTradeNo, type, attach);
+//        shopWallet.setAmount(shopWallet.getAmount().add(param.getTotal()));
+        shopWallet.setTotalAmount(shopWallet.getTotalAmount().subtract(param.getTotal()));
+        walletDao.save(shopWallet);
+        createWalletFlow(shopWallet.getId(), param.getTotal(), param.getOutTradeNo(), TradeType.Refund, param.getAttach(), param.getSchoolId());
+
+        Wallet userWallet = findWallet(param.getOid(), WalletType.User, param.getShopId(), param.getUserId());
+        userWallet.setAmount(userWallet.getAmount().add(param.getTotal()));
+        userWallet.setTotalAmount(userWallet.getTotalAmount().add(param.getTotal()));
+        walletDao.save(userWallet);
+        createWalletFlow(userWallet.getId(), param.getTotal(), param.getOutTradeNo(), TradeType.Refund, param.getAttach(), param.getSchoolId());
         return ResultContent.buildSuccess();
     }
 
+    /** 用户发起提现 */
+
+    /** 用户提现(审批失败) */
+
+    /** 用户提现(审批通过) */
+
+//    @Override
+//    public ResultContent addAmount(String walletId, BigDecimal total, String outTradeNo, TradeType type, String attach) {
+//        Wallet wallet = walletDao.findTop1ById(walletId);
+//        if (wallet==null){
+//            return ResultContent.buildFail("钱包未开通");
+//        }
+//        wallet.setAmount(wallet.getAmount().add(total));
+//        walletDao.save(wallet);
+//        createWalletFlow(walletId, total, outTradeNo, type, attach);
+//        return ResultContent.buildSuccess();
+//    }
+//
+//    @Override
+//    public ResultContent addTotalAmount(String walletId, BigDecimal total, String outTradeNo, TradeType type, String attach) {
+//        Wallet wallet = walletDao.findTop1ById(walletId);
+//        if (wallet==null){
+//            return ResultContent.buildFail("钱包未开通");
+//        }
+//        wallet.setTotalAmount(wallet.getTotalAmount().add(total));
+//        walletDao.save(wallet);
+//        createWalletFlow(walletId, total, outTradeNo, type, attach);
+//        return ResultContent.buildSuccess();
+//    }
+//
+//    @Override
+//    public ResultContent subtractAmount(String walletId, BigDecimal total, String outTradeNo, TradeType type, String attach) {
+//        Wallet wallet = walletDao.findTop1ById(walletId);
+//        if (wallet==null){
+//            return ResultContent.buildFail("钱包未开通");
+//        }
+//        if (wallet.getAmount().compareTo(total) < 0 ){
+//            return ResultContent.buildFail("可用余额不足");
+//        }
+//        wallet.setAmount(wallet.getAmount().subtract(total));
+//        walletDao.save(wallet);
+//        createWalletFlow(walletId, total, outTradeNo, type, attach);
+//        return ResultContent.buildSuccess();
+//    }
+//
+//    @Override
+//    public ResultContent subtractTotalAmount(String walletId, BigDecimal total, String outTradeNo, TradeType type, String attach) {
+//        Wallet wallet = walletDao.findTop1ById(walletId);
+//        if (wallet==null){
+//            return ResultContent.buildFail("钱包未开通");
+//        }
+//        if (wallet.getTotalAmount().compareTo(total) < 0 ){
+//            return ResultContent.buildFail("总额不足");
+//        }
+//        wallet.setTotalAmount(wallet.getTotalAmount().subtract(total));
+//        walletDao.save(wallet);
+//        createWalletFlow(walletId, total, outTradeNo, type, attach);
+//        return ResultContent.buildSuccess();
+//    }
+
     @Override
     public List<WalletFlowModel> queryWalletFlow(String walletId) {
         return null;
     }
 
-    private WalletFlow createWalletFlow(String walletId, BigDecimal total, String outTradeNo, TradeType type, String attach){
+    private WalletFlow createWalletFlow(String walletId, BigDecimal total, String outTradeNo, TradeType type, String attach, String schoolId){
         WalletFlow walletFlow = new WalletFlow();
         Wallet wallet = new Wallet();
         wallet.setId(walletId);
@@ -124,6 +224,7 @@ public class WalletFeignServiceImpl implements WalletFeignService {
         walletFlow.setOutTradeNo(outTradeNo);
         walletFlow.setTradeType(type);
         walletFlow.setAttach(attach);
+        walletFlow.setSchoolId(schoolId);
         return walletFlowDao.save(walletFlow);
     }
 

+ 17 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/wxPaymentV3/WxPayNotifyService.java

@@ -1,14 +1,18 @@
 package com.zhongshu.payment.server.core.service.wxPaymentV3;
 
+import com.github.microservice.core.util.JsonUtil;
 import com.wechat.pay.java.core.RSAAutoCertificateConfig;
 import com.wechat.pay.java.core.notification.NotificationConfig;
 import com.wechat.pay.java.core.notification.NotificationParser;
 import com.wechat.pay.java.core.notification.RequestParam;
 import com.wechat.pay.java.service.payments.model.Transaction;
+import com.zhongshu.payment.client.model.param.AmountUpdateParam;
+import com.zhongshu.payment.client.ret.ResultContent;
 import com.zhongshu.payment.client.types.RechargeState;
 import com.zhongshu.payment.server.core.dao.RechargeRecordDao;
 import com.zhongshu.payment.server.core.dataConfig.WxV3PayConfig;
 import com.zhongshu.payment.server.core.domain.wallet.RechargeRecord;
+import com.zhongshu.payment.server.core.service.impl.WalletFeignServiceImpl;
 import com.zhongshu.payment.server.core.utils.DateUtils;
 import jakarta.servlet.ServletInputStream;
 import jakarta.servlet.http.HttpServletRequest;
@@ -33,6 +37,9 @@ public class WxPayNotifyService {
     @Autowired
     RechargeRecordDao rechargeRecordDao;
 
+    @Autowired
+    WalletFeignServiceImpl walletService;
+
     public void payNotify(HttpServletRequest request) {
         try {
             //读取请求体的信息
@@ -85,6 +92,16 @@ public class WxPayNotifyService {
                 record.setRechargeState(RechargeState.SUCCESS);
                 record.setTradeTime(DateUtils.timeToLong(transaction.getSuccessTime(), DateUtils.patternWx));
                 rechargeRecordDao.save(record);
+                AmountUpdateParam amountUpdateParam = new AmountUpdateParam();
+                amountUpdateParam.setOid(record.getOid());
+                amountUpdateParam.setUserId(record.getUserId());
+                amountUpdateParam.setTotal(record.getTotal());
+                amountUpdateParam.setOutTradeNo(record.getOutTradeNo());
+                amountUpdateParam.setAttach(JsonUtil.toJson(transaction));
+                ResultContent recharge = walletService.recharge(amountUpdateParam);
+                if (recharge.isFailed()){
+                    log.error("充值失败:钱包余额增加失败");
+                }
                 //todo 账户可用余额 增加
             }else {
                 log.info("微信支付异常:{}", transaction.getTradeState());