wujiefeng 1 жил өмнө
parent
commit
5d5a528a29

+ 15 - 0
PaymentClient/src/main/java/com/zhongshu/payment/client/model/WalletOrderModel.java

@@ -0,0 +1,15 @@
+package com.zhongshu.payment.client.model;
+
+import lombok.Data;
+
+/**
+ * @author wjf
+ * @date 2024/7/31
+ */
+@Data
+public class WalletOrderModel {
+
+    private Integer orderSize;
+
+    private Integer total;
+}

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

@@ -31,5 +31,5 @@ public class AmountUpdateParam {
     private String outTradeNo;
 
     @Schema(description = "附加信息")
-    private String attach;
+    private Object attach;
 }

+ 6 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/controller/WalletController.java

@@ -34,4 +34,10 @@ public class WalletController {
     public Object getWalletByUser(@RequestBody GetWalletParam param){
         return walletService.getWalletByUser(param.getAppid(), param.getWalletType(), null);
     }
+
+    @Operation(summary = "获取可提现金额及订单数量", description = "获取可提现金额及订单数量")
+    @PostMapping("getTransferTotal")
+    public Object getTransferTotal(@RequestParam(name = "walletId") String walletId){
+        return walletService.getTransferTotal(walletId);
+    }
 }

+ 2 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/dao/RechargeRecordDao.java

@@ -17,4 +17,6 @@ public interface RechargeRecordDao extends MongoDao<RechargeRecord>, RechargeRec
     List<RechargeRecord> findByOutTradeNoIn(List<String> outTradeNo);
 
     RechargeRecord findTop1ById(String id);
+
+    Integer countByWallet_Id(String walletId);
 }

+ 10 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/dao/extend/WalletFlowDaoExtend.java

@@ -0,0 +1,10 @@
+package com.zhongshu.payment.server.core.dao.extend;
+
+/**
+ * @author wjf
+ * @date 2024/7/31
+ */
+public interface WalletFlowDaoExtend {
+
+
+}

+ 1 - 1
PaymentServer/src/main/java/com/zhongshu/payment/server/core/dao/impl/RechargeRecordDaoImpl.java

@@ -108,7 +108,7 @@ public class RechargeRecordDaoImpl implements RechargeRecordDaoExtend {
         criteria.and("rechargeState").in(List.of(RechargeState.SUCCESS, RechargeState.TakeSuccess));
         Aggregation aggregation = Aggregation.newAggregation(
                 Aggregation.match(criteria),
-                Aggregation.project("tradeType","amountTotal"),
+                Aggregation.project("_id","amountTotal"),
                 Aggregation.group("tradeType").sum("total").as("amountTotal")
                 );
 

+ 10 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/dao/impl/WalletFlowDaoImpl.java

@@ -0,0 +1,10 @@
+package com.zhongshu.payment.server.core.dao.impl;
+
+import com.zhongshu.payment.server.core.dao.extend.WalletFlowDaoExtend;
+
+/**
+ * @author wjf
+ * @date 2024/7/31
+ */
+public class WalletFlowDaoImpl implements WalletFlowDaoExtend {
+}

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

@@ -33,5 +33,5 @@ public class WalletFlow extends SuperEntity {
     private TradeType tradeType;
 
     @Schema(description = "附加数据")
-    private String attach;
+    private Object attach;
 }

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

@@ -249,7 +249,7 @@ public class WalletFeignServiceImpl implements WalletFeignService {
         return null;
     }
 
-    private WalletFlow createWalletFlow(String walletId, BigDecimal total, String outTradeNo, TradeType type, String attach, String schoolId){
+    private WalletFlow createWalletFlow(String walletId, BigDecimal total, String outTradeNo, TradeType type, Object attach, String schoolId){
         WalletFlow walletFlow = new WalletFlow();
         Wallet wallet = new Wallet();
         wallet.setId(walletId);

+ 11 - 0
PaymentServer/src/main/java/com/zhongshu/payment/server/core/service/wallet/WalletService.java

@@ -10,6 +10,7 @@ import com.zhongshu.card.client.model.payment.paySetting.WxPayConfigModel;
 import com.zhongshu.card.client.service.OrganizationFeignService;
 import com.zhongshu.card.client.service.ProjectPaySettingFeignService;
 import com.zhongshu.payment.client.model.WalletModel;
+import com.zhongshu.payment.client.model.WalletOrderModel;
 import com.zhongshu.payment.client.ret.ResultContent;
 import com.zhongshu.payment.client.ret.ResultState;
 import com.zhongshu.payment.client.types.DataState;
@@ -101,6 +102,16 @@ public class WalletService {
         return ResultContent.buildSuccess(toModel(wallet));
     }
 
+    public Object getTransferTotal(String walletId){
+        Wallet wallet = walletDao.findTop1ById(walletId);
+        WalletOrderModel walletOrderModel = new WalletOrderModel();
+        walletOrderModel.setTotal(wallet.getAmount().intValue());
+
+        Integer integer = rechargeRecordDao.countByWallet_Id(walletId);
+        walletOrderModel.setOrderSize(integer);
+        return ResultContent.buildContent(walletOrderModel);
+    }
+
     private WalletModel toModel(Wallet wallet){
         WalletModel model = new WalletModel();
         if (wallet!=null){