| | |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private OperatorClient operatorClient; |
| | | |
| | | @Resource |
| | | private TransactionRecordClient transactionRecordClient; |
| | | |
| | | |
| | | |
| | |
| | | if(null != data){ |
| | | //支付失败,删除无效的订单 |
| | | String tradeStatus = data.getTradeStatus(); |
| | | if(tradeStatus.equals("TRADE_CLOSED")){ |
| | | if(null != tradeStatus && tradeStatus.equals("TRADE_CLOSED")){ |
| | | this.removeById(tChargingOrder.getId()); |
| | | } |
| | | } |
| | |
| | | if(null != data && data.getChargeNum() > 0){ |
| | | //计算折扣 |
| | | List<AccountingStrategyDetailOrder> list = accountingStrategyDetailOrderClient.getAllAccountingStrategyDetailOrder(chargingOrder.getId()).getData(); |
| | | list.get(list.size() - 1).setEndTime("23:59"); |
| | | //将数据叠加两份,处理跨天的情况 |
| | | list.addAll(list); |
| | | boolean sta = false; |
| | |
| | | long times = rechargeAmount1.divide(s_total_amount, 0, RoundingMode.DOWN).longValue(); |
| | | if(times > m){ |
| | | //充电时间跨度两个计费策略,需要继续对下一个策略进行计算 |
| | | serviceCharge = s_server_amount.multiply(new BigDecimal(m)); |
| | | serviceCharge = serviceCharge.add(s_server_amount.multiply(new BigDecimal(m))); |
| | | rechargeAmount1 = rechargeAmount1.subtract(s_total_amount.multiply(new BigDecimal(m))); |
| | | if(null != discount){ |
| | | discountAmount = discountAmount.add(serviceCharge.multiply(new BigDecimal(1).subtract(discount))); |
| | | } |
| | | nowTimeMillis = null; |
| | | }else{ |
| | | serviceCharge = s_server_amount.multiply(new BigDecimal(times)); |
| | | if(null != discount){ |
| | | discountAmount = discountAmount.add(serviceCharge.multiply(new BigDecimal(1).subtract(discount))); |
| | | } |
| | | serviceCharge = serviceCharge.add(s_server_amount.multiply(new BigDecimal(times))); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | if(null != discount){ |
| | | discountAmount = serviceCharge.multiply(new BigDecimal(1).subtract(discount)); |
| | | } |
| | | |
| | | if(discountAmount.compareTo(BigDecimal.ZERO) >= 0){ |
| | | //计算会员最大优惠金额 |
| | | TVip vip = vipClient.getInfo1(appUser.getVipId()).getData(); |
| | |
| | | } |
| | | } |
| | | discountAmount = discountAmount.setScale(4, RoundingMode.HALF_EVEN); |
| | | if(discountAmount.compareTo(BigDecimal.ZERO) >= 0){ |
| | | data.setChargeNum(data.getChargeNum() - 1); |
| | | appUserVipDetailClient.updateAppUserVipDetail(data); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | //机子上显示的金额为用户充值的金额+会员折扣金额 |
| | | BigDecimal account_balance = chargingOrder.getRechargeAmount().add(discountAmount).setScale(4, RoundingMode.HALF_EVEN); |
| | |
| | | |
| | | log.info(chargingOrder.getCode() + ":-------------------远程调起开始充电请求-------------------" + platformStartCharging.toString()); |
| | | sendMessageClient.platformStartCharging(platformStartCharging); |
| | | //异步线程检测远程启动的应答结果。如果失败,则需要全额退款 |
| | | Long id = chargingOrder.getId(); |
| | | //执行5分钟的定时任务检测 |
| | | ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); |
| | | scheduler.scheduleAtFixedRate(()->{ |
| | | if(timingDetection(id)){ |
| | | scheduler.shutdown(); |
| | | } |
| | | }, 5, 1, TimeUnit.SECONDS); |
| | | // //异步线程检测远程启动的应答结果。如果失败,则需要全额退款 |
| | | // Long id = chargingOrder.getId(); |
| | | // //执行5分钟的定时任务检测 |
| | | // ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); |
| | | // scheduler.scheduleAtFixedRate(()->{ |
| | | // if(timingDetection(id)){ |
| | | // scheduler.shutdown(); |
| | | // } |
| | | // }, 5, 1, TimeUnit.SECONDS); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | |
| | | Integer counter = counter_map.get(code); |
| | | PreChargeCheck preChargeCheck1 = redisService.getCacheObject(key); |
| | | //5分钟内还未插枪则取消充电,退回金额。 |
| | | if(failure_cause == 5 && (null == counter || counter < 300)){ |
| | | if(failure_cause == 5 && (null == counter || counter < 1800)){ |
| | | counter = (null == counter ? 0 : counter) + 1; |
| | | counter_map.put(code, counter); |
| | | //启动失败 |
| | |
| | | log.info(code + ":-------------------未上传开启充电结果-------------------" + counter); |
| | | PreChargeCheck preChargeCheck1 = redisService.getCacheObject(key); |
| | | //5分钟内未启动成功,退回金额。 |
| | | if(null == counter || counter < 300){ |
| | | if(null == counter || counter < 1800){ |
| | | counter = (null == counter ? 0 : counter) + 1; |
| | | boot_failed_map.put(code, counter); |
| | | //启动失败 |
| | |
| | | chargingGun.setStatus(4); |
| | | chargingGunClient.updateChargingGunById(chargingGun); |
| | | //推送状态给三方平台 |
| | | tcecClient.pushChargingGunStatus(chargingGun.getId(), chargingGun.getStatus()); |
| | | tcecClient.pushChargingGunStatus(chargingGun.getFullNumber(), chargingGun.getStatus()); |
| | | } |
| | | redisService.setCacheObject("AQJC_" + order.getChargingGunId(), preChargeCheck1, 24L, TimeUnit.HOURS); |
| | | this.updateById(order); |
| | |
| | | amount.setTotal(rechargeAmount.multiply(new BigDecimal(100)).intValue()); |
| | | amount.setCurrency("CNY"); |
| | | model.setAmount(amount); |
| | | R<String> orderR = wxPaymentClient.refundOrderR(model); |
| | | R<Map<String, Object>> orderR = wxPaymentClient.refundOrderR(model); |
| | | if(200 == orderR.getCode()){ |
| | | chargingOrderRefundService.save(chargingOrderRefund); |
| | | //手续费 |
| | | Map<String, Object> amount1 = (Map<String, Object>) orderR.getData().get("amount"); |
| | | Object refund_fee1 = amount1.get("refund_fee"); |
| | | BigDecimal refund_fee = new BigDecimal(null == refund_fee1 ? "0" : refund_fee1.toString()).divide(new BigDecimal(100)); |
| | | chargingOrderRefund.setRefundFee(refund_fee); |
| | | chargingOrderRefundService.updateById(chargingOrderRefund); |
| | | //回退会员折扣次数 |
| | | if(chargingOrder.getVipDiscountAmount().compareTo(BigDecimal.ZERO) > 0){ |
| | | TAppUser appUser = appUserClient.getUserById(chargingOrder.getAppUserId()).getData(); |
| | | GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail(); |
| | | getAppUserVipDetail.setAppUserId(chargingOrder.getAppUserId()); |
| | | getAppUserVipDetail.setVipId(appUser.getVipId()); |
| | | TAppUserVipDetail data = appUserVipDetailClient.getAppUserVipDetail(getAppUserVipDetail).getData(); |
| | | if(null != data){ |
| | | data.setChargeNum(data.getChargeNum() + 1); |
| | | appUserVipDetailClient.updateAppUserVipDetail(data); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if(2 == rechargePaymentType){ |
| | |
| | | dto.setRefundReason("充电失败,取消充电订单"); |
| | | RefundResp resp = aliPaymentClient.refund(dto).getData(); |
| | | if(null != resp){ |
| | | AjaxResult success = chargingOrderStartupFailureWxRefund(resp.getOutTradeNo(), resp.getTradeNo(), "SUCCESS", null); |
| | | if(success.isSuccess()){ |
| | | chargingOrderRefundService.save(chargingOrderRefund); |
| | | chargingOrderRefundService.save(chargingOrderRefund); |
| | | //回退会员折扣次数 |
| | | if(chargingOrder.getVipDiscountAmount().compareTo(BigDecimal.ZERO) > 0){ |
| | | TAppUser appUser = appUserClient.getUserById(chargingOrder.getAppUserId()).getData(); |
| | | GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail(); |
| | | getAppUserVipDetail.setAppUserId(chargingOrder.getAppUserId()); |
| | | getAppUserVipDetail.setVipId(appUser.getVipId()); |
| | | TAppUserVipDetail data = appUserVipDetailClient.getAppUserVipDetail(getAppUserVipDetail).getData(); |
| | | if(null != data){ |
| | | data.setChargeNum(data.getChargeNum() + 1); |
| | | appUserVipDetailClient.updateAppUserVipDetail(data); |
| | | } |
| | | } |
| | | |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | chargingOrderStartupFailureWxRefund(chargingOrderRefund.getRefundCode(), resp.getTradeNo(), "SUCCESS", null); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | public void refund1(String code, BigDecimal money){ |
| | | log.info(code + ":-------------------充电成功,执行手动退款-------------------"); |
| | | TChargingOrder chargingOrder = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, code)); |
| | | if(chargingOrder.getOrderSource() == 1){ |
| | | BigDecimal rechargeAmount = chargingOrder.getRechargeAmount(); |
| | | Integer rechargePaymentType = chargingOrder.getRechargePaymentType(); |
| | | //构建退款明细 |
| | | TChargingOrderRefund chargingOrderRefund = new TChargingOrderRefund(); |
| | | chargingOrderRefund.setChargingOrderId(chargingOrder.getId()); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | chargingOrderRefund.setRefundCode("CDF" + sdf.format(new Date()) + Double.valueOf(Math.random() * 1000).intValue()); |
| | | chargingOrderRefund.setRefundAmount(money); |
| | | chargingOrderRefund.setRefundStatus(1); |
| | | chargingOrderRefund.setPayType(rechargePaymentType); |
| | | chargingOrderRefund.setRefundStatus(1); |
| | | chargingOrderRefund.setCode(code); |
| | | chargingOrderRefund.setRefundTitle("充电完成退款"); |
| | | chargingOrderRefund.setRefundContent("充电完成退款"); |
| | | chargingOrderRefund.setRefundReason("充电完成退款"); |
| | | chargingOrderRefund.setRefundRemark("充电完成退款,手动退款"); |
| | | chargingOrderRefund.setRefundTotalAmount(money); |
| | | chargingOrderRefund.setPayAmount(money); |
| | | if(1 == rechargePaymentType){ |
| | | WxPaymentRefundModel model = new WxPaymentRefundModel(); |
| | | model.setOut_trade_no(chargingOrder.getCode()); |
| | | model.setOut_refund_no(chargingOrderRefund.getRefundCode()); |
| | | model.setReason("充电完成退款"); |
| | | model.setNotify_url("/payment/wx/refund/notify"); |
| | | WxPaymentRefundModel.RefundAmount amount = new WxPaymentRefundModel.RefundAmount(); |
| | | amount.setRefund(money.multiply(new BigDecimal(100)).intValue()); |
| | | amount.setTotal(rechargeAmount.multiply(new BigDecimal(100)).intValue()); |
| | | amount.setCurrency("CNY"); |
| | | model.setAmount(amount); |
| | | R<Map<String, Object>> orderR = wxPaymentClient.refundOrderR(model); |
| | | if(200 == orderR.getCode()){ |
| | | chargingOrderRefundService.save(chargingOrderRefund); |
| | | //手续费 |
| | | Map<String, Object> amount1 = (Map<String, Object>) orderR.getData().get("amount"); |
| | | Object refund_fee1 = amount1.get("refund_fee"); |
| | | BigDecimal refund_fee = new BigDecimal(null == refund_fee1 ? "0" : refund_fee1.toString()).divide(new BigDecimal(100)); |
| | | chargingOrderRefund.setRefundFee(refund_fee); |
| | | chargingOrderRefundService.updateById(chargingOrderRefund); |
| | | } |
| | | } |
| | | if(2 == rechargePaymentType){ |
| | | RefundReq dto = new RefundReq(); |
| | | dto.setOutTradeNo(chargingOrder.getCode()); |
| | | dto.setOutRequestNo(chargingOrderRefund.getCode()); |
| | | dto.setRefundAmount(money.toString()); |
| | | dto.setRefundReason("充电完成退款"); |
| | | RefundResp resp = aliPaymentClient.refund(dto).getData(); |
| | | if(null != resp){ |
| | | chargingOrderRefundService.save(chargingOrderRefund); |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | chargingOrderStartupFailureWxRefund(chargingOrderRefund.getRefundCode(), resp.getTradeNo(), "SUCCESS", null); |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | if(1 == doubleIntegration){ |
| | | num1 *= 2; |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | GetInviteUser query = new GetInviteUser(); |
| | |
| | | @Override |
| | | public TCharingOrderVO chargingOrder(ChargingOrderQuery dto) { |
| | | TCharingOrderVO tCharingOrderVO = new TCharingOrderVO(); |
| | | |
| | | |
| | | List<TChargingGun> allGun = chargingGunClient.getAllGun().getData(); |
| | | List<TChargingPile> allPile = chargingGunClient.getAllPile().getData(); |
| | | List<Site> data9 = siteClient.getSiteAll().getData(); |
| | | List<TAppUser> data6 = appUserClient.getAllUser().getData(); |
| | | List<TAppUserCar> data4 = appUserCarClient.getAllCar().getData(); |
| | | String startTime1 = null; |
| | | String startTime2 = null; |
| | | String endTime1 = null; |
| | |
| | | endTime2 = split[1]; |
| | | } |
| | | PageInfo<ChargingOrderVO> pageInfo = new PageInfo<>(dto.getPageCurr(),dto.getPageSize()); |
| | | PageInfo<ChargingOrderVO> pageInfo1 = new PageInfo<>(1,9999999); |
| | | |
| | | if (StringUtils.hasLength(dto.getPhone())){ |
| | | List<Long> data = appUserClient.getUserIdsByPhone(dto.getPhone()).getData(); |
| | |
| | | if (siteIds.isEmpty())siteIds.add(-1); |
| | | dto.setSiteIds(siteIds); |
| | | List<ChargingOrderVO> list = this.baseMapper.chargingOrder(pageInfo,dto,startTime1,startTime2,endTime1,endTime2); |
| | | List<ChargingOrderVO> list1 = this.baseMapper.chargingOrder(pageInfo1,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"); |
| | | BigDecimal commissionMoney = new BigDecimal("0"); |
| | | BigDecimal refundMoney = new BigDecimal("0"); |
| | | // BigDecimal refundMoney = new BigDecimal("0"); |
| | | BigDecimal paymentMoney = new BigDecimal("0"); |
| | | List<String> collect2 = list.stream().map(TChargingOrder::getCode).collect(Collectors.toList()); |
| | | List<TChargingOrderAccountingStrategy> list3 = chargingOrderAccountingStrategyService.list(); |
| | | |
| | | for (ChargingOrderVO chargingOrderVO : list) { |
| | | if (roleType == 2){ |
| | | for (Integer siteId : siteIds) { |
| | |
| | | List<Boolean> t1= partnerClient.getChargingOrderMenu(sysUser.getObjectId(),siteId).getData(); |
| | | chargingOrderVO.setAuthRecord(t1.get(0)); |
| | | } |
| | | |
| | | } |
| | | chargingOrderVO.setCommissionAmount(chargingOrderVO.getOrderAmount()!=null?chargingOrderVO.getOrderAmount().multiply(new BigDecimal("0.006")):new BigDecimal("0")); |
| | | chargingOrderVO.setPlatFormMoney(chargingOrderVO.getOrderAmount()!=null?chargingOrderVO.getOrderAmount().multiply(new BigDecimal("0.006")).setScale(2,BigDecimal.ROUND_DOWN):new BigDecimal("0")); |
| | | chargingOrderVO.setCommissionAmount(chargingOrderVO.getRechargeAmount()!=null?chargingOrderVO.getRechargeAmount().multiply(new BigDecimal("0.006")):new BigDecimal("0")); |
| | | chargingOrderVO.setPlatFormMoney(chargingOrderVO.getRechargeAmount()!=null?chargingOrderVO.getRechargeAmount().multiply(new BigDecimal("0.006")).setScale(2,BigDecimal.ROUND_DOWN):new BigDecimal("0")); |
| | | chargingOrderVO.setUid(chargingOrderVO.getId()+""); |
| | | TChargingGun data3 = chargingGunClient.getChargingGunById(chargingOrderVO.getChargingGunId()).getData(); |
| | | TChargingPile data2 = chargingPileClient.getChargingPileById(chargingOrderVO.getChargingPileId()).getData(); |
| | | TChargingGun data3 = allGun.stream().filter(e->e.getId().equals(chargingOrderVO.getChargingGunId())).findFirst().orElse(null); |
| | | TChargingPile data2 = allPile.stream().filter(e->e.getId().equals(chargingOrderVO.getChargingPileId())).findFirst().orElse(null); |
| | | if (chargingOrderVO.getSiteId()!=null){ |
| | | List<Integer> integers = new ArrayList<>(); |
| | | integers.add(chargingOrderVO.getSiteId()); |
| | | List<Site> data = siteClient.getSiteByIds(integers).getData(); |
| | | if (!data.isEmpty())chargingOrderVO.setSiteName(data.get(0).getName()); |
| | | Site site = data9.stream().filter(e -> e.getId().equals(chargingOrderVO.getSiteId())).findFirst().orElse(null); |
| | | if (site!=null)chargingOrderVO.setSiteName(site.getName()); |
| | | } |
| | | if (data2!=null && data3!=null){ |
| | | chargingOrderVO.setTerminalName(data2.getName()+"-"+data3.getName()); |
| | | } |
| | | // 充电订单 明细记录 |
| | | List<TChargingOrderAccountingStrategy> chargingOrderId = chargingOrderAccountingStrategyService.list(new QueryWrapper<TChargingOrderAccountingStrategy>() |
| | | .eq("charging_order_id", chargingOrderVO.getId())); |
| | | List<TChargingOrderAccountingStrategy> chargingOrderId = list3.stream().filter(e -> e.getChargingOrderId().equals(chargingOrderVO.getId())).collect(Collectors.toList()); |
| | | if (chargingOrderVO.getStartTime()!=null && chargingOrderVO.getEndTime()!=null){ |
| | | LocalDateTime startTime = chargingOrderVO.getStartTime(); |
| | | LocalDateTime endTime = chargingOrderVO.getEndTime(); |
| | | // 计算时间差 单位秒 |
| | | long between = ChronoUnit.SECONDS.between(startTime, endTime); |
| | | chargingOrderVO.setChargingSecond(between); |
| | | |
| | | |
| | | BigDecimal electronic_reduce = chargingOrderId.stream().map(TChargingOrderAccountingStrategy::getPeriodElectricPrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | chargingOrderVO.setElectrovalence(electronic_reduce); |
| | | BigDecimal service_reduce = chargingOrderId.stream().map(TChargingOrderAccountingStrategy::getPeriodServicePrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | if (!chargingOrderVO.getOrderSource().equals(2)){ |
| | | chargingOrderVO.setServiceCharge(service_reduce); |
| | | chargingOrderVO.setSharingAmount(BigDecimal.ZERO); |
| | | }else{ |
| | | chargingOrderVO.setServiceCharge(service_reduce.multiply(new BigDecimal("0.8"))); |
| | | chargingOrderVO.setSharingAmount(service_reduce.multiply(new BigDecimal("0.2"))); |
| | | } |
| | | } |
| | | // 充电时段数 |
| | | int size = chargingOrderId.size(); |
| | | chargingOrderVO.setCount(size); |
| | | // 用户手机号 |
| | | TAppUser data = appUserClient.getUserById(chargingOrderVO.getAppUserId()).getData(); |
| | | TAppUser data = data6.stream().filter(e -> e.getId().equals(chargingOrderVO.getAppUserId())).findFirst().orElse(null); |
| | | 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()); |
| | | TAppUserCar tAppUserCar = data4.stream().filter(e -> e.getId().equals(chargingOrderVO.getAppUserCarId())).findFirst().orElse(null); |
| | | if (tAppUserCar!=null){ |
| | | chargingOrderVO.setLicensePlate(tAppUserCar.getLicensePlate()); |
| | | } |
| | | }else{ |
| | | chargingOrderVO.setLicensePlate(chargingOrderVO.getPlateNum()); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | List<Long> orderIds = list1.stream().map(TChargingOrder::getId).collect(Collectors.toList()); |
| | | if(orderIds.isEmpty())orderIds.add(-1L); |
| | | List<TChargingOrderRefund> chargingOrderRefunds = chargingOrderRefundService.lambdaQuery() |
| | | .in(TChargingOrderRefund::getChargingOrderId, orderIds) |
| | | .eq(TChargingOrderRefund::getRefundStatus,2).list(); |
| | | |
| | | // List<TChargingOrderRefund> chargingOrderRefunds = chargingOrderRefundService.lambdaQuery() |
| | | // .eq(TChargingOrderRefund::getRefundStatus,2).list(); |
| | | |
| | | |
| | | List<ChargingOrderVO> list1 = this.baseMapper.chargingOrderNolimit(dto,startTime1,startTime2,endTime1,endTime2); |
| | | for (ChargingOrderVO chargingOrderVO : list1) { |
| | | paymentMoney= paymentMoney.add(chargingOrderVO.getPaymentAmount()!=null?chargingOrderVO.getPaymentAmount():new BigDecimal("0")); |
| | | commissionMoney = commissionMoney.add(chargingOrderVO.getOrderAmount()!=null?chargingOrderVO.getOrderAmount().multiply(new BigDecimal("0.006")):new BigDecimal("0")); |
| | | if (chargingOrderVO.getChargingCapacity()!=null){ |
| | | total = total.add(chargingOrderVO.getElectricity()!=null?chargingOrderVO.getElectricity():new BigDecimal("0")); |
| | | if(null == chargingOrderVO.getStatus() || 5 != chargingOrderVO.getStatus()){ |
| | | continue; |
| | | } |
| | | List<TChargingOrderAccountingStrategy> list4 = list3.stream().filter(e -> e.getChargingOrderId().equals(chargingOrderVO.getId())).collect(Collectors.toList()); |
| | | BigDecimal electronic_reduce = list4.stream().map(TChargingOrderAccountingStrategy::getPeriodElectricPrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal service_reduce = list4.stream().map(TChargingOrderAccountingStrategy::getPeriodServicePrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal chargingCapacity = list4.stream().map(TChargingOrderAccountingStrategy::getChargingCapacity).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | electronicMoney = electronicMoney.add(electronic_reduce); |
| | | total = total.add(chargingCapacity); |
| | | if (!chargingOrderVO.getOrderSource().equals(2)) { |
| | | serviceMoney = serviceMoney.add(service_reduce); |
| | | paymentMoney = paymentMoney.add(electronic_reduce).add(service_reduce); |
| | | }else{ |
| | | serviceMoney = serviceMoney.add(service_reduce.multiply(new BigDecimal("0.8"))); |
| | | paymentMoney = paymentMoney.add(electronic_reduce).add(service_reduce.multiply(new BigDecimal("0.8"))); |
| | | } |
| | | if (chargingOrderVO.getStartTime()!=null && chargingOrderVO.getEndTime()!=null){ |
| | | LocalDateTime startTime = chargingOrderVO.getStartTime(); |
| | |
| | | long between = ChronoUnit.SECONDS.between(startTime, endTime); |
| | | time+=between; |
| | | } |
| | | List<TChargingOrderRefund> list2 = chargingOrderRefunds.stream().filter(e -> e.getChargingOrderId() != null && e.getChargingOrderId().equals(chargingOrderVO.getId())) |
| | | .collect(Collectors.toList()); |
| | | for (TChargingOrderRefund tChargingOrderRefund : list2) { |
| | | refundMoney = refundMoney.add(tChargingOrderRefund.getRefundTotalAmount()); |
| | | } |
| | | electronicMoney = electronicMoney.add(chargingOrderVO.getElectrovalence()!=null?chargingOrderVO.getElectrovalence():new BigDecimal("0")); |
| | | serviceMoney = serviceMoney.add(chargingOrderVO.getServiceCharge()!=null?chargingOrderVO.getServiceCharge():new BigDecimal("0")); |
| | | // List<TChargingOrderRefund> list2 = chargingOrderRefunds.stream().filter(e -> e.getChargingOrderId() != null && e.getChargingOrderId().equals(chargingOrderVO.getId())) |
| | | // .collect(Collectors.toList()); |
| | | // for (TChargingOrderRefund tChargingOrderRefund : list2) { |
| | | // refundMoney = refundMoney.add(tChargingOrderRefund.getRefundTotalAmount()); |
| | | // } |
| | | } |
| | | tCharingOrderVO.setTotal(total); |
| | | tCharingOrderVO.setTime(time); |
| | | tCharingOrderVO.setIncome(paymentMoney.subtract(commissionMoney)); |
| | | tCharingOrderVO.setElectronicMoney(electronicMoney); |
| | | tCharingOrderVO.setServiceMoney(serviceMoney); |
| | | tCharingOrderVO.setIncome(paymentMoney.setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | tCharingOrderVO.setElectronicMoney(electronicMoney.setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | tCharingOrderVO.setServiceMoney(serviceMoney.setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | pageInfo.setRecords(list); |
| | | tCharingOrderVO.setList(pageInfo); |
| | | return tCharingOrderVO; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, Object> countAll(LocalDate sixBefore,List<Integer> siteIds) { |
| | | return this.baseMapper.countAll(sixBefore,siteIds); |
| | | public Map<String, Object> countAll(List<Integer> siteIds) { |
| | | return this.baseMapper.countAll(siteIds); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getSumByType(List<Long> chargingOrderIds) { |
| | | return this.baseMapper.getSumByType(chargingOrderIds); |
| | | public List<Map<String, Object>> getSumByType(LocalDate start,LocalDate end,List<Integer> siteIds) { |
| | | LocalDateTime start1 = start.atStartOfDay(); |
| | | LocalDateTime end1 = end.atTime(LocalTime.MAX); |
| | | return this.baseMapper.getSumByType(start1,end1, siteIds); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getDateData(List<Long> chargingOrderIds) { |
| | | return this.baseMapper.getDateData(chargingOrderIds); |
| | | public List<Map<String, Object>> getDateData(LocalDate start,LocalDate end,List<Integer> siteIds) { |
| | | LocalDateTime start1 = start.atStartOfDay(); |
| | | LocalDateTime end1 = end.atTime(LocalTime.MAX); |
| | | return this.baseMapper.getDateData(start1,end1, siteIds); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getWeekData(List<Long> chargingOrderIds) { |
| | | return this.baseMapper.getWeekData(chargingOrderIds); |
| | | public List<Map<String, Object>> getWeekData(LocalDate start,LocalDate end,List<Integer> siteIds) { |
| | | LocalDateTime start1 = start.atStartOfDay(); |
| | | LocalDateTime end1 = end.atTime(LocalTime.MAX); |
| | | return this.baseMapper.getWeekData(start1,end1,siteIds); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getMonthData(List<Long> chargingOrderIds) { |
| | | return this.baseMapper.getMonthData(chargingOrderIds); |
| | | public List<Map<String, Object>> getMonthData(LocalDate start,LocalDate end,List<Integer> siteIds) { |
| | | LocalDateTime start1 = start.atStartOfDay(); |
| | | LocalDateTime end1 = end.atTime(LocalTime.MAX); |
| | | return this.baseMapper.getMonthData(start1,end1,siteIds); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getYearData(List<Long> chargingOrderIds) { |
| | | return this.baseMapper.getYearData(chargingOrderIds); |
| | | public List<Map<String, Object>> getYearData(LocalDate start,LocalDate end,List<Integer> siteIds) { |
| | | LocalDateTime start1 = start.atStartOfDay(); |
| | | LocalDateTime end1 = end.atTime(LocalTime.MAX); |
| | | return this.baseMapper.getYearData(start1,end1,siteIds); |
| | | } |
| | | |
| | | @Resource |
| | | private SysUserClient sysUserClient; |
| | | |
| | | |
| | | @Override |
| | | public ChargingOrderTimeVO chargingList(ChargingListQuery dto) { |
| | | String startTime1 = null; |
| | | String startTime2 = null; |
| | | String endTime1 = null; |
| | | String endTime2 = null; |
| | | |
| | | List<TChargingGun> allGun = chargingGunClient.getAllGun().getData(); |
| | | List<TChargingPile> allPile = chargingGunClient.getAllPile().getData(); |
| | | |
| | | if (StringUtils.hasLength(dto.getStartTime())){ |
| | | String[] split = dto.getStartTime().split(" - "); |
| | |
| | | chargingOrderListVO.setChargingCapacity(chargingOrderListVO.getElectricity()); |
| | | BigDecimal bigDecimal = new BigDecimal("0.006"); |
| | | if (chargingOrderListVO.getOrderAmount()!=null){ |
| | | chargingOrderListVO.setCommissionAmount(chargingOrderListVO.getPaymentAmount().multiply(bigDecimal)); |
| | | chargingOrderListVO.setCommissionAmount(chargingOrderListVO.getRechargeAmount().multiply(bigDecimal)); |
| | | } |
| | | chargingOrderListVO.setPaymentAmount(chargingOrderListVO.getPaymentAmount()); |
| | | chargingOrderListVO.setUid(chargingOrderListVO.getId()+""); |
| | |
| | | chargingOrderListVO.setSiteName(site.getName()); |
| | | } |
| | | if (chargingOrderListVO.getChargingGunId()!=null && chargingOrderListVO.getChargingPileId()!=null){ |
| | | TChargingGun data1 = chargingGunClient.getChargingGunById(chargingOrderListVO.getChargingGunId()).getData(); |
| | | TChargingPile data2 = chargingPileClient.getChargingPileById(chargingOrderListVO.getChargingPileId()).getData(); |
| | | TChargingGun data1 = allGun.stream().filter(e->e.getId().equals(chargingOrderListVO.getChargingGunId())).findFirst().orElse(null); |
| | | TChargingPile data2 = allPile.stream().filter(e->e.getId().equals(chargingOrderListVO.getChargingPileId())).findFirst().orElse(null); |
| | | 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.getCumulative_charging_time()*60L); |
| | | |
| | | } |
| | | if (chargingOrderListVO.getStartTime()!=null && chargingOrderListVO.getEndTime()!=null){ |
| | | LocalDateTime startTime = chargingOrderListVO.getStartTime(); |
| | | LocalDateTime endTime = chargingOrderListVO.getEndTime(); |
| | | // 计算时间差 单位秒 |
| | | long between = ChronoUnit.SECONDS.between(startTime, endTime); |
| | | chargingOrderListVO.setChargingSecond(between); |
| | | } |
| | | // 获取开始SOC 结束soc |
| | | if (chargingOrderListVO.getCode()!=null){ |
| | |
| | | "0"+"%(平)/"+ |
| | | "0"+"%(谷)"); |
| | | } |
| | | |
| | | if (chargingOrderListVO.getOrderSource().equals(2)){ |
| | | chargingOrderListVO.setSharingAmount(chargingOrderListVO.getServiceCharge()!=null? |
| | | chargingOrderListVO.getServiceCharge().multiply(new BigDecimal("0.2")).setScale(2,BigDecimal.ROUND_HALF_UP) |
| | | :new BigDecimal("0")); |
| | | }else{ |
| | | chargingOrderListVO.setSharingAmount(new BigDecimal("0")); |
| | | } |
| | | } |
| | | // 不分页 |
| | | PageInfo<ChargingOrderListVO> pageInfo1 = new PageInfo<>(1,999999999); |
| | |
| | | if (site!=null){ |
| | | chargingOrderListVO.setSiteName(site.getName()); |
| | | } |
| | | if (chargingOrderListVO.getStartTime()!=null && chargingOrderListVO.getEndTime()!=null){ |
| | | LocalDateTime startTime = chargingOrderListVO.getStartTime(); |
| | | LocalDateTime endTime = chargingOrderListVO.getEndTime(); |
| | | // 计算时间差 单位秒 |
| | | long between = ChronoUnit.SECONDS.between(startTime, endTime); |
| | | chargingOrderListVO.setChargingSecond(between); |
| | | } |
| | | if (chargingOrderListVO.getChargingGunId()!=null && chargingOrderListVO.getChargingPileId()!=null){ |
| | | TChargingGun data1 = chargingGunClient.getChargingGunById(chargingOrderListVO.getChargingGunId()).getData(); |
| | | TChargingPile data2 = chargingPileClient.getChargingPileById(chargingOrderListVO.getChargingPileId()).getData(); |
| | | TChargingGun data1 = allGun.stream().filter(e->e.getId().equals(chargingOrderListVO.getChargingGunId())).findFirst().orElse(null); |
| | | TChargingPile data2 = allPile.stream().filter(e->e.getId().equals(chargingOrderListVO.getChargingPileId())).findFirst().orElse(null); |
| | | if (data2 != null && data1 != null) { |
| | | chargingOrderListVO.setTerminalName(data2.getName() + "-" + data1.getName()); |
| | | } |
| | |
| | | BigDecimal feng = new BigDecimal("0"); |
| | | BigDecimal ping = new BigDecimal("0"); |
| | | BigDecimal gu = new BigDecimal("0"); |
| | | List<Long> collect = list1.stream().map(ChargingOrderListVO::getId).collect(Collectors.toList()); |
| | | List<TChargingOrderAccountingStrategy> chargingOrderAccountingStrategies = chargingOrderAccountingStrategyService.lambdaQuery() |
| | | .in(TChargingOrderAccountingStrategy::getChargingOrderId,collect).list(); |
| | | List<TChargingOrderAccountingStrategy> chargingOrderAccountingStrategies = chargingOrderAccountingStrategyService.list(); |
| | | for (ChargingOrderListVO chargingOrderListVO : list1) { |
| | | if (chargingOrderListVO.getChargingCapacity()!=null)electronic = electronic.add(chargingOrderListVO.getElectricity()); |
| | | |
| | | if (chargingOrderListVO.getPaymentAmount()!=null)paymentAmount = paymentAmount.add(chargingOrderListVO.getPaymentAmount()); |
| | | if (chargingOrderListVO.getElectrovalence()!=null)electrovalence = electrovalence.add(chargingOrderListVO.getElectrovalence()); |
| | | if (chargingOrderListVO.getServiceCharge()!=null)serviceCharge = serviceCharge.add(chargingOrderListVO.getServiceCharge()); |
| | | List<TChargingOrderAccountingStrategy> list2 = chargingOrderAccountingStrategies.stream().filter(e -> e.getChargingOrderId().equals(chargingOrderListVO.getId())) |
| | | .collect(Collectors.toList()); |
| | | for (TChargingOrderAccountingStrategy temp : list2) { |
| | | switch (temp.getType()){ |
| | | case 1: |
| | | if (temp.getChargingCapacity()!=null)jian = jian.add(temp.getChargingCapacity()); |
| | | if (temp.getChargingCapacity()!=null)jianElectronic = jianElectronic.add(temp.getElectrovalence()); |
| | | if (temp.getChargingCapacity()!=null)jianService = jianService.add(temp.getServiceCharge()); |
| | | break; |
| | | case 2: |
| | | if (temp.getChargingCapacity()!=null)feng = feng.add(temp.getChargingCapacity()); |
| | | if (temp.getChargingCapacity()!=null)fengElectronic = fengElectronic.add(temp.getElectrovalence()); |
| | | if (temp.getChargingCapacity()!=null)fengService = fengService.add(temp.getServiceCharge()); |
| | | break; |
| | | case 3: |
| | | if (temp.getChargingCapacity()!=null)ping = ping.add(temp.getChargingCapacity()); |
| | | if (temp.getChargingCapacity()!=null)pingElectronic = pingElectronic.add(temp.getElectrovalence()); |
| | | if (temp.getChargingCapacity()!=null)pingService = pingService.add(temp.getServiceCharge()); |
| | | break; |
| | | case 4: |
| | | if (temp.getChargingCapacity()!=null)gu = gu.add(temp.getChargingCapacity()); |
| | | if (temp.getChargingCapacity()!=null)guElectronic = guElectronic.add(temp.getElectrovalence()); |
| | | if (temp.getChargingCapacity()!=null)guService = guService.add(temp.getServiceCharge()); |
| | | break; |
| | | List<TChargingOrderAccountingStrategy> collect = chargingOrderAccountingStrategies.stream().filter(s -> s.getChargingOrderId().equals(chargingOrderListVO.getId())).collect(Collectors.toList()); |
| | | BigDecimal periodServicePrice = collect.stream().map(TChargingOrderAccountingStrategy::getPeriodServicePrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal periodElectricPrice = collect.stream().map(TChargingOrderAccountingStrategy::getPeriodElectricPrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal chargingCapacity = collect.stream().map(TChargingOrderAccountingStrategy::getChargingCapacity).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | electronic = electronic.add(chargingCapacity); |
| | | electrovalence = electrovalence.add(periodElectricPrice); |
| | | if (chargingOrderListVO.getOrderSource().equals(2)){ |
| | | serviceCharge = serviceCharge.add(periodServicePrice.multiply(new BigDecimal("0.8"))); |
| | | paymentAmount = paymentAmount.add(periodElectricPrice).add(periodServicePrice.multiply(new BigDecimal("0.8"))); |
| | | }else{ |
| | | serviceCharge = serviceCharge.add(periodServicePrice); |
| | | paymentAmount = paymentAmount.add(periodElectricPrice).add(periodServicePrice); |
| | | } |
| | | if (!chargingOrderListVO.getOrderSource().equals(2)){ |
| | | List<TChargingOrderAccountingStrategy> list2 = chargingOrderAccountingStrategies.stream().filter(e -> e.getChargingOrderId().equals(chargingOrderListVO.getId())) |
| | | .collect(Collectors.toList()); |
| | | for (TChargingOrderAccountingStrategy temp : list2) { |
| | | switch (temp.getType()){ |
| | | case 1: |
| | | jian = jian.add(temp.getChargingCapacity()); |
| | | jianElectronic = jianElectronic.add(temp.getPeriodElectricPrice()).add(temp.getPeriodServicePrice()); |
| | | jianService = jianService.add(temp.getPeriodServicePrice()); |
| | | break; |
| | | case 2: |
| | | feng = feng.add(temp.getChargingCapacity()); |
| | | fengElectronic = fengElectronic.add(temp.getPeriodElectricPrice()).add(temp.getPeriodServicePrice()); |
| | | fengService = fengService.add(temp.getPeriodServicePrice()); |
| | | break; |
| | | case 3: |
| | | ping = ping.add(temp.getChargingCapacity()); |
| | | pingElectronic = pingElectronic.add(temp.getPeriodElectricPrice()).add(temp.getPeriodServicePrice()); |
| | | pingService = pingService.add(temp.getPeriodServicePrice()); |
| | | break; |
| | | case 4: |
| | | gu = gu.add(temp.getChargingCapacity()); |
| | | guElectronic = guElectronic.add(temp.getPeriodElectricPrice()).add(temp.getPeriodServicePrice()); |
| | | guService = guService.add(temp.getPeriodServicePrice()); |
| | | break; |
| | | } |
| | | } |
| | | }else{ |
| | | List<TChargingOrderAccountingStrategy> list2 = chargingOrderAccountingStrategies.stream().filter(e -> e.getChargingOrderId().equals(chargingOrderListVO.getId())) |
| | | .collect(Collectors.toList()); |
| | | for (TChargingOrderAccountingStrategy temp : list2) { |
| | | BigDecimal multiply = temp.getPeriodServicePrice().multiply(new BigDecimal("0.8")); |
| | | switch (temp.getType()){ |
| | | case 1: |
| | | jian = jian.add(temp.getChargingCapacity()); |
| | | jianElectronic = jianElectronic.add(temp.getPeriodElectricPrice()).add(multiply); |
| | | jianService = jianService.add(multiply); |
| | | break; |
| | | case 2: |
| | | feng = feng.add(temp.getChargingCapacity()); |
| | | fengElectronic = fengElectronic.add(temp.getPeriodElectricPrice()).add(multiply); |
| | | fengService = fengService.add(multiply); |
| | | break; |
| | | case 3: |
| | | ping = ping.add(temp.getChargingCapacity()); |
| | | pingElectronic = pingElectronic.add(temp.getPeriodElectricPrice()).add(multiply); |
| | | pingService = pingService.add(multiply); |
| | | break; |
| | | case 4: |
| | | gu = gu.add(temp.getChargingCapacity()); |
| | | guElectronic = guElectronic.add(temp.getPeriodElectricPrice()).add(multiply); |
| | | guService = guService.add(multiply); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | chargingOrderTimeVO.setChargingCapacity(electronic); |
| | | chargingOrderTimeVO.setPaymentAmount(paymentAmount); |
| | | chargingOrderTimeVO.setElectrovalence(electrovalence); |
| | | chargingOrderTimeVO.setServiceCharge(serviceCharge); |
| | | // 计算尖峰平谷充电量占比 |
| | | chargingOrderTimeVO.setChargingCapacity(electronic.setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | chargingOrderTimeVO.setPaymentAmount(paymentAmount.setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | chargingOrderTimeVO.setElectrovalence(electrovalence.setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | chargingOrderTimeVO.setServiceCharge(serviceCharge.setScale(2, BigDecimal.ROUND_HALF_EVEN)); |
| | | // 计算尖峰平谷充电到账占比 |
| | | 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); |
| | | if (add.compareTo(new BigDecimal("0"))!=0){ |
| | | 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.setCapacityProportion(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.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.setElectronicProportion(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"))+"%"); |
| | | }else{ |
| | | chargingOrderTimeVO.setCapacityProportion(jianElectronic+"度/"+fengElectronic+"度/"+pingElectronic+"度/"+guElectronic+"度-" |
| | | +"0"+"%/" |
| | |
| | | public ChargingOrderListInfoVO chargingInfo(String uid) { |
| | | TChargingOrder chargingOrder= this.getById(uid); |
| | | ChargingOrderListInfoVO chargingOrderListInfoVO = new ChargingOrderListInfoVO(); |
| | | chargingOrderListInfoVO.setStartTime(chargingOrder.getStartTime()); |
| | | chargingOrderListInfoVO.setEndTime(chargingOrder.getEndTime()); |
| | | chargingOrderListInfoVO.setStatus(chargingOrder.getStatus()); |
| | | BigDecimal bigDecimal = new BigDecimal("0.006"); |
| | | if (chargingOrder.getOrderAmount()!=null){ |
| | |
| | | |
| | | chargingOrderListInfoVO.setList(data6); |
| | | } |
| | | // 获取充电时间 |
| | | UploadRealTimeMonitoringData data5 = uploadRealTimeMonitoringDataClient.chargingOrderInfo(chargingOrder.getCode()).getData(); |
| | | if (data5!=null){ |
| | | if (data5.getTime_remaining()!=null){ |
| | | chargingOrderListInfoVO.setChargingSecond(data5.getCumulative_charging_time()*60L+""); |
| | | |
| | | } |
| | | if (chargingOrderListInfoVO.getStartTime()!=null && chargingOrderListInfoVO.getEndTime()!=null){ |
| | | LocalDateTime startTime = chargingOrderListInfoVO.getStartTime(); |
| | | LocalDateTime endTime = chargingOrderListInfoVO.getEndTime(); |
| | | // 计算时间差 单位秒 |
| | | long between = ChronoUnit.SECONDS.between(startTime, endTime); |
| | | chargingOrderListInfoVO.setChargingSecond(between+""); |
| | | } |
| | | |
| | | if (chargingOrder.getAppUserCarId()!=null){ |
| | |
| | | chargingOrderListInfoVO.setUid(chargingOrder.getId().toString()); |
| | | chargingOrderListInfoVO.setCouponDiscountAmount(chargingOrder.getCouponDiscountAmount()); |
| | | chargingOrderListInfoVO.setVipDiscountAmount(chargingOrder.getVipDiscountAmount()); |
| | | chargingOrderListInfoVO.setSharingAmount(chargingOrder.getSharingAmount()); |
| | | if (chargingOrder.getOrderSource().equals(2)){ |
| | | chargingOrderListInfoVO.setSharingAmount(chargingOrder.getServiceCharge().multiply(new BigDecimal("0.2")).setScale(2, BigDecimal.ROUND_HALF_UP)); |
| | | }else{ |
| | | chargingOrderListInfoVO.setSharingAmount(chargingOrder.getSharingAmount()); |
| | | |
| | | } |
| | | // 查询费用明细列表 |
| | | List<TChargingOrderAccountingStrategy> list = chargingOrderAccountingStrategyService.lambdaQuery() |
| | | .eq(TChargingOrderAccountingStrategy::getChargingOrderId, chargingOrder.getId()) |
| | |
| | | chargingOrder.setChargingCapacity(query.getCharging_degree()); |
| | | chargingOrder.setElectricity(query.getCharging_degree()); |
| | | chargingOrder.setTotalElectricity(new BigDecimal(100 - query.getSoc())); |
| | | BmsDemandAndChargerExportation data = bmsDemandAndChargerExportationClient.getBmsDemandAndChargerExportation(chargingOrder.getCode()).getData(); |
| | | BmsDemandAndChargerExportation data = bmsDemandAndChargerExportationClient.getBmsDemandAndChargerExportation(chargingOrder1.getCode()).getData(); |
| | | if(null != data){ |
| | | chargingOrder.setNeedElec(data.getBms_current_requirements()); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | public void endChargeBillingCharge(TransactionRecordMessageVO vo) { |
| | | public R endChargeBillingCharge(TransactionRecordMessageVO vo) { |
| | | TChargingOrder chargingOrder = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, vo.getTransaction_serial_number())); |
| | | if(null == chargingOrder){ |
| | | return R.ok(); |
| | | } |
| | | Integer status = chargingOrder.getStatus(); |
| | | if(status == 5){ |
| | | return; |
| | | return R.ok(); |
| | | } |
| | | |
| | | //如果使用优惠券需要判断优惠券是否满足使用条件 |
| | | //根据实际的充电金额计算退款金额 退回费用=(原金额/总金额)*(总金额-实际充电金额) |
| | | //退款金额=优惠券金额+剩余充电金额 |
| | | BigDecimal periodElectricPrice_total = BigDecimal.ZERO; |
| | | BigDecimal periodServicePrice_total = BigDecimal.ZERO; |
| | | BigDecimal vipDiscountAmount_total = BigDecimal.ZERO; |
| | | BigDecimal serviceCharge_total = BigDecimal.ZERO; |
| | | BigDecimal total = BigDecimal.ZERO; |
| | | |
| | | //获取订单的计费策略 |
| | |
| | | AccountingStrategyDetailOrderVo vo1 = new AccountingStrategyDetailOrderVo(); |
| | | BeanUtils.copyProperties(strategyDetail, vo1); |
| | | vo1.setChargingCapacity(sharp_peak_charge); |
| | | lists.add(vo1); |
| | | lists.add(0, vo1); |
| | | } |
| | | |
| | | //第二天的 |
| | |
| | | } |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | R.fail("处理失败"); |
| | | } |
| | | |
| | | //开始处理明细 |
| | |
| | | BigDecimal vipDiscountAmount = BigDecimal.ZERO; |
| | | //计算优惠金额 |
| | | if(null != chargingOrder.getVipDiscount()){ |
| | | //0.58折 |
| | | vipDiscountAmount = serviceCharge.multiply(new BigDecimal(1).subtract(chargingOrder.getVipDiscount())); |
| | | serviceCharge = serviceCharge.multiply(chargingOrder.getVipDiscount()); |
| | | } |
| | |
| | | chargingOrderAccountingStrategy.setVipDiscountAmount(vipDiscountAmount.setScale(4, RoundingMode.HALF_EVEN)); |
| | | chargingOrderAccountingStrategy.setCreateTime(LocalDateTime.now()); |
| | | chargingOrderAccountingStrategyService.save(chargingOrderAccountingStrategy); |
| | | |
| | | //电费 |
| | | periodElectricPrice_total = periodElectricPrice_total.add(electrovalenc); |
| | | //服务费(含折扣) |
| | | serviceCharge_total = serviceCharge_total.add(serviceCharge); |
| | | //服务费(不含折扣) |
| | | periodServicePrice_total = periodServicePrice_total.add(originalServicePrice); |
| | | //会员折扣优惠金额 |
| | | vipDiscountAmount_total = vipDiscountAmount_total.add(vipDiscountAmount); |
| | | //原始总金额(不含折扣) |
| | | total = total.add(electrovalenc.add(originalServicePrice)); |
| | | |
| | | } |
| | | |
| | | |
| | | BigDecimal orderAmount = BigDecimal.valueOf(total.doubleValue()); |
| | | //原金额 |
| | | BigDecimal rechargeAmount = chargingOrder.getRechargeAmount(); |
| | | BigDecimal vipDiscountAmount = chargingOrder.getVipDiscountAmount(); |
| | | //总金额(充值金额+会员折扣金额) |
| | | BigDecimal decimal = rechargeAmount.add(vipDiscountAmount); |
| | | //退款金额(已经计算了折扣优惠部分) |
| | | //如果充电总金额未使用完,则需要退回费用=(原金额/总金额)*(总金额-实际充电金额) |
| | | BigDecimal refundAmount = rechargeAmount.divide(decimal, new MathContext(4, RoundingMode.HALF_EVEN)).multiply(decimal.subtract(total)); |
| | | BigDecimal orderAmount = BigDecimal.valueOf(total.doubleValue()); |
| | | BigDecimal payAmount = BigDecimal.valueOf(total.doubleValue()); |
| | | //折扣金额 |
| | | BigDecimal discountAmount = BigDecimal.ZERO; |
| | | if(null != chargingOrder.getVipDiscount()){ |
| | | TAppUser appUser = appUserClient.getUserById(chargingOrder.getAppUserId()).getData(); |
| | | //判断会员是否还有充电优惠次数 |
| | | GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail(); |
| | | getAppUserVipDetail.setAppUserId(chargingOrder.getAppUserId()); |
| | | getAppUserVipDetail.setVipId(appUser.getVipId()); |
| | | TAppUserVipDetail data = appUserVipDetailClient.getAppUserVipDetail(getAppUserVipDetail).getData(); |
| | | if(null != data && data.getChargeNum() > 0){ |
| | | data.setChargeNum(data.getChargeNum() - 1); |
| | | appUserVipDetailClient.updateAppUserVipDetail(data); |
| | | |
| | | //服务费折扣 |
| | | discountAmount = periodServicePrice_total.multiply((new BigDecimal(1).subtract(chargingOrder.getVipDiscount()))); |
| | | TVip vip = vipClient.getInfo1(appUser.getVipId()).getData(); |
| | | BigDecimal maximumDeduction = vip.getMaximumDeduction(); |
| | | //普通会员有最高优惠限制 |
| | | if(vip.getType() == 1 && discountAmount.compareTo(maximumDeduction) > 0){ |
| | | discountAmount = maximumDeduction; |
| | | } |
| | | } |
| | | } |
| | | //会员折扣金额 |
| | | discountAmount = discountAmount.setScale(4, RoundingMode.HALF_EVEN); |
| | | payAmount = payAmount.subtract(discountAmount); |
| | | periodServicePrice_total = periodServicePrice_total.subtract(discountAmount); |
| | | |
| | | //支付金额 |
| | | BigDecimal payAmount = periodElectricPrice_total.add(serviceCharge_total); |
| | | //退款金额=充值金额-实际支付金额 |
| | | BigDecimal refundAmount = rechargeAmount.subtract(payAmount); |
| | | |
| | | TChargingOrder order = new TChargingOrder(); |
| | | order.setId(chargingOrder.getId()); |
| | | order.setAppUserId(chargingOrder.getAppUserId()); |
| | | UploadRealTimeMonitoringData uploadRealTimeMonitoringData = uploadRealTimeMonitoringDataClient.chargingOrderInfo(chargingOrder.getCode()).getData(); |
| | | if(null != uploadRealTimeMonitoringData && null == chargingOrder.getEndMode()){ |
| | | Integer soc = uploadRealTimeMonitoringData.getSoc(); |
| | | order.setEndMode(soc > 98 ? 2 : 3); |
| | | }else{ |
| | | order.setEndMode(1); |
| | | if(soc >= 98){ |
| | | order.setEndMode(2); |
| | | }else if(chargingOrder.getResidualAmount().compareTo(new BigDecimal(1)) <= 0){ |
| | | order.setEndMode(3); |
| | | }else{ |
| | | order.setEndMode(0); |
| | | } |
| | | } |
| | | order.setResidualAmount(rechargeAmount.subtract(total).setScale(2, RoundingMode.HALF_EVEN)); |
| | | order.setStartTime(LocalDateTime.parse(vo.getStart_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SS"))); |
| | | order.setEndTime(LocalDateTime.parse(vo.getEnd_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SS"))); |
| | | order.setStatus(5); |
| | | order.setOrderAmount(orderAmount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | order.setVipDiscountAmount(discountAmount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | order.setElectrovalence(periodElectricPrice_total.setScale(2, RoundingMode.HALF_EVEN)); |
| | | order.setChargingCapacity(vo.getTotal_electricity()); |
| | | order.setElectricity(vo.getTotal_electricity()); |
| | | order.setVipDiscountAmount(vipDiscountAmount_total); |
| | | if(vipDiscountAmount_total.compareTo(BigDecimal.ZERO) == 0){ |
| | | order.setVipDiscount(BigDecimal.valueOf(1)); |
| | | } |
| | | |
| | | //计算优惠券 |
| | | BigDecimal couponDiscount = BigDecimal.ZERO; |
| | |
| | | if(payAmount.compareTo(tCoupon.getMeetTheConditions()) >= 0){ |
| | | BigDecimal couponDiscountAmount = tCoupon.getDiscountAmount(); |
| | | //如果优惠金额大于服务费金额,以服务费作为最大限制 |
| | | if(periodServicePrice_total.compareTo(couponDiscountAmount) < 0){ |
| | | couponDiscount = periodServicePrice_total; |
| | | periodServicePrice_total = BigDecimal.ZERO; |
| | | if(serviceCharge_total.compareTo(couponDiscountAmount) < 0){ |
| | | couponDiscount = serviceCharge_total; |
| | | serviceCharge_total = BigDecimal.ZERO; |
| | | }else{ |
| | | couponDiscount = couponDiscountAmount; |
| | | } |
| | |
| | | BigDecimal divide = payAmount.multiply(new BigDecimal(10).subtract(tCoupon.getDiscount())).divide(new BigDecimal(10)); |
| | | divide = divide.compareTo(tCoupon.getMaximumDiscountAmount()) > 0 ? tCoupon.getMaximumDiscountAmount() : divide; |
| | | //如果优惠金额大于服务费金额,以服务费作为最大限制 |
| | | if(periodServicePrice_total.compareTo(divide) < 0){ |
| | | couponDiscount = periodServicePrice_total; |
| | | periodServicePrice_total = BigDecimal.ZERO; |
| | | if(serviceCharge_total.compareTo(divide) < 0){ |
| | | couponDiscount = serviceCharge_total; |
| | | serviceCharge_total = BigDecimal.ZERO; |
| | | }else{ |
| | | couponDiscount = divide; |
| | | } |
| | |
| | | } |
| | | //优惠券优惠金额 |
| | | couponDiscount = couponDiscount.setScale(4, RoundingMode.HALF_EVEN); |
| | | //退款金额+优惠券 |
| | | refundAmount = refundAmount.add(couponDiscount); |
| | | //实际支付金额-优惠券 |
| | | payAmount = payAmount.subtract(couponDiscount); |
| | | if(periodServicePrice_total.compareTo(BigDecimal.ZERO) > 0){ |
| | | periodServicePrice_total = periodServicePrice_total.subtract(couponDiscount); |
| | | if(serviceCharge_total.compareTo(BigDecimal.ZERO) > 0){ |
| | | serviceCharge_total = serviceCharge_total.subtract(couponDiscount); |
| | | } |
| | | order.setCouponDiscountAmount(couponDiscount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | order.setServiceCharge(periodServicePrice_total.setScale(2, RoundingMode.HALF_EVEN)); |
| | | order.setServiceCharge(serviceCharge_total.setScale(2, RoundingMode.HALF_EVEN)); |
| | | order.setPaymentAmount(payAmount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | order.setRefundAmount(refundAmount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | order.setRefundStatus(1); |
| | |
| | | |
| | | //推送三方平台 |
| | | if(2 == chargingOrder.getOrderSource()){ |
| | | tcecClient.notificationEquipChargeStatus(chargingOrder.getStartChargeSeq(), chargingOrder.getOperatorId()); |
| | | tcecClient.notificationStopChargeResult(chargingOrder.getStartChargeSeq(), chargingOrder.getChargingGunId().toString(), |
| | | chargingOrder.getOperatorId()); |
| | | tcecClient.notificationChargeOrderInfo(chargingOrder.getStartChargeSeq(), chargingOrder.getOperatorId()); |
| | | TChargingOrder finalChargingOrder = chargingOrder; |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | tcecClient.notificationEquipChargeStatus(finalChargingOrder.getStartChargeSeq(), finalChargingOrder.getOperatorId()); |
| | | tcecClient.notificationStopChargeResult(finalChargingOrder.getStartChargeSeq(), finalChargingOrder.getChargingGunId().toString(), |
| | | finalChargingOrder.getOperatorId()); |
| | | tcecClient.notificationChargeOrderInfo(finalChargingOrder.getStartChargeSeq(), finalChargingOrder.getOperatorId()); |
| | | } |
| | | }).start(); |
| | | } |
| | | |
| | | //开始将优惠券优惠的金额添加到明细中 |
| | |
| | | chargingGunClient.updateChargingGunById(chargingGun); |
| | | //推送状态给三方平台 |
| | | if(2 == chargingOrder.getOrderSource()){ |
| | | tcecClient.pushChargingGunStatus(chargingGun.getId(), chargingGun.getStatus()); |
| | | tcecClient.pushChargingGunStatus(chargingGun.getFullNumber(), chargingGun.getStatus()); |
| | | } |
| | | |
| | | //添加积分 |
| | |
| | | amount.setTotal(rechargeAmount.multiply(new BigDecimal(100)).intValue()); |
| | | amount.setCurrency("CNY"); |
| | | model.setAmount(amount); |
| | | R<String> orderR = wxPaymentClient.refundOrderR(model); |
| | | if(200 == orderR.getCode()){ |
| | | R<Map<String, Object>> result = wxPaymentClient.refundOrderR(model); |
| | | if(200 == result.getCode()){ |
| | | chargingOrderRefundService.save(chargingOrderRefund); |
| | | //手续费 |
| | | Map<String, Object> amount1 = (Map<String, Object>) result.getData().get("amount"); |
| | | Object refund_fee1 = amount1.get("refund_fee"); |
| | | BigDecimal refund_fee = new BigDecimal(null == refund_fee1 ? "0" : refund_fee1.toString()).divide(new BigDecimal(100)); |
| | | chargingOrderRefund.setRefundFee(refund_fee); |
| | | chargingOrderRefundService.updateById(chargingOrderRefund); |
| | | } |
| | | } |
| | | if(2 == rechargePaymentType){ |
| | |
| | | |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | // /** |
| | | // * 停止充电返回账单后计算费用 |
| | | // * @param vo |
| | | // */ |
| | | // @Override |
| | | // @GlobalTransactional(rollbackFor = Exception.class) |
| | | // public void endChargeBillingCharge1(TransactionRecordMessageVO vo) { |
| | | // TChargingOrder chargingOrder = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, vo.getTransaction_serial_number())); |
| | | // Integer status = chargingOrder.getStatus(); |
| | | //// if(status == 5){ |
| | | //// return; |
| | | //// } |
| | | // |
| | | // //如果使用优惠券需要判断优惠券是否满足使用条件 |
| | | // //根据实际的充电金额计算退款金额 退回费用=(原金额/总金额)*(总金额-实际充电金额) |
| | | // //退款金额=优惠券金额+剩余充电金额 |
| | | // BigDecimal periodElectricPrice_total = BigDecimal.ZERO; |
| | | // BigDecimal periodServicePrice_total = BigDecimal.ZERO; |
| | | // BigDecimal total = BigDecimal.ZERO; |
| | | // |
| | | // //获取订单的计费策略 |
| | | // List<AccountingStrategyDetailOrder> accountingStrategyDetailOrderList = accountingStrategyDetailOrderClient.getAllAccountingStrategyDetailOrder(chargingOrder.getId()).getData(); |
| | | // accountingStrategyDetailOrderList.get(accountingStrategyDetailOrderList.size() - 1).setEndTime("23:59"); |
| | | // //开始处理计费明细数据和优惠数据 |
| | | //// chargingOrderAccountingStrategyService.remove(new LambdaQueryWrapper<TChargingOrderAccountingStrategy>().eq(TChargingOrderAccountingStrategy::getChargingOrderId, chargingOrder.getId())); |
| | | // SimpleDateFormat sdfs = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // List<AccountingStrategyDetailOrderVo> lists = new ArrayList<>(); |
| | | // try { |
| | | // //跨天 |
| | | // if(!vo.getStart_time().split(" ")[0].equals(vo.getEnd_time().split(" ")[0])){ |
| | | // //当天的 |
| | | // //开始通过计费策略遍历解析每个时段的费用明细 |
| | | // String start_time = vo.getStart_time(); |
| | | // String end_time = vo.getEnd_time(); |
| | | // long start = sdfs.parse(start_time).getTime(); |
| | | // long end = sdfs.parse(end_time).getTime(); |
| | | // Class<? extends TransactionRecordMessageVO> clazz = vo.getClass(); |
| | | // /** |
| | | // * "start_time": "2025-01-03 23:06:43.00", |
| | | // * "end_time": "2025-01-04 00:39:39.00", |
| | | // */ |
| | | // for (int i = accountingStrategyDetailOrderList.size(); i > 0; i--) { |
| | | // AccountingStrategyDetailOrder strategyDetail = accountingStrategyDetailOrderList.get(i - 1); |
| | | // long time = sdfs.parse(start_time.split(" ")[0] + " " + strategyDetail.getEndTime() + ":00").getTime(); |
| | | // if(time < start){ |
| | | // break; |
| | | // } |
| | | // //阶段(1=尖阶段,2=峰阶段,3=平阶段,4=谷阶段) |
| | | // Object invoke = null; |
| | | // switch (strategyDetail.getType()){ |
| | | // case 1: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getSpike_charge" + (i)).invoke(vo); |
| | | // break; |
| | | // case 2: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getPeak_charge" + (i)).invoke(vo); |
| | | // break; |
| | | // case 3: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getFlat_charge" + (i)).invoke(vo); |
| | | // break; |
| | | // case 4: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getValley_charge" + (i)).invoke(vo); |
| | | // break; |
| | | // } |
| | | // if(null == invoke || Double.valueOf(invoke.toString()) == 0){ |
| | | // continue; |
| | | // } |
| | | // BigDecimal sharp_peak_charge = new BigDecimal(invoke.toString()); |
| | | // AccountingStrategyDetailOrderVo vo1 = new AccountingStrategyDetailOrderVo(); |
| | | // BeanUtils.copyProperties(strategyDetail, vo1); |
| | | // vo1.setChargingCapacity(sharp_peak_charge); |
| | | // lists.add(vo1); |
| | | // } |
| | | // |
| | | // //第二天的 |
| | | // //开始通过计费策略遍历解析每个时段的费用明细 |
| | | // for (int i = 0; i < accountingStrategyDetailOrderList.size(); i++) { |
| | | // AccountingStrategyDetailOrder strategyDetail = accountingStrategyDetailOrderList.get(i); |
| | | // long time = sdfs.parse(end_time.split(" ")[0] + " " + strategyDetail.getStartTime() + ":00").getTime(); |
| | | // if(time > end){ |
| | | // break; |
| | | // } |
| | | // //阶段(1=尖阶段,2=峰阶段,3=平阶段,4=谷阶段) |
| | | // Object invoke = null; |
| | | // switch (strategyDetail.getType()){ |
| | | // case 1: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getSpike_charge" + (i + 1)).invoke(vo); |
| | | // break; |
| | | // case 2: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getPeak_charge" + (i + 1)).invoke(vo); |
| | | // break; |
| | | // case 3: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getFlat_charge" + (i + 1)).invoke(vo); |
| | | // break; |
| | | // case 4: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getValley_charge" + (i + 1)).invoke(vo); |
| | | // break; |
| | | // } |
| | | // if(null == invoke || Double.valueOf(invoke.toString()) == 0){ |
| | | // continue; |
| | | // } |
| | | // BigDecimal sharp_peak_charge = new BigDecimal(invoke.toString()); |
| | | // AccountingStrategyDetailOrderVo vo1 = new AccountingStrategyDetailOrderVo(); |
| | | // BeanUtils.copyProperties(strategyDetail, vo1); |
| | | // vo1.setChargingCapacity(sharp_peak_charge); |
| | | // lists.add(vo1); |
| | | // } |
| | | // }else{ |
| | | // for (int i = 0; i < accountingStrategyDetailOrderList.size(); i++) { |
| | | // Class<? extends TransactionRecordMessageVO> clazz = vo.getClass(); |
| | | // AccountingStrategyDetailOrder strategyDetail = accountingStrategyDetailOrderList.get(i); |
| | | // //阶段(1=尖阶段,2=峰阶段,3=平阶段,4=谷阶段) |
| | | // Object invoke = null; |
| | | // switch (strategyDetail.getType()){ |
| | | // case 1: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getSpike_charge" + (i + 1)).invoke(vo); |
| | | // break; |
| | | // case 2: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getPeak_charge" + (i + 1)).invoke(vo); |
| | | // break; |
| | | // case 3: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getFlat_charge" + (i + 1)).invoke(vo); |
| | | // break; |
| | | // case 4: |
| | | // //充电度数 |
| | | // invoke = clazz.getMethod("getValley_charge" + (i + 1)).invoke(vo); |
| | | // break; |
| | | // } |
| | | // if(null == invoke || Double.valueOf(invoke.toString()) == 0){ |
| | | // continue; |
| | | // } |
| | | // BigDecimal sharp_peak_charge = new BigDecimal(invoke.toString()); |
| | | // AccountingStrategyDetailOrderVo vo1 = new AccountingStrategyDetailOrderVo(); |
| | | // BeanUtils.copyProperties(strategyDetail, vo1); |
| | | // vo1.setChargingCapacity(sharp_peak_charge); |
| | | // lists.add(vo1); |
| | | // } |
| | | // } |
| | | // }catch (Exception e){ |
| | | // e.printStackTrace(); |
| | | // } |
| | | // |
| | | // //开始处理明细 |
| | | // for (int i = 0; i < lists.size(); i++) { |
| | | // AccountingStrategyDetailOrderVo strategyDetail = lists.get(i); |
| | | // BigDecimal sharp_peak_charge = strategyDetail.getChargingCapacity(); |
| | | // TChargingOrderAccountingStrategy chargingOrderAccountingStrategy = new TChargingOrderAccountingStrategy(); |
| | | // chargingOrderAccountingStrategy.setChargingOrderId(chargingOrder.getId()); |
| | | // chargingOrderAccountingStrategy.setAccountingStrategyDetailId(strategyDetail.getId()); |
| | | // chargingOrderAccountingStrategy.setType(strategyDetail.getType()); |
| | | // chargingOrderAccountingStrategy.setElectrovalence(strategyDetail.getElectrovalence()); |
| | | // chargingOrderAccountingStrategy.setServiceCharge(strategyDetail.getServiceCharge()); |
| | | // chargingOrderAccountingStrategy.setCostServiceCharge(strategyDetail.getCostServiceCharge()); |
| | | // if(i == 0){ |
| | | // String time = vo.getStart_time().split(" ")[1]; |
| | | // chargingOrderAccountingStrategy.setStartTime(time.substring(0, time.lastIndexOf(":"))); |
| | | // }else{ |
| | | // chargingOrderAccountingStrategy.setStartTime(strategyDetail.getStartTime()); |
| | | // } |
| | | // if(i == lists.size() - 1){ |
| | | // String time = vo.getEnd_time().split(" ")[1]; |
| | | // chargingOrderAccountingStrategy.setEndTime(time.substring(0, time.lastIndexOf(":"))); |
| | | // }else{ |
| | | // chargingOrderAccountingStrategy.setEndTime(strategyDetail.getEndTime()); |
| | | // } |
| | | // |
| | | // //已充电总度数 |
| | | // BigDecimal electrovalenc = strategyDetail.getElectrovalence().multiply(sharp_peak_charge); |
| | | // BigDecimal originalServicePrice = strategyDetail.getServiceCharge().multiply(sharp_peak_charge); |
| | | // BigDecimal serviceCharge = originalServicePrice; |
| | | // BigDecimal vipDiscountAmount = BigDecimal.ZERO; |
| | | // //计算优惠金额 |
| | | // if(null != chargingOrder.getVipDiscount()){ |
| | | // vipDiscountAmount = serviceCharge.multiply(new BigDecimal(1).subtract(chargingOrder.getVipDiscount())); |
| | | // serviceCharge = serviceCharge.multiply(chargingOrder.getVipDiscount()); |
| | | // } |
| | | // chargingOrderAccountingStrategy.setChargingCapacity(sharp_peak_charge); |
| | | // chargingOrderAccountingStrategy.setPeriodElectricPrice(electrovalenc.setScale(4, RoundingMode.HALF_EVEN)); |
| | | // chargingOrderAccountingStrategy.setPeriodServicePrice(serviceCharge.setScale(4, RoundingMode.HALF_EVEN)); |
| | | // chargingOrderAccountingStrategy.setPeriodOriginalServicePrice(originalServicePrice.setScale(4, RoundingMode.HALF_EVEN)); |
| | | // chargingOrderAccountingStrategy.setVipDiscountAmount(vipDiscountAmount.setScale(4, RoundingMode.HALF_EVEN)); |
| | | // chargingOrderAccountingStrategy.setCreateTime(LocalDateTime.now()); |
| | | //// chargingOrderAccountingStrategyService.save(chargingOrderAccountingStrategy); |
| | | // System.err.println("----------"+JSON.toJSONString(chargingOrderAccountingStrategy)); |
| | | // |
| | | // periodElectricPrice_total = periodElectricPrice_total.add(electrovalenc); |
| | | // periodServicePrice_total = periodServicePrice_total.add(originalServicePrice); |
| | | // total = total.add(electrovalenc.add(originalServicePrice)); |
| | | // |
| | | // } |
| | | // |
| | | // |
| | | // //原金额 |
| | | // BigDecimal rechargeAmount = chargingOrder.getRechargeAmount(); |
| | | // BigDecimal vipDiscountAmount = chargingOrder.getVipDiscountAmount(); |
| | | // //总金额(充值金额+会员折扣金额) |
| | | // BigDecimal decimal = rechargeAmount.add(vipDiscountAmount); |
| | | // //退款金额(已经计算了折扣优惠部分) |
| | | // //如果充电总金额未使用完,则需要退回费用=(原金额/总金额)*(总金额-实际充电金额) |
| | | // BigDecimal refundAmount = rechargeAmount.divide(decimal, new MathContext(4, RoundingMode.HALF_EVEN)).multiply(decimal.subtract(total)); |
| | | // BigDecimal orderAmount = BigDecimal.valueOf(total.doubleValue()); |
| | | // BigDecimal payAmount = BigDecimal.valueOf(total.doubleValue()); |
| | | // //折扣金额 |
| | | // BigDecimal discountAmount = BigDecimal.ZERO; |
| | | //// if(null != chargingOrder.getVipDiscount()){ |
| | | //// TAppUser appUser = appUserClient.getUserById(chargingOrder.getAppUserId()).getData(); |
| | | //// //判断会员是否还有充电优惠次数 |
| | | //// GetAppUserVipDetail getAppUserVipDetail = new GetAppUserVipDetail(); |
| | | //// getAppUserVipDetail.setAppUserId(chargingOrder.getAppUserId()); |
| | | //// getAppUserVipDetail.setVipId(appUser.getVipId()); |
| | | //// TAppUserVipDetail data = appUserVipDetailClient.getAppUserVipDetail(getAppUserVipDetail).getData(); |
| | | //// if(null != data && data.getChargeNum() > 0){ |
| | | //// data.setChargeNum(data.getChargeNum() - 1); |
| | | //// appUserVipDetailClient.updateAppUserVipDetail(data); |
| | | //// |
| | | //// //服务费折扣 |
| | | //// discountAmount = periodServicePrice_total.multiply((new BigDecimal(1).subtract(chargingOrder.getVipDiscount()))); |
| | | //// TVip vip = vipClient.getInfo1(appUser.getVipId()).getData(); |
| | | //// BigDecimal maximumDeduction = vip.getMaximumDeduction(); |
| | | //// //普通会员有最高优惠限制 |
| | | //// if(vip.getType() == 1 && discountAmount.compareTo(maximumDeduction) > 0){ |
| | | //// discountAmount = maximumDeduction; |
| | | //// } |
| | | //// } |
| | | //// } |
| | | // //会员折扣金额 |
| | | // discountAmount = discountAmount.setScale(4, RoundingMode.HALF_EVEN); |
| | | // payAmount = payAmount.subtract(discountAmount); |
| | | // periodServicePrice_total = periodServicePrice_total.subtract(discountAmount); |
| | | // |
| | | // TChargingOrder order = new TChargingOrder(); |
| | | // order.setId(chargingOrder.getId()); |
| | | // order.setAppUserId(chargingOrder.getAppUserId()); |
| | | // UploadRealTimeMonitoringData uploadRealTimeMonitoringData = uploadRealTimeMonitoringDataClient.chargingOrderInfo(chargingOrder.getCode()).getData(); |
| | | // if(null != uploadRealTimeMonitoringData && null == chargingOrder.getEndMode()){ |
| | | // Integer soc = uploadRealTimeMonitoringData.getSoc(); |
| | | // order.setEndMode(soc > 98 ? 2 : 3); |
| | | // }else{ |
| | | // order.setEndMode(1); |
| | | // } |
| | | // order.setResidualAmount(rechargeAmount.subtract(total).setScale(2, RoundingMode.HALF_EVEN)); |
| | | // order.setStartTime(LocalDateTime.parse(vo.getStart_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SS"))); |
| | | // order.setEndTime(LocalDateTime.parse(vo.getEnd_time(), DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SS"))); |
| | | // order.setStatus(5); |
| | | // order.setOrderAmount(orderAmount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | // order.setVipDiscountAmount(discountAmount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | // order.setElectrovalence(periodElectricPrice_total.setScale(2, RoundingMode.HALF_EVEN)); |
| | | // order.setChargingCapacity(vo.getTotal_electricity()); |
| | | // order.setElectricity(vo.getTotal_electricity()); |
| | | // |
| | | // //计算优惠券 |
| | | // BigDecimal couponDiscount = BigDecimal.ZERO; |
| | | //// if(null != chargingOrder.getAppCouponId()){ |
| | | //// //判断实际充电金额是否满足优惠券使用条件,如果不满足则不适用优惠券。 |
| | | //// TAppCoupon appCoupon = appCouponClient.getAppCouponById(chargingOrder.getAppCouponId()).getData(); |
| | | //// String couponJson = appCoupon.getCouponJson(); |
| | | //// TCoupon tCoupon = JSON.parseObject(couponJson, TCoupon.class); |
| | | //// Integer preferentialMode = tCoupon.getPreferentialMode(); |
| | | //// if(1 == preferentialMode){ |
| | | //// //满减 |
| | | //// if(payAmount.compareTo(tCoupon.getMeetTheConditions()) >= 0){ |
| | | //// BigDecimal couponDiscountAmount = tCoupon.getDiscountAmount(); |
| | | //// //如果优惠金额大于服务费金额,以服务费作为最大限制 |
| | | //// if(periodServicePrice_total.compareTo(couponDiscountAmount) < 0){ |
| | | //// couponDiscount = periodServicePrice_total; |
| | | //// periodServicePrice_total = BigDecimal.ZERO; |
| | | //// }else{ |
| | | //// couponDiscount = couponDiscountAmount; |
| | | //// } |
| | | //// appCoupon.setStatus(2); |
| | | ////// appCouponClient.updateAppCoupon(appCoupon); |
| | | //// }else{ |
| | | //// order.setAppCouponId(null); |
| | | //// order.setCouponDiscountAmount(BigDecimal.ZERO); |
| | | ////// appCouponClient.refund(chargingOrder.getAppCouponId().toString()); |
| | | //// } |
| | | //// } |
| | | //// if(2 == preferentialMode){ |
| | | //// //抵扣 |
| | | //// if(payAmount.compareTo(tCoupon.getMeetTheConditions()) >= 0){ |
| | | //// //折扣金额 |
| | | //// BigDecimal divide = payAmount.multiply(new BigDecimal(10).subtract(tCoupon.getDiscount())).divide(new BigDecimal(10)); |
| | | //// divide = divide.compareTo(tCoupon.getMaximumDiscountAmount()) > 0 ? tCoupon.getMaximumDiscountAmount() : divide; |
| | | //// //如果优惠金额大于服务费金额,以服务费作为最大限制 |
| | | //// if(periodServicePrice_total.compareTo(divide) < 0){ |
| | | //// couponDiscount = periodServicePrice_total; |
| | | //// periodServicePrice_total = BigDecimal.ZERO; |
| | | //// }else{ |
| | | //// couponDiscount = divide; |
| | | //// } |
| | | //// |
| | | //// appCoupon.setStatus(2); |
| | | //// appCouponClient.updateAppCoupon(appCoupon); |
| | | //// }else{ |
| | | //// order.setAppCouponId(null); |
| | | //// order.setCouponDiscountAmount(BigDecimal.ZERO); |
| | | //// appCouponClient.refund(chargingOrder.getAppCouponId().toString()); |
| | | //// } |
| | | //// } |
| | | //// } |
| | | // //优惠券优惠金额 |
| | | // couponDiscount = couponDiscount.setScale(4, RoundingMode.HALF_EVEN); |
| | | // refundAmount = refundAmount.add(couponDiscount); |
| | | // payAmount = payAmount.subtract(couponDiscount); |
| | | // if(periodServicePrice_total.compareTo(BigDecimal.ZERO) > 0){ |
| | | // periodServicePrice_total = periodServicePrice_total.subtract(couponDiscount); |
| | | // } |
| | | // order.setCouponDiscountAmount(couponDiscount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | // order.setServiceCharge(periodServicePrice_total.setScale(2, RoundingMode.HALF_EVEN)); |
| | | // order.setPaymentAmount(payAmount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | // order.setRefundAmount(refundAmount.setScale(2, RoundingMode.HALF_EVEN)); |
| | | // order.setRefundStatus(1); |
| | | //// this.updateById(order); |
| | | // System.err.println("----------"+JSON.toJSONString(order)); |
| | | //// chargingOrder = this.getById(order.getId()); |
| | | //// |
| | | //// //开始将优惠券优惠的金额添加到明细中 |
| | | //// BigDecimal couponDiscountAmount = order.getCouponDiscountAmount(); |
| | | //// if(null != couponDiscountAmount && couponDiscountAmount.compareTo(BigDecimal.ZERO) > 0){ |
| | | //// List<TChargingOrderAccountingStrategy> list = chargingOrderAccountingStrategyService.list(new LambdaQueryWrapper<TChargingOrderAccountingStrategy>().eq(TChargingOrderAccountingStrategy::getChargingOrderId, order.getId())); |
| | | //// BigDecimal reduce = list.stream().map(TChargingOrderAccountingStrategy::getPeriodServicePrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | //// for (TChargingOrderAccountingStrategy chargingOrderAccountingStrategy : list) { |
| | | //// BigDecimal periodServicePrice = chargingOrderAccountingStrategy.getPeriodServicePrice(); |
| | | //// BigDecimal multiply = couponDiscountAmount.multiply(periodServicePrice.divide(reduce, new MathContext(4, RoundingMode.HALF_EVEN))); |
| | | //// periodServicePrice = periodServicePrice.subtract(multiply); |
| | | //// chargingOrderAccountingStrategy.setPeriodServicePrice(periodServicePrice.setScale(2, RoundingMode.HALF_EVEN)); |
| | | //// chargingOrderAccountingStrategy.setCouponDiscountAmount(multiply.setScale(2, RoundingMode.HALF_EVEN)); |
| | | //// } |
| | | ////// chargingOrderAccountingStrategyService.updateBatchById(list); |
| | | //// } |
| | | //// |
| | | //// // 将枪状态重置为空闲 |
| | | //// TChargingGun chargingGun = new TChargingGun(); |
| | | //// chargingGun.setId(chargingOrder.getChargingGunId()); |
| | | //// chargingGun.setStatus(2); |
| | | //// chargingGun.setChargingPower(BigDecimal.ZERO); |
| | | ////// chargingGunClient.updateChargingGunById(chargingGun); |
| | | //// |
| | | //// //添加积分 |
| | | //// TIntegralRule integralRule = integralRuleClient.getSet().getData(); |
| | | //// if(null != integralRule){ |
| | | //// TAppUser appUser = appUserClient.getUserById(chargingOrder.getAppUserId()).getData(); |
| | | //// Integer num1 = JSON.parseObject(integralRule.getChargeCredit()).getInteger("num1"); |
| | | //// Integer integral = chargingOrder.getServiceCharge().intValue() * num1; |
| | | //// if(null != appUser.getVipId()){ |
| | | //// TVip vip = vipClient.getInfo1(appUser.getVipId()).getData(); |
| | | //// Integer doubleIntegration = vip.getDoubleIntegration(); |
| | | //// //双倍积分 |
| | | //// if(1 == doubleIntegration){ |
| | | //// integral *= 2; |
| | | //// } |
| | | //// } |
| | | //// |
| | | //// if(integral > 0){ |
| | | //// TAppUserIntegralChange appUserIntegralChange = new TAppUserIntegralChange(); |
| | | //// appUserIntegralChange.setAppUserId(appUser.getId()); |
| | | //// appUserIntegralChange.setChangeType(2); |
| | | //// appUserIntegralChange.setHistoricalIntegral(appUser.getPoints()); |
| | | //// appUser.setPoints(appUser.getPoints() + integral); |
| | | //// appUserIntegralChange.setCurrentIntegral(appUser.getPoints()); |
| | | //// appUserIntegralChange.setCreateTime(LocalDateTime.now()); |
| | | //// appUserIntegralChange.setOrderCode(chargingOrder.getCode()); |
| | | //// appUserIntegralChange.setExtension(chargingOrder.getId().toString()); |
| | | //// appUserClient.updateAppUser(appUser); |
| | | //// appUserIntegralChangeClient.addAppUserIntegralChange(appUserIntegralChange); |
| | | //// } |
| | | //// } |
| | | //// |
| | | //// //计算用户标签 |
| | | //// editUserTag(chargingOrder); |
| | | //// //用户推荐奖励 |
| | | //// referralReward(chargingOrder); |
| | | //// |
| | | //// //开始构建退款费用 |
| | | //// if(refundAmount.compareTo(BigDecimal.ZERO) > 0){ |
| | | //// Integer rechargePaymentType = chargingOrder.getRechargePaymentType(); |
| | | //// //构建退款明细 |
| | | //// TChargingOrderRefund chargingOrderRefund = new TChargingOrderRefund(); |
| | | //// chargingOrderRefund.setChargingOrderId(chargingOrder.getId()); |
| | | //// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | //// chargingOrderRefund.setRefundCode("CDF" + sdf.format(new Date()) + (Double.valueOf(Math.random() * 1000).intValue())); |
| | | //// chargingOrderRefund.setRefundAmount(refundAmount); |
| | | //// chargingOrderRefund.setRefundStatus(1); |
| | | //// chargingOrderRefund.setPayType(rechargePaymentType); |
| | | //// chargingOrderRefund.setRefundStatus(1); |
| | | //// chargingOrderRefund.setCode(chargingOrder.getCode()); |
| | | //// chargingOrderRefund.setRefundTitle("充电完成退款"); |
| | | //// chargingOrderRefund.setRefundContent("充电完成退款"); |
| | | //// chargingOrderRefund.setRefundReason("充电完成退款"); |
| | | //// chargingOrderRefund.setRefundRemark("实际充电消费金额:" + chargingOrder.getPaymentAmount()); |
| | | //// chargingOrderRefund.setRefundTotalAmount(refundAmount); |
| | | //// 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("/payment/wx/refund/notify"); |
| | | //// WxPaymentRefundModel.RefundAmount amount = new WxPaymentRefundModel.RefundAmount(); |
| | | //// amount.setRefund(refundAmount.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(refundAmount.toString()); |
| | | //// dto.setRefundReason("充电完成退款"); |
| | | //// RefundResp resp = aliPaymentClient.refund(dto).getData(); |
| | | //// if(null != resp){ |
| | | //// AjaxResult success = chargingOrderStartupFailureWxRefund(resp.getOutTradeNo(), resp.getTradeNo(), "SUCCESS", null); |
| | | //// if(success.isSuccess()){ |
| | | //// chargingOrderRefundService.save(chargingOrderRefund); |
| | | //// } |
| | | //// } |
| | | //// } |
| | | //// |
| | | //// } |
| | | // } |
| | | |
| | | |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getByDate(List<Long> chargingOrderIds) { |
| | | return this.baseMapper.getByDate(chargingOrderIds); |
| | | public List<Map<String, Object>> getByDate(LocalDate start,LocalDate end,List<Integer> siteIds) { |
| | | |
| | | LocalDateTime start1 = start.atStartOfDay(); |
| | | LocalDateTime end1 = end.atTime(LocalTime.MAX); |
| | | return this.baseMapper.getByDate(start1,end1,siteIds); |
| | | } |
| | | |
| | | @Override |
| | |
| | | return this.baseMapper.queryPowerLevel(siteIds,statisticsQueryDto); |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> queryOrderCountAndMoneyBySiteIdDate(List<Integer> siteIds) { |
| | | return this.baseMapper.queryOrderCountAndMoneyBySiteIdDate(siteIds); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> usersDay(ChargingStatisticsQueryDto statisticsQueryDto) { |
| | |
| | | private TVipOrderService vipOrderService; |
| | | @Resource |
| | | private TVipOrderRefundService vipOrderRefundService; |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public R payRefund(PayOrderRefundDto payOrderQueryDto) { |
| | | if (payOrderQueryDto.getType()==1){ |
| | |
| | | amount.setTotal(tChargingOrder.getRechargeAmount().multiply(new BigDecimal(100)).intValue()); |
| | | amount.setCurrency("CNY"); |
| | | model.setAmount(amount); |
| | | R<String> orderR = wxPaymentClient.refundOrderR(model); |
| | | R<Map<String, Object>> orderR = wxPaymentClient.refundOrderR(model); |
| | | if(200 == orderR.getCode()){ |
| | | tChargingOrder.setRefundStatus(2); |
| | | tChargingOrder.setRefundAmount((tChargingOrder.getRefundAmount()==null? BigDecimal.valueOf(0) :tChargingOrder.getRefundAmount()).add(payOrderQueryDto.getRefundAmount())); |
| | | this.baseMapper.updateById(tChargingOrder); |
| | | chargingOrderRefundService.save(chargingOrderRefund); |
| | | //手续费 |
| | | Map<String, Object> amount1 = (Map<String, Object>) orderR.getData().get("amount"); |
| | | Object refund_fee1 = amount1.get("refund_fee"); |
| | | BigDecimal refund_fee = new BigDecimal(null == refund_fee1 ? "0" : refund_fee1.toString()).divide(new BigDecimal(100)); |
| | | chargingOrderRefund.setRefundFee(refund_fee); |
| | | chargingOrderRefundService.updateById(chargingOrderRefund); |
| | | } |
| | | } |
| | | |
| | |
| | | dto.setRefundReason("取消订单"); |
| | | RefundResp resp = aliPaymentClient.refund(dto).getData(); |
| | | if(null != resp){ |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-DDTHH:mm:ss+TIMEZONE"); |
| | | chargingOrderRefund.setRefundStatus(2); |
| | | chargingOrderRefund.setRefundAmount((tChargingOrder.getRefundAmount()==null? BigDecimal.valueOf(0) :tChargingOrder.getRefundAmount()).add(payOrderQueryDto.getRefundAmount())); |
| | | this.baseMapper.updateById(tChargingOrder); |
| | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | if (payOrderQueryDto.getType()==2){ |
| | | TShoppingOrder tChargingOrder = shoppingOrderService.getById(payOrderQueryDto.getOrderId()); |
| | |
| | | amount.setTotal(tChargingOrder.getPaymentAmount().multiply(new BigDecimal(100)).intValue()); |
| | | amount.setCurrency("CNY"); |
| | | model.setAmount(amount); |
| | | R<String> orderR = wxPaymentClient.refundOrderR(model); |
| | | R<Map<String, Object>> orderR = wxPaymentClient.refundOrderR(model); |
| | | if(200 == orderR.getCode()){ |
| | | tChargingOrder.setRefundStatus(2); |
| | | tChargingOrder.setRefundAmount((tChargingOrder.getRefundAmount()==null? BigDecimal.valueOf(0) :tChargingOrder.getRefundAmount()).add(payOrderQueryDto.getRefundAmount())); |
| | | shoppingOrderService.updateById(tChargingOrder); |
| | | shoppingOrderRefundService.save(chargingOrderRefund); |
| | | //手续费 |
| | | Map<String, Object> amount1 = (Map<String, Object>) orderR.getData().get("amount"); |
| | | Object refund_fee1 = amount1.get("refund_fee"); |
| | | BigDecimal refund_fee = new BigDecimal(null == refund_fee1 ? "0" : refund_fee1.toString()).divide(new BigDecimal(100)); |
| | | chargingOrderRefund.setRefundFee(refund_fee); |
| | | shoppingOrderRefundService.updateById(chargingOrderRefund); |
| | | } |
| | | } |
| | | |
| | |
| | | dto.setRefundReason("取消订单"); |
| | | RefundResp resp = aliPaymentClient.refund(dto).getData(); |
| | | if(null != resp){ |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-DDTHH:mm:ss+TIMEZONE"); |
| | | |
| | | tChargingOrder.setRefundStatus(2); |
| | | tChargingOrder.setRefundAmount((tChargingOrder.getRefundAmount()==null? BigDecimal.valueOf(0) :tChargingOrder.getRefundAmount()).add(payOrderQueryDto.getRefundAmount())); |
| | | |
| | | |
| | | shoppingOrderService.updateById(tChargingOrder); |
| | | |
| | | shoppingOrderRefundService.save(chargingOrderRefund); |
| | | |
| | | } |
| | | } |
| | | |
| | |
| | | if (tChargingOrder.getPaymentAmount().compareTo(payOrderQueryDto.getRefundAmount())==-1){ |
| | | return R.fail("退款金额需小于支付金额"); |
| | | } |
| | | |
| | | |
| | | TVipOrderRefund chargingOrderRefund = new TVipOrderRefund(); |
| | | chargingOrderRefund.setVipOrderId(tChargingOrder.getId()); |
| | | chargingOrderRefund.setRefundAmount(payOrderQueryDto.getRefundAmount()); |
| | |
| | | amount.setTotal(tChargingOrder.getPaymentAmount().multiply(new BigDecimal(100)).intValue()); |
| | | amount.setCurrency("CNY"); |
| | | model.setAmount(amount); |
| | | R<String> orderR = wxPaymentClient.refundOrderR(model); |
| | | R<Map<String, Object>> orderR = wxPaymentClient.refundOrderR(model); |
| | | if(200 == orderR.getCode()){ |
| | | tChargingOrder.setRefundStatus(2); |
| | | tChargingOrder.setRefundAmount((tChargingOrder.getRefundAmount()==null? BigDecimal.valueOf(0) :tChargingOrder.getRefundAmount()).add(payOrderQueryDto.getRefundAmount())); |
| | | vipOrderService.updateById(tChargingOrder); |
| | | vipOrderRefundService.save(chargingOrderRefund); |
| | | //手续费 |
| | | Map<String, Object> amount1 = (Map<String, Object>) orderR.getData().get("amount"); |
| | | Object refund_fee1 = amount1.get("refund_fee"); |
| | | BigDecimal refund_fee = new BigDecimal(null == refund_fee1 ? "0" : refund_fee1.toString()).divide(new BigDecimal(100)); |
| | | chargingOrderRefund.setRefundFee(refund_fee); |
| | | vipOrderRefundService.updateById(chargingOrderRefund); |
| | | } |
| | | } |
| | | |
| | |
| | | dto.setRefundReason("取消订单"); |
| | | RefundResp resp = aliPaymentClient.refund(dto).getData(); |
| | | if(null != resp){ |
| | | SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-DDTHH:mm:ss+TIMEZONE"); |
| | | |
| | | tChargingOrder.setRefundStatus(2); |
| | | tChargingOrder.setRefundAmount((tChargingOrder.getRefundAmount()==null? BigDecimal.valueOf(0) :tChargingOrder.getRefundAmount()).add(payOrderQueryDto.getRefundAmount())); |
| | | |
| | | |
| | | vipOrderService.updateById(tChargingOrder); |
| | | |
| | | vipOrderRefundService.save(chargingOrderRefund); |
| | | |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public TSettlementConfirm settlementAdd(SettlementConfirmAdd dto) { |
| | | List<Site> data = siteClient.getSiteByIds(Arrays.asList(dto.getSiteId())).getData(); |
| | | List<TChargingOrderAccountingStrategy> list3 = chargingOrderAccountingStrategyService.list(); |
| | | |
| | | TSettlementConfirm tSettlementConfirm = new TSettlementConfirm(); |
| | | if (!data.isEmpty()){ |
| | | tSettlementConfirm.setSiteName(data.get(0).getName()); |
| | |
| | | |
| | | // 根据站点id和开始时间和结束时间和归属日期 查询充电订单列表 |
| | | QueryWrapper<TChargingOrder> eq = new QueryWrapper<TChargingOrder>() |
| | | .eq("site_id", dto.getSiteId()) |
| | | .eq("status", 5) |
| | | .eq("recharge_payment_status",2); |
| | | .eq("site_id", dto.getSiteId()); |
| | | switch (dto.getType()){ |
| | | case 1: |
| | | eq.between("pay_time", localDateTime, localDateTime1); |
| | |
| | | // 支付订单金额 需要减去退款金额 |
| | | BigDecimal paymentAmount = new BigDecimal("0"); |
| | | for (TChargingOrder tChargingOrder : tChargingOrders) { |
| | | // 累加充电总度数 |
| | | if (tChargingOrder.getChargingCapacity()!=null){ |
| | | chargingElectronic = chargingElectronic.add(tChargingOrder.getChargingCapacity()); |
| | | |
| | | if(null == tChargingOrder.getStatus() || 5 != tChargingOrder.getStatus()){ |
| | | continue; |
| | | } |
| | | 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); |
| | | BigDecimal service_reduce = list4.stream().map(TChargingOrderAccountingStrategy::getPeriodServicePrice).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal chargingCapacity = list4.stream().map(TChargingOrderAccountingStrategy::getChargingCapacity).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // 累加充电总度数 |
| | | chargingElectronic = chargingElectronic.add(chargingCapacity); |
| | | // 累加分佣 |
| | | if (tChargingOrder.getSharingAmount()!=null) { |
| | | sharingAmount = sharingAmount.add(tChargingOrder.getSharingAmount()); |
| | | if (tChargingOrder.getOrderSource()==2) { |
| | | sharingAmount = sharingAmount.add(service_reduce.multiply(new BigDecimal("0.2")).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | } |
| | | // 累加电费 |
| | | if (tChargingOrder.getElectrovalence()!=null) { |
| | | electrovalence = electrovalence.add(tChargingOrder.getElectrovalence()); |
| | | electrovalence = electrovalence.add(electronic_reduce); |
| | | if (tChargingOrder.getPaymentAmount()!=null && tChargingOrder.getOrderSource()!=2){ |
| | | paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount()); |
| | | |
| | | } |
| | | if (tChargingOrder.getRechargeAmount()!=null){ |
| | | orderCommission = orderCommission.add(tChargingOrder.getRechargeAmount().multiply(new BigDecimal("0.006")) |
| | | .setScale(2,BigDecimal.ROUND_DOWN)); |
| | | } |
| | | |
| | | // 累加服务费 |
| | | if (tChargingOrder.getServiceCharge()!=null){ |
| | | serviceCharge = serviceCharge.add(tChargingOrder.getServiceCharge()); |
| | | |
| | | if (tChargingOrder.getOrderSource()==2) { |
| | | serviceCharge = serviceCharge.add(service_reduce.multiply(new BigDecimal("0.8")).setScale(2,BigDecimal.ROUND_DOWN)); |
| | | paymentAmount = paymentAmount.add(electronic_reduce).add(service_reduce.multiply(new BigDecimal("0.8"))); |
| | | }else{ |
| | | serviceCharge = serviceCharge.add(service_reduce); |
| | | } |
| | | } |
| | | // 累加会员折扣 |
| | | if (tChargingOrder.getVipDiscountAmount()!=null){ |
| | |
| | | if (tChargingOrder.getCouponDiscountAmount()!=null){ |
| | | couponDiscount = couponDiscount.add(tChargingOrder.getCouponDiscountAmount()); |
| | | } |
| | | if (tChargingOrder.getPaymentAmount()!=null){ |
| | | paymentAmount = paymentAmount.add(tChargingOrder.getPaymentAmount()); |
| | | orderCommission = orderCommission.add(tChargingOrder.getPaymentAmount().multiply(new BigDecimal("0.006")) |
| | | .setScale(2,BigDecimal.ROUND_DOWN)); |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | return pageInfo; |
| | | } |
| | | |
| | | @Autowired |
| | | private TChargingOrderService chargingOrderService; |
| | | @Override |
| | | public SettlementTotalVO settlementTotal(String time) { |
| | | Long userId = tokenService.getLoginUser().getUserid(); |
| | |
| | | if (siteIds.isEmpty()){ |
| | | siteIds.add(-1); |
| | | } |
| | | List<Site> siteList = siteClient.getSiteAll().getData(); |
| | | List<TChargingPile> pileList = chargingGunClient.getAllPile().getData(); |
| | | List<TChargingOrder> totalOrder = chargingOrderService.list(new LambdaQueryWrapper<>(TChargingOrder.class) |
| | | .eq(TChargingOrder::getRechargePaymentStatus, 2).eq(TChargingOrder::getStatus, 5)); |
| | | SettlementTotalVO res = new SettlementTotalVO(); |
| | | List<TSettlementConfirm> list1 = tSettlementConfirmMapper.settlementTotal(time,siteIds); |
| | | LocalDateTime parse = LocalDateTime.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | |
| | | 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"); |
| | |
| | | for (TSettlementConfirm tSettlementConfirm : list1) { |
| | | tSettlementConfirm.setXuhao(i); |
| | | tSettlementConfirm.setMetering(tSettlementConfirm.getSupplyElectronic()); |
| | | List<Site> data1 = siteClient.getSiteByIds(Arrays.asList(tSettlementConfirm.getSiteId())).getData(); |
| | | if (!data1.isEmpty()){ |
| | | tSettlementConfirm.setSiteName(data1.get(0).getName()); |
| | | Site site = siteList.stream().filter(e -> e.getId().equals(tSettlementConfirm.getSiteId())).findFirst().orElse(null); |
| | | if (site!=null){ |
| | | tSettlementConfirm.setSiteName(site.getName()); |
| | | } |
| | | if (tSettlementConfirm.getMeteringElectronic()!=null){ |
| | | meteringElectronic = meteringElectronic.add(tSettlementConfirm.getMeteringElectronic()); |
| | |
| | | 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(","); |
| | | |
| | | } |
| | | List<TChargingOrder> tChargingOrders = totalOrder.stream().filter(e-> e.getPayTime() |
| | | .isBefore(tSettlementConfirm.getEndTime()) |
| | | && e.getPayTime().isAfter(tSettlementConfirm.getStartTime())&&e.getSiteId().equals(tSettlementConfirm.getSiteId())).collect(Collectors.toList()); |
| | | // 充电总时长 |
| | | |
| | | Long temp = 1L; |
| | | if (StringUtils.hasLength(stringBuilder.toString())){ |
| | | String substring = stringBuilder.substring(0, stringBuilder.length() - 1); |
| | | for (String s : substring.split(",")) { |
| | | UploadRealTimeMonitoringData data6 = uploadRealTimeMonitoringDataClient.chargingOrderInfo(s).getData(); |
| | | if (data6!=null){ |
| | | temp+=(data6.getCumulative_charging_time()*60); |
| | | |
| | | } |
| | | |
| | | } |
| | | Long temp = 0L; |
| | | for (TChargingOrder tChargingOrder : tChargingOrders) { |
| | | LocalDateTime startTime = tChargingOrder.getStartTime(); |
| | | LocalDateTime endTime = tChargingOrder.getEndTime(); |
| | | // 计算时间差 单位秒 |
| | | long between = ChronoUnit.SECONDS.between(startTime, endTime); |
| | | temp+=between; |
| | | } |
| | | List<TChargingPile> data = siteClient.getPileListBySiteId(tSettlementConfirm.getSiteId()).getData(); |
| | | // 计算充电桩的功率平均值 |
| | |
| | | bigDecimal = bigDecimal.add(datum.getRatedPower()); |
| | | } |
| | | |
| | | |
| | | tSettlementConfirm.setIncome(tSettlementConfirm.getElectrovalence().add(tSettlementConfirm.getServiceCharge())); |
| | | //利用率=充电量/(桩数量*功率*时间) |
| | | List<TChargingPile> data2 = chargingPileClient.getChargingPileBySiteId(tSettlementConfirm.getSiteId()).getData(); |
| | | List<TChargingPile> data2 = pileList.stream().filter(e -> e.getSiteId().equals(tSettlementConfirm.getSiteId())).collect(Collectors.toList()); |
| | | BigDecimal bigDecimal2 = new BigDecimal("0"); |
| | | |
| | | if (data2!=null && (!data2.isEmpty())){ |
| | |
| | | BigDecimal subtract = income.subtract(beforeIncome).divide(beforeIncome,2,RoundingMode.HALF_DOWN).multiply(new BigDecimal("100")); |
| | | tSettlementConfirm.setIncomePercentage(subtract+"%"); |
| | | tSettlementConfirm.setIncomePercentage(subtract+"%"); |
| | | |
| | | } |
| | | // 比较总利润 收入合计-成本合计 |
| | | BigDecimal subtract1 = income.subtract(cost); |
| | |
| | | if (siteIds.isEmpty()){ |
| | | siteIds.add(-1); |
| | | } |
| | | List<Site> siteList = siteClient.getSiteAll().getData(); |
| | | List<TChargingGun> gunList = chargingGunClient.getAllGun().getData(); |
| | | List<TChargingPile> pileList = chargingGunClient.getAllPile().getData(); |
| | | List<TAppUser> userList = appUserClient.getAllUser().getData(); |
| | | List<TAppUserCar> carList = appUserCarClient.getAllCar().getData(); |
| | | List<TChargingOrder> totalOrder = chargingOrderService.list(new LambdaQueryWrapper<>(TChargingOrder.class) |
| | | .eq(TChargingOrder::getRechargePaymentStatus, 2)); |
| | | SettlementTotalVO res = new SettlementTotalVO(); |
| | | List<TSettlementConfirm> list1 = tSettlementConfirmMapper.settlementTotal(time,siteIds); |
| | | LocalDateTime parse = LocalDateTime.parse(time, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); |
| | | // 减少一个月 |
| | | LocalDateTime minus = parse.minusMonths(1); |
| | | List<TSettlementConfirm> list2 = tSettlementConfirmMapper.settlementTotal(time,siteIds); |
| | | // 合计 |
| | | List<TSettlementConfirm> total = new ArrayList<>(); |
| | |
| | | for (TSettlementConfirm tSettlementConfirm : list1) { |
| | | tSettlementConfirm.setXuhao(i); |
| | | tSettlementConfirm.setMetering(tSettlementConfirm.getSupplyElectronic()); |
| | | List<Site> data1 = siteClient.getSiteByIds(Arrays.asList(tSettlementConfirm.getSiteId())).getData(); |
| | | List<Site> data1 = siteList.stream().filter(e -> e.getId().equals(tSettlementConfirm.getSiteId())).collect(Collectors.toList()); |
| | | if (!data1.isEmpty()){ |
| | | tSettlementConfirm.setSiteName(data1.get(0).getName()); |
| | | } |
| | |
| | | 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(","); |
| | | |
| | | } |
| | | List<TChargingOrder> tChargingOrders = totalOrder.stream().filter(e-> e.getPayTime() |
| | | .isBefore(tSettlementConfirm.getEndTime()) |
| | | && e.getPayTime().isAfter(tSettlementConfirm.getStartTime())&&e.getSiteId().equals(tSettlementConfirm.getSiteId())).collect(Collectors.toList()); |
| | | // 充电总时长 |
| | | |
| | | Long temp = 1L; |
| | | if (StringUtils.hasLength(stringBuilder.toString())){ |
| | | String substring = stringBuilder.substring(0, stringBuilder.length() - 1); |
| | | for (String s : substring.split(",")) { |
| | | UploadRealTimeMonitoringData data6 = uploadRealTimeMonitoringDataClient.chargingOrderInfo(s).getData(); |
| | | if (data6!=null){ |
| | | temp+=(data6.getCumulative_charging_time()*60); |
| | | |
| | | } |
| | | |
| | | } |
| | | Long temp = 0L; |
| | | for (TChargingOrder tChargingOrder : tChargingOrders) { |
| | | LocalDateTime startTime = tChargingOrder.getStartTime(); |
| | | LocalDateTime endTime = tChargingOrder.getEndTime(); |
| | | // 计算时间差 单位秒 |
| | | long between = ChronoUnit.SECONDS.between(startTime, endTime); |
| | | temp+=between; |
| | | } |
| | | List<TChargingPile> data = siteClient.getPileListBySiteId(tSettlementConfirm.getSiteId()).getData(); |
| | | // 计算充电桩的功率平均值 |
| | |
| | | chargingOrder.setStatus(2); |
| | | chargingOrder.setPayTime(LocalDateTime.now()); |
| | | chargingOrder.setChargeAmount(chargingOrder.getRechargeAmount()); |
| | | chargingOrder.setVipDiscountAmount(BigDecimal.ZERO); |
| | | this.save(chargingOrder); |
| | | |
| | | Integer accountingStrategyId = tChargingGun.getAccountingStrategyId(); |
| | |
| | | platformStartCharging.setAccount_balance(rechargeAmount); |
| | | log.info(chargingOrder.getCode() + ":-------------------远程调起开始充电请求-------------------" + platformStartCharging.toString()); |
| | | sendMessageClient.platformStartCharging(platformStartCharging); |
| | | //异步线程检测远程启动的应答结果。如果失败,则需要全额退款 |
| | | Long id = chargingOrder.getId(); |
| | | //执行5分钟的定时任务检测 |
| | | ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); |
| | | scheduler.scheduleAtFixedRate(()->{ |
| | | if(timingDetection(id)){ |
| | | scheduler.shutdown(); |
| | | } |
| | | }, 5, 1, TimeUnit.SECONDS); |
| | | // //异步线程检测远程启动的应答结果。如果失败,则需要全额退款 |
| | | // Long id = chargingOrder.getId(); |
| | | // //执行5分钟的定时任务检测 |
| | | // ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); |
| | | // scheduler.scheduleAtFixedRate(()->{ |
| | | // if(timingDetection(id)){ |
| | | // scheduler.shutdown(); |
| | | // } |
| | | // }, 5, 1, TimeUnit.SECONDS); |
| | | |
| | | //推送三方平台订单状态 |
| | | tcecClient.notificationEquipChargeStatus(chargingOrder.getStartChargeSeq(), chargingOrder.getOperatorId()); |
| | |
| | | }); |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取充电后没有扣除费用的数据 |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R getNotPaymentChargingOrder() { |
| | | List<TChargingOrder> list = this.list(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getPaymentAmount, 0) |
| | | .ne(TChargingOrder::getElectricity, 0).in(TChargingOrder::getStatus, Arrays.asList(4, 5))); |
| | | List<Map<String, Object>> mapList = new ArrayList<>(); |
| | | for (TChargingOrder order : list) { |
| | | TransactionRecord transactionRecord = transactionRecordClient.findTransactionRecord(order.getCode()).getData(); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("order", order); |
| | | map.put("transactionRecord", transactionRecord); |
| | | mapList.add(map); |
| | | } |
| | | return R.ok(mapList); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * |
| | | * 手动推送订单给第三方平台 |
| | | * @param code |
| | | * @return |
| | | */ |
| | | @Override |
| | | public R pushOrderInfo(String code) { |
| | | TChargingOrder chargingOrder = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, code)); |
| | | tcecClient.notificationEquipChargeStatus(chargingOrder.getStartChargeSeq(), chargingOrder.getOperatorId()); |
| | | tcecClient.notificationStopChargeResult(chargingOrder.getStartChargeSeq(), chargingOrder.getChargingGunId().toString(), |
| | | chargingOrder.getOperatorId()); |
| | | tcecClient.notificationChargeOrderInfo(chargingOrder.getStartChargeSeq(), chargingOrder.getOperatorId()); |
| | | return R.ok(); |
| | | } |
| | | } |