| | |
| | | package com.ruoyi.order.service.impl; |
| | | |
| | | import cn.hutool.core.date.DateUtil; |
| | | import com.alibaba.fastjson2.JSON; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.annotation.TableField; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | |
| | | import com.ruoyi.integration.api.feignClient.*; |
| | | import com.ruoyi.integration.api.model.*; |
| | | import com.ruoyi.integration.api.vo.GetPlatformStopChargingReply; |
| | | import com.ruoyi.order.api.dto.SettlementConfirmAdd; |
| | | import com.ruoyi.order.api.feignClient.AccountingStrategyDetailOrderClient; |
| | | import com.ruoyi.order.api.feignClient.ChargingOrderAccountingStrategyClient; |
| | | import com.ruoyi.order.api.model.*; |
| | | import com.ruoyi.order.api.query.ChargingOrderQuery; |
| | | import com.ruoyi.order.api.query.SettlementListQuery; |
| | | import com.ruoyi.order.api.query.UploadRealTimeMonitoringDataQuery; |
| | | import com.ruoyi.order.api.vo.ChargingOrderListVO; |
| | | import com.ruoyi.order.api.vo.ChargingOrderTimeVO; |
| | | import com.ruoyi.order.api.vo.ChargingOrderVO; |
| | | import com.ruoyi.order.api.vo.TCharingOrderVO; |
| | | import com.ruoyi.order.api.vo.*; |
| | | import com.ruoyi.order.dto.*; |
| | | import com.ruoyi.order.mapper.TChargingOrderMapper; |
| | | import com.ruoyi.order.mapper.TSettlementConfirmMapper; |
| | | import com.ruoyi.order.service.TChargingOrderAccountingStrategyService; |
| | | import com.ruoyi.order.service.TChargingOrderRefundService; |
| | | import com.ruoyi.order.service.TChargingOrderService; |
| | |
| | | import com.ruoyi.order.vo.ChargingOrderListInfoVO; |
| | | import com.ruoyi.other.api.domain.TIntegralRule; |
| | | import com.ruoyi.other.api.feignClient.IntegralRuleClient; |
| | | import com.ruoyi.other.api.feignClient.OtherClient; |
| | | import com.ruoyi.other.api.feignClient.RoleSiteClient; |
| | | import com.ruoyi.other.api.feignClient.UserSiteClient; |
| | | import com.ruoyi.payment.api.feignClient.AliPaymentClient; |
| | |
| | | import com.ruoyi.payment.api.model.WxPaymentRefundModel; |
| | | import com.ruoyi.payment.api.vo.*; |
| | | import com.ruoyi.system.api.feignClient.SysUserClient; |
| | | import com.sun.org.apache.bcel.internal.generic.NEW; |
| | | import io.seata.spring.annotation.GlobalTransactional; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import org.slf4j.Logger; |
| | |
| | | |
| | | @Resource |
| | | private ChargingGunClient chargingGunClient; |
| | | |
| | | @Resource |
| | | private TSettlementConfirmMapper tSettlementConfirmMapper; |
| | | |
| | | @Resource |
| | | private SiteClient siteClient; |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private AppUserCarClient appUserCarClient; |
| | | @Resource |
| | |
| | | |
| | | @Resource |
| | | private ChargingPileClient chargingPileClient; |
| | | |
| | | |
| | | @Resource |
| | | private TChargingOrderAccountingStrategyService chargingOrderAccountingStrategyService; |
| | |
| | | |
| | | @Resource |
| | | private AliPaymentClient aliPaymentClient; |
| | | |
| | | |
| | | @Resource |
| | | private AppCouponClient appCouponClient; |
| | |
| | | chargingOrder.setVipDiscountAmount(discountAmount); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | this.save(chargingOrder); |
| | | |
| | |
| | | preChargeCheck1.setFailureCause(failure_cause); |
| | | //启动失败后取消订单,退款操作 |
| | | refund(code); |
| | | order.setStatus(5); |
| | | order.setStatus(-1); |
| | | order.setEndMode(0); |
| | | }else{ |
| | | preChargeCheck1.setStartupSuccess(2); |
| | |
| | | model.setOut_trade_no(chargingOrder.getCode()); |
| | | model.setOut_refund_no(chargingOrderRefund.getRefundCode()); |
| | | model.setReason("充电失败,取消充电订单"); |
| | | model.setNotify_url("http://127.0.0.1:9000/order/t-charging-order/chargingOrderStartupFailureWxRefund"); |
| | | model.setNotify_url("http://221.182.45.100:9000/order/t-charging-order/chargingOrderStartupFailureWxRefund"); |
| | | WxPaymentRefundModel.RefundAmount amount = new WxPaymentRefundModel.RefundAmount(); |
| | | amount.setRefund(rechargeAmount.multiply(new BigDecimal(100)).intValue()); |
| | | amount.setTotal(rechargeAmount.multiply(new BigDecimal(100)).intValue()); |
| | |
| | | model.setOut_trade_no(chargingOrder.getCode()); |
| | | model.setOut_refund_no(chargingOrderRefund.getRefundCode()); |
| | | model.setReason("充电完成退款"); |
| | | model.setNotify_url("http://127.0.0.1:9000/order/t-charging-order/chargingOrderStartupFailureWxRefund"); |
| | | model.setNotify_url("http://221.182.45.100:9000/order/t-charging-order/chargingOrderStartupFailureWxRefund"); |
| | | WxPaymentRefundModel.RefundAmount amount = new WxPaymentRefundModel.RefundAmount(); |
| | | amount.setRefund(refundAmount.multiply(new BigDecimal(100)).intValue()); |
| | | amount.setTotal(rechargeAmount.multiply(new BigDecimal(100)).intValue()); |
| | |
| | | } |
| | | // 不分页 |
| | | List<ChargingOrderListVO> list1 = this.baseMapper.chargingList1(dto,startTime1,startTime2,endTime1,endTime2); |
| | | chargingOrderTimeVO.setExportList(list1); |
| | | chargingOrderTimeVO.setOrderCount(list1.size()); |
| | | // 计算充电总度数 |
| | | BigDecimal electronic = new BigDecimal("0"); |
| | |
| | | chargingOrderListInfoVO.setTerminalName(data2.getName()+data1.getName()); |
| | | } |
| | | chargingOrderListInfoVO.setEndMode(chargingOrder.getEndMode()); |
| | | // todo 周一完善 |
| | | // 获取开始SOC 结束soc |
| | | List<UploadRealTimeMonitoringData> data6 = uploadRealTimeMonitoringDataClient.getDataByOrderCode(chargingOrder.getCode()).getData(); |
| | | if (!data6.isEmpty()){ |
| | |
| | | model.setOut_refund_no(chargingOrderRefund.getRefundCode()); |
| | | model.setTransaction_id(tChargingOrder.getRechargeSerialNumber()); |
| | | model.setReason("取消订单"); |
| | | model.setNotify_url("http://127.0.0.1:9000/order/t-shopping-order/cancelShoppingOrderWxRefund"); |
| | | model.setNotify_url("http://221.182.45.100:9000/order/t-shopping-order/cancelShoppingOrderWxRefund"); |
| | | WxPaymentRefundModel.RefundAmount amount = new WxPaymentRefundModel.RefundAmount(); |
| | | amount.setRefund(payOrderQueryDto.getRefundAmount().multiply(new BigDecimal(100)).intValue()); |
| | | amount.setTotal(tChargingOrder.getPaymentAmount().multiply(new BigDecimal(100)).intValue()); |
| | |
| | | |
| | | return null; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 根据车牌号和开始时间查询充电数据 |
| | | * @param query |
| | | * @return |
| | | */ |
| | | @Override |
| | | public TChargingOrder getChargingOrderByLicensePlate(GetChargingOrderByLicensePlate query) { |
| | | TAppUserCar appUserCar = appUserCarClient.getAppUserCarByLicensePlate(query.getLicensePlate()).getData(); |
| | | if(null == appUserCar){ |
| | | return null; |
| | | } |
| | | TChargingOrder one = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getAppUserCarId, appUserCar.getId()) |
| | | .eq(TChargingOrder::getDelFlag, 0).gt(TChargingOrder::getStartTime, query.getStartTime()) |
| | | .eq(TChargingOrder::getRechargePaymentStatus, 2).ne(TChargingOrder::getStatus, -1)); |
| | | return one; |
| | | } |
| | | |
| | | @Override |
| | | public TSettlementConfirm settlementAdd(SettlementConfirmAdd dto) { |
| | | List<Site> data = siteClient.getSiteByIds(Arrays.asList(dto.getSiteId())).getData(); |
| | | TSettlementConfirm tSettlementConfirm = new TSettlementConfirm(); |
| | | if (!data.isEmpty()){ |
| | | tSettlementConfirm.setSiteName(data.get(0).getName()); |
| | | tSettlementConfirm.setPartnerId(data.get(0).getPartnerId()); |
| | | if (data.get(0).getPartnerId()!=null){ |
| | | Partner data1 = siteClient.getPartnerR(data.get(0).getPartnerId()).getData(); |
| | | if (data1!=null){ |
| | | tSettlementConfirm.setPartnerName(data1.getName()); |
| | | tSettlementConfirm.setPartnerId(data1.getId()); |
| | | } |
| | | } |
| | | } |
| | | String startTime = dto.getStartTime(); |
| | | String endTime = dto.getEndTime(); |
| | | // 将这两个时间转化为localDateTime |
| | | tSettlementConfirm.setStartTime(LocalDateTime.parse(startTime)); |
| | | tSettlementConfirm.setEndTime(LocalDateTime.parse(endTime)); |
| | | // 根据站点id和开始时间和结束时间和归属日期 查询充电订单列表 |
| | | QueryWrapper<TChargingOrder> eq = new QueryWrapper<TChargingOrder>() |
| | | .eq("site_id", dto.getSiteId()) |
| | | .eq("recharge_payment_status",2); |
| | | switch (dto.getType()){ |
| | | case 1: |
| | | eq.between("start_time", startTime, endTime); |
| | | break; |
| | | case 2: |
| | | eq.between("end_time", startTime, endTime); |
| | | break; |
| | | } |
| | | List<TChargingOrder> tChargingOrders = this.baseMapper.selectList(eq); |
| | | // 充电电量 度 |
| | | BigDecimal chargingElectronic = new BigDecimal("0"); |
| | | // 三方收费 分佣 |
| | | BigDecimal sharingAmount = new BigDecimal("0"); |
| | | // 三方交易手续费 三方收费*0.6% |
| | | BigDecimal commissionAmount = new BigDecimal("0"); |
| | | // 累计电费 |
| | | BigDecimal electrovalence = new BigDecimal("0"); |
| | | // 累计服务费 |
| | | BigDecimal serviceCharge = new BigDecimal("0"); |
| | | // 订单手续费 订单支付金额*0.6% |
| | | BigDecimal orderCommission = new BigDecimal("0"); |
| | | // 会员抵扣 |
| | | BigDecimal vipDiscount = new BigDecimal("0"); |
| | | // 优惠券抵扣 |
| | | BigDecimal couponDiscount = new BigDecimal("0"); |
| | | // 支付订单金额 需要减去退款金额 |
| | | BigDecimal paymentAmount = new BigDecimal("0"); |
| | | for (TChargingOrder tChargingOrder : tChargingOrders) { |
| | | // 累加充电总度数 |
| | | chargingElectronic = chargingElectronic.add(tChargingOrder.getChargingCapacity()); |
| | | // 累加分佣 |
| | | sharingAmount = sharingAmount.add(tChargingOrder.getSharingAmount()); |
| | | // 累加电费 |
| | | electrovalence = electrovalence.add(tChargingOrder.getElectrovalence()); |
| | | // 累加服务费 |
| | | 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){ |
| | | // 如果成功退款 那么减去退款金额 |
| | | paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount().subtract(tChargingOrder.getRefundAmount())); |
| | | }else{ |
| | | paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount()); |
| | | } |
| | | } |
| | | // 三方交易手续费 三方收费*0.6% |
| | | commissionAmount = sharingAmount.multiply(new BigDecimal("0.006")); |
| | | // 订单手续费 订单支付金额 - 退款金额*0.6% |
| | | orderCommission = paymentAmount.multiply(new BigDecimal("0.006")); |
| | | tSettlementConfirm.setSharingAmount(sharingAmount); |
| | | tSettlementConfirm.setCommissionAmount(commissionAmount); |
| | | tSettlementConfirm.setElectrovalence(electrovalence); |
| | | // 服务费=总服务费-三费收费-交易手续费-交易手续费-服务费会员抵扣-服务费优惠券抵扣 |
| | | tSettlementConfirm.setServiceCharge(serviceCharge.subtract(commissionAmount).subtract(sharingAmount).subtract(orderCommission).subtract(vipDiscount).subtract(couponDiscount)); |
| | | tSettlementConfirm.setOrderCommission(orderCommission); |
| | | 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().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()); |
| | | tSettlementConfirm.setProportionPartner(dto.getData().getProportionPartner()); |
| | | tSettlementConfirm.setProportionMoney(dto.getData().getProportionMoney()); |
| | | tSettlementConfirm.setTotalElectronic(dto.getData().getTotalElectronic()); |
| | | tSettlementConfirm.setTotalService(dto.getData().getTotalService()); |
| | | tSettlementConfirm.setRemark(dto.getData().getRemark()); |
| | | tSettlementConfirm.setServicePartner(dto.getData().getServicePartner()); |
| | | tSettlementConfirm.setServiceMoney(dto.getData().getServiceMoney()); |
| | | tSettlementConfirm.setTotalService(dto.getData().getTotalService()); |
| | | tSettlementConfirm.setServiceRemark(dto.getData().getServiceRemark()); |
| | | tSettlementConfirm.setDistribution(dto.getData().getDistribution()); |
| | | tSettlementConfirm.setIncome(dto.getData().getElectrovalence().add(dto.getData().getServiceCharge())); |
| | | if (dto.getState() == 2){ |
| | | tSettlementConfirmMapper.insert(tSettlementConfirm); |
| | | } |
| | | return tSettlementConfirm; |
| | | } |
| | | |
| | | @Override |
| | | public PageInfo<TSettlementConfirm> settlementList(SettlementListQuery dto) { |
| | | PageInfo<TSettlementConfirm> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize()); |
| | | List<TSettlementConfirm> list = tSettlementConfirmMapper.settlementList(pageInfo,dto); |
| | | for (TSettlementConfirm tSettlementConfirm : list) { |
| | | tSettlementConfirm.setUid(tSettlementConfirm.getId().toString()); |
| | | Partner data = siteClient.getPartnerR(tSettlementConfirm.getPartnerId()).getData(); |
| | | List<Site> data1 = siteClient.getSiteByIds(Arrays.asList(tSettlementConfirm.getSiteId())).getData(); |
| | | if (!data1.isEmpty()){ |
| | | tSettlementConfirm.setSiteName(data1.get(0).getName()); |
| | | } |
| | | if (data!=null){ |
| | | tSettlementConfirm.setPartnerName(data.getName()); |
| | | } |
| | | String format = tSettlementConfirm.getStartTime().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH:mm:ss")); |
| | | String format1 = tSettlementConfirm.getEndTime().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH:mm:ss")); |
| | | tSettlementConfirm.setTime(format+"至"+format1); |
| | | |
| | | |
| | | } |
| | | pageInfo.setRecords(list); |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public SettlementTotalVO settlementTotal(String time) { |
| | | SettlementTotalVO res = new SettlementTotalVO(); |
| | | List<TSettlementConfirm> list1 = tSettlementConfirmMapper.settlementTotal(time); |
| | | LocalDateTime parse = LocalDateTime.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | // 减少一个月 |
| | | LocalDateTime minus = parse.minusMonths(1); |
| | | List<TSettlementConfirm> list2 = tSettlementConfirmMapper.settlementTotal(time); |
| | | // 合计 |
| | | List<TSettlementConfirm> total = new ArrayList<>(); |
| | | |
| | | TSettlementConfirm tSettlementConfirm1 = new TSettlementConfirm(); |
| | | BigDecimal meteringElectronic = new BigDecimal("0"); |
| | | BigDecimal chargingElectronic = new BigDecimal("0"); |
| | | BigDecimal lossElectronic = new BigDecimal("0"); |
| | | BigDecimal income = new BigDecimal("0"); |
| | | BigDecimal venue = new BigDecimal("0"); |
| | | BigDecimal metering = new BigDecimal("0"); |
| | | BigDecimal clean = new BigDecimal("0"); |
| | | BigDecimal maintain = new BigDecimal("0"); |
| | | BigDecimal cost = new BigDecimal("0"); |
| | | BigDecimal profitMoney = new BigDecimal("0"); |
| | | BigDecimal newMoney = new BigDecimal("0"); |
| | | BigDecimal newSettlement = new BigDecimal("0"); |
| | | BigDecimal supplyElectronic = new BigDecimal("0"); |
| | | BigDecimal proportionPartner = new BigDecimal("0"); |
| | | BigDecimal proportionMoney = new BigDecimal("0"); |
| | | BigDecimal totalElectronic = new BigDecimal("0"); |
| | | BigDecimal totalService = new BigDecimal("0"); |
| | | BigDecimal servicePartner = new BigDecimal("0"); |
| | | BigDecimal serviceMoney = new BigDecimal("0"); |
| | | BigDecimal sharingAmount = new BigDecimal("0"); |
| | | BigDecimal commissionAmount = new BigDecimal("0"); |
| | | BigDecimal electrovalence = new BigDecimal("0"); |
| | | BigDecimal serviceCharge = new BigDecimal("0"); |
| | | BigDecimal orderCommission = new BigDecimal("0"); |
| | | BigDecimal vipDiscount = new BigDecimal("0"); |
| | | BigDecimal couponDiscount = new BigDecimal("0"); |
| | | // tSettlementConfirm1.setIncomePercentage(); |
| | | // tSettlementConfirm1.setTotalPercentage(); |
| | | tSettlementConfirm1.setElectronicRefund(0); |
| | | // 上月成本合计 |
| | | BigDecimal beforeCost= new BigDecimal("0"); |
| | | // 上月利润合计 |
| | | BigDecimal beforeIncome= new BigDecimal("0"); |
| | | for (TSettlementConfirm tSettlementConfirm : list1) { |
| | | List<Site> data1 = siteClient.getSiteByIds(Arrays.asList(tSettlementConfirm.getSiteId())).getData(); |
| | | if (!data1.isEmpty()){ |
| | | tSettlementConfirm.setSiteName(data1.get(0).getName()); |
| | | } |
| | | meteringElectronic = meteringElectronic.add(tSettlementConfirm.getMeteringElectronic()); |
| | | chargingElectronic = chargingElectronic.add(tSettlementConfirm.getChargingElectronic()); |
| | | lossElectronic = lossElectronic.add(tSettlementConfirm.getLossElectronic()); |
| | | income = income.add(tSettlementConfirm.getIncome()); |
| | | venue = venue.add(tSettlementConfirm.getVenue()); |
| | | metering = metering.add(tSettlementConfirm.getMetering()); |
| | | clean = clean.add(tSettlementConfirm.getClean()); |
| | | maintain = maintain.add(tSettlementConfirm.getMaintain()); |
| | | cost = cost.add(tSettlementConfirm.getCost()); |
| | | profitMoney = profitMoney.add(tSettlementConfirm.getProfitMoney()); |
| | | newMoney = newMoney.add(tSettlementConfirm.getNewMoney()); |
| | | newSettlement = newSettlement.add(tSettlementConfirm.getNewSettlement()); |
| | | supplyElectronic = supplyElectronic.add(tSettlementConfirm.getSupplyElectronic()); |
| | | proportionPartner = proportionPartner.add(tSettlementConfirm.getProportionPartner()); |
| | | proportionMoney = proportionMoney.add(tSettlementConfirm.getProportionMoney()); |
| | | totalElectronic = totalElectronic.add(tSettlementConfirm.getTotalElectronic()); |
| | | totalService = totalService.add(tSettlementConfirm.getTotalService()); |
| | | servicePartner = servicePartner.add(tSettlementConfirm.getServicePartner()); |
| | | serviceMoney = serviceMoney.add(tSettlementConfirm.getServiceMoney()); |
| | | sharingAmount = sharingAmount.add(tSettlementConfirm.getSharingAmount()); |
| | | commissionAmount = commissionAmount.add(tSettlementConfirm.getCommissionAmount()); |
| | | electrovalence = electrovalence.add(tSettlementConfirm.getElectrovalence()); |
| | | serviceCharge = serviceCharge.add(tSettlementConfirm.getServiceCharge()); |
| | | orderCommission = orderCommission.add(tSettlementConfirm.getOrderCommission()); |
| | | vipDiscount = vipDiscount.add(tSettlementConfirm.getVipDiscount()); |
| | | couponDiscount = couponDiscount.add(tSettlementConfirm.getCouponDiscount()); |
| | | |
| | | // 查询结算确认单开始时间和结束时间的单子 |
| | | QueryWrapper<TChargingOrder> eq = new QueryWrapper<TChargingOrder>() |
| | | .eq("site_id", tSettlementConfirm.getSiteId()) |
| | | .eq("recharge_payment_status",2); |
| | | switch (tSettlementConfirm.getType()){ |
| | | case 1: |
| | | eq.between("start_time", tSettlementConfirm.getStartTime(), tSettlementConfirm.getEndTime()); |
| | | break; |
| | | case 2: |
| | | eq.between("end_time", tSettlementConfirm.getStartTime(), tSettlementConfirm.getEndTime()); |
| | | break; |
| | | } |
| | | List<TChargingOrder> tChargingOrders = this.baseMapper.selectList(eq); |
| | | Map<String,TChargingOrder> map = new HashMap<>(); |
| | | StringBuilder stringBuilder = new StringBuilder(); |
| | | for (TChargingOrder tChargingOrder : tChargingOrders) { |
| | | stringBuilder.append(tChargingOrder.getCode()).append(","); |
| | | } |
| | | Long temp = 0L; |
| | | if (StringUtils.hasLength(stringBuilder.toString())){ |
| | | List<UploadRealTimeMonitoringData> data6 = uploadRealTimeMonitoringDataClient.getOrderInfoByCodes(stringBuilder.substring(0,stringBuilder.length()-1)).getData(); |
| | | temp+=data6.stream().mapToLong(UploadRealTimeMonitoringData::getCumulative_charging_time).sum(); |
| | | } |
| | | List<TChargingPile> data = siteClient.getPileListBySiteId(tSettlementConfirm.getSiteId()).getData(); |
| | | // 计算充电桩的功率平均值 |
| | | BigDecimal bigDecimal = new BigDecimal("0"); |
| | | for (TChargingPile datum : data) { |
| | | bigDecimal = bigDecimal.add(datum.getRatedPower()); |
| | | } |
| | | BigDecimal bigDecimal1 = bigDecimal.divide(new BigDecimal(data.size())).setScale(2, RoundingMode.HALF_DOWN); |
| | | |
| | | tSettlementConfirm.setIncome(tSettlementConfirm.getElectrovalence().add(tSettlementConfirm.getServiceCharge())); |
| | | // todo 计算利用率 该电站充电桩本月利用率: |
| | | //利用率=充电量/(桩数量*功率*时间) |
| | | |
| | | for (TSettlementConfirm settlementConfirm : list2) { |
| | | settlementConfirm.setIncome(settlementConfirm.getElectrovalence().add(settlementConfirm.getServiceCharge())); |
| | | if (tSettlementConfirm.getSiteId().equals(settlementConfirm.getSiteId())){ |
| | | // 电站相同比较收入涨幅跌幅 |
| | | BigDecimal subtract = tSettlementConfirm.getIncome().subtract(settlementConfirm.getIncome()).divide(tSettlementConfirm.getIncome()).setScale(2, RoundingMode.HALF_DOWN).multiply(new BigDecimal("100")); |
| | | tSettlementConfirm.setIncomePercentage(subtract+"%"); |
| | | // 比较总利润 收入合计-成本合计 |
| | | BigDecimal subtract1 = tSettlementConfirm.getIncome().subtract(tSettlementConfirm.getCost()); |
| | | BigDecimal subtract2 = settlementConfirm.getIncome().subtract(settlementConfirm.getCost()); |
| | | tSettlementConfirm.setTotalPercentage(subtract1.subtract(subtract2).divide(subtract2).setScale(2, RoundingMode.HALF_DOWN).multiply(new BigDecimal("100"))+"%"); |
| | | } |
| | | beforeCost = beforeCost.add(settlementConfirm.getCost()); |
| | | beforeIncome = beforeIncome.add(settlementConfirm.getIncome()); |
| | | |
| | | |
| | | } |
| | | } |
| | | TSettlementConfirm tSettlementConfirm = new TSettlementConfirm(); |
| | | tSettlementConfirm.setMeteringElectronic(meteringElectronic); |
| | | tSettlementConfirm.setChargingElectronic(chargingElectronic); |
| | | tSettlementConfirm.setLossElectronic(lossElectronic); |
| | | tSettlementConfirm.setIncome(income); |
| | | tSettlementConfirm.setVenue(venue); |
| | | tSettlementConfirm.setMetering(metering); |
| | | tSettlementConfirm.setClean(clean); |
| | | tSettlementConfirm.setMaintain(maintain); |
| | | tSettlementConfirm.setCost(cost); |
| | | tSettlementConfirm.setProfitMoney(profitMoney); |
| | | tSettlementConfirm.setNewMoney(newMoney); |
| | | tSettlementConfirm.setNewSettlement(newSettlement); |
| | | tSettlementConfirm.setSupplyElectronic(supplyElectronic); |
| | | tSettlementConfirm.setProportionPartner(proportionPartner); |
| | | tSettlementConfirm.setProportionMoney(proportionMoney); |
| | | tSettlementConfirm.setTotalElectronic(totalElectronic); |
| | | tSettlementConfirm.setTotalService(totalService); |
| | | tSettlementConfirm.setServicePartner(servicePartner); |
| | | tSettlementConfirm.setServiceMoney(serviceMoney); |
| | | tSettlementConfirm.setSharingAmount(sharingAmount); |
| | | tSettlementConfirm.setCommissionAmount(commissionAmount); |
| | | tSettlementConfirm.setElectrovalence(electrovalence); |
| | | tSettlementConfirm.setServiceCharge(serviceCharge); |
| | | tSettlementConfirm.setOrderCommission(orderCommission); |
| | | tSettlementConfirm.setVipDiscount(vipDiscount); |
| | | tSettlementConfirm.setCouponDiscount(couponDiscount); |
| | | // 本月 |
| | | BigDecimal subtract = income.subtract(beforeIncome).divide(beforeIncome).setScale(2, RoundingMode.HALF_DOWN).multiply(new BigDecimal("100")); |
| | | tSettlementConfirm.setIncomePercentage(subtract+"%"); |
| | | // 比较总利润 收入合计-成本合计 |
| | | BigDecimal subtract1 = income.subtract(cost); |
| | | BigDecimal subtract2 = beforeIncome.subtract(beforeCost); |
| | | 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); |
| | | res.setList1(list1); |
| | | res.setList2(total); |
| | | return res; |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | // String format = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH:mm:ss")); |
| | | // String format1 = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日HH:mm:ss")); |
| | | // System.err.println(format+"至"+format1); |
| | | // LocalDateTime parse = LocalDateTime.parse("2024-01-12 00:00:00", DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | // System.err.println(parse.format(DateTimeFormatter.ofPattern("yyyy-dd"))); |
| | | } |
| | | } |