| | |
| | | int count = onePushTime / sleepTime; |
| | | // 第一轮推单 |
| | | log.info("开始第一轮推单 {}", orderNo); |
| | | processPushOrder(quoteName, count, sleepTime, uid, split, orderNo, xpTradingStrategy, onePushDistance, distance, duration, planRule); |
| | | |
| | | Boolean processed = processPushOrder(quoteName, count, sleepTime, uid, split, orderNo, xpTradingStrategy, onePushDistance, distance, duration, planRule); |
| | | if(processed){ |
| | | log.info("订单推送成功 {}", orderNo); |
| | | return; |
| | | } |
| | | // 第二轮推单 |
| | | Integer twoPushTime = xpTradingStrategy.getTwoPushTime(); |
| | | Double twoPushDistance = xpTradingStrategy.getTwoPushDistance(); |
| | | count = twoPushTime / sleepTime; |
| | | log.info("开始第二轮推单 {}", orderNo); |
| | | processPushOrder(quoteName, count, sleepTime, uid, split, orderNo, xpTradingStrategy, twoPushDistance, distance, duration, planRule); |
| | | processed = processPushOrder(quoteName, count, sleepTime, uid, split, orderNo, xpTradingStrategy, twoPushDistance, distance, duration, planRule); |
| | | if(processed){ |
| | | log.info("订单推送成功 {}", orderNo); |
| | | return; |
| | | } |
| | | |
| | | // 第三轮推单 |
| | | Integer threePushTime = xpTradingStrategy.getThreePushTime(); |
| | | Double threePushDistance = xpTradingStrategy.getThreePushDistance(); |
| | | count = threePushTime / sleepTime; |
| | | log.info("开始第三轮推单 {}", orderNo); |
| | | processPushOrder(quoteName, count, sleepTime, uid, split, orderNo, xpTradingStrategy, threePushDistance, distance, duration, planRule); |
| | | processed = processPushOrder(quoteName, count, sleepTime, uid, split, orderNo, xpTradingStrategy, threePushDistance, distance, duration, planRule); |
| | | if(processed){ |
| | | log.info("订单推送成功 {}", orderNo); |
| | | return; |
| | | } |
| | | |
| | | // 第四轮推单 |
| | | Integer fourPushTime = xpTradingStrategy.getFourPushTime(); |
| | | Double fourPushDistance = xpTradingStrategy.getFourPushDistance(); |
| | | count = fourPushTime / sleepTime; |
| | | log.info("开始第四轮推单 {}", orderNo); |
| | | processPushOrder(quoteName, count, sleepTime, uid, split, orderNo, xpTradingStrategy, fourPushDistance, distance, duration, planRule); |
| | | processed = processPushOrder(quoteName, count, sleepTime, uid, split, orderNo, xpTradingStrategy, fourPushDistance, distance, duration, planRule); |
| | | if(processed){ |
| | | log.info("订单推送成功 {}", orderNo); |
| | | return; |
| | | } |
| | | |
| | | // 第五轮推单 |
| | | Integer fivePushTime = xpTradingStrategy.getFivePushTime(); |
| | | Double fivePushDistance = xpTradingStrategy.getFivePushDistance(); |
| | | count = fivePushTime / sleepTime; |
| | | log.info("开始第五轮推单 {}", orderNo); |
| | | processPushOrder(quoteName, count, sleepTime, uid, split, orderNo, xpTradingStrategy, fivePushDistance, distance, duration, planRule); |
| | | processed = processPushOrder(quoteName, count, sleepTime, uid, split, orderNo, xpTradingStrategy, fivePushDistance, distance, duration, planRule); |
| | | if(processed){ |
| | | log.info("订单推送成功 {}", orderNo); |
| | | return; |
| | | } |
| | | |
| | | // 取消订单 |
| | | R<XpOrder> xpOrderR = xpOrderClient.queryOrderById(Long.valueOf(orderId)); |
| | |
| | | * @param xpTradingStrategy 规则 |
| | | */ |
| | | @SneakyThrows |
| | | private void processPushOrder(String quoteName, int count, int sleepTime, String uid, String[] split, String orderNo, XpTradingStrategy xpTradingStrategy, Double pushDistance, String distance, String duration, String planRule) { |
| | | private Boolean processPushOrder(String quoteName, int count, int sleepTime, String uid, String[] split, String orderNo, XpTradingStrategy xpTradingStrategy, Double pushDistance, String distance, String duration, String planRule) { |
| | | log.info("进入推单环节 单号 {}", orderNo); |
| | | if (count == 0) { |
| | | count = 1; |
| | |
| | | // 订单状态 |
| | | R<XpOrder> xpOrderR = xpOrderClient.queryOrderByOrderNo(orderNo); |
| | | if (xpOrderR.getCode() != 200) { |
| | | return; |
| | | return false; |
| | | } |
| | | if (xpOrderR.getData().getStatus() != 1) { |
| | | return; |
| | | return true; |
| | | } |
| | | XpOrder xpOrder = xpOrderR.getData(); |
| | | |
| | |
| | | |
| | | redisService.popFirstElement(quoteName); |
| | | log.info("将订单 {} 从队列 {} 弹出去", orderNo, quoteName); |
| | | return; |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | |
| | | xpVehicleClient.updateVehicleById(vehicle); |
| | | } |
| | | } |
| | | return; |
| | | return true; |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | |
| | | } |
| | | } |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | /** |
| | |
| | | order.setFleetId(vehicle.getFleetId()); |
| | | addTaxiPassengerVo.setVin(vehicle.getVehicleVin()); |
| | | } |
| | | order.setStatus(2); |
| | | order.setStatus(3); |
| | | |
| | | // Redis弹出这个队列元素 |
| | | // value 订单Id_经纬度_状态_用户id_订单编号_距离_时间 |