| | |
| | | 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.dto.ChargingDto; |
| | | import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5C3HeartbeatReportInnerFrame; |
| | | import com.sandu.ximon.admin.pay.OrderStatusEnums; |
| | | import com.sandu.ximon.admin.pay.wx.WxFastPayService; |
| | |
| | | import com.sandu.ximon.admin.utils.AliPayUtils; |
| | | import com.sandu.ximon.admin.vo.C3mOrderVO; |
| | | import com.sandu.ximon.dao.bo.C3mOrderBo; |
| | | import com.sandu.ximon.dao.domain.*; |
| | | import com.sandu.ximon.dao.domain.C3mCharging; |
| | | import com.sandu.ximon.dao.domain.C3mOrder; |
| | | import com.sandu.ximon.dao.domain.Pole; |
| | | import com.sandu.ximon.dao.domain.WxConfigEntity; |
| | | import com.sandu.ximon.dao.enums.OrderStatus; |
| | | import com.sandu.ximon.dao.enums.OrderType; |
| | | import com.sandu.ximon.dao.mapper.C3mOrderMapper; |
| | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.time.ZoneId; |
| | | import java.util.Date; |
| | |
| | | String username = SecurityUtils.getUsername(); |
| | | C3mOrder orderByOutTradeNo = c3mOrderMapper.getOrderByOutTradeNo(outTradeNo); |
| | | |
| | | if(orderByOutTradeNo==null){ |
| | | throw new BusinessException("未找到订单!"); |
| | | } |
| | | //退款前进行状态判断 |
| | | if (orderByOutTradeNo.getOrderStatus().equals(OrderStatus.REFUND.getStatus()) |
| | | || orderByOutTradeNo.getOrderStatus().equals(OrderStatus.CANCEL.getStatus()) |
| | | || orderByOutTradeNo.getOrderStatus().equals(OrderStatus.NO_PAY.getStatus())) { |
| | | throw new BusinessException("订单状态错误,无法退款 !"); |
| | | } |
| | | if (orderByOutTradeNo == null) { |
| | | throw new BusinessException("未找到订单"); |
| | | } else { |
| | |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public C3mOrder advancePayOrder(Long streetlightId, C3mCharging c3m, String orderType, Double totalAmount, |
| | | Integer subscribeChargingCapacity, String wxCode) throws InterruptedException { |
| | | Integer subscribeChargingCapacity, String openId) throws InterruptedException { |
| | | //查询充电桩是否存在正在进行中的订单 |
| | | C3mOrder c3mOrder = getOne(Wrappers.lambdaQuery(C3mOrder.class) |
| | | .eq(C3mOrder::getC3Udid, c3m.getMcuUdid()).eq(C3mOrder::getC3Mac, c3m.getC3Mac()).last("limit 1")); |
| | |
| | | throw new BusinessException("充电桩正在被占用!"); |
| | | } |
| | | |
| | | //存在订单,但是未支付,需要取消订单 |
| | | if (c3mOrder != null) { |
| | | c3mOrder.setOrderStatus(OrderStatus.CANCEL.getStatus()); |
| | | updateById(c3mOrder); |
| | | } |
| | | // //存在订单,但是未支付,需要取消订单 |
| | | // if (c3mOrder != null) { |
| | | // c3mOrder.setOrderStatus(OrderStatus.CANCEL.getStatus()); |
| | | // updateById(c3mOrder); |
| | | // } |
| | | |
| | | Pole pole = poleService.getById(streetlightId); |
| | | if (null == pole) { |
| | |
| | | c3mOrderEntity.setPoleMac(pole.getDeviceCode()); |
| | | c3mOrderEntity.setPoleName(pole.getPoleName()); |
| | | c3mOrderEntity.setC3Mac(c3m.getC3Mac()); |
| | | c3mOrderEntity.setC3Name(c3m.getC3Name()); |
| | | c3mOrderEntity.setOrderStatus(0); |
| | | c3mOrderEntity.setUserCode(wxCode); |
| | | c3mOrderEntity.setUserCode(openId); |
| | | c3mOrderEntity.setC3Udid(c3m.getMcuUdid()); |
| | | c3mOrderEntity.setRefundAmount(totalAmount); |
| | | c3mOrderEntity.setSurplusAmount(totalAmount); |
| | | |
| | | //确认充电桩状态 |
| | | ChargingDto chargingInfo = c3ChargingService.getChargingInfo(streetlightId.toString()); |
| | | if (chargingInfo.getStatusBit() != 1) { |
| | | throw new BusinessException("充电桩非空闲状态,无法创建订单!"); |
| | | } |
| | | Thread.sleep(500); |
| | | |
| | | //同步时间戳 |
| | | System.out.println("同步时间戳开始"); |
| | | String date = new SimpleDateFormat("yyMMddHHmmss").format(new Date()); |
| | | String s = c3ChargingService.SetCalendar(c3m.getC3Mac(), Integer.parseInt(date.substring(0, 2)), Integer.parseInt(date.substring(2, 4)), |
| | | Integer.parseInt(date.substring(4, 6)), Integer.parseInt(date.substring(6, 8)), |
| | | Integer.parseInt(date.substring(8, 10)), Integer.parseInt(date.substring(10, 12)), true); |
| | | log.error("同步时间戳结果 : " + s); |
| | | if (!"操作成功".equals(s)) { |
| | | throw new BusinessException(s + "!"); |
| | | } |
| | | Thread.sleep(500); |
| | | |
| | | //同步费率 |
| | | List<C3mChargingCharge> list = SpringContextHolder.getBean(C3mChargingChargeService.class) |
| | | .list(Wrappers.lambdaQuery(C3mChargingCharge.class).eq(C3mChargingCharge::getC3Id, c3m.getC3Id())); |
| | | if (list == null && list.size() == 0) { |
| | | //费率表中没有此充电桩数据时 添加默认费率 |
| | | SpringContextHolder.getBean(C3mChargingChargeService.class).initCharge((c3m.getC3Id()).intValue()); |
| | | } |
| | | String rateState = c3ChargingService.setRate(c3m.getC3Mac(), list, true); |
| | | log.error("费率设置结果 : " + rateState); |
| | | if (!"操作成功".equals(rateState)) { |
| | | throw new BusinessException(s + "!"); |
| | | } |
| | | // //确认充电桩状态 |
| | | // ChargingDto chargingInfo = c3ChargingService.getChargingInfo(streetlightId.toString()); |
| | | // if (chargingInfo.getStatusBit() != 1) { |
| | | // throw new BusinessException("充电桩非空闲状态,无法创建订单!"); |
| | | // } |
| | | // Thread.sleep(500); |
| | | // |
| | | // //同步时间戳 |
| | | // System.out.println("同步时间戳开始"); |
| | | // String date = new SimpleDateFormat("yyMMddHHmmss").format(new Date()); |
| | | // String s = c3ChargingService.SetCalendar(c3m.getC3Mac(), Integer.parseInt(date.substring(0, 2)), Integer.parseInt(date.substring(2, 4)), |
| | | // Integer.parseInt(date.substring(4, 6)), Integer.parseInt(date.substring(6, 8)), |
| | | // Integer.parseInt(date.substring(8, 10)), Integer.parseInt(date.substring(10, 12)), true); |
| | | // log.error("同步时间戳结果 : " + s); |
| | | // if (!"操作成功".equals(s)) { |
| | | // throw new BusinessException(s + "!"); |
| | | // } |
| | | // Thread.sleep(500); |
| | | // |
| | | // //同步费率 |
| | | // System.out.println("同步费率开始"); |
| | | // List<C3mChargingCharge> list = SpringContextHolder.getBean(C3mChargingChargeService.class) |
| | | // .list(Wrappers.lambdaQuery(C3mChargingCharge.class).eq(C3mChargingCharge::getC3Id, c3m.getC3Id())); |
| | | // if (list == null && list.size() == 0) { |
| | | // //费率表中没有此充电桩数据时 添加默认费率 |
| | | // SpringContextHolder.getBean(C3mChargingChargeService.class).initCharge((c3m.getC3Id()).intValue()); |
| | | // } |
| | | // String rateState = c3ChargingService.setRate(c3m.getC3Mac(), list, true); |
| | | // log.error("费率设置结果 : " + rateState); |
| | | // if (!"操作成功".equals(rateState)) { |
| | | // throw new BusinessException(s + "!"); |
| | | // } |
| | | |
| | | if (save(c3mOrderEntity)) { |
| | | return c3mOrderEntity; |
| | |
| | | |
| | | |
| | | /** |
| | | * 充电桩故障情况下,结果故障前正在进行中的订单 |
| | | * 充电桩故障情况下,结束故障前正在进行中的订单 |
| | | * |
| | | * @param dataPackage |
| | | */ |
| | | public void stopCharingOrder(String c3Mac, A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage dataPackage) { |
| | | if (c3Mac.isEmpty() || c3Mac == null || dataPackage == null) { |
| | | public void stopCharingOrder(A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage dataPackage) { |
| | | if (dataPackage == null) { |
| | | return; |
| | | } |
| | | //获取正在进行中的订单 |
| | | C3mOrder c3mOrder = getOne(Wrappers.lambdaQuery(C3mOrder.class) |
| | | .eq(C3mOrder::getC3Mac, c3Mac).eq(C3mOrder::getChargingStates, 0) |
| | | .eq(C3mOrder::getC3Mac, dataPackage.getC3Mac()).eq(C3mOrder::getChargingStates, 0) |
| | | .eq(C3mOrder::getOrderStatus, OrderStatus.PAYED.getStatus()).last("limit 1")); |
| | | //订单未结束,但是充电桩为空闲状态(即充电桩断电/故障情况) 结束该订单 |
| | | if ("1".equals(dataPackage.getStatusBit()) && c3mOrder != null) { |