| | |
| | | } |
| | | |
| | | /** |
| | | * 统计近六月订单收入支付方式占比;服务层聚合避免复杂CASE SQL在当前数据库驱动中转换异常。 |
| | | * 统计近六月订单收入支付方式占比;历史订单缺少支付渠道时归入其他支付,避免漏算。 |
| | | */ |
| | | @Override |
| | | public List<SixIncomeCircleDto> payTypeCircle(LocalDate sixBefore, List<Integer> siteIds, Boolean partnerView) { |
| | | if (siteIds == null || siteIds.isEmpty()) { |
| | | return buildPayTypeCircleData(BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO); |
| | | return buildPayTypeCircleData(BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO, BigDecimal.ZERO); |
| | | } |
| | | if (Boolean.TRUE.equals(partnerView)) { |
| | | return buildPartnerShareCircleData(this.baseMapper.chargingOrderShareIncomeByPayChannel(sixBefore, siteIds)); |
| | |
| | | BigDecimal wechatAmount = BigDecimal.ZERO; |
| | | BigDecimal alipayAmount = BigDecimal.ZERO; |
| | | BigDecimal balanceAmount = BigDecimal.ZERO; |
| | | BigDecimal otherAmount = BigDecimal.ZERO; |
| | | for (TChargingOrder order : orders) { |
| | | BigDecimal thirdPayAmount = getThirdPayNetAmount(order); |
| | | BigDecimal balancePayAmount = getBalancePayNetAmount(order); |
| | | Integer rechargePaymentType = order.getRechargePaymentType(); |
| | | if (Integer.valueOf(1).equals(rechargePaymentType)) { |
| | | wechatAmount = wechatAmount.add(thirdPayAmount); |
| | | } |
| | | if (Integer.valueOf(2).equals(rechargePaymentType) || Integer.valueOf(3).equals(rechargePaymentType)) { |
| | | } else if (Integer.valueOf(2).equals(rechargePaymentType) || Integer.valueOf(3).equals(rechargePaymentType)) { |
| | | alipayAmount = alipayAmount.add(thirdPayAmount); |
| | | } else { |
| | | otherAmount = otherAmount.add(thirdPayAmount); |
| | | } |
| | | Integer payMethod = order.getPayMethod(); |
| | | if (Integer.valueOf(1).equals(payMethod) || Integer.valueOf(2).equals(payMethod)) { |
| | | balanceAmount = balanceAmount.add(balancePayAmount); |
| | | } |
| | | } |
| | | return buildPayTypeCircleData(wechatAmount, alipayAmount, balanceAmount); |
| | | return buildPayTypeCircleData(wechatAmount, alipayAmount, balanceAmount, otherAmount); |
| | | } |
| | | |
| | | private List<SixIncomeCircleDto> buildPartnerShareCircleData(List<Map<String, Object>> rows) { |
| | | BigDecimal wechatAmount = BigDecimal.ZERO; |
| | | BigDecimal alipayAmount = BigDecimal.ZERO; |
| | | BigDecimal balanceAmount = BigDecimal.ZERO; |
| | | BigDecimal otherAmount = BigDecimal.ZERO; |
| | | if (rows != null) { |
| | | for (Map<String, Object> row : rows) { |
| | | String channel = row.get("payChannel") == null ? "" : row.get("payChannel").toString(); |
| | |
| | | } else if ("BALANCE".equalsIgnoreCase(channel) || "WHITELIST".equalsIgnoreCase(channel)) { |
| | | balanceAmount = balanceAmount.add(shareAmount); |
| | | } else { |
| | | wechatAmount = wechatAmount.add(shareAmount); |
| | | otherAmount = otherAmount.add(shareAmount); |
| | | } |
| | | } |
| | | } |
| | | return buildPayTypeCircleData(wechatAmount, alipayAmount, balanceAmount); |
| | | return buildPayTypeCircleData(wechatAmount, alipayAmount, balanceAmount, otherAmount); |
| | | } |
| | | |
| | | /** |
| | | * 构造固定三类支付方式数据,保证前端饼图在无订单时也有稳定结构。 |
| | | */ |
| | | private List<SixIncomeCircleDto> buildPayTypeCircleData(BigDecimal wechatAmount, BigDecimal alipayAmount, BigDecimal balanceAmount) { |
| | | private List<SixIncomeCircleDto> buildPayTypeCircleData(BigDecimal wechatAmount, BigDecimal alipayAmount, |
| | | BigDecimal balanceAmount, BigDecimal otherAmount) { |
| | | List<SixIncomeCircleDto> data = new ArrayList<>(); |
| | | data.add(buildIncomeCircleDto("微信支付", wechatAmount)); |
| | | data.add(buildIncomeCircleDto("支付宝支付", alipayAmount)); |
| | | data.add(buildIncomeCircleDto("余额支付", balanceAmount)); |
| | | data.add(buildIncomeCircleDto("其他支付", otherAmount)); |
| | | return data; |
| | | } |
| | | |