fix: 修复行程规划明细,订单订单明细缺失的问题

This commit is contained in:
lulz1 2024-06-19 14:32:22 +08:00
parent b4bd0fd02b
commit 78c4bb7812
36 changed files with 436 additions and 207 deletions

View File

@ -0,0 +1,16 @@
package com.chint.application.commands;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.infrastructure.echo_framework.command.Command;
import lombok.Data;
@Data
public class RouteAutoSyncCommand extends Command {
private RouteOrder routeOrder;
public RouteAutoSyncCommand route(RouteOrder routeOrder) {
this.routeOrder = routeOrder;
return this;
}
}

View File

@ -4,7 +4,9 @@ import com.chint.application.commands.LYOrderRecordGenerateCommand;
import com.chint.application.commands.OrderRecordGenerateCommand; import com.chint.application.commands.OrderRecordGenerateCommand;
import com.chint.application.dtos.RecordMonthSaveDTO; import com.chint.application.dtos.RecordMonthSaveDTO;
import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.system.SystemAnnouncement;
import com.chint.domain.factoriy.order_record.LyStatementOrder; import com.chint.domain.factoriy.order_record.LyStatementOrder;
import com.chint.domain.repository.SystemAnnouncementRepository;
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.OrderRecordGenerator;
import com.chint.domain.service.order_record.OrderRecordPuller; import com.chint.domain.service.order_record.OrderRecordPuller;
@ -27,6 +29,9 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.util.List;
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS; import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
import static com.chint.infrastructure.constant.LegConstant.*; import static com.chint.infrastructure.constant.LegConstant.*;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP; import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP;
@ -56,6 +61,9 @@ public class AutoWorkController {
@Autowired @Autowired
private SupplierAdapterSelector supplierAdapterSelector; private SupplierAdapterSelector supplierAdapterSelector;
@Autowired
private SystemAnnouncementRepository systemAnnouncementRepository;
@ApiOperation("用户状态检查,离职用户将关闭开卡") @ApiOperation("用户状态检查,离职用户将关闭开卡")
@PostMapping("/user/status/check") @PostMapping("/user/status/check")
@ -198,4 +206,17 @@ public class AutoWorkController {
PageResult<RouteOrder> routeOrderPageResult = PageResult.totalPageNum(res.getTotalElements(), res.toList()); PageResult<RouteOrder> routeOrderPageResult = PageResult.totalPageNum(res.getTotalElements(), res.toList());
return Result.Success(SUCCESS, routeOrderPageResult); return Result.Success(SUCCESS, routeOrderPageResult);
} }
@ApiOperation("更新公告是否过期")
@PostMapping("/system/announcement/check/status")
public Result<String> updateSystemAnnouncementStatus() {
List<SystemAnnouncement> systemAnnouncements = systemAnnouncementRepository.findEffective()
.stream()
.filter(it -> it.getExpiryDate().isBefore(LocalDateTime.now()))
.peek(SystemAnnouncement::updateStatusByExpiryDate)
.toList();
systemAnnouncementRepository.saveAll(systemAnnouncements);
return Result.Success(SUCCESS);
}
} }

View File

@ -114,6 +114,12 @@ public class FSSCController {
if (extensionOptional.isPresent()) { if (extensionOptional.isPresent()) {
reDirectUrl = dataBaseUrl + extensionOptional.get().getFieldValue(); reDirectUrl = dataBaseUrl + extensionOptional.get().getFieldValue();
} }
//特殊处理
if(sysCode.getIfImmediateResponse() == 1){
reDirectUrl = sysCode.getSystemCodeUrl().getRedirectUrlDev();
} else {
reDirectUrl = sysCode.getSystemCodeUrl().getRedirectUrlProd();
}
} }
return reDirectUrl; return reDirectUrl;
} }

View File

@ -131,17 +131,15 @@ public class LoginController {
@ApiOperation("商旅平台移动端单点") @ApiOperation("商旅平台移动端单点")
@PostMapping("/login/sso/mobile") @PostMapping("/login/sso/mobile")
public Result<UserLoginResult> loginSSOMobile(@RequestBody UserLoginParam userLoginParam) { public Result<UserLoginResult> loginSSOMobile(@RequestBody UserLoginParam userLoginParam) {
String employeeNo = feishuLoginStrategy.login(userLoginParam.getCode()); String employeeNo = feishuLoginStrategy.login(userLoginParam.getCode());
String timespan = userLoginParam.getTimespan() + "-M";
userLoginParam.setTimespan(timespan);
userLoginParam.setSfno(employeeNo); userLoginParam.setSfno(employeeNo);
UserLoginResult userLoginResult = authenticateService UserLoginResult userLoginResult = authenticateService
.authenticateEmployeeNo(userLoginParam); .authenticateEmployeeNo(userLoginParam);
//异步执行更新用户信息到同程 //异步执行更新用户信息到同程
User currentUser = BaseContext.getCurrentUser(); User currentUser = BaseContext.getCurrentUser();
loginEventBoarder(currentUser); loginEventBoarder(currentUser);
return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult); return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult);
} }

View File

@ -3,6 +3,7 @@ package com.chint.application.out;
import com.chint.application.dtos.*; import com.chint.application.dtos.*;
import com.chint.application.dtos.mapper.RouteOrderMapper; import com.chint.application.dtos.mapper.RouteOrderMapper;
import com.chint.application.dtos.response.OrderDetailRes; import com.chint.application.dtos.response.OrderDetailRes;
import com.chint.application.dtos.response.RouteOrderPageRes;
import com.chint.application.queryies.OrderDetailQuery; import com.chint.application.queryies.OrderDetailQuery;
import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
@ -202,6 +203,13 @@ public class OrderDetailController {
return Result.Success(SUCCESS, orderDetailResPageResult); return Result.Success(SUCCESS, orderDetailResPageResult);
} }
// @ApiOperation("查询我的订单根据行程规划单分类")
// @PostMapping("/query/page/route")
// public Result<PageResult<OrderDetailRes>> queryOrderDetailByRoute(@RequestBody OrderDetailQueryParam orderDetailQueryParam) {
// PageResult<OrderDetailRes> orderDetailResPageResult = orderDetailPageQuery.orderDetailPageQuery(orderDetailQueryParam);
// return Result.Success(SUCCESS, orderDetailResPageResult);
// }
@ApiOperation("查询携程订单") @ApiOperation("查询携程订单")
@PostMapping("/public/query/cTrip") @PostMapping("/public/query/cTrip")
public Result<Object> queryOrderDetail(@RequestBody OrderDetailQueryParam orderDetailQueryParam) { public Result<Object> queryOrderDetail(@RequestBody OrderDetailQueryParam orderDetailQueryParam) {

View File

@ -2,6 +2,7 @@ package com.chint.application.queryies;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.chint.application.dtos.RoutOrderFieldParam; import com.chint.application.dtos.RoutOrderFieldParam;
import com.chint.application.dtos.mapper.OrderDetailMapper;
import com.chint.application.dtos.mapper.RouteOrderMapper; import com.chint.application.dtos.mapper.RouteOrderMapper;
import com.chint.application.dtos.response.*; import com.chint.application.dtos.response.*;
import com.chint.application.dtos.trip.*; import com.chint.application.dtos.trip.*;
@ -39,8 +40,7 @@ import java.util.stream.Stream;
import static com.chint.infrastructure.constant.FSSCConstant.*; import static com.chint.infrastructure.constant.FSSCConstant.*;
import static com.chint.infrastructure.constant.LegConstant.*; import static com.chint.infrastructure.constant.LegConstant.*;
import static com.chint.infrastructure.constant.LocationConstant.LOCATION_LEVEL_CITY; import static com.chint.infrastructure.constant.LocationConstant.*;
import static com.chint.infrastructure.constant.LocationConstant.LOCATION_LEVEL_COUNTY;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_CANCEL_NAME; import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_CANCEL_NAME;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_PREPARE_NAME; import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_PREPARE_NAME;
import static com.chint.infrastructure.constant.RouteConstant.*; import static com.chint.infrastructure.constant.RouteConstant.*;
@ -365,23 +365,27 @@ public class OrderQuery {
List<Location> locationListAfterNotNull = locationList.stream().filter(Objects::nonNull).toList(); List<Location> locationListAfterNotNull = locationList.stream().filter(Objects::nonNull).toList();
for (Location location : locationListAfterNotNull) { for (Location location : locationListAfterNotNull) {
if (location.getLocationEnName() == null) { if (location.getLocationEnName() == null) {
//这里的代码来补充地理位置的英文名 location.setLocationEnName(
Integer level = location.getLevel(); switch (location.getLocationType()) {
if (level.equals(LOCATION_LEVEL_CITY)) { case LOCATION_TYPE_CITY ->
PrefectureLevelCityInfoEntity cityInfo = prefectureLevelRepository.findByCityId(location.getCityId()); Optional.ofNullable(prefectureLevelRepository.findByCityId(location.getCityId()))
location.setLocationEnName(cityInfo.getCityEnName()); .map(PrefectureLevelCityInfoEntity::getCityEnName)
} else if (level.equals(LOCATION_LEVEL_COUNTY) && location.getLocationShortName().contains("D")) { .orElse("unknown");
DistrictPOIInfoEntity byCityId = districtInfoRepository.findByCityId(location.getCityId()); case LOCATION_TYPE_DISTRICT ->
location.setLocationEnName(byCityId.getDistrictEnName()); Optional.ofNullable(districtInfoRepository.findByCityId(location.getCityId()))
} else if (level.equals(LOCATION_LEVEL_COUNTY)) { .map(DistrictPOIInfoEntity::getDistrictEnName)
CountryLevelInfoEntity byCityId = countryLevelInfoRepository.findByCityId(location.getCityId()); .orElse("unknown");
location.setLocationEnName(byCityId.getCountyEnName()); case LOCATION_TYPE_COUNTY ->
} else { Optional.ofNullable(countryLevelInfoRepository.findByCityId(location.getCityId()))
location.setLocationEnName("unknown"); .map(CountryLevelInfoEntity::getCountyEnName)
.orElse("unknown");
default -> "unknown";
}
);
if (location.getLocationEnName() != null) {
locationRepository.save(location);
} }
locationRepository.saveAll(List.of(location));
} }
callbackDataBuilder.cityList() callbackDataBuilder.cityList()
.cityName(location.getLocationName()) .cityName(location.getLocationName())
@ -395,24 +399,20 @@ public class OrderQuery {
ScheduleDetail.ScheduleDetailBuilder scheduleDetailBuilder = ScheduleDetail ScheduleDetail.ScheduleDetailBuilder scheduleDetailBuilder = ScheduleDetail
.builder() .builder()
.legId(leg.getLegId()); .legId(leg.getLegId());
if (!leg.getLegType().equals(LEG_TYPE_OTHER)) { Location originLocation = leg.getOriginLocation();
Location originLocation = leg.getOriginLocation(); if (originLocation != null) {
if (originLocation != null) { scheduleDetailBuilder
scheduleDetailBuilder .startCity(originLocation.getLocationName())
.startCity(originLocation.getLocationName()) .startCityName(originLocation.getLocationName())
.startCityName(originLocation.getLocationName()) .startCityEnName(originLocation.getLocationEnName());
.startCityEnName(originLocation.getLocationEnName()); }
} Location destinationLocation = leg.getDestinationLocation();
if (destinationLocation != null) {
Location destinationLocation = leg.getDestinationLocation(); scheduleDetailBuilder
if (destinationLocation != null) { .endCityName(destinationLocation.getLocationName())
scheduleDetailBuilder .endCity(destinationLocation.getLocationName())
.endCityName(destinationLocation.getLocationName()) .endCityEnName(destinationLocation.getLocationEnName());
.endCity(destinationLocation.getLocationName())
.endCityEnName(destinationLocation.getLocationEnName());
}
} }
if (leg.getLegType().equals(LEG_TYPE_HOTEL)) { if (leg.getLegType().equals(LEG_TYPE_HOTEL)) {
scheduleDetailBuilder scheduleDetailBuilder
.roomCount("1") .roomCount("1")
@ -442,15 +442,6 @@ public class OrderQuery {
.locationList(locationList1.stream().map(LocationRes::copyFrom).toList()); .locationList(locationList1.stream().map(LocationRes::copyFrom).toList());
} }
} }
// if (leg.getLegType().equals(LEG_TYPE_OTHER) && Objects.requireNonNull(leg.getLegExtensionField()).getAmountType().equals(LEG_OTHER_AMOUNT_TYPE_VISA)) {
// scheduleDetailBuilder.expenseTypeId("6770f575013211eabce29fde958f48e4")
// .travelType("LOCAL_OTHER")
// .scheduleType("VISA");
// } else {
// scheduleDetailBuilder
// }
return scheduleDetailBuilder return scheduleDetailBuilder
.scheduleNum(leg.getLegNo()) .scheduleNum(leg.getLegNo())
.scheduleType(translateLegType(leg.getLegType())) .scheduleType(translateLegType(leg.getLegType()))
@ -486,6 +477,24 @@ public class OrderQuery {
return callbackDataBuilder.ScheduleDetail(scheduleDetails).done().build(); return callbackDataBuilder.ScheduleDetail(scheduleDetails).done().build();
} }
// private String getLocationEnName(Location location) {
// return switch (location.getLocationType()) {
// case LOCATION_TYPE_CITY -> Optional.ofNullable(prefectureLevelRepository.findByCityId(location.getCityId()))
// .map(PrefectureLevelCityInfoEntity::getCityEnName)
// .orElse("unknown");
// case LOCATION_TYPE_DISTRICT ->
// Optional.ofNullable(districtInfoRepository.findByCityId(location.getCityId()))
// .map(DistrictPOIInfoEntity::getDistrictEnName)
// .orElse("unknown");
// case LOCATION_TYPE_COUNTY ->
// Optional.ofNullable(countryLevelInfoRepository.findByCityId(location.getCityId()))
// .map(CountryLevelInfoEntity::getCountyEnName)
// .orElse("unknown");
// default -> "unknown";
// };
// }
private String translateLegType(Integer legType) { private String translateLegType(Integer legType) {
return switch (legType) { return switch (legType) {
case LegConstant.LEG_TYPE_TRAIN -> TRIP_CALLBACK_TRAIN_TYPE; case LegConstant.LEG_TYPE_TRAIN -> TRIP_CALLBACK_TRAIN_TYPE;
@ -499,7 +508,6 @@ public class OrderQuery {
public RouteOrderRes queryRouteRes(RouteOrder routeOrder) { public RouteOrderRes queryRouteRes(RouteOrder routeOrder) {
RouteOrderRes routeOrderRes = RouteOrderRes.copyFrom(routeOrder); RouteOrderRes routeOrderRes = RouteOrderRes.copyFrom(routeOrder);
List<Leg> legItems = routeOrder.getLegItems(); List<Leg> legItems = routeOrder.getLegItems();
if (legItems != null && !legItems.isEmpty()) { if (legItems != null && !legItems.isEmpty()) {
//这里使用领域事件进行检查leg的订单状态 用户每次想要查看行程都会进行一次检查 //这里使用领域事件进行检查leg的订单状态 用户每次想要查看行程都会进行一次检查
@ -510,16 +518,12 @@ public class OrderQuery {
List<OrderDetailRes> orderDetailResList = routeOrder List<OrderDetailRes> orderDetailResList = routeOrder
.getOrderDetails() .getOrderDetails()
.stream() .stream()
.map(OrderDetailRes::copyFrom) .filter(it -> !it.getOrderStatus().equals(ORDER_EVENT_CANCEL_NAME) && !it.getOrderStatus().equals(ORDER_EVENT_PREPARE_NAME))
.map(OrderDetailMapper::copyFromExtension)
.toList(); .toList();
User user = userRepository.findByUserEmployeeNo(routeOrder.getUserId()); User user = userRepository.findByUserEmployeeNo(routeOrder.getUserId());
routeOrderRes.setUserName(user.getName()); routeOrderRes.setUserName(user.getName());
routeOrderRes.setOrderDetailRes(orderDetailResList); routeOrderRes.setOrderDetailRes(orderDetailResList);
routeOrderRes.setOrderDetailRes(routeOrderRes
.getOrderDetailRes()
.stream()
.filter(it -> !it.getOrderStatus().equals(ORDER_EVENT_CANCEL_NAME) && !it.getOrderStatus().equals(ORDER_EVENT_PREPARE_NAME))
.toList());
} }
return routeOrderRes; return routeOrderRes;
} }

View File

@ -117,8 +117,8 @@ public class UserController {
@PostMapping("/add/role") @PostMapping("/add/role")
public Result<String> addRoleUser(@RequestBody RoleOrgParam roleOrgParam) { public Result<String> addRoleUser(@RequestBody RoleOrgParam roleOrgParam) {
//查询已有权限 //查询已有权限
List<RoleUser> exist=roleUserRepository.findByUserId(roleOrgParam.getUserId()); List<RoleUser> exist = roleUserRepository.findByUserId(roleOrgParam.getUserId());
List<Long> roleIdList=roleOrgParam.getRoleIdList(); List<Long> roleIdList = roleOrgParam.getRoleIdList();
roleIdList.removeAll(exist.stream().map(RoleUser::getRoleId).toList()); roleIdList.removeAll(exist.stream().map(RoleUser::getRoleId).toList());
if (roleIdList.isEmpty()) { if (roleIdList.isEmpty()) {
return Result.Success(); return Result.Success();
@ -174,6 +174,6 @@ public class UserController {
@ApiOperation("用户角色分页查询") @ApiOperation("用户角色分页查询")
@PostMapping("/role/pageQuery") @PostMapping("/role/pageQuery")
public Result<PageResult<?>> rolePageQuery(@RequestBody RolePageQuery rolePageQuery) { public Result<PageResult<?>> rolePageQuery(@RequestBody RolePageQuery rolePageQuery) {
return Result.Success(SUCCESS,userDomainService.userPageQuery(rolePageQuery)); return Result.Success(SUCCESS, userDomainService.userPageQuery(rolePageQuery));
} }
} }

View File

@ -18,7 +18,6 @@ public class RouteRequestLeg implements Serializable {
@Id @Id
private Long id; private Long id;
private Long routeRequestId; private Long routeRequestId;
private Long routeRequestKey;
private Long legId; private Long legId;
@Transient @Transient
private Leg leg; private Leg leg;

View File

@ -110,4 +110,12 @@ public class SystemAnnouncement implements Serializable {
return this; return this;
} }
public SystemAnnouncement updateStatusByExpiryDate(){
LocalDateTime expiryDate = this.getExpiryDate();
if (expiryDate.isBefore(LocalDateTime.now())) {
this.setStatus("0");
}
return this;
}
} }

View File

@ -98,6 +98,7 @@ public class RouteOrderFactory implements OrderFactory {
requestByRoute.setRouteRequestLegList(routeRequestLegs); requestByRoute.setRouteRequestLegList(routeRequestLegs);
requestByRoute.setCreateTime(LocalDateTime.now()); requestByRoute.setCreateTime(LocalDateTime.now());
requestByRoute.setUpdateTime(LocalDateTime.now()); requestByRoute.setUpdateTime(LocalDateTime.now());
requestByRoute.setSupplierName(supplier);
return requestByRoute; return requestByRoute;
} }

View File

@ -185,7 +185,6 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
String orderNo = flightOrderBasicInfo.getOrderID(); String orderNo = flightOrderBasicInfo.getOrderID();
String journeyNo = flightOrderBasicInfo.getJourneyID(); String journeyNo = flightOrderBasicInfo.getJourneyID();
RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(journeyNo); RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(journeyNo);
return buildFlightOrderDetail(flightOrderInfoEntity, routeOrder, orderNo); return buildFlightOrderDetail(flightOrderInfoEntity, routeOrder, orderNo);
} }

View File

@ -2,17 +2,20 @@ package com.chint.domain.factoriy.order_record;
import com.chint.domain.aggregates.order.OrderDetail; import com.chint.domain.aggregates.order.OrderDetail;
import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.order.RouterOrderExtensionField;
import com.chint.domain.aggregates.order.order_record.OrderCarRecord; import com.chint.domain.aggregates.order.order_record.OrderCarRecord;
import com.chint.domain.aggregates.order.order_record.OrderFlightRecord; 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.infrastructure.util.BigDecimalCalculator; import com.chint.infrastructure.util.DateTimeUtil;
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 com.chint.interfaces.rest.data_center.user.UserHttpRequest;
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.Duration;
import java.time.LocalDateTime;
import java.util.Optional; import java.util.Optional;
import static com.chint.domain.service.supplier.SupplierUtil.getBelongSysType; import static com.chint.domain.service.supplier.SupplierUtil.getBelongSysType;
@ -61,20 +64,42 @@ public class AmapOrderRecordExtensionFactory implements OrderRecordExtensionFact
} else { } else {
orderStatus = "1"; orderStatus = "1";
} }
// orderCarRecord.loadBasicOrderInfo(carRecordData.getAmapOrderId(),
// orderStatus,
// carRecordData.getGmtCreate())
// .loadBelongDeport(
// routeOrder.stream().flatMap(order ->
// Optional.ofNullable(order.getRouterOrderExtensionField().getBelongDeptCode()).stream()
// ).findFirst().orElseGet(() ->
// userHttpRequest.belongDeport(orderCarRecord.getBookingUserCode(), orderCarRecord.getAccountCompanyName()))
// );
orderCarRecord.loadBasicOrderInfo(carRecordData.getAmapOrderId(), orderCarRecord.loadBasicOrderInfo(carRecordData.getAmapOrderId(),
orderStatus, orderStatus,
carRecordData.getGmtCreate()) carRecordData.getGmtCreate())
.loadBelongDeport( .loadBelongDeport(
routeOrder.stream().flatMap(order -> routeOrder.stream()
Optional.ofNullable(order.getRouterOrderExtensionField().getBelongDeptCode()).stream() .flatMap(order ->
).findFirst().orElseGet(()-> Optional.of(order)
userHttpRequest.belongDeport(orderCarRecord.getBookingUserCode(), orderCarRecord.getAccountCompanyName())) .map(RouteOrder::getRouterOrderExtensionField)
.map(RouterOrderExtensionField::getBelongDeptCode)
.stream()
)
.findFirst()
.orElseGet(() ->
userHttpRequest.belongDeport(orderCarRecord.getBookingUserCode(), orderCarRecord.getAccountCompanyName()))
); );
String ds = carRecordData.getDs(); String ds = carRecordData.getDs();
//车辆运行时间
String gmtCreateStartTime106 = carRecordData.getGmtCreateStartTime106();
String gmtCreateEndTime106 = carRecordData.getGmtCreateEndTime106();
orderCarRecord.loadTravelInfo( orderCarRecord.loadTravelInfo(
carRecordData.getGmtCreateStartTime106(), gmtCreateStartTime106,
carRecordData.getGmtCreateEndTime106(), gmtCreateEndTime106,
carRecordData.getCityName(), carRecordData.getCityName(),
carRecordData.getEndCity(), carRecordData.getEndCity(),
carRecordData.getStartName(), carRecordData.getStartName(),
@ -86,17 +111,19 @@ public class AmapOrderRecordExtensionFactory implements OrderRecordExtensionFact
).loadFinancialInfo( ).loadFinancialInfo(
ds.substring(0, 6), ds.substring(0, 6),
ds, ds,
String.valueOf(carRecordData.getOrderAmount()), String.valueOf(carRecordData.getEnterpriseAmount()),
BigDecimalCalculator.add(String.valueOf(carRecordData.getOrderAmount()), String.valueOf(carRecordData.getServicefee())) String.valueOf(carRecordData.getEnterpriseAmount())
).loadFeeDetails( ).loadFeeDetails(
"", "",
"", "",
String.valueOf(carRecordData.getServicefee()), String.valueOf(carRecordData.getServicefee()),
String.valueOf(carRecordData.getCancelFee()), String.valueOf(carRecordData.getCancelFee()),
String.valueOf(carRecordData.getHighwayFee()), String.valueOf(carRecordData.getHighwayFee()),
"" "高速费"
); );
orderCarRecord.setNoTaxAmt(carRecordData.getTotalCouponAmount() == 0 ? String.valueOf(carRecordData.getTotalCouponAmount())
: "-" + carRecordData.getTotalCouponAmount());
orderCarRecord.setTaxAmt(String.valueOf(carRecordData.getOrderAmount()));
Double enterpriseAmount = carRecordData.getEnterpriseAmount(); Double enterpriseAmount = carRecordData.getEnterpriseAmount();
Double individualAmount = carRecordData.getIndividualAmount(); Double individualAmount = carRecordData.getIndividualAmount();
String paymentType; String paymentType;
@ -113,6 +140,10 @@ public class AmapOrderRecordExtensionFactory implements OrderRecordExtensionFact
outApplyRecordId = split[split.length - 1]; outApplyRecordId = split[split.length - 1];
} }
orderCarRecord.loadSystemInfo(SUPPLIER_AMAP_FSSC, getBelongSysType(split[4]), split[1], split[0]); orderCarRecord.loadSystemInfo(SUPPLIER_AMAP_FSSC, getBelongSysType(split[4]), split[1], split[0]);
//补充遗漏的字段
orderCarRecord.setProjectOrderNo(split[2]);
orderCarRecord.setOfflineCcomyCode(split[3]);
orderCarRecord.loadPayment( orderCarRecord.loadPayment(
paymentType, paymentType,
String.valueOf(enterpriseAmount), String.valueOf(enterpriseAmount),
@ -131,6 +162,20 @@ public class AmapOrderRecordExtensionFactory implements OrderRecordExtensionFact
carRecordData.getAmapOrderId(), carRecordData.getAmapOrderId(),
carRecordData.getAmapOrderId() carRecordData.getAmapOrderId()
); );
//兼容测试环境获取运行时间
if (gmtCreateStartTime106 != null && gmtCreateStartTime106.length() > 18 &&
gmtCreateEndTime106 != null && gmtCreateEndTime106.length() > 18 &&
Double.parseDouble(orderCarRecord.getRunTime()) <= 0) {
LocalDateTime runStartTime = DateTimeUtil.strToTime(gmtCreateStartTime106);
LocalDateTime runEndTime = DateTimeUtil.strToTime(gmtCreateEndTime106);
Duration runtimeDuration = Duration.between(runStartTime, runEndTime);
long runtimeInMinutes = runtimeDuration.toMinutes();
orderCarRecord.setRunTime(String.valueOf(runtimeInMinutes));
} else {
orderCarRecord.setRunTime("0");
}
orderDetail.ifPresentOrElse(orderCarRecord::loadComplianceInfo, orderCarRecord::loadComplianceInfoNot); orderDetail.ifPresentOrElse(orderCarRecord::loadComplianceInfo, orderCarRecord::loadComplianceInfoNot);
return orderCarRecord; return orderCarRecord;
} }

View File

@ -6,6 +6,10 @@ import java.util.Optional;
public interface SupplierRepository { public interface SupplierRepository {
Supplier save(Supplier supplier); Supplier save(Supplier supplier);
Optional<Supplier> findById(Long id); Optional<Supplier> findById(Long id);
Optional<Supplier> findBySupplierName(String supplierName); Optional<Supplier> findBySupplierName(String supplierName);
Iterable<Supplier> findAll();
} }

View File

@ -8,6 +8,8 @@ import java.util.Optional;
public interface SystemAnnouncementRepository { public interface SystemAnnouncementRepository {
SystemAnnouncement save(SystemAnnouncement systemAnnouncement); SystemAnnouncement save(SystemAnnouncement systemAnnouncement);
void saveAll(List<SystemAnnouncement> systemAnnouncementList);
Optional<SystemAnnouncement> findById(Long id); Optional<SystemAnnouncement> findById(Long id);
Optional<SystemAnnouncement> findNew(); Optional<SystemAnnouncement> findNew();

View File

@ -12,7 +12,6 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional;
import static com.chint.infrastructure.constant.CommonMessageConstant.LEG_CHANGE_MAX_ERROR; import static com.chint.infrastructure.constant.CommonMessageConstant.LEG_CHANGE_MAX_ERROR;
import static com.chint.infrastructure.constant.LegConstant.*; import static com.chint.infrastructure.constant.LegConstant.*;
@ -171,30 +170,48 @@ public class LegDomainService {
} }
public List<Leg> queryLegsCanSync(RouteOrder routeOrder, String supplierName) { public List<Leg> queryLegsCanSync(RouteOrder routeOrder, String supplierName) {
// 获取所有Leg items并查询位置信息
List<Leg> legItems = routeOrder.getLegItems(); List<Leg> legItems = routeOrder.getLegItems();
queryLocation(legItems); queryLocation(legItems);
legItems = legItems.stream()
// 过滤Leg items
List<Leg> filteredLegItems = legItems.stream()
.filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER) && it.legIsInternal()) .filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER) && it.legIsInternal())
.toList(); .toList();
// 通过查看供应商的商品类型来进行同步
legItems = ifCanSync(legItems, routeOrder, supplierName);
legItems.forEach(Leg::reloadStatus);
return legItems;
}
private List<Leg> ifCanSync(List<Leg> legs, RouteOrder routeOrder, String supplierName) { // 根据供应商名称查找供应商并进行处理
return supplierRepository.findBySupplierName(supplierName) return supplierRepository.findBySupplierName(supplierName)
.map(supplier -> { .map(supplier -> {
List<Integer> productTypes = supplier.getSupplierProductList() List<Leg> syncAbleLegItems = ifCanSync(filteredLegItems, routeOrder, supplier);
.stream() syncAbleLegItems.forEach(Leg::reloadStatus);
.filter(it -> it.getIfCanOrder().equals(1)) return syncAbleLegItems;
.map(SupplierProduct::getProductType)
.toList();
return legs.stream()
.filter(leg -> productTypes.contains(leg.getLegType()) && checkLegCompatibility(leg, routeOrder, supplier))
.toList();
}) })
.orElse(legs); .orElse(filteredLegItems);
}
public List<Leg> queryLegsCanSync(RouteOrder routeOrder, Supplier supplier) {
// 获取所有Leg items并查询位置信息
List<Leg> legItems = routeOrder.getLegItems();
queryLocation(legItems);
// 过滤Leg items
List<Leg> filteredLegItems = legItems.stream()
.filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER) && it.legIsInternal())
.toList();
List<Leg> syncAbleLegItems = ifCanSync(filteredLegItems, routeOrder, supplier);
syncAbleLegItems.forEach(Leg::reloadStatus);
return syncAbleLegItems;
}
private List<Leg> ifCanSync(List<Leg> legs, RouteOrder routeOrder, Supplier supplier) {
List<Integer> productTypes = supplier.getSupplierProductList()
.stream()
.filter(it -> it.getIfCanOrder().equals(1))
.map(SupplierProduct::getProductType)
.toList();
return legs.stream()
.filter(leg -> productTypes.contains(leg.getLegType()) && checkLegCompatibility(leg, routeOrder, supplier))
.toList();
} }
private boolean checkLegCompatibility(Leg leg, RouteOrder routeOrder, Supplier supplier) { private boolean checkLegCompatibility(Leg leg, RouteOrder routeOrder, Supplier supplier) {

View File

@ -83,6 +83,9 @@ public class OrderDomainService {
@Autowired @Autowired
private BPMOrderDomainService bpmOrderDomainService; private BPMOrderDomainService bpmOrderDomainService;
@Autowired
private SupplierRepository supplierRepository;
private Set<String> companyBlackList = new HashSet<>(); private Set<String> companyBlackList = new HashSet<>();
public RouteOrder saveOrder(RouteOrder routeOrder) { public RouteOrder saveOrder(RouteOrder routeOrder) {
@ -174,6 +177,8 @@ public class OrderDomainService {
} }
} }
private boolean isSpecialEventType(Integer orderEventType) { private boolean isSpecialEventType(Integer orderEventType) {
return orderEventType.equals(ORDER_EVENT_ETA) || return orderEventType.equals(ORDER_EVENT_ETA) ||
orderEventType.equals(ORDER_EVENT_CHANGE) || orderEventType.equals(ORDER_EVENT_CHANGE) ||

View File

@ -1,5 +1,6 @@
package com.chint.domain.service; package com.chint.domain.service;
import com.chint.application.commands.RouteAutoSyncCommand;
import com.chint.domain.aggregates.order.*; import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.supplier.Supplier; import com.chint.domain.aggregates.supplier.Supplier;
import com.chint.domain.exceptions.CommandException; import com.chint.domain.exceptions.CommandException;
@ -13,6 +14,7 @@ import com.chint.domain.service.order_sync.SupplierOrderSync;
import com.chint.domain.service.order_sync.SyncAdapter; import com.chint.domain.service.order_sync.SyncAdapter;
import com.chint.domain.service.supplier.SupplierAdapterSelector; import com.chint.domain.service.supplier.SupplierAdapterSelector;
import com.chint.domain.value_object.SyncLegData; import com.chint.domain.value_object.SyncLegData;
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.Service; import org.springframework.stereotype.Service;
@ -21,7 +23,8 @@ import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.chint.infrastructure.constant.LegConstant.*; import static com.chint.infrastructure.constant.LegConstant.LEG_EVENT_APPROVAL;
import static com.chint.infrastructure.constant.LegConstant.LEG_EVENT_NOT_ORDERED;
import static com.chint.infrastructure.constant.RouteRequestConstant.ROUTE_REQUEST_STATUS_PREPARE; import static com.chint.infrastructure.constant.RouteRequestConstant.ROUTE_REQUEST_STATUS_PREPARE;
@Service @Service
@ -72,13 +75,33 @@ public class RouteRequestDomainService {
// legEventFactory.creatLegEvent(command.getLegEventType()) // legEventFactory.creatLegEvent(command.getLegEventType())
// )); // ));
@ListenTo(command = "RouteAutoSyncCommand", order = 0)
public RouteRequest syncRouteRequestToSupplierAuto(RouteAutoSyncCommand command) {
RouteOrder routeOrder = command.getRouteOrder();
legDomainService.checkLegIfStartApproval(routeOrder);
supplierRepository.findAll()
.forEach(it -> {
List<Leg> legs = legDomainService.queryLegsCanSync(routeOrder, it);
List<Long> legIdList = legs.stream().map(leg -> leg.getLegId()).toList();
RouteRequest routeRequest = getRouteRequest(routeOrder, legIdList, it.getName());
});
return null;
}
public RouteRequest syncRouteRequestToSupplier(SyncLegData syncLegData) { public RouteRequest syncRouteRequestToSupplier(SyncLegData syncLegData) {
RouteOrder routeOrder = routeRepository.queryById(syncLegData.getRouteId()); RouteOrder routeOrder = routeRepository.queryById(syncLegData.getRouteId());
legDomainService.checkLegIfStartApproval(routeOrder); legDomainService.checkLegIfStartApproval(routeOrder);
List<Long> legIds = syncLegData.getLegIds(); List<Long> legIds = syncLegData.getLegIds();
String supplierName = syncLegData.getSupplierName(); String supplierName = syncLegData.getSupplierName();
return createAndSyncRouteRequest(routeOrder, legIds, supplierName);
}
private RouteRequest createAndSyncRouteRequest(RouteOrder routeOrder, List<Long> legIds, String supplierName) {
RouteRequest routeRequest = getRouteRequest(routeOrder, legIds, supplierName); RouteRequest routeRequest = getRouteRequest(routeOrder, legIds, supplierName);
if (routeRequest.getStatus().equals(ROUTE_REQUEST_STATUS_PREPARE)) { if (routeRequest.getStatus().equals(ROUTE_REQUEST_STATUS_PREPARE) && routeRequest.getSupplier() == null) {
//如果是刚生成的订单需要加入行程规划单当中 //如果是刚生成的订单需要加入行程规划单当中
//保存供应商信息 //保存供应商信息
routeRequest.setSupplier(supplierName); routeRequest.setSupplier(supplierName);
@ -87,23 +110,10 @@ public class RouteRequestDomainService {
//如果是不是刚生成的需要调整差旅申请单的行程 //如果是不是刚生成的需要调整差旅申请单的行程
loadLegInfo(routeRequest, routeOrder, legIds); loadLegInfo(routeRequest, routeOrder, legIds);
} }
routeRequest.getRouteRequestLegList()
List<Leg> legs = routeRequest.getRouteRequestLegList()
.stream() .stream()
.map(RouteRequestLeg::getLeg) .map(RouteRequestLeg::getLeg)
.toList(); .forEach(it -> it.addEvent(legEventFactory.creatLegEvent(LEG_EVENT_NOT_ORDERED)));
if (legs.isEmpty()) {
throw new CommandException("订单的行程不能为空");
}
List<Leg> needSyncLegs = legs.stream().filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER)).toList();
if (needSyncLegs.isEmpty()) {
throw new CommandException("有所选的行程规划单不存在需要同步的行程");
}
legs.forEach(it -> it.addEvent(legEventFactory.creatLegEvent(LEG_EVENT_NOT_ORDERED)));
supplierRepository.findBySupplierName(supplierName) supplierRepository.findBySupplierName(supplierName)
.ifPresentOrElse( .ifPresentOrElse(
supplier -> syncRouteRequest(routeRequest, supplier, routeOrder), supplier -> syncRouteRequest(routeRequest, supplier, routeOrder),
@ -130,9 +140,7 @@ public class RouteRequestDomainService {
List<Long> legIds = syncLegData.getLegIds(); List<Long> legIds = syncLegData.getLegIds();
Long routeId = syncLegData.getRouteId(); Long routeId = syncLegData.getRouteId();
RouteOrder routeOrder = routeRepository.queryById(routeId); RouteOrder routeOrder = routeRepository.queryById(routeId);
Optional<RouteRequest> optionalRouteRequest = findRouteRequest(routeOrder, syncLegData); Optional<RouteRequest> optionalRouteRequest = findRouteRequest(routeOrder, syncLegData);
optionalRouteRequest.ifPresent(routeRequest -> { optionalRouteRequest.ifPresent(routeRequest -> {
List<Leg> legs = getLegsFromRouteRequest(routeRequest, routeOrder); List<Leg> legs = getLegsFromRouteRequest(routeRequest, routeOrder);

View File

@ -6,6 +6,7 @@ import com.chint.application.dtos.system.RoleUserDto;
import com.chint.domain.aggregates.user.Role; import com.chint.domain.aggregates.user.Role;
import com.chint.domain.aggregates.user.RoleUser; import com.chint.domain.aggregates.user.RoleUser;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.RoleRepository;
import com.chint.infrastructure.repository.jdbc.JdbcRoleRepository; import com.chint.infrastructure.repository.jdbc.JdbcRoleRepository;
import com.chint.infrastructure.repository.jdbc.JdbcRoleUserRepository; import com.chint.infrastructure.repository.jdbc.JdbcRoleUserRepository;
import com.chint.infrastructure.repository.jdbc.JdbcUserRepository; import com.chint.infrastructure.repository.jdbc.JdbcUserRepository;
@ -23,6 +24,7 @@ public class UserDomainService {
private JdbcUserRepository jdbcUserRepository; private JdbcUserRepository jdbcUserRepository;
@Autowired @Autowired
private JdbcRoleRepository jdbcRoleRepository; private JdbcRoleRepository jdbcRoleRepository;
@Autowired @Autowired
private JdbcRoleUserRepository jdbcRoleUserRepository; private JdbcRoleUserRepository jdbcRoleUserRepository;

View File

@ -74,7 +74,9 @@ public class AuthenticateServiceImpl implements AuthenticateService {
private UserLoginResult getUserLoginResult(User user) { private UserLoginResult getUserLoginResult(User user) {
UserLoginParam userLoginParam = user.getUserLoginParam(); UserLoginParam userLoginParam = user.getUserLoginParam();
String companyCode = userLoginParam.getCompanyCode(); String companyCode = userLoginParam.getCompanyCode();
if (companyCode != null && !companyCode.isEmpty()) { if (user.getCompanyCode() == null &&
companyCode != null &&
!companyCode.isEmpty()) {
user.setCompanyCode(companyCode); user.setCompanyCode(companyCode);
} }
user.setUserLoginParam(userLoginParam); user.setUserLoginParam(userLoginParam);

View File

@ -22,6 +22,7 @@ import com.chint.domain.value_object.SyncLegData;
import com.chint.infrastructure.constant.CommonMessageConstant; import com.chint.infrastructure.constant.CommonMessageConstant;
import com.chint.infrastructure.constant.LegConstant; import com.chint.infrastructure.constant.LegConstant;
import com.chint.infrastructure.constant.RouteConstant; import com.chint.infrastructure.constant.RouteConstant;
import com.chint.infrastructure.echo_framework.command.Command;
import com.chint.infrastructure.echo_framework.dispatch.ResultContainer; import com.chint.infrastructure.echo_framework.dispatch.ResultContainer;
import com.chint.infrastructure.util.BaseContext; import com.chint.infrastructure.util.BaseContext;
import com.chint.infrastructure.util.OrderNo; import com.chint.infrastructure.util.OrderNo;
@ -145,6 +146,9 @@ public class LegEventHandler implements LegEventService {
//保存routeOrder的状态 //保存routeOrder的状态
RouteOrder save = routeRepository.save(routeOrder); RouteOrder save = routeRepository.save(routeOrder);
command.order(save); command.order(save);
//异步执行自动同步功能
Command.of(RouteAutoSyncCommand.class).route(save).async().sendToQueue();
} }
@Transactional @Transactional

View File

@ -114,7 +114,7 @@ public class AmapOrderRecordGenerator implements OrderRecordGenerator {
Map<String, Optional<RouteOrder>> collect = routeOrderNoList.parallelStream().collect(Collectors.toMap(Function.identity(), Map<String, Optional<RouteOrder>> collect = routeOrderNoList.parallelStream().collect(Collectors.toMap(Function.identity(),
it -> routeOrderList.stream().filter(routeOrder -> routeOrder != null && routeOrder.checkIfMine(it)).findFirst())); it -> routeOrderList.stream().filter(routeOrder -> routeOrder != null && routeOrder.checkIfMine(it)).findFirst()));
List<OrderCarRecord> orderCarRecordList = amapCarOrderRecordList List<OrderCarRecord> orderCarRecordList = amapCarOrderRecordList
.stream() .parallelStream()
.map(it -> orderRecordExtensionFactory.createCarOrderRecord(it, collect.get(it.getOutApplyRecordId()))) .map(it -> orderRecordExtensionFactory.createCarOrderRecord(it, collect.get(it.getOutApplyRecordId())))
.toList(); .toList();
return orderDetailDomainService.saveCarOrderRecordBatch(orderCarRecordList); return orderDetailDomainService.saveCarOrderRecordBatch(orderCarRecordList);

View File

@ -89,11 +89,11 @@ public class LYOrderRecordDomainService {
List<RouteOrder> routeOrderList = routeRequestDomainService.getRouteOrder(routeOrderNoList); List<RouteOrder> routeOrderList = routeRequestDomainService.getRouteOrder(routeOrderNoList);
Map<String, Optional<RouteOrder>> collect = routeOrderNoList.parallelStream().collect(Collectors.toMap(Function.identity(), Map<String, Optional<RouteOrder>> collect = routeOrderNoList.parallelStream().collect(Collectors.toMap(Function.identity(),
it -> routeOrderList.stream().filter(routeOrder ->routeOrder != null && routeOrder.checkIfMine(it)).findFirst())); it -> routeOrderList.stream().filter(routeOrder ->routeOrder != null && routeOrder.checkIfMine(it)).findFirst()));
List<OrderFlightRecord> orderCarRecordList = recordsTotal List<OrderFlightRecord> orderFlightRecordList = recordsTotal
.stream() .stream()
.map(it -> lyOrderRecordExtensionFactory.createFlightOrderRecord(it, collect.get(it.getOutApplayOrderNo()))) .map(it -> lyOrderRecordExtensionFactory.createFlightOrderRecord(it, collect.get(it.getOutApplayOrderNo())))
.toList(); .toList();
orderDetailDomainService.saveFlightOrderRecordBatch(orderCarRecordList); orderDetailDomainService.saveFlightOrderRecordBatch(orderFlightRecordList);
jdbcLyOrderFlightRecord.updateStatusByNullStatus(); jdbcLyOrderFlightRecord.updateStatusByNullStatus();
} }
@ -129,7 +129,7 @@ public class LYOrderRecordDomainService {
.map(it -> lyOrderRecordExtensionFactory.createHotelOrderRecord(it, collect.get(it.getOutApplayOrderNo()))) .map(it -> lyOrderRecordExtensionFactory.createHotelOrderRecord(it, collect.get(it.getOutApplayOrderNo())))
.toList(); .toList();
orderDetailDomainService.saveHotelOrderRecordBatch(orderHotelRecordList); orderDetailDomainService.saveHotelOrderRecordBatch(orderHotelRecordList);
jdbcLyOrderFlightRecord.updateStatusByNullStatus(); jdbcLyOrderHotelRecord.updateStatusByNullStatus();
} }
@ -164,7 +164,7 @@ public class LYOrderRecordDomainService {
.map(it -> lyOrderRecordExtensionFactory.createTrainOrderRecord(it, collect.get(it.getOutApplayOrderNo()))) .map(it -> lyOrderRecordExtensionFactory.createTrainOrderRecord(it, collect.get(it.getOutApplayOrderNo())))
.toList(); .toList();
orderDetailDomainService.saveTrainOrderRecordBatch(orderTrainRecordList); orderDetailDomainService.saveTrainOrderRecordBatch(orderTrainRecordList);
jdbcLyOrderFlightRecord.updateStatusByNullStatus(); jdbcLyOrderTrainRecord.updateStatusByNullStatus();
} }
@ -199,7 +199,7 @@ public class LYOrderRecordDomainService {
.map(it -> lyOrderRecordExtensionFactory.createCarOrderRecord(it, collect.get(it.getOutApplayOrderNo()))) .map(it -> lyOrderRecordExtensionFactory.createCarOrderRecord(it, collect.get(it.getOutApplayOrderNo())))
.toList(); .toList();
orderDetailDomainService.saveCarOrderRecordBatch(orderCarRecordList); orderDetailDomainService.saveCarOrderRecordBatch(orderCarRecordList);
jdbcLyOrderFlightRecord.updateStatusByNullStatus(); jdbcLyOrderCarRecord.updateStatusByNullStatus();
} }

View File

@ -5,9 +5,11 @@ import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.supplier.Supplier; import com.chint.domain.aggregates.supplier.Supplier;
import com.chint.domain.aggregates.supplier.SupplierProduct; import com.chint.domain.aggregates.supplier.SupplierProduct;
import com.chint.domain.exceptions.AuthException; import com.chint.domain.exceptions.AuthException;
import com.chint.domain.exceptions.CommandException;
import com.chint.domain.service.supplier.SupplierAdapter; import com.chint.domain.service.supplier.SupplierAdapter;
import java.util.List; import java.util.List;
import java.util.Optional;
import static com.chint.infrastructure.constant.LegConstant.*; import static com.chint.infrastructure.constant.LegConstant.*;
@ -21,60 +23,118 @@ public interface SupplierOrderSync extends SupplierAdapter {
boolean cancelRouteRequest(RouteRequest routeRequest); boolean cancelRouteRequest(RouteRequest routeRequest);
default boolean syncRouteRequest(RouteRequest routeRequest, Supplier supplier) { default boolean syncRouteRequest(RouteRequest routeRequest, Supplier supplier) {
return syncRouteRequestInternal(routeRequest, supplier, true);
}
default boolean syncRouteRequestWithoutException(RouteRequest routeRequest, Supplier supplier) {
return syncRouteRequestInternal(routeRequest, supplier, false);
}
private boolean syncRouteRequestInternal(RouteRequest routeRequest, Supplier supplier, boolean throwError) {
// Check if routeRequest or supplier is null
if (routeRequest == null || supplier == null) { if (routeRequest == null || supplier == null) {
throw new AuthException("验证差旅申请单失败,请联系管理员"); throw new AuthException("验证差旅申请单失败,请联系管理员");
} }
// Extract routeRequestFields
RouteRequestFields routeRequestFields = routeRequest.getRouteRequestFields(); RouteRequestFields routeRequestFields = routeRequest.getRouteRequestFields();
// Create list of legs from routeRequest
List<Leg> legList = routeRequest.getRouteRequestLegList() List<Leg> legList = routeRequest.getRouteRequestLegList()
.stream() .stream()
.map(RouteRequestLeg::getLeg) .map(RouteRequestLeg::getLeg)
.toList(); .toList();
legList.forEach(leg -> {
switch (leg.getLegType()) { // Legs can not be empty
case LEG_TYPE_TRAIN -> trainProductCheck(routeRequestFields, supplier); if (legList.isEmpty()) {
case LEG_TYPE_AIRPLANE -> flightProductCheck(routeRequestFields, supplier); if (throwError) {
case LEG_TYPE_HOTEL -> hotelProductCheck(routeRequestFields, supplier); throw new CommandException("订单的行程不能为空");
case LEG_TYPE_TAXI -> carProductCheck(routeRequestFields, supplier); } else {
return false;
} }
}); }
return syncRouteRequest(routeRequest);
// Legs can not be other type
List<Leg> needSyncLegs = legList.stream().filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER)).toList();
if (needSyncLegs.isEmpty()) {
if (throwError) {
throw new CommandException("有所选的行程规划单不存在需要同步的行程");
} else {
return false;
}
}
// Introduce a flag to track if any check fails
boolean isValid = true;
// Process each leg
for (Leg leg : legList) {
// Perform product check based on leg type and update the isValid flag
switch (leg.getLegType()) {
case LEG_TYPE_TRAIN ->
isValid = isValid && productCheckWrapper(routeRequestFields, supplier.trainSupplierProduct(), supplier, "火车", throwError);
case LEG_TYPE_AIRPLANE ->
isValid = isValid && productCheckWrapper(routeRequestFields, supplier.flightSupplierProduct(), supplier, "机票", throwError);
case LEG_TYPE_HOTEL ->
isValid = isValid && productCheckWrapper(routeRequestFields, supplier.hotelSupplierProduct(), supplier, "酒店", throwError);
case LEG_TYPE_TAXI ->
isValid = isValid && productCheckWrapper(routeRequestFields, supplier.carSupplierProduct(), supplier, "打车", throwError);
}
// If any check fails and throwError is false, break the loop
if (!isValid && !throwError) {
break;
}
}
// If all checks pass, sync the route request
if (isValid) {
return syncRouteRequest(routeRequest);
} else {
return false; // Indicate that the request was not synced due to validation failure
}
} }
private void carProductCheck(RouteRequestFields routeRequestFields, Supplier supplier) { private boolean productCheckWrapper(RouteRequestFields routeRequestFields,
supplier.carSupplierProduct() Optional<SupplierProduct> supplierProductOpt,
.ifPresent(carSupplierProduct -> productCheck(routeRequestFields, carSupplierProduct, supplier, "打车")); Supplier supplier,
String legCnName,
boolean throwError) {
return supplierProductOpt.map(supplierProduct ->
productCheck(routeRequestFields, supplierProduct, supplier, legCnName, throwError)).orElse(true);
} }
private void flightProductCheck(RouteRequestFields routeRequestFields, Supplier supplier) { // General product check method
supplier.flightSupplierProduct() private boolean productCheck(RouteRequestFields routeRequestFields,
.ifPresent(flightSupplierProduct -> productCheck(routeRequestFields, flightSupplierProduct, supplier, "机票")); SupplierProduct supplierProduct,
} Supplier supplier,
String legCnName,
private void hotelProductCheck(RouteRequestFields routeRequestFields, Supplier supplier) { boolean throwError) {
supplier.hotelSupplierProduct()
.ifPresent(hotelSupplierProduct -> productCheck(routeRequestFields, hotelSupplierProduct, supplier, "酒店"));
}
private void trainProductCheck(RouteRequestFields routeRequestFields, Supplier supplier) {
supplier.trainSupplierProduct()
.ifPresent(trainSupplierProduct -> productCheck(routeRequestFields, trainSupplierProduct, supplier, "火车"));
}
private void productCheck(RouteRequestFields routeRequestFields,
SupplierProduct supplierProduct,
Supplier supplier,
String legCnName) {
if (!supplierProduct.checkStandardLevelIfInUse(routeRequestFields.getStandardLevel())) { if (!supplierProduct.checkStandardLevelIfInUse(routeRequestFields.getStandardLevel())) {
throw new AuthException("你目前的差标暂不支持使用" + supplier.getCnName() + legCnName); if (throwError) {
throw new AuthException("你目前的差标暂不支持使用" + supplier.getCnName() + legCnName + "");
}
return false;
} }
if (supplierProduct.checkSysCodeIfNotUse(routeRequestFields.getSysCode())) { if (supplierProduct.checkSysCodeIfNotUse(routeRequestFields.getSysCode())) {
throw new AuthException("你目前的来源系统暂不支持使用" + supplier.getCnName() + legCnName); if (throwError) {
throw new AuthException("你目前的来源系统暂不支持使用" + supplier.getCnName() + legCnName + "");
}
return false;
} }
if (supplierProduct.checkSysCodeIfNotUse(routeRequestFields.getAccountCompany())) { if (supplierProduct.checkCompanyIfNotUse(routeRequestFields.getAccountCompany())) {
throw new AuthException("你目前的公司暂不支持使用" + supplier.getCnName() + legCnName); if (throwError) {
throw new AuthException("你目前的公司暂不支持使用" + supplier.getCnName() + legCnName + "");
}
return false;
} }
if (supplierProduct.checkSysCodeIfNotUse(routeRequestFields.getAccountCompanyName())) { if (supplierProduct.checkCompanyIfNotUse(routeRequestFields.getAccountCompanyName())) {
throw new AuthException("你目前的公司暂不支持使用" + supplier.getCnName() + legCnName); if (throwError) {
throw new AuthException("你目前的公司暂不支持使用" + supplier.getCnName() + legCnName + "");
}
return false;
} }
return true;
} }
} }

View File

@ -9,4 +9,5 @@ import java.lang.annotation.*;
public @interface ListenTo { public @interface ListenTo {
String command(); String command();
long order(); long order();
boolean async() default false;
} }

View File

@ -11,6 +11,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
public abstract class Command { public abstract class Command {
private String commandName; private String commandName;
private boolean ifSync = false;
public Properties sendToQueue() { public Properties sendToQueue() {
return CommandDispatcher.dispatch(this); return CommandDispatcher.dispatch(this);
@ -26,4 +27,9 @@ public abstract class Command {
throw new CommandException("command create error :" + e.getMessage()); throw new CommandException("command create error :" + e.getMessage());
} }
} }
public Command async() {
ifSync = true;
return this;
}
} }

View File

@ -23,6 +23,7 @@ import org.springframework.transaction.support.TransactionTemplate;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -104,23 +105,30 @@ public class EventManager implements ApplicationContextAware, BeanNameAware, Ini
List<MethodContainer> containers = listenerMethods.getOrDefault(command.getCommandName(), Collections.emptyList()); List<MethodContainer> containers = listenerMethods.getOrDefault(command.getCommandName(), Collections.emptyList());
List<ResultContainer> resultContainers = new ArrayList<>(); List<ResultContainer> resultContainers = new ArrayList<>();
containers.forEach(container -> { containers.forEach(container -> {
Object result = null;
try { try {
result = container.getMethod().invoke(container.getBean(), command); if (command.isIfSync()) {
CompletableFuture.runAsync(() -> {
try {
container.getMethod().invoke(container.getBean(), command);
} catch (IllegalAccessException | InvocationTargetException e) {
e.printStackTrace();
}
});
} else {
Object result = container.getMethod().invoke(container.getBean(), command);
if (result instanceof ResultContainer) {
resultContainers.add((ResultContainer) result);
}
}
} catch (IllegalAccessException | InvocationTargetException e) { } catch (IllegalAccessException | InvocationTargetException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
if (result instanceof ResultContainer) {
resultContainers.add((ResultContainer) result);
}
}); });
return resultContainers; return resultContainers;
} }
private static List<ResultContainer> processTransitionCommand(Command command) { private static List<ResultContainer> processTransitionCommand(Command command) {
System.out.println(transitionMethods);
List<MethodContainer> containers = transitionMethods.getOrDefault(command.getCommandName(), Collections.emptyList()); List<MethodContainer> containers = transitionMethods.getOrDefault(command.getCommandName(), Collections.emptyList());
List<ResultContainer> resultContainers = new ArrayList<>(); List<ResultContainer> resultContainers = new ArrayList<>();
transactionTemplate.execute(transactionStatus -> { transactionTemplate.execute(transactionStatus -> {

View File

@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional; import java.util.Optional;
@Repository @Repository
@ -30,4 +31,9 @@ public class SupplierRepositoryImpl implements SupplierRepository {
public Optional<Supplier> findBySupplierName(String supplierName) { public Optional<Supplier> findBySupplierName(String supplierName) {
return jdbcSupplierRepository.findByName(supplierName); return jdbcSupplierRepository.findByName(supplierName);
} }
@Override
public Iterable<Supplier> findAll() {
return jdbcSupplierRepository.findAll();
}
} }

View File

@ -25,6 +25,12 @@ public class SystemAnnouncementRepositoryImpl implements SystemAnnouncementRepos
return jdbcSystemAnnouncementRepository.save(systemAnnouncement); return jdbcSystemAnnouncementRepository.save(systemAnnouncement);
} }
@Override
public void saveAll(List<SystemAnnouncement> systemAnnouncementList) {
jdbcSystemAnnouncementRepository.saveAll(systemAnnouncementList)
.forEach(it -> cacheEvictAnnouncement(it.getAnnouncementId()));
}
@Cacheable(value = "SystemAnnouncement", key = "#id") @Cacheable(value = "SystemAnnouncement", key = "#id")
@Override @Override
public Optional<SystemAnnouncement> findById(Long id) { public Optional<SystemAnnouncement> findById(Long id) {
@ -47,4 +53,9 @@ public class SystemAnnouncementRepositoryImpl implements SystemAnnouncementRepos
public List<SystemAnnouncement> findEffective() { public List<SystemAnnouncement> findEffective() {
return jdbcSystemAnnouncementRepository.findByStatus("1"); return jdbcSystemAnnouncementRepository.findByStatus("1");
} }
@CacheEvict(value = "SystemAnnouncement", key = "#id")
public void cacheEvictAnnouncement(Long id) {
}
} }

View File

@ -3,7 +3,6 @@ package com.chint.interfaces.rest.ctrip.in;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.chint.application.commands.OrderStatusChangeCommand; import com.chint.application.commands.OrderStatusChangeCommand;
import com.chint.application.commands.SupplierCallBackErrorCommand; import com.chint.application.commands.SupplierCallBackErrorCommand;
import com.chint.domain.aggregates.order.OrderDetail;
import com.chint.domain.repository.SupplierCallBackLogRepository; import com.chint.domain.repository.SupplierCallBackLogRepository;
import com.chint.domain.service.SystemDomainService; import com.chint.domain.service.SystemDomainService;
import com.chint.domain.service.supplier.SupplierService; import com.chint.domain.service.supplier.SupplierService;
@ -172,24 +171,7 @@ public class CTripNoteController {
.outOrderStatus(orderStatus) .outOrderStatus(orderStatus)
.orderNo(orderId) .orderNo(orderId)
.productType(legType); .productType(legType);
supplierService.handleSupplierCallback(supplierCallbackData);
OrderDetail orderDetail = supplierService.handleSupplierCallback(supplierCallbackData);
// OrderStatusChangeCommand command = Command.of(OrderStatusChangeCommand.class)
// .orderDetail(orderDetail)
// .orderNo(orderId)
// .outStatus(orderStatus);
//
// Integer eventType = CTripUtils.outStatusMapToEventType(legType, orderStatus);
// String etaReason = CTripUtils.getETAReason(response, legType);
//
// command.eventType(eventType)
// .extension(etaReason)
// .sendToQueue();
// if (legType.equals(LEG_TYPE_HOTEL)) {
// checkHotelIfRefund(response, command);
// }
return Result.Success("成功收到消息"); return Result.Success("成功收到消息");
} }

View File

@ -204,6 +204,7 @@ public class CTripUtils {
!"Confirmed".equals(status) && !"Confirmed".equals(status) &&
!"Wait".equals(status) && !"Wait".equals(status) &&
!"CancellationFailed".equals(status) && !"CancellationFailed".equals(status) &&
!"Cancelled".equals(status) &&
!"submitFailed".equals(status) && !"submitFailed".equals(status) &&
!"Approve_G".equals(status) && !"Approve_G".equals(status) &&
!"Approving".equals(status) && !"Approving".equals(status) &&

View File

@ -87,33 +87,33 @@ public class CommonController {
@PostMapping("/back") @PostMapping("/back")
public LYNoteResponse Back(@RequestBody Notification notification) { public LYNoteResponse Back(@RequestBody Notification notification) {
// int notifyType = notification.getNotifyType(); int notifyType = notification.getNotifyType();
// switch (notifyType) { switch (notifyType) {
// //进行订单数据回推 //进行订单数据回推
// case 1 -> getOrderFlight(notification); case 1 -> getOrderFlight(notification);
// case 3 -> getOrderHotel(notification); case 3 -> getOrderHotel(notification);
// case 5 -> getOrderTrain(notification); case 5 -> getOrderTrain(notification);
// case 6 -> getOrderCar(notification); case 6 -> getOrderCar(notification);
// default -> LYNoteResponse.success(); default -> LYNoteResponse.success();
// }
if (ifForwardRequest) {
CompletableFuture.runAsync(() -> {
log.info("转发同程订单状态推送");
LYNoteResponse response = basePostRequest
.post(forwardRequestBaseUrl + forwardRequestPath, notification, LYNoteResponse.class);
if (response.getResCode().equals("100")) {
log.info("转发同程订单状态推送成功");
} else {
log.info("转发同程订单状态推送失败");
}
});
} }
String json = gson.toJson(notification);
log.info("存入Redis{}", json); // if (ifForwardRequest) {
redisTemplate.opsForList().leftPush(CommonMessageConstant.COMMON_BACK, json); // CompletableFuture.runAsync(() -> {
// log.info("转发同程订单状态推送");
// LYNoteResponse response = basePostRequest
// .post(forwardRequestBaseUrl + forwardRequestPath, notification, LYNoteResponse.class);
// if (response.getResCode().equals("100")) {
// log.info("转发同程订单状态推送成功");
// } else {
// log.info("转发同程订单状态推送失败");
// }
// });
// }
//
// String json = gson.toJson(notification);
// log.info("存入Redis{}", json);
// redisTemplate.opsForList().leftPush(CommonMessageConstant.COMMON_BACK, json);
return new LYNoteResponse("100", "OK"); return new LYNoteResponse("100", "OK");
} }

View File

@ -31,6 +31,7 @@ public class LYOrderUtil {
public static boolean checkTrainStatus(String status) { public static boolean checkTrainStatus(String status) {
return !"N".equals(status) && return !"N".equals(status) &&
!"D".equals(status) && !"D".equals(status) &&
!"C".equals(status) &&
!"S".equals(status) && !"S".equals(status) &&
!"G".equals(status) && !"G".equals(status) &&
!"H".equals(status) && !"H".equals(status) &&
@ -80,6 +81,7 @@ public class LYOrderUtil {
!"22".equals(status) && !"22".equals(status) &&
!"60".equals(status) && !"60".equals(status) &&
!"67".equals(status) && !"67".equals(status) &&
!"96".equals(status) &&
!"99".equals(status); !"99".equals(status);
} }
@ -120,7 +122,11 @@ public class LYOrderUtil {
!"11".equals(status) && !"11".equals(status) &&
!"12".equals(status) && !"12".equals(status) &&
!"13".equals(status) && !"13".equals(status) &&
!"14".equals(status); !"14".equals(status) &&
!"15".equals(status) &&
!"16".equals(status) &&
!"17".equals(status) &&
!"18".equals(status);
} }
public static Integer mapCarStatus(Integer status) { public static Integer mapCarStatus(Integer status) {

View File

@ -52,7 +52,6 @@ ly:
baseUrl: https://api.dttrip.cn/openapi baseUrl: https://api.dttrip.cn/openapi
ifForwardRequest: true ifForwardRequest: true
forwardRequestBaseUrl: https://gxdev03.chint.com/routeapi forwardRequestBaseUrl: https://gxdev03.chint.com/routeapi
#高德 #高德
amap: amap:
eId: 201107 eId: 201107

View File

@ -250,7 +250,7 @@ public class CTripTest {
@Test @Test
void search() { void search() {
BaseContext.setCurrentUser(user); BaseContext.setCurrentUser(user);
SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("32430240547"); SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("32002090029");
System.out.println(response); System.out.println(response);
} }

View File

@ -820,7 +820,7 @@ public class LYTest {
@Test @Test
void searchTrain() { void searchTrain() {
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DT24041770487265905"); TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DTC24061977736328100");
Gson gson = new Gson(); Gson gson = new Gson();
String json = gson.toJson(trainOrderDetail); String json = gson.toJson(trainOrderDetail);
System.out.println(json); System.out.println(json);
@ -828,7 +828,7 @@ public class LYTest {
@Test @Test
void searchHotel() { void searchHotel() {
HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240321165300961176"); HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240406120100189791");
Gson gson = new Gson(); Gson gson = new Gson();
String json = gson.toJson(hotelOrderDetail); String json = gson.toJson(hotelOrderDetail);
System.out.println(json); System.out.println(json);

View File

@ -321,7 +321,7 @@ class RouteApplicationTests {
@Test @Test
void loginSignProd() { void loginSignProd() {
String sfno = "230228069"; String sfno = "220921136";
String syscode = "FSSC"; String syscode = "FSSC";
String billcode = "CLSQ240225000099"; String billcode = "CLSQ240225000099";
String companycode = "正泰集团股份有限公司"; String companycode = "正泰集团股份有限公司";