|
|
@@ -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;
|