| | |
| | | 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.pay.wxpay.UsrWxPayConfigService; |
| | | import com.sandu.ximon.admin.security.SecurityUtils; |
| | | import com.sandu.ximon.admin.security.order.OrderQueryListener; |
| | | import com.sandu.ximon.admin.utils.AliPayUtils; |
| | | import com.sandu.ximon.admin.utils.RedisUtils; |
| | | import com.sandu.ximon.admin.vo.C3mOrderVO; |
| | | import com.sandu.ximon.dao.bo.C3mOrderBo; |
| | | 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.domain.*; |
| | | 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; |
| | |
| | | @AllArgsConstructor |
| | | public class C3mOrderService extends BaseServiceImpl<C3mOrderMapper, C3mOrder> { |
| | | |
| | | private final RedisUtils redisUtils; |
| | | private final PoleService poleService; |
| | | private final C3mOrderMapper c3mOrderMapper; |
| | | private final WxFastPayService fastPayService; |
| | | private final OrderQueryListener orderQueryListener; |
| | | private final Snowflake snowflake; |
| | | |
| | | private final C3ChargingService c3ChargingService; |
| | |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public C3mOrder advancePayOrder(Long streetlightId, C3mCharging c3m, String orderType, Double totalAmount, |
| | | Integer subscribeChargingCapacity, String wxCode) { |
| | | Integer subscribeChargingCapacity, String wxCode) throws InterruptedException { |
| | | //查询充电桩是否存在正在进行中的订单 |
| | | C3mOrder c3mOrder = getOne(Wrappers.lambdaQuery(C3mOrder.class) |
| | | .eq(C3mOrder::getC3Udid, c3m.getMcuUdid()).eq(C3mOrder::getC3Mac, c3m.getC3Mac()).last("limit 1")); |
| | |
| | | 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 + "!"); |
| | | } |
| | | |
| | | if (save(c3mOrderEntity)) { |
| | | return c3mOrderEntity; |
| | |
| | | //删除超过10分钟未付款的订单 |
| | | remove(Wrappers.lambdaQuery(C3mOrder.class).lt(C3mOrder::getCreateTimestamp, timeMinus10).eq(C3mOrder::getOrderStatus, 0)); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |