fix:携程超标推送增加配置功能
This commit is contained in:
parent
52897065ec
commit
bcac378e4b
|
@ -203,7 +203,7 @@ public class CTripOrderDataAdapter implements OrderDataAdapter {
|
|||
.originId(departCityName.getLocationId())
|
||||
.destinationId(arriveCityName.getLocationId())
|
||||
.price(String.valueOf(carBasicInfo.getOrderAmount()))
|
||||
.selfOrderNo(carBasicInfo.getJouneryID())
|
||||
.selfOrderNo(carBasicInfo.getJourneyID())
|
||||
.outOrderNo(String.valueOf(carBasicInfo.getOrderId()))
|
||||
.orderStatus(translateCarOrderStatus(carBasicInfo.getOrderStatus()))
|
||||
.originOrderStatus(carBasicInfo.getOrderStatus());
|
||||
|
|
|
@ -78,17 +78,6 @@ public class BPMController {
|
|||
if (SUPPLIER_L_Y_BPM_NAME.equals(bpmBack.getOrderSource())) {
|
||||
List<OrderTravel> byOrderNo = orderTravelRepository.findByOrderNo(bpmBack.getOrderNo());
|
||||
String travelNo = byOrderNo.isEmpty() ? "" : byOrderNo.get(0).getTravelNo();
|
||||
StrokePushDTO strokePushDTO = new StrokePushDTO();
|
||||
Param param = new Param();
|
||||
if ("通过".equals(result) || "同意".equals(result)) {
|
||||
param.setTravelBizOrderNo(travelNo)//同程行程单号
|
||||
.setApprovalStatus(2);//1驳回 2通过
|
||||
} else {
|
||||
param.setTravelBizOrderNo(travelNo)//同程行程单号
|
||||
.setApprovalStatus(1);//1驳回 2通过
|
||||
}
|
||||
strokePushDTO.setParam(param);
|
||||
strokeController.strokePush(strokePushDTO);
|
||||
|
||||
//新审批接口
|
||||
if (BELONG_SYS_CODE_ANFSSC.equals(bpmBack.getTag()) && "拒绝".equals(bpmBack.getResult())) {
|
||||
|
@ -102,7 +91,6 @@ public class BPMController {
|
|||
() -> lyApprovalRequest.pushApprovalSuccess(travelNo).isSuccess(), 0
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//记录审批状态
|
||||
|
|
|
@ -5,15 +5,20 @@ import com.chint.application.commands.OrderStatusChangeCommand;
|
|||
import com.chint.application.commands.SupplierCallBackErrorCommand;
|
||||
import com.chint.domain.aggregates.order.OrderDetail;
|
||||
import com.chint.domain.repository.SupplierCallBackLogRepository;
|
||||
import com.chint.domain.service.SystemDomainService;
|
||||
import com.chint.domain.service.supplier.SupplierService;
|
||||
import com.chint.domain.value_object.SupplierCallbackData;
|
||||
import com.chint.infrastructure.echo_framework.command.Command;
|
||||
import com.chint.infrastructure.util.DelayDispatch;
|
||||
import com.chint.infrastructure.util.Digest;
|
||||
import com.chint.infrastructure.util.Result;
|
||||
import com.chint.interfaces.rest.ctrip.CTripAuditRequest;
|
||||
import com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest;
|
||||
import com.chint.interfaces.rest.ctrip.dto.put.CTripStatusNotification;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.ItineraryEntity;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.car.CarQuickOrderInfoEntity;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.flight.FlightOrderInfoEntity;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.hotel.HotelOrderInfoEntity;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.hotel.RefundInfo;
|
||||
import com.chint.interfaces.rest.ctrip.tools.CTripUtils;
|
||||
|
@ -30,6 +35,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
|
@ -58,9 +64,16 @@ public class CTripNoteController {
|
|||
@Autowired
|
||||
private SupplierCallBackLogRepository supplierCallBackLogRepository;
|
||||
|
||||
@Autowired
|
||||
private SystemDomainService systemDomainService;
|
||||
|
||||
@Autowired
|
||||
private CTripAuditRequest cTripAuditRequest;
|
||||
|
||||
@Autowired
|
||||
public RedisTemplate<String, String> redisTemplate;
|
||||
|
||||
|
||||
private static final String NO_ETA_AVAILABLE = "暂无";
|
||||
|
||||
private Gson gson = new Gson();
|
||||
|
@ -70,7 +83,6 @@ public class CTripNoteController {
|
|||
public Result<String> statusEvent(@RequestBody CTripStatusNotification cTripStatusNotification) {
|
||||
|
||||
|
||||
|
||||
String json = gson.toJson(cTripStatusNotification);
|
||||
log.info(json);
|
||||
//创建回推日志
|
||||
|
@ -89,6 +101,7 @@ public class CTripNoteController {
|
|||
return Result.Success(ORDER_STATUS_REFUSE_MSG);
|
||||
}
|
||||
|
||||
|
||||
String orderId = cTripStatusNotification.getOrderId();
|
||||
String putCTripSign = Digest.getPutCTripStatusSign(cTripStatusNotification.getCorpId(), productType, orderStatus, orderId, C_TRIP_REQUEST_SECRET);
|
||||
if (!putCTripSign.equals(cTripStatusNotification.getSign())) {
|
||||
|
@ -142,6 +155,18 @@ public class CTripNoteController {
|
|||
SearchOrderResponse response = cTripOrderSearchRequest
|
||||
.searchOrderResponseByOrderId(orderId);
|
||||
|
||||
|
||||
//如果返回的审批是正确的并且为超标状态 ,那么根据配置来执行是否进行立刻外部审批
|
||||
// 如果 orderStatus 为 "Approving2" 才执行以下代码
|
||||
if ("Approving2".equals(orderStatus)) {
|
||||
Optional<String> routeOrderNoOptional = findRouteOrderNoByLegType(legType, response);
|
||||
routeOrderNoOptional
|
||||
.filter(routeOrderNo -> !routeOrderNo.isEmpty())
|
||||
.map(routeOrderNo -> routeOrderNo.split("-"))
|
||||
.filter(split -> split.length > 0)
|
||||
.ifPresent(split -> processImmediateResponse(orderId, legType, split[0]));
|
||||
}
|
||||
|
||||
SupplierCallbackData supplierCallbackData = SupplierCallbackData.of(SUPPLIER_C_TRIP)
|
||||
.data(response)
|
||||
.outOrderStatus(orderStatus)
|
||||
|
@ -182,4 +207,39 @@ public class CTripNoteController {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Optional<String> findRouteOrderNoByLegType(Integer legType, SearchOrderResponse response) {
|
||||
try {
|
||||
return switch (legType) {
|
||||
case LEG_TYPE_AIRPLANE -> {
|
||||
FlightOrderInfoEntity flightOrderInfoEntity = response.getItineraryList()
|
||||
.get(0).getFlightOrderInfoList().get(0);
|
||||
yield Optional.ofNullable(flightOrderInfoEntity.getBasicInfo().getJourneyID());
|
||||
}
|
||||
case LEG_TYPE_HOTEL -> {
|
||||
HotelOrderInfoEntity hotelOrderInfoEntity = response.getItineraryList()
|
||||
.get(0).getHotelOrderInfoList().get(0);
|
||||
yield Optional.ofNullable(hotelOrderInfoEntity.getJourneyNo());
|
||||
}
|
||||
case LEG_TYPE_TAXI -> {
|
||||
CarQuickOrderInfoEntity carQuickOrderInfoEntity = response.getItineraryList()
|
||||
.get(0).getCarQuickOrderInfoList().get(0);
|
||||
yield Optional.ofNullable(carQuickOrderInfoEntity.getBasicInfo().getJourneyID());
|
||||
}
|
||||
default -> Optional.empty();
|
||||
};
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return Optional.empty();
|
||||
}
|
||||
}
|
||||
|
||||
private void processImmediateResponse(String orderId, Integer legType, String sysCode) {
|
||||
if (systemDomainService.ifImmediateResponse(sysCode)) {
|
||||
Integer orderType = CTripUtils.cTripOrderTypeMapByLegType(legType);
|
||||
CompletableFuture.runAsync(() -> DelayDispatch.attemptToSend(
|
||||
() -> cTripAuditRequest.auditSuccess(orderId, orderType).getStatus().getSuccess(), 0
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ import org.apache.commons.lang3.StringUtils;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import static com.chint.infrastructure.constant.BPMConstant.*;
|
||||
import static com.chint.infrastructure.constant.BPMConstant.EXCEED_STANDARD_TYPE_CAR;
|
||||
import static com.chint.infrastructure.constant.LegConstant.*;
|
||||
import static com.chint.infrastructure.constant.OrderConstant.*;
|
||||
|
||||
|
@ -300,4 +302,18 @@ public class CTripUtils {
|
|||
!"Approve_A".equals(status) &&
|
||||
!"Approve_C".equals(status);
|
||||
}
|
||||
|
||||
|
||||
//携程类型映射
|
||||
//1:机票;2:酒店;3:火车票;4:用车(接送机/站,国内租车,马上用车,国内包车,汽车票)
|
||||
public static Integer cTripOrderTypeMapByLegType(Integer legType) {
|
||||
return switch (legType) {
|
||||
case LEG_TYPE_TRAIN -> 3;
|
||||
case LEG_TYPE_HOTEL -> 2;
|
||||
case LEG_TYPE_AIRPLANE -> 1;
|
||||
case LEG_TYPE_TAXI -> 4;
|
||||
default -> 0; // 默认值,如果都不匹配则为0
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -246,7 +246,7 @@ public class CTripTest {
|
|||
@Test
|
||||
void search() {
|
||||
BaseContext.setCurrentUser(user);
|
||||
SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("31674878596");
|
||||
SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("30398235616");
|
||||
System.out.println(response);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue