fix: 优化携程结算功能,高德结算功能
This commit is contained in:
parent
88872c2922
commit
f89b8b803d
|
@ -1,11 +1,14 @@
|
||||||
package com.chint.application.commands;
|
package com.chint.application.commands;
|
||||||
|
|
||||||
import com.chint.infrastructure.echo_framework.command.Command;
|
import com.chint.infrastructure.echo_framework.command.Command;
|
||||||
|
import com.chint.infrastructure.util.DateTimeUtil;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
|
import java.time.YearMonth;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class OrderRecordGenerateCommand extends Command {
|
public class OrderRecordGenerateCommand extends Command {
|
||||||
|
@ -17,6 +20,22 @@ public class OrderRecordGenerateCommand extends Command {
|
||||||
private String supplierName;
|
private String supplierName;
|
||||||
private Integer productType;
|
private Integer productType;
|
||||||
|
|
||||||
|
public void generateStartAndEndTime() {
|
||||||
|
if (oneDate != null && !oneDate.isEmpty()) {
|
||||||
|
LocalDate specificDate = LocalDate.parse(oneDate, DateTimeFormatter.BASIC_ISO_DATE);
|
||||||
|
startTime = LocalDateTime.of(specificDate, LocalTime.MIDNIGHT);
|
||||||
|
endTime = LocalDateTime.of(specificDate, LocalTime.MAX);
|
||||||
|
} else if (date != null && !date.isEmpty()) {
|
||||||
|
YearMonth specificMonth = YearMonth.parse(date, DateTimeUtil.formatterDateYYYYMM);
|
||||||
|
startTime = LocalDateTime.of(specificMonth.atDay(1), LocalTime.MIDNIGHT);
|
||||||
|
endTime = LocalDateTime.of(specificMonth.atEndOfMonth(), LocalTime.MAX);
|
||||||
|
} else {
|
||||||
|
LocalDate yesterday = LocalDate.now().minusDays(1);
|
||||||
|
startTime = LocalDateTime.of(yesterday, LocalTime.MIDNIGHT);
|
||||||
|
endTime = LocalDateTime.of(yesterday, LocalTime.MAX);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public OrderRecordGenerateCommand startTime(LocalDateTime startTime) {
|
public OrderRecordGenerateCommand startTime(LocalDateTime startTime) {
|
||||||
this.setStartTime(startTime);
|
this.setStartTime(startTime);
|
||||||
return this;
|
return this;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.chint.application.dtos.RecordMonthSaveDTO;
|
||||||
import com.chint.domain.aggregates.order.RouteOrder;
|
import com.chint.domain.aggregates.order.RouteOrder;
|
||||||
import com.chint.domain.factoriy.order_record.LyStatementOrder;
|
import com.chint.domain.factoriy.order_record.LyStatementOrder;
|
||||||
import com.chint.domain.service.OrderRecordDomainService;
|
import com.chint.domain.service.OrderRecordDomainService;
|
||||||
|
import com.chint.domain.service.order_record.OrderRecordGenerator;
|
||||||
import com.chint.domain.service.order_record.OrderRecordPuller;
|
import com.chint.domain.service.order_record.OrderRecordPuller;
|
||||||
import com.chint.domain.service.supplier.SupplierAdapterSelector;
|
import com.chint.domain.service.supplier.SupplierAdapterSelector;
|
||||||
import com.chint.infrastructure.echo_framework.command.Command;
|
import com.chint.infrastructure.echo_framework.command.Command;
|
||||||
|
@ -126,13 +127,30 @@ public class AutoWorkController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// @ApiOperation("生成结算数据根据时间参数")
|
@ApiOperation("生成结算数据根据时间参数")
|
||||||
// @PostMapping("/record/pull")
|
@PostMapping("/record/generate")
|
||||||
// public Result<String> generateFromRecord(@RequestBody RecordMonthSaveDTO param) {
|
public Result<String> generateRecord(@RequestBody RecordMonthSaveDTO param) {
|
||||||
//
|
OrderRecordGenerator orderRecordGenerator = supplierAdapterSelector
|
||||||
// return Result.Success(SUCCESS);
|
.of(param.getSupplierName(), OrderRecordGenerator.class);
|
||||||
//
|
//将昨天的结算数据生成为财务共享需要的数据
|
||||||
// }
|
OrderRecordGenerateCommand command = Command.of(OrderRecordGenerateCommand.class)
|
||||||
|
.oneDate(param.getOneDate())
|
||||||
|
.date(param.getDate())
|
||||||
|
.supplierName(param.getSupplierName());
|
||||||
|
if (param.getProductType().equals(LEG_TYPE_TRAIN)) {
|
||||||
|
orderRecordGenerator.generateTrainRecordMultiParam(command);
|
||||||
|
}
|
||||||
|
if (param.getProductType().equals(LEG_TYPE_AIRPLANE)) {
|
||||||
|
orderRecordGenerator.generateFlightRecordMultiParam(command);
|
||||||
|
}
|
||||||
|
if (param.getProductType().equals(LEG_TYPE_HOTEL)) {
|
||||||
|
orderRecordGenerator.generateHotelRecordMultiParam(command);
|
||||||
|
}
|
||||||
|
if (param.getProductType().equals(LEG_TYPE_TAXI)) {
|
||||||
|
orderRecordGenerator.generateCarRecordMultiParam(command);
|
||||||
|
}
|
||||||
|
return Result.Success(SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
|
|
|
@ -68,6 +68,17 @@ public class OrderCarRecord extends OrderBaseRecord {
|
||||||
// private String belongDepart; //归属部门
|
// private String belongDepart; //归属部门
|
||||||
private String settleOrderFlag;
|
private String settleOrderFlag;
|
||||||
|
|
||||||
|
public OrderCarRecord loadSystemInfo(String trvaleSysType,
|
||||||
|
String belongSysType,
|
||||||
|
String accountCompanyId,
|
||||||
|
String accountCompanyName) {
|
||||||
|
this.setTrvaleSysType(trvaleSysType);
|
||||||
|
this.setBelongSysType(belongSysType);
|
||||||
|
this.setAccountCompanyId(accountCompanyId);
|
||||||
|
this.setAccountCompanyName(accountCompanyName);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public OrderCarRecord loadBelongDeport(String belongDeport
|
public OrderCarRecord loadBelongDeport(String belongDeport
|
||||||
) {
|
) {
|
||||||
// 行程信息
|
// 行程信息
|
||||||
|
|
|
@ -9,21 +9,27 @@ import com.chint.domain.aggregates.order.order_record.OrderTrainRecord;
|
||||||
import com.chint.domain.aggregates.order.order_record.amap_order_record.AmapCarOrderRecord;
|
import com.chint.domain.aggregates.order.order_record.amap_order_record.AmapCarOrderRecord;
|
||||||
import com.chint.infrastructure.util.BigDecimalCalculator;
|
import com.chint.infrastructure.util.BigDecimalCalculator;
|
||||||
import com.chint.interfaces.rest.amap.dto.settlement.FinishedOrderResponse;
|
import com.chint.interfaces.rest.amap.dto.settlement.FinishedOrderResponse;
|
||||||
|
import com.chint.interfaces.rest.data_center.user.UserHttpRequest;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import static com.chint.domain.service.supplier.SupplierUtil.getBelongSysType;
|
||||||
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP;
|
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP;
|
||||||
|
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP_FSSC;
|
||||||
import static com.chint.infrastructure.constant.UtilConstant.KEEP_TWO_DECIMAL_ZERO;
|
import static com.chint.infrastructure.constant.UtilConstant.KEEP_TWO_DECIMAL_ZERO;
|
||||||
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class AmapOrderRecordExtensionFactory implements OrderRecordExtensionFactory {
|
public class AmapOrderRecordExtensionFactory implements OrderRecordExtensionFactory {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserHttpRequest userHttpRequest;
|
||||||
|
|
||||||
private final String isCancel = "取消费订单";
|
private final String isCancel = "取消费订单";
|
||||||
private final String isNotCancel = "非取消费订单";
|
private final String isNotCancel = "非取消费订单";
|
||||||
|
|
||||||
|
|
||||||
private OrderRecordBasic buildWithRecord(Object orderCarRecordData) {
|
private OrderRecordBasic buildWithRecord(Object orderCarRecordData) {
|
||||||
AmapCarOrderRecord carRecordData = (AmapCarOrderRecord) orderCarRecordData;
|
AmapCarOrderRecord carRecordData = (AmapCarOrderRecord) orderCarRecordData;
|
||||||
OrderRecordBasic orderRecordBasic = new OrderRecordBasic();
|
OrderRecordBasic orderRecordBasic = new OrderRecordBasic();
|
||||||
|
@ -61,7 +67,8 @@ public class AmapOrderRecordExtensionFactory implements OrderRecordExtensionFact
|
||||||
.loadBelongDeport(
|
.loadBelongDeport(
|
||||||
routeOrder.stream().flatMap(order ->
|
routeOrder.stream().flatMap(order ->
|
||||||
Optional.ofNullable(order.getRouterOrderExtensionField().getBelongDeptCode()).stream()
|
Optional.ofNullable(order.getRouterOrderExtensionField().getBelongDeptCode()).stream()
|
||||||
).findFirst().orElseGet(carRecordData::getDepartmentId)
|
).findFirst().orElseGet(()->
|
||||||
|
userHttpRequest.belongDeport(orderCarRecord.getBookingUserCode(), orderCarRecord.getAccountCompanyName()))
|
||||||
);
|
);
|
||||||
|
|
||||||
String ds = carRecordData.getDs();
|
String ds = carRecordData.getDs();
|
||||||
|
@ -93,15 +100,19 @@ public class AmapOrderRecordExtensionFactory implements OrderRecordExtensionFact
|
||||||
Double enterpriseAmount = carRecordData.getEnterpriseAmount();
|
Double enterpriseAmount = carRecordData.getEnterpriseAmount();
|
||||||
Double individualAmount = carRecordData.getIndividualAmount();
|
Double individualAmount = carRecordData.getIndividualAmount();
|
||||||
String paymentType;
|
String paymentType;
|
||||||
if (enterpriseAmount > 0 && enterpriseAmount < carRecordData.getOrderAmount()) {
|
if (enterpriseAmount > 0 && individualAmount > 0) {
|
||||||
paymentType = "2"; // 企业支付部分,个人支付部分
|
paymentType = "2"; // 企业支付部分,个人支付部分
|
||||||
} else if (enterpriseAmount.equals(carRecordData.getOrderAmount())) {
|
} else if (enterpriseAmount == 0 && individualAmount > 0) {
|
||||||
paymentType = "0"; // 全部由企业支付
|
|
||||||
} else {
|
|
||||||
paymentType = "1"; // 全部由个人支付
|
paymentType = "1"; // 全部由个人支付
|
||||||
|
} else {
|
||||||
|
paymentType = "0"; // 全部由企业支付
|
||||||
}
|
}
|
||||||
|
|
||||||
String outApplyRecordId = carRecordData.getOutApplyRecordId();
|
String outApplyRecordId = carRecordData.getOutApplyRecordId();
|
||||||
|
String[] split = carRecordData.getRemark().split("-");
|
||||||
|
if (outApplyRecordId == null || outApplyRecordId.isEmpty()) {
|
||||||
|
outApplyRecordId = split[split.length - 1];
|
||||||
|
}
|
||||||
|
orderCarRecord.loadSystemInfo(SUPPLIER_AMAP_FSSC, getBelongSysType(split[4]), split[1], split[0]);
|
||||||
orderCarRecord.loadPayment(
|
orderCarRecord.loadPayment(
|
||||||
paymentType,
|
paymentType,
|
||||||
String.valueOf(enterpriseAmount),
|
String.valueOf(enterpriseAmount),
|
||||||
|
@ -113,10 +124,10 @@ public class AmapOrderRecordExtensionFactory implements OrderRecordExtensionFact
|
||||||
).loadSource(
|
).loadSource(
|
||||||
outApplyRecordId == null || outApplyRecordId.isEmpty() ? "N" : "Y"
|
outApplyRecordId == null || outApplyRecordId.isEmpty() ? "N" : "Y"
|
||||||
).loadRelatedOrderInfo(
|
).loadRelatedOrderInfo(
|
||||||
orderDetail.flatMap(it -> Optional.ofNullable(it.getOrderId())).orElse(Long.parseLong(carRecordData.getAmapOrderId())),
|
orderDetail.flatMap(it -> Optional.ofNullable(it.getOrderId())).orElse(1L),
|
||||||
carRecordData.getAmapOrderId(),
|
carRecordData.getAmapOrderId(),
|
||||||
carRecordData.getOutApplyRecordId(),
|
outApplyRecordId,
|
||||||
carRecordData.getOutApplyRecordId(),
|
outApplyRecordId,
|
||||||
carRecordData.getAmapOrderId(),
|
carRecordData.getAmapOrderId(),
|
||||||
carRecordData.getAmapOrderId()
|
carRecordData.getAmapOrderId()
|
||||||
);
|
);
|
||||||
|
|
|
@ -25,7 +25,8 @@ import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import static com.chint.infrastructure.constant.BelongSystemConstant.*;
|
import static com.chint.domain.service.supplier.SupplierUtil.getBelongSysType;
|
||||||
|
import static com.chint.infrastructure.constant.BelongSystemConstant.TRAVAL_SYS_TYPE_CTRIP;
|
||||||
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
|
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
|
||||||
import static com.chint.infrastructure.constant.UtilConstant.KEEP_TWO_DECIMAL_ZERO;
|
import static com.chint.infrastructure.constant.UtilConstant.KEEP_TWO_DECIMAL_ZERO;
|
||||||
|
|
||||||
|
@ -56,24 +57,25 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
|
||||||
private UserCustomCodeRepository userCustomCodeRepository;
|
private UserCustomCodeRepository userCustomCodeRepository;
|
||||||
|
|
||||||
private String getBeLongSysType(String sysCode) {
|
private String getBeLongSysType(String sysCode) {
|
||||||
String res = null;
|
// String res = null;
|
||||||
if (sysCode != null) {
|
// if (sysCode != null) {
|
||||||
if (sysCode.equals(BELONG_SYS_CODE_FSSC) || sysCode.contains(BELONG_SYS_TYPE_FSSC)) {
|
// if (sysCode.equals(BELONG_SYS_CODE_FSSC) || sysCode.contains(BELONG_SYS_TYPE_FSSC)) {
|
||||||
res = BELONG_SYS_TYPE_FSSC;
|
// res = BELONG_SYS_TYPE_FSSC;
|
||||||
}
|
// }
|
||||||
if (sysCode.equals(BELONG_SYS_CODE_H3BPM) || sysCode.contains(BELONG_SYS_TYPE_H3BPM)) {
|
// if (sysCode.equals(BELONG_SYS_CODE_H3BPM) || sysCode.contains(BELONG_SYS_TYPE_H3BPM)) {
|
||||||
res = BELONG_SYS_TYPE_H3BPM;
|
// res = BELONG_SYS_TYPE_H3BPM;
|
||||||
}
|
// }
|
||||||
if (sysCode.equals(BELONG_SYS_CODE_XNFSSC) || sysCode.contains(BELONG_SYS_TYPE_XNFSSC)) {
|
// if (sysCode.equals(BELONG_SYS_CODE_XNFSSC) || sysCode.contains(BELONG_SYS_TYPE_XNFSSC)) {
|
||||||
res = BELONG_SYS_TYPE_XNFSSC;
|
// res = BELONG_SYS_TYPE_XNFSSC;
|
||||||
}
|
// }
|
||||||
if (sysCode.equals(BELONG_SYS_CODE_ANFSSC) || sysCode.contains(BELONG_SYS_TYPE_ANFSSC)) {
|
// if (sysCode.equals(BELONG_SYS_CODE_ANFSSC) || sysCode.contains(BELONG_SYS_TYPE_ANFSSC)) {
|
||||||
res = BELONG_SYS_TYPE_ANFSSC;
|
// res = BELONG_SYS_TYPE_ANFSSC;
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
res = BELONG_SYS_TYPE_NOT;
|
// res = BELONG_SYS_TYPE_NOT;
|
||||||
}
|
// }
|
||||||
return res;
|
// return res;
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private OrderRecordBasic buildWithRecord(CTripCarRecord record) {
|
private OrderRecordBasic buildWithRecord(CTripCarRecord record) {
|
||||||
|
@ -90,7 +92,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
|
||||||
orderRecordBasic.setAccountCompanyName(cTripCarPassengerInfo.getCostCenter2());
|
orderRecordBasic.setAccountCompanyName(cTripCarPassengerInfo.getCostCenter2());
|
||||||
orderRecordBasic.setOfflineCcomyCode(cTripCarPassengerInfo.getCostCenter1());
|
orderRecordBasic.setOfflineCcomyCode(cTripCarPassengerInfo.getCostCenter1());
|
||||||
orderRecordBasic.setProjectOrderNo(cTripCarPassengerInfo.getCostCenter5());
|
orderRecordBasic.setProjectOrderNo(cTripCarPassengerInfo.getCostCenter5());
|
||||||
orderRecordBasic.setBelongSysType(getBeLongSysType(cTripCarPassengerInfo.getCostCenter3()));
|
orderRecordBasic.setBelongSysType(getBelongSysType(cTripCarPassengerInfo.getCostCenter3()));
|
||||||
return orderRecordBasic;
|
return orderRecordBasic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,7 +290,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
|
||||||
orderRecordBasic.setAccountCompanyName(cTripFlightBaseInfo.getCostCenter2());
|
orderRecordBasic.setAccountCompanyName(cTripFlightBaseInfo.getCostCenter2());
|
||||||
orderRecordBasic.setOfflineCcomyCode(cTripFlightBaseInfo.getCostCenter());
|
orderRecordBasic.setOfflineCcomyCode(cTripFlightBaseInfo.getCostCenter());
|
||||||
orderRecordBasic.setProjectOrderNo(cTripFlightBaseInfo.getCostCenter5());
|
orderRecordBasic.setProjectOrderNo(cTripFlightBaseInfo.getCostCenter5());
|
||||||
orderRecordBasic.setBelongSysType(getBeLongSysType(cTripFlightBaseInfo.getCostCenter3()));
|
orderRecordBasic.setBelongSysType(getBelongSysType(cTripFlightBaseInfo.getCostCenter3()));
|
||||||
return orderRecordBasic;
|
return orderRecordBasic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,7 +505,7 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
|
||||||
orderRecordBasic.setAccountCompanyName(cTripHotelOrderDetail.getCostCenter2());
|
orderRecordBasic.setAccountCompanyName(cTripHotelOrderDetail.getCostCenter2());
|
||||||
orderRecordBasic.setOfflineCcomyCode(cTripHotelOrderDetail.getCostCenter());
|
orderRecordBasic.setOfflineCcomyCode(cTripHotelOrderDetail.getCostCenter());
|
||||||
orderRecordBasic.setProjectOrderNo(cTripHotelOrderDetail.getCostCenter5());
|
orderRecordBasic.setProjectOrderNo(cTripHotelOrderDetail.getCostCenter5());
|
||||||
orderRecordBasic.setBelongSysType(getBeLongSysType(cTripHotelOrderDetail.getCostCenter3()));
|
orderRecordBasic.setBelongSysType(getBelongSysType(cTripHotelOrderDetail.getCostCenter3()));
|
||||||
return orderRecordBasic;
|
return orderRecordBasic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,4 +11,7 @@ public interface AmapCarOrderRecordRepository {
|
||||||
List<AmapCarOrderRecord> findByOrderIds(List<String> orderIds);
|
List<AmapCarOrderRecord> findByOrderIds(List<String> orderIds);
|
||||||
|
|
||||||
List<AmapCarOrderRecord> findByDs(String ds);
|
List<AmapCarOrderRecord> findByDs(String ds);
|
||||||
|
|
||||||
|
List<AmapCarOrderRecord> findByOneDate(String oneDate);
|
||||||
|
List<AmapCarOrderRecord> findByDate(String date);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,27 +7,33 @@ import com.chint.domain.aggregates.order.order_record.OrderFlightRecord;
|
||||||
import com.chint.domain.aggregates.order.order_record.OrderHotelRecord;
|
import com.chint.domain.aggregates.order.order_record.OrderHotelRecord;
|
||||||
import com.chint.domain.aggregates.order.order_record.OrderTrainRecord;
|
import com.chint.domain.aggregates.order.order_record.OrderTrainRecord;
|
||||||
import com.chint.domain.aggregates.order.order_record.amap_order_record.AmapCarOrderRecord;
|
import com.chint.domain.aggregates.order.order_record.amap_order_record.AmapCarOrderRecord;
|
||||||
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripHotelRecord;
|
import com.chint.domain.factoriy.order_record.AmapOrderRecordExtensionFactory;
|
||||||
import com.chint.domain.factoriy.order_record.OrderRecordExtensionFactory;
|
import com.chint.domain.factoriy.order_record.OrderRecordExtensionFactory;
|
||||||
import com.chint.domain.factoriy.order_record.OrderRecordFactorySelector;
|
import com.chint.domain.factoriy.order_record.OrderRecordFactorySelector;
|
||||||
import com.chint.domain.repository.AmapCarOrderRecordRepository;
|
import com.chint.domain.repository.AmapCarOrderRecordRepository;
|
||||||
import com.chint.domain.service.OrderDetailDomainService;
|
import com.chint.domain.service.OrderDetailDomainService;
|
||||||
import com.chint.domain.service.RouteRequestDomainService;
|
import com.chint.domain.service.RouteRequestDomainService;
|
||||||
|
import com.chint.domain.service.supplier.SupplierAdapterSelector;
|
||||||
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
|
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
|
||||||
|
import com.chint.infrastructure.util.DateTimeUtil;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP;
|
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP;
|
||||||
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
|
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class AmapOrderRecordDomainService implements OrderRecordDomainService{
|
public class AmapOrderRecordGenerator implements OrderRecordGenerator {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AmapCarOrderRecordRepository aMapCarOrderRecordRepository;
|
private AmapCarOrderRecordRepository aMapCarOrderRecordRepository;
|
||||||
|
@ -41,29 +47,67 @@ public class AmapOrderRecordDomainService implements OrderRecordDomainService{
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderDetailDomainService orderDetailDomainService;
|
private OrderDetailDomainService orderDetailDomainService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SupplierAdapterSelector supplierAdapterSelector;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<OrderHotelRecord> generateHotelRecord(OrderRecordGenerateCommand command) {
|
public List<OrderHotelRecord> generateHotelRecord(OrderRecordGenerateCommand command) {
|
||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OrderHotelRecord> generateHotelRecordMultiParam(OrderRecordGenerateCommand command) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<OrderTrainRecord> generateTrainRecord(OrderRecordGenerateCommand command) {
|
public List<OrderTrainRecord> generateTrainRecord(OrderRecordGenerateCommand command) {
|
||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OrderTrainRecord> generateTrainRecordMultiParam(OrderRecordGenerateCommand command) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<OrderFlightRecord> generateFlightRecord(OrderRecordGenerateCommand command) {
|
public List<OrderFlightRecord> generateFlightRecord(OrderRecordGenerateCommand command) {
|
||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OrderFlightRecord> generateFlightRecordMultiParam(OrderRecordGenerateCommand command) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
@ListenTo(command = "OrderRecordGenerateCommand", order = 0)
|
@ListenTo(command = "OrderRecordGenerateCommand", order = 0)
|
||||||
@Override
|
@Override
|
||||||
public List<OrderCarRecord> generateCarRecord(OrderRecordGenerateCommand command) {
|
public List<OrderCarRecord> generateCarRecord(OrderRecordGenerateCommand command) {
|
||||||
if (!command.getSupplierName().equals(SUPPLIER_AMAP)) {
|
if (!command.getSupplierName().equals(SUPPLIER_AMAP)) {
|
||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
List<AmapCarOrderRecord> amapCarOrderRecordList = aMapCarOrderRecordRepository.findByDs(command.getDate());
|
return getOrderCarRecords(command);
|
||||||
OrderRecordExtensionFactory orderRecordExtensionFactory = orderRecordFactorySelector.extensionFactoryOfSupplierName(SUPPLIER_C_TRIP);
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OrderCarRecord> generateCarRecordMultiParam(OrderRecordGenerateCommand command) {
|
||||||
|
return getOrderCarRecords(command);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<OrderCarRecord> getOrderCarRecords(OrderRecordGenerateCommand command) {
|
||||||
|
List<AmapCarOrderRecord> amapCarOrderRecordList;
|
||||||
|
String oneDate = command.getOneDate();
|
||||||
|
String date = command.getDate();
|
||||||
|
if (oneDate != null) {
|
||||||
|
amapCarOrderRecordList = aMapCarOrderRecordRepository.findByDs(oneDate);
|
||||||
|
} else
|
||||||
|
amapCarOrderRecordList = aMapCarOrderRecordRepository.findByDate(Objects
|
||||||
|
.requireNonNullElseGet(date, () -> DateTimeUtil.timeToStrYYYYMMDD(LocalDateTime.now().minusDays(1))));
|
||||||
|
return mapToCarRecord(amapCarOrderRecordList);
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<OrderCarRecord> mapToCarRecord(List<AmapCarOrderRecord> amapCarOrderRecordList) {
|
||||||
|
OrderRecordExtensionFactory orderRecordExtensionFactory = supplierAdapterSelector.of(SUPPLIER_AMAP, OrderRecordExtensionFactory.class);
|
||||||
List<String> routeOrderNoList = amapCarOrderRecordList.stream().map(AmapCarOrderRecord::getOutApplyRecordId).distinct().toList();
|
List<String> routeOrderNoList = amapCarOrderRecordList.stream().map(AmapCarOrderRecord::getOutApplyRecordId).distinct().toList();
|
||||||
List<RouteOrder> routeOrderList = routeRequestDomainService.getRouteOrder(routeOrderNoList);
|
List<RouteOrder> routeOrderList = routeRequestDomainService.getRouteOrder(routeOrderNoList);
|
||||||
// 根据RouteOrder的checkIfMine方法,创建一个包含自己订单的Map
|
// 根据RouteOrder的checkIfMine方法,创建一个包含自己订单的Map
|
|
@ -16,10 +16,12 @@ import com.chint.domain.repository.CTripOrderDetailRepository;
|
||||||
import com.chint.domain.repository.RouteRepository;
|
import com.chint.domain.repository.RouteRepository;
|
||||||
import com.chint.domain.service.OrderDetailDomainService;
|
import com.chint.domain.service.OrderDetailDomainService;
|
||||||
import com.chint.domain.service.RouteRequestDomainService;
|
import com.chint.domain.service.RouteRequestDomainService;
|
||||||
|
import com.chint.domain.service.supplier.SupplierAdapterSelector;
|
||||||
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
|
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
@ -29,7 +31,7 @@ import java.util.stream.Collectors;
|
||||||
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
|
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class CTripOrderRecordDomainService implements OrderRecordDomainService {
|
public class CTripOrderRecordGenerator implements OrderRecordGenerator {
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
|
@ -43,6 +45,9 @@ public class CTripOrderRecordDomainService implements OrderRecordDomainService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private RouteRequestDomainService routeRequestDomainService;
|
private RouteRequestDomainService routeRequestDomainService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SupplierAdapterSelector supplierAdapterSelector;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private RouteRepository routeRepository;
|
private RouteRepository routeRepository;
|
||||||
|
|
||||||
|
@ -52,16 +57,24 @@ public class CTripOrderRecordDomainService implements OrderRecordDomainService {
|
||||||
if (!command.getSupplierName().equals(SUPPLIER_C_TRIP)) {
|
if (!command.getSupplierName().equals(SUPPLIER_C_TRIP)) {
|
||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
List<CTripHotelRecord> records = cTripOrderDetailRepository.findHotelRecordByCreateTime(command.getStartTime(), command.getEndTime());
|
return generateHotelRecord(command.getStartTime(), command.getEndTime());
|
||||||
OrderRecordExtensionFactory orderRecordExtensionFactory = orderRecordFactorySelector.extensionFactoryOfSupplierName(SUPPLIER_C_TRIP);
|
}
|
||||||
|
|
||||||
|
public List<OrderHotelRecord> generateHotelRecordMultiParam(OrderRecordGenerateCommand command) {
|
||||||
|
command.generateStartAndEndTime();
|
||||||
|
return generateHotelRecord(command.getStartTime(), command.getEndTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<OrderHotelRecord> generateHotelRecord(LocalDateTime startTime, LocalDateTime endTime) {
|
||||||
|
List<CTripHotelRecord> records = cTripOrderDetailRepository.findHotelRecordByCreateTime(startTime, endTime);
|
||||||
|
OrderRecordExtensionFactory orderRecordExtensionFactory = supplierAdapterSelector.of(SUPPLIER_C_TRIP, OrderRecordExtensionFactory.class);
|
||||||
List<String> routeOrderNoList = records.stream().map(CTripHotelRecord::getRouteOrderNo).distinct().toList();
|
List<String> routeOrderNoList = records.stream().map(CTripHotelRecord::getRouteOrderNo).distinct().toList();
|
||||||
List<RouteOrder> routeOrderList = routeRequestDomainService.getRouteOrder(routeOrderNoList);
|
List<RouteOrder> routeOrderList = routeRequestDomainService.getRouteOrder(routeOrderNoList);
|
||||||
// 根据RouteOrder的checkIfMine方法,创建一个包含自己订单的Map
|
// 根据RouteOrder的checkIfMine方法,创建一个包含自己订单的Map
|
||||||
Map<String, Optional<RouteOrder>> collect = routeOrderNoList.parallelStream().collect(Collectors.toMap(Function.identity(),
|
Map<String, Optional<RouteOrder>> routeOrderMap = createRouteOrderMap(routeOrderNoList, routeOrderList);
|
||||||
it -> routeOrderList.stream().filter(routeOrder -> routeOrder != null && routeOrder.checkIfMine(it)).findFirst()));
|
|
||||||
List<OrderHotelRecord> orderHotelRecordList = records
|
List<OrderHotelRecord> orderHotelRecordList = records
|
||||||
.stream()
|
.stream()
|
||||||
.map(it -> orderRecordExtensionFactory.createHotelOrderRecord(it, collect.get(it.getRouteOrderNo())))
|
.map(it -> orderRecordExtensionFactory.createHotelOrderRecord(it, routeOrderMap.get(it.getRouteOrderNo())))
|
||||||
.toList();
|
.toList();
|
||||||
return orderDetailDomainService.saveHotelOrderRecordBatch(orderHotelRecordList);
|
return orderDetailDomainService.saveHotelOrderRecordBatch(orderHotelRecordList);
|
||||||
}
|
}
|
||||||
|
@ -72,42 +85,67 @@ public class CTripOrderRecordDomainService implements OrderRecordDomainService {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<OrderTrainRecord> generateTrainRecordMultiParam(OrderRecordGenerateCommand command) {
|
||||||
|
return List.of();
|
||||||
|
}
|
||||||
|
|
||||||
@ListenTo(command = "OrderRecordGenerateCommand", order = 1)
|
@ListenTo(command = "OrderRecordGenerateCommand", order = 1)
|
||||||
@Override
|
@Override
|
||||||
public List<OrderFlightRecord> generateFlightRecord(OrderRecordGenerateCommand command) {
|
public List<OrderFlightRecord> generateFlightRecord(OrderRecordGenerateCommand command) {
|
||||||
if (!command.getSupplierName().equals(SUPPLIER_C_TRIP)) {
|
if (!command.getSupplierName().equals(SUPPLIER_C_TRIP)) {
|
||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
List<CTripFlightRecord> records = cTripOrderDetailRepository.findFlightRecordByCreateTime(command.getStartTime(), command.getEndTime());
|
return generateFlightRecord(command.getStartTime(), command.getEndTime());
|
||||||
OrderRecordExtensionFactory orderRecordExtensionFactory = orderRecordFactorySelector.extensionFactoryOfSupplierName(SUPPLIER_C_TRIP);
|
}
|
||||||
|
|
||||||
|
public List<OrderFlightRecord> generateFlightRecordMultiParam(OrderRecordGenerateCommand command) {
|
||||||
|
command.generateStartAndEndTime();
|
||||||
|
return generateFlightRecord(command.getStartTime(), command.getEndTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private List<OrderFlightRecord> generateFlightRecord(LocalDateTime startTime, LocalDateTime endTime) {
|
||||||
|
List<CTripFlightRecord> records = cTripOrderDetailRepository.findFlightRecordByCreateTime(startTime, endTime);
|
||||||
|
OrderRecordExtensionFactory orderRecordExtensionFactory = supplierAdapterSelector.of(SUPPLIER_C_TRIP, OrderRecordExtensionFactory.class);
|
||||||
List<String> routeOrderNoList = records.stream().map(CTripFlightRecord::getRouteOrderNo).distinct().toList();
|
List<String> routeOrderNoList = records.stream().map(CTripFlightRecord::getRouteOrderNo).distinct().toList();
|
||||||
List<RouteOrder> routeOrderList = routeRequestDomainService.getRouteOrder(routeOrderNoList);
|
List<RouteOrder> routeOrderList = routeRequestDomainService.getRouteOrder(routeOrderNoList);
|
||||||
// 根据RouteOrder的checkIfMine方法,创建一个包含自己订单的Map
|
Map<String, Optional<RouteOrder>> routeOrderMap = createRouteOrderMap(routeOrderNoList, routeOrderList);
|
||||||
Map<String, Optional<RouteOrder>> collect = routeOrderNoList.parallelStream().collect(Collectors.toMap(Function.identity(),
|
List<OrderFlightRecord> orderFlightRecordList = records.stream()
|
||||||
it -> routeOrderList.stream().filter(routeOrder -> routeOrder != null && routeOrder.checkIfMine(it)).findFirst()));
|
.map(it -> orderRecordExtensionFactory.createFlightOrderRecord(it, routeOrderMap.get(it.getRouteOrderNo())))
|
||||||
List<OrderFlightRecord> orderFlightRecordList = records
|
|
||||||
.stream()
|
|
||||||
.map(it -> orderRecordExtensionFactory.createFlightOrderRecord(it, collect.get(it.getRouteOrderNo())))
|
|
||||||
.toList();
|
.toList();
|
||||||
return orderDetailDomainService.saveFlightOrderRecordBatch(orderFlightRecordList);
|
return orderDetailDomainService.saveFlightOrderRecordBatch(orderFlightRecordList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<String, Optional<RouteOrder>> createRouteOrderMap(List<String> routeOrderNoList, List<RouteOrder> routeOrderList) {
|
||||||
|
return routeOrderNoList.parallelStream().collect(Collectors.toMap(
|
||||||
|
Function.identity(),
|
||||||
|
it -> routeOrderList.stream().filter(routeOrder -> routeOrder != null && routeOrder.checkIfMine(it)).findFirst()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
@ListenTo(command = "OrderRecordGenerateCommand", order = 2)
|
@ListenTo(command = "OrderRecordGenerateCommand", order = 2)
|
||||||
@Override
|
@Override
|
||||||
public List<OrderCarRecord> generateCarRecord(OrderRecordGenerateCommand command) {
|
public List<OrderCarRecord> generateCarRecord(OrderRecordGenerateCommand command) {
|
||||||
if (!command.getSupplierName().equals(SUPPLIER_C_TRIP)) {
|
if (!command.getSupplierName().equals(SUPPLIER_C_TRIP)) {
|
||||||
return List.of();
|
return List.of();
|
||||||
}
|
}
|
||||||
List<CTripCarRecord> records = cTripOrderDetailRepository.findCarRecordByCreateTime(command.getStartTime(), command.getEndTime());
|
return generateCarRecord(command.getStartTime(), command.getEndTime());
|
||||||
OrderRecordExtensionFactory orderRecordExtensionFactory = orderRecordFactorySelector.extensionFactoryOfSupplierName(SUPPLIER_C_TRIP);
|
}
|
||||||
|
|
||||||
|
public List<OrderCarRecord> generateCarRecordMultiParam(OrderRecordGenerateCommand command){
|
||||||
|
command.generateStartAndEndTime();
|
||||||
|
return generateCarRecord(command.getStartTime(), command.getEndTime());
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<OrderCarRecord> generateCarRecord(LocalDateTime startTime, LocalDateTime endTime){
|
||||||
|
List<CTripCarRecord> records = cTripOrderDetailRepository.findCarRecordByCreateTime(startTime, endTime);
|
||||||
|
OrderRecordExtensionFactory orderRecordExtensionFactory = supplierAdapterSelector.of(SUPPLIER_C_TRIP, OrderRecordExtensionFactory.class);
|
||||||
List<String> routeOrderNoList = records.stream().map(CTripCarRecord::getRouteOrderNo).distinct().toList();
|
List<String> routeOrderNoList = records.stream().map(CTripCarRecord::getRouteOrderNo).distinct().toList();
|
||||||
List<RouteOrder> routeOrderList = routeRequestDomainService.getRouteOrder(routeOrderNoList);
|
List<RouteOrder> routeOrderList = routeRequestDomainService.getRouteOrder(routeOrderNoList);
|
||||||
// 根据RouteOrder的checkIfMine方法,创建一个包含自己订单的Map
|
Map<String, Optional<RouteOrder>> routeOrderMap = createRouteOrderMap(routeOrderNoList, routeOrderList);
|
||||||
Map<String, Optional<RouteOrder>> collect = routeOrderNoList.parallelStream().collect(Collectors.toMap(Function.identity(),
|
List<OrderCarRecord> orderCarRecordList = records.stream()
|
||||||
it -> routeOrderList.stream().filter(routeOrder -> routeOrder != null && routeOrder.checkIfMine(it)).findFirst()));
|
.map(it -> orderRecordExtensionFactory.createCarOrderRecord(it, routeOrderMap.get(it.getRouteOrderNo())))
|
||||||
List<OrderCarRecord> orderCarRecordList = records
|
|
||||||
.stream()
|
|
||||||
.map(it -> orderRecordExtensionFactory.createCarOrderRecord(it, collect.get(it.getRouteOrderNo())))
|
|
||||||
.toList();
|
.toList();
|
||||||
return orderDetailDomainService.saveCarOrderRecordBatch(orderCarRecordList);
|
return orderDetailDomainService.saveCarOrderRecordBatch(orderCarRecordList);
|
||||||
}
|
}
|
|
@ -9,9 +9,13 @@ import com.chint.domain.service.supplier.SupplierAdapter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public interface OrderRecordDomainService extends SupplierAdapter {
|
public interface OrderRecordGenerator extends SupplierAdapter {
|
||||||
List<OrderHotelRecord> generateHotelRecord(OrderRecordGenerateCommand command);
|
List<OrderHotelRecord> generateHotelRecord(OrderRecordGenerateCommand command);
|
||||||
|
List<OrderHotelRecord> generateHotelRecordMultiParam(OrderRecordGenerateCommand command);
|
||||||
List<OrderTrainRecord> generateTrainRecord(OrderRecordGenerateCommand command);
|
List<OrderTrainRecord> generateTrainRecord(OrderRecordGenerateCommand command);
|
||||||
|
List<OrderTrainRecord> generateTrainRecordMultiParam(OrderRecordGenerateCommand command);
|
||||||
List<OrderFlightRecord> generateFlightRecord(OrderRecordGenerateCommand command);
|
List<OrderFlightRecord> generateFlightRecord(OrderRecordGenerateCommand command);
|
||||||
|
List<OrderFlightRecord> generateFlightRecordMultiParam(OrderRecordGenerateCommand command);
|
||||||
List<OrderCarRecord> generateCarRecord(OrderRecordGenerateCommand command);
|
List<OrderCarRecord> generateCarRecord(OrderRecordGenerateCommand command);
|
||||||
|
List<OrderCarRecord> generateCarRecordMultiParam(OrderRecordGenerateCommand command);
|
||||||
}
|
}
|
|
@ -1,10 +1,13 @@
|
||||||
package com.chint.domain.service.supplier;
|
package com.chint.domain.service.supplier;
|
||||||
|
|
||||||
import com.chint.domain.exceptions.NotFoundException;
|
import com.chint.domain.exceptions.NotFoundException;
|
||||||
|
import com.chint.domain.service.order_record.OrderRecordGenerator;
|
||||||
import jakarta.annotation.PostConstruct;
|
import jakarta.annotation.PostConstruct;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.context.ApplicationListener;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
@ -14,7 +17,7 @@ import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Component
|
@Component
|
||||||
public class SupplierAdapterSelector {
|
public class SupplierAdapterSelector implements ApplicationListener<ApplicationReadyEvent> {
|
||||||
|
|
||||||
private final Map<String, Map<Class<?>, SupplierAdapter>> adapterMap = new HashMap<>();
|
private final Map<String, Map<Class<?>, SupplierAdapter>> adapterMap = new HashMap<>();
|
||||||
|
|
||||||
|
@ -23,14 +26,7 @@ public class SupplierAdapterSelector {
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
log.info("开始注入供应商适配器到选择器。。。。。");
|
|
||||||
Map<String, SupplierAdapter> beansOfType = applicationContext.getBeansOfType(SupplierAdapter.class);
|
|
||||||
for (SupplierAdapter adapter : beansOfType.values()) {
|
|
||||||
String supplierName = adapter.getSupplierName();
|
|
||||||
adapterMap
|
|
||||||
.computeIfAbsent(supplierName, k -> new HashMap<>())
|
|
||||||
.put(adapter.getClass().getInterfaces()[0], adapter);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
@ -45,4 +41,16 @@ public class SupplierAdapterSelector {
|
||||||
}
|
}
|
||||||
return (T) adapter;
|
return (T) adapter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onApplicationEvent(ApplicationReadyEvent event) {
|
||||||
|
log.info("开始注入供应商适配器到选择器。。。。。");
|
||||||
|
Map<String, SupplierAdapter> beansOfType = applicationContext.getBeansOfType(SupplierAdapter.class);
|
||||||
|
for (SupplierAdapter adapter : beansOfType.values()) {
|
||||||
|
String supplierName = adapter.getSupplierName();
|
||||||
|
adapterMap
|
||||||
|
.computeIfAbsent(supplierName, k -> new HashMap<>())
|
||||||
|
.put(adapter.getClass().getInterfaces()[0], adapter);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,12 +84,15 @@ public class SupplierServiceImpl implements SupplierService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private BPMOrderDomainService bpmOrderDomainService;
|
private BPMOrderDomainService bpmOrderDomainService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SupplierAdapterSelector supplierAdapterSelector;
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Override
|
@Override
|
||||||
public OrderDetail handleSupplierCallback(SupplierCallbackData callbackData) {
|
public OrderDetail handleSupplierCallback(SupplierCallbackData callbackData) {
|
||||||
String supplierName = callbackData.getSupplierName();
|
String supplierName = callbackData.getSupplierName();
|
||||||
Optional<OrderLegData> data = orderDataAdapterSelector.of(supplierName).adapt(callbackData);
|
Optional<OrderLegData> data = supplierAdapterSelector.of(supplierName, OrderDataAdapter.class).adapt(callbackData);
|
||||||
if (data.isPresent()) {
|
if (data.isPresent()) {
|
||||||
OrderLegData orderLegData = data.get();
|
OrderLegData orderLegData = data.get();
|
||||||
return processOrderLegData(orderLegData, callbackData);
|
return processOrderLegData(orderLegData, callbackData);
|
||||||
|
@ -102,8 +105,8 @@ public class SupplierServiceImpl implements SupplierService {
|
||||||
RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(orderLegData.getSelfOrderNo());
|
RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(orderLegData.getSelfOrderNo());
|
||||||
String supplierName = callbackData.getSupplierName();
|
String supplierName = callbackData.getSupplierName();
|
||||||
OrderDetail orderDetail = routeUpdateOrder(orderLegData, routeOrder);
|
OrderDetail orderDetail = routeUpdateOrder(orderLegData, routeOrder);
|
||||||
List<OrderStatusChangeCommand> commandList = orderDataAdapterSelector
|
List<OrderStatusChangeCommand> commandList = supplierAdapterSelector
|
||||||
.of(supplierName)
|
.of(supplierName, OrderDataAdapter.class)
|
||||||
.orderStatusToCommand(routeOrder, callbackData)
|
.orderStatusToCommand(routeOrder, callbackData)
|
||||||
.stream()
|
.stream()
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
|
@ -113,7 +116,7 @@ public class SupplierServiceImpl implements SupplierService {
|
||||||
command.routeOrder(routeOrder);
|
command.routeOrder(routeOrder);
|
||||||
orderDetailStatusChange(command);
|
orderDetailStatusChange(command);
|
||||||
}
|
}
|
||||||
OrderExtensionFactory orderExtensionFactory = orderExtensionCreator.of(orderLegData.getSupplierName());
|
OrderExtensionFactory orderExtensionFactory = supplierAdapterSelector.of(supplierName, OrderExtensionFactory.class);
|
||||||
switch (orderLegData.getProductType()) {
|
switch (orderLegData.getProductType()) {
|
||||||
case LegConstant.LEG_TYPE_TRAIN ->
|
case LegConstant.LEG_TYPE_TRAIN ->
|
||||||
addTrainOrderData(orderDetail, orderLegData, orderExtensionFactory, routeOrder);
|
addTrainOrderData(orderDetail, orderLegData, orderExtensionFactory, routeOrder);
|
||||||
|
@ -144,8 +147,8 @@ public class SupplierServiceImpl implements SupplierService {
|
||||||
OrderDetail orderDetail = (OrderDetail) byPropertyName.getValue();
|
OrderDetail orderDetail = (OrderDetail) byPropertyName.getValue();
|
||||||
|
|
||||||
Integer productType = orderLegData.getProductType();
|
Integer productType = orderLegData.getProductType();
|
||||||
OrderExtensionFactory orderExtensionFactory = orderExtensionCreator
|
OrderExtensionFactory orderExtensionFactory = supplierAdapterSelector.of(orderLegData.getSupplierName()
|
||||||
.of(orderLegData.getSupplierName());
|
, OrderExtensionFactory.class);
|
||||||
|
|
||||||
//根据产品的不同类型添加不同的扩展字段
|
//根据产品的不同类型添加不同的扩展字段
|
||||||
switch (productType) {
|
switch (productType) {
|
||||||
|
@ -661,7 +664,7 @@ public class SupplierServiceImpl implements SupplierService {
|
||||||
trainOrderDetail.setCreateTime(command.getCreateTime());
|
trainOrderDetail.setCreateTime(command.getCreateTime());
|
||||||
trainOrderDetail.setId(null);
|
trainOrderDetail.setId(null);
|
||||||
if (orderDetail.getSupplierName().equals(SUPPLIER_L_Y)) {
|
if (orderDetail.getSupplierName().equals(SUPPLIER_L_Y)) {
|
||||||
trainOrderDetail = orderExtensionCreator.of(SUPPLIER_L_Y).updateTrainOrderDetailData(trainOrderDetail, command.getOrderInfo());
|
trainOrderDetail = supplierAdapterSelector.of(SUPPLIER_L_Y, OrderExtensionFactory.class).updateTrainOrderDetailData(trainOrderDetail, command.getOrderInfo());
|
||||||
}
|
}
|
||||||
trainOrderDetail.setDetailId(newOrderNo);
|
trainOrderDetail.setDetailId(newOrderNo);
|
||||||
orderDetail.setTrainOrderDetail(trainOrderDetail);
|
orderDetail.setTrainOrderDetail(trainOrderDetail);
|
||||||
|
@ -676,9 +679,9 @@ public class SupplierServiceImpl implements SupplierService {
|
||||||
flightOrderDetail.setCreateTime(command.getCreateTime());
|
flightOrderDetail.setCreateTime(command.getCreateTime());
|
||||||
flightOrderDetail.setId(null);
|
flightOrderDetail.setId(null);
|
||||||
if (orderDetail.getSupplierName().equals(SUPPLIER_C_TRIP)) {
|
if (orderDetail.getSupplierName().equals(SUPPLIER_C_TRIP)) {
|
||||||
flightOrderDetail = orderExtensionCreator.of(SUPPLIER_C_TRIP).updateFlightOrderDetailData(flightOrderDetail, command.getOrderInfo());
|
flightOrderDetail = supplierAdapterSelector.of(SUPPLIER_C_TRIP, OrderExtensionFactory.class).updateFlightOrderDetailData(flightOrderDetail, command.getOrderInfo());
|
||||||
} else {
|
} else if (orderDetail.getSupplierName().equals(SUPPLIER_L_Y)) {
|
||||||
flightOrderDetail = orderExtensionCreator.of(SUPPLIER_L_Y).updateFlightOrderDetailData(flightOrderDetail, command.getOrderInfo());
|
flightOrderDetail = supplierAdapterSelector.of(SUPPLIER_L_Y, OrderExtensionFactory.class).updateFlightOrderDetailData(flightOrderDetail, command.getOrderInfo());
|
||||||
}
|
}
|
||||||
flightOrderDetail.setDetailId(newOrderNo);
|
flightOrderDetail.setDetailId(newOrderNo);
|
||||||
orderDetail.setFlightOrderDetail(flightOrderDetail);
|
orderDetail.setFlightOrderDetail(flightOrderDetail);
|
||||||
|
@ -700,7 +703,7 @@ public class SupplierServiceImpl implements SupplierService {
|
||||||
}
|
}
|
||||||
hotelOrderDetail.setCustomers(newCustomers);
|
hotelOrderDetail.setCustomers(newCustomers);
|
||||||
if (orderDetail.getSupplierName().equals(SUPPLIER_L_Y)) {
|
if (orderDetail.getSupplierName().equals(SUPPLIER_L_Y)) {
|
||||||
hotelOrderDetail = orderExtensionCreator.of(SUPPLIER_L_Y).updateHotelOrderDetailData(hotelOrderDetail, command.getOrderInfo());
|
hotelOrderDetail = supplierAdapterSelector.of(SUPPLIER_L_Y, OrderExtensionFactory.class).updateHotelOrderDetailData(hotelOrderDetail, command.getOrderInfo());
|
||||||
}
|
}
|
||||||
hotelOrderDetail.setDetailId(newOrderNo);
|
hotelOrderDetail.setDetailId(newOrderNo);
|
||||||
orderDetail.setHotelOrderDetail(hotelOrderDetail);
|
orderDetail.setHotelOrderDetail(hotelOrderDetail);
|
||||||
|
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.chint.domain.service.supplier;
|
||||||
|
|
||||||
|
import static com.chint.infrastructure.constant.BelongSystemConstant.*;
|
||||||
|
|
||||||
|
public class SupplierUtil {
|
||||||
|
public static String getBelongSysType(String sysCode) {
|
||||||
|
String res = null;
|
||||||
|
if (sysCode != null) {
|
||||||
|
if (sysCode.equals(BELONG_SYS_CODE_FSSC) || sysCode.contains(BELONG_SYS_TYPE_FSSC)) {
|
||||||
|
res = BELONG_SYS_TYPE_FSSC;
|
||||||
|
}
|
||||||
|
if (sysCode.equals(BELONG_SYS_CODE_H3BPM) || sysCode.contains(BELONG_SYS_TYPE_H3BPM)) {
|
||||||
|
res = BELONG_SYS_TYPE_H3BPM;
|
||||||
|
}
|
||||||
|
if (sysCode.equals(BELONG_SYS_CODE_XNFSSC) || sysCode.contains(BELONG_SYS_TYPE_XNFSSC)) {
|
||||||
|
res = BELONG_SYS_TYPE_XNFSSC;
|
||||||
|
}
|
||||||
|
if (sysCode.equals(BELONG_SYS_CODE_ANFSSC) || sysCode.contains(BELONG_SYS_TYPE_ANFSSC)) {
|
||||||
|
res = BELONG_SYS_TYPE_ANFSSC;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
res = BELONG_SYS_TYPE_NOT;
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
|
@ -15,4 +15,5 @@ public class SupplierNameConstant {
|
||||||
public static final String SUPPLIER_AMAP_CN_NAME = "高德";
|
public static final String SUPPLIER_AMAP_CN_NAME = "高德";
|
||||||
public static final String SUPPLIER_AMAP_EXTENSION_NAME = "高德预定";
|
public static final String SUPPLIER_AMAP_EXTENSION_NAME = "高德预定";
|
||||||
public static final String SUPPLIER_AMAP_BPM_NAME = "高德商旅";
|
public static final String SUPPLIER_AMAP_BPM_NAME = "高德商旅";
|
||||||
|
public static final String SUPPLIER_AMAP_FSSC = "GD";
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,4 +31,14 @@ public class AmapCarOrderRecordRepositoryImpl implements AmapCarOrderRecordRepos
|
||||||
public List<AmapCarOrderRecord> findByDs(String ds) {
|
public List<AmapCarOrderRecord> findByDs(String ds) {
|
||||||
return jdbcAmapCarOrderRecordRepository.findByDsContaining(ds);
|
return jdbcAmapCarOrderRecordRepository.findByDsContaining(ds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AmapCarOrderRecord> findByOneDate(String oneDate) {
|
||||||
|
return jdbcAmapCarOrderRecordRepository.findByDs(oneDate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AmapCarOrderRecord> findByDate(String date) {
|
||||||
|
return jdbcAmapCarOrderRecordRepository.findByDsContaining(date);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,5 +10,6 @@ import java.util.List;
|
||||||
@Repository
|
@Repository
|
||||||
public interface JdbcAmapCarOrderRecordRepository extends CrudRepository<AmapCarOrderRecord, Long> {
|
public interface JdbcAmapCarOrderRecordRepository extends CrudRepository<AmapCarOrderRecord, Long> {
|
||||||
List<AmapCarOrderRecord> findByDsContaining(String ds);
|
List<AmapCarOrderRecord> findByDsContaining(String ds);
|
||||||
|
List<AmapCarOrderRecord> findByDs(String ds);
|
||||||
List<AmapCarOrderRecord> findByAmapOrderIdIn(Collection<String> amapOrderId);
|
List<AmapCarOrderRecord> findByAmapOrderIdIn(Collection<String> amapOrderId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,7 @@ public class CTripOrderRecordAutoSave {
|
||||||
OrderHotelResponse response = Optional.ofNullable(command.getOneDate())
|
OrderHotelResponse response = Optional.ofNullable(command.getOneDate())
|
||||||
.map(cTripOrderDetailRequest::getHotelOrder)
|
.map(cTripOrderDetailRequest::getHotelOrder)
|
||||||
.or(() -> Optional.ofNullable(command.getDate())
|
.or(() -> Optional.ofNullable(command.getDate())
|
||||||
.flatMap(it -> Optional.ofNullable(cTripOrderDetailRequest.getHotelOrder(it))))
|
.flatMap(it -> Optional.ofNullable(cTripOrderDetailRequest.getHotelOrderByDate(it))))
|
||||||
.orElseGet(cTripOrderDetailRequest::getHotelOrder);
|
.orElseGet(cTripOrderDetailRequest::getHotelOrder);
|
||||||
cTripHotelRecordAutoSave(response);
|
cTripHotelRecordAutoSave(response);
|
||||||
}
|
}
|
||||||
|
@ -234,9 +234,9 @@ public class CTripOrderRecordAutoSave {
|
||||||
|
|
||||||
public void cTripCarRecordAutoSave(OrderRecordGenerateCommand command){
|
public void cTripCarRecordAutoSave(OrderRecordGenerateCommand command){
|
||||||
OrderCarResponse response = Optional.ofNullable(command.getOneDate())
|
OrderCarResponse response = Optional.ofNullable(command.getOneDate())
|
||||||
.map(cTripOrderDetailRequest::getCarOrder)
|
.flatMap(oneDate -> Optional.ofNullable(cTripOrderDetailRequest.getCarOrder(oneDate)))
|
||||||
.or(() -> Optional.ofNullable(command.getDate())
|
.or(() -> Optional.ofNullable(command.getDate())
|
||||||
.flatMap(it -> Optional.ofNullable(cTripOrderDetailRequest.getCarOrder(it))))
|
.flatMap(it -> Optional.ofNullable(cTripOrderDetailRequest.getCarOrderByDate(it))))
|
||||||
.orElseGet(cTripOrderDetailRequest::getCarOrder);
|
.orElseGet(cTripOrderDetailRequest::getCarOrder);
|
||||||
cTripCarRecordAutoSave(response);
|
cTripCarRecordAutoSave(response);
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,16 +114,17 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
||||||
rankName = DEFAULT_RANK_NAME;
|
rankName = DEFAULT_RANK_NAME;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Ranks ranks = rankDomainService.queryRanks(rankName, user.getCompanyCode());
|
||||||
|
if (ranks == null) {
|
||||||
if (rankName.contains("L")) {
|
if (rankName.contains("L")) {
|
||||||
rankName = rankName.replace("L", "P");
|
rankName = rankName.replace("L", "P");
|
||||||
}
|
}
|
||||||
Ranks ranks = rankDomainService.queryRanks(rankName, user.getCompanyCode());
|
ranks = rankDomainService.queryRanks(rankName, user.getCompanyCode());
|
||||||
if (ranks != null) {
|
|
||||||
user.setStandardLevel(ranks.getStandardLevel());
|
|
||||||
} else {
|
|
||||||
ranks = rankDomainService.queryRanks(rankName, JT_COMPANY_CODE);
|
|
||||||
user.setStandardLevel(ranks.getStandardLevel());
|
|
||||||
}
|
}
|
||||||
|
if (ranks == null) {
|
||||||
|
ranks = rankDomainService.queryRanks(rankName, JT_COMPANY_CODE);
|
||||||
|
}
|
||||||
|
user.setStandardLevel(ranks.getStandardLevel());
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -250,7 +250,7 @@ public class CTripTest {
|
||||||
@Test
|
@Test
|
||||||
void search() {
|
void search() {
|
||||||
BaseContext.setCurrentUser(user);
|
BaseContext.setCurrentUser(user);
|
||||||
SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("31839097186");
|
SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("32430240547");
|
||||||
System.out.println(response);
|
System.out.println(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -310,7 +310,7 @@ class RouteApplicationTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void loginSign() {
|
void loginSign() {
|
||||||
String sfno = "190506003";
|
String sfno = "190401151";
|
||||||
String syscode = "FSSC";
|
String syscode = "FSSC";
|
||||||
String billcode = "CLSQ240225000099";
|
String billcode = "CLSQ240225000099";
|
||||||
String companycode = "正泰集团股份有限公司";
|
String companycode = "正泰集团股份有限公司";
|
||||||
|
|
Loading…
Reference in New Issue