Compare commits
12 Commits
3594267e0b
...
2ccc93fdd9
Author | SHA1 | Date |
---|---|---|
lulz1 | 2ccc93fdd9 | |
lulz1 | 9de63a32c9 | |
lulz1 | 0d8b55f6d7 | |
lulz1 | b6207c278b | |
lulz1 | 5c4fa0b63a | |
lulz1 | 4e29974760 | |
lulz1 | f0f4b20315 | |
lulz1 | 09a5a39bfe | |
lulz1 | 5ec5842d4a | |
lulz1 | 2d48aeb8df | |
lulz1 | ec68c44112 | |
lulz1 | 94c04eccda |
32
pom.xml
32
pom.xml
|
@ -13,9 +13,8 @@
|
|||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>Route</name>
|
||||
<description>Route</description>
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
@ -66,33 +65,30 @@
|
|||
<artifactId>hutool-all</artifactId>
|
||||
<version>5.7.22</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.belerweb</groupId>
|
||||
<artifactId>pinyin4j</artifactId>
|
||||
<version>2.5.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.xiaoymin</groupId>
|
||||
<artifactId>knife4j-spring-boot-starter</artifactId>
|
||||
<version>3.0.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-actuator</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>
|
||||
app
|
||||
</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<image>
|
||||
<builder>paketobuildpacks/builder-jammy-base:latest</builder>
|
||||
</image>
|
||||
<excludes>
|
||||
<exclude>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</exclude>
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
|
|
@ -8,4 +8,6 @@ public class LocationParam extends BaseQuery {
|
|||
private Long level;
|
||||
private Long parentLocationId;
|
||||
private String cityName;
|
||||
private String firstLetter;
|
||||
private Integer cityType;
|
||||
}
|
||||
|
|
|
@ -66,5 +66,4 @@ public class OrderController {
|
|||
orderApplicationService.reject(rejectLegData);
|
||||
return Result.Success(SUCCESS);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.chint.application.out;
|
|||
import com.chint.application.dtos.LocationParam;
|
||||
import com.chint.domain.aggregates.order.Location;
|
||||
import com.chint.domain.repository.LocationRepository;
|
||||
import com.chint.domain.service.LocationDomainService;
|
||||
import com.chint.infrastructure.util.PageResult;
|
||||
import com.chint.infrastructure.util.Result;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
@ -12,6 +13,8 @@ import org.springframework.web.bind.annotation.RequestBody;
|
|||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.chint.infrastructure.constant.Constant.SUCCESS;
|
||||
|
||||
@RestController
|
||||
|
@ -21,9 +24,18 @@ public class LocationController {
|
|||
@Autowired
|
||||
private LocationRepository locationRepository;
|
||||
|
||||
@Autowired
|
||||
private LocationDomainService locationDomainService;
|
||||
|
||||
@ApiOperation("分页查询地理信息")
|
||||
@PostMapping("/pageQuery")
|
||||
public Result<PageResult<Location>> pageQuery(@RequestBody LocationParam locationParam) {
|
||||
return Result.Success(SUCCESS, locationRepository.pageQuery(locationParam));
|
||||
}
|
||||
|
||||
@ApiOperation("根据首字母查询地理信息")
|
||||
@PostMapping("/query/firstLetter")
|
||||
public Result<List<Location>> queryByFirstLetter(@RequestBody LocationParam locationParam) {
|
||||
return Result.Success(SUCCESS, locationDomainService.queryByFirstLetter(locationParam));
|
||||
}
|
||||
}
|
|
@ -3,8 +3,9 @@ package com.chint.application.out;
|
|||
|
||||
import com.chint.application.queryies.OrderQuery;
|
||||
import com.chint.domain.aggregates.order.RouteOrder;
|
||||
import com.chint.domain.repository.RouteRepository;
|
||||
import com.chint.domain.value_object.OrderQueryData;
|
||||
import com.chint.domain.value_object.PriceQueryData;
|
||||
import com.chint.domain.value_object.TrainPriceData;
|
||||
import com.chint.infrastructure.util.PageResult;
|
||||
import com.chint.infrastructure.util.Result;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
@ -24,6 +25,7 @@ public class OrderOutController {
|
|||
@Autowired
|
||||
private OrderQuery orderQuery;
|
||||
|
||||
|
||||
@ApiOperation("根据临时单号查询订单")
|
||||
@PostMapping("/query/billcode")
|
||||
public Result<RouteOrder> queryOrderByBillCode(@RequestBody OrderQueryData queryData) {
|
||||
|
@ -43,4 +45,10 @@ public class OrderOutController {
|
|||
return Result.Success(SUCCESS, orderQuery.pageQuery(queryData));
|
||||
}
|
||||
|
||||
@ApiOperation("查询火车估算价格")
|
||||
@PostMapping("/estimate/train")
|
||||
public Result<TrainPriceData> estimateTrainPrice(@RequestBody PriceQueryData priceQueryData) {
|
||||
return Result.Success(SUCCESS, orderQuery.queryTrainPrice(priceQueryData));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
package com.chint.application.queryies;
|
||||
|
||||
import com.chint.application.queryies.estimate.EstimatePrice;
|
||||
import com.chint.domain.aggregates.order.RouteOrder;
|
||||
import com.chint.domain.repository.RouteRepository;
|
||||
import com.chint.domain.service.OrderDomainService;
|
||||
import com.chint.domain.value_object.FlightPriceData;
|
||||
import com.chint.domain.value_object.OrderQueryData;
|
||||
import com.chint.domain.value_object.PriceQueryData;
|
||||
import com.chint.domain.value_object.TrainPriceData;
|
||||
import com.chint.infrastructure.util.PageResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -17,6 +21,9 @@ public class OrderQuery {
|
|||
@Autowired
|
||||
private OrderDomainService orderDomainService;
|
||||
|
||||
@Autowired
|
||||
private EstimatePrice estimatePrice;
|
||||
|
||||
public RouteOrder queryByOrderId(OrderQueryData queryData) {
|
||||
return routeRepository.queryById(queryData.getRouteId()).reloadStatus();
|
||||
}
|
||||
|
@ -38,4 +45,12 @@ public class OrderQuery {
|
|||
public RouteOrder queryByBillCode(String billCode) {
|
||||
return routeRepository.findByFakeOrderNo(billCode);
|
||||
}
|
||||
|
||||
public TrainPriceData queryTrainPrice(PriceQueryData priceQueryData) {
|
||||
return estimatePrice.queryTrainPrice(priceQueryData);
|
||||
}
|
||||
|
||||
public FlightPriceData queryFlightPrice(PriceQueryData priceQueryData) {
|
||||
return estimatePrice.queryFlightPrice(priceQueryData);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
package com.chint.application.queryies.estimate;
|
||||
|
||||
import com.chint.domain.repository.CityRepository;
|
||||
import com.chint.domain.value_object.FlightPriceData;
|
||||
import com.chint.domain.value_object.PriceQueryData;
|
||||
import com.chint.domain.value_object.TrainPriceData;
|
||||
import com.chint.interfaces.rest.ctrip.CTripEstimateRequest;
|
||||
import com.chint.interfaces.rest.ctrip.dto.estimate.request.BookingRelatedApiRequest;
|
||||
import com.chint.interfaces.rest.ctrip.dto.estimate.request.TrainProductInfo;
|
||||
import com.chint.interfaces.rest.ctrip.dto.estimate.response.BookingRelatedApiResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.estimate.response.CTripSeatType;
|
||||
import com.chint.interfaces.rest.ctrip.dto.estimate.response.TrainValuationResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class CTripEstimatePrice implements EstimatePrice {
|
||||
|
||||
@Autowired
|
||||
private CTripEstimateRequest cTripEstimateRequest;
|
||||
@Autowired
|
||||
private CityRepository cityRepository;
|
||||
|
||||
@Override
|
||||
public TrainPriceData queryTrainPrice(PriceQueryData priceQueryData) {
|
||||
TrainProductInfo trainProductInfo = new TrainProductInfo();
|
||||
|
||||
trainProductInfo.setArriveCityID(
|
||||
cityRepository.findByCityName(priceQueryData.getArriveCity()).getCity()
|
||||
);
|
||||
trainProductInfo.setDepartCityID(
|
||||
cityRepository.findByCityName(priceQueryData.getDepartCity()).getCity()
|
||||
);
|
||||
trainProductInfo.setDepartDate(priceQueryData.getDepartDate());
|
||||
trainProductInfo.setReturnNoTicket(true);
|
||||
|
||||
BookingRelatedApiRequest bookingRelatedApiRequest = cTripEstimateRequest
|
||||
.generateBaseRequest(null, trainProductInfo);
|
||||
BookingRelatedApiResponse estimate = cTripEstimateRequest.estimate(bookingRelatedApiRequest);
|
||||
TrainValuationResult trainValuationResult = estimate.getData().getTrainValuationResult();
|
||||
|
||||
TrainPriceData trainPriceData = new TrainPriceData();
|
||||
trainPriceData.setMaxPrice(String.valueOf(trainValuationResult.getMaxPrice()));
|
||||
trainValuationResult.getSeatMaxPriceInfoList().forEach(seatMaxPriceInfo -> {
|
||||
String seatCode = seatMaxPriceInfo.getSeatCode();
|
||||
trainPriceData.addSeatInfo(CTripSeatType.getDescriptionByCode(
|
||||
Integer.parseInt(seatCode)),
|
||||
String.valueOf(seatMaxPriceInfo.getMaxPrice()),
|
||||
seatCode);
|
||||
});
|
||||
return trainPriceData;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FlightPriceData queryFlightPrice(PriceQueryData priceQueryData) {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.chint.application.queryies.estimate;
|
||||
|
||||
import com.chint.domain.value_object.FlightPriceData;
|
||||
import com.chint.domain.value_object.PriceQueryData;
|
||||
import com.chint.domain.value_object.TrainPriceData;
|
||||
|
||||
|
||||
public interface EstimatePrice {
|
||||
TrainPriceData queryTrainPrice(PriceQueryData priceQueryData);
|
||||
|
||||
FlightPriceData queryFlightPrice(PriceQueryData priceQueryData);
|
||||
}
|
|
@ -4,6 +4,7 @@ package com.chint.domain.aggregates.order;
|
|||
import com.chint.domain.exceptions.LegEventException;
|
||||
import com.chint.domain.service.amount_estimate.EstimateAdapter;
|
||||
import com.chint.domain.value_object.LegData;
|
||||
import com.chint.infrastructure.util.BigDecimalCalculator;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.data.annotation.Id;
|
||||
|
@ -32,6 +33,8 @@ public class Leg {
|
|||
|
||||
private LocalDateTime endTime;
|
||||
|
||||
private String estimateAmount;
|
||||
|
||||
@Column("origin_id")
|
||||
private Long originId;
|
||||
@Transient
|
||||
|
@ -45,15 +48,13 @@ public class Leg {
|
|||
@Transient
|
||||
private String amount;
|
||||
@Transient
|
||||
private String estimateAmount;
|
||||
@Transient
|
||||
private String legTypeName;
|
||||
@Transient
|
||||
private Integer legStatus;
|
||||
@Transient
|
||||
private String legStatusName;
|
||||
@Transient
|
||||
private OrderDetail orderDetail; //这个属性不做持久化保存 ,根据下单事件进行获取
|
||||
private List<OrderDetail> orderDetails; //这个属性不做持久化保存 ,根据下单事件进行获取
|
||||
|
||||
@MappedCollection(idColumn = "leg_id", keyColumn = "leg_key")
|
||||
private List<LegEvent> eventList;
|
||||
|
@ -89,14 +90,17 @@ public class Leg {
|
|||
// If the latest event is an order event, update the amount
|
||||
if (latestEvent.getEventType() >= LEG_EVENT_ORDERED) {
|
||||
//获取最新的下单事件
|
||||
LegEvent latestOrderEvent = this.eventList
|
||||
this.eventList
|
||||
.stream()
|
||||
.filter(legEvent -> legEvent.getEventType().equals(LEG_EVENT_ORDERED))
|
||||
.max(Comparator.comparingLong(LegEvent::getLegEventId))
|
||||
.orElse(null);
|
||||
Optional.ofNullable(latestOrderEvent.getOrderDetail()).ifPresent(detail -> {
|
||||
this.amount = detail.getPrice();
|
||||
this.orderDetail = detail;
|
||||
.flatMap(event -> Optional.ofNullable(event.getOrderDetails()))
|
||||
.ifPresent(detail -> {
|
||||
this.amount = detail.stream()
|
||||
.map(OrderDetail::getPrice)
|
||||
.reduce(BigDecimalCalculator::add)
|
||||
.orElse(KEEP_TWO_DECIMAL_ZERO);
|
||||
this.orderDetails = detail;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ import org.springframework.data.relational.core.mapping.MappedCollection;
|
|||
import org.springframework.data.relational.core.mapping.Table;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.chint.infrastructure.constant.Constant.*;
|
||||
|
||||
|
@ -25,8 +27,8 @@ public class LegEvent {
|
|||
|
||||
private LocalDateTime happenTime;
|
||||
|
||||
@MappedCollection(idColumn = "order_id")
|
||||
private OrderDetail orderDetail;
|
||||
@MappedCollection(idColumn = "leg_event_id",keyColumn = "leg_event_key")
|
||||
private List<OrderDetail> orderDetails;
|
||||
|
||||
public String translateLegEvent(int event) {
|
||||
return switch (event) {
|
||||
|
@ -46,8 +48,11 @@ public class LegEvent {
|
|||
return this;
|
||||
}
|
||||
|
||||
public LegEvent orderDetail(OrderDetail orderDetail) {
|
||||
this.setOrderDetail(orderDetail);
|
||||
public LegEvent addOrderDetail(OrderDetail orderDetail){
|
||||
if(this.orderDetails == null){
|
||||
this.orderDetails = new ArrayList<>();
|
||||
}
|
||||
this.orderDetails.add(orderDetail);
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ public class Location {
|
|||
private String locationPathName;
|
||||
private String locationName;
|
||||
private String locationShortName;
|
||||
private String firstPinYin;
|
||||
private Long parentLocationId;
|
||||
@Column("level")
|
||||
private Integer level;
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
package com.chint.domain.factoriy.user;
|
||||
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
|
||||
public interface UserFactory {
|
||||
User create(String employeeNo);
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
package com.chint.domain.factoriy.user;
|
||||
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class UserFactoryImpl implements UserFactory {
|
||||
@Override
|
||||
public User create(String employeeNo) {
|
||||
User user = new User();
|
||||
user.setEmployeeNo(Long.valueOf(employeeNo));
|
||||
return user;
|
||||
}
|
||||
}
|
|
@ -4,8 +4,17 @@ import com.chint.application.dtos.LocationParam;
|
|||
import com.chint.domain.aggregates.order.Location;
|
||||
import com.chint.infrastructure.util.PageResult;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface LocationRepository {
|
||||
// List<Location> findByHot(List<LocationHot> locationHots);
|
||||
Location findByLocationId(Long locationId);
|
||||
|
||||
PageResult<Location> pageQuery(LocationParam locationParam);
|
||||
|
||||
List<Location> findAll();
|
||||
|
||||
void saveAll(List<Location> locations);
|
||||
|
||||
List<Location> findByFirstLetter(LocationParam locationParam);
|
||||
}
|
|
@ -5,4 +5,6 @@ import com.chint.domain.aggregates.user.User;
|
|||
public interface UserRepository {
|
||||
User findById(Long id);
|
||||
User findByUserEmployeeNo(Long employeeNo);
|
||||
|
||||
User save(User user);
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.chint.domain.service;
|
||||
|
||||
import com.chint.application.dtos.LocationParam;
|
||||
import com.chint.domain.aggregates.order.Location;
|
||||
import com.chint.domain.exceptions.NotFoundException;
|
||||
import com.chint.domain.repository.LocationRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.chint.infrastructure.constant.Constant.*;
|
||||
|
||||
@Service
|
||||
public class LocationDomainService {
|
||||
|
||||
@Autowired
|
||||
private LocationRepository locationRepository;
|
||||
|
||||
public List<Location> queryByFirstLetter(LocationParam locationParam) {
|
||||
List<Location> byFirstPinYin = locationRepository.findByFirstLetter(locationParam);
|
||||
Integer cityType = locationParam.getCityType();
|
||||
return switch (cityType) {
|
||||
case CITY_TYPE_DOMESTIC -> byFirstPinYin
|
||||
.stream()
|
||||
.filter(location -> location.getLocationPath().startsWith(CITY_TYPE_DOMESTIC_PATH)).toList();
|
||||
|
||||
case CITY_TYPE_FOREIGN -> byFirstPinYin
|
||||
.stream()
|
||||
.filter(location -> !location.getLocationPath().startsWith(CITY_TYPE_DOMESTIC_PATH)).toList();
|
||||
default -> throw new NotFoundException(NOT_FOUND);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -2,12 +2,20 @@ package com.chint.domain.service.amount_estimate;
|
|||
|
||||
import com.chint.domain.aggregates.order.Leg;
|
||||
import com.chint.domain.aggregates.order.RouteOrder;
|
||||
import com.chint.interfaces.rest.ctrip.CTripEstimateRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class CTripEstimate implements AmountEstimate {
|
||||
|
||||
@Autowired
|
||||
private CTripEstimateRequest cTripEstimateRequest;
|
||||
@Override
|
||||
public String amountEstimate(Leg leg) {
|
||||
|
||||
// cTripEstimateRequest.generateBaseRequest(null,)
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package com.chint.domain.service.auth;
|
||||
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.factoriy.user.UserFactory;
|
||||
import com.chint.domain.repository.UserRepository;
|
||||
import com.chint.domain.value_object.UserLoginParam;
|
||||
import com.chint.domain.value_object.UserLoginResult;
|
||||
import com.chint.infrastructure.util.Digest;
|
||||
import com.chint.infrastructure.util.JWTUtil;
|
||||
import com.chint.infrastructure.util.Json;
|
||||
import com.chint.infrastructure.util.Token;
|
||||
|
@ -21,6 +23,9 @@ public class AuthenticateServiceImpl implements AuthenticateService {
|
|||
private final UserRepository userRepository;
|
||||
private final UserHttpRequest httpRequest;
|
||||
|
||||
@Autowired
|
||||
private UserFactory userFactory;
|
||||
|
||||
@Autowired
|
||||
private Json json;
|
||||
|
||||
|
@ -49,9 +54,14 @@ public class AuthenticateServiceImpl implements AuthenticateService {
|
|||
claims.put(USER_LOGIN_PARAM, json.gson().toJson(userLoginParam));
|
||||
String jwt = JWTUtil.createJWT(claims);
|
||||
|
||||
return UserLoginResult.buildWithUser(user).loadToken(Token.of(jwt));
|
||||
return UserLoginResult.buildWithUser(user).loadToken(Token.of(jwt)).redirectUrl(SYSTEM_HOME_URL +
|
||||
"?token=" + Digest.aes(jwt));
|
||||
} else {
|
||||
throw new RuntimeException(NOT_FOUND);
|
||||
User newUser = userFactory.create(userLoginParam.getSfno());
|
||||
//如果数据库不存在该用户,需要通过sf信息进行查询并保存到数据库
|
||||
httpRequest.loadUserInfo(newUser);
|
||||
userRepository.save(newUser);
|
||||
return authenticateEmployeeNo(userLoginParam);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -117,7 +117,7 @@ public class LegEventHandler implements LegEventService {
|
|||
.findFirst()
|
||||
.ifPresent(leg -> {
|
||||
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
|
||||
legEvent.setOrderDetail(orderDetail);
|
||||
legEvent.addOrderDetail(orderDetail);
|
||||
leg.addEvent(legEvent);
|
||||
});
|
||||
routeRepository.save(routeOrder);
|
||||
|
@ -133,7 +133,7 @@ public class LegEventHandler implements LegEventService {
|
|||
OrderDetail orderDetail = orderDetailRepository.findById(command.getOrderDetailId());
|
||||
LegEvent legEvent = legEventFactory
|
||||
.creatLegEvent(command.getLegEventType())
|
||||
.orderDetail(orderDetail);
|
||||
.addOrderDetail(orderDetail);
|
||||
leg.addEvent(legEvent);
|
||||
|
||||
legRepository.save(leg);
|
||||
|
@ -146,7 +146,7 @@ public class LegEventHandler implements LegEventService {
|
|||
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId()));
|
||||
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
|
||||
OrderDetail orderDetail = new OrderDetail();
|
||||
legEvent.setOrderDetail(orderDetail);
|
||||
legEvent.addOrderDetail(orderDetail);
|
||||
leg.addEvent(legEvent);
|
||||
legRepository.save(leg);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
package com.chint.domain.value_object;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FlightPriceData {
|
||||
private String maxPrice;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.chint.domain.value_object;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PriceQueryData {
|
||||
private String departCity;
|
||||
private String arriveCity;
|
||||
private String departDate;
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.chint.domain.value_object;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class TrainPriceData {
|
||||
private String maxPrice;
|
||||
private List<SeatInfo> seatInfoList;
|
||||
|
||||
public void addSeatInfo(String seatName, String seatPrice, String seatCode) {
|
||||
if (this.seatInfoList == null) {
|
||||
this.seatInfoList = new ArrayList<>();
|
||||
}
|
||||
SeatInfo seatInfo = new SeatInfo();
|
||||
seatInfo.setSeatName(seatName);
|
||||
seatInfo.setSeatPrice(seatPrice);
|
||||
seatInfo.setSeatCode(seatCode);
|
||||
this.seatInfoList.add(seatInfo);
|
||||
}
|
||||
|
||||
@Data
|
||||
private static class SeatInfo {
|
||||
private String seatName;
|
||||
private String seatPrice;
|
||||
private String seatCode;
|
||||
}
|
||||
}
|
|
@ -2,10 +2,13 @@ package com.chint.domain.value_object;
|
|||
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.infrastructure.util.Token;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UserLoginResult {
|
||||
private User user;
|
||||
private Token token;
|
||||
private String redirectUrl;
|
||||
|
||||
public UserLoginResult(User user) {
|
||||
this.user = user;
|
||||
|
@ -36,4 +39,9 @@ public class UserLoginResult {
|
|||
this.token = token;
|
||||
return this;
|
||||
}
|
||||
|
||||
public UserLoginResult redirectUrl(String url) {
|
||||
this.redirectUrl = url;
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -197,4 +197,13 @@ public class Constant {
|
|||
|
||||
// status
|
||||
public static final int STATUS_DISABLED = 0;
|
||||
|
||||
// 城市类型
|
||||
public static final int CITY_TYPE_DOMESTIC = 0;//国内
|
||||
public static final String CITY_TYPE_DOMESTIC_PATH = "3106_1_";//国内
|
||||
public static final int CITY_TYPE_FOREIGN = 1;//国外
|
||||
|
||||
//system
|
||||
public static final String SYSTEM_HOME_URL = "www.baidu.com";//国内
|
||||
public static final String AES_SECRET = "chint";//国内
|
||||
}
|
||||
|
|
|
@ -10,6 +10,9 @@ import org.springframework.data.domain.Page;
|
|||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public class LocationRepositoryImpl implements LocationRepository {
|
||||
@Autowired
|
||||
|
@ -40,4 +43,21 @@ public class LocationRepositoryImpl implements LocationRepository {
|
|||
}
|
||||
return PageResult.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Location> findAll() {
|
||||
List<Location> res = new ArrayList<>();
|
||||
jdbcLocationRepository.findAll().forEach(res::add);
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveAll(List<Location> locations) {
|
||||
jdbcLocationRepository.saveAll(locations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Location> findByFirstLetter(LocationParam locationParam) {
|
||||
return jdbcLocationRepository.findByFirstPinYin(locationParam.getFirstLetter());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,4 +21,9 @@ public class UserRepositoryImpl implements UserRepository {
|
|||
public User findByUserEmployeeNo(Long employeeNo) {
|
||||
return jdbcUserRepository.findByEmployeeNo(employeeNo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public User save(User user) {
|
||||
return jdbcUserRepository.save(user);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@ import org.springframework.data.domain.Pageable;
|
|||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface JdbcLocationRepository extends CrudRepository<Location, Long> {
|
||||
Location findByLocationId(Long locationId);
|
||||
|
@ -16,4 +18,6 @@ public interface JdbcLocationRepository extends CrudRepository<Location,Long> {
|
|||
|
||||
Page<Location> findAllByLevel(Long level, Pageable pageable);
|
||||
|
||||
List<Location> findByFirstPinYin(String firstPinYin);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,16 @@
|
|||
package com.chint.infrastructure.util;
|
||||
|
||||
import javax.crypto.*;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Base64;
|
||||
|
||||
import static com.chint.infrastructure.constant.Constant.AES_SECRET;
|
||||
|
||||
public class Digest {
|
||||
|
||||
|
@ -22,4 +31,44 @@ public class Digest {
|
|||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static final SecretKey secretKey = generateKey(128); // 类级别的密钥
|
||||
|
||||
// 生成密钥
|
||||
private static SecretKey generateKey(int n) {
|
||||
try {
|
||||
KeyGenerator keyGenerator = KeyGenerator.getInstance("AES");
|
||||
keyGenerator.init(n); // 可以是 128, 192, 或 256
|
||||
return keyGenerator.generateKey();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String aes(String input) {
|
||||
try {
|
||||
Cipher cipher = Cipher.getInstance("AES");
|
||||
cipher.init(Cipher.ENCRYPT_MODE, secretKey);
|
||||
byte[] encryptedBytes = cipher.doFinal(input.getBytes());
|
||||
|
||||
String encodedEncryptedToken = Base64.getEncoder().encodeToString(encryptedBytes);
|
||||
return URLEncoder.encode(encodedEncryptedToken, StandardCharsets.UTF_8);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String aesBack(String input) {
|
||||
try {
|
||||
String urlDecodedToken = URLDecoder.decode(input, StandardCharsets.UTF_8);
|
||||
byte[] encryptedBytes = Base64.getDecoder().decode(urlDecodedToken);
|
||||
|
||||
Cipher cipher = Cipher.getInstance("AES");
|
||||
cipher.init(Cipher.DECRYPT_MODE, secretKey);
|
||||
byte[] decryptedBytes = cipher.doFinal(encryptedBytes);
|
||||
return new String(decryptedBytes);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.chint.infrastructure.webconfig;
|
|||
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.infrastructure.util.BaseContext;
|
||||
import com.chint.infrastructure.util.Digest;
|
||||
import com.chint.infrastructure.util.JWTUtil;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
|
@ -30,8 +31,9 @@ public class JwtTokenAdminInterceptor implements HandlerInterceptor {
|
|||
}
|
||||
|
||||
try {
|
||||
JWTUtil.verifyJWT(SECRET, token);
|
||||
var parseJWT = JWTUtil.parseJWT(SECRET, token);
|
||||
String str = Digest.aesBack(token);
|
||||
JWTUtil.verifyJWT(SECRET, str);
|
||||
var parseJWT = JWTUtil.parseJWT(SECRET, str);
|
||||
var withJwt = User.withJwt(parseJWT);
|
||||
BaseContext.setCurrentUser(withJwt);
|
||||
return true; // If verification succeeds, continue processing the request
|
||||
|
|
|
@ -57,7 +57,7 @@ public class CTripEstimateRequest {
|
|||
.requestContent()
|
||||
.valuationBaseInfo()
|
||||
.eID(user.getEmployeeNo().toString())
|
||||
.corpID("zhengtai")
|
||||
.corpID(C_TRIP_CORP_ID)
|
||||
// .rankName(user.getRankCode())
|
||||
.done()
|
||||
.valuationProductInfo()
|
||||
|
@ -67,6 +67,4 @@ public class CTripEstimateRequest {
|
|||
.done()
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.List;
|
|||
public class BookingRelatedApiResponse {
|
||||
|
||||
// 请求相关API的响应
|
||||
private ResponseStatus status;
|
||||
private EstimateResponseStatus status;
|
||||
// 数据内容
|
||||
private ValuateBudgetResponseType data;
|
||||
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
package com.chint.interfaces.rest.ctrip.dto.estimate.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import static com.chint.interfaces.rest.ctrip.dto.approval.train.TrainSkipFields.SeatType;
|
||||
|
||||
|
||||
public enum CTripSeatType {
|
||||
HARD_SEAT_201("硬座", 201),
|
||||
SOFT_SEAT_203("软座", 203),
|
||||
PREMIUM_SEAT_205("特等座", 205),
|
||||
FIRST_CLASS_SEAT_207("一等座", 207),
|
||||
SECOND_CLASS_SEAT_209("二等座", 209),
|
||||
HARD_SLEEPER_UPPER_211("硬卧上", 211),
|
||||
HARD_SLEEPER_MIDDLE_212("硬卧中", 212),
|
||||
HARD_SLEEPER_LOWER_213("硬卧下", 213),
|
||||
SOFT_SLEEPER_UPPER_214("软卧上", 214),
|
||||
SOFT_SLEEPER_LOWER_215("软卧下", 215),
|
||||
BUSINESS_SEAT_221("商务座", 221),
|
||||
NO_SEAT_227("无座", 227),
|
||||
HARD_SLEEPER_224("硬卧", 224),
|
||||
SOFT_SLEEPER_225("软卧", 225),
|
||||
LUXURY_SOFT_SLEEPER_226("高级软卧", 226),
|
||||
FIRST_CLASS_SOFT_SEAT_301("一等软座", 301),
|
||||
SECOND_CLASS_SOFT_SEAT_302("二等软座", 302),
|
||||
SOLO_SOFT_COMPARTMENT_303("一人软包", 303),
|
||||
MOVING_BERTH_304("动卧", 304),
|
||||
MOVING_BERTH_UPPER_305("动卧上", 305),
|
||||
MOVING_BERTH_LOWER_306("动卧下", 306),
|
||||
LUXURY_MOVING_BERTH_307("高级动卧", 307),
|
||||
LUXURY_MOVING_BERTH_UPPER_308("高级动卧上", 308),
|
||||
LUXURY_MOVING_BERTH_LOWER_309("高级动卧下", 309),
|
||||
FIRST_CLASS_DOUBLE_SOFT_311("一等双软", 311),
|
||||
FIRST_CLASS_DOUBLE_SOFT_UPPER_312("一等双软上", 312),
|
||||
FIRST_CLASS_DOUBLE_SOFT_LOWER_313("一等双软下", 313),
|
||||
SECOND_CLASS_DOUBLE_SOFT_314("二等双软", 314),
|
||||
SECOND_CLASS_DOUBLE_SOFT_UPPER_315("二等双软上", 315),
|
||||
SECOND_CLASS_DOUBLE_SOFT_MIDDLE_316("二等双软中", 316),
|
||||
SECOND_CLASS_DOUBLE_SOFT_LOWER_317("二等双软下", 317);
|
||||
|
||||
private final String description;
|
||||
private final int code;
|
||||
|
||||
CTripSeatType(String description, int code) {
|
||||
this.description = description;
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
// 根据 int 类型的 code 获取对应的描述
|
||||
public static String getDescriptionByCode(int code) {
|
||||
for (CTripSeatType seatType : CTripSeatType.values()) {
|
||||
if (seatType.getCode() == code) {
|
||||
return seatType.getDescription();
|
||||
}
|
||||
}
|
||||
return null; // 或者你可以选择抛出一个异常,如果 code 无效
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
package com.chint.interfaces.rest.ctrip.dto.estimate.response;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class EstimateResponseStatus {
|
||||
private Boolean success;
|
||||
private int errorCode;
|
||||
private String message;
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
package com.chint.interfaces.rest.ctrip.dto.search;
|
||||
|
||||
public class CarOrderInfoEntity {
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
package com.chint.interfaces.rest.ctrip.dto.search;
|
||||
|
||||
public class FlightOrderInfoEntity {
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
package com.chint.interfaces.rest.ctrip.dto.search;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class HotelOrderInfoEntity {
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
package com.chint.interfaces.rest.ctrip.dto.search;
|
||||
|
||||
public class TrainOrderInfoEntity {
|
||||
}
|
|
@ -5,6 +5,9 @@ package com.chint.interfaces.rest.user;
|
|||
//import com.chint.dc.api.DataCenterResult;
|
||||
//import com.chint.dc.api.dto.DataCenterOption;
|
||||
//import com.chint.dc.api.service.DataCenterService;
|
||||
import com.chint.dc.api.DataCenterResult;
|
||||
import com.chint.dc.api.dto.DataCenterOption;
|
||||
import com.chint.dc.api.service.DataCenterService;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.interfaces.rest.base.PostRequest;
|
||||
import com.chint.interfaces.rest.user.dto.*;
|
||||
|
@ -40,14 +43,14 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
}
|
||||
|
||||
private User loadSFAndRank(User user) {
|
||||
// List<UserDataDTO> loadSFInfo = loadSFInfo(user);
|
||||
// String custManaLevel = loadSFInfo.get(0).getCust_manaLevel();
|
||||
// String level = custManaLevel != null ? custManaLevel : "M0";
|
||||
// if (level.contains("R")) {
|
||||
// level = level.substring(0, level.length() - 3) + "M0";
|
||||
// }
|
||||
// TravelRankDTO loadTravelRank = loadTravelRank(new TravelRankParam(level));
|
||||
// user.setRankCode(loadTravelRank.getLEVEL_MAPPING_CODE());
|
||||
List<UserDataDTO> loadSFInfo = loadSFInfo(user);
|
||||
String custManaLevel = loadSFInfo.get(0).getCust_manaLevel();
|
||||
String level = custManaLevel != null ? custManaLevel : "M0";
|
||||
if (level.contains("R")) {
|
||||
level = level.substring(0, level.length() - 3) + "M0";
|
||||
}
|
||||
TravelRankDTO loadTravelRank = loadTravelRank(new TravelRankParam(level));
|
||||
user.setRankCode(loadTravelRank.getLEVEL_MAPPING_CODE());
|
||||
user.setRankCode("测试职级");
|
||||
return user;
|
||||
}
|
||||
|
@ -67,31 +70,33 @@ public class UserHttpRequestImpl implements UserHttpRequest {
|
|||
}
|
||||
|
||||
private List<UserDataDTO> loadSFInfo(User user) {
|
||||
// Gson gson = new Gson();
|
||||
// AccessKeyDTO akSkLoad = akSkLoad();
|
||||
// DataCenterOption option = new DataCenterOption();
|
||||
// option.setSk(akSkLoad.sk);
|
||||
// option.setAk(akSkLoad.ak);
|
||||
// option.setUrl(OPENAI_BASE_URL);
|
||||
// DataCenterService dataCenterService = new DataCenterService(option);
|
||||
// LinkedHashMap map = new LinkedHashMap<String, Object>();
|
||||
// map.put("LoginUsername", user.getEmployeeNo().toString());
|
||||
// map.put("start", 0);
|
||||
// map.put("pageSize", 1);
|
||||
// DataCenterResult result = dataCenterService.post(USER_DATA_PATH, map);
|
||||
// Type type = new TypeToken<List<UserDataDTO>>() {
|
||||
// }.getType();
|
||||
// if (result.getData() != null) {
|
||||
// List<UserDataDTO> fromJson = gson.fromJson(result.getData().toString(), type);
|
||||
// UserDataDTO userDataDTO = fromJson.get(0);
|
||||
// user.setCompanyCode(userDataDTO.getCompany());
|
||||
// user.setWorkStatus(userDataDTO.getStatus());
|
||||
// user.setGender(userDataDTO.getGender());
|
||||
// return fromJson;
|
||||
// } else {
|
||||
// throw new RuntimeException("用户数据不存在");
|
||||
// }
|
||||
return null;
|
||||
Gson gson = new Gson();
|
||||
AccessKeyDTO akSkLoad = akSkLoad();
|
||||
DataCenterOption option = new DataCenterOption();
|
||||
option.setSk(akSkLoad.sk);
|
||||
option.setAk(akSkLoad.ak);
|
||||
option.setUrl(OPENAI_BASE_URL);
|
||||
DataCenterService dataCenterService = new DataCenterService(option);
|
||||
LinkedHashMap map = new LinkedHashMap<String, Object>();
|
||||
map.put("LoginUsername", user.getEmployeeNo().toString());
|
||||
map.put("start", 0);
|
||||
map.put("pageSize", 1);
|
||||
DataCenterResult result = dataCenterService.post(USER_DATA_PATH, map);
|
||||
Type type = new TypeToken<List<UserDataDTO>>() {
|
||||
}.getType();
|
||||
if (result.getData() != null) {
|
||||
List<UserDataDTO> fromJson = gson.fromJson(result.getData().toString(), type);
|
||||
UserDataDTO userDataDTO = fromJson.get(0);
|
||||
user.setCompanyCode(userDataDTO.getCompany());
|
||||
user.setWorkStatus(userDataDTO.getStatus());
|
||||
user.setGender(userDataDTO.getGender());
|
||||
user.setName(userDataDTO.getUname());
|
||||
user.setPhoneNumber(userDataDTO.getMobilePhone());
|
||||
return fromJson;
|
||||
} else {
|
||||
throw new RuntimeException("用户数据不存在");
|
||||
}
|
||||
// return null;
|
||||
}
|
||||
|
||||
private TravelRankDTO loadTravelRank(TravelRankParam travelRankParam) {
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
FROM harbor.chint.com/wz-build-env-public/openjdk:17 AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 8080
|
||||
EXPOSE 443
|
||||
ENV LANG en_US.UTF-8
|
||||
RUN ln -snf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
|
||||
RUN sed -i 's/jdk.tls.disabledAlgorithms=SSLv3, TLSv1, TLSv1.1/jdk.tls.disabledAlgorithms=SSLv3/g' /usr/lib/jvm/msopenjdk-17-amd64/conf/security/java.security
|
||||
|
||||
FROM base AS final
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN rm -f /app/Dockerfile
|
||||
ENTRYPOINT ["java", "-jar", "app.jar"]
|
|
@ -1,5 +1,5 @@
|
|||
server:
|
||||
port: 8081
|
||||
port: 8080
|
||||
|
||||
chint:
|
||||
datasource:
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
version: "3"
|
||||
|
||||
networks:
|
||||
gitea:
|
||||
external: false
|
||||
|
||||
services:
|
||||
server:
|
||||
image: gitea/gitea:1.21.4
|
||||
container_name: gitea
|
||||
environment:
|
||||
- USER_UID=1000
|
||||
- USER_GID=1000
|
||||
- GITEA__database__DB_TYPE=mysql
|
||||
- GITEA__database__HOST=rm-cn-jeo3lfy9q0006gso.rwlb.rds.aliyuncs.com:3306
|
||||
- GITEA__database__NAME=gitea
|
||||
- GITEA__database__USER=gitea
|
||||
- GITEA__database__PASSWD=gitea
|
||||
restart: always
|
||||
volumes:
|
||||
- /app/gitea/data:/data
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "222:22"
|
|
@ -7,12 +7,14 @@ import com.chint.interfaces.rest.ctrip.*;
|
|||
import com.chint.interfaces.rest.ctrip.dto.estimate.request.BookingRelatedApiRequest;
|
||||
import com.chint.interfaces.rest.ctrip.dto.estimate.request.FlightProductInfo;
|
||||
import com.chint.interfaces.rest.ctrip.dto.estimate.request.RouteInfo;
|
||||
import com.chint.interfaces.rest.ctrip.dto.estimate.request.TrainProductInfo;
|
||||
import com.chint.interfaces.rest.ctrip.dto.estimate.response.BookingRelatedApiResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.location.CTripCity;
|
||||
import com.chint.interfaces.rest.ctrip.dto.location.CTripCountry;
|
||||
import com.chint.interfaces.rest.ctrip.dto.login.CTripLoginParam;
|
||||
import com.chint.interfaces.rest.ctrip.dto.login.PCResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse;
|
||||
import com.google.gson.Gson;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
@ -43,17 +45,17 @@ public class CTripTest {
|
|||
|
||||
private User user = new User(1L, 230615020L, 1, "卢麟哲", "1033719135@qq.com", "15857193365");
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
void locationCountry() {
|
||||
System.out.println(cTripLocationHttpRequest.syncCountry());
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
void locationCity() {
|
||||
System.out.println(cTripLocationHttpRequest.syncCity(2));
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
void syncAllCity() {
|
||||
List<CTripCountry> countries = cTripLocationHttpRequest.syncCountry();
|
||||
for (CTripCountry country : countries) {
|
||||
|
@ -62,18 +64,18 @@ public class CTripTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
void SaveCorpCustInfoList() {
|
||||
BaseContext.setCurrentUser(user);
|
||||
cTripUserSaveRequest.saveUserToCTrip();
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
void approval() {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
void login() {
|
||||
BaseContext.setCurrentUser(user);
|
||||
CTripLoginParam cTripLoginParam = new CTripLoginParam();
|
||||
|
@ -81,7 +83,7 @@ public class CTripTest {
|
|||
loginRequest.login(cTripLoginParam);
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
void authLogin() {
|
||||
BaseContext.setCurrentUser(user);
|
||||
PCResponse response = loginRequest.authLogin();
|
||||
|
@ -89,35 +91,51 @@ public class CTripTest {
|
|||
}
|
||||
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
void hSingleLogin() {
|
||||
BaseContext.setCurrentUser(user);
|
||||
System.out.println(loginRequest.hSingleLogin().getRedirectUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
//@Test
|
||||
void h5LoginTest() {
|
||||
BaseContext.setCurrentUser(user);
|
||||
System.out.println(loginRequest.h5Login());
|
||||
}
|
||||
|
||||
@Test
|
||||
void estimate() {
|
||||
// @Test
|
||||
void estimateFlight() {
|
||||
BaseContext.setCurrentUser(user);
|
||||
FlightProductInfo flightProductInfo = new FlightProductInfo();
|
||||
flightProductInfo.setClassType("YCF");
|
||||
RouteInfo routeInfo = new RouteInfo();
|
||||
routeInfo.setArriveCityID("17");
|
||||
routeInfo.setArriveCityID("1");
|
||||
routeInfo.setDepartCityID("491");
|
||||
routeInfo.setDepartDate("2024-04-01");
|
||||
routeInfo.setDepartDate("2024-03-01");
|
||||
flightProductInfo.setRoutes(List.of(routeInfo));
|
||||
BookingRelatedApiRequest bookingRelatedApiRequest = estimateRequest
|
||||
.generateBaseRequest(flightProductInfo, null);
|
||||
BookingRelatedApiResponse estimate = estimateRequest.estimate(bookingRelatedApiRequest);
|
||||
System.out.println(estimate);
|
||||
Gson gson = new Gson();
|
||||
System.out.println(gson.toJson(estimate));
|
||||
}
|
||||
|
||||
@Test
|
||||
// @Test
|
||||
void estimateTrain() {
|
||||
BaseContext.setCurrentUser(user);
|
||||
TrainProductInfo trainProductInfo = new TrainProductInfo();
|
||||
trainProductInfo.setArriveCityID("17");
|
||||
trainProductInfo.setDepartCityID("1");
|
||||
trainProductInfo.setDepartDate("2024-03-01");
|
||||
trainProductInfo.setReturnNoTicket(true);
|
||||
BookingRelatedApiRequest bookingRelatedApiRequest = estimateRequest
|
||||
.generateBaseRequest(null, trainProductInfo);
|
||||
BookingRelatedApiResponse estimate = estimateRequest.estimate(bookingRelatedApiRequest);
|
||||
Gson gson = new Gson();
|
||||
System.out.println(gson.toJson(estimate));
|
||||
}
|
||||
|
||||
// @Test
|
||||
void search() {
|
||||
BaseContext.setCurrentUser(user);
|
||||
SearchOrderResponse response = orderSearchRequest.searchOrder("actual12345622");
|
||||
|
|
|
@ -67,7 +67,7 @@ public class LYTest {
|
|||
|
||||
|
||||
//机票订单最新价格校验
|
||||
@Test
|
||||
// @Test
|
||||
void ticketNewPrice() {
|
||||
String flyPriceUrl = Constant.L_Y_BASE_URL + Constant.L_Y_FLY_PRICE;
|
||||
TicketNewPrice ticketNewPrice = new TicketNewPrice();
|
||||
|
@ -79,7 +79,7 @@ public class LYTest {
|
|||
}
|
||||
|
||||
///查询酒店最小价格
|
||||
@Test
|
||||
// @Test
|
||||
void hotleMinPrice() {
|
||||
String HotelListUrl = Constant.L_Y_BASE_URL + Constant.L_Y_HOTEL_List;
|
||||
HotelCityList hotelCityList = new HotelCityList();
|
||||
|
@ -104,7 +104,7 @@ public class LYTest {
|
|||
}
|
||||
|
||||
//火车票最高价查询
|
||||
@Test
|
||||
// @Test
|
||||
void maxPrice() {
|
||||
String maxPriceUrl = Constant.L_Y_BASE_URL + Constant.L_Y_TRAIN_MAX_PRICE;
|
||||
TrainMaxPrice trainMaxPrice = new TrainMaxPrice();
|
||||
|
@ -126,7 +126,7 @@ public class LYTest {
|
|||
System.out.println(max);
|
||||
}
|
||||
|
||||
@Test
|
||||
// @Test
|
||||
//外部差旅单同步
|
||||
void ApplyOrderSync() {
|
||||
AOSParam aosParam = new AOSParam();
|
||||
|
@ -207,7 +207,7 @@ public class LYTest {
|
|||
}
|
||||
|
||||
//同步同程订单
|
||||
@Test
|
||||
// @Test
|
||||
void syncSupplierOrder() {
|
||||
String supplierOrderSyncUrl = Constant.L_Y_BASE_URL + Constant.L_Y_ORDER_PATH;
|
||||
SupplierOrderParam param = new SupplierOrderParam();
|
||||
|
@ -262,25 +262,25 @@ public class LYTest {
|
|||
System.out.println(post);
|
||||
}
|
||||
|
||||
@Test
|
||||
// @Test
|
||||
void loadToken() {
|
||||
System.out.println(lyTokenRequest.loadToken());
|
||||
}
|
||||
|
||||
@Test
|
||||
// @Test
|
||||
void saveCurrentUser2Ly() {
|
||||
// BaseContext.setCurrentUser(user);
|
||||
BaseContext.setCurrentUser(hxh);
|
||||
System.out.println(lyUserRequest.saveCurrentUser());
|
||||
}
|
||||
|
||||
@Test
|
||||
// @Test
|
||||
void loginLY() {
|
||||
BaseContext.setCurrentUser(user);
|
||||
System.out.println(loginRequest.login(L_Y_ENTRANCE_HOME));
|
||||
}
|
||||
|
||||
@Test
|
||||
// @Test
|
||||
void loginLYPC() {
|
||||
BaseContext.setCurrentUser(user);
|
||||
System.out.println(loginRequest.loginPC(L_Y_ENTRANCE_HOME));
|
||||
|
|
|
@ -1,37 +1,58 @@
|
|||
package com.chint;
|
||||
|
||||
import cn.hutool.extra.pinyin.PinyinUtil;
|
||||
import com.chint.domain.aggregates.order.Location;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.infrastructure.util.BaseContext;
|
||||
import com.chint.domain.repository.LocationRepository;
|
||||
import com.chint.infrastructure.util.Digest;
|
||||
import com.chint.interfaces.rest.user.UserHttpRequest;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SpringBootTest
|
||||
class RouteApplicationTests {
|
||||
|
||||
@Autowired
|
||||
private UserHttpRequest userHttpRequest;
|
||||
|
||||
@Autowired
|
||||
private LocationRepository locationRepository;
|
||||
|
||||
private User user = new User(1L, 230615020L, 1, "卢麟哲", "1033719135@qq.com", "15857193365");
|
||||
|
||||
|
||||
@Test
|
||||
// @Test
|
||||
void contextLoads() {
|
||||
|
||||
userHttpRequest.loadUserInfo(user);
|
||||
}
|
||||
|
||||
@Test
|
||||
void loginSign() {
|
||||
String sfno = "230615020";
|
||||
String sfno = "220322120";
|
||||
String syscode = "abc";
|
||||
String billcode = "12321412323";
|
||||
String billcode = "12345622";
|
||||
String sec = "Superdandan";
|
||||
String timespan = "12312312312312";
|
||||
|
||||
String s = Digest.md5(sfno + syscode + billcode + sec + timespan);
|
||||
System.out.println(s);
|
||||
}
|
||||
|
||||
// @Test
|
||||
void handleLocation() {
|
||||
List<Location> all = locationRepository.findAll();
|
||||
|
||||
all.forEach(
|
||||
location ->{
|
||||
char c = location.getLocationName().charAt(0);
|
||||
char firstLetter = PinyinUtil.getFirstLetter(c);
|
||||
String h3 = String.valueOf(firstLetter).toUpperCase();
|
||||
location.setFirstPinYin(h3);
|
||||
}
|
||||
);
|
||||
|
||||
locationRepository.saveAll(all);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue