소스 검색

Merge remote-tracking branch 'origin/master'

TRX 1 년 전
부모
커밋
0b462c2e2c

+ 28 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/pay/WithdrawMonthPageParam.java

@@ -0,0 +1,28 @@
+package com.zhongshu.card.client.model.pay;
+
+import com.zhongshu.card.client.type.AuditStatus;
+import com.zhongshu.card.client.type.paySetting.WithdrawMethodType;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Data
+public class WithdrawMonthPageParam {
+
+    @Schema(description = "项目oid")
+    private String projectOid;
+
+    @Schema(description = "机构oid")
+    private String oid;
+
+    @Schema(description = "开始时间")
+    private Integer year;
+
+    @Schema(description = "结束时间")
+    private Integer month;
+
+//    @Schema(description = "索引")
+//    private String search;
+
+    @Schema(description = "提现方式")
+    private WithdrawMethodType withdrawMethodType;
+}

+ 18 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/pay/withdraw/WithdrawController.java

@@ -4,6 +4,7 @@ import com.github.microservice.auth.security.annotations.ResourceAuth;
 import com.github.microservice.auth.security.type.AuthType;
 import com.github.microservice.types.payment.PaymentType;
 import com.zhongshu.card.client.model.pay.ProcessWithdrawParam;
+import com.zhongshu.card.client.model.pay.WithdrawMonthPageParam;
 import com.zhongshu.card.client.model.pay.WithdrawPageParam;
 import com.zhongshu.card.client.model.pay.WithdrawParam;
 import com.zhongshu.card.server.core.service.pay.WithdrawService;
@@ -62,7 +63,7 @@ public class WithdrawController {
     }
 
     @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "分页查询-提现记录", description = "查询收入账单-年月日汇总")
+    @Operation(summary = "分页查询-提现记录", description = "查询提现记录")
     @RequestMapping(value = "page", method = RequestMethod.POST)
     public Object page(@Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
             @Parameter(required = false) WithdrawPageParam param) {
@@ -82,4 +83,20 @@ public class WithdrawController {
     public Object queryDetailById(@RequestParam("id") String id) {
         return withdrawService.queryDetailById(id);
     }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "按月分页查询-提现记录", description = "按月分页查询-提现记录")
+    @RequestMapping(value = "monthPage", method = RequestMethod.POST)
+    public Object monthPage(@Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
+                            @Parameter(required = false) WithdrawMonthPageParam param){
+        return withdrawService.page(pageable, param);
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "查询提现余额明细", description = "查询提现余额明细")
+    @RequestMapping(value = "transactionLogPage", method = RequestMethod.POST)
+    public Object transactionLogPage(@Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
+                                     @Parameter(required = false) WithdrawMonthPageParam param){
+        return withdrawService.transactionLogPage(pageable, param);
+    }
 }

+ 2 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/pay/extend/WithdrawOrderDaoExtend.java

@@ -3,13 +3,14 @@ package com.zhongshu.card.server.core.dao.pay.extend;
 import com.zhongshu.card.client.model.pay.WithdrawPageParam;
 import com.zhongshu.card.client.type.AuditStatus;
 import com.zhongshu.card.client.type.WithdrawStatus;
+import com.zhongshu.card.client.type.paySetting.WithdrawMethodType;
 import com.zhongshu.card.server.core.domain.pay.WithdrawOrder;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 
 public interface WithdrawOrderDaoExtend {
 
-    Page<WithdrawOrder> page(Pageable pageable, String projectOid, String oid, Long startTime, Long endTime, String search, AuditStatus auditStatus);
+    Page<WithdrawOrder> page(Pageable pageable, String projectOid, String oid, Long startTime, Long endTime, String search, AuditStatus auditStatus, WithdrawMethodType withdrawMethodType);
 
     boolean updateWithdrawStatus(String id, WithdrawStatus status, String withdrawStatusDesc);
 }

+ 6 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/pay/impl/WithdrawOrderDaoImpl.java

@@ -5,6 +5,7 @@ import com.github.microservice.components.data.mongo.mongo.helper.DBHelper;
 import com.zhongshu.card.client.model.pay.WithdrawPageParam;
 import com.zhongshu.card.client.type.AuditStatus;
 import com.zhongshu.card.client.type.WithdrawStatus;
+import com.zhongshu.card.client.type.paySetting.WithdrawMethodType;
 import com.zhongshu.card.server.core.dao.pay.WithdrawOrderDao;
 import com.zhongshu.card.server.core.dao.pay.extend.WithdrawOrderDaoExtend;
 import com.zhongshu.card.server.core.domain.pay.WithdrawOrder;
@@ -30,7 +31,7 @@ public class WithdrawOrderDaoImpl implements WithdrawOrderDaoExtend {
     MongoTemplate mongoTemplate;
 
     @Override
-    public Page<WithdrawOrder> page(Pageable pageable, String projectOid, String oid, Long startTime, Long endTime, String search, AuditStatus auditStatus) {
+    public Page<WithdrawOrder> page(Pageable pageable, String projectOid, String oid, Long startTime, Long endTime, String search, AuditStatus auditStatus, WithdrawMethodType withdrawMethodType) {
         Criteria criteria = new Criteria();
 
         if (StringUtils.isNotBlank(projectOid)) {
@@ -58,6 +59,10 @@ public class WithdrawOrderDaoImpl implements WithdrawOrderDaoExtend {
             }
         }
 
+        if (withdrawMethodType != null) {
+            criteria.and("withdrawMethodType").is(withdrawMethodType);
+        }
+
         Query query = new Query(criteria);
         query.with(Sort.by(Sort.Order.asc("sort"), Sort.Order.desc("createTime")));
         return dbHelper.pages(query, pageable, WithdrawOrder.class);

+ 72 - 4
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/pay/WithdrawService.java

@@ -1,5 +1,6 @@
 package com.zhongshu.card.server.core.service.pay;
 
+import com.github.microservice.components.data.base.page.PageableModel;
 import com.github.microservice.components.data.base.util.PageEntityUtil;
 import com.github.microservice.core.util.JsonUtil;
 import com.github.microservice.core.util.queue.ExecuteQueueUtil;
@@ -214,6 +215,10 @@ public class WithdrawService extends SuperService {
         PaymentType paymentType = param.getPaymentType();
         BigDecimal amount = param.getAmount();
 
+        if(amount.compareTo(new BigDecimal(0)) == 0) {
+            return com.github.microservice.net.ResultContent.buildFail("提现金额不能为0");
+        }
+
         if (StringUtils.isBlank(projectOid)) {
             projectOid = getCurrentProjectOid();
         }
@@ -260,7 +265,7 @@ public class WithdrawService extends SuperService {
         sourceTransaction.setTransactionType(TransactionType.WithdrawFrozen);
         sourceTransaction.setTransactionStatus(TransactionStatus.Success);
         sourceTransaction.setAmount(amount.negate().longValue());
-        sourceTransaction.setMeta(Map.of("paymentType", paymentType, "paymentChannelType", paymentType.getChannelType(), "description", "提现冻结"));
+        sourceTransaction.setMeta(Map.of("paymentType", paymentType, "paymentChannelType", paymentType.getChannelType(), "description", "提现冻结", "withdrawMethodType", projectMainPaySetting.getWithdrawMethodType()));
         transferModel.setSource(new TransferTransactionsModel.GeneralLedgerTransaction[]{sourceTransaction});
         //构建入账账户
         TransferTransactionsModel.GeneralLedgerTransaction destinationTransaction = new TransferTransactionsModel.GeneralLedgerTransaction();
@@ -269,7 +274,7 @@ public class WithdrawService extends SuperService {
         destinationTransaction.setTransactionType(TransactionType.WithdrawFrozen);
         destinationTransaction.setTransactionStatus(TransactionStatus.Success);
         destinationTransaction.setAmount(amount.longValue());
-        destinationTransaction.setMeta(Map.of("paymentType", paymentType, "paymentChannelType", paymentType.getChannelType(), "description", "提现冻结"));
+        destinationTransaction.setMeta(Map.of("paymentType", paymentType, "paymentChannelType", paymentType.getChannelType(), "description", "提现冻结", "withdrawMethodType", projectMainPaySetting.getWithdrawMethodType()));
         transferModel.setDestinations(new TransferTransactionsModel.GeneralLedgerTransaction[]{destinationTransaction});
         ResultContent<List<TransactionLogModel>> transfer = transactionLogService.transfer(transferModel);
         if (!transfer.getState().equals(ResultState.Success)) {
@@ -480,7 +485,7 @@ public class WithdrawService extends SuperService {
         }
         boolean isProjectManager = userOrgPermissService.userIsProjectManager(projectOid, userId);
         if (isProjectManager) {
-            Page<WithdrawOrder> page = withdrawOrderDao.page(pageable, projectOid, null, param.getStartTime(), param.getEndTime(), param.getSearch(), param.getAuditStatus());
+            Page<WithdrawOrder> page = withdrawOrderDao.page(pageable, projectOid, null, param.getStartTime(), param.getEndTime(), param.getSearch(), param.getAuditStatus(), null);
             return com.github.microservice.net.ResultContent.buildContent(PageEntityUtil.concurrent2PageModel(page, this::toModel));
         }
         List<String> userManagerOids = userOrgPermissService.getUserManagerOids(projectOid, userId);
@@ -489,10 +494,73 @@ public class WithdrawService extends SuperService {
             return com.github.microservice.net.ResultContent.buildContent(PageEntityUtil.buildEmptyPage(pageable));
         }
 
-        Page<WithdrawOrder> page = withdrawOrderDao.page(pageable, projectOid, userManagerOids.get(0), param.getStartTime(), param.getEndTime(), param.getSearch(), param.getAuditStatus());
+        Page<WithdrawOrder> page = withdrawOrderDao.page(pageable, projectOid, userManagerOids.get(0), param.getStartTime(), param.getEndTime(), param.getSearch(), param.getAuditStatus(), null);
         return com.github.microservice.net.ResultContent.buildContent(PageEntityUtil.concurrent2PageModel(page, this::toModel));
     }
 
+    public Object page(Pageable pageable, WithdrawMonthPageParam param){
+        String projectOid = param.getProjectOid();
+        if (StringUtils.isBlank(projectOid)) {
+            projectOid = getCurrentProjectOid();
+        }
+        String oid = param.getOid();
+        if (StringUtils.isBlank(oid)) {
+            oid = getCurrentOid();
+        }
+
+        if (param.getYear() == null || param.getMonth() == null) {
+            return com.github.microservice.net.ResultContent.buildFail("year或month不能为null");
+        }
+
+        Long monthStartTime = DateUtils.getMonthStartTime(param.getYear(), param.getMonth());
+        Long monthEndTime = DateUtils.getMonthEndTime(param.getYear(), param.getMonth());
+
+        Page<WithdrawOrder> page = withdrawOrderDao.page(pageable, projectOid, oid, monthStartTime, monthEndTime, null, null, param.getWithdrawMethodType());
+        return com.github.microservice.net.ResultContent.buildContent(PageEntityUtil.concurrent2PageModel(page, this::toModel));
+    }
+
+    /**
+     * 查询提现余额明细
+     * @return
+     */
+    public Object transactionLogPage(Pageable pageable, WithdrawMonthPageParam param){
+        String projectOid = param.getProjectOid();
+        if (StringUtils.isBlank(projectOid)) {
+            projectOid = getCurrentProjectOid();
+        }
+        String oid = param.getOid();
+        if (StringUtils.isBlank(oid)) {
+            oid = getCurrentOid();
+        }
+
+        if (param.getYear() == null || param.getMonth() == null) {
+            return com.github.microservice.net.ResultContent.buildFail("year或month不能为null");
+        }
+
+        Long monthStartTime = DateUtils.getMonthStartTime(param.getYear(), param.getMonth());
+        Long monthEndTime = DateUtils.getMonthEndTime(param.getYear(), param.getMonth());
+
+        PayAccount orgChildren = payAccountService.getOrgChildren(projectOid, oid, PaymentChannelType.Settle);
+
+        GeneralLedgerQueryTransactionLogModel queryModel = new GeneralLedgerQueryTransactionLogModel();
+        queryModel.setGeneralLedgerId(new String[]{orgChildren.getLedgerId()});
+        queryModel.setStartTime(monthStartTime);
+        queryModel.setEndTime(monthEndTime);
+        if (param.getWithdrawMethodType()!=null){
+            queryModel.setFilter(Map.of("meta.withdrawMethodType", param.getWithdrawMethodType()));
+        }
+        PageableModel pageableModel = new PageableModel();
+        pageableModel.setPage(pageable.getPageNumber());
+        pageableModel.setSize(pageable.getPageSize());
+        pageableModel.setSort("createTime");
+        queryModel.setPage(pageableModel);
+        ResultContent<TransactionLogAggregateRetModel> aggregateResult = transactionLogService.aggregate(queryModel);
+        if (!aggregateResult.getState().equals(ResultState.Success)){
+            return com.github.microservice.net.ResultContent.buildFail(aggregateResult.getMsg());
+        }
+        return com.github.microservice.net.ResultContent.buildContent(aggregateResult.getContent().getPages());
+    }
+
     private WithdrawOrderModel toModel(WithdrawOrder withdrawOrder) {
         WithdrawOrderModel model = new WithdrawOrderModel();
         if (withdrawOrder != null) {