| | |
| | | import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient; |
| | | import com.ruoyi.chargingPile.api.feignClient.PartnerClient; |
| | | import com.ruoyi.chargingPile.api.feignClient.SiteClient; |
| | | import com.ruoyi.chargingPile.api.model.Partner; |
| | | import com.ruoyi.chargingPile.api.model.Site; |
| | | import com.ruoyi.chargingPile.api.model.TChargingGun; |
| | | import com.ruoyi.chargingPile.api.model.TChargingPile; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.DateUtils; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.time.temporal.TemporalAdjusters; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | BigDecimal serviceChargeTotal = new BigDecimal("0"); |
| | | BigDecimal commissionAmountTotal = new BigDecimal("0"); |
| | | BigDecimal sharingAmountTotal = new BigDecimal("0"); |
| | | BigDecimal platformIncomeTotal = new BigDecimal("0"); |
| | | BigDecimal partnerIncomeTotal = new BigDecimal("0"); |
| | | BigDecimal chargingCapacityTotal = new BigDecimal("0"); |
| | | BigDecimal discountTotal = new BigDecimal("0"); |
| | | List<TChargingOrderAccountingStrategy> list3 = chargingOrderAccountingStrategyService.list(); |
| | | Map<Integer, BigDecimal> siteServiceShareRatioMap = loadSiteServiceShareRatioMap(); |
| | | |
| | | |
| | | for (ChargingBillListVO chargingBillListVO : list) { |
| | |
| | | tChargingOrders = total.stream().filter(e -> e.getPayTime().isBefore(lastDayOfMonth.withHour(23).withMinute(59).withSecond(59)) |
| | | && e.getPayTime().isAfter(firstDayOfMonth.withHour(0).withMinute(0).withSecond(0))).collect(Collectors.toList()); |
| | | } |
| | | tChargingOrders = filterAccountSettlementOrders(tChargingOrders, chargingBillListVO.getPayType()); |
| | | chargingBillListVO.setPayTypeName(resolveAccountPayTypeName(chargingBillListVO.getPayType(), tChargingOrders)); |
| | | |
| | | |
| | | |
| | |
| | | if (data1!=null && data2!=null){ |
| | | tChargingOrder.setTerminalName(data1.getName()+data2.getName()); |
| | | tChargingOrder.setTerminalCode(data2.getCode()); |
| | | } |
| | | if (tChargingOrder.getRechargePaymentType()!=null && tChargingOrder.getRechargePaymentType()==1){ |
| | | chargingBillListVO.setPayTypeName("微信商户"); |
| | | } |
| | | if (tChargingOrder.getRechargePaymentType()!=null && tChargingOrder.getRechargePaymentType()==2){ |
| | | if (StringUtils.hasLength(chargingBillListVO.getPayTypeName())){ |
| | | chargingBillListVO.setPayTypeName("微信商户+支付宝商户"); |
| | | }else{ |
| | | chargingBillListVO.setPayTypeName("支付宝商户"); |
| | | } |
| | | } |
| | | tChargingOrder.setOrderClassification1("线上订单"); |
| | | tChargingOrder.setRechargePaymentType1("预付"); |
| | |
| | | chargingBillListVO.setChargingCapacity(chargingCapacity == null?BigDecimal.ZERO:chargingCapacity); |
| | | chargingBillListVO.setBillMoney(paymentAmount |
| | | .subtract(commissionAmount.setScale(2,BigDecimal.ROUND_DOWN)).subtract(sharingAmount).setScale(2, BigDecimal.ROUND_DOWN)); |
| | | Map<String, BigDecimal> incomeMap = calculateChargingBillIncome(chargingBillListVO.getType(), chargingBillListVO.getSiteId(), |
| | | chargingBillListVO.getBillWeek(), tChargingOrders, list3, siteServiceShareRatioMap); |
| | | chargingBillListVO.setPlatformIncome(incomeMap.get("platformIncome")); |
| | | chargingBillListVO.setPartnerIncome(incomeMap.get("partnerIncome")); |
| | | switch (chargingBillListVO.getType()){ |
| | | case 1: |
| | | chargingBillListVO.setSiteName("全站"); |
| | |
| | | tChargingOrders = total.stream().filter(e -> e.getPayTime().isBefore(lastDayOfMonth.withHour(23).withMinute(59).withSecond(59)) |
| | | && e.getPayTime().isAfter(firstDayOfMonth.withHour(0).withMinute(0).withSecond(0))).collect(Collectors.toList()); |
| | | } |
| | | tChargingOrders = filterAccountSettlementOrders(tChargingOrders, chargingBillListVO.getPayType()); |
| | | for (TChargingOrder tChargingOrder : tChargingOrders) { |
| | | List<TChargingOrderAccountingStrategy> list4 = list3.stream().filter(e -> e.getChargingOrderId().equals(tChargingOrder.getId())).collect(Collectors.toList()); |
| | | BigDecimal electronic_reduce = list4.stream().map(TChargingOrderAccountingStrategy::getPeriodElectricPrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | |
| | | discountTotal = discountTotal.add(tChargingOrder.getVipDiscountAmount()); |
| | | } |
| | | } |
| | | Map<String, BigDecimal> incomeMap = calculateChargingBillIncome(chargingBillListVO.getType(), chargingBillListVO.getSiteId(), |
| | | chargingBillListVO.getBillWeek(), tChargingOrders, list3, siteServiceShareRatioMap); |
| | | platformIncomeTotal = platformIncomeTotal.add(incomeMap.get("platformIncome")); |
| | | partnerIncomeTotal = partnerIncomeTotal.add(incomeMap.get("partnerIncome")); |
| | | tChargingOrders1.addAll(tChargingOrders); |
| | | chargingBillVO.setExportList(tChargingOrders); |
| | | } |
| | |
| | | chargingBillVO.setServiceCharge(serviceChargeTotal); |
| | | chargingBillVO.setCommissionAmount(commissionAmountTotal); |
| | | chargingBillVO.setSharingAmount(sharingAmountTotal); |
| | | chargingBillVO.setPlatformIncome(platformIncomeTotal.setScale(2, RoundingMode.HALF_UP)); |
| | | chargingBillVO.setPartnerIncome(partnerIncomeTotal.setScale(2, RoundingMode.HALF_UP)); |
| | | chargingBillVO.setDiscount(discountTotal); |
| | | chargingBillVO.setRefundAmount(refundAmountTotal); |
| | | List<TChargingOrder> collect = tChargingOrders1.stream().distinct().collect(Collectors.toList()); |
| | |
| | | List<TAppUser> userList = appUserClient.getAllUser().getData(); |
| | | List<TAppUserCar> carList = appUserCarClient.getAllCar().getData(); |
| | | List<TChargingOrderAccountingStrategy> list3 = chargingOrderAccountingStrategyService.list(); |
| | | Map<Integer, BigDecimal> siteServiceShareRatioMap = loadSiteServiceShareRatioMap(); |
| | | |
| | | Long userId = tokenService.getLoginUser().getUserid(); |
| | | // 查询当前登陆人按钮权限 |
| | |
| | | BigDecimal serviceChargeTotal = new BigDecimal("0"); |
| | | BigDecimal commissionAmountTotal = new BigDecimal("0"); |
| | | BigDecimal sharingAmountTotal = new BigDecimal("0"); |
| | | BigDecimal platformIncomeTotal = new BigDecimal("0"); |
| | | BigDecimal partnerIncomeTotal = new BigDecimal("0"); |
| | | BigDecimal chargingCapacityTotal = new BigDecimal("0"); |
| | | BigDecimal discountTotal = new BigDecimal("0"); |
| | | BigDecimal refundAmountTotal = new BigDecimal("0"); |
| | |
| | | chargingBillListVO.setOrderCount(tChargingOrders.size()); |
| | | // 充电时间秒 |
| | | chargingBillListVO.setChargingSecond(chargingSecond); |
| | | Map<String, BigDecimal> incomeMap = calculateChargingBillIncome(chargingBillListVO.getType(), chargingBillListVO.getSiteId(), |
| | | chargingBillListVO.getBillWeek(), tChargingOrders, list3, siteServiceShareRatioMap); |
| | | chargingBillListVO.setPlatformIncome(incomeMap.get("platformIncome")); |
| | | chargingBillListVO.setPartnerIncome(incomeMap.get("partnerIncome")); |
| | | } |
| | | for (ChargingBillListVO chargingBillListVO : list1) { |
| | | if (dto.getType() == 1){ |
| | |
| | | discountTotal = discountTotal.add(tChargingOrder.getVipDiscountAmount()); |
| | | } |
| | | } |
| | | Map<String, BigDecimal> incomeMap = calculateChargingBillIncome(chargingBillListVO.getType(), chargingBillListVO.getSiteId(), |
| | | chargingBillListVO.getBillWeek(), tChargingOrders, list3, siteServiceShareRatioMap); |
| | | platformIncomeTotal = platformIncomeTotal.add(incomeMap.get("platformIncome")); |
| | | partnerIncomeTotal = partnerIncomeTotal.add(incomeMap.get("partnerIncome")); |
| | | } |
| | | chargingBillVO.setChargingCapacity(chargingCapacityTotal); |
| | | chargingBillVO.setPaymentAmount(paymentAmountTotal.subtract(commissionAmountTotal).subtract(sharingAmountTotal).setScale(2, BigDecimal.ROUND_DOWN)); |
| | |
| | | chargingBillVO.setOrderCount(orderCount); |
| | | chargingBillVO.setCommissionAmount(commissionAmountTotal.setScale(2, BigDecimal.ROUND_DOWN)); |
| | | chargingBillVO.setSharingAmount(sharingAmountTotal.setScale(2, BigDecimal.ROUND_DOWN)); |
| | | chargingBillVO.setPlatformIncome(platformIncomeTotal.setScale(2, RoundingMode.HALF_UP)); |
| | | chargingBillVO.setPartnerIncome(partnerIncomeTotal.setScale(2, RoundingMode.HALF_UP)); |
| | | chargingBillVO.setDiscount(discountTotal.setScale(2, BigDecimal.ROUND_DOWN)); |
| | | pageInfo.setRecords(chargingBillListVOS); |
| | | chargingBillVO.setList(pageInfo); |
| | |
| | | List<Map<String, Object>> list = chargingSettlementBillService.queryList(pageInfo, dto.getType(), dto.getState(), dto.getDateRange(), statisticalDateType, dto.getSiteIds()); |
| | | ChargingBillWapper chargingBillVO = new ChargingBillWapper(); |
| | | List<Map<String, Object>> pageList = new ArrayList<>(); |
| | | List<TChargingOrder> total = chargingOrderList.selectList(new LambdaQueryWrapper<>(TChargingOrder.class) |
| | | .isNotNull(TChargingOrder::getPayTime)); |
| | | List<TChargingOrderAccountingStrategy> strategyList = chargingOrderAccountingStrategyService.list(); |
| | | Map<Integer, BigDecimal> siteServiceShareRatioMap = loadSiteServiceShareRatioMap(); |
| | | if(null != list){ |
| | | for (Map<String, Object> map : list) { |
| | | Integer site_id = Integer.valueOf(map.get("site_id").toString()); |
| | |
| | | String chargingCapacity = map.get("total_electricity").toString(); |
| | | String electrovalence = map.get("total_electricity_charge").toString(); |
| | | String serviceCharge = map.get("total_service_fee").toString(); |
| | | Map<String, BigDecimal> incomeMap = calculateChargingBillIncome(dto.getType(), site_id, billingCycle, total, strategyList, siteServiceShareRatioMap); |
| | | Map<String, Object> data1 = new HashMap<>(); |
| | | data1.put("code", code); |
| | | data1.put("orderState", 2); |
| | |
| | | data1.put("commissionAmount", commissionAmount); |
| | | data1.put("sharingAmount", sharingAmount); |
| | | data1.put("paymentAmount", paymentAmount); |
| | | data1.put("platformIncome", incomeMap.get("platformIncome")); |
| | | data1.put("partnerIncome", incomeMap.get("partnerIncome")); |
| | | data1.put("chargingCapacity", chargingCapacity); |
| | | data1.put("electrovalence", electrovalence); |
| | | data1.put("serviceCharge", serviceCharge); |
| | |
| | | BigDecimal commissionAmount = (null == map || null == map.get("platformFee")) ? BigDecimal.ZERO : new BigDecimal(map.get("platformFee").toString()); |
| | | BigDecimal sharingAmount = (null == map || null == map.get("tripartiteCommission")) ? BigDecimal.ZERO : new BigDecimal(map.get("tripartiteCommission").toString()); |
| | | BigDecimal discount = (null == map || null == map.get("couponDeduction")) ? BigDecimal.ZERO : new BigDecimal(map.get("couponDeduction").toString()); |
| | | BigDecimal platformIncome = BigDecimal.ZERO; |
| | | BigDecimal partnerIncome = BigDecimal.ZERO; |
| | | PageInfo<Map<String, Object>> sumPageInfo = new PageInfo<>(1, 100000); |
| | | List<Map<String, Object>> sumList = chargingSettlementBillService.queryList(sumPageInfo, dto.getType(), dto.getState(), dto.getDateRange(), statisticalDateType, dto.getSiteIds()); |
| | | if (sumList != null) { |
| | | for (Map<String, Object> row : sumList) { |
| | | Integer siteId = Integer.valueOf(row.get("site_id").toString()); |
| | | String billingCycle = row.get("billingCycle").toString(); |
| | | Map<String, BigDecimal> incomeMap = calculateChargingBillIncome(dto.getType(), siteId, billingCycle, total, strategyList, siteServiceShareRatioMap); |
| | | platformIncome = platformIncome.add(incomeMap.get("platformIncome")); |
| | | partnerIncome = partnerIncome.add(incomeMap.get("partnerIncome")); |
| | | } |
| | | } |
| | | chargingBillVO.setChargingCapacity(chargingCapacity); |
| | | chargingBillVO.setPaymentAmount(paymentAmount.setScale(2, BigDecimal.ROUND_DOWN)); |
| | | chargingBillVO.setOrderAmount(orderAmount.setScale(2, BigDecimal.ROUND_DOWN)); |
| | |
| | | chargingBillVO.setOrderCount(orderCount); |
| | | chargingBillVO.setCommissionAmount(commissionAmount.setScale(2, BigDecimal.ROUND_DOWN)); |
| | | chargingBillVO.setSharingAmount(sharingAmount.setScale(2, BigDecimal.ROUND_DOWN)); |
| | | chargingBillVO.setPlatformIncome(platformIncome.setScale(2, RoundingMode.HALF_UP)); |
| | | chargingBillVO.setPartnerIncome(partnerIncome.setScale(2, RoundingMode.HALF_UP)); |
| | | chargingBillVO.setDiscount(discount.setScale(2, BigDecimal.ROUND_DOWN)); |
| | | pageInfo.setRecords(pageList); |
| | | chargingBillVO.setList(pageInfo); |
| | |
| | | List<TAppUser> userList = appUserClient.getAllUser().getData(); |
| | | List<TAppUserCar> carList = appUserCarClient.getAllCar().getData(); |
| | | List<TChargingOrderAccountingStrategy> list3 = chargingOrderAccountingStrategyService.list(); |
| | | Map<Integer, BigDecimal> siteServiceShareRatioMap = loadSiteServiceShareRatioMap(); |
| | | |
| | | Long userId = tokenService.getLoginUser().getUserid(); |
| | | // 查询当前登陆人按钮权限 |
| | |
| | | BigDecimal serviceChargeTotal = new BigDecimal("0"); |
| | | BigDecimal commissionAmountTotal = new BigDecimal("0"); |
| | | BigDecimal sharingAmountTotal = new BigDecimal("0"); |
| | | BigDecimal platformIncomeTotal = new BigDecimal("0"); |
| | | BigDecimal partnerIncomeTotal = new BigDecimal("0"); |
| | | BigDecimal chargingCapacityTotal = new BigDecimal("0"); |
| | | BigDecimal discountTotal = new BigDecimal("0"); |
| | | BigDecimal refundAmountTotal = new BigDecimal("0"); |
| | |
| | | chargingBillListVO.setOrderCount(tChargingOrders.size()); |
| | | // 充电时间秒 |
| | | chargingBillListVO.setChargingSecond(chargingSecond); |
| | | Map<String, BigDecimal> incomeMap = calculateChargingBillIncome(chargingBillListVO.getType(), chargingBillListVO.getSiteId(), |
| | | chargingBillListVO.getBillWeek(), tChargingOrders, list3, siteServiceShareRatioMap); |
| | | chargingBillListVO.setPlatformIncome(incomeMap.get("platformIncome")); |
| | | chargingBillListVO.setPartnerIncome(incomeMap.get("partnerIncome")); |
| | | } |
| | | for (ChargingBillListVO chargingBillListVO : list1) { |
| | | if (dto.getType() == 1){ |
| | |
| | | discountTotal = discountTotal.add(tChargingOrder.getVipDiscountAmount()); |
| | | } |
| | | } |
| | | Map<String, BigDecimal> incomeMap = calculateChargingBillIncome(chargingBillListVO.getType(), chargingBillListVO.getSiteId(), |
| | | chargingBillListVO.getBillWeek(), tChargingOrders, list3, siteServiceShareRatioMap); |
| | | platformIncomeTotal = platformIncomeTotal.add(incomeMap.get("platformIncome")); |
| | | partnerIncomeTotal = partnerIncomeTotal.add(incomeMap.get("partnerIncome")); |
| | | } |
| | | chargingBillVO.setChargingCapacity(chargingCapacityTotal); |
| | | chargingBillVO.setPaymentAmount(paymentAmountTotal.subtract(commissionAmountTotal).subtract(sharingAmountTotal).setScale(2, BigDecimal.ROUND_DOWN)); |
| | |
| | | chargingBillVO.setOrderCount(orderCount); |
| | | chargingBillVO.setCommissionAmount(commissionAmountTotal.setScale(2, BigDecimal.ROUND_DOWN)); |
| | | chargingBillVO.setSharingAmount(sharingAmountTotal.setScale(2, BigDecimal.ROUND_DOWN)); |
| | | chargingBillVO.setPlatformIncome(platformIncomeTotal.setScale(2, RoundingMode.HALF_UP)); |
| | | chargingBillVO.setPartnerIncome(partnerIncomeTotal.setScale(2, RoundingMode.HALF_UP)); |
| | | chargingBillVO.setDiscount(discountTotal.setScale(2, BigDecimal.ROUND_DOWN)); |
| | | pageInfo.setRecords(chargingBillListVOS); |
| | | chargingBillVO.setList(pageInfo); |
| | | return chargingBillVO; |
| | | } |
| | | |
| | | private Map<String, BigDecimal> calculateChargingBillIncome(Integer billType, Integer billSiteId, String billingCycle, |
| | | List<TChargingOrder> allOrders, |
| | | List<TChargingOrderAccountingStrategy> allStrategies, |
| | | Map<Integer, BigDecimal> siteServiceShareRatioMap) { |
| | | Map<String, BigDecimal> incomeMap = new HashMap<>(); |
| | | BigDecimal platformIncome = BigDecimal.ZERO; |
| | | BigDecimal partnerIncome = BigDecimal.ZERO; |
| | | if (!StringUtils.hasLength(billingCycle) || allOrders == null || allOrders.isEmpty()) { |
| | | incomeMap.put("platformIncome", platformIncome); |
| | | incomeMap.put("partnerIncome", partnerIncome); |
| | | return incomeMap; |
| | | } |
| | | |
| | | LocalDate billMonth = LocalDate.parse(billingCycle + "-01"); |
| | | LocalDateTime firstDayOfMonth = billMonth.withDayOfMonth(1).atStartOfDay(); |
| | | LocalDateTime lastDayOfMonth = billMonth.with(TemporalAdjusters.lastDayOfMonth()).atTime(23, 59, 59); |
| | | List<TChargingOrderAccountingStrategy> strategies = allStrategies == null ? Collections.emptyList() : allStrategies; |
| | | for (TChargingOrder order : allOrders) { |
| | | if (order == null || order.getPayTime() == null) { |
| | | continue; |
| | | } |
| | | if (billType != null && billType == 2 && !billSiteId.equals(order.getSiteId())) { |
| | | continue; |
| | | } |
| | | if (order.getPayTime().isBefore(firstDayOfMonth) || order.getPayTime().isAfter(lastDayOfMonth)) { |
| | | continue; |
| | | } |
| | | List<TChargingOrderAccountingStrategy> orderStrategies = strategies.stream() |
| | | .filter(strategy -> strategy.getChargingOrderId().equals(order.getId())) |
| | | .collect(Collectors.toList()); |
| | | BigDecimal electronicReduce = orderStrategies.stream() |
| | | .map(TChargingOrderAccountingStrategy::getPeriodElectricPrice) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal serviceReduce = orderStrategies.stream() |
| | | .map(TChargingOrderAccountingStrategy::getPeriodServicePrice) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal paymentAmount; |
| | | if (Integer.valueOf(2).equals(order.getOrderSource())) { |
| | | paymentAmount = electronicReduce.add(serviceReduce.multiply(new BigDecimal("0.8")).setScale(2, RoundingMode.DOWN)); |
| | | } else { |
| | | paymentAmount = electronicReduce.add(serviceReduce); |
| | | if (Integer.valueOf(1).equals(order.getOrderSource())) { |
| | | BigDecimal serviceShareRatio = siteServiceShareRatioMap.get(order.getSiteId()); |
| | | if (serviceShareRatio != null && serviceShareRatio.compareTo(BigDecimal.ZERO) > 0) { |
| | | partnerIncome = partnerIncome.add(serviceReduce.multiply(serviceShareRatio).divide(new BigDecimal("100"), 2, RoundingMode.HALF_UP)); |
| | | } |
| | | } |
| | | } |
| | | platformIncome = platformIncome.add(paymentAmount); |
| | | } |
| | | platformIncome = platformIncome.subtract(partnerIncome).max(BigDecimal.ZERO); |
| | | incomeMap.put("platformIncome", platformIncome.setScale(2, RoundingMode.HALF_UP)); |
| | | incomeMap.put("partnerIncome", partnerIncome.setScale(2, RoundingMode.HALF_UP)); |
| | | return incomeMap; |
| | | } |
| | | |
| | | private List<TChargingOrder> filterAccountSettlementOrders(List<TChargingOrder> orders, Integer payType) { |
| | | if (orders == null || orders.isEmpty() || payType == null || payType == 0) { |
| | | return orders == null ? Collections.emptyList() : orders; |
| | | } |
| | | return orders.stream() |
| | | .filter(order -> accountSettlementOrderMatches(order, payType)) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | private boolean accountSettlementOrderMatches(TChargingOrder order, Integer payType) { |
| | | if (order == null || payType == null) { |
| | | return true; |
| | | } |
| | | if (payType == 1) { |
| | | return !isIcbcOrder(order) && Integer.valueOf(1).equals(order.getRechargePaymentType()); |
| | | } |
| | | if (payType == 2) { |
| | | return !isIcbcOrder(order) && (Integer.valueOf(2).equals(order.getRechargePaymentType()) || Integer.valueOf(3).equals(order.getRechargePaymentType())); |
| | | } |
| | | if (payType == 3) { |
| | | return isIcbcOrder(order) && Integer.valueOf(1).equals(order.getOrderSource()); |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | private String resolveAccountPayTypeName(Integer payType, List<TChargingOrder> orders) { |
| | | if (payType != null && payType != 0) { |
| | | switch (payType) { |
| | | case 1: |
| | | return "微信商户"; |
| | | case 2: |
| | | return "支付宝商户"; |
| | | case 3: |
| | | return "工商银行商户"; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | boolean hasWx = false; |
| | | boolean hasAli = false; |
| | | boolean hasIcbc = false; |
| | | if (orders != null) { |
| | | for (TChargingOrder order : orders) { |
| | | if (isIcbcOrder(order)) { |
| | | hasIcbc = true; |
| | | } else if (Integer.valueOf(1).equals(order.getRechargePaymentType())) { |
| | | hasWx = true; |
| | | } else if (Integer.valueOf(2).equals(order.getRechargePaymentType()) || Integer.valueOf(3).equals(order.getRechargePaymentType())) { |
| | | hasAli = true; |
| | | } |
| | | } |
| | | } |
| | | List<String> names = new ArrayList<>(); |
| | | if (hasWx) { |
| | | names.add("微信商户"); |
| | | } |
| | | if (hasAli) { |
| | | names.add("支付宝商户"); |
| | | } |
| | | if (hasIcbc) { |
| | | names.add("工商银行商户"); |
| | | } |
| | | return names.isEmpty() ? "" : String.join("+", names); |
| | | } |
| | | |
| | | private boolean isIcbcOrder(TChargingOrder order) { |
| | | return order != null && "ICBC".equals(order.getSourceName()); |
| | | } |
| | | |
| | | private Map<Integer, BigDecimal> loadSiteServiceShareRatioMap() { |
| | | Map<Integer, BigDecimal> ratioMap = new HashMap<>(); |
| | | R<List<Site>> siteResult = siteClient.getSiteAll(); |
| | | R<List<Partner>> partnerResult = siteClient.getAllPartner(); |
| | | List<Site> sites = siteResult == null ? Collections.emptyList() : siteResult.getData(); |
| | | List<Partner> partners = partnerResult == null ? Collections.emptyList() : partnerResult.getData(); |
| | | if (sites == null || sites.isEmpty() || partners == null || partners.isEmpty()) { |
| | | return ratioMap; |
| | | } |
| | | Map<Integer, Partner> partnerMap = partners.stream() |
| | | .filter(partner -> partner != null && partner.getId() != null) |
| | | .collect(Collectors.toMap(Partner::getId, partner -> partner, (left, right) -> left)); |
| | | for (Site site : sites) { |
| | | if (site == null || site.getId() == null || site.getPartnerId() == null) { |
| | | continue; |
| | | } |
| | | Partner partner = partnerMap.get(site.getPartnerId()); |
| | | if (partner != null && partner.getServiceShareRatio() != null) { |
| | | ratioMap.put(site.getId(), partner.getServiceShareRatio()); |
| | | } |
| | | } |
| | | return ratioMap; |
| | | } |
| | | } |