| | |
| | | public R<List<SixChargingDto>> charge(Integer siteId, Integer partnerId) { |
| | | Long userId = tokenService.getLoginUser().getUserid(); |
| | | SysUser sysUser = sysUserClient.getSysUser(userId).getData(); |
| | | boolean partnerView = isPartnerView(sysUser); |
| | | List<Integer> siteIds = resolvePlatformRevenueSiteIds(userId, sysUser, siteId, partnerId); |
| | | LocalDate sixBefore = PreviousSixMonths.get(); |
| | | //通过siteIds进行sql查询统计 |
| | | List<SixChargingDto> chargingDtos = chargingOrderService.charge(sixBefore, siteIds, false); |
| | | return R.ok(buildLastSixMonths(siteIds, false)); |
| | | } |
| | | |
| | | /** |
| | | * 近6月+当月电站收入:历史月读结算账单、当月补原始订单。 |
| | | * 与「电站收入分析」图表、底部数据分类及加盟商收支同口径。 |
| | | */ |
| | | private List<SixChargingDto> buildLastSixMonths(List<Integer> siteIds, boolean partnerView) { |
| | | LocalDate sixBefore = PreviousSixMonths.get(); |
| | | List<SixChargingDto> chargingDtos = chargingOrderService.charge(sixBefore, siteIds, partnerView); |
| | | LocalDate statisticsEndMonth = resolveStatisticsEndMonth(LocalDate.now(), chargingDtos); |
| | | List<SixChargingDto> sixChargingDtos = generateLastSixMonths(statisticsEndMonth); |
| | | for (SixChargingDto sixChargingDto : sixChargingDtos) { |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | return R.ok(sixChargingDtos); |
| | | |
| | | return sixChargingDtos; |
| | | } |
| | | |
| | | |
| | |
| | | SysUser sysUser = sysUserClient.getSysUser(userId).getData(); |
| | | boolean partnerView = isPartnerView(sysUser); |
| | | List<Integer> siteIds = resolvePlatformRevenueSiteIds(userId, sysUser, siteId, partnerId); |
| | | Map<String,Object> map = chargingOrderService.countAll(siteIds, false); |
| | | if (map == null) { |
| | | map = new HashMap<String,Object>(); |
| | | } |
| | | LocalDate sixBefore = PreviousSixMonths.get(); |
| | | Map<String,Object> map = new HashMap<String,Object>(); |
| | | // 电费/服务费与上方「电站收入分析」图表同口径:近6月结算账单 + 当月原始订单,保证底部合计=图表6个月相加 |
| | | List<SixChargingDto> sixChargingDtos = buildLastSixMonths(siteIds, false); |
| | | map.put("electrovalence", sixChargingDtos.stream() |
| | | .filter(Objects::nonNull) |
| | | .map(SixChargingDto::getElectrovalence) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | map.put("service_charge", sixChargingDtos.stream() |
| | | .filter(Objects::nonNull) |
| | | .map(SixChargingDto::getServiceCharge) |
| | | .filter(Objects::nonNull) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add)); |
| | | // 合作商分成/三方平台分佣按近6月结算口径统计(与图表月份窗口一致) |
| | | Map<String,Object> sub = chargingOrderService.countAll(siteIds, false, sixBefore); |
| | | map.put("commission_amount", sub == null ? BigDecimal.ZERO : sub.get("commission_amount")); |
| | | map.put("sharing_amount", sub == null ? BigDecimal.ZERO : sub.get("sharing_amount")); |
| | | boolean platformVisible = !partnerView; |
| | | if(platformVisible){ |
| | | R<BigDecimal> parkingAmountResult = parkingLotClient.getRecordAmount(siteIds); |
| | | R<BigDecimal> parkingAmountResult = parkingLotClient.getRecordAmount(siteIds, sixBefore.toString()); |
| | | BigDecimal data = parkingAmountResult == null || parkingAmountResult.getData() == null |
| | | ? BigDecimal.ZERO : parkingAmountResult.getData(); |
| | | map.put("parkingAmount",data); |
| | | BigDecimal data1 = shoppingOrderService.getSumAmount(); |
| | | BigDecimal data1 = shoppingOrderService.getSumAmount(sixBefore); |
| | | map.put("shopAmount",data1); |
| | | BigDecimal data2 = vipOrderService.getSumAmout(); |
| | | BigDecimal data2 = vipOrderService.getSumAmout(sixBefore); |
| | | map.put("vipAmount",data2); |
| | | }else{ |
| | | map.put("parkingAmount",0); |