|
@@ -14,6 +14,7 @@ import com.github.microservice.pay.client.type.ledger.TransactionType;
|
|
|
import com.github.microservice.types.payment.PaymentChannelType;
|
|
import com.github.microservice.types.payment.PaymentChannelType;
|
|
|
import com.zhongshu.card.client.model.pay.*;
|
|
import com.zhongshu.card.client.model.pay.*;
|
|
|
import com.zhongshu.card.client.type.PeriodType;
|
|
import com.zhongshu.card.client.type.PeriodType;
|
|
|
|
|
+import com.zhongshu.card.client.type.SettleStatus;
|
|
|
import com.zhongshu.card.client.utils.DateUtils;
|
|
import com.zhongshu.card.client.utils.DateUtils;
|
|
|
import com.zhongshu.card.server.core.domain.pay.PayAccount;
|
|
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.base.SuperService;
|
|
@@ -333,6 +334,147 @@ public class OrgOverviewService extends SuperService {
|
|
|
return transactionLogService.settleAggregate(queryModel);
|
|
return transactionLogService.settleAggregate(queryModel);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public Object querySettleBillDetail(Pageable pageable, SettleDetailQueryModel settleDetailQueryModel){
|
|
|
|
|
+ String projectOid = settleDetailQueryModel.getProjectOid();
|
|
|
|
|
+ if (StringUtils.isBlank(projectOid)) {
|
|
|
|
|
+ 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);
|
|
|
|
|
+
|
|
|
|
|
+ GeneralLedgerQueryTransactionLogModel queryModel = new GeneralLedgerQueryTransactionLogModel();
|
|
|
|
|
+
|
|
|
|
|
+ PageableModel pageableModel = new PageableModel();
|
|
|
|
|
+ pageableModel.setPage(pageable.getPageNumber());
|
|
|
|
|
+ pageableModel.setSize(pageable.getPageSize());
|
|
|
|
|
+ pageableModel.setSort("createTime");
|
|
|
|
|
+ pageableModel.setDirection(Sort.Direction.DESC);
|
|
|
|
|
+ queryModel.setPage(pageableModel);
|
|
|
|
|
+
|
|
|
|
|
+ queryModel.setGeneralLedgerId(new String[]{payAccount.getLedgerId()});
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> filter = new HashMap<>();
|
|
|
|
|
+ Optional.ofNullable(settleDetailQueryModel.getTransactionLogId()).ifPresent((it) ->{
|
|
|
|
|
+ filter.put("transactionLogId", it);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Optional.ofNullable(settleDetailQueryModel.getLedgerEntry()).ifPresent((it) ->{
|
|
|
|
|
+ filter.put("ledgerEntry", it);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Optional.ofNullable(settleDetailQueryModel.getOrderNo()).ifPresent((it) ->{
|
|
|
|
|
+ filter.put("orderNumber", it);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Optional.ofNullable(settleDetailQueryModel.getPaymentType()).ifPresent((it) ->{
|
|
|
|
|
+ filter.put("meta.paymentType", it);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ String createDate = settleDetailQueryModel.getCreateDate();
|
|
|
|
|
+ if (StringUtils.isBlank(createDate)){
|
|
|
|
|
+ return com.github.microservice.net.ResultContent.buildFail("createDate不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String formatCreateTime = DateUtils.paresTime(DateUtils.timeToLong(createDate, DateUtils.pattern), DateUtils.pattern);
|
|
|
|
|
+
|
|
|
|
|
+ filter.put("meta.settleStatus", SettleStatus.Settle);
|
|
|
|
|
+ filter.put("meta.settleTime", formatCreateTime);
|
|
|
|
|
+ filter.put("transactionType",new Document("$ne", "Settle"));
|
|
|
|
|
+ queryModel.setFilter(filter);
|
|
|
|
|
+ return ResultContent.buildContent(transactionLogService.aggregate(queryModel).getContent().getPages());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public Object queryWithdrawBill(Pageable pageable, PeriodQueryModel param){
|
|
|
|
|
+ String projectOid = param.getProjectOid();
|
|
|
|
|
+ if (StringUtils.isBlank(param.getProjectOid())){
|
|
|
|
|
+ projectOid = getCurrentProjectOid();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ PageableModel pageableModel = new PageableModel();
|
|
|
|
|
+ pageableModel.setPage(pageable.getPageNumber());
|
|
|
|
|
+ pageableModel.setSize(pageable.getPageSize());
|
|
|
|
|
+
|
|
|
|
|
+ List<String> oidList = organizationUserService.getUserOrgListOids(getCurrentUserId(), projectOid);
|
|
|
|
|
+ if (oidList==null || oidList.isEmpty()){
|
|
|
|
|
+ return com.github.microservice.net.ResultContent.buildFail("未加入机构");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //获取已结算账本
|
|
|
|
|
+ PayAccount settleAccount = payAccountService.getOrgChildren(projectOid, oidList.get(0), PaymentChannelType.Settle);
|
|
|
|
|
+
|
|
|
|
|
+ GeneralLedgerQueryTransactionLogModel queryModel = new GeneralLedgerQueryTransactionLogModel();
|
|
|
|
|
+ queryModel.setGeneralLedgerId(new String[]{settleAccount.getLedgerId()});
|
|
|
|
|
+ queryModel.setStartTime(param.getStartTime());
|
|
|
|
|
+ queryModel.setEndTime(param.getEndTime());
|
|
|
|
|
+
|
|
|
|
|
+// queryModel.setFilter(Map.of("transactionType","Withdrawal"));
|
|
|
|
|
+ queryModel.setFilter(Map.of("transactionType",new Document("$in", List.of(TransactionType.Withdrawal, TransactionType.WithdrawRefund))));
|
|
|
|
|
+ queryModel.setPage(pageableModel);
|
|
|
|
|
+ return transactionLogService.withdrawAggregate(queryModel);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public Object queryWithdrawBillDetail(Pageable pageable, SettleDetailQueryModel settleDetailQueryModel){
|
|
|
|
|
+ String projectOid = settleDetailQueryModel.getProjectOid();
|
|
|
|
|
+ if (StringUtils.isBlank(projectOid)) {
|
|
|
|
|
+ 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.Settle);
|
|
|
|
|
+
|
|
|
|
|
+ GeneralLedgerQueryTransactionLogModel queryModel = new GeneralLedgerQueryTransactionLogModel();
|
|
|
|
|
+
|
|
|
|
|
+ PageableModel pageableModel = new PageableModel();
|
|
|
|
|
+ pageableModel.setPage(pageable.getPageNumber());
|
|
|
|
|
+ pageableModel.setSize(pageable.getPageSize());
|
|
|
|
|
+ pageableModel.setSort("createTime");
|
|
|
|
|
+ pageableModel.setDirection(Sort.Direction.DESC);
|
|
|
|
|
+ queryModel.setPage(pageableModel);
|
|
|
|
|
+
|
|
|
|
|
+ queryModel.setGeneralLedgerId(new String[]{payAccount.getLedgerId()});
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> filter = new HashMap<>();
|
|
|
|
|
+ Optional.ofNullable(settleDetailQueryModel.getTransactionLogId()).ifPresent((it) ->{
|
|
|
|
|
+ filter.put("transactionLogId", it);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Optional.ofNullable(settleDetailQueryModel.getLedgerEntry()).ifPresent((it) ->{
|
|
|
|
|
+ filter.put("ledgerEntry", it);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Optional.ofNullable(settleDetailQueryModel.getOrderNo()).ifPresent((it) ->{
|
|
|
|
|
+ filter.put("orderNumber", it);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ Optional.ofNullable(settleDetailQueryModel.getPaymentType()).ifPresent((it) ->{
|
|
|
|
|
+ filter.put("meta.paymentType", it);
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ String createDate = settleDetailQueryModel.getCreateDate();
|
|
|
|
|
+ if (StringUtils.isBlank(createDate)){
|
|
|
|
|
+ return com.github.microservice.net.ResultContent.buildFail("createDate不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Long startTime = DateUtils.timeToLong(createDate, DateUtils.pattern);
|
|
|
|
|
+
|
|
|
|
|
+ queryModel.setStartTime(startTime);
|
|
|
|
|
+ queryModel.setEndTime(startTime + 24*60*60*1000L);
|
|
|
|
|
+
|
|
|
|
|
+ filter.put("transactionType",new Document("$in", List.of(TransactionType.Withdrawal, TransactionType.WithdrawRefund)));
|
|
|
|
|
+ queryModel.setFilter(filter);
|
|
|
|
|
+ return ResultContent.buildContent(transactionLogService.aggregate(queryModel).getContent().getPages());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
private BigDecimal changeRate(Long todayAmount, Long yesterdayAmount) {
|
|
private BigDecimal changeRate(Long todayAmount, Long yesterdayAmount) {
|
|
|
BigDecimal amountChangeRate = BigDecimal.ZERO;
|
|
BigDecimal amountChangeRate = BigDecimal.ZERO;
|