| | |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | continue; |
| | | }else{ |
| | | log.error(code1 + ":-------------------远程停止充电请求成功-------------------"); |
| | | stop_status = true; |
| | | break; |
| | | } |
| | | break; |
| | | } |
| | | if(stop_status){ |
| | | chargingOrder.setStatus(5); |
| | |
| | | } |
| | | log.error(code1 + ":停机失败:订单号:{},失败原因:{}", order.getCode(), failure_cause); |
| | | }else{ |
| | | order.setEndTime(LocalDateTime.now()); |
| | | order.setStatus(5); |
| | | order.setEndMode(1); |
| | | this.updateById(order); |
| | | //计算用户标签 |
| | | editUserTag(order); |
| | | //用户推荐奖励 |
| | | referralReward(order); |
| | | // 将枪状态重置为空闲 |
| | | chargingGun.setStatus(2); |
| | | chargingGunClient.updateChargingGunById(chargingGun); |
| | | } |
| | | } |
| | | |
| | |
| | | if(chargingOrderAccountingStrategy.getAccountingStrategyDetailId().equals(strategyDetail.getId())){ |
| | | //已充电总度数 |
| | | BigDecimal charging_degree = query.getCharging_degree(); |
| | | BigDecimal electrovalenc = strategyDetail.getElectrovalence().multiply(charging_degree); |
| | | BigDecimal originalServicePrice = strategyDetail.getServiceCharge().multiply(charging_degree); |
| | | BigDecimal chargingCapacity = chargingOrderAccountingStrategy.getChargingCapacity(); |
| | | //计算本阶段充电度数 |
| | | BigDecimal subtract = charging_degree.subtract(chargingCapacity); |
| | | //计算本阶段费用 |
| | | BigDecimal electrovalenc = strategyDetail.getElectrovalence().multiply(subtract); |
| | | BigDecimal originalServicePrice = strategyDetail.getServiceCharge().multiply(subtract); |
| | | BigDecimal serviceCharge = originalServicePrice; |
| | | //计算优惠金额 |
| | | if(null != chargingOrder.getVipDiscount()){ |
| | | serviceCharge = serviceCharge.multiply(chargingOrder.getVipDiscount().divide(new BigDecimal(10))); |
| | | } |
| | | //将本阶段的费用增加到总费用中 |
| | | electrovalenc = electrovalenc.add(chargingOrderAccountingStrategy.getPeriodElectricPrice()); |
| | | originalServicePrice = originalServicePrice.add(chargingOrderAccountingStrategy.getPeriodOriginalServicePrice()); |
| | | serviceCharge = serviceCharge.add(chargingOrderAccountingStrategy.getPeriodServicePrice()); |
| | | chargingOrderAccountingStrategy.setChargingCapacity(charging_degree); |
| | | chargingOrderAccountingStrategy.setPeriodElectricPrice(electrovalenc); |
| | | chargingOrderAccountingStrategy.setPeriodServicePrice(serviceCharge); |
| | |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | public void endCharge(String orderCode, Integer endMode) { |
| | | TChargingOrder chargingOrder = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, orderCode)); |
| | | Integer status = chargingOrder.getStatus(); |
| | | if(status == 4 || status == 5){ |
| | | return; |
| | | } |
| | | chargingOrder.setStatus(5); |
| | | chargingOrder.setEndMode(endMode); |
| | | chargingOrder.setEndTime(LocalDateTime.now()); |
| | | this.updateById(chargingOrder); |
| | | // 将枪状态重置为空闲 |
| | | TChargingGun chargingGun = chargingGunClient.getChargingGunById(chargingOrder.getChargingGunId()).getData(); |
| | | chargingGun.setStatus(2); |
| | | chargingGunClient.updateChargingGunById(chargingGun); |
| | | |
| | | //计算用户标签 |
| | | editUserTag(chargingOrder); |
| | | //用户推荐奖励 |
| | | referralReward(chargingOrder); |
| | | } |
| | | |
| | | /** |
| | |
| | | @Override |
| | | @GlobalTransactional(rollbackFor = Exception.class) |
| | | public void endChargeBillingCharge(TransactionRecordMessageVO vo) { |
| | | TChargingOrder chargingOrder = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, vo.getTransaction_serial_number())); |
| | | Integer status = chargingOrder.getStatus(); |
| | | if(status == 4 || status == 5){ |
| | | return; |
| | | } |
| | | |
| | | //计算用户标签 |
| | | editUserTag(chargingOrder); |
| | | //用户推荐奖励 |
| | | referralReward(chargingOrder); |
| | | |
| | | //如果使用优惠券需要判断优惠券是否满足使用条件 |
| | | //根据实际的充电金额计算退款金额 退回费用=(原金额/总金额)*(总金额-实际充电金额) |
| | | //退款金额=优惠券金额+剩余充电金额 |
| | | TChargingOrder chargingOrder = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getCode, vo.getTransaction_serial_number())); |
| | | List<TChargingOrderAccountingStrategy> list = chargingOrderAccountingStrategyService.list(new LambdaQueryWrapper<TChargingOrderAccountingStrategy>().eq(TChargingOrderAccountingStrategy::getChargingOrderId, chargingOrder.getId())); |
| | | BigDecimal periodElectricPrice_total = BigDecimal.ZERO; |
| | | BigDecimal periodServicePrice_total = BigDecimal.ZERO; |
| | |
| | | if(chargingOrder.getEndMode() == 2){ |
| | | chargingOrder.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.getAppCouponId()){ |
| | |
| | | chargingOrder.setPaymentAmount(payAmount); |
| | | this.updateById(chargingOrder); |
| | | |
| | | // 将枪状态重置为空闲 |
| | | TChargingGun chargingGun = chargingGunClient.getChargingGunById(chargingOrder.getChargingGunId()).getData(); |
| | | chargingGun.setStatus(2); |
| | | chargingGunClient.updateChargingGunById(chargingGun); |
| | | |
| | | //添加积分 |
| | | TIntegralRule integralRule = integralRuleClient.getSet().getData(); |
| | | if(null != integralRule){ |