Merge remote-tracking branch 'origin/dev' into dev

# Conflicts:
#	src/main/java/com/chint/interfaces/rest/ly/in/HotelBackController.java
This commit is contained in:
huangxh3 2024-03-01 16:06:58 +08:00
commit f7538a1e11
22 changed files with 189 additions and 72 deletions

View File

@ -1,5 +1,6 @@
package com.chint.application.commands;
import com.chint.domain.aggregates.order.OrderDetail;
import com.chint.infrastructure.echo_framework.command.Command;
import lombok.Data;
@ -7,7 +8,7 @@ import lombok.Data;
public class BPMAuditCommand extends Command {
private String orderNo;
private Integer productType;
private Object extensionData;
private OrderDetail extensionData;
public BPMAuditCommand orderNo(String orderNo) {
this.orderNo = orderNo;
@ -19,7 +20,7 @@ public class BPMAuditCommand extends Command {
return this;
}
public BPMAuditCommand extensionData(Object extensionData) {
public BPMAuditCommand extensionData(OrderDetail extensionData) {
this.extensionData = extensionData;
return this;
}

View File

@ -1,6 +1,5 @@
package com.chint.application.commands;
import com.chint.domain.value_object.ApproveLegData;
import com.chint.infrastructure.echo_framework.command.Command;
import lombok.Data;
@ -8,17 +7,11 @@ import static com.chint.infrastructure.constant.LegConstant.LEG_EVENT_APPROVAL;
@Data
public class LegApprovalCommand extends Command {
private Integer LegEventType = LEG_EVENT_APPROVAL;
private Long LegId;
private ApproveLegData data;
private Integer legEventType = LEG_EVENT_APPROVAL;
private Long legId;
public LegApprovalCommand legId(Long LegId) {
this.setLegId(LegId);
return this;
}
public LegApprovalCommand data(ApproveLegData data) {
this.data = data;
return this;
}
}

View File

@ -0,0 +1,24 @@
package com.chint.application.commands;
import com.chint.domain.value_object.ApproveLegData;
import com.chint.infrastructure.echo_framework.command.Command;
import lombok.Data;
import static com.chint.infrastructure.constant.LegConstant.LEG_EVENT_APPROVAL;
@Data
public class RouteApprovalCommand extends Command {
private Integer LegEventType = LEG_EVENT_APPROVAL;
private Long LegId;
private ApproveLegData data;
public RouteApprovalCommand legId(Long LegId) {
this.setLegId(LegId);
return this;
}
public RouteApprovalCommand data(ApproveLegData data) {
this.data = data;
return this;
}
}

View File

@ -6,7 +6,7 @@ import lombok.Data;
@Data
public class HotelScheduleDetail extends ScheduleDetail {
private String lastUpdateTime;
private Integer nightCount;
private String nightCount;
public static HotelScheduleDetailBuilder builder(){
return new HotelScheduleDetailBuilder();
}
@ -19,7 +19,7 @@ public class HotelScheduleDetail extends ScheduleDetail {
return this;
}
public HotelScheduleDetailBuilder nightCount(Integer nightCount) {
public HotelScheduleDetailBuilder nightCount(String nightCount) {
hotelScheduleDetail.setNightCount(nightCount);
return this;
}

View File

@ -9,6 +9,9 @@ import java.util.List;
@Data
public class ScheduleDetail {
protected Long legId;
protected String serviceProvider;
protected String orderState;
@ -114,6 +117,10 @@ public class ScheduleDetail {
@JsonProperty("RealScheduleNum")
protected String RealScheduleNum;
@JsonProperty("NightCount")
protected String NightCount;
@JsonProperty("RoomCount")
protected String RoomCount;
// Constructor, getters and setters
@ -130,6 +137,21 @@ public class ScheduleDetail {
return this;
}
public ScheduleDetailBuilder legId(Long legId) {
scheduleDetail.setLegId(legId);
return this;
}
public ScheduleDetailBuilder nightCount(String NightCount) {
scheduleDetail.setNightCount(NightCount);
return this;
}
public ScheduleDetailBuilder roomCount(String RoomCount) {
scheduleDetail.setRoomCount(RoomCount);
return this;
}
public ScheduleDetailBuilder orderState(String orderState) {
scheduleDetail.setOrderState(orderState);
return this;

View File

@ -6,6 +6,7 @@ import com.chint.application.services.login.strategy.PailaLoginStrategy;
import com.chint.application.services.login.strategy.PailaMobileLoginStrategy;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.exceptions.OrderException;
import com.chint.domain.repository.UserRepository;
import com.chint.domain.service.SystemDomainService;
import com.chint.domain.service.auth.AuthenticateService;
import com.chint.domain.value_object.UserLoginParam;
@ -18,15 +19,18 @@ import com.chint.infrastructure.util.Digest;
import com.chint.infrastructure.util.Result;
import com.chint.interfaces.rest.ctrip.CTripUserSaveRequest;
import com.chint.interfaces.rest.ly.LYUserRequest;
import com.chint.interfaces.rest.ly.dto.login.LoginParam;
import com.chint.interfaces.rest.user.UserHttpRequest;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.concurrent.CompletableFuture;
@Slf4j
@RestController
@RequestMapping("/public")
public class LoginController {
@ -52,6 +56,9 @@ public class LoginController {
@Autowired
private PailaMobileLoginStrategy pailaMobileLoginStrategy;
@Autowired
private UserRepository userRepository;
@ApiOperation("财务共享登录")
@Transactional
@GetMapping("/login")
@ -83,17 +90,7 @@ public class LoginController {
//异步执行更新用户信息到同程
User currentUser = userLoginResult.getUser();
CompletableFuture.runAsync(() -> {
BaseContext.setCurrentUser(currentUser);
lyUserRequest.saveCurrentUser();
BaseContext.removeCurrentUser();
});
//异步执行更新用户信息到携程
CompletableFuture.runAsync(() -> {
BaseContext.setCurrentUser(currentUser);
cTripUserSaveRequest.saveUserToCTrip();
BaseContext.removeCurrentUser();
});
syncUserInfoToSupplier(currentUser);
//清除职级信息
userLoginResult.getUser().setProfLevel(null);
@ -107,7 +104,7 @@ public class LoginController {
@ApiOperation("商旅平台单点")
@Transactional
@PostMapping("/login/sso")
public Result<UserLoginResult> loginSSO(@RequestBody UserLoginParam userLoginParam){
public Result<UserLoginResult> loginSSO(@RequestBody UserLoginParam userLoginParam) {
String employeeNo = pailaLoginStrategy.login(userLoginParam.getCode());
@ -117,18 +114,7 @@ public class LoginController {
//异步执行更新用户信息到同程
User currentUser = userLoginResult.getUser();
CompletableFuture.runAsync(() -> {
BaseContext.setCurrentUser(currentUser);
lyUserRequest.saveCurrentUser();
BaseContext.removeCurrentUser();
});
//异步执行更新用户信息到携程
CompletableFuture.runAsync(() -> {
BaseContext.setCurrentUser(currentUser);
cTripUserSaveRequest.saveUserToCTrip();
BaseContext.removeCurrentUser();
});
syncUserInfoToSupplier(currentUser);
//清除职级信息
userLoginResult.getUser().setProfLevel(null);
userLoginResult.getUser().setManaLevel(null);
@ -138,7 +124,7 @@ public class LoginController {
@ApiOperation("商旅平台移动端单点")
@Transactional
@PostMapping("/login/sso/mobile")
public Result<UserLoginResult> loginSSOMobile(@RequestBody UserLoginParam userLoginParam){
public Result<UserLoginResult> loginSSOMobile(@RequestBody UserLoginParam userLoginParam) {
String employeeNo = pailaMobileLoginStrategy.login(userLoginParam.getCode());
@ -148,21 +134,51 @@ public class LoginController {
//异步执行更新用户信息到同程
User currentUser = userLoginResult.getUser();
CompletableFuture.runAsync(() -> {
BaseContext.setCurrentUser(currentUser);
lyUserRequest.saveCurrentUser();
BaseContext.removeCurrentUser();
});
//异步执行更新用户信息到携程
CompletableFuture.runAsync(() -> {
BaseContext.setCurrentUser(currentUser);
cTripUserSaveRequest.saveUserToCTrip();
BaseContext.removeCurrentUser();
});
syncUserInfoToSupplier(currentUser);
//清除职级信息
userLoginResult.getUser().setProfLevel(null);
userLoginResult.getUser().setManaLevel(null);
return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult);
}
private void syncUserInfoToSupplier(User user) {
// 给定的 LocalDateTime 实例示例中为2024年3月1日15:00
LocalDateTime lastSyncTime = user.getSyncTime();
if (lastSyncTime == null) {
asyncUser(user);
return;
}
// 获取当前时间
LocalDateTime now = LocalDateTime.now();
// 计算当前时间与给定时间之间的持续时间
Duration duration = Duration.between(lastSyncTime, now);
// 判断是否超过一天
if (duration.toDays() >= 1) {
asyncUser(user);
} else {
log.info("未超过一天,不执行同步。");
}
}
private void asyncUser(User user) {
// 如果超过一天执行同步代码
CompletableFuture.runAsync(() -> {
BaseContext.setCurrentUser(user);
lyUserRequest.saveCurrentUser();
BaseContext.removeCurrentUser();
});
//异步执行更新用户信息到携程
CompletableFuture.runAsync(() -> {
BaseContext.setCurrentUser(user);
cTripUserSaveRequest.saveUserToCTrip();
BaseContext.removeCurrentUser();
});
// 发送保存用户同步时间
user.setSyncTime(LocalDateTime.now());
userRepository.save(user);
}
}

View File

@ -19,6 +19,7 @@ import com.chint.infrastructure.constant.FSSCConstant;
import com.chint.infrastructure.constant.LegConstant;
import com.chint.infrastructure.util.BaseContext;
import com.chint.infrastructure.util.PageResult;
import com.chint.infrastructure.util.StringCheck;
import com.chint.interfaces.rest.user.UserHttpRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
@ -32,6 +33,7 @@ import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_HOTEL;
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.ORDER_STATUS_APPROVAL;
@ -68,6 +70,12 @@ public class OrderQuery {
public PageResult<RouteOrderPageRes> pageQuery(OrderQueryData queryData) {
if (StringCheck.isFirstCharacterChinese(queryData.getKeyWord())) {
queryData.setInstructions(queryData.getKeyWord());
} else {
queryData.setOrderNo(queryData.getKeyWord());
}
//执行筛选分页查询
List<Integer> approvalStatusCodes = queryData.getApprovalStatusCodes();
List<Integer> legTypes = queryData.getLegTypes();
@ -230,7 +238,9 @@ public class OrderQuery {
leg.reloadStatus();
CityEntity originCity;
CityEntity destinationCity;
ScheduleDetail.ScheduleDetailBuilder scheduleDetailBuilder = ScheduleDetail.builder();
ScheduleDetail.ScheduleDetailBuilder scheduleDetailBuilder = ScheduleDetail
.builder()
.legId(leg.getLegId());
if (!leg.getLegType().equals(LegConstant.LEG_TYPE_OTHER)) {
if (leg.getOriginLocation() != null) {
@ -256,6 +266,12 @@ public class OrderQuery {
}
}
if (leg.getLegType().equals(LEG_TYPE_HOTEL)) {
scheduleDetailBuilder
.roomCount("1")
.nightCount(leg.nightCount().toString());
}
if (leg.getCurrencyType() != null) {
scheduleDetailBuilder
.currencyName(leg.getCurrencyType().getDescription())
@ -301,7 +317,7 @@ public class OrderQuery {
return switch (legType) {
case LegConstant.LEG_TYPE_TRAIN -> FSSCConstant.TRIP_CALLBACK_TRAIN_TYPE;
case LegConstant.LEG_TYPE_AIRPLANE -> FSSCConstant.TRIP_CALLBACK_FLIGHT_TYPE;
case LegConstant.LEG_TYPE_HOTEL -> FSSCConstant.TRIP_CALLBACK_HOTEL_TYPE;
case LEG_TYPE_HOTEL -> FSSCConstant.TRIP_CALLBACK_HOTEL_TYPE;
case LegConstant.LEG_TYPE_TAXI -> FSSCConstant.TRIP_CALLBACK_OTHER_TYPE;
case LegConstant.LEG_TYPE_OTHER -> FSSCConstant.TRIP_CALLBACK_OTHER_TYPE;
default -> FSSCConstant.TRIP_CALLBACK_OTHER_TYPE;

View File

@ -28,8 +28,7 @@ import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_NOT_ORDERED;
import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_PREPARE;
import static com.chint.infrastructure.constant.RouteConstant.*;
@Service
public class OrderApplicationService {
@ -77,7 +76,14 @@ public class OrderApplicationService {
List<Leg> legs = processLegData(addLegData.getLegData(), order);
RouteOrder routeOrder = orderDomainService.saveOrder(order);
legs.forEach(leg -> Command.of(LegPrepareCommand.class).legId(leg.getLegId()).sendToQueue());
legs.forEach(leg -> {
Command.of(LegPrepareCommand.class).legId(leg.getLegId()).sendToQueue();
//如果订单状态已经处于审批中 那么为这个新增的leg也提交审批状态
if (order.getOrderStatus() >= ORDER_STATUS_APPROVAL) {
Command.of(LegApprovalCommand.class).legId(leg.getLegId()).sendToQueue();
}
});
//异步操作-如果是当前的状态已经进行过匹配那么就要订单同步到供应商一次
if (order.getOrderStatus() >= ORDER_STATUS_NOT_ORDERED) {
@ -142,7 +148,7 @@ public class OrderApplicationService {
@Transactional
public void approve(ApproveLegData approveLegData) {
Command.of(LegApprovalCommand.class).data(approveLegData).sendToQueue();
Command.of(RouteApprovalCommand.class).data(approveLegData).sendToQueue();
}
@Transactional

View File

@ -16,8 +16,10 @@ import org.springframework.data.relational.core.mapping.Column;
import org.springframework.data.relational.core.mapping.MappedCollection;
import org.springframework.data.relational.core.mapping.Table;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.util.*;
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_OTHER;
@ -212,6 +214,17 @@ public class Leg {
.max(Integer::compareTo);
}
public Integer nightCount() {
return calculateNightsBetweenDates(LocalDate.from(this.startTime),
LocalDate.from(this.endTime));
}
public static int calculateNightsBetweenDates(LocalDate start, LocalDate end) {
// 计算两个日期之间的天数差异不包括结束日期
long daysBetween = ChronoUnit.DAYS.between(start, end);
// 将天数差异转换为晚上数量
return (int) daysBetween;
}
// private Leg timeFormatter() {
// DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// String string = this.startTime.toString();

View File

@ -43,6 +43,10 @@ public class HotCityTag {
internationalCitys.add("欧洲_挪威_奥斯陆市_奥斯陆_");
internationalCitys.add("北美洲_美国_加利福尼亚州_旧金山_");
internationalCitys.add("亚洲_新加坡_新加坡_新加坡_");
internationalCitys.add("亚洲_中国_香港_香港_");
internationalCitys.add("亚洲_中国_澳门_澳门_");
internationalCitys.add("亚洲_中国_台湾_台北_");
}

View File

@ -9,4 +9,5 @@ public class SystemCode {
private Long id;
private String systemName;
private String systemCode;
private String bpmCode;
}

View File

@ -11,6 +11,7 @@ import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;
import org.springframework.data.relational.core.mapping.Table;
import java.time.LocalDateTime;
import java.util.Map;
@Data
@ -27,6 +28,7 @@ public class User {
private String gender;
private String phoneNumber;
private String password;
private LocalDateTime syncTime;
@Transient
private String standardLevel;
@Transient
@ -47,7 +49,7 @@ public class User {
this.employeeNo = employeeNo;
}
public User(Long userId, String employeeNo, Integer employeeLevel, String name, String email, String phoneNumber, UserLoginParam userLoginParam, String standardLevel,String companyCode) {
public User(Long userId, String employeeNo, Integer employeeLevel, String name, String email, String phoneNumber, UserLoginParam userLoginParam, String standardLevel, String companyCode) {
this.userId = userId;
this.employeeNo = employeeNo;
this.employeeLevel = employeeLevel;
@ -80,7 +82,7 @@ public class User {
Claim employeeNo = claims.get(AuthMessageConstant.USER_EMPLOYEE_NO);
Claim name = claims.get(AuthMessageConstant.USER_NAME);
Claim employeeLevel = claims.get(AuthMessageConstant.USER_EMPLOYEE_LEVEL);
// Claim rankCode = claims.get(AuthMessageConstant.USER_RANK_CODE);
// Claim rankCode = claims.get(AuthMessageConstant.USER_RANK_CODE);
Claim companyCode = claims.get(AuthMessageConstant.USER_COMPANY_CODE);
Claim loginParam = claims.get(AuthMessageConstant.USER_LOGIN_PARAM);
Claim standardLevel = claims.get(AuthMessageConstant.USER_STANDARD_LEVEL);

View File

@ -32,6 +32,7 @@ public class LocationDomainService {
}
private List<Location> getLocationsByType(LocationParam locationParam, List<Location> queryByCityName) {
System.out.println(queryByCityName);
Integer cityType = locationParam.getCityType();
return switch (cityType) {
case LocationConstant.CITY_TYPE_DOMESTIC -> queryByCityName

View File

@ -126,15 +126,17 @@ public class OrderDomainService {
Command.of(BPMAuditCommand.class)
.orderNo(orderDetail.getOrderNo())
.productType(orderDetail.getProductType())
.extensionData(orderDetail.getExtensionDataByProductType())
.extensionData(orderDetail)
.sendToQueue();
}
;
}
@ListenTo(command = "BPMAuditCommand", order = 0)
public void toBpmAudit(BPMAuditCommand command) {
Object data = command.getExtensionData();
OrderDetail orderDetail = command.getExtensionData();
Object data = orderDetail.getExtensionDataByProductType();
RouteOrder routeOrder = routeRepository.queryById(orderDetail.getRouteId());
String sysCode = routeOrder.getApproveOrderNo().getSysCode();
ExceedStandardDto exceedStandardDto = switch (command.getProductType()) {
case LegConstant.LEG_TYPE_TRAIN -> bpmParamFactory.creatAuditParamByTrain((TrainOrderDetail) data);
case LegConstant.LEG_TYPE_AIRPLANE -> bpmParamFactory.creatAuditParamByFlight((FlightOrderDetail) data);
@ -143,7 +145,7 @@ public class OrderDomainService {
case LegConstant.LEG_TYPE_OTHER -> bpmParamFactory.creatAuditParamByOther((OtherOrderDetail) data);
default -> throw new NotFoundException(CommonMessageConstant.NOT_FOUND);
};
DelayDispatch.attemptToSend(() -> bpmRequest.exceedStandard(exceedStandardDto).getSuccess(),
DelayDispatch.attemptToSend(() -> bpmRequest.exceedStandard(exceedStandardDto, sysCode).getSuccess(),
0);
}
}

View File

@ -72,7 +72,7 @@ public class LegEventHandler implements LegEventService {
@Transactional
@Override
public void approveLeg(LegApprovalCommand command) {
public void approveRoute(RouteApprovalCommand command) {
ApproveLegData data = command.getData();
RouteOrder routeOrder = routeRepository.findByFakeOrderNoAndSysCode(data.getFakeOrderNo(), data.getSysCode()).reloadStatus();
if (routeOrder.getLegItems().isEmpty()) {
@ -135,6 +135,13 @@ public class LegEventHandler implements LegEventService {
}
}
@Override
public void approveLeg(LegApprovalCommand command) {
Leg leg = legRepository.findByLegId(command.getLegId());
leg.addEvent(legEventFactory.creatLegEvent(command.getLegEventType()));
legRepository.save(leg);
}
@Transactional
@Override
public ResultContainer routeUpdateOrder(RouteUpdateOrderCommand command) {

View File

@ -8,10 +8,12 @@ public interface LegEventService {
void prepareLeg(LegPrepareCommand command);
//审批事件要从bpm或其他平台接收到一个真实订单
void approveLeg(LegApprovalCommand command);
void approveRoute(RouteApprovalCommand command);
void syncLeg(LegSyncCommand command);
void approveLeg(LegApprovalCommand command);
//下单事件
ResultContainer orderLeg(LegOrderedCommand command);

View File

@ -23,10 +23,10 @@ public class LegEventServiceImpl implements LegEventService {
//因为审批是针对整个订单的因此所有订单下属的行程节点触发审批事件
//出发审批提交事件 需要生成 差旅单 将差旅但提交到供应商
//根据command里面选择的数据来讲差旅但提交到不同的实现类当中
@ListenTo(command = "LegApprovalCommand", order = 0)
@ListenTo(command = "RouteApprovalCommand", order = 0)
@Override
public void approveLeg(LegApprovalCommand command) {
legEventHandler.approveLeg(command);
public void approveRoute(RouteApprovalCommand command) {
legEventHandler.approveRoute(command);
}
//这里需要获取同步类价格routeOrder同步到供应商
@ -36,6 +36,13 @@ public class LegEventServiceImpl implements LegEventService {
legEventHandler.syncLeg(command);
}
@ListenTo(command = "LegApprovalCommand", order = 0)
@Override
public void approveLeg(LegApprovalCommand command) {
legEventHandler.approveLeg(command);
}
//下单时间要求回传需要付款的金额以及生成对于的行程订单号如果没有行程订单号根据地点和时间进行匹配
@ListenTo(command = "LegOrderedCommand", order = 0)
@Override

View File

@ -94,6 +94,8 @@ public class LocationRepositoryImpl implements LocationRepository {
List<Location> hotCities =
jdbcLocationRepository.findByLocationPathNameInAndLevel(locationNames,3);
return hotCities;
}

View File

@ -41,7 +41,7 @@ public class BPMRequest {
private String XNBPMUrl;
//超标申请
public BPMResponse exceedStandard(ExceedStandardDto exceedStandardDto) {
public BPMResponse exceedStandard(ExceedStandardDto exceedStandardDto , String sysCode ) {
if ("H3BPM".equals("XNBPM")) {
return XNBPMSubmitWorkflow("JG_AS_CLCESQ", exceedStandardDto);
} else {

View File

@ -34,6 +34,5 @@ public class CommonController {
case 6-> carBackController.carBack(notification);
default -> new LYNoteResponse("200", "失败");
};
}
}

View File

@ -81,7 +81,6 @@ public class HotelBackController {
case 1 -> OrderConstant.ORDER_EVENT_PAYED;//确认中
case 2,3,6 -> OrderConstant.ORDER_EVENT_ORDERED;//待入住,已变更,已退房
case 4,5 -> OrderConstant.ORDER_EVENT_CANCEL;//已取消,预定失败
// case 50 -> OrderConstant.ORDER_EVENT_ETA;//超标
default -> -99;
};
}

View File

@ -139,9 +139,9 @@ class RouteApplicationTests {
}
@Test
void loginSign() {
String sfno = "230615020";
String sfno = "090223001";
String syscode = "FSSC";
String billcode = "CLSQ20240228";
String billcode = "CLSQ240226000004";
String companycode = "正泰集团股份有限公司";
String sec = "Superdandan";
String timespan = "1708908662738";