| | |
| | | package com.ruoyi.order.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.ruoyi.account.api.feignClient.AppUserCarClient; |
| | | import com.ruoyi.account.api.feignClient.AppUserClient; |
| | |
| | | import com.ruoyi.account.api.model.TAppUserCar; |
| | | import com.ruoyi.account.api.model.TAppUserVipDetail; |
| | | import com.ruoyi.account.api.vo.GetAppUserVipDetail; |
| | | import com.ruoyi.chargingPile.api.feignClient.AccountingStrategyDetailClient; |
| | | import com.ruoyi.chargingPile.api.feignClient.ChargingGunClient; |
| | | import com.ruoyi.chargingPile.api.feignClient.ChargingPileClient; |
| | | import com.ruoyi.chargingPile.api.feignClient.SiteClient; |
| | | import com.ruoyi.chargingPile.api.model.Site; |
| | | import com.ruoyi.chargingPile.api.model.TAccountingStrategyDetail; |
| | | 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.dto.ChargingOrderGroup; |
| | | import com.ruoyi.common.core.dto.ChargingPercentProvinceDto; |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.BasePage; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | import com.ruoyi.order.api.model.TChargingOrder; |
| | | import com.ruoyi.order.api.model.TChargingOrderAccountingStrategy; |
| | | import com.ruoyi.integration.api.feignClient.ChargingHandshakeClient; |
| | | import com.ruoyi.integration.api.feignClient.PlatformStartChargingReplyClient; |
| | | import com.ruoyi.integration.api.feignClient.SendMessageClient; |
| | | import com.ruoyi.integration.api.feignClient.UploadRealTimeMonitoringDataClient; |
| | | import com.ruoyi.integration.api.model.ChargingHandshake; |
| | | import com.ruoyi.integration.api.model.PlatformStartCharging; |
| | | import com.ruoyi.integration.api.model.PlatformStartChargingReply; |
| | | import com.ruoyi.integration.api.model.UploadRealTimeMonitoringData; |
| | | import com.ruoyi.order.api.model.*; |
| | | import com.ruoyi.order.api.query.ChargingOrderQuery; |
| | | 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.dto.*; |
| | | import com.ruoyi.order.mapper.TChargingOrderMapper; |
| | | import com.ruoyi.order.service.TChargingOrderAccountingStrategyService; |
| | | import com.ruoyi.order.service.TChargingOrderRefundService; |
| | | import com.ruoyi.order.service.TChargingOrderService; |
| | | import com.ruoyi.other.api.domain.TVip; |
| | | import com.ruoyi.order.service.TOrderEvaluateService; |
| | | import com.ruoyi.other.api.domain.TCoupon; |
| | | import com.ruoyi.other.api.domain.TGoods; |
| | | import com.ruoyi.order.vo.ChargingOrderListInfoVO; |
| | | import com.ruoyi.payment.api.feignClient.AliPaymentClient; |
| | | import com.ruoyi.payment.api.feignClient.WxPaymentClient; |
| | | import com.ruoyi.payment.api.vo.NotifyV3PayDecodeRespBody; |
| | | import com.ruoyi.payment.api.vo.PaymentOrder; |
| | | import com.ruoyi.payment.api.model.RefundReq; |
| | | import com.ruoyi.payment.api.model.RefundResp; |
| | | import com.ruoyi.payment.api.model.WxPaymentRefundModel; |
| | | import com.ruoyi.payment.api.vo.*; |
| | | import io.seata.spring.annotation.GlobalTransactional; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneOffset; |
| | | import java.time.format.DateTimeFormatter; |
| | | import java.time.temporal.ChronoUnit; |
| | | import java.util.*; |
| | | import java.util.concurrent.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | @Resource |
| | | private AppUserCarClient appUserCarClient; |
| | | |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | @Resource |
| | | private ChargingPileClient chargingPileClient; |
| | | |
| | | |
| | | @Resource |
| | | private TChargingOrderAccountingStrategyService chargingOrderAccountingStrategyService; |
| | | |
| | |
| | | private WxPaymentClient wxPaymentClient; |
| | | |
| | | @Resource |
| | | private ChargingPileClient chargingPileClient; |
| | | private AliPaymentClient aliPaymentClient; |
| | | |
| | | @Resource |
| | | private AppUserClient appUserClient; |
| | | |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private AppUserVipDetailClient appUserVipDetailClient; |
| | | |
| | | @Resource |
| | | private RedisService redisService; |
| | | |
| | | @Resource |
| | | private UploadRealTimeMonitoringDataClient uploadRealTimeMonitoringDataClient; |
| | | |
| | | |
| | | |
| | | @Resource |
| | | private ChargingHandshakeClient chargingHandshakeClient; |
| | | |
| | | @Resource |
| | | private SendMessageClient sendMessageClient; |
| | | |
| | | @Resource |
| | | private TOrderEvaluateService orderEvaluateService; |
| | | |
| | | |
| | | @Resource |
| | | private AccountingStrategyDetailClient accountingStrategyDetailClient; |
| | | |
| | | @Resource |
| | | private PlatformStartChargingReplyClient platformStartChargingReplyClient; |
| | | |
| | | @Resource |
| | | private TChargingOrderRefundService chargingOrderRefundService; |
| | | |
| | | //计数器 |
| | | private Map<String, Integer> counter_map = new HashMap<>(); |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取小程序充电记录列表数据 |
| | | * @param query |
| | |
| | | BigDecimal payMoney = tChargingOrder.getStatus() < 4 ? tChargingOrder.getRechargeAmount() : tChargingOrder.getPaymentAmount(); |
| | | myChargingOrderList.setPayMoney(payMoney); |
| | | myChargingOrderList.setCreateTime(tChargingOrder.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | long count = orderEvaluateService.count(new LambdaQueryWrapper<TOrderEvaluate>().eq(TOrderEvaluate::getOrderType, 1) |
| | | .eq(TOrderEvaluate::getOrderId, tChargingOrder.getId()).eq(TOrderEvaluate::getDelFlag, 0)); |
| | | myChargingOrderList.setEvaluate(count + 1L); |
| | | orderLists.add(myChargingOrderList); |
| | | } |
| | | list = this.baseMapper.getMyChargingOrderList(appUserId, query.getType(), null, null); |
| | | map.put("list", orderLists); |
| | | map.put("totle", list.size()); |
| | | return map; |
| | | } |
| | | |
| | |
| | | .orderByAsc(TChargingOrderAccountingStrategy::getStartTime) |
| | | ); |
| | | myChargingOrderInfo.setStageCost(stageCost); |
| | | // todo 待完善 |
| | | //再MongoDB中获取数据 |
| | | myChargingOrderInfo.setCurrentAndVoltage(null); |
| | | //再MongoDB中获取数据 |
| | | myChargingOrderInfo.setPower(null); |
| | | List<UploadRealTimeMonitoringData> dataList = uploadRealTimeMonitoringDataClient.getDataByOrderCode(chargingOrder.getCode()).getData(); |
| | | if(null != dataList){ |
| | | //在MongoDB中获取数据 |
| | | SimpleDateFormat sdf = new SimpleDateFormat("HH:mm"); |
| | | List<String> time = dataList.stream().map(s -> sdf.format(s.getCreate_time())).collect(Collectors.toList()); |
| | | List<BigDecimal> outputVoltage = dataList.stream().map(UploadRealTimeMonitoringData::getOutput_voltage).collect(Collectors.toList()); |
| | | List<BigDecimal> outputCurrent = dataList.stream().map(UploadRealTimeMonitoringData::getOutput_current).collect(Collectors.toList()); |
| | | List<Map<String, Object>> currentAndVoltage = new ArrayList<>(); |
| | | for (int i = 0; i < time.size(); i++) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("time", time.get(i)); |
| | | //电流 |
| | | map.put("electricity", outputCurrent.get(i)); |
| | | //电压 |
| | | map.put("voltage", outputVoltage.get(i)); |
| | | currentAndVoltage.add(map); |
| | | } |
| | | myChargingOrderInfo.setCurrentAndVoltage(currentAndVoltage); |
| | | //在MongoDB中获取数据 |
| | | List<Integer> soc = dataList.stream().map(UploadRealTimeMonitoringData::getSoc).collect(Collectors.toList()); |
| | | List<BigDecimal> po = dataList.stream().map(s -> s.getOutput_current().multiply(s.getOutput_voltage()).divide(new BigDecimal(1000))).collect(Collectors.toList()); |
| | | List<Map<String, Object>> power = new ArrayList<>(); |
| | | for (int i = 0; i < time.size(); i++) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("time", time.get(i)); |
| | | //soc |
| | | map.put("soc", soc.get(i)); |
| | | //功率 |
| | | map.put("power", po.get(i)); |
| | | power.add(map); |
| | | } |
| | | myChargingOrderInfo.setPower(power); |
| | | } |
| | | myChargingOrderInfo.setActionable(myChargingOrderInfo.getEndTime() + 604800000L > System.currentTimeMillis() ? 0 : 1); |
| | | return myChargingOrderInfo; |
| | | } |
| | |
| | | BigDecimal payMoney = tChargingOrder.getStatus() < 4 ? tChargingOrder.getRechargeAmount() : tChargingOrder.getPaymentAmount(); |
| | | myChargingOrderList.setPayMoney(payMoney); |
| | | myChargingOrderList.setCreateTime(tChargingOrder.getCreateTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | myChargingOrderList.setElectricCharge(tChargingOrder.getElectrovalence()); |
| | | myChargingOrderList.setServiceCharge(tChargingOrder.getServiceCharge()); |
| | | list.add(myChargingOrderList); |
| | | } |
| | | return list; |
| | |
| | | } |
| | | } |
| | | if(2 == rechargePaymentType){ |
| | | |
| | | AliQueryOrder data = aliPaymentClient.query(tChargingOrder.getCode()).getData(); |
| | | if(null != data){ |
| | | //支付失败,删除无效的订单 |
| | | String tradeStatus = data.getTradeStatus(); |
| | | if(tradeStatus.equals("TRADE_CLOSED")){ |
| | | this.removeById(tChargingOrder.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | if(2 == one.getRechargePaymentType()){ |
| | | |
| | | AliQueryOrder data = aliPaymentClient.query(one.getCode()).getData(); |
| | | if(null != data){ |
| | | String trade_state = data.getTradeStatus(); |
| | | //支付失败,删除无效的订单 |
| | | if(trade_state.equals("TRADE_CLOSED")){ |
| | | this.removeById(one.getId()); |
| | | } |
| | | if(trade_state.equals("WAIT_BUYER_PAY")){ |
| | | //结束第三方支付,删除订单 |
| | | aliPaymentClient.close(one.getCode()); |
| | | this.removeById(one.getId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | return AjaxResult.success(data); |
| | | } |
| | | if(2 == addChargingOrder.getPaymentType()){ |
| | | |
| | | AliPaymentReq req = new AliPaymentReq(); |
| | | req.setOutTradeNo(chargingOrder.getCode()); |
| | | req.setTotalAmount(chargingOrder.getPaymentAmount().toString()); |
| | | req.setSubject("充电充值"); |
| | | req.setBuyerOpenId(appUser.getAliOpenid()); |
| | | req.setBody("充电充值"); |
| | | AliPaymentResp data = aliPaymentClient.payment(req).getData(); |
| | | if(null != data){ |
| | | data.setNotifyUrl(data.getNotifyUrl() + "/t-charging-order/chargingOrderALICallback"); |
| | | return AjaxResult.success(data); |
| | | } |
| | | } |
| | | throw new RuntimeException("无效的支付方式"); |
| | | } |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | public AjaxResult chargingOrderCallback(Integer paymentType, String out_trade_no, String transaction_id, String attach) { |
| | | TChargingOrder chargingOrder = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, out_trade_no)); |
| | | if(chargingOrder.getRechargePaymentStatus() == 2){ |
| | |
| | | } |
| | | chargingOrder.setRechargePaymentStatus(2); |
| | | chargingOrder.setRechargeSerialNumber(transaction_id); |
| | | chargingOrder.setStatus(2); |
| | | this.updateById(chargingOrder); |
| | | |
| | | //添加安全检测数据到缓存中,每步安全检测完成后需要更新缓存数据 |
| | | PreChargeCheck preChargeCheck = new PreChargeCheck(); |
| | | preChargeCheck.setElectronicLockLock(false); |
| | | preChargeCheck.setInsulationTesting(false); |
| | | preChargeCheck.setSecureConnectionDetection(false); |
| | | preChargeCheck.setStartupSuccess(1); |
| | | String key = "AQJC_" + chargingOrder.getChargingGunId(); |
| | | redisService.setCacheObject(key, preChargeCheck); |
| | | //开始检测充电桩状,将检查状态写入缓存。检测完成后开始开启充电 |
| | | //充电结束后需要计算退款剩余金额 |
| | | // todo 需要完善 |
| | | |
| | | //根据当前充值的金额和计费模板算出充电的金额 |
| | | BigDecimal rechargeAmount = chargingOrder.getRechargeAmount(); |
| | | //计算充电金额,会员需要将折扣金额加入到充电总金额中 |
| | | TChargingGun chargingGun = chargingGunClient.getChargingGunById(chargingOrder.getChargingGunId()).getData(); |
| | | TAccountingStrategyDetail strategyDetail = accountingStrategyDetailClient.getNowData(chargingGun.getAccountingStrategyId()).getData(); |
| | | //总单价 |
| | | BigDecimal totalUnitPrice = strategyDetail.getServiceCharge().add(strategyDetail.getElectrovalence()); |
| | | //计算能充电的度数 |
| | | BigDecimal degrees = rechargeAmount.divide(totalUnitPrice); |
| | | //计算电费金额和服务费 |
| | | BigDecimal serviceCharge = strategyDetail.getServiceCharge().multiply(degrees); |
| | | BigDecimal electrovalence = strategyDetail.getElectrovalence().multiply(degrees); |
| | | |
| | | //再处理会员折扣 |
| | | BigDecimal discount = BigDecimal.ZERO; |
| | | TAppUser appUser = appUserClient.getUserById(chargingOrder.getAppUserId()).getData(); |
| | | if(null != appUser.getVipId()){ |
| | | GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail(); |
| | | getAppUserVipDetail.setAppUserId(chargingOrder.getAppUserId()); |
| | | getAppUserVipDetail.setVipId(appUser.getVipId()); |
| | | TAppUserVipDetail data = appUserVipDetailClient.getAppUserVipDetail(getAppUserVipDetail).getData(); |
| | | if(data.getChargeNum() > 0){ |
| | | discount = serviceCharge.multiply(data.getDiscount().divide(new BigDecimal(10))); |
| | | data.setChargeNum(data.getChargeNum() - 1); |
| | | appUserVipDetailClient.updateAppUserVipDetail(data); |
| | | } |
| | | } |
| | | electrovalence = electrovalence.add(discount); |
| | | |
| | | |
| | | TChargingPile chargingPile = chargingPileClient.getChargingPileById(chargingGun.getChargingPileId()).getData(); |
| | | //调用远程启动充电消息 |
| | | PlatformStartCharging platformStartCharging = new PlatformStartCharging(); |
| | | platformStartCharging.setTransaction_serial_number(chargingOrder.getCode()); |
| | | platformStartCharging.setCharging_pile_code(chargingPile.getCode()); |
| | | platformStartCharging.setCharging_gun_code(chargingGun.getCode()); |
| | | //使用订单id作为逻辑卡号 |
| | | platformStartCharging.setCard_number(chargingOrder.getId().toString()); |
| | | platformStartCharging.setAccount_balance(electrovalence); |
| | | sendMessageClient.platformStartCharging(platformStartCharging); |
| | | //异步线程检测远程启动的应答结果。如果失败,则需要全额退款 |
| | | String code = chargingOrder.getCode(); |
| | | //执行5分钟的定时任务检测 |
| | | ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); |
| | | scheduler.scheduleAtFixedRate(()->{ |
| | | List<PlatformStartChargingReply> data = platformStartChargingReplyClient.getPlatformStartChargingReply(code).getData(); |
| | | if(data.size() != 0){ |
| | | PlatformStartChargingReply platformStartChargingReply = data.get(1); |
| | | Integer startup_result = platformStartChargingReply.getStartup_result(); |
| | | Integer failure_cause = platformStartChargingReply.getFailure_cause(); |
| | | Integer counter = counter_map.get(code); |
| | | PreChargeCheck preChargeCheck1 = redisService.getCacheObject(key); |
| | | //状态为5的时候,硬件会间隔60秒后再次检测,依然未插枪,则不启动充电 |
| | | //因这里是间隔5秒执行检测,所以累计次数在30次以上 |
| | | if(failure_cause == 5 && null == counter || counter < 35){ |
| | | counter++; |
| | | counter_map.put(code, counter); |
| | | //启动失败 |
| | | preChargeCheck1.setStartupSuccess(3); |
| | | preChargeCheck1.setFailureCause(failure_cause); |
| | | redisService.setCacheObject(key, preChargeCheck1); |
| | | return; |
| | | } |
| | | //清除计时器中的无效数据 |
| | | counter_map.remove(code); |
| | | //开始处理退款 |
| | | TChargingOrder order = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, code)); |
| | | if(0 == startup_result){ |
| | | //启动失败 |
| | | preChargeCheck1.setStartupSuccess(3); |
| | | preChargeCheck1.setFailureCause(failure_cause); |
| | | //启动失败后取消订单,退款操作 |
| | | refund(code); |
| | | order.setStatus(5); |
| | | order.setEndMode(0); |
| | | }else{ |
| | | preChargeCheck1.setStartupSuccess(2); |
| | | order.setStatus(3); |
| | | order.setStartTime(LocalDateTime.now()); |
| | | } |
| | | this.updateById(order); |
| | | redisService.setCacheObject(key, preChargeCheck1); |
| | | //提前结束定时任务 |
| | | scheduler.shutdown(); |
| | | } |
| | | }, 5, 300, TimeUnit.SECONDS); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 启动失败后的退款,取消订单 |
| | | * @param code |
| | | */ |
| | | public void refund(String code){ |
| | | TChargingOrder chargingOrder = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, code)); |
| | | if(chargingOrder.getStatus() == 2){ |
| | | Integer rechargePaymentType = chargingOrder.getRechargePaymentType(); |
| | | BigDecimal rechargeAmount = chargingOrder.getRechargeAmount(); |
| | | //构建退款明细 |
| | | TChargingOrderRefund chargingOrderRefund = new TChargingOrderRefund(); |
| | | chargingOrderRefund.setChargingOrderId(chargingOrder.getId()); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | chargingOrderRefund.setRefundCode("CDF" + sdf.format(new Date()) + (Math.random() * 1000)); |
| | | chargingOrderRefund.setRefundAmount(rechargeAmount); |
| | | chargingOrderRefund.setRefundStatus(1); |
| | | chargingOrderRefund.setPayType(rechargePaymentType); |
| | | chargingOrderRefund.setRefundStatus(1); |
| | | chargingOrderRefund.setCode(code); |
| | | chargingOrderRefund.setRefundTitle("充电失败"); |
| | | chargingOrderRefund.setRefundContent("充电失败"); |
| | | chargingOrderRefund.setRefundReason("充电失败"); |
| | | chargingOrderRefund.setRefundRemark("全额退款"); |
| | | chargingOrderRefund.setRefundTotalAmount(rechargeAmount); |
| | | chargingOrderRefund.setPayAmount(rechargeAmount); |
| | | if(1 == rechargePaymentType){ |
| | | WxPaymentRefundModel model = new WxPaymentRefundModel(); |
| | | 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"); |
| | | WxPaymentRefundModel.RefundAmount amount = new WxPaymentRefundModel.RefundAmount(); |
| | | amount.setRefund(rechargeAmount.multiply(new BigDecimal(100)).intValue()); |
| | | amount.setTotal(rechargeAmount.multiply(new BigDecimal(100)).intValue()); |
| | | amount.setCurrency("CNY"); |
| | | model.setAmount(amount); |
| | | R<String> orderR = wxPaymentClient.refundOrderR(model); |
| | | if(200 == orderR.getCode()){ |
| | | chargingOrderRefundService.save(chargingOrderRefund); |
| | | } |
| | | } |
| | | if(2 == rechargePaymentType){ |
| | | RefundReq dto = new RefundReq(); |
| | | dto.setOutTradeNo(chargingOrder.getCode()); |
| | | dto.setOutRequestNo(chargingOrderRefund.getCode()); |
| | | dto.setRefundAmount(rechargeAmount.toString()); |
| | | dto.setRefundReason("充电失败,取消充电订单"); |
| | | RefundResp resp = aliPaymentClient.refund(dto).getData(); |
| | | if(null != resp){ |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-DDTHH:mm:ss+TIMEZONE"); |
| | | AjaxResult success = chargingOrderStartupFailureWxRefund(resp.getOutTradeNo(), resp.getTradeNo(), "SUCCESS", sdf1.format(new Date())); |
| | | if(success.isSuccess()){ |
| | | chargingOrderRefundService.save(chargingOrderRefund); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 启动失败后微信退款的回调处理 |
| | | * @param out_refund_no |
| | | * @param refund_id |
| | | * @param tradeState |
| | | * @param success_time |
| | | * @return |
| | | */ |
| | | public AjaxResult chargingOrderStartupFailureWxRefund(String out_refund_no, String refund_id, String tradeState, String success_time){ |
| | | if("SUCCESS".equals(tradeState)){ |
| | | TChargingOrderRefund one = chargingOrderRefundService.getOne(new LambdaQueryWrapper<TChargingOrderRefund>().eq(TChargingOrderRefund::getRefundCode, out_refund_no)); |
| | | one.setRefundSerialNumber(refund_id); |
| | | one.setRefundStatus(2); |
| | | one.setRefundTime(LocalDateTime.parse(success_time, DateTimeFormatter.ofPattern("yyyy-MM-DDTHH:mm:ss+TIMEZONE"))); |
| | | chargingOrderRefundService.updateById(one); |
| | | } |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取充电中的详情 |
| | | * @param id |
| | |
| | | if(null == one){ |
| | | return null; |
| | | } |
| | | // todo 需要完善充电实时数据 |
| | | ChargingDetails chargingDetails = new ChargingDetails(); |
| | | chargingDetails.setId(one.getId().toString()); |
| | | TChargingGun chargingGun = chargingGunClient.getChargingGunById(id).getData(); |
| | |
| | | chargingDetails.setName(site.getName() + "-" + chargingPile.getName()); |
| | | chargingDetails.setCode(one.getCode()); |
| | | chargingDetails.setStatus(one.getStatus()); |
| | | chargingDetails.setChargingCost(one.getResidualAmount()); |
| | | UploadRealTimeMonitoringData data = uploadRealTimeMonitoringDataClient.chargingOrderInfo(one.getCode()).getData(); |
| | | if(null != data){ |
| | | chargingDetails.setChargeCurrent(data.getOutput_current()); |
| | | chargingDetails.setChargeVoltage(data.getOutput_voltage()); |
| | | BigDecimal power = data.getOutput_current().multiply(data.getOutput_voltage()).divide(new BigDecimal(1000)); |
| | | chargingDetails.setChargePower(power); |
| | | chargingDetails.setCompletionRatio(data.getSoc()); |
| | | chargingDetails.setRemainingChargeTime(data.getTime_remaining()); |
| | | chargingDetails.setChargedDegrees(data.getCharging_degree()); |
| | | chargingDetails.setChargedTime(data.getCumulative_charging_time()); |
| | | } |
| | | ChargingHandshake chargingHandshake = chargingHandshakeClient.getDataByOrderCode(one.getCode()).getData(); |
| | | if(null != chargingHandshake && null != data && null != one.getAppUserCarId()){ |
| | | BigDecimal bms_battery_capacity = chargingHandshake.getBms_battery_capacity(); |
| | | TAppUserCar appUserCar = appUserCarClient.getCarByIds(Arrays.asList(one.getAppUserCarId())).getData().get(0); |
| | | // 续航 = 电池容量 / 续航里程 * soc |
| | | BigDecimal divide = bms_battery_capacity.divide(new BigDecimal(appUserCar.getEndurance())); |
| | | BigDecimal multiply = new BigDecimal(data.getSoc() / 100).multiply(divide); |
| | | chargingDetails.setEndurance(multiply); |
| | | } |
| | | return chargingDetails; |
| | | } |
| | | |
| | |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | |
| | | public void endCharge(){ |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public PageInfo<ChargingOrderVO> chargingOrder(ChargingOrderQuery dto) { |
| | | public TCharingOrderVO chargingOrder(ChargingOrderQuery dto) { |
| | | TCharingOrderVO tCharingOrderVO = new TCharingOrderVO(); |
| | | |
| | | |
| | | String startTime1 = null; |
| | | String startTime2 = null; |
| | | String endTime1 = null; |
| | |
| | | endTime2 = split[1]; |
| | | } |
| | | PageInfo<ChargingOrderVO> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize()); |
| | | |
| | | if (StringUtils.hasLength(dto.getPhone())){ |
| | | List<Long> data = appUserClient.getUserIdsByPhone(dto.getPhone()).getData(); |
| | | if (data.isEmpty()){ |
| | | tCharingOrderVO.setList(pageInfo); |
| | | return tCharingOrderVO; |
| | | } |
| | | dto.setUserIds(data); |
| | | } |
| | | List<ChargingOrderVO> list = this.baseMapper.chargingOrder(pageInfo,dto,startTime1,startTime2,endTime1,endTime2); |
| | | BigDecimal total = new BigDecimal("0"); |
| | | long time = 0L; |
| | | BigDecimal income = new BigDecimal("0"); |
| | | BigDecimal electronicMoney = new BigDecimal("0"); |
| | | BigDecimal serviceMoney = new BigDecimal("0"); |
| | | for (ChargingOrderVO chargingOrderVO : list) { |
| | | TChargingGun data3 = chargingGunClient.getChargingGunById(chargingOrderVO.getChargingGunId()).getData(); |
| | | TChargingPile data2 = chargingPileClient.getChargingPileById(chargingOrderVO.getChargingPileId()).getData(); |
| | | if (data2!=null && data3!=null){ |
| | | chargingOrderVO.setTerminalName(data2.getName()+"-"+data3.getName()); |
| | | |
| | | } |
| | | if (chargingOrderVO.getChargingCapacity()!=null){ |
| | | total = total.add(chargingOrderVO.getChargingCapacity()); |
| | | } |
| | | // 充电订单 明细记录 |
| | | List<TChargingOrderAccountingStrategy> chargingOrderId = chargingOrderAccountingStrategyService.list(new QueryWrapper<TChargingOrderAccountingStrategy>() |
| | | .eq("charging_order_id", chargingOrderVO.getId())); |
| | | // 单个订单累计电费 |
| | | BigDecimal electronicMoney1 = new BigDecimal("0"); |
| | | // 单个订单累计服务费 |
| | | BigDecimal serviceMoney1 = new BigDecimal("0"); |
| | | UploadRealTimeMonitoringData data5 = uploadRealTimeMonitoringDataClient.chargingOrderInfo(chargingOrderVO.getCode()).getData(); |
| | | chargingOrderVO.setChargingSecond(data5.getTime_remaining()*60L); |
| | | // 总收入 |
| | | if (chargingOrderVO.getRefundStatus() !=null && chargingOrderVO.getRefundStatus() == 2){ |
| | | income = income.add(chargingOrderVO.getPaymentAmount().subtract(chargingOrderVO.getRefundAmount())); |
| | | }else{ |
| | | if (chargingOrderVO.getPaymentAmount()!=null){ |
| | | income = income.add(chargingOrderVO.getPaymentAmount()); |
| | | } |
| | | } |
| | | for (TChargingOrderAccountingStrategy tChargingOrderAccountingStrategy : chargingOrderId) { |
| | | // 累计电费 |
| | | electronicMoney1 = electronicMoney1.add(tChargingOrderAccountingStrategy.getElectrovalence() |
| | | .multiply(tChargingOrderAccountingStrategy.getChargingCapacity())); |
| | | electronicMoney = electronicMoney.add(electronicMoney1); |
| | | // 累计服务费 |
| | | serviceMoney1 = serviceMoney1.add(tChargingOrderAccountingStrategy.getServiceCharge()); |
| | | serviceMoney = serviceMoney.add(serviceMoney1); |
| | | } |
| | | chargingOrderVO.setServiceCharge(serviceMoney1); |
| | | chargingOrderVO.setElectrovalence(electronicMoney1); |
| | | // 充电时段数 |
| | | int size = chargingOrderId.size(); |
| | | chargingOrderVO.setCount(size); |
| | | // 用户手机号 |
| | | TAppUser data = appUserClient.getUserById(chargingOrderVO.getAppUserId()).getData(); |
| | | if (data!=null){ |
| | | // 车牌号 |
| | | chargingOrderVO.setPhone(data.getPhone()); |
| | | List<Long> longs = new ArrayList<>(); |
| | | if (chargingOrderVO.getAppUserCarId()!=null){ |
| | | longs.add(chargingOrderVO.getAppUserCarId()); |
| | | List<TAppUserCar> data1 = appUserCarClient.getCarByIds(longs).getData(); |
| | | if (!data1.isEmpty()){ |
| | | chargingOrderVO.setLicensePlate(data1.get(0).getLicensePlate()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | tCharingOrderVO.setTotal(total); |
| | | tCharingOrderVO.setTime(time); |
| | | tCharingOrderVO.setIncome(income); |
| | | tCharingOrderVO.setElectronicMoney(electronicMoney); |
| | | tCharingOrderVO.setServiceMoney(serviceMoney); |
| | | pageInfo.setRecords(list); |
| | | return pageInfo; |
| | | tCharingOrderVO.setList(pageInfo); |
| | | return tCharingOrderVO; |
| | | } |
| | | |
| | | @Override |
| | | public R<PageInfo<PayOrderDto>> payOrderQuery(PayOrderQueryDto payOrderQueryDto) { |
| | | PageInfo<PayOrderDto> pageInfo = new PageInfo<>(payOrderQueryDto.getPageCurr(),payOrderQueryDto.getPageSize()); |
| | | List<PayOrderDto> list = this.baseMapper.payOrderQuery(pageInfo,payOrderQueryDto); |
| | | pageInfo.setRecords(list); |
| | | return R.ok(pageInfo); |
| | | } |
| | | |
| | | @Override |
| | | public R<PageInfo<TChargingOrderRefund>> getRefundList(ChargingRefundDto chargingRefundDto) { |
| | | PageInfo<TChargingOrderRefund> pageInfo = new PageInfo<>(chargingRefundDto.getPageCurr(),chargingRefundDto.getPageSize()); |
| | | List<TChargingOrderRefund> list = this.baseMapper.getRefundList(pageInfo,chargingRefundDto); |
| | | pageInfo.setRecords(list); |
| | | |
| | | return R.ok(pageInfo); |
| | | } |
| | | |
| | | @Override |
| | | public List<ChargingOrderGroup> chargingOrderGroup(ChargingPercentProvinceDto chargingPercentProvinceDto) { |
| | | |
| | | return this.baseMapper.chargingOrderGroup(chargingPercentProvinceDto); |
| | | } |
| | | |
| | | @Override |
| | | public List<SixChargingDto> charge(LocalDate sixBefore, List<Integer> siteIds) { |
| | | return this.baseMapper.charge(sixBefore,siteIds); |
| | | } |
| | | |
| | | @Override |
| | | public List<SixCircleDto> circle(List<Integer> siteIds,LocalDate sixBefore) { |
| | | return this.baseMapper.circle(siteIds,sixBefore); |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, BigDecimal> countAll(LocalDate sixBefore) { |
| | | return this.baseMapper.countAll(sixBefore); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, BigDecimal>> getSumByType(List<Long> chargingOrderIds) { |
| | | return this.baseMapper.getSumByType(chargingOrderIds); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, BigDecimal>> getDateData(List<Long> chargingOrderIds) { |
| | | return this.baseMapper.getDateData(chargingOrderIds); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, BigDecimal>> getWeekData(List<Long> chargingOrderIds) { |
| | | return this.baseMapper.getWeekData(chargingOrderIds); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, BigDecimal>> getMonthData(List<Long> chargingOrderIds) { |
| | | return this.baseMapper.getMonthData(chargingOrderIds); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, BigDecimal>> getYearData(List<Long> chargingOrderIds) { |
| | | return this.baseMapper.getYearData(chargingOrderIds); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public ChargingOrderTimeVO chargingList(ChargingListQuery dto) { |
| | | String startTime1 = null; |
| | | String startTime2 = null; |
| | | String endTime1 = null; |
| | | String endTime2 = null; |
| | | |
| | | if (StringUtils.hasLength(dto.getStartTime())){ |
| | | String[] split = dto.getStartTime().split(" - "); |
| | | startTime1 = split[0]; |
| | | startTime2 = split[1]; |
| | | } |
| | | if (StringUtils.hasLength(dto.getEndTime())){ |
| | | String[] split = dto.getEndTime().split(" - "); |
| | | endTime1 = split[0]; |
| | | endTime2 = split[1]; |
| | | } |
| | | ChargingOrderTimeVO chargingOrderTimeVO = new ChargingOrderTimeVO(); |
| | | |
| | | |
| | | PageInfo<ChargingOrderListVO> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize()); |
| | | List<ChargingOrderListVO> list = this.baseMapper.chargingList(pageInfo,dto,startTime1,startTime2,endTime1,endTime2); |
| | | for (ChargingOrderListVO chargingOrderListVO : list) { |
| | | chargingOrderListVO.setUid(chargingOrderListVO.getId()+""); |
| | | List<Integer> integers = new ArrayList<>(); |
| | | integers.add(chargingOrderListVO.getSiteId()); |
| | | List<Site> data = siteClient.getSiteByIds(integers).getData(); |
| | | if (!data.isEmpty()) { |
| | | chargingOrderListVO.setSiteName(data.get(0).getName()); |
| | | } |
| | | TChargingGun data1 = chargingGunClient.getChargingGunById(chargingOrderListVO.getChargingGunId()).getData(); |
| | | TChargingPile data2 = chargingPileClient.getChargingPileById(chargingOrderListVO.getChargingPileId()).getData(); |
| | | if (data2 != null && data1 != null) { |
| | | chargingOrderListVO.setTerminalName(data2.getName() + "-" + data1.getName()); |
| | | } |
| | | // 获取充电时间 |
| | | UploadRealTimeMonitoringData data5 = uploadRealTimeMonitoringDataClient.chargingOrderInfo(chargingOrderListVO.getCode()).getData(); |
| | | if (data5!=null){ |
| | | if (data5.getTime_remaining()!=null){ |
| | | chargingOrderListVO.setChargingSecond(data5.getTime_remaining()*60L); |
| | | |
| | | } |
| | | } |
| | | // 获取开始SOC 结束soc |
| | | List<UploadRealTimeMonitoringData> data6 = uploadRealTimeMonitoringDataClient.getDataByOrderCode(chargingOrderListVO.getCode()).getData(); |
| | | if (!data6.isEmpty()){ |
| | | // 第一条数据soc为开始 最后一条数据soc为结束soc |
| | | chargingOrderListVO.setStartSoc(data6.get(0).getSoc().toString()); |
| | | chargingOrderListVO.setEndSoc(data6.get(data6.size()-1).getSoc().toString()); |
| | | } |
| | | TAppUser data3 = appUserClient.getUserById(chargingOrderListVO.getAppUserId()).getData(); |
| | | List<Long> carId = new ArrayList<>(); |
| | | if (chargingOrderListVO.getAppUserCarId() != null) { |
| | | carId.add(chargingOrderListVO.getAppUserCarId()); |
| | | List<TAppUserCar> data4 = appUserCarClient.getCarByIds(carId).getData(); |
| | | if (!data4.isEmpty()) chargingOrderListVO.setLicensePlate(data4.get(0).getLicensePlate()); |
| | | } |
| | | if (data3 != null) chargingOrderListVO.setPhone(data3.getPhone()); |
| | | List<TChargingOrderAccountingStrategy> list2 = chargingOrderAccountingStrategyService.lambdaQuery() |
| | | .eq(TChargingOrderAccountingStrategy::getChargingOrderId, chargingOrderListVO.getId()).list(); |
| | | // 尖峰平谷充电量 度数 |
| | | BigDecimal jian = new BigDecimal("0"); |
| | | BigDecimal feng = new BigDecimal("0"); |
| | | BigDecimal ping = new BigDecimal("0"); |
| | | BigDecimal gu = new BigDecimal("0"); |
| | | BigDecimal total = new BigDecimal("0"); |
| | | for (TChargingOrderAccountingStrategy temp : list2) { |
| | | switch (temp.getType()) { |
| | | case 1: |
| | | jian = jian.add(temp.getChargingCapacity()); |
| | | break; |
| | | case 2: |
| | | feng = feng.add(temp.getChargingCapacity()); |
| | | break; |
| | | case 3: |
| | | ping = ping.add(temp.getChargingCapacity()); |
| | | break; |
| | | case 4: |
| | | gu = gu.add(temp.getChargingCapacity()); |
| | | break; |
| | | } |
| | | } |
| | | total = total.add(jian).add(feng).add(ping).add(gu); |
| | | chargingOrderListVO.setElectronicProportion( |
| | | jian.divide(total,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"))+"%(尖)/" |
| | | +feng.divide(total,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"))+"%(峰)/" |
| | | +ping.divide(total,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"))+"%(平)/" |
| | | +gu.divide(total,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"))+"%(谷)"); |
| | | } |
| | | // 不分页 |
| | | List<ChargingOrderListVO> list1 = this.baseMapper.chargingList1(dto,startTime1,startTime2,endTime1,endTime2); |
| | | chargingOrderTimeVO.setOrderCount(list1.size()); |
| | | // 计算充电总度数 |
| | | BigDecimal electronic = new BigDecimal("0"); |
| | | // 支付金额 |
| | | BigDecimal paymentAmount = new BigDecimal("0"); |
| | | // 电费 |
| | | BigDecimal electrovalence = new BigDecimal("0"); |
| | | // 服务费 |
| | | BigDecimal serviceCharge = new BigDecimal("0"); |
| | | // 尖峰平谷充电到账 |
| | | BigDecimal jianElectronic = new BigDecimal("0"); |
| | | BigDecimal fengElectronic = new BigDecimal("0"); |
| | | BigDecimal pingElectronic = new BigDecimal("0"); |
| | | BigDecimal guElectronic = new BigDecimal("0"); |
| | | // 尖峰平谷服务费 |
| | | BigDecimal jianService = new BigDecimal("0"); |
| | | BigDecimal fengService = new BigDecimal("0"); |
| | | BigDecimal pingService = new BigDecimal("0"); |
| | | BigDecimal guService = new BigDecimal("0"); |
| | | // 尖峰平谷充电量 度数 |
| | | BigDecimal jian = new BigDecimal("0"); |
| | | BigDecimal feng = new BigDecimal("0"); |
| | | BigDecimal ping = new BigDecimal("0"); |
| | | BigDecimal gu = new BigDecimal("0"); |
| | | for (ChargingOrderListVO chargingOrderListVO : list1) { |
| | | electronic = electronic.add(chargingOrderListVO.getChargingCapacity()); |
| | | paymentAmount = paymentAmount.add(chargingOrderListVO.getPaymentAmount()); |
| | | electrovalence = electrovalence.add(chargingOrderListVO.getElectrovalence()); |
| | | serviceCharge = serviceCharge.add(chargingOrderListVO.getServiceCharge()); |
| | | List<TChargingOrderAccountingStrategy> list2 = chargingOrderAccountingStrategyService.lambdaQuery() |
| | | .eq(TChargingOrderAccountingStrategy::getChargingOrderId, chargingOrderListVO.getId()).list(); |
| | | for (TChargingOrderAccountingStrategy temp : list2) { |
| | | switch (temp.getType()){ |
| | | case 1: |
| | | jian = jian.add(temp.getChargingCapacity()); |
| | | jianElectronic = jianElectronic.add(temp.getChargingCapacity()); |
| | | jianService = jianService.add(temp.getChargingCapacity()); |
| | | break; |
| | | case 2: |
| | | feng = feng.add(temp.getChargingCapacity()); |
| | | fengElectronic = fengElectronic.add(temp.getChargingCapacity()); |
| | | fengService = fengService.add(temp.getChargingCapacity()); |
| | | break; |
| | | case 3: |
| | | ping = ping.add(temp.getChargingCapacity()); |
| | | pingElectronic = pingElectronic.add(temp.getChargingCapacity()); |
| | | pingService = pingService.add(temp.getChargingCapacity()); |
| | | break; |
| | | case 4: |
| | | gu = gu.add(temp.getChargingCapacity()); |
| | | guElectronic = guElectronic.add(temp.getChargingCapacity()); |
| | | guService = guService.add(temp.getChargingCapacity()); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | chargingOrderTimeVO.setChargingCapacity(electronic); |
| | | chargingOrderTimeVO.setPaymentAmount(paymentAmount); |
| | | chargingOrderTimeVO.setElectrovalence(electrovalence); |
| | | chargingOrderTimeVO.setServiceCharge(serviceCharge); |
| | | // 计算尖峰平谷充电量占比 |
| | | BigDecimal add = jianElectronic.add(fengElectronic).add(pingElectronic).add(guElectronic); |
| | | // 计算尖峰平谷服务费占比 |
| | | BigDecimal add1 = jianService.add(fengService).add(pingService).add(guService); |
| | | // 计算尖峰平谷充电到账占比 |
| | | BigDecimal add2 = jian.add(feng).add(ping).add(gu); |
| | | chargingOrderTimeVO.setCapacityProportion(jianElectronic+"度/"+fengElectronic+"度/"+pingElectronic+"度/"+guElectronic+"度-" |
| | | +jianElectronic.divide(add,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"))+"%/" |
| | | +fengElectronic.divide(add,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"))+"%/" |
| | | +pingElectronic.divide(add,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"))+"%/" |
| | | +guElectronic.divide(add,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"))+"%"); |
| | | chargingOrderTimeVO.setServiceProportion(jianService+"元/"+fengService+"元/"+pingService+"元/"+guService+"元-" |
| | | +jianService.divide(add1,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"))+"%/" |
| | | +fengService.divide(add1,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"))+"%/" |
| | | +pingService.divide(add1,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"))+"%/" |
| | | +guService.divide(add1,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"))+"%"); |
| | | chargingOrderTimeVO.setElectronicProportion(jian+"元/"+feng+"元/"+ping+"元/"+gu+"元-" |
| | | +jian.divide(add2,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"))+"%/" |
| | | +feng.divide(add2,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"))+"%/" |
| | | +ping.divide(add2,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"))+"%/" |
| | | +gu.divide(add2,4,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal("100"))+"%"); |
| | | chargingOrderTimeVO.setList(pageInfo); |
| | | return chargingOrderTimeVO; |
| | | } |
| | | |
| | | @Override |
| | | public ChargingOrderListInfoVO chargingInfo(String uid) { |
| | | TChargingOrder chargingOrder= this.getById(uid); |
| | | |
| | | ChargingOrderListInfoVO chargingOrderListInfoVO = new ChargingOrderListInfoVO(); |
| | | chargingOrderListInfoVO.setCode(chargingOrder.getCode()); |
| | | List<Site> data = siteClient.getSiteByIds(Arrays.asList(chargingOrder.getSiteId())).getData(); |
| | | if (!data.isEmpty()){ |
| | | chargingOrderListInfoVO.setSiteName(data.get(0).getName()); |
| | | chargingOrderListInfoVO.setSiteAddress(data.get(0).getAddress()); |
| | | } |
| | | TChargingGun data1 = chargingGunClient.getChargingGunById(chargingOrder.getChargingGunId()).getData(); |
| | | TChargingPile data2 = chargingPileClient.getChargingPileById(data1.getChargingPileId()).getData(); |
| | | |
| | | if (data1!=null){ |
| | | chargingOrderListInfoVO.setGunCode(data1.getCode()); |
| | | chargingOrderListInfoVO.setTerminalName(data2.getName()+data1.getName()); |
| | | } |
| | | chargingOrderListInfoVO.setEndMode(chargingOrder.getEndMode()); |
| | | // todo 周一完善 |
| | | // 获取开始SOC 结束soc |
| | | List<UploadRealTimeMonitoringData> data6 = uploadRealTimeMonitoringDataClient.getDataByOrderCode(chargingOrder.getCode()).getData(); |
| | | if (!data6.isEmpty()){ |
| | | // 第一条数据soc为开始 最后一条数据soc为结束soc |
| | | chargingOrderListInfoVO.setStartSoc(data6.get(0).getSoc().toString()); |
| | | chargingOrderListInfoVO.setEndSoc(data6.get(data6.size()-1).getSoc().toString()); |
| | | chargingOrderListInfoVO.setChargingCapacity(data6.get(data6.size()-1).getCharging_degree()); |
| | | chargingOrderListInfoVO.setChargingSecond(data6.get(data6.size()-1).getCumulative_charging_time()*60+""); |
| | | |
| | | } |
| | | if (chargingOrder.getAppUserCarId()!=null){ |
| | | List<TAppUserCar> data3 = appUserCarClient.getCarByIds(Collections.singletonList(chargingOrder.getAppUserCarId())).getData(); |
| | | if (!data3.isEmpty())chargingOrderListInfoVO.setLicensePlate(data3.get(0).getLicensePlate()); |
| | | } |
| | | chargingOrderListInfoVO.setStartTime(chargingOrder.getStartTime()); |
| | | chargingOrderListInfoVO.setEndTime(chargingOrder.getEndTime()); |
| | | chargingOrderListInfoVO.setId(chargingOrder.getId()); |
| | | chargingOrderListInfoVO.setUid(chargingOrder.getId().toString()); |
| | | chargingOrderListInfoVO.setList(data6); |
| | | chargingOrderListInfoVO.setCouponDiscountAmount(chargingOrder.getCouponDiscountAmount()); |
| | | chargingOrderListInfoVO.setVipDiscountAmount(chargingOrder.getVipDiscountAmount()); |
| | | chargingOrderListInfoVO.setSharingAmount(chargingOrder.getSharingAmount()); |
| | | chargingOrderListInfoVO.setCommissionAmount(chargingOrder.getCommissionAmount()); |
| | | // 查询费用明细列表 |
| | | List<TChargingOrderAccountingStrategy> list = chargingOrderAccountingStrategyService.lambdaQuery() |
| | | .eq(TChargingOrderAccountingStrategy::getChargingOrderId, chargingOrder.getId()) |
| | | .list(); |
| | | chargingOrderListInfoVO.setList1(list); |
| | | return chargingOrderListInfoVO; |
| | | } |
| | | |
| | | /** |
| | | * 处理充电订单实时监控数据相关的业务逻辑 |
| | | * @param query |
| | | */ |
| | | @Override |
| | | public void chargeMonitoring(UploadRealTimeMonitoringDataQuery query) { |
| | | // todo 需完善 |
| | | } |
| | | } |