| | |
| | | chargingOrder.setAppUserId(userId); |
| | | chargingOrder.setAppUserCarId(addChargingOrder.getAppUserCarId()); |
| | | TChargingGun tChargingGun = chargingGunClient.getChargingGunById(addChargingOrder.getId()).getData(); |
| | | TChargingPile chargingPile = chargingPileClient.getChargingPileById(tChargingGun.getChargingPileId()).getData(); |
| | | chargingOrder.setSiteId(tChargingGun.getSiteId()); |
| | | chargingOrder.setChargingPileId(tChargingGun.getChargingPileId()); |
| | | chargingOrder.setChargingGunId(addChargingOrder.getId()); |
| | |
| | | chargingOrder.setAppCouponId(addChargingOrder.getAppUserCouponId()); |
| | | chargingOrder.setVipDiscount(new BigDecimal(10)); |
| | | chargingOrder.setVipDiscountAmount(BigDecimal.ZERO); |
| | | chargingOrder.setOrderSource(0); |
| | | chargingOrder.setTitle("【充电桩充电】" + chargingPile.getNumber() + "号桩/" + tChargingGun.getCode() + "号枪"); |
| | | |
| | | Site site = siteClient.getSiteByIds(Arrays.asList(tChargingGun.getSiteId())).getData().get(0); |
| | | Integer accountingStrategyId = tChargingGun.getAccountingStrategyId(); |
| | |
| | | return AjaxResult.error("不能重复操作"); |
| | | } |
| | | chargingOrder.setEndTime(LocalDateTime.now()); |
| | | chargingOrder.setStatus(4); |
| | | chargingOrder.setEndMode(1); |
| | | this.updateById(chargingOrder); |
| | | |
| | |
| | | for (int i = 0; i < 60; i++) { |
| | | TChargingOrder chargingOrder1 = this.getById(id); |
| | | if(chargingOrder1.getStatus() != 3){ |
| | | stop_status = true; |
| | | break; |
| | | } |
| | | GetPlatformStopChargingReply query = new GetPlatformStopChargingReply(); |
| | |
| | | } |
| | | } |
| | | if(stop_status){ |
| | | chargingOrder.setStatus(5); |
| | | chargingOrder.setEndMode(1); |
| | | this.updateById(chargingOrder); |
| | | |
| | | //计算用户标签 |
| | | editUserTag(chargingOrder); |
| | | //用户推荐奖励 |
| | | referralReward(chargingOrder); |
| | | // 将枪状态重置为空闲 |
| | | chargingGun.setStatus(2); |
| | | chargingGunClient.updateChargingGunById(chargingGun); |
| | | }else{ |
| | | log.error(code1 + ":-------------------远程停止充电应答最终失败-------------------"); |
| | | } |
| | |
| | | } |
| | | log.error(code1 + ":停机失败:订单号:{},失败原因:{}", order.getCode(), failure_cause); |
| | | }else{ |
| | | order.setEndMode(1); |
| | | this.updateById(order); |
| | | TChargingOrder chargingOrder = new TChargingOrder(); |
| | | chargingOrder.setId(order.getId()); |
| | | chargingOrder.setAppUserId(order.getAppUserId()); |
| | | chargingOrder.setEndMode(1); |
| | | this.updateById(chargingOrder); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | BigDecimal residualAmount = chargingOrder.getRechargeAmount().subtract(t).setScale(4, RoundingMode.HALF_EVEN); |
| | | chargingOrder.setResidualAmount(residualAmount); |
| | | BigDecimal divide = query.getOutput_current().multiply(query.getOutput_voltage()).divide(new BigDecimal(1000)); |
| | | chargingOrder.setChargingPower(divide); |
| | | if(query.getOutput_current().compareTo(BigDecimal.ZERO) != 0){ |
| | | BigDecimal divide = query.getOutput_current().multiply(query.getOutput_voltage()).divide(new BigDecimal(1000)); |
| | | chargingOrder.setChargingPower(divide); |
| | | chargingOrder.setCurrent(query.getOutput_current()); |
| | | chargingOrder.setVoltage(query.getOutput_voltage()); |
| | | chargingOrder.setPower(query.getOutput_current().multiply(query.getOutput_voltage())); |
| | | chargingOrder.setNeedElec(query.getOutput_current()); |
| | | } |
| | | chargingOrder.setElectricity(query.getCharging_degree()); |
| | | chargingOrder.setTotalElectricity(new BigDecimal(100 - query.getSoc())); |
| | | this.updateById(chargingOrder); |
| | | } |
| | | } |
| | |
| | | @Override |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | public void endCharge(String orderCode, Integer endMode) { |
| | | TChargingOrder chargingOrder = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, orderCode)); |
| | | TChargingOrder order = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, orderCode)); |
| | | TChargingOrder chargingOrder = new TChargingOrder(); |
| | | chargingOrder.setId(order.getId()); |
| | | chargingOrder.setAppUserId(order.getAppUserId()); |
| | | chargingOrder.setEndMode(endMode); |
| | | this.updateById(chargingOrder); |
| | | } |
| | |
| | | Integer status = chargingOrder.getStatus(); |
| | | if(status == 4 || status == 5){ |
| | | return; |
| | | } |
| | | |
| | | //先判断总的充电度数是否和总报文消息中的数据相同,不相同等待30s |
| | | UploadRealTimeMonitoringData uploadRealTimeMonitoringData = uploadRealTimeMonitoringDataClient.chargingOrderInfo(chargingOrder.getCode()).getData(); |
| | | if(null != uploadRealTimeMonitoringData){ |
| | | for (int i = 0; i < 30; i++) { |
| | | List<TChargingOrderAccountingStrategy> list1 = chargingOrderAccountingStrategyService.list(new LambdaQueryWrapper<TChargingOrderAccountingStrategy>().eq(TChargingOrderAccountingStrategy::getChargingOrderId, chargingOrder.getId())); |
| | | BigDecimal reduce = list1.stream().map(TChargingOrderAccountingStrategy::getChargingCapacity).reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | BigDecimal charging_degree = uploadRealTimeMonitoringData.getCharging_degree(); |
| | | if(charging_degree.compareTo(reduce) != 0){ |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | }else{ |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | //计算用户标签 |
| | |
| | | payAmount = payAmount.subtract(discountAmount); |
| | | } |
| | | |
| | | if(chargingOrder.getEndMode() == 2){ |
| | | chargingOrder.setEndMode(refundAmount.compareTo(BigDecimal.ZERO) > 0 ? 2 : 3); |
| | | TChargingOrder order = new TChargingOrder(); |
| | | order.setId(chargingOrder.getId()); |
| | | order.setAppUserId(chargingOrder.getAppUserId()); |
| | | if(null != chargingOrder.getEndMode() && chargingOrder.getEndMode() == 2){ |
| | | order.setEndMode(refundAmount.compareTo(BigDecimal.ZERO) > 0 ? 2 : 3); |
| | | } |
| | | chargingOrder.setEndTime(LocalDateTime.now()); |
| | | chargingOrder.setStatus(5); |
| | | chargingOrder.setOrderAmount(orderAmount); |
| | | chargingOrder.setVipDiscountAmount(discountAmount); |
| | | chargingOrder.setServiceCharge(periodServicePrice_total); |
| | | chargingOrder.setElectrovalence(periodElectricPrice_total); |
| | | if(null == chargingOrder.getEndMode()){ |
| | | order.setEndMode(1); |
| | | } |
| | | order.setEndTime(LocalDateTime.now()); |
| | | order.setStatus(5); |
| | | order.setOrderAmount(orderAmount); |
| | | order.setVipDiscountAmount(discountAmount); |
| | | order.setServiceCharge(periodServicePrice_total); |
| | | order.setElectrovalence(periodElectricPrice_total); |
| | | |
| | | //计算优惠券 |
| | | if(null != chargingOrder.getAppCouponId()){ |
| | |
| | | //满减 |
| | | if(payAmount.compareTo(tCoupon.getMeetTheConditions()) >= 0){ |
| | | refundAmount = refundAmount.add(tCoupon.getDiscountAmount()); |
| | | chargingOrder.setCouponDiscountAmount(tCoupon.getDiscountAmount()); |
| | | order.setCouponDiscountAmount(tCoupon.getDiscountAmount()); |
| | | payAmount = payAmount.subtract(tCoupon.getDiscountAmount()); |
| | | }else{ |
| | | chargingOrder.setAppCouponId(null); |
| | | chargingOrder.setCouponDiscountAmount(BigDecimal.ZERO); |
| | | order.setAppCouponId(null); |
| | | order.setCouponDiscountAmount(BigDecimal.ZERO); |
| | | appCouponClient.refund(chargingOrder.getAppCouponId().toString()); |
| | | } |
| | | } |
| | |
| | | BigDecimal divide = payAmount.multiply(new BigDecimal(10).subtract(tCoupon.getDiscount())).divide(new BigDecimal(10)); |
| | | divide = divide.compareTo(tCoupon.getMaximumDiscountAmount()) > 0 ? tCoupon.getMaximumDiscountAmount() : divide; |
| | | refundAmount = refundAmount.add(divide); |
| | | chargingOrder.setCouponDiscountAmount(divide); |
| | | order.setCouponDiscountAmount(divide); |
| | | payAmount = payAmount.subtract(divide); |
| | | }else{ |
| | | chargingOrder.setAppCouponId(null); |
| | | chargingOrder.setCouponDiscountAmount(BigDecimal.ZERO); |
| | | order.setAppCouponId(null); |
| | | order.setCouponDiscountAmount(BigDecimal.ZERO); |
| | | appCouponClient.refund(chargingOrder.getAppCouponId().toString()); |
| | | } |
| | | } |
| | | } |
| | | chargingOrder.setPaymentAmount(payAmount); |
| | | this.updateById(chargingOrder); |
| | | order.setPaymentAmount(payAmount); |
| | | order.setRefundAmount(refundAmount); |
| | | order.setRefundStatus(1); |
| | | this.updateById(order); |
| | | chargingOrder = this.getById(order.getId()); |
| | | |
| | | // 将枪状态重置为空闲 |
| | | TChargingGun chargingGun = chargingGunClient.getChargingGunById(chargingOrder.getChargingGunId()).getData(); |
| | |
| | | RefundReq dto = new RefundReq(); |
| | | dto.setOutTradeNo(chargingOrder.getCode()); |
| | | dto.setOutRequestNo(chargingOrderRefund.getCode()); |
| | | dto.setRefundAmount(rechargeAmount.toString()); |
| | | dto.setRefundAmount(refundAmount.toString()); |
| | | dto.setRefundReason("充电完成退款"); |
| | | RefundResp resp = aliPaymentClient.refund(dto).getData(); |
| | | if(null != resp){ |