| | |
| | | String startTime = dto.getStartTime(); |
| | | String endTime = dto.getEndTime(); |
| | | // 将这两个时间转化为localDateTime |
| | | tSettlementConfirm.setStartTime(LocalDateTime.parse(startTime)); |
| | | tSettlementConfirm.setEndTime(LocalDateTime.parse(endTime)); |
| | | // 创建 DateTimeFormatter 对象,指定格式 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| | | |
| | | // 将字符串解析为 LocalDateTime 对象 |
| | | LocalDateTime localDateTime = LocalDateTime.parse(startTime, formatter); |
| | | LocalDateTime localDateTime1 = LocalDateTime.parse(endTime, formatter); |
| | | tSettlementConfirm.setEndTime(localDateTime1); |
| | | tSettlementConfirm.setStartTime(localDateTime); |
| | | |
| | | // 根据站点id和开始时间和结束时间和归属日期 查询充电订单列表 |
| | | QueryWrapper<TChargingOrder> eq = new QueryWrapper<TChargingOrder>() |
| | | .eq("site_id", dto.getSiteId()) |
| | |
| | | BigDecimal paymentAmount = new BigDecimal("0"); |
| | | for (TChargingOrder tChargingOrder : tChargingOrders) { |
| | | // 累加充电总度数 |
| | | if (tChargingOrder.getChargingCapacity()!=null){ |
| | | chargingElectronic = chargingElectronic.add(tChargingOrder.getChargingCapacity()); |
| | | |
| | | } |
| | | // 累加分佣 |
| | | if (tChargingOrder.getSharingAmount()!=null) { |
| | | sharingAmount = sharingAmount.add(tChargingOrder.getSharingAmount()); |
| | | } |
| | | // 累加电费 |
| | | if (tChargingOrder.getElectrovalence()!=null) { |
| | | electrovalence = electrovalence.add(tChargingOrder.getElectrovalence()); |
| | | } |
| | | // 累加服务费 |
| | | if (tChargingOrder.getServiceCharge()!=null){ |
| | | serviceCharge = serviceCharge.add(tChargingOrder.getServiceCharge()); |
| | | |
| | | } |
| | | // 累加会员折扣 |
| | | if (tChargingOrder.getVipDiscountAmount()!=null){ |
| | | vipDiscount = vipDiscount.add(tChargingOrder.getVipDiscountAmount()); |
| | |
| | | if (tChargingOrder.getCouponDiscountAmount()!=null){ |
| | | couponDiscount = couponDiscount.add(tChargingOrder.getCouponDiscountAmount()); |
| | | } |
| | | if (tChargingOrder.getRefundStatus() == 2){ |
| | | if (tChargingOrder.getRefundStatus()!=null &&tChargingOrder.getRefundStatus() == 2){ |
| | | // 如果成功退款 那么减去退款金额 |
| | | paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount().subtract(tChargingOrder.getRefundAmount())); |
| | | }else{ |
| | | if (tChargingOrder.getPaymentAmount()!=null){ |
| | | paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount()); |
| | | } |
| | | } |
| | | } |
| | | // 三方交易手续费 三方收费*0.6% |
| | |
| | | tSettlementConfirm.setVipDiscount(vipDiscount); |
| | | tSettlementConfirm.setCouponDiscount(couponDiscount); |
| | | tSettlementConfirm.setSiteId(dto.getSiteId()); |
| | | tSettlementConfirm.setMeteringElectronic(dto.getData().getMeteringElectronic()); |
| | | tSettlementConfirm.setChargingElectronic(chargingElectronic); |
| | | tSettlementConfirm.setLossElectronic(dto.getData().getLossElectronic()); |
| | | tSettlementConfirm.setIncome(chargingElectronic.add(serviceCharge)); |
| | | tSettlementConfirm.setVenue(dto.getData().getVenue()); |
| | | tSettlementConfirm.setMetering(dto.getData().getMetering()); |
| | | tSettlementConfirm.setClean(dto.getData().getClean()); |
| | | tSettlementConfirm.setMaintain(dto.getData().getMaintain()); |
| | | tSettlementConfirm.setCost(dto.getData().getMaintain().subtract(dto.getData().getVenue().add(dto.getData().getClean()).add(dto.getData().getMaintain()))); |
| | | tSettlementConfirm.setProfitMoney(new BigDecimal("0")); |
| | | tSettlementConfirm.setNewMoney(new BigDecimal("0")); |
| | | tSettlementConfirm.setNewSettlement(new BigDecimal("0")); |
| | | tSettlementConfirm.setVipDiscount(vipDiscount); |
| | | tSettlementConfirm.setCouponDiscount(couponDiscount); |
| | | tSettlementConfirm.setSupplyElectronic(dto.getData().getSupplyElectronic()); |
| | | tSettlementConfirm.setType(dto.getType()); |
| | | |
| | | if (dto.getState() == 2){ |
| | | tSettlementConfirm.setSupplyElectronic(dto.getData().getSupplyElectronic()); |
| | | tSettlementConfirm.setVenue(dto.getData().getVenue()); |
| | | tSettlementConfirm.setMetering(dto.getData().getMetering()); |
| | | tSettlementConfirm.setClean(dto.getData().getClean()); |
| | | tSettlementConfirm.setLossElectronic(dto.getData().getLossElectronic()); |
| | | tSettlementConfirm.setMaintain(dto.getData().getMaintain()); |
| | | |
| | | tSettlementConfirm.setMeteringElectronic(dto.getData().getMeteringElectronic()); |
| | | tSettlementConfirm.setProportionPartner(dto.getData().getProportionPartner()); |
| | | tSettlementConfirm.setProportionMoney(dto.getData().getProportionMoney()); |
| | | tSettlementConfirm.setTotalElectronic(dto.getData().getTotalElectronic()); |
| | |
| | | tSettlementConfirm.setServiceRemark(dto.getData().getServiceRemark()); |
| | | tSettlementConfirm.setDistribution(dto.getData().getDistribution()); |
| | | tSettlementConfirm.setIncome(dto.getData().getElectrovalence().add(dto.getData().getServiceCharge())); |
| | | if (dto.getState() == 2){ |
| | | tSettlementConfirm.setCost(dto.getData().getVenue().add(dto.getData().getClean()).add(dto.getData().getMaintain())); |
| | | tSettlementConfirmMapper.insert(tSettlementConfirm); |
| | | } |
| | | return tSettlementConfirm; |
| | |
| | | tSettlementConfirm.setVipDiscount(vipDiscount); |
| | | tSettlementConfirm.setCouponDiscount(couponDiscount); |
| | | // 本月 |
| | | if (beforeIncome.compareTo(new BigDecimal("0")) == 0){ |
| | | tSettlementConfirm.setIncomePercentage(0+"%"); |
| | | tSettlementConfirm.setIncomePercentage(0+"%"); |
| | | }else{ |
| | | BigDecimal subtract = income.subtract(beforeIncome).divide(beforeIncome).setScale(2, RoundingMode.HALF_DOWN).multiply(new BigDecimal("100")); |
| | | tSettlementConfirm.setIncomePercentage(subtract+"%"); |
| | | tSettlementConfirm.setIncomePercentage(subtract+"%"); |
| | | |
| | | } |
| | | // 比较总利润 收入合计-成本合计 |
| | | BigDecimal subtract1 = income.subtract(cost); |
| | | BigDecimal subtract2 = beforeIncome.subtract(beforeCost); |
| | | if (subtract2.compareTo(new BigDecimal("0")) == 0){ |
| | | tSettlementConfirm.setTotalPercentage(0+"%"); |
| | | }else{ |
| | | tSettlementConfirm.setTotalPercentage(subtract1.subtract(subtract2).divide(subtract2).setScale(2, RoundingMode.HALF_DOWN).multiply(new BigDecimal("100"))+"%"); |
| | | tSettlementConfirm.setIncomePercentage(subtract+"%"); |
| | | } |
| | | tSettlementConfirm.setElectronicRefund(0); |
| | | // 查询上次汇报数据 进行比对涨幅跌幅 |
| | | total.add(tSettlementConfirm); |