fix: 修复行程规划明细,订单订单明细缺失的问题
This commit is contained in:
parent
b4bd0fd02b
commit
78c4bb7812
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -4,7 +4,9 @@ import com.chint.application.commands.LYOrderRecordGenerateCommand;
|
|||
import com.chint.application.commands.OrderRecordGenerateCommand;
|
||||
import com.chint.application.dtos.RecordMonthSaveDTO;
|
||||
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.repository.SystemAnnouncementRepository;
|
||||
import com.chint.domain.service.OrderRecordDomainService;
|
||||
import com.chint.domain.service.order_record.OrderRecordGenerator;
|
||||
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.RestController;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
|
||||
import static com.chint.infrastructure.constant.LegConstant.*;
|
||||
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP;
|
||||
|
@ -56,6 +61,9 @@ public class AutoWorkController {
|
|||
@Autowired
|
||||
private SupplierAdapterSelector supplierAdapterSelector;
|
||||
|
||||
@Autowired
|
||||
private SystemAnnouncementRepository systemAnnouncementRepository;
|
||||
|
||||
|
||||
@ApiOperation("用户状态检查,离职用户将关闭开卡")
|
||||
@PostMapping("/user/status/check")
|
||||
|
@ -198,4 +206,17 @@ public class AutoWorkController {
|
|||
PageResult<RouteOrder> routeOrderPageResult = PageResult.totalPageNum(res.getTotalElements(), res.toList());
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,6 +114,12 @@ public class FSSCController {
|
|||
if (extensionOptional.isPresent()) {
|
||||
reDirectUrl = dataBaseUrl + extensionOptional.get().getFieldValue();
|
||||
}
|
||||
//特殊处理
|
||||
if(sysCode.getIfImmediateResponse() == 1){
|
||||
reDirectUrl = sysCode.getSystemCodeUrl().getRedirectUrlDev();
|
||||
} else {
|
||||
reDirectUrl = sysCode.getSystemCodeUrl().getRedirectUrlProd();
|
||||
}
|
||||
}
|
||||
return reDirectUrl;
|
||||
}
|
||||
|
|
|
@ -131,17 +131,15 @@ public class LoginController {
|
|||
@ApiOperation("商旅平台移动端单点")
|
||||
@PostMapping("/login/sso/mobile")
|
||||
public Result<UserLoginResult> loginSSOMobile(@RequestBody UserLoginParam userLoginParam) {
|
||||
|
||||
String employeeNo = feishuLoginStrategy.login(userLoginParam.getCode());
|
||||
|
||||
String timespan = userLoginParam.getTimespan() + "-M";
|
||||
userLoginParam.setTimespan(timespan);
|
||||
userLoginParam.setSfno(employeeNo);
|
||||
UserLoginResult userLoginResult = authenticateService
|
||||
.authenticateEmployeeNo(userLoginParam);
|
||||
|
||||
//异步执行更新用户信息到同程
|
||||
User currentUser = BaseContext.getCurrentUser();
|
||||
loginEventBoarder(currentUser);
|
||||
|
||||
return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult);
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.chint.application.out;
|
|||
import com.chint.application.dtos.*;
|
||||
import com.chint.application.dtos.mapper.RouteOrderMapper;
|
||||
import com.chint.application.dtos.response.OrderDetailRes;
|
||||
import com.chint.application.dtos.response.RouteOrderPageRes;
|
||||
import com.chint.application.queryies.OrderDetailQuery;
|
||||
import com.chint.domain.aggregates.order.RouteOrder;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
|
@ -202,6 +203,13 @@ public class OrderDetailController {
|
|||
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("查询携程订单")
|
||||
@PostMapping("/public/query/cTrip")
|
||||
public Result<Object> queryOrderDetail(@RequestBody OrderDetailQueryParam orderDetailQueryParam) {
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.chint.application.queryies;
|
|||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
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.response.*;
|
||||
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.LegConstant.*;
|
||||
import static com.chint.infrastructure.constant.LocationConstant.LOCATION_LEVEL_CITY;
|
||||
import static com.chint.infrastructure.constant.LocationConstant.LOCATION_LEVEL_COUNTY;
|
||||
import static com.chint.infrastructure.constant.LocationConstant.*;
|
||||
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.RouteConstant.*;
|
||||
|
@ -365,23 +365,27 @@ public class OrderQuery {
|
|||
|
||||
List<Location> locationListAfterNotNull = locationList.stream().filter(Objects::nonNull).toList();
|
||||
for (Location location : locationListAfterNotNull) {
|
||||
|
||||
if (location.getLocationEnName() == null) {
|
||||
//这里的代码来补充地理位置的英文名
|
||||
Integer level = location.getLevel();
|
||||
if (level.equals(LOCATION_LEVEL_CITY)) {
|
||||
PrefectureLevelCityInfoEntity cityInfo = prefectureLevelRepository.findByCityId(location.getCityId());
|
||||
location.setLocationEnName(cityInfo.getCityEnName());
|
||||
} else if (level.equals(LOCATION_LEVEL_COUNTY) && location.getLocationShortName().contains("D")) {
|
||||
DistrictPOIInfoEntity byCityId = districtInfoRepository.findByCityId(location.getCityId());
|
||||
location.setLocationEnName(byCityId.getDistrictEnName());
|
||||
} else if (level.equals(LOCATION_LEVEL_COUNTY)) {
|
||||
CountryLevelInfoEntity byCityId = countryLevelInfoRepository.findByCityId(location.getCityId());
|
||||
location.setLocationEnName(byCityId.getCountyEnName());
|
||||
} else {
|
||||
location.setLocationEnName("unknown");
|
||||
location.setLocationEnName(
|
||||
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";
|
||||
}
|
||||
);
|
||||
if (location.getLocationEnName() != null) {
|
||||
locationRepository.save(location);
|
||||
}
|
||||
locationRepository.saveAll(List.of(location));
|
||||
}
|
||||
callbackDataBuilder.cityList()
|
||||
.cityName(location.getLocationName())
|
||||
|
@ -395,24 +399,20 @@ public class OrderQuery {
|
|||
ScheduleDetail.ScheduleDetailBuilder scheduleDetailBuilder = ScheduleDetail
|
||||
.builder()
|
||||
.legId(leg.getLegId());
|
||||
if (!leg.getLegType().equals(LEG_TYPE_OTHER)) {
|
||||
Location originLocation = leg.getOriginLocation();
|
||||
if (originLocation != null) {
|
||||
scheduleDetailBuilder
|
||||
.startCity(originLocation.getLocationName())
|
||||
.startCityName(originLocation.getLocationName())
|
||||
.startCityEnName(originLocation.getLocationEnName());
|
||||
}
|
||||
|
||||
Location destinationLocation = leg.getDestinationLocation();
|
||||
if (destinationLocation != null) {
|
||||
scheduleDetailBuilder
|
||||
.endCityName(destinationLocation.getLocationName())
|
||||
.endCity(destinationLocation.getLocationName())
|
||||
.endCityEnName(destinationLocation.getLocationEnName());
|
||||
}
|
||||
Location originLocation = leg.getOriginLocation();
|
||||
if (originLocation != null) {
|
||||
scheduleDetailBuilder
|
||||
.startCity(originLocation.getLocationName())
|
||||
.startCityName(originLocation.getLocationName())
|
||||
.startCityEnName(originLocation.getLocationEnName());
|
||||
}
|
||||
Location destinationLocation = leg.getDestinationLocation();
|
||||
if (destinationLocation != null) {
|
||||
scheduleDetailBuilder
|
||||
.endCityName(destinationLocation.getLocationName())
|
||||
.endCity(destinationLocation.getLocationName())
|
||||
.endCityEnName(destinationLocation.getLocationEnName());
|
||||
}
|
||||
|
||||
if (leg.getLegType().equals(LEG_TYPE_HOTEL)) {
|
||||
scheduleDetailBuilder
|
||||
.roomCount("1")
|
||||
|
@ -442,15 +442,6 @@ public class OrderQuery {
|
|||
.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
|
||||
.scheduleNum(leg.getLegNo())
|
||||
.scheduleType(translateLegType(leg.getLegType()))
|
||||
|
@ -486,6 +477,24 @@ public class OrderQuery {
|
|||
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) {
|
||||
return switch (legType) {
|
||||
case LegConstant.LEG_TYPE_TRAIN -> TRIP_CALLBACK_TRAIN_TYPE;
|
||||
|
@ -499,7 +508,6 @@ public class OrderQuery {
|
|||
|
||||
public RouteOrderRes queryRouteRes(RouteOrder routeOrder) {
|
||||
RouteOrderRes routeOrderRes = RouteOrderRes.copyFrom(routeOrder);
|
||||
|
||||
List<Leg> legItems = routeOrder.getLegItems();
|
||||
if (legItems != null && !legItems.isEmpty()) {
|
||||
//这里使用领域事件进行检查leg的订单状态 ,用户每次想要查看行程都会进行一次检查
|
||||
|
@ -510,16 +518,12 @@ public class OrderQuery {
|
|||
List<OrderDetailRes> orderDetailResList = routeOrder
|
||||
.getOrderDetails()
|
||||
.stream()
|
||||
.map(OrderDetailRes::copyFrom)
|
||||
.filter(it -> !it.getOrderStatus().equals(ORDER_EVENT_CANCEL_NAME) && !it.getOrderStatus().equals(ORDER_EVENT_PREPARE_NAME))
|
||||
.map(OrderDetailMapper::copyFromExtension)
|
||||
.toList();
|
||||
User user = userRepository.findByUserEmployeeNo(routeOrder.getUserId());
|
||||
routeOrderRes.setUserName(user.getName());
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -117,8 +117,8 @@ public class UserController {
|
|||
@PostMapping("/add/role")
|
||||
public Result<String> addRoleUser(@RequestBody RoleOrgParam roleOrgParam) {
|
||||
//查询已有权限
|
||||
List<RoleUser> exist=roleUserRepository.findByUserId(roleOrgParam.getUserId());
|
||||
List<Long> roleIdList=roleOrgParam.getRoleIdList();
|
||||
List<RoleUser> exist = roleUserRepository.findByUserId(roleOrgParam.getUserId());
|
||||
List<Long> roleIdList = roleOrgParam.getRoleIdList();
|
||||
roleIdList.removeAll(exist.stream().map(RoleUser::getRoleId).toList());
|
||||
if (roleIdList.isEmpty()) {
|
||||
return Result.Success();
|
||||
|
@ -174,6 +174,6 @@ public class UserController {
|
|||
@ApiOperation("用户角色分页查询")
|
||||
@PostMapping("/role/pageQuery")
|
||||
public Result<PageResult<?>> rolePageQuery(@RequestBody RolePageQuery rolePageQuery) {
|
||||
return Result.Success(SUCCESS,userDomainService.userPageQuery(rolePageQuery));
|
||||
return Result.Success(SUCCESS, userDomainService.userPageQuery(rolePageQuery));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ public class RouteRequestLeg implements Serializable {
|
|||
@Id
|
||||
private Long id;
|
||||
private Long routeRequestId;
|
||||
private Long routeRequestKey;
|
||||
private Long legId;
|
||||
@Transient
|
||||
private Leg leg;
|
||||
|
|
|
@ -110,4 +110,12 @@ public class SystemAnnouncement implements Serializable {
|
|||
return this;
|
||||
}
|
||||
|
||||
public SystemAnnouncement updateStatusByExpiryDate(){
|
||||
LocalDateTime expiryDate = this.getExpiryDate();
|
||||
if (expiryDate.isBefore(LocalDateTime.now())) {
|
||||
this.setStatus("0");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -98,6 +98,7 @@ public class RouteOrderFactory implements OrderFactory {
|
|||
requestByRoute.setRouteRequestLegList(routeRequestLegs);
|
||||
requestByRoute.setCreateTime(LocalDateTime.now());
|
||||
requestByRoute.setUpdateTime(LocalDateTime.now());
|
||||
requestByRoute.setSupplierName(supplier);
|
||||
return requestByRoute;
|
||||
}
|
||||
|
||||
|
|
|
@ -185,7 +185,6 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
|
|||
String orderNo = flightOrderBasicInfo.getOrderID();
|
||||
String journeyNo = flightOrderBasicInfo.getJourneyID();
|
||||
RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(journeyNo);
|
||||
|
||||
return buildFlightOrderDetail(flightOrderInfoEntity, routeOrder, orderNo);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,17 +2,20 @@ package com.chint.domain.factoriy.order_record;
|
|||
|
||||
import com.chint.domain.aggregates.order.OrderDetail;
|
||||
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.OrderFlightRecord;
|
||||
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.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.data_center.user.UserHttpRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.chint.domain.service.supplier.SupplierUtil.getBelongSysType;
|
||||
|
@ -61,20 +64,42 @@ public class AmapOrderRecordExtensionFactory implements OrderRecordExtensionFact
|
|||
} else {
|
||||
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(),
|
||||
orderStatus,
|
||||
carRecordData.getGmtCreate())
|
||||
.loadBelongDeport(
|
||||
routeOrder.stream().flatMap(order ->
|
||||
Optional.ofNullable(order.getRouterOrderExtensionField().getBelongDeptCode()).stream()
|
||||
).findFirst().orElseGet(()->
|
||||
userHttpRequest.belongDeport(orderCarRecord.getBookingUserCode(), orderCarRecord.getAccountCompanyName()))
|
||||
routeOrder.stream()
|
||||
.flatMap(order ->
|
||||
Optional.of(order)
|
||||
.map(RouteOrder::getRouterOrderExtensionField)
|
||||
.map(RouterOrderExtensionField::getBelongDeptCode)
|
||||
.stream()
|
||||
)
|
||||
.findFirst()
|
||||
.orElseGet(() ->
|
||||
userHttpRequest.belongDeport(orderCarRecord.getBookingUserCode(), orderCarRecord.getAccountCompanyName()))
|
||||
);
|
||||
|
||||
String ds = carRecordData.getDs();
|
||||
|
||||
//车辆运行时间
|
||||
String gmtCreateStartTime106 = carRecordData.getGmtCreateStartTime106();
|
||||
String gmtCreateEndTime106 = carRecordData.getGmtCreateEndTime106();
|
||||
|
||||
orderCarRecord.loadTravelInfo(
|
||||
carRecordData.getGmtCreateStartTime106(),
|
||||
carRecordData.getGmtCreateEndTime106(),
|
||||
gmtCreateStartTime106,
|
||||
gmtCreateEndTime106,
|
||||
carRecordData.getCityName(),
|
||||
carRecordData.getEndCity(),
|
||||
carRecordData.getStartName(),
|
||||
|
@ -86,17 +111,19 @@ public class AmapOrderRecordExtensionFactory implements OrderRecordExtensionFact
|
|||
).loadFinancialInfo(
|
||||
ds.substring(0, 6),
|
||||
ds,
|
||||
String.valueOf(carRecordData.getOrderAmount()),
|
||||
BigDecimalCalculator.add(String.valueOf(carRecordData.getOrderAmount()), String.valueOf(carRecordData.getServicefee()))
|
||||
String.valueOf(carRecordData.getEnterpriseAmount()),
|
||||
String.valueOf(carRecordData.getEnterpriseAmount())
|
||||
).loadFeeDetails(
|
||||
"",
|
||||
"",
|
||||
String.valueOf(carRecordData.getServicefee()),
|
||||
String.valueOf(carRecordData.getCancelFee()),
|
||||
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 individualAmount = carRecordData.getIndividualAmount();
|
||||
String paymentType;
|
||||
|
@ -113,6 +140,10 @@ public class AmapOrderRecordExtensionFactory implements OrderRecordExtensionFact
|
|||
outApplyRecordId = split[split.length - 1];
|
||||
}
|
||||
orderCarRecord.loadSystemInfo(SUPPLIER_AMAP_FSSC, getBelongSysType(split[4]), split[1], split[0]);
|
||||
//补充遗漏的字段
|
||||
orderCarRecord.setProjectOrderNo(split[2]);
|
||||
orderCarRecord.setOfflineCcomyCode(split[3]);
|
||||
|
||||
orderCarRecord.loadPayment(
|
||||
paymentType,
|
||||
String.valueOf(enterpriseAmount),
|
||||
|
@ -131,6 +162,20 @@ public class AmapOrderRecordExtensionFactory implements OrderRecordExtensionFact
|
|||
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);
|
||||
return orderCarRecord;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,10 @@ import java.util.Optional;
|
|||
|
||||
public interface SupplierRepository {
|
||||
Supplier save(Supplier supplier);
|
||||
|
||||
Optional<Supplier> findById(Long id);
|
||||
|
||||
Optional<Supplier> findBySupplierName(String supplierName);
|
||||
|
||||
Iterable<Supplier> findAll();
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ import java.util.Optional;
|
|||
public interface SystemAnnouncementRepository {
|
||||
SystemAnnouncement save(SystemAnnouncement systemAnnouncement);
|
||||
|
||||
void saveAll(List<SystemAnnouncement> systemAnnouncementList);
|
||||
|
||||
Optional<SystemAnnouncement> findById(Long id);
|
||||
|
||||
Optional<SystemAnnouncement> findNew();
|
||||
|
|
|
@ -12,7 +12,6 @@ import org.springframework.stereotype.Service;
|
|||
|
||||
import java.util.ArrayList;
|
||||
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.LegConstant.*;
|
||||
|
@ -171,30 +170,48 @@ public class LegDomainService {
|
|||
}
|
||||
|
||||
public List<Leg> queryLegsCanSync(RouteOrder routeOrder, String supplierName) {
|
||||
// 获取所有Leg items并查询位置信息
|
||||
List<Leg> legItems = routeOrder.getLegItems();
|
||||
queryLocation(legItems);
|
||||
legItems = legItems.stream()
|
||||
|
||||
// 过滤Leg items
|
||||
List<Leg> filteredLegItems = legItems.stream()
|
||||
.filter(it -> !it.getLegType().equals(LEG_TYPE_OTHER) && it.legIsInternal())
|
||||
.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)
|
||||
.map(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();
|
||||
List<Leg> syncAbleLegItems = ifCanSync(filteredLegItems, routeOrder, supplier);
|
||||
syncAbleLegItems.forEach(Leg::reloadStatus);
|
||||
return syncAbleLegItems;
|
||||
})
|
||||
.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) {
|
||||
|
|
|
@ -83,6 +83,9 @@ public class OrderDomainService {
|
|||
@Autowired
|
||||
private BPMOrderDomainService bpmOrderDomainService;
|
||||
|
||||
@Autowired
|
||||
private SupplierRepository supplierRepository;
|
||||
|
||||
private Set<String> companyBlackList = new HashSet<>();
|
||||
|
||||
public RouteOrder saveOrder(RouteOrder routeOrder) {
|
||||
|
@ -174,6 +177,8 @@ public class OrderDomainService {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private boolean isSpecialEventType(Integer orderEventType) {
|
||||
return orderEventType.equals(ORDER_EVENT_ETA) ||
|
||||
orderEventType.equals(ORDER_EVENT_CHANGE) ||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.chint.domain.service;
|
||||
|
||||
import com.chint.application.commands.RouteAutoSyncCommand;
|
||||
import com.chint.domain.aggregates.order.*;
|
||||
import com.chint.domain.aggregates.supplier.Supplier;
|
||||
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.supplier.SupplierAdapterSelector;
|
||||
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.stereotype.Service;
|
||||
|
||||
|
@ -21,7 +23,8 @@ import java.util.Map;
|
|||
import java.util.Optional;
|
||||
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;
|
||||
|
||||
@Service
|
||||
|
@ -72,13 +75,33 @@ public class RouteRequestDomainService {
|
|||
// 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) {
|
||||
RouteOrder routeOrder = routeRepository.queryById(syncLegData.getRouteId());
|
||||
legDomainService.checkLegIfStartApproval(routeOrder);
|
||||
List<Long> legIds = syncLegData.getLegIds();
|
||||
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);
|
||||
if (routeRequest.getStatus().equals(ROUTE_REQUEST_STATUS_PREPARE)) {
|
||||
if (routeRequest.getStatus().equals(ROUTE_REQUEST_STATUS_PREPARE) && routeRequest.getSupplier() == null) {
|
||||
//如果是刚生成的订单需要加入行程规划单当中
|
||||
//保存供应商信息
|
||||
routeRequest.setSupplier(supplierName);
|
||||
|
@ -87,23 +110,10 @@ public class RouteRequestDomainService {
|
|||
//如果是不是刚生成的,需要调整差旅申请单的行程
|
||||
loadLegInfo(routeRequest, routeOrder, legIds);
|
||||
}
|
||||
|
||||
List<Leg> legs = routeRequest.getRouteRequestLegList()
|
||||
routeRequest.getRouteRequestLegList()
|
||||
.stream()
|
||||
.map(RouteRequestLeg::getLeg)
|
||||
.toList();
|
||||
|
||||
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)));
|
||||
|
||||
.forEach(it -> it.addEvent(legEventFactory.creatLegEvent(LEG_EVENT_NOT_ORDERED)));
|
||||
supplierRepository.findBySupplierName(supplierName)
|
||||
.ifPresentOrElse(
|
||||
supplier -> syncRouteRequest(routeRequest, supplier, routeOrder),
|
||||
|
@ -130,9 +140,7 @@ public class RouteRequestDomainService {
|
|||
List<Long> legIds = syncLegData.getLegIds();
|
||||
Long routeId = syncLegData.getRouteId();
|
||||
RouteOrder routeOrder = routeRepository.queryById(routeId);
|
||||
|
||||
Optional<RouteRequest> optionalRouteRequest = findRouteRequest(routeOrder, syncLegData);
|
||||
|
||||
optionalRouteRequest.ifPresent(routeRequest -> {
|
||||
List<Leg> legs = getLegsFromRouteRequest(routeRequest, routeOrder);
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.chint.application.dtos.system.RoleUserDto;
|
|||
import com.chint.domain.aggregates.user.Role;
|
||||
import com.chint.domain.aggregates.user.RoleUser;
|
||||
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.JdbcRoleUserRepository;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcUserRepository;
|
||||
|
@ -23,6 +24,7 @@ public class UserDomainService {
|
|||
private JdbcUserRepository jdbcUserRepository;
|
||||
@Autowired
|
||||
private JdbcRoleRepository jdbcRoleRepository;
|
||||
|
||||
@Autowired
|
||||
private JdbcRoleUserRepository jdbcRoleUserRepository;
|
||||
|
||||
|
|
|
@ -74,7 +74,9 @@ public class AuthenticateServiceImpl implements AuthenticateService {
|
|||
private UserLoginResult getUserLoginResult(User user) {
|
||||
UserLoginParam userLoginParam = user.getUserLoginParam();
|
||||
String companyCode = userLoginParam.getCompanyCode();
|
||||
if (companyCode != null && !companyCode.isEmpty()) {
|
||||
if (user.getCompanyCode() == null &&
|
||||
companyCode != null &&
|
||||
!companyCode.isEmpty()) {
|
||||
user.setCompanyCode(companyCode);
|
||||
}
|
||||
user.setUserLoginParam(userLoginParam);
|
||||
|
|
|
@ -22,6 +22,7 @@ import com.chint.domain.value_object.SyncLegData;
|
|||
import com.chint.infrastructure.constant.CommonMessageConstant;
|
||||
import com.chint.infrastructure.constant.LegConstant;
|
||||
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.util.BaseContext;
|
||||
import com.chint.infrastructure.util.OrderNo;
|
||||
|
@ -145,6 +146,9 @@ public class LegEventHandler implements LegEventService {
|
|||
//保存routeOrder的状态
|
||||
RouteOrder save = routeRepository.save(routeOrder);
|
||||
command.order(save);
|
||||
|
||||
//异步执行自动同步功能
|
||||
Command.of(RouteAutoSyncCommand.class).route(save).async().sendToQueue();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
|
|
|
@ -114,7 +114,7 @@ public class AmapOrderRecordGenerator implements OrderRecordGenerator {
|
|||
Map<String, Optional<RouteOrder>> collect = routeOrderNoList.parallelStream().collect(Collectors.toMap(Function.identity(),
|
||||
it -> routeOrderList.stream().filter(routeOrder -> routeOrder != null && routeOrder.checkIfMine(it)).findFirst()));
|
||||
List<OrderCarRecord> orderCarRecordList = amapCarOrderRecordList
|
||||
.stream()
|
||||
.parallelStream()
|
||||
.map(it -> orderRecordExtensionFactory.createCarOrderRecord(it, collect.get(it.getOutApplyRecordId())))
|
||||
.toList();
|
||||
return orderDetailDomainService.saveCarOrderRecordBatch(orderCarRecordList);
|
||||
|
|
|
@ -89,11 +89,11 @@ public class LYOrderRecordDomainService {
|
|||
List<RouteOrder> routeOrderList = routeRequestDomainService.getRouteOrder(routeOrderNoList);
|
||||
Map<String, Optional<RouteOrder>> collect = routeOrderNoList.parallelStream().collect(Collectors.toMap(Function.identity(),
|
||||
it -> routeOrderList.stream().filter(routeOrder ->routeOrder != null && routeOrder.checkIfMine(it)).findFirst()));
|
||||
List<OrderFlightRecord> orderCarRecordList = recordsTotal
|
||||
List<OrderFlightRecord> orderFlightRecordList = recordsTotal
|
||||
.stream()
|
||||
.map(it -> lyOrderRecordExtensionFactory.createFlightOrderRecord(it, collect.get(it.getOutApplayOrderNo())))
|
||||
.toList();
|
||||
orderDetailDomainService.saveFlightOrderRecordBatch(orderCarRecordList);
|
||||
orderDetailDomainService.saveFlightOrderRecordBatch(orderFlightRecordList);
|
||||
jdbcLyOrderFlightRecord.updateStatusByNullStatus();
|
||||
}
|
||||
|
||||
|
@ -129,7 +129,7 @@ public class LYOrderRecordDomainService {
|
|||
.map(it -> lyOrderRecordExtensionFactory.createHotelOrderRecord(it, collect.get(it.getOutApplayOrderNo())))
|
||||
.toList();
|
||||
orderDetailDomainService.saveHotelOrderRecordBatch(orderHotelRecordList);
|
||||
jdbcLyOrderFlightRecord.updateStatusByNullStatus();
|
||||
jdbcLyOrderHotelRecord.updateStatusByNullStatus();
|
||||
}
|
||||
|
||||
|
||||
|
@ -164,7 +164,7 @@ public class LYOrderRecordDomainService {
|
|||
.map(it -> lyOrderRecordExtensionFactory.createTrainOrderRecord(it, collect.get(it.getOutApplayOrderNo())))
|
||||
.toList();
|
||||
orderDetailDomainService.saveTrainOrderRecordBatch(orderTrainRecordList);
|
||||
jdbcLyOrderFlightRecord.updateStatusByNullStatus();
|
||||
jdbcLyOrderTrainRecord.updateStatusByNullStatus();
|
||||
}
|
||||
|
||||
|
||||
|
@ -199,7 +199,7 @@ public class LYOrderRecordDomainService {
|
|||
.map(it -> lyOrderRecordExtensionFactory.createCarOrderRecord(it, collect.get(it.getOutApplayOrderNo())))
|
||||
.toList();
|
||||
orderDetailDomainService.saveCarOrderRecordBatch(orderCarRecordList);
|
||||
jdbcLyOrderFlightRecord.updateStatusByNullStatus();
|
||||
jdbcLyOrderCarRecord.updateStatusByNullStatus();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,9 +5,11 @@ import com.chint.domain.aggregates.order.*;
|
|||
import com.chint.domain.aggregates.supplier.Supplier;
|
||||
import com.chint.domain.aggregates.supplier.SupplierProduct;
|
||||
import com.chint.domain.exceptions.AuthException;
|
||||
import com.chint.domain.exceptions.CommandException;
|
||||
import com.chint.domain.service.supplier.SupplierAdapter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.chint.infrastructure.constant.LegConstant.*;
|
||||
|
||||
|
@ -21,60 +23,118 @@ public interface SupplierOrderSync extends SupplierAdapter {
|
|||
boolean cancelRouteRequest(RouteRequest routeRequest);
|
||||
|
||||
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) {
|
||||
throw new AuthException("验证差旅申请单失败,请联系管理员");
|
||||
}
|
||||
|
||||
|
||||
// Extract routeRequestFields
|
||||
RouteRequestFields routeRequestFields = routeRequest.getRouteRequestFields();
|
||||
|
||||
// Create list of legs from routeRequest
|
||||
List<Leg> legList = routeRequest.getRouteRequestLegList()
|
||||
.stream()
|
||||
.map(RouteRequestLeg::getLeg)
|
||||
.toList();
|
||||
legList.forEach(leg -> {
|
||||
switch (leg.getLegType()) {
|
||||
case LEG_TYPE_TRAIN -> trainProductCheck(routeRequestFields, supplier);
|
||||
case LEG_TYPE_AIRPLANE -> flightProductCheck(routeRequestFields, supplier);
|
||||
case LEG_TYPE_HOTEL -> hotelProductCheck(routeRequestFields, supplier);
|
||||
case LEG_TYPE_TAXI -> carProductCheck(routeRequestFields, supplier);
|
||||
|
||||
// Legs can not be empty
|
||||
if (legList.isEmpty()) {
|
||||
if (throwError) {
|
||||
throw new CommandException("订单的行程不能为空");
|
||||
} 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) {
|
||||
supplier.carSupplierProduct()
|
||||
.ifPresent(carSupplierProduct -> productCheck(routeRequestFields, carSupplierProduct, supplier, "打车"));
|
||||
private boolean productCheckWrapper(RouteRequestFields routeRequestFields,
|
||||
Optional<SupplierProduct> supplierProductOpt,
|
||||
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) {
|
||||
supplier.flightSupplierProduct()
|
||||
.ifPresent(flightSupplierProduct -> productCheck(routeRequestFields, flightSupplierProduct, supplier, "机票"));
|
||||
}
|
||||
|
||||
private void hotelProductCheck(RouteRequestFields routeRequestFields, Supplier supplier) {
|
||||
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) {
|
||||
// General product check method
|
||||
private boolean productCheck(RouteRequestFields routeRequestFields,
|
||||
SupplierProduct supplierProduct,
|
||||
Supplier supplier,
|
||||
String legCnName,
|
||||
boolean throwError) {
|
||||
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())) {
|
||||
throw new AuthException("你目前的来源系统暂不支持使用" + supplier.getCnName() + legCnName);
|
||||
if (throwError) {
|
||||
throw new AuthException("你目前的来源系统暂不支持使用" + supplier.getCnName() + legCnName + "。");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (supplierProduct.checkSysCodeIfNotUse(routeRequestFields.getAccountCompany())) {
|
||||
throw new AuthException("你目前的公司暂不支持使用" + supplier.getCnName() + legCnName);
|
||||
if (supplierProduct.checkCompanyIfNotUse(routeRequestFields.getAccountCompany())) {
|
||||
if (throwError) {
|
||||
throw new AuthException("你目前的公司暂不支持使用" + supplier.getCnName() + legCnName + "。");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (supplierProduct.checkSysCodeIfNotUse(routeRequestFields.getAccountCompanyName())) {
|
||||
throw new AuthException("你目前的公司暂不支持使用" + supplier.getCnName() + legCnName);
|
||||
if (supplierProduct.checkCompanyIfNotUse(routeRequestFields.getAccountCompanyName())) {
|
||||
if (throwError) {
|
||||
throw new AuthException("你目前的公司暂不支持使用" + supplier.getCnName() + legCnName + "。");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,4 +9,5 @@ import java.lang.annotation.*;
|
|||
public @interface ListenTo {
|
||||
String command();
|
||||
long order();
|
||||
boolean async() default false;
|
||||
}
|
|
@ -11,6 +11,7 @@ import lombok.NoArgsConstructor;
|
|||
@NoArgsConstructor
|
||||
public abstract class Command {
|
||||
private String commandName;
|
||||
private boolean ifSync = false;
|
||||
|
||||
public Properties sendToQueue() {
|
||||
return CommandDispatcher.dispatch(this);
|
||||
|
@ -26,4 +27,9 @@ public abstract class Command {
|
|||
throw new CommandException("command create error :" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public Command async() {
|
||||
ifSync = true;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@ import org.springframework.transaction.support.TransactionTemplate;
|
|||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
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<ResultContainer> resultContainers = new ArrayList<>();
|
||||
containers.forEach(container -> {
|
||||
|
||||
Object result = null;
|
||||
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) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (result instanceof ResultContainer) {
|
||||
resultContainers.add((ResultContainer) result);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return resultContainers;
|
||||
}
|
||||
|
||||
private static List<ResultContainer> processTransitionCommand(Command command) {
|
||||
System.out.println(transitionMethods);
|
||||
List<MethodContainer> containers = transitionMethods.getOrDefault(command.getCommandName(), Collections.emptyList());
|
||||
List<ResultContainer> resultContainers = new ArrayList<>();
|
||||
transactionTemplate.execute(transactionStatus -> {
|
||||
|
|
|
@ -7,6 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
|
@ -30,4 +31,9 @@ public class SupplierRepositoryImpl implements SupplierRepository {
|
|||
public Optional<Supplier> findBySupplierName(String supplierName) {
|
||||
return jdbcSupplierRepository.findByName(supplierName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Supplier> findAll() {
|
||||
return jdbcSupplierRepository.findAll();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,12 @@ public class SystemAnnouncementRepositoryImpl implements SystemAnnouncementRepos
|
|||
return jdbcSystemAnnouncementRepository.save(systemAnnouncement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAll(List<SystemAnnouncement> systemAnnouncementList) {
|
||||
jdbcSystemAnnouncementRepository.saveAll(systemAnnouncementList)
|
||||
.forEach(it -> cacheEvictAnnouncement(it.getAnnouncementId()));
|
||||
}
|
||||
|
||||
@Cacheable(value = "SystemAnnouncement", key = "#id")
|
||||
@Override
|
||||
public Optional<SystemAnnouncement> findById(Long id) {
|
||||
|
@ -47,4 +53,9 @@ public class SystemAnnouncementRepositoryImpl implements SystemAnnouncementRepos
|
|||
public List<SystemAnnouncement> findEffective() {
|
||||
return jdbcSystemAnnouncementRepository.findByStatus("1");
|
||||
}
|
||||
|
||||
@CacheEvict(value = "SystemAnnouncement", key = "#id")
|
||||
public void cacheEvictAnnouncement(Long id) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package com.chint.interfaces.rest.ctrip.in;
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.chint.application.commands.OrderStatusChangeCommand;
|
||||
import com.chint.application.commands.SupplierCallBackErrorCommand;
|
||||
import com.chint.domain.aggregates.order.OrderDetail;
|
||||
import com.chint.domain.repository.SupplierCallBackLogRepository;
|
||||
import com.chint.domain.service.SystemDomainService;
|
||||
import com.chint.domain.service.supplier.SupplierService;
|
||||
|
@ -172,24 +171,7 @@ public class CTripNoteController {
|
|||
.outOrderStatus(orderStatus)
|
||||
.orderNo(orderId)
|
||||
.productType(legType);
|
||||
|
||||
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);
|
||||
// }
|
||||
supplierService.handleSupplierCallback(supplierCallbackData);
|
||||
return Result.Success("成功收到消息");
|
||||
}
|
||||
|
||||
|
|
|
@ -204,6 +204,7 @@ public class CTripUtils {
|
|||
!"Confirmed".equals(status) &&
|
||||
!"Wait".equals(status) &&
|
||||
!"CancellationFailed".equals(status) &&
|
||||
!"Cancelled".equals(status) &&
|
||||
!"submitFailed".equals(status) &&
|
||||
!"Approve_G".equals(status) &&
|
||||
!"Approving".equals(status) &&
|
||||
|
|
|
@ -87,33 +87,33 @@ public class CommonController {
|
|||
@PostMapping("/back")
|
||||
public LYNoteResponse Back(@RequestBody Notification notification) {
|
||||
|
||||
// int notifyType = notification.getNotifyType();
|
||||
// switch (notifyType) {
|
||||
// //进行订单数据回推
|
||||
// case 1 -> getOrderFlight(notification);
|
||||
// case 3 -> getOrderHotel(notification);
|
||||
// case 5 -> getOrderTrain(notification);
|
||||
// case 6 -> getOrderCar(notification);
|
||||
// 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("转发同程订单状态推送失败");
|
||||
}
|
||||
});
|
||||
int notifyType = notification.getNotifyType();
|
||||
switch (notifyType) {
|
||||
//进行订单数据回推
|
||||
case 1 -> getOrderFlight(notification);
|
||||
case 3 -> getOrderHotel(notification);
|
||||
case 5 -> getOrderTrain(notification);
|
||||
case 6 -> getOrderCar(notification);
|
||||
default -> LYNoteResponse.success();
|
||||
}
|
||||
|
||||
String json = gson.toJson(notification);
|
||||
log.info("存入Redis{}", json);
|
||||
redisTemplate.opsForList().leftPush(CommonMessageConstant.COMMON_BACK, json);
|
||||
|
||||
// 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);
|
||||
// redisTemplate.opsForList().leftPush(CommonMessageConstant.COMMON_BACK, json);
|
||||
return new LYNoteResponse("100", "OK");
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ public class LYOrderUtil {
|
|||
public static boolean checkTrainStatus(String status) {
|
||||
return !"N".equals(status) &&
|
||||
!"D".equals(status) &&
|
||||
!"C".equals(status) &&
|
||||
!"S".equals(status) &&
|
||||
!"G".equals(status) &&
|
||||
!"H".equals(status) &&
|
||||
|
@ -80,6 +81,7 @@ public class LYOrderUtil {
|
|||
!"22".equals(status) &&
|
||||
!"60".equals(status) &&
|
||||
!"67".equals(status) &&
|
||||
!"96".equals(status) &&
|
||||
!"99".equals(status);
|
||||
}
|
||||
|
||||
|
@ -120,7 +122,11 @@ public class LYOrderUtil {
|
|||
!"11".equals(status) &&
|
||||
!"12".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) {
|
||||
|
|
|
@ -52,7 +52,6 @@ ly:
|
|||
baseUrl: https://api.dttrip.cn/openapi
|
||||
ifForwardRequest: true
|
||||
forwardRequestBaseUrl: https://gxdev03.chint.com/routeapi
|
||||
|
||||
#高德
|
||||
amap:
|
||||
eId: 201107
|
||||
|
|
|
@ -250,7 +250,7 @@ public class CTripTest {
|
|||
@Test
|
||||
void search() {
|
||||
BaseContext.setCurrentUser(user);
|
||||
SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("32430240547");
|
||||
SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("32002090029");
|
||||
System.out.println(response);
|
||||
}
|
||||
|
||||
|
|
|
@ -820,7 +820,7 @@ public class LYTest {
|
|||
|
||||
@Test
|
||||
void searchTrain() {
|
||||
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DT24041770487265905");
|
||||
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DTC24061977736328100");
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(trainOrderDetail);
|
||||
System.out.println(json);
|
||||
|
@ -828,7 +828,7 @@ public class LYTest {
|
|||
|
||||
@Test
|
||||
void searchHotel() {
|
||||
HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240321165300961176");
|
||||
HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240406120100189791");
|
||||
Gson gson = new Gson();
|
||||
String json = gson.toJson(hotelOrderDetail);
|
||||
System.out.println(json);
|
||||
|
|
|
@ -321,7 +321,7 @@ class RouteApplicationTests {
|
|||
|
||||
@Test
|
||||
void loginSignProd() {
|
||||
String sfno = "230228069";
|
||||
String sfno = "220921136";
|
||||
String syscode = "FSSC";
|
||||
String billcode = "CLSQ240225000099";
|
||||
String companycode = "正泰集团股份有限公司";
|
||||
|
|
Loading…
Reference in New Issue