| | |
| | | if(null != preChargeCheck1){ |
| | | preChargeCheck1.setElectronicLockLock(true); |
| | | preChargeCheck1.setInsulationTesting(true); |
| | | preChargeCheck1.setSecureConnectionDetection(preChargeCheck1.getSecureConnectionDetection()); |
| | | preChargeCheck1.setSecureConnectionDetection(securityDetection.getSecure_connection() == 1); |
| | | preChargeCheck1.setStartupSuccess(1); |
| | | redisService.setCacheObject("AQJC_" + chargingOrder.getChargingGunId(), preChargeCheck1, 24L, TimeUnit.HOURS); |
| | | } |
| | |
| | | if(null != preChargeCheck1){ |
| | | preChargeCheck1.setElectronicLockLock(true); |
| | | preChargeCheck1.setInsulationTesting(true); |
| | | preChargeCheck1.setSecureConnectionDetection(preChargeCheck1.getSecureConnectionDetection()); |
| | | preChargeCheck1.setStartupSuccess(1); |
| | | preChargeCheck1.setSecureConnectionDetection(securityDetection.getSecure_connection() == 1); |
| | | redisService.setCacheObject("AQJC_" + chargingGun.getId(), preChargeCheck1, 24L, TimeUnit.HOURS); |
| | | } |
| | | } |
| | |
| | | if(null != preChargeCheck1){ |
| | | preChargeCheck1.setElectronicLockLock(true); |
| | | preChargeCheck1.setInsulationTesting(true); |
| | | preChargeCheck1.setSecureConnectionDetection(preChargeCheck1.getSecureConnectionDetection()); |
| | | preChargeCheck1.setStartupSuccess(1); |
| | | } |
| | | if(0 == startup_result){ |
| | |
| | | public ChargingDetails getChargingDetails(Integer id) { |
| | | Long userId = tokenService.getLoginUserApplet().getUserId(); |
| | | TChargingOrder one = this.getOne(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getAppUserId, userId).eq(TChargingOrder::getChargingGunId, id) |
| | | .in(TChargingOrder::getStatus, Arrays.asList(1, 2, 3)).eq(TChargingOrder::getRechargePaymentStatus, 2).eq(TChargingOrder::getDelFlag, 0)); |
| | | .eq(TChargingOrder::getRechargePaymentStatus, 2).eq(TChargingOrder::getDelFlag, 0).orderByDesc(TChargingOrder::getEndTime).last(" limit 0, 1")); |
| | | if(null == one){ |
| | | return null; |
| | | } |
| | |
| | | chargingOrder.setStatus(4); |
| | | chargingOrder.setEndMode(1); |
| | | this.updateById(chargingOrder); |
| | | //计算用户标签 |
| | | editUserTag(chargingOrder); |
| | | //用户推荐奖励 |
| | | referralReward(chargingOrder); |
| | | //计算费用,处理退款 |
| | | endCharge(chargingOrder); |
| | | TChargingGun chargingGun = chargingGunClient.getChargingGunById(chargingOrder.getChargingGunId()).getData(); |
| | | // 将枪状态重置为空闲 |
| | | chargingGun.setStatus(2); |
| | | chargingGunClient.updateChargingGunById(chargingGun); |
| | | |
| | | String code1 = chargingOrder.getCode(); |
| | | |
| | | //异步线程处理停机 |
| | | ExecutorService cachedThreadPool = Executors.newFixedThreadPool(1); |
| | | cachedThreadPool.execute(()->{ |
| | | //调用硬件停止充电,停止成功后开始计算费用退款 |
| | | TChargingPile chargingPile = chargingPileClient.getChargingPileById(chargingOrder.getChargingPileId()).getData(); |
| | | PlatformStopCharging platformStopCharging = new PlatformStopCharging(); |
| | | platformStopCharging.setCharging_pile_code(chargingPile.getCode()); |
| | | platformStopCharging.setCharging_gun_code(chargingGun.getCode()); |
| | | sendMessageClient.platformStopCharging(platformStopCharging); |
| | | log.error(code1 + ":-------------------远程停止充电请求-------------------"); |
| | | log.error(platformStopCharging.toString()); |
| | | //开始查询停机应答,成功后开始计费费用 |
| | | for (int i = 0; i < 60; i++) { |
| | | TChargingOrder chargingOrder1 = this.getById(id); |
| | | if(chargingOrder1.getStatus() != 3){ |
| | | break; |
| | | } |
| | | GetPlatformStopChargingReply query = new GetPlatformStopChargingReply(); |
| | | query.setCharging_gun_code(chargingGun.getCode()); |
| | | query.setCharging_pile_code(chargingPile.getCode()); |
| | | query.setEnd_time(chargingOrder.getEndTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | PlatformStopChargingReply reply = platformStopChargingReplyClient.getPlatformStopChargingReply(query).getData(); |
| | | log.error(code1 + ":-------------------查询远程停止充电应答-------------------"); |
| | | if(null == reply){ |
| | | log.error(code1 + ":-------------------远程停止充电应答无数据-------------------"); |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | continue; |
| | | } |
| | | log.error(reply.toString()); |
| | | |
| | | if(0 == reply.getStop_result()){ |
| | | String failure_cause = ""; |
| | | switch (reply.getFailure_cause()){ |
| | | case 0: |
| | | failure_cause = "无"; |
| | | break; |
| | | case 1: |
| | | failure_cause = "设备编号不匹配"; |
| | | break; |
| | | case 2: |
| | | failure_cause = "枪未处于充电状态"; |
| | | break; |
| | | case 3: |
| | | failure_cause = "其他"; |
| | | break; |
| | | } |
| | | log.error(code1 + ":停机失败:订单号:{},失败原因:{}", chargingOrder.getCode(), failure_cause); |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | continue; |
| | | } |
| | | log.error(code1 + ":-------------------远程停止充电请求成功-------------------"); |
| | | break; |
| | | } |
| | | |
| | | chargingOrder.setStatus(5); |
| | | this.updateById(chargingOrder); |
| | | }); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 结束充电后处理用户标签数据 |
| | | * @param chargingOrder |
| | | */ |
| | | public void editUserTag(TChargingOrder chargingOrder){ |
| | | //处理用户标签数据 |
| | | List<TUserTag> data = userTagClient.getAllUserTag().getData(); |
| | | //累计充电次数 |
| | |
| | | } |
| | | } |
| | | } |
| | | String code1 = chargingOrder.getCode(); |
| | | |
| | | //异步线程处理停机 |
| | | ExecutorService cachedThreadPool = Executors.newFixedThreadPool(1); |
| | | cachedThreadPool.execute(()->{ |
| | | //调用硬件停止充电,停止成功后开始计算费用退款 |
| | | TChargingPile chargingPile = chargingPileClient.getChargingPileById(chargingOrder.getChargingPileId()).getData(); |
| | | TChargingGun chargingGun = chargingGunClient.getChargingGunById(chargingOrder.getChargingGunId()).getData(); |
| | | PlatformStopCharging platformStopCharging = new PlatformStopCharging(); |
| | | platformStopCharging.setCharging_pile_code(chargingPile.getCode()); |
| | | platformStopCharging.setCharging_gun_code(chargingGun.getCode()); |
| | | sendMessageClient.platformStopCharging(platformStopCharging); |
| | | log.error(code1 + ":-------------------远程停止充电请求-------------------"); |
| | | log.error(platformStopCharging.toString()); |
| | | //开始查询停机应答,成功后开始计费费用 |
| | | for (int i = 0; i < 60; i++) { |
| | | GetPlatformStopChargingReply query = new GetPlatformStopChargingReply(); |
| | | query.setCharging_gun_code(chargingGun.getCode()); |
| | | query.setCharging_pile_code(chargingPile.getCode()); |
| | | query.setEnd_time(chargingOrder.getEndTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); |
| | | PlatformStopChargingReply reply = platformStopChargingReplyClient.getPlatformStopChargingReply(query).getData(); |
| | | log.error(code1 + ":-------------------查询远程停止充电应答-------------------"); |
| | | if(null == reply){ |
| | | log.error(code1 + ":-------------------远程停止充电应答无数据-------------------"); |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | continue; |
| | | } |
| | | log.error(reply.toString()); |
| | | TChargingOrder chargingOrder1 = this.getById(id); |
| | | if(chargingOrder1.getStatus() != 3){ |
| | | break; |
| | | } |
| | | |
| | | if(0 == reply.getStop_result()){ |
| | | String failure_cause = ""; |
| | | switch (reply.getFailure_cause()){ |
| | | case 0: |
| | | failure_cause = "无"; |
| | | break; |
| | | case 1: |
| | | failure_cause = "设备编号不匹配"; |
| | | break; |
| | | case 2: |
| | | failure_cause = "枪未处于充电状态"; |
| | | break; |
| | | case 3: |
| | | failure_cause = "其他"; |
| | | break; |
| | | } |
| | | log.error(code1 + ":停机失败:订单号:{},失败原因:{}", chargingOrder.getCode(), failure_cause); |
| | | try { |
| | | Thread.sleep(1000); |
| | | } catch (InterruptedException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | continue; |
| | | } |
| | | |
| | | // 将枪状态重置为空闲 |
| | | chargingGun.setStatus(2); |
| | | chargingGunClient.updateChargingGunById(chargingGun); |
| | | //计算费用,处理退款 |
| | | endCharge(chargingOrder); |
| | | log.error(code1 + ":-------------------远程停止充电请求成功-------------------"); |
| | | break; |
| | | } |
| | | }); |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 推荐奖励(被推荐首单奖励) |
| | | * @param chargingOrder |
| | | */ |
| | | public void referralReward(TChargingOrder chargingOrder){ |
| | | //处理推荐奖励(被推荐首单奖励) |
| | | TAppUser appUser = appUserClient.getUserById(chargingOrder.getAppUserId()).getData(); |
| | | long count = this.count(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getAppUserId, chargingOrder.getAppUserId()) |
| | |
| | | appUserIntegralChange.setHistoricalIntegral(appUser1.getPoints()); |
| | | appUserIntegralChange.setCurrentIntegral(appUser1.getPoints() + num1); |
| | | appUserIntegralChange.setCreateTime(LocalDateTime.now()); |
| | | appUserIntegralChange.setOrderCode(code1); |
| | | appUserIntegralChange.setOrderCode(chargingOrder.getCode()); |
| | | appUserIntegralChangeClient.addAppUserIntegralChange(appUserIntegralChange); |
| | | |
| | | |
| | | appUser1.setPoints(appUser1.getPoints() + num1); |
| | | appUserClient.updateAppUser(appUser1); |
| | | } |
| | | |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | |
| | |
| | | if(null != order && order.getStatus() != 3){ |
| | | return; |
| | | } |
| | | |
| | | order.setEndTime(LocalDateTime.now()); |
| | | order.setStatus(5); |
| | | order.setEndMode(1); |
| | | this.updateById(order); |
| | | //计算用户标签 |
| | | editUserTag(order); |
| | | //用户推荐奖励 |
| | | referralReward(order); |
| | | //计算费用,处理退款 |
| | | endCharge(order); |
| | | // 将枪状态重置为空闲 |
| | | chargingGun.setStatus(2); |
| | | chargingGunClient.updateChargingGunById(chargingGun); |
| | | |
| | | String code1 = order.getCode(); |
| | | if(0 == platformStopChargingReply.getStop_result()){ |
| | | String failure_cause = ""; |
| | |
| | | break; |
| | | } |
| | | log.error(code1 + ":停机失败:订单号:{},失败原因:{}", order.getCode(), failure_cause); |
| | | return; |
| | | } |
| | | |
| | | // 将枪状态重置为空闲 |
| | | chargingGun.setStatus(2); |
| | | chargingGunClient.updateChargingGunById(chargingGun); |
| | | //计算费用,处理退款 |
| | | endCharge(order); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | 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); |
| | | //计算费用,处理退款 |
| | | endCharge(chargingOrder); |
| | | |
| | | //处理推荐奖励(被推荐首单奖励) |
| | | TAppUser appUser = appUserClient.getUserById(chargingOrder.getAppUserId()).getData(); |
| | | long count = this.count(new LambdaQueryWrapper<TChargingOrder>().eq(TChargingOrder::getAppUserId, chargingOrder.getAppUserId()) |
| | | .eq(TChargingOrder::getStatus, 5).isNull(TChargingOrder::getEndMode).eq(TChargingOrder::getDelFlag, 0)); |
| | | if(null != appUser.getInviteUserId() && 1 == count){ |
| | | TIntegralRule integralRule = integralRuleClient.getSet().getData(); |
| | | String inviteUsersToEarnPoints = integralRule.getInviteUsersToEarnPoints(); |
| | | JSONObject jsonObject = JSON.parseObject(inviteUsersToEarnPoints); |
| | | Integer num1 = jsonObject.getInteger("num1"); |
| | | |
| | | TAppUser appUser1 = appUserClient.getUserById(appUser.getInviteUserId()).getData(); |
| | | if(null != appUser1.getVipId()){ |
| | | TVip vip = vipClient.getInfo1(appUser1.getVipId()).getData(); |
| | | Integer doubleIntegration = vip.getDoubleIntegration(); |
| | | //双倍积分 |
| | | if(1 == doubleIntegration){ |
| | | num1 *= 2; |
| | | } |
| | | } |
| | | |
| | | GetInviteUser query = new GetInviteUser(); |
| | | query.setAppUserId(appUser1.getId()); |
| | | query.setBeInvitedAppUserId(chargingOrder.getAppUserId()); |
| | | TInviteUser inviteUser = inviteUserClient.getInviteUser(query).getData(); |
| | | if(null == inviteUser){ |
| | | inviteUser = new TInviteUser(); |
| | | inviteUser.setAppUserId(appUser1.getId()); |
| | | inviteUser.setBeInvitedAppUserId(chargingOrder.getAppUserId()); |
| | | inviteUser.setAward(num1); |
| | | inviteUser.setCreateTime(LocalDateTime.now()); |
| | | inviteUserClient.saveInviteUser(inviteUser); |
| | | }else{ |
| | | inviteUser.setAward(num1); |
| | | inviteUserClient.updateInviteUser(inviteUser); |
| | | } |
| | | TAppUserIntegralChange appUserIntegralChange = new TAppUserIntegralChange(); |
| | | String code = Double.valueOf(Math.random() * 1000).intValue() + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS")); |
| | | appUserIntegralChange.setCode(code); |
| | | appUserIntegralChange.setAppUserId(appUser1.getId()); |
| | | appUserIntegralChange.setChangeType(5); |
| | | appUserIntegralChange.setHistoricalIntegral(appUser1.getPoints()); |
| | | appUserIntegralChange.setCurrentIntegral(appUser1.getPoints() + num1); |
| | | appUserIntegralChange.setCreateTime(LocalDateTime.now()); |
| | | appUserIntegralChange.setOrderCode(chargingOrder.getCode()); |
| | | appUserIntegralChangeClient.addAppUserIntegralChange(appUserIntegralChange); |
| | | |
| | | appUser1.setPoints(appUser1.getPoints() + num1); |
| | | appUserClient.updateAppUser(appUser1); |
| | | } |
| | | |
| | | } |
| | | |
| | | /** |