wujiefeng 1 год назад
Родитель
Сommit
3077f4c54f

+ 0 - 9
FullCardClient/src/main/java/com/zhongshu/card/client/model/pay/CollectBillQueryModel.java

@@ -1,9 +0,0 @@
-package com.zhongshu.card.client.model.pay;
-
-public class CollectBillQueryModel {
-
-    private Integer year;
-
-    private Integer month;
-
-}

+ 21 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/pay/PeriodQueryModel.java

@@ -0,0 +1,21 @@
+package com.zhongshu.card.client.model.pay;
+
+import com.zhongshu.card.client.type.PeriodType;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+@Data
+public class PeriodQueryModel {
+
+    @Schema(description = "周期")
+    private PeriodType periodType;
+
+    @Schema(description = "年")
+    private Integer year;
+
+    @Schema(description = "月")
+    private Integer month;
+
+    private String projectOid;
+
+}

+ 17 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/type/PeriodType.java

@@ -0,0 +1,17 @@
+package com.zhongshu.card.client.type;
+
+import lombok.Getter;
+
+public enum PeriodType {
+
+    year("年"),
+    month("月"),
+    day("日");
+
+    @Getter
+    String remark;
+
+    PeriodType (String remark){
+        this.remark = remark;
+    }
+}

+ 10 - 6
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/pay/statistics/PayOverviewController.java

@@ -1,16 +1,14 @@
 package com.zhongshu.card.server.core.controller.pay.statistics;
 
+import com.zhongshu.card.client.model.pay.PeriodQueryModel;
 import com.zhongshu.card.server.core.service.pay.OrgOverviewService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 @RestController
-@RequestMapping("balance/recharge")
+@RequestMapping("fundOverview")
 @Tag(name = "资金概况", description = "资金概况")
 public class PayOverviewController {
 
@@ -28,6 +26,12 @@ public class PayOverviewController {
     @RequestMapping(value = "realTimeOverview", method = RequestMethod.GET)
     public Object realTimeOverview(@RequestParam(name = "projectOid", required = false) String projectOid,
                                   @RequestParam(name = "oid" ,required = false) String oid){
-        return orgOverviewService.realTimeOverview(projectOid, oid);
+        return orgOverviewService.realTimeOverview(projectOid);
+    }
+
+    @Operation(summary = "查询收入账单", description = "查询收入账单-年月日汇总")
+    @RequestMapping(value = "queryCreditBill", method = RequestMethod.POST)
+    public Object queryCreditBill(@RequestBody PeriodQueryModel param){
+        return orgOverviewService.queryCreditBill(param);
     }
 }

+ 62 - 8
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/pay/OrgOverviewService.java

@@ -8,26 +8,31 @@ 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.github.microservice.pay.client.type.ledger.LedgerEntry;
+import com.github.microservice.pay.client.type.ledger.TransactionStatus;
+import com.github.microservice.pay.client.type.ledger.TransactionType;
 import com.github.microservice.types.payment.PaymentChannelType;
 import com.zhongshu.card.client.model.pay.BalanceOverviewModel;
-import com.zhongshu.card.client.model.pay.CollectBillQueryModel;
+import com.zhongshu.card.client.model.pay.PeriodQueryModel;
 import com.zhongshu.card.client.model.pay.RealTimeOverviewModel;
+import com.zhongshu.card.client.type.PeriodType;
 import com.zhongshu.card.client.utils.DateUtils;
 import com.zhongshu.card.server.core.domain.pay.PayAccount;
 import com.zhongshu.card.server.core.service.base.SuperService;
+import com.zhongshu.card.server.core.service.org.OrganizationUserServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.math3.stat.descriptive.summary.Sum;
+import org.bson.Document;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
+import static org.springframework.integration.IntegrationPatternType.filter;
+
 @Service
 @Slf4j
 public class OrgOverviewService extends SuperService {
@@ -97,14 +102,18 @@ public class OrgOverviewService extends SuperService {
         return balanceOverviewModel;
     }
 
-    public Object realTimeOverview(String projectOid, String oid){
+    public Object realTimeOverview(String projectOid){
         if (StringUtils.isEmpty(projectOid)){
             projectOid = getCurrentProjectOid();
         }
-        if (StringUtils.isEmpty(oid)){
-            oid = getCurrentOid();
+
+
+        List<String> oidList = organizationUserService.getUserOrgListOids(getCurrentUserId(), projectOid);
+        if (oidList==null || oidList.isEmpty()){
+            return com.github.microservice.net.ResultContent.buildFail("未加入机构");
         }
-        PayAccount waitSettleAccount = payAccountService.getOrgChildren(projectOid, oid, PaymentChannelType.WaitSettle);
+
+        PayAccount waitSettleAccount = payAccountService.getOrgChildren(projectOid, oidList.get(0), PaymentChannelType.WaitSettle);
 
         //构建实时概况收入数据
         List<Long> yesterdayList = new ArrayList<>();
@@ -164,12 +173,57 @@ public class OrgOverviewService extends SuperService {
         realTimeOverviewModel.setTodayOrder(todayOrder);
         realTimeOverviewModel.setOrderChangeRate(changeRate(todayOrder, yesterdayOrder));
 
-        BalanceOverviewModel balanceOverviewModel = balanceOverview(projectOid, oid);
+        BalanceOverviewModel balanceOverviewModel = balanceOverview(projectOid, oidList.get(0));
         realTimeOverviewModel.setBalanceOverview(balanceOverviewModel);
         //构建24小时大小的
         return ResultContent.buildContent(realTimeOverviewModel);
     }
 
+    @Autowired
+    OrganizationUserServiceImpl organizationUserService;
+
+    public Object queryCreditBill(PeriodQueryModel param){
+        String projectOid = param.getProjectOid();
+        if (StringUtils.isBlank(param.getProjectOid())){
+            projectOid = getCurrentProjectOid();
+        }
+
+        List<String> oidList = organizationUserService.getUserOrgListOids(getCurrentUserId(), projectOid);
+        if (oidList==null || oidList.isEmpty()){
+            return com.github.microservice.net.ResultContent.buildFail("未加入机构");
+        }
+
+        PayAccount payAccount = payAccountService.getOrgChildren(projectOid, oidList.get(0), PaymentChannelType.WaitSettle);
+
+
+        if (param.getPeriodType().equals(PeriodType.day)){
+            Long monthStartTime = DateUtils.getMonthStartTime(param.getYear(), param.getMonth());
+            Long monthEndTime = DateUtils.getMonthEndTime(param.getYear(), param.getMonth());
+            GeneralLedgerQueryTransactionLogModel queryModel = new GeneralLedgerQueryTransactionLogModel();
+            queryModel.setGeneralLedgerId(new String[]{payAccount.getLedgerId()});
+            queryModel.setStartTime(monthStartTime);
+            queryModel.setEndTime(monthEndTime);
+            queryModel.setFilter(Map.of("transactionType",new Document("$ne", "Settle")));
+//            queryModel.setFilter(Map.of("transactionType", "{$ne : \"Settle\"}"));
+            return transactionLogService.periodDayAggregate(queryModel);
+        } else if (param.getPeriodType().equals(PeriodType.month)){
+            Long yearStartTime = DateUtils.getYearStartTime(param.getYear());
+            Long yearEndTime = DateUtils.getYearEndTime(param.getYear());
+            GeneralLedgerQueryTransactionLogModel queryModel = new GeneralLedgerQueryTransactionLogModel();
+            queryModel.setGeneralLedgerId(new String[]{payAccount.getLedgerId()});
+            queryModel.setStartTime(yearStartTime);
+            queryModel.setEndTime(yearEndTime);
+            queryModel.setFilter(Map.of("transactionType",new Document("$ne", "Settle")));
+            return transactionLogService.periodMonthAggregate(queryModel);
+        }else if (param.getPeriodType().equals(PeriodType.year)){
+            GeneralLedgerQueryTransactionLogModel queryModel = new GeneralLedgerQueryTransactionLogModel();
+            queryModel.setGeneralLedgerId(new String[]{payAccount.getLedgerId()});
+            queryModel.setFilter(Map.of("transactionType",new Document("$ne", "Settle")));
+            return transactionLogService.periodYearAggregate(queryModel);
+        }
+        return com.github.microservice.net.ResultContent.buildFail("周期类型不存在");
+    }
+
 
     private static Long changeRate(Long todayAmount, Long yesterdayAmount) {
         Long amountChangeRate = null;