| | |
| | | import com.xiaopeng.common.core.constant.CacheConstants; |
| | | import com.xiaopeng.common.core.constant.Constants; |
| | | import com.xiaopeng.common.core.domain.R; |
| | | import com.xiaopeng.common.core.enums.CancelOrderSceneEnum; |
| | | import com.xiaopeng.common.core.enums.OrderStatusEnum; |
| | | import com.xiaopeng.common.core.enums.PushMessageTypeEnum; |
| | | import com.xiaopeng.common.core.utils.StringUtils; |
| | |
| | | @Slf4j |
| | | @Service |
| | | public class KafkaConsumerService { |
| | | private static final String CANCEL_ORDER_CONTEXT_PREFIX = "CANCEL_ORDER_CONTEXT:"; |
| | | |
| | | |
| | | @Resource |
| | | private XpMapClient xpMapClient; |
| | |
| | | case ORDER_CANCELLED: |
| | | //已取消 |
| | | if(!orderId.contains("XU")){ |
| | | String taskId = orderStatusInfo.getTaskId(); |
| | | JSONObject cancelContext = getCancelOrderContext(taskId); |
| | | if (shouldSkipCancelForReassign(cancelContext)) { |
| | | log.info("改派旧车取消回调,跳过订单取消处理,orderId: {}, taskId: {}, cancelScene: {}, context: {}", |
| | | orderId, taskId, cancelContext.getString("cancelScene"), cancelContext); |
| | | //响应消息 |
| | | responseMessage(sequence, cancelContext.getString("vin")); |
| | | return; |
| | | } |
| | | if(orderId.contains("TEST")){ |
| | | //判断订单状态,已经取消的不作处理 |
| | | Object cacheObject = redisService.getCacheObject("TEST_ORDER_STATUS:" + orderId.substring(4)); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 根据taskId获取订单取消的上下文信息 |
| | | * @param taskId |
| | | * @return |
| | | */ |
| | | private JSONObject getCancelOrderContext(String taskId) { |
| | | if (StringUtils.isEmpty(taskId)) { |
| | | return null; |
| | | } |
| | | Object cacheObject = redisService.getCacheObject(CANCEL_ORDER_CONTEXT_PREFIX + taskId); |
| | | if (cacheObject == null) { |
| | | return null; |
| | | } |
| | | return JSON.parseObject(cacheObject.toString()); |
| | | } |
| | | |
| | | /** |
| | | * 判断是否是改派旧车取消回调,是则跳过订单取消处理 |
| | | * @param cancelContext |
| | | * @return |
| | | */ |
| | | private boolean shouldSkipCancelForReassign(JSONObject cancelContext) { |
| | | if (cancelContext == null) { |
| | | return false; |
| | | } |
| | | return CancelOrderSceneEnum.REASSIGN_OLD_VEHICLE == CancelOrderSceneEnum.fromCode( |
| | | cancelContext.getString("cancelScene")); |
| | | } |
| | | |
| | | /** |
| | | * 云端下发导航到XPU |
| | | * @param requestId XPU请求id |
| | | * @param routeId 高德导航id |