| | |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.service.impl.BaseServiceImpl; |
| | | import com.sandu.common.util.SpringContextHolder; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5C3HeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.manager.iot.rrpc.enums.C3mRedisConstant; |
| | | import com.sandu.ximon.admin.pay.OrderStatusEnums; |
| | |
| | | //查询充电桩是否存在正在进行中的订单 |
| | | C3mOrder c3mOrder = getOne(Wrappers.lambdaQuery(C3mOrder.class) |
| | | .eq(C3mOrder::getC3Udid, c3m.getMcuUdid()).eq(C3mOrder::getChargingStates, 1).last("limit 1")); |
| | | if (c3mOrder != null) { |
| | | throw new BusinessException("该充电桩已存在正在进行中的订单"); |
| | | } |
| | | if (!c3mOrder.getUserCode().equals(wxCode)) { |
| | | |
| | | if (c3mOrder != null && !c3mOrder.getUserCode().equals(wxCode)) { |
| | | throw new BusinessException("该充电桩正在被别人使用"); |
| | | } |
| | | Pole pole = poleService.getById(streetlightId); |
| | |
| | | userOrder.setOutTradeNo(transactionId); |
| | | userOrder.setPayTimestamp(new Date().getTime()); |
| | | userOrder.setOrderStatus(OrderStatusEnums.PAID.getCode()); |
| | | if (!updateById(userOrder)) { |
| | | return WxPayNotifyResponse.fail("更新数据已失效"); |
| | | } |
| | | /** |
| | | * 调起开始充电接口 |
| | | */ |
| | | String s = c3ChargingService.startCharging(userOrder.getC3Mac(), userOrder.getSubscribeChargingCapacity(), userOrder.getTotalAmount()); |
| | | if (s.isEmpty() || s == null) { |
| | | throw new BusinessException("开启充电失败"); |
| | | } |
| | | userOrder.setChargingStates(0); |
| | | if (!updateById(userOrder)) { |
| | | return WxPayNotifyResponse.fail("更新数据已失效"); |
| | | } |
| | | |
| | | return WxPayNotifyResponse.success("更新数据成功"); |
| | |
| | | remove(Wrappers.lambdaQuery(C3mOrder.class).lt(C3mOrder::getCreateTimestamp, time).eq(C3mOrder::getOrderStatus, 0)); |
| | | } |
| | | |
| | | /** |
| | | * 恢复继续充电 |
| | | * |
| | | * @param c3Mac |
| | | * @param mcuUdid |
| | | */ |
| | | public void recoverContinueCharing(String c3Mac, String mcuUdid) { |
| | | C3mOrder c3mOrder = getOne(Wrappers.lambdaQuery(C3mOrder.class). |
| | | eq(C3mOrder::getC3Mac, c3Mac).eq(C3mOrder::getC3Udid, mcuUdid).eq(C3mOrder::getChargingStates, 0).last("limit 1")); |
| | | if (c3mOrder != null) { |
| | | c3mOrder.setActualChargingCapacity(c3mOrder.getActualChargingCapacityHide()); |
| | | c3mOrder.setActualChargingCapacityHide(0.00); |
| | | |
| | | //再次充电电量 |
| | | double electricity = c3mOrder.getSubscribeChargingCapacity() - c3mOrder.getActualChargingCapacity(); |
| | | Integer chargingCapacity = Integer.valueOf(String.valueOf(Math.floor(electricity))); |
| | | //再次充电金额 |
| | | double chargeAmount = c3mOrder.getSurplusAmount(); |
| | | SpringContextHolder.getBean(C3ChargingService.class).startCharging(c3Mac, chargingCapacity, chargeAmount); |
| | | } |
| | | } |
| | | |
| | | } |