Ver código fonte

Merge remote-tracking branch 'origin/master'

TRX 1 ano atrás
pai
commit
fe15c1ac54

+ 4 - 3
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/pay/BalanceRechargeOrder.java

@@ -27,9 +27,6 @@ public class BalanceRechargeOrder extends SuperEntity {
     @Schema(description = "支付账户")
     private String payAccount;
 
-    @Schema(description = "预支付单号(用于前端调起支付的参数)")
-    private Object prepay;
-
     @Schema(description = "订单状态")
     private RechargeOrderStatus status;
 
@@ -44,4 +41,8 @@ public class BalanceRechargeOrder extends SuperEntity {
 
     @Schema(description = "描述")
     private String description;
+
+    /********************************渠道所属参数*********************************/
+    @Schema(description = "预支付单号(用于前端调起支付的参数)")
+    private Object prepay;
 }

+ 30 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/pay/BalanceRefundOrder.java

@@ -0,0 +1,30 @@
+package com.zhongshu.card.server.core.domain.pay;
+
+import com.github.microservice.components.data.mongo.mongo.domain.SuperEntity;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import org.springframework.data.mongodb.core.mapping.Document;
+
+import java.math.BigDecimal;
+
+@Document
+@Data
+public class BalanceRefundOrder extends SuperEntity {
+
+    @Schema(description = "原支付订单号")
+    public String orderNo;
+
+    @Schema(description = "原支付金额")
+    public BigDecimal total;
+
+    @Schema(description = "退款单号")
+    public String refundOrderNo;
+
+    @Schema(description = "退款金额")
+    public BigDecimal refundTotal;
+
+    @Schema(description = "退款原因")
+    public String reason;
+
+    
+}

+ 60 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/pay/AccountBookService.java

@@ -0,0 +1,60 @@
+package com.zhongshu.card.server.core.service.pay;
+
+import com.github.microservice.components.data.base.page.PageableModel;
+import com.github.microservice.pay.client.model.ledger.GeneralLedgerModel;
+import com.github.microservice.pay.client.model.ledger.GeneralLedgerTreeModel;
+import com.github.microservice.pay.client.model.ledger.transaction.BaseQueryTransactionLogModel;
+import com.github.microservice.pay.client.model.ledger.transaction.DescendantQueryTransactionLogModel;
+import com.github.microservice.pay.client.model.ledger.transaction.TransactionLogAggregateRetModel;
+import com.github.microservice.pay.client.ret.ResultContent;
+import com.github.microservice.pay.client.ret.ResultState;
+import com.github.microservice.pay.client.service.ledger.GeneralLedgerService;
+import com.github.microservice.pay.client.service.ledger.TransactionLogService;
+import com.zhongshu.card.client.utils.DateUtils;
+import com.zhongshu.card.server.core.domain.pay.PayAccount;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Pageable;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Service
+public class AccountBookService {
+
+    @Autowired
+    TransactionLogService transactionLogService;
+
+    @Autowired
+    GeneralLedgerService generalLedgerService;
+
+    @Autowired
+    PayAccountService payAccountService;
+
+    /**
+     * 查询用户流水
+     */
+    public Object queryFlow(Pageable pageable, String userId, String projectOid){
+        PayAccount userParent = payAccountService.getUserParent(projectOid, userId);
+        ResultContent<GeneralLedgerTreeModel> descendantRet = generalLedgerService.descendant(userParent.getLedgerId());
+        if (!descendantRet.getState().equals(ResultState.Success)){
+            return com.github.microservice.net.ResultContent.buildFail("获取用户账户及下级账户失败");
+        }
+        GeneralLedgerTreeModel generalLedgerTreeModel = descendantRet.getContent();
+
+        List<GeneralLedgerTreeModel> children = generalLedgerTreeModel.getChildren();
+        List<String> childrenIdList = children.stream().map(GeneralLedgerModel::getId).toList();
+
+        DescendantQueryTransactionLogModel descendantQueryTransactionLogModel = new DescendantQueryTransactionLogModel();
+        PageableModel pageableModel = new PageableModel();
+        pageableModel.setPage(pageable.getPageNumber());
+        pageableModel.setSize(pageable.getPageSize());
+        pageableModel.setSort("createTime");
+
+        descendantQueryTransactionLogModel.setPage(pageableModel);
+        descendantQueryTransactionLogModel.setParentGeneralLedgerId(userParent.getLedgerId());
+
+        descendantQueryTransactionLogModel.setStartTime(DateUtils.getMonthStartTime(2024, 10));
+        return transactionLogService.aggregate(descendantQueryTransactionLogModel);
+    }
+}

+ 23 - 2
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/pay/BalancePayService.java

@@ -151,7 +151,7 @@ public class BalancePayService extends SuperService {
                 TransferTransactionsModel.GeneralLedgerTransaction destinationTransaction = new TransferTransactionsModel.GeneralLedgerTransaction();
                 destinationTransaction.setGeneralLedgerId(userPayAccount.getLedgerId());
                 destinationTransaction.setOrderNumber(rechargeOrder.getOrderNo());
-                destinationTransaction.setTransactionType(TransactionType.Transfer);
+                destinationTransaction.setTransactionType(TransactionType.Deposit);
                 destinationTransaction.setTransactionStatus(TransactionStatus.Success);
                 destinationTransaction.setAmount(rechargeOrder.getTotal().longValue());
                 destinationTransaction.setRemark("用户余额充值");
@@ -205,7 +205,7 @@ public class BalancePayService extends SuperService {
         TransferTransactionsModel.GeneralLedgerTransaction destinationTransaction = new TransferTransactionsModel.GeneralLedgerTransaction();
         destinationTransaction.setGeneralLedgerId(orgWaitSettle.getLedgerId());
         destinationTransaction.setOrderNumber(orderNo);
-        destinationTransaction.setTransactionType(TransactionType.Receive);
+        destinationTransaction.setTransactionType(TransactionType.Pay);
         destinationTransaction.setTransactionStatus(TransactionStatus.Success);
         destinationTransaction.setAmount(total.longValue());
         destinationTransaction.setRemark(remark);
@@ -277,6 +277,9 @@ public class BalancePayService extends SuperService {
         return ResultContent.build(ResultState.Success);
     }
 
+    /**
+     * 商家退款
+     */
     public ResultContent<List<TransactionLogModel>> refund(String projectOid, String oid, String userId, String orderNo, BigDecimal total, String remark){
         //获取用户余额支付子账户
         PayAccount userAccount = payAccountService.getUserChildren(projectOid, userId, PaymentChannelType.BalancePayment);
@@ -307,6 +310,24 @@ public class BalancePayService extends SuperService {
         return transactionLogService.transfer(transferModel);
     }
 
+    /**
+     * 充值退款-从支付渠道退款
+     * @return
+     */
+    public Object channelRefund(String projectId, String userId, String orderNo){
+        BalanceRechargeOrder rechargeOrder = rechargeOrderDao.findTopByOrderNo(orderNo);
+        if (rechargeOrder==null){
+            return com.github.microservice.net.ResultContent.buildFail("订单不存在");
+        }
+
+        PayProductParameter<Object> parameter = new PayProductParameter<>();
+        String accountName = orgPayAccountService.buildPayAccountName(rechargeOrder.getProjectOid(), rechargeOrder.getPaymentType());
+        parameter.setAccountName(accountName);
+//        parameter.setMeta(Map.of("orderNo", rechargeOrder.getOrderNo(), ));
+
+        return null;
+    }
+
     private RechargeOrderModel toModel(BalanceRechargeOrder balanceRechargeOrder) {
         RechargeOrderModel rechargeOrderModel = new RechargeOrderModel();
         if (balanceRechargeOrder != null) {

+ 22 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/stream/WeChatMiniAppReFundStream.java

@@ -0,0 +1,22 @@
+package com.zhongshu.card.server.core.stream;
+
+import com.github.microservice.app.stream.StreamConsumer;
+import com.github.microservice.pay.client.model.weChatMiniApp.WeChatMiniAppPayRet;
+import com.github.microservice.pay.client.model.weChatMiniApp.WeChatMiniAppRefundRet;
+import com.zhongshu.card.server.core.service.pay.BalancePayService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+@Slf4j
+@Component("weChatMiniAppReFundStreamConsumer")
+public class WeChatMiniAppReFundStream extends StreamConsumer<WeChatMiniAppRefundRet> {
+
+    @Autowired
+    BalancePayService balancePayService;
+
+    @Override
+    public void accept(WeChatMiniAppRefundRet weChatMiniAppRefundRet) {
+        log.info("---------------收到微信退款结果通知广播----------------");
+    }
+}