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

# Conflicts:
#	pom.xml
This commit is contained in:
dengwc 2024-02-29 17:25:08 +08:00
commit 45a12474e1
62 changed files with 1021 additions and 53 deletions

View File

@ -0,0 +1,12 @@
package com.chint.application.dtos;
import com.chint.domain.value_object.BaseQuery;
import com.chint.domain.value_object.LegData;
import lombok.Data;
@Data
public class AuthenticationDto extends BaseQuery {
private String clientid ;
private String secretkey;
}

View File

@ -0,0 +1,16 @@
package com.chint.application.dtos;
import com.chint.domain.value_object.BaseQuery;
import lombok.Data;
@Data
public class AuthenticationSignDto extends BaseQuery {
private Integer productType; //机票1 酒店2火车3打车4
private String systemType;
private String startTime;
private String endTime;
private String sign;
}

View File

@ -0,0 +1,15 @@
package com.chint.application.dtos;
import com.chint.application.dtos.response.LocationRes;
import lombok.Data;
import java.util.List;
@Data
public class HotCityResponseDto {
private List<LocationRes> internationalCitys; //热门国际城市
private List<LocationRes> internalCitys; //热门国内城市
}

View File

@ -0,0 +1,6 @@
package com.chint.application.dtos;
import com.chint.domain.value_object.BaseQuery;
public class OrderDetailQueryParam extends BaseQuery {
}

View File

@ -0,0 +1,10 @@
package com.chint.application.dtos;
import com.chint.infrastructure.util.Token;
import lombok.Data;
@Data
public class OrderSearchResult {
private Token token;
}

View File

@ -4,12 +4,14 @@ package com.chint.application.dtos.response;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.chint.domain.aggregates.order.Leg; import com.chint.domain.aggregates.order.Leg;
import com.chint.domain.aggregates.order.LegExtensionField; import com.chint.domain.aggregates.order.LegExtensionField;
import com.chint.domain.aggregates.order.Location;
import com.chint.domain.aggregates.order.OrderDetail; import com.chint.domain.aggregates.order.OrderDetail;
import com.chint.domain.value_object.enums.CurrencyType; import com.chint.domain.value_object.enums.CurrencyType;
import lombok.Data; import lombok.Data;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Data @Data
@ -37,6 +39,8 @@ public class LegRes {
private CurrencyType currencyType; private CurrencyType currencyType;
private List<LocationRes> otherLocationList;
private List<OrderDetail> orderDetails; //这个属性不做持久化保存 根据下单事件进行获取 private List<OrderDetail> orderDetails; //这个属性不做持久化保存 根据下单事件进行获取
public static LegRes copyFrom(Leg leg) { public static LegRes copyFrom(Leg leg) {
@ -50,9 +54,19 @@ public class LegRes {
legRes.setAmountType(legExtensionField.getAmountType()); legRes.setAmountType(legExtensionField.getAmountType());
legRes.setAmountTypeName(legExtensionField.getAmountTypeName()); legRes.setAmountTypeName(legExtensionField.getAmountTypeName());
legRes.setAmountTypeEnName(legExtensionField.getAmountTypeEnName()); legRes.setAmountTypeEnName(legExtensionField.getAmountTypeEnName());
if (legExtensionField.getLocationIds() != null) {
List<LocationRes> locationResList = new ArrayList<>();
List<Location> locationList = legExtensionField.getLocationList();
for (Location location : locationList) {
locationResList.add(LocationRes.copyFrom(location));
}
legRes.setOtherLocationList(locationResList);
}
} }
legRes.setOriginLocation(LocationRes.copyFrom(leg.getOriginLocation())); legRes.setOriginLocation(LocationRes.copyFrom(leg.getOriginLocation()));
legRes.setDestinationLocation(LocationRes.copyFrom(leg.getDestinationLocation())); legRes.setDestinationLocation(LocationRes.copyFrom(leg.getDestinationLocation()));
return legRes; return legRes;
} }
} }

View File

@ -10,8 +10,19 @@ public class LocationRes {
@Id @Id
private Long locationId; private Long locationId;
private String locationName; private String locationName;
private String continent;
private String country;
private String province;
public static LocationRes copyFrom(Location location) { public static LocationRes copyFrom(Location location) {
return BeanUtil.copyProperties(location, LocationRes.class); LocationRes locationRes = BeanUtil.copyProperties(location, LocationRes.class);
String[] parts = location.getLocationPathName().split("_");
if (parts.length != 4) {
throw new IllegalArgumentException("Invalid loclocationation string format");
}
locationRes.setContinent(parts[0]);
locationRes.setCountry(parts[1]);
locationRes.setProvince(parts[2]);
return locationRes;
} }
} }

View File

@ -34,6 +34,7 @@ public class RouteOrderPageRes {
private String amount; private String amount;
private String estimateAmount; private String estimateAmount;
private Integer orderStatus; private Integer orderStatus;
private Integer approvalStatusCode;
private String approvalStatus; private String approvalStatus;
private String orderStatusName; private String orderStatusName;
private String startTime; private String startTime;

View File

@ -6,7 +6,9 @@ import com.chint.application.queryies.OrderQuery;
import com.chint.application.services.OrderApplicationService; import com.chint.application.services.OrderApplicationService;
import com.chint.domain.aggregates.order.RouteOrder; import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.service.OrderDetailDomainService; import com.chint.domain.service.OrderDetailDomainService;
import com.chint.domain.value_object.*; import com.chint.domain.value_object.OrderSaveData;
import com.chint.domain.value_object.SyncLegData;
import com.chint.domain.value_object.UpdateLegData;
import com.chint.infrastructure.util.Result; import com.chint.infrastructure.util.Result;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -41,7 +43,6 @@ public class OrderController {
} }
@Transactional @Transactional
@ApiOperation("同步行程规划单到供应商") @ApiOperation("同步行程规划单到供应商")
@PostMapping("/sync") @PostMapping("/sync")
@ -50,6 +51,19 @@ public class OrderController {
return Result.Success(SUCCESS); return Result.Success(SUCCESS);
} }
@Transactional
@ApiOperation("批量同步行程规划单到供应商")
@PostMapping("/sync/batch")
public Result<String> syncOrderBatch(@RequestBody SyncLegData syncLegData) {
syncLegData.getRouteIds().stream().map(routeId -> {
SyncLegData syncLegDataItem = new SyncLegData();
syncLegDataItem.setRouteId(routeId);
syncLegDataItem.setSupplierName(syncLegData.getSupplierName());
return syncLegDataItem;
}).toList().forEach(data -> orderApplicationService.sync(data));
return Result.Success(SUCCESS);
}
@Transactional @Transactional
@ApiOperation("修改规划节点关联的订单") @ApiOperation("修改规划节点关联的订单")
@PostMapping("/leg/update") @PostMapping("/leg/update")
@ -66,6 +80,15 @@ public class OrderController {
return Result.Success(SUCCESS); return Result.Success(SUCCESS);
} }
@Transactional
@ApiOperation("修改行程节点")
@PostMapping("/leg/change/")
public Result<String> changeLeg(@RequestBody AddLegData addLegData) {
orderApplicationService.changeLeg(addLegData);
return Result.Success(SUCCESS);
}
@Transactional @Transactional
@ApiOperation("删除行程节点") @ApiOperation("删除行程节点")
@PostMapping("/leg/delete") @PostMapping("/leg/delete")

View File

@ -1,21 +1,28 @@
package com.chint.application.out; package com.chint.application.out;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import com.chint.application.dtos.HotCityResponseDto;
import com.chint.application.dtos.LocationParam; import com.chint.application.dtos.LocationParam;
import com.chint.application.dtos.response.LocationRes; import com.chint.application.dtos.response.LocationRes;
import com.chint.domain.aggregates.order.Location; import com.chint.domain.aggregates.order.Location;
import com.chint.domain.aggregates.standards.CityTag;
import com.chint.domain.aggregates.standards.HotCityTag;
import com.chint.domain.repository.LocationRepository; import com.chint.domain.repository.LocationRepository;
import com.chint.domain.service.LocationDomainService; import com.chint.domain.service.LocationDomainService;
import com.chint.infrastructure.util.PageResult; import com.chint.infrastructure.util.PageResult;
import com.chint.infrastructure.util.Result; import com.chint.infrastructure.util.Result;
import com.chint.infrastructure.util.StringCheck; import com.chint.infrastructure.util.StringCheck;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List; import java.util.List;
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS; import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
@ -51,8 +58,43 @@ public class LocationController {
if (locations != null && !locations.isEmpty()) { if (locations != null && !locations.isEmpty()) {
locationRes = locations locationRes = locations
.stream() .stream()
.map(location -> BeanUtil.copyProperties(location, LocationRes.class)).toList(); .map(LocationRes::copyFrom).toList();
} }
return Result.Success(SUCCESS, locationRes); return Result.Success(SUCCESS, locationRes);
} }
@ApiOperation("获取热门城市")
@PostMapping("/getHotCities")
public Result<HotCityResponseDto> getHotCities() {
List<String> city = HotCityTag.citys;
List<Location> locations = null;
List<LocationRes> locationRes = null;
locations = locationRepository.findHotCitiesByCityName(city);
if (locations != null && !locations.isEmpty()) {
locationRes = locations
.stream()
.map(LocationRes::copyFrom).toList();
}
List<String> internationalCitys = HotCityTag.internationalCitys;
List<LocationRes> internationalLocationRes = null;
List<Location> internationalLocations = locationRepository.findHotIntnationalCitiesByCityName(internationalCitys);
if (internationalLocations != null && !internationalLocations.isEmpty()) {
internationalLocationRes = internationalLocations
.stream()
.map(LocationRes::copyFrom).toList();
}
HotCityResponseDto dto = new HotCityResponseDto();
dto.setInternalCitys(locationRes);
dto.setInternationalCitys(internationalLocationRes);
return Result.Success(SUCCESS, dto);
}
} }

View File

@ -130,4 +130,35 @@ public class LoginController {
userLoginResult.getUser().setManaLevel(null); userLoginResult.getUser().setManaLevel(null);
return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult); return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult);
} }
@ApiOperation("商旅平台移动端单点")
@Transactional
@PostMapping("/login/sso/mobile")
public Result<UserLoginResult> loginSSOMobile(@RequestBody UserLoginParam userLoginParam){
String employeeNo = pailaLoginStrategy.login(userLoginParam.getCode());
userLoginParam.setSfno(employeeNo);
UserLoginResult userLoginResult = authenticateService
.authenticateEmployeeNo(userLoginParam);
//异步执行更新用户信息到同程
User currentUser = userLoginResult.getUser();
CompletableFuture.runAsync(() -> {
BaseContext.setCurrentUser(currentUser);
lyUserRequest.saveCurrentUser();
BaseContext.removeCurrentUser();
});
//异步执行更新用户信息到携程
CompletableFuture.runAsync(() -> {
BaseContext.setCurrentUser(currentUser);
cTripUserSaveRequest.saveUserToCTrip();
BaseContext.removeCurrentUser();
});
//清除职级信息
userLoginResult.getUser().setProfLevel(null);
userLoginResult.getUser().setManaLevel(null);
return Result.Success(CommonMessageConstant.SUCCESS, userLoginResult);
}
} }

View File

@ -0,0 +1,91 @@
package com.chint.application.out;
import cn.hutool.core.bean.BeanUtil;
import com.chint.application.dtos.*;
import com.chint.application.dtos.response.LocationRes;
import com.chint.application.dtos.response.OrderDetailRes;
import com.chint.domain.aggregates.order.Location;
import com.chint.domain.repository.ClientRepository;
import com.chint.domain.repository.LocationRepository;
import com.chint.domain.service.LocationDomainService;
import com.chint.domain.service.auth.AuthenticateService;
import com.chint.infrastructure.util.Digest;
import com.chint.infrastructure.util.PageResult;
import com.chint.infrastructure.util.Result;
import com.chint.infrastructure.util.StringCheck;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Calendar;
import java.util.List;
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
@RestController
@RequestMapping("/OrderDetail")
public class OrderDetailController {
// @Autowired
// private LocationRepository locationRepository;
//
// @Autowired
// private LocationDomainService locationDomainService;
@Autowired
private AuthenticateService authenticateService;
@Autowired
private ClientRepository clientRepository;
@ApiOperation("订单明细认证接口")
@PostMapping("/pubilc/authentication")
public Result<OrderSearchResult> queryAuthentication(@RequestBody AuthenticationDto authenticationDto) {
OrderSearchResult orderSearchResult = null;
try {
orderSearchResult = authenticateService.authenticateClient(authenticationDto);
if (orderSearchResult != null){
return Result.Success(SUCCESS, orderSearchResult);
}else {
return Result.error("认证失败");
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@ApiOperation("订单明细查询接口")
@PostMapping("/query")
public Result query(@RequestBody AuthenticationSignDto authenticationDto) {
String productType = authenticationDto.getProductType().toString();
String systemType = authenticationDto.getSystemType();
String startTime = authenticationDto.getStartTime();
String endTime = authenticationDto.getEndTime();
String pageSize = authenticationDto.getPageSize().toString();
String pageNum = authenticationDto.getPageNum().toString();
String orgsign = authenticationDto.getSign();
String sign = Digest.md5(productType + systemType + startTime + endTime + pageSize + pageNum);
System.out.println(sign);
if (StringUtils.isNotBlank(orgsign) && orgsign.equals(sign)) {
return Result.Success(SUCCESS,sign);
} else {
return Result.error("签名错误");
}
}
@ApiOperation("查询我的订单")
@PostMapping("/query/page")
public Result<OrderDetailRes> query(@RequestBody OrderDetailQueryParam orderDetailQueryParam){
return null;
}
}

View File

@ -19,6 +19,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS; import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
@Slf4j @Slf4j
@ -86,4 +88,11 @@ public class OrderOutController {
return Result.Success(SUCCESS, tripCallback); return Result.Success(SUCCESS, tripCallback);
} }
@ApiOperation("分页查询行程规划订单")
@PostMapping("/query/not/submit")
public Result<List<RouteOrderPageRes>> queryNotSubmit(@RequestBody OrderQueryData queryData) {
return Result.Success(SUCCESS, orderQuery.queryNotSubmit(queryData));
}
} }

View File

@ -0,0 +1,22 @@
package com.chint.application.queryies;
import com.chint.application.dtos.OrderDetailQueryParam;
import com.chint.application.dtos.response.OrderDetailRes;
import com.chint.domain.repository.OrderDetailRepository;
import com.chint.infrastructure.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class OrderDetailQuery {
@Autowired
private OrderDetailRepository orderDetailRepository;
public PageResult<OrderDetailRes> orderDetailPageQuery(OrderDetailQueryParam orderDetailQueryParam) {
return null;
}
}

View File

@ -26,6 +26,7 @@ import org.springframework.stereotype.Service;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -33,6 +34,7 @@ import java.util.stream.Stream;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_CANCEL_NAME; import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_CANCEL_NAME;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_PREPARE_NAME; import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_PREPARE_NAME;
import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_APPROVAL;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP; import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
@Service @Service
@ -59,6 +61,7 @@ public class OrderQuery {
@Autowired @Autowired
private EstimateAdapter estimateAdapter; private EstimateAdapter estimateAdapter;
public RouteOrder queryByOrderId(OrderQueryData queryData) { public RouteOrder queryByOrderId(OrderQueryData queryData) {
return routeRepository.queryById(queryData.getRouteId()).reloadStatus(); return routeRepository.queryById(queryData.getRouteId()).reloadStatus();
} }
@ -89,6 +92,7 @@ public class OrderQuery {
int total = routeOrders.size(); int total = routeOrders.size();
List<RouteOrderPageRes> orders = routeOrders List<RouteOrderPageRes> orders = routeOrders
.stream() .stream()
.sorted(Comparator.comparing(RouteOrder::getUpdateTime))
.skip((long) (pageNum - 1) * pageSize) .skip((long) (pageNum - 1) * pageSize)
.limit(pageSize) .limit(pageSize)
.map(OrderQuery::getRouteOrderPageRes) .map(OrderQuery::getRouteOrderPageRes)
@ -138,7 +142,8 @@ public class OrderQuery {
private static RouteOrderPageRes getRouteOrderPageRes(RouteOrder routeOrder) { private static RouteOrderPageRes getRouteOrderPageRes(RouteOrder routeOrder) {
User currentUser = BaseContext.getCurrentUser(); User currentUser = BaseContext.getCurrentUser();
RouteOrderPageRes res = BeanUtil.copyProperties(routeOrder.reloadStatus(), RouteOrderPageRes.class); RouteOrderPageRes res = BeanUtil.copyProperties(routeOrder.reloadStatus(), RouteOrderPageRes.class);
List<LocationRes> locationRes = routeOrder.getLegItems() List<Leg> legItems = routeOrder.getLegItems();
List<LocationRes> locationRes = legItems
.stream() .stream()
.flatMap(leg -> Stream.of(leg.getOriginLocation(), leg.getDestinationLocation())) .flatMap(leg -> Stream.of(leg.getOriginLocation(), leg.getDestinationLocation()))
.map(LocationRes::copyFrom) .map(LocationRes::copyFrom)
@ -297,7 +302,7 @@ public class OrderQuery {
}; };
} }
public RouteOrderRes queryRouteRes(RouteOrder routeOrder){ public RouteOrderRes queryRouteRes(RouteOrder routeOrder) {
RouteOrderRes routeOrderRes = RouteOrderRes.copyFrom(routeOrder); RouteOrderRes routeOrderRes = RouteOrderRes.copyFrom(routeOrder);
List<Leg> legItems = routeOrder.getLegItems(); List<Leg> legItems = routeOrder.getLegItems();
orderDomainService.queryLocation(legItems); orderDomainService.queryLocation(legItems);
@ -318,4 +323,12 @@ public class OrderQuery {
.toList()); .toList());
return routeOrderRes; return routeOrderRes;
} }
public List<RouteOrderPageRes> queryNotSubmit(OrderQueryData queryData) {
List<RouteOrder> routeOrders = routeRepository.findByActualOrderNoNotNull(queryData);
routeOrders.forEach(route -> orderDomainService.queryLocation(route.getLegItems()));
return routeOrders.stream().filter(order -> order.reloadStatus().getOrderStatus().equals(ORDER_STATUS_APPROVAL))
.map(OrderQuery::getRouteOrderPageRes)
.toList();
}
} }

View File

@ -9,25 +9,25 @@ import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.exceptions.OrderException; import com.chint.domain.exceptions.OrderException;
import com.chint.domain.factoriy.leg.LegFactory; import com.chint.domain.factoriy.leg.LegFactory;
import com.chint.domain.factoriy.order.OrderFactory; import com.chint.domain.factoriy.order.OrderFactory;
import com.chint.domain.repository.LegRepository;
import com.chint.domain.repository.RouteRepository; import com.chint.domain.repository.RouteRepository;
import com.chint.domain.service.OrderDomainService; import com.chint.domain.service.OrderDomainService;
import com.chint.domain.value_object.*; import com.chint.domain.value_object.*;
import com.chint.infrastructure.constant.CommonMessageConstant; import com.chint.infrastructure.constant.CommonMessageConstant;
import com.chint.infrastructure.constant.DataMessageConstant; import com.chint.infrastructure.constant.DataMessageConstant;
import com.chint.infrastructure.constant.LegConstant; 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.command.Command;
import com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import static com.chint.infrastructure.constant.CommonMessageConstant.ORDER_STATUS_ERROR; import static com.chint.infrastructure.constant.CommonMessageConstant.ORDER_STATUS_ERROR;
import static com.chint.infrastructure.constant.LegConstant.LEG_STATUS_PREPARE;
import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_PREPARE; import static com.chint.infrastructure.constant.RouteConstant.ORDER_STATUS_PREPARE;
@Service @Service
@ -45,6 +45,8 @@ public class OrderApplicationService {
@Autowired @Autowired
private LegFactory legFactory; private LegFactory legFactory;
@Autowired
private LegRepository legRepository;
@Transactional @Transactional
@ -149,4 +151,20 @@ public class OrderApplicationService {
public void reloadOrderDetail(SyncLegData syncLegData) { public void reloadOrderDetail(SyncLegData syncLegData) {
} }
@Transactional
public void updateLegToOrder(AddLegData addLegData) {
}
@Transactional
public void changeLeg(AddLegData addLegData) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss");
LegData legData = addLegData.getLegData();
Leg byLegId = legRepository.findByLegId(legData.getLegId());
byLegId.setStartTime(LocalDateTime.parse(legData.getStartTime(), formatter));
byLegId.setEndTime(LocalDateTime.parse(legData.getEndTime(), formatter));
byLegId.setOriginId(legData.getOriginId());
byLegId.setDestinationId(legData.getDestinationId());
legRepository.save(byLegId);
}
} }

View File

@ -4,6 +4,7 @@ package com.chint.application.services.login;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import com.chint.domain.exceptions.AuthException; import com.chint.domain.exceptions.AuthException;
import com.chint.domain.exceptions.SSOLoginException;
import org.apache.http.HttpResponse; import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient; import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpRequestBase; import org.apache.http.client.methods.HttpRequestBase;
@ -22,7 +23,7 @@ public interface LoginStrategy {
default String login(String code) { default String login(String code) {
Optional<String> accessToken = getAccessToken(code); Optional<String> accessToken = getAccessToken(code);
return getUserInfo(accessToken.orElseThrow(()-> new AuthException("Failed to obtain access token"))); return getUserInfo(accessToken.orElseThrow(()-> new SSOLoginException("Failed to obtain access token")));
} }
Optional<String> getAccessToken(String code); Optional<String> getAccessToken(String code);

View File

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.chint.application.dtos.UserDTO; import com.chint.application.dtos.UserDTO;
import com.chint.application.services.login.LoginStrategy; import com.chint.application.services.login.LoginStrategy;
import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.exceptions.SSOLoginException;
import com.chint.domain.factoriy.user.UserFactory; import com.chint.domain.factoriy.user.UserFactory;
import com.chint.domain.repository.UserRepository; import com.chint.domain.repository.UserRepository;
import com.chint.interfaces.rest.user.UserHttpRequest; import com.chint.interfaces.rest.user.UserHttpRequest;
@ -65,7 +66,6 @@ public class PailaLoginStrategy implements LoginStrategy {
new BasicNameValuePair("client_secret", clientSecret), new BasicNameValuePair("client_secret", clientSecret),
new BasicNameValuePair("code", code), new BasicNameValuePair("code", code),
new BasicNameValuePair("redirect_uri", redirectUri) new BasicNameValuePair("redirect_uri", redirectUri)
); );
HttpPost getMethod = postRequest("/esc-sso/oauth2.0/accessToken", parameters); HttpPost getMethod = postRequest("/esc-sso/oauth2.0/accessToken", parameters);
@ -92,7 +92,7 @@ public class PailaLoginStrategy implements LoginStrategy {
} }
UserDTO userDTO = JSON.parseObject(userInfoResBody, UserDTO.class); UserDTO userDTO = JSON.parseObject(userInfoResBody, UserDTO.class);
if (userDTO == null) { if (userDTO == null) {
throw new NotFoundException(NOT_FOUND); throw new SSOLoginException(NOT_FOUND);
} }
return userDTO.getAttributes().getAccount_no(); return userDTO.getAttributes().getAccount_no();
} }

View File

@ -0,0 +1,125 @@
package com.chint.application.services.login.strategy;
import com.alibaba.fastjson.JSON;
import com.chint.application.dtos.UserDTO;
import com.chint.application.services.login.LoginStrategy;
import com.chint.domain.exceptions.SSOLoginException;
import com.chint.domain.factoriy.user.UserFactory;
import com.chint.domain.repository.UserRepository;
import com.chint.interfaces.rest.user.UserHttpRequest;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND;
@Slf4j
@Component
public class PailaMobileLoginStrategy implements LoginStrategy {
@Value("${paila.base-url}")
private String baseUrl;
@Value("${paila.client-mobile-id}")
private String clientId;
@Value("${paila.client-mobile-secret}")
private String clientSecret;
@Value("${paila.redirect-mobile-url}")
private String redirectUri;
@Autowired
private UserRepository userRepository;
@Autowired
private UserHttpRequest userHttpRequest;
@Autowired
private UserFactory userFactory;
@Override
public Optional<String> getAccessToken(String code) {
log.info("开始执行登录");
List<NameValuePair> parameters = Arrays.asList(
new BasicNameValuePair("grant_type", "authorization_code"),
new BasicNameValuePair("client_id", clientId),
new BasicNameValuePair("client_secret", clientSecret),
new BasicNameValuePair("code", code),
new BasicNameValuePair("redirect_uri", redirectUri)
);
HttpPost getMethod = postRequest("/esc-sso/oauth2.0/accessToken", parameters);
return LoginStrategy.getAccessTokenMethod(getMethod, "access_token");
}
@Override
public String getUserInfo(String accessToken) {
List<NameValuePair> userInfoParams = Collections.singletonList(
new BasicNameValuePair("access_token", accessToken)
);
HttpGet getMethodUserInfo = getRequest("/esc-sso/oauth2.0/profile", userInfoParams);
String userInfoResBody = null;
HttpClient client = HttpClients.createDefault();
try {
HttpResponse userInfoRes = client.execute(getMethodUserInfo);
userInfoResBody = EntityUtils.toString(userInfoRes.getEntity(), "UTF-8");
} catch (IOException e) {
log.error(e.getMessage());
}
UserDTO userDTO = JSON.parseObject(userInfoResBody, UserDTO.class);
if (userDTO == null) {
throw new SSOLoginException(NOT_FOUND);
}
return userDTO.getAttributes().getAccount_no();
}
private HttpGet getRequest(String path, List<NameValuePair> parameters) {
String userInfoUrl = null;
try {
userInfoUrl = new URIBuilder(baseUrl).setPath(path)
.setParameters(parameters).build().toString();
} catch (URISyntaxException e) {
log.error(e.getMessage());
}
HttpGet request = new HttpGet(userInfoUrl);
request.setHeader("Content-Type", "application/json");
return request;
}
private HttpPost postRequest(String path, List<NameValuePair> parameters) {
String userInfoUrl = null;
try {
userInfoUrl = new URIBuilder(baseUrl).setPath(path)
.setParameters(parameters).build().toString();
} catch (URISyntaxException e) {
log.error(e.getMessage());
}
HttpPost request = new HttpPost(userInfoUrl);
request.setHeader("Content-Type", "application/json");
return request;
}
}

View File

@ -1,5 +1,6 @@
package com.chint.domain.aggregates.location; package com.chint.domain.aggregates.location;
import com.chint.interfaces.rest.ctrip.dto.city.FlightCitySearchResponse;
import lombok.Data; import lombok.Data;
import org.springframework.data.annotation.Id; import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table; import org.springframework.data.relational.core.mapping.Table;
@ -19,4 +20,16 @@ public class CityEntity {
private String province; private String province;
private String provinceename; private String provinceename;
private String provinceName; private String provinceName;
public static CityEntity copyFrom(FlightCitySearchResponse.DataItem dataItem) {
CityEntity cityEntity = new CityEntity();
cityEntity.setCity(String.valueOf(dataItem.getCityId()));
cityEntity.setCityename(dataItem.getEName());
cityEntity.setCityName(dataItem.getName());
cityEntity.setCountryName(dataItem.getCountry());
cityEntity.setCountryename(dataItem.getEName());
cityEntity.setJianPin(dataItem.getCode());
cityEntity.setProvinceName(dataItem.getProvince());
return cityEntity;
}
} }

View File

@ -0,0 +1,18 @@
package com.chint.domain.aggregates.order;
import lombok.Data;
import org.springframework.data.relational.core.mapping.Table;
/**
* @author wanglf3
* @date 2024-02-28
* @vsrsion 1.0
**/
@Data
@Table("client")
public class Client {
private Long id;
private String clientId;
private String clientSecret;
}

View File

@ -6,6 +6,10 @@ import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient; import org.springframework.data.annotation.Transient;
import org.springframework.data.relational.core.mapping.Table; import org.springframework.data.relational.core.mapping.Table;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@Data @Data
@Table("leg_extension_field") @Table("leg_extension_field")
public class LegExtensionField { public class LegExtensionField {
@ -13,6 +17,9 @@ public class LegExtensionField {
private Long id; private Long id;
private Long legId; private Long legId;
private Integer amountType; private Integer amountType;
private String locationIds;
@Transient
private List<Location> locationList;
@Transient @Transient
private String amountTypeName; private String amountTypeName;
@Transient @Transient
@ -23,6 +30,26 @@ public class LegExtensionField {
private String estimatedAmount; private String estimatedAmount;
public LegExtensionField addLocationIdsAsString(List<Long> locationIds) {
this.locationIds = Arrays.toString(locationIds.toArray());
return this;
}
public List<Long> getLocationIdsAsLong() {
// 去除字符串开头和结尾的方括号
this.locationIds = this.locationIds.substring(1, this.locationIds.length() - 1);
// 根据逗号分割字符串
String[] items = this.locationIds.split(",");
// 创建一个Long类型的列表
List<Long> result = new ArrayList<>();
// 将每个分割后的字符串转换为Long并添加到列表中
for (String item : items) {
result.add(Long.parseLong(item.trim()));
}
return result;
}
public LegExtensionField reloadStatus() { public LegExtensionField reloadStatus() {
this.amountTypeName = translateLegOtherAmountTypeToChineseName(this.amountType); this.amountTypeName = translateLegOtherAmountTypeToChineseName(this.amountType);
this.amountTypeEnName = translateLegOtherAmountTypeToEnglishName(this.amountType); this.amountTypeEnName = translateLegOtherAmountTypeToEnglishName(this.amountType);

View File

@ -32,6 +32,7 @@ public class OrderDetail {
private CurrencyType currencyType; //货币类型 private CurrencyType currencyType; //货币类型
private Long destinationId; private Long destinationId;
private Long originId; private Long originId;
private String employeeNo;
private LocalDateTime orderDate; private LocalDateTime orderDate;
private LocalDateTime startTime; private LocalDateTime startTime;
private LocalDateTime endTime; private LocalDateTime endTime;
@ -69,7 +70,10 @@ public class OrderDetail {
orderDetail.setUpdateTime(LocalDateTime.now()); orderDetail.setUpdateTime(LocalDateTime.now());
return orderDetail; return orderDetail;
} }
public OrderDetail employeeNo(String employeeNo) {
this.setEmployeeNo(employeeNo);
return this;
}
public OrderDetail productType(Integer productType) { public OrderDetail productType(Integer productType) {
this.setProductType(productType); this.setProductType(productType);
return this; return this;

View File

@ -3,7 +3,6 @@ package com.chint.domain.aggregates.standards;
import java.util.HashMap; import java.util.HashMap;
public class CityTag { public class CityTag {
public static final HashMap<String, String> cityMap; public static final HashMap<String, String> cityMap;
static { static {

View File

@ -0,0 +1,49 @@
package com.chint.domain.aggregates.standards;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class HotCityTag {
public static final List<String> citys;
public static final List<String> internationalCitys;
static {
citys = new ArrayList<>();
citys.add("上海");
citys.add("北京");
citys.add("广州");
citys.add("深圳");
citys.add("天津");
citys.add("重庆");
citys.add("苏州");
citys.add("武汉");
citys.add("成都");
citys.add("杭州");
citys.add("温州");
internationalCitys = new ArrayList<>();
internationalCitys.add("北美洲_美国_纽约州_纽约_");
internationalCitys.add("北美洲_美国_内华达州_拉斯维加斯_");
internationalCitys.add("北美洲_美国_伊利诺伊州_芝加哥_");
internationalCitys.add("北美洲_美国_华盛顿哥伦比亚特区_华盛顿_");
internationalCitys.add("欧洲_英国_英格兰_伦敦_");
internationalCitys.add("欧洲_德国_拜恩巴伐利亚_慕尼黑_");
internationalCitys.add("欧洲_西班牙_加泰罗尼亚_巴塞罗那_");
internationalCitys.add("欧洲_德国_柏林_柏林_");
internationalCitys.add("北美洲_美国_纽约州_阿姆斯特丹_");
internationalCitys.add("欧洲_法国_法兰西岛_巴黎_");
internationalCitys.add("欧洲_西班牙_马德里_马德里_");
internationalCitys.add("欧洲_葡萄牙_特茹河谷里斯本_里斯本_");
internationalCitys.add("欧洲_奥地利_维也纳_维也纳_");
internationalCitys.add("亚洲_日本_东京都_东京_");
internationalCitys.add("欧洲_挪威_奥斯陆市_奥斯陆_");
internationalCitys.add("北美洲_美国_加利福尼亚州_旧金山_");
internationalCitys.add("亚洲_新加坡_新加坡_新加坡_");
}
}

View File

@ -21,7 +21,7 @@ public class LegEventListener {
// @TransitionTo(command = "LegPrepareCommand", order = 0) // @TransitionTo(command = "LegPrepareCommand", order = 0)
public void onLegStatusChange(LegPrepareCommand command) { public void onLegStatusChange(LegPrepareCommand command) {
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId())); Leg leg = legRepository.findByLegId(command.getLegId());
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType()); LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
leg.addEvent(legEvent); leg.addEvent(legEvent);
legRepository.save(leg); legRepository.save(leg);

View File

@ -0,0 +1,7 @@
package com.chint.domain.exceptions;
public class SSOLoginException extends BaseException{
public SSOLoginException(String msg) {
super(msg);
}
}

View File

@ -126,6 +126,10 @@ public class RouteLegFactory implements LegFactory {
private static LegExtensionField getLegExtensionField(LegData data) { private static LegExtensionField getLegExtensionField(LegData data) {
LegExtensionFieldData legExtensionFieldData = data.getLegExtensionFieldData(); LegExtensionFieldData legExtensionFieldData = data.getLegExtensionFieldData();
return BeanUtil.copyProperties(legExtensionFieldData, LegExtensionField.class); LegExtensionField legExtensionField = BeanUtil.copyProperties(legExtensionFieldData, LegExtensionField.class);
if (legExtensionFieldData.getLocationIds() != null && !legExtensionFieldData.getLocationIds().isEmpty()) {
legExtensionField.addLocationIdsAsString(legExtensionFieldData.getLocationIds());
}
return legExtensionField;
} }
} }

View File

@ -0,0 +1,16 @@
package com.chint.domain.repository;
import com.chint.application.dtos.AuthenticationDto;
import com.chint.domain.aggregates.order.Client;
/**
* @author wanglf3
* @date 2024-02-28
* @vsrsion 1.0
**/
public interface ClientRepository {
Client save(Client client);
Client findByClientId(String clientId);
}

View File

@ -14,5 +14,7 @@ public interface LegRepository {
void saveAll(List<Leg> legs); void saveAll(List<Leg> legs);
Leg findByLegId(Leg leg); Leg findByLegId(Long legId);
} }

View File

@ -22,4 +22,12 @@ public interface LocationRepository {
List<Location> findByName(String localName); List<Location> findByName(String localName);
String locationPathByName(String localName); String locationPathByName(String localName);
List<Location> findHotCitiesByCityName(List<String> locationNames);
List<Location> findHotIntnationalCitiesByCityName(List<String> locationNames);
List<Location> findByNameList(List<Long> locationIds);
} }

View File

@ -1,11 +1,15 @@
package com.chint.domain.repository; package com.chint.domain.repository;
import com.chint.application.dtos.OrderDetailQueryParam;
import com.chint.domain.aggregates.order.OrderDetail; import com.chint.domain.aggregates.order.OrderDetail;
import org.springframework.data.domain.Page;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
public interface OrderDetailRepository { public interface OrderDetailRepository {
Page<OrderDetail> pageQuery(OrderDetailQueryParam orderDetailQueryParam);
OrderDetail findById(Long orderDetailId); OrderDetail findById(Long orderDetailId);
List<OrderDetail> findByLegId(Long legId); List<OrderDetail> findByLegId(Long legId);

View File

@ -68,6 +68,12 @@ public class OrderDomainService {
public List<Leg> queryLocation(List<Leg> list) { public List<Leg> queryLocation(List<Leg> list) {
list.forEach(leg -> { list.forEach(leg -> {
LegExtensionField legExtensionField = leg.getLegExtensionField();
if (legExtensionField != null && legExtensionField.getLocationIds() != null) {
List<Long> locationIdsAsLong = legExtensionField.getLocationIdsAsLong();
List<Location> byNameList = locationRepository.findByNameList(locationIdsAsLong);
legExtensionField.setLocationList(byNameList);
}
leg.setOriginLocation(locationRepository.findByLocationId(leg.getOriginId())); leg.setOriginLocation(locationRepository.findByLocationId(leg.getOriginId()));
leg.setDestinationLocation(locationRepository.findByLocationId(leg.getDestinationId())); leg.setDestinationLocation(locationRepository.findByLocationId(leg.getDestinationId()));
}); });
@ -122,7 +128,8 @@ public class OrderDomainService {
.productType(orderDetail.getProductType()) .productType(orderDetail.getProductType())
.extensionData(orderDetail.getExtensionDataByProductType()) .extensionData(orderDetail.getExtensionDataByProductType())
.sendToQueue(); .sendToQueue();
}; }
;
} }
@ListenTo(command = "BPMAuditCommand", order = 0) @ListenTo(command = "BPMAuditCommand", order = 0)

View File

@ -1,8 +1,12 @@
package com.chint.domain.service.auth; package com.chint.domain.service.auth;
import com.chint.application.dtos.AuthenticationDto;
import com.chint.application.dtos.OrderSearchResult;
import com.chint.domain.value_object.UserLoginParam; import com.chint.domain.value_object.UserLoginParam;
import com.chint.domain.value_object.UserLoginResult; import com.chint.domain.value_object.UserLoginResult;
public interface AuthenticateService { public interface AuthenticateService {
UserLoginResult authenticateEmployeeNo(UserLoginParam userLoginParam); UserLoginResult authenticateEmployeeNo(UserLoginParam userLoginParam);
OrderSearchResult authenticateClient(AuthenticationDto authenticationDto)throws Exception;
} }

View File

@ -1,7 +1,12 @@
package com.chint.domain.service.auth; package com.chint.domain.service.auth;
import com.chint.application.dtos.AuthenticationDto;
import com.chint.application.dtos.OrderSearchResult;
import com.chint.domain.aggregates.order.Client;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import com.chint.domain.exceptions.AuthException;
import com.chint.domain.factoriy.user.UserFactory; import com.chint.domain.factoriy.user.UserFactory;
import com.chint.domain.repository.ClientRepository;
import com.chint.domain.repository.UserRepository; import com.chint.domain.repository.UserRepository;
import com.chint.domain.value_object.UserLoginParam; import com.chint.domain.value_object.UserLoginParam;
import com.chint.domain.value_object.UserLoginResult; import com.chint.domain.value_object.UserLoginResult;
@ -23,6 +28,9 @@ public class AuthenticateServiceImpl implements AuthenticateService {
private final UserRepository userRepository; private final UserRepository userRepository;
private final UserHttpRequest httpRequest; private final UserHttpRequest httpRequest;
@Autowired
private ClientRepository clientRepository;
@Autowired @Autowired
private UserFactory userFactory; private UserFactory userFactory;
@ -74,4 +82,26 @@ public class AuthenticateServiceImpl implements AuthenticateService {
return authenticateEmployeeNo(userLoginParam); return authenticateEmployeeNo(userLoginParam);
} }
} }
@Override
public OrderSearchResult authenticateClient(AuthenticationDto authenticationDto) throws Exception{
Client client = clientRepository.findByClientId(authenticationDto.getClientid());
if (client != null){
Map<String, Object> claims = new HashMap<>();
claims.put(AuthMessageConstant.CLIENT_ID, client.getClientId());
claims.put(AuthMessageConstant.CLIENT_SECRET,client.getClientSecret());
String jwt = JWTUtil.createJWT(AuthMessageConstant.SECRET,AuthMessageConstant.EXPIRATION_CLIENT_TIME_MS,
AuthMessageConstant.SUBJECT,claims);
OrderSearchResult result = new OrderSearchResult();
result.setToken(Token.of(jwt));
return result;
}else {
throw new AuthException(AuthMessageConstant.JWT_INVALID);
}
}
} }

View File

@ -62,7 +62,7 @@ public class LegEventHandler implements LegEventService {
@Transactional @Transactional
@Override @Override
public void prepareLeg(LegPrepareCommand command) { public void prepareLeg(LegPrepareCommand command) {
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId())); Leg leg = legRepository.findByLegId(command.getLegId());
if (leg.getEventList().isEmpty()) { if (leg.getEventList().isEmpty()) {
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType()); LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
leg.addEvent(legEvent); leg.addEvent(legEvent);
@ -153,7 +153,8 @@ public class LegEventHandler implements LegEventService {
if (byOrderNo.isEmpty()) { if (byOrderNo.isEmpty()) {
//否则创建新的订单添加到routeOrder //否则创建新的订单添加到routeOrder
orderDetail = orderDetailFactory.create(data) orderDetail = orderDetailFactory.create(data)
.price(data.getPrice()).productType(data.getProductType()); .price(data.getPrice()).productType(data.getProductType())
.employeeNo(routeOrder.getUserId());
routeOrder.addOrderDetail(orderDetail); routeOrder.addOrderDetail(orderDetail);
routeOrder = routeRepository.save(routeOrder); routeOrder = routeRepository.save(routeOrder);
// OrderDetail orderDetail = routeOrder // OrderDetail orderDetail = routeOrder
@ -173,7 +174,7 @@ public class LegEventHandler implements LegEventService {
@Override @Override
public ResultContainer orderLeg(LegOrderedCommand command) { public ResultContainer orderLeg(LegOrderedCommand command) {
//如果筛选事件可能会是错误需要用户手动添加并修改事件 因此会进行额外出发修改下单事件 //如果筛选事件可能会是错误需要用户手动添加并修改事件 因此会进行额外出发修改下单事件
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId())); Leg leg = legRepository.findByLegId(command.getLegId());
//因为orderDetail已经进行持久化保存 只需要从数据库进行查询 //因为orderDetail已经进行持久化保存 只需要从数据库进行查询
OrderDetail orderDetail = orderDetailRepository.findById(command.getOrderDetailId()); OrderDetail orderDetail = orderDetailRepository.findById(command.getOrderDetailId());
LegEvent legEvent = legEventFactory LegEvent legEvent = legEventFactory
@ -189,7 +190,7 @@ public class LegEventHandler implements LegEventService {
@Override @Override
public void payForLeg(LegPayedCommand command) { public void payForLeg(LegPayedCommand command) {
// PayLegData data = command.getData(); // PayLegData data = command.getData();
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId())); Leg leg = legRepository.findByLegId(command.getLegId());
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType()); LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
leg.addEvent(legEvent); leg.addEvent(legEvent);
legRepository.save(leg); legRepository.save(leg);
@ -198,7 +199,7 @@ public class LegEventHandler implements LegEventService {
@Transactional @Transactional
@Override @Override
public void finishLeg(LegFinishedCommand command) { public void finishLeg(LegFinishedCommand command) {
Leg leg = legRepository.findByLegId(Leg.of(command.getLegId())); Leg leg = legRepository.findByLegId(command.getLegId());
LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType()); LegEvent legEvent = legEventFactory.creatLegEvent(command.getLegEventType());
leg.addEvent(legEvent); leg.addEvent(legEvent);
legRepository.save(leg); legRepository.save(leg);

View File

@ -59,7 +59,7 @@ public class LegEventServiceImpl implements LegEventService {
@Override @Override
@ListenTo(command = "LegFinishedCommand", order = 0) @ListenTo(command = "LegFinishedCommand", order = 0)
public void finishLeg(LegFinishedCommand command) { public void finishLeg(LegFinishedCommand command) {
legEventHandler.finishLeg(command);
} }
@Override @Override

View File

@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import org.springframework.data.annotation.Transient; import org.springframework.data.annotation.Transient;
import java.util.List;
@Data @Data
public class LegExtensionFieldData { public class LegExtensionFieldData {
@ApiModelProperty("其他费用类型") @ApiModelProperty("其他费用类型")
@ -16,4 +18,6 @@ public class LegExtensionFieldData {
private String destinationDescription; private String destinationDescription;
@ApiModelProperty("预估金额") @ApiModelProperty("预估金额")
private String estimatedAmount; private String estimatedAmount;
@ApiModelProperty("地理位置id列表")
private List<Long> locationIds;
} }

View File

@ -2,8 +2,11 @@ package com.chint.domain.value_object;
import lombok.Data; import lombok.Data;
import java.util.List;
@Data @Data
public class SyncLegData { public class SyncLegData {
private Long routeId; private Long routeId;
private List<Long> routeIds;
private String supplierName; private String supplierName;
} }

View File

@ -35,4 +35,12 @@ public class AuthMessageConstant {
public static final long EXPIRATION_TIME_MS = 3600000L; // 1小时过期时间 public static final long EXPIRATION_TIME_MS = 3600000L; // 1小时过期时间
public static final String HEADER_TOKEN = "token"; public static final String HEADER_TOKEN = "token";
public static final String HEADER_TOKEN_UP_CASE = "Token"; public static final String HEADER_TOKEN_UP_CASE = "Token";
public static final String CLIENT_ID = "有效的 CLIENT_id ";
public static final String CLIENT_SECRET = "有效的 CLIENT_SECRET";
public static final String HEADER_CLIENT_CASE = "Client";
public static final long EXPIRATION_CLIENT_TIME_MS = 10800000L; // 3小时过期时间
} }

View File

@ -27,6 +27,7 @@ public class CTripConstant {
public static final String C_TRIP_AUTH_LOGIN = "/corpservice/authorize/login"; public static final String C_TRIP_AUTH_LOGIN = "/corpservice/authorize/login";
public static final String C_TRIP_SINGLE_LOGIN = "/m/SingleSignOn/H5SignInfo"; public static final String C_TRIP_SINGLE_LOGIN = "/m/SingleSignOn/H5SignInfo";
public static final String C_TRIP_AUDIT_PATH = "/corpservice/AuditService/Audit"; public static final String C_TRIP_AUDIT_PATH = "/corpservice/AuditService/Audit";
public static final String C_TRIP_FLIGHT_CITY_PATH = "/CorpOpenapi/Position/SearchFlightCityInfo";
public static final String C_TRIP_REQUEST_SECRET = "zhengtai2024_nEbmKfOo"; public static final String C_TRIP_REQUEST_SECRET = "zhengtai2024_nEbmKfOo";
public static final String C_TRIP_AUDIT_ACTION_SUCCESS = "T"; public static final String C_TRIP_AUDIT_ACTION_SUCCESS = "T";
public static final String C_TRIP_AUDIT_ACTION_FAIL = "F"; public static final String C_TRIP_AUDIT_ACTION_FAIL = "F";

View File

@ -10,9 +10,9 @@ public class LegConstant {
public static final String LEG_STATUS_NOT_ORDERED_NAME = "未下单"; public static final String LEG_STATUS_NOT_ORDERED_NAME = "未下单";
public static final int LEG_STATUS_ORDERED = 3; public static final int LEG_STATUS_ORDERED = 3;
public static final String LEG_STATUS_ORDERED_NAME = "已下单"; public static final String LEG_STATUS_ORDERED_NAME = "已下单";
public static final int LEG_STATUS_PAYED = 4; public static final int LEG_STATUS_PAYED = 5;
public static final String LEG_STATUS_PAYED_NAME = "已付款"; public static final String LEG_STATUS_PAYED_NAME = "已付款";
public static final int LEG_STATUS_FINISH = 5; public static final int LEG_STATUS_FINISH = -2;
public static final String LEG_STATUS_FINISH_NAME = "已结束"; public static final String LEG_STATUS_FINISH_NAME = "已结束";
public static final int LEG_STATUS_REJECT = -1; public static final int LEG_STATUS_REJECT = -1;
public static final String LEG_STATUS_REJECT_NAME = "审批未通过"; public static final String LEG_STATUS_REJECT_NAME = "审批未通过";
@ -56,9 +56,9 @@ public class LegConstant {
public static final String LEG_EVENT_NOT_ORDERED_NAME = "同步事件"; public static final String LEG_EVENT_NOT_ORDERED_NAME = "同步事件";
public static final int LEG_EVENT_ORDERED = 3; public static final int LEG_EVENT_ORDERED = 3;
public static final String LEG_EVENT_ORDERED_NAME = "下单事件"; public static final String LEG_EVENT_ORDERED_NAME = "下单事件";
public static final int LEG_EVENT_PAYED = 4; public static final int LEG_EVENT_PAYED = 5;
public static final String LEG_EVENT_PAYED_NAME = "付款事件"; public static final String LEG_EVENT_PAYED_NAME = "付款事件";
public static final int LEG_EVENT_FINISH = 5; public static final int LEG_EVENT_FINISH = -2;
public static final String LEG_EVENT_FINISH_NAME = "结束事件"; public static final String LEG_EVENT_FINISH_NAME = "结束事件";
public static final int LEG_EVENT_REJECT = -1; public static final int LEG_EVENT_REJECT = -1;
public static final String LEG_EVENT_REJECT_NAME = "拒绝事件"; public static final String LEG_EVENT_REJECT_NAME = "拒绝事件";

View File

@ -47,6 +47,11 @@ public class GlobalExceptionHandler {
return Result.tokenExpired(e.getMessage()); return Result.tokenExpired(e.getMessage());
} }
@ExceptionHandler(SSOLoginException.class)
public Result<String> handleSSOLoginException(HttpServletRequest request, SSOLoginException e) {
return Result.ssoLoginFail(e.getMessage());
}
@ExceptionHandler(value = Exception.class) @ExceptionHandler(value = Exception.class)
public Result<String> handleException(Exception ex) { public Result<String> handleException(Exception ex) {
Throwable rootCause = ex; Throwable rootCause = ex;

View File

@ -1,12 +1,18 @@
package com.chint.infrastructure.repository; package com.chint.infrastructure.repository;
import com.chint.domain.aggregates.location.CityEntity; import com.chint.domain.aggregates.location.CityEntity;
import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.repository.CityRepository; import com.chint.domain.repository.CityRepository;
import com.chint.infrastructure.repository.jdbc.JdbcCityRepository; import com.chint.infrastructure.repository.jdbc.JdbcCityRepository;
import com.chint.interfaces.rest.ctrip.CTripFlightCitySearchRequest;
import com.chint.interfaces.rest.ctrip.dto.city.FlightCitySearchResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
import java.util.Optional;
import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND;
@Repository @Repository
public class CityRepositoryImpl implements CityRepository { public class CityRepositoryImpl implements CityRepository {
@ -14,6 +20,9 @@ public class CityRepositoryImpl implements CityRepository {
@Autowired @Autowired
private JdbcCityRepository jdbcCityRepository; private JdbcCityRepository jdbcCityRepository;
@Autowired
private CTripFlightCitySearchRequest cTripFlightCitySearchRequest;
@Override @Override
public void saveAll(List<CityEntity> cities) { public void saveAll(List<CityEntity> cities) {
jdbcCityRepository.save(cities.get(0)); jdbcCityRepository.save(cities.get(0));
@ -22,7 +31,22 @@ public class CityRepositoryImpl implements CityRepository {
@Override @Override
public CityEntity findByCityName(String name) { public CityEntity findByCityName(String name) {
return jdbcCityRepository.findByCityName(name); CityEntity byCityName = jdbcCityRepository.findByCityName(name);
} if (byCityName == null) {
Optional<FlightCitySearchResponse.DataItem> optional = Optional.ofNullable(
cTripFlightCitySearchRequest.getFlightCity(name, 1).getData()
.stream()
.filter(dataItem -> dataItem.getType() == 5 || dataItem.getType() == 4)
.toList()
.get(0));
if (optional.isPresent()) {
FlightCitySearchResponse.DataItem dataItem = optional.get();
CityEntity cityEntity = CityEntity.copyFrom(dataItem);
jdbcCityRepository.save(cityEntity);
return cityEntity;
} else {
throw new NotFoundException(NOT_FOUND);
}
}return byCityName;}
} }

View File

@ -0,0 +1,32 @@
package com.chint.infrastructure.repository;
import com.chint.application.dtos.AuthenticationDto;
import com.chint.domain.aggregates.order.Client;
import com.chint.domain.repository.ClientRepository;
import com.chint.infrastructure.repository.jdbc.JdbcClientRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
/**
* @author wanglf3
* @date 2024-02-28
* @vsrsion 1.0
**/
@Repository
public class ClientRepositoryImpl implements ClientRepository {
@Autowired
private JdbcClientRepository jdbcClientRepository;
@Override
public Client save(Client client) {
return jdbcClientRepository.save(client);
}
@Override
public Client findByClientId(String clientId){
return jdbcClientRepository.findByClientId(clientId);
}
}

View File

@ -39,7 +39,7 @@ public class LegRepositoryImpl implements LegRepository {
} }
@Override @Override
public Leg findByLegId(Leg leg) { public Leg findByLegId(Long legId) {
return legRepository.findById(leg.getLegId()).orElseThrow(()->new NotFoundException(NOT_FOUND)); return legRepository.findById(legId).orElseThrow(()->new NotFoundException(NOT_FOUND));
} }
} }

View File

@ -76,4 +76,30 @@ public class LocationRepositoryImpl implements LocationRepository {
Location byLocationName = jdbcLocationRepository.findByLocationName(localName); Location byLocationName = jdbcLocationRepository.findByLocationName(localName);
return byLocationName.getLocationPathName().replace("_", ""); return byLocationName.getLocationPathName().replace("_", "");
} }
@Override
public List<Location> findByNameList(List<Long> locationIds) {
return jdbcLocationRepository.findByLocationIdIn(locationIds);
}
@Override
public List<Location> findHotCitiesByCityName(List<String> locationNames) {
return jdbcLocationRepository.findByLocationNameInAndLocationPathContainingAndLevel(locationNames,"3106_1_",3);
}
@Override
public List<Location> findHotIntnationalCitiesByCityName(List<String> locationNames){
List<Location> hotCities =
jdbcLocationRepository.findByLocationPathNameInAndLevel(locationNames,3);
return hotCities;
}
// public List<Location> findHotIntnationalCitiesByCityName(List<String> locationNames) {
// List<Location> hotCities =
// jdbcLocationRepository.findByLocationPathNameAndLevel(locationNames,3);
// return hotCities;
// }
} }

View File

@ -1,10 +1,15 @@
package com.chint.infrastructure.repository; package com.chint.infrastructure.repository;
import com.chint.application.dtos.OrderDetailQueryParam;
import com.chint.domain.aggregates.order.OrderDetail; import com.chint.domain.aggregates.order.OrderDetail;
import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.repository.OrderDetailRepository; import com.chint.domain.repository.OrderDetailRepository;
import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository; import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository;
import com.chint.infrastructure.util.BaseContext;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
@ -17,6 +22,14 @@ public class OrderDetailRepositoryImpl implements OrderDetailRepository {
@Autowired @Autowired
private JdbcOrderDetailRepository orderDetailRepository; private JdbcOrderDetailRepository orderDetailRepository;
@Override
public Page<OrderDetail> pageQuery(OrderDetailQueryParam orderDetailQueryParam) {
PageRequest pageRequest = PageRequest
.of(orderDetailQueryParam.getPageNum() - 1, orderDetailQueryParam.getPageSize(), Sort.by("updateTime"));
String employeeNo = BaseContext.getCurrentUser().getEmployeeNo();
return orderDetailRepository.findByEmployeeNo(employeeNo, pageRequest);
}
@Override @Override
public OrderDetail findById(Long orderDetailId) { public OrderDetail findById(Long orderDetailId) {
return orderDetailRepository.findById(orderDetailId).orElseThrow(() -> new NotFoundException(NOT_FOUND)); return orderDetailRepository.findById(orderDetailId).orElseThrow(() -> new NotFoundException(NOT_FOUND));

View File

@ -49,7 +49,7 @@ public class RouteRepositoryImpl implements RouteRepository {
@Override @Override
public Page<RouteOrder> findByOrderNoFuzzy(OrderQueryData orderQueryData) { public Page<RouteOrder> findByOrderNoFuzzy(OrderQueryData orderQueryData) {
PageRequest sort = PageRequest PageRequest sort = PageRequest
.of(orderQueryData.getPageNum() - 1, orderQueryData.getPageSize(), Sort.by("sort")); .of(orderQueryData.getPageNum() - 1, orderQueryData.getPageSize(), Sort.by("updateTime"));
String employeeNo = BaseContext.getCurrentUser().getEmployeeNo().toString(); String employeeNo = BaseContext.getCurrentUser().getEmployeeNo().toString();
return jdbcRouteRepository return jdbcRouteRepository
.findByUserIdAndRouteOrderNoContainingOrApproveOrderNo_CreatorAndRouteOrderNoContaining( .findByUserIdAndRouteOrderNoContainingOrApproveOrderNo_CreatorAndRouteOrderNoContaining(
@ -63,7 +63,7 @@ public class RouteRepositoryImpl implements RouteRepository {
@Override @Override
public Page<RouteOrder> findByInstructions(OrderQueryData orderQueryData) { public Page<RouteOrder> findByInstructions(OrderQueryData orderQueryData) {
PageRequest sort = PageRequest PageRequest sort = PageRequest
.of(orderQueryData.getPageNum() - 1, orderQueryData.getPageSize(), Sort.by("sort")); .of(orderQueryData.getPageNum() - 1, orderQueryData.getPageSize(), Sort.by("updateTime"));
String employeeNo = BaseContext.getCurrentUser().getEmployeeNo().toString(); String employeeNo = BaseContext.getCurrentUser().getEmployeeNo().toString();
return jdbcRouteRepository.findByUserIdAndApproveOrderNo_InstructionsContainingOrApproveOrderNo_CreatorAndApproveOrderNo_InstructionsContaining( return jdbcRouteRepository.findByUserIdAndApproveOrderNo_InstructionsContainingOrApproveOrderNo_CreatorAndApproveOrderNo_InstructionsContaining(
Long.valueOf(employeeNo), Long.valueOf(employeeNo),
@ -81,7 +81,7 @@ public class RouteRepositoryImpl implements RouteRepository {
@Override @Override
public PageResult<RouteOrder> pageQuery(OrderQueryData orderQueryData) { public PageResult<RouteOrder> pageQuery(OrderQueryData orderQueryData) {
PageRequest sort = PageRequest PageRequest sort = PageRequest
.of(orderQueryData.getPageNum() - 1, orderQueryData.getPageSize(), Sort.by("sort")); .of(orderQueryData.getPageNum() - 1, orderQueryData.getPageSize(), Sort.by("updateTime"));
String employeeNo = BaseContext.getCurrentUser().getEmployeeNo().toString(); String employeeNo = BaseContext.getCurrentUser().getEmployeeNo().toString();
Page<RouteOrder> byUserId = jdbcRouteRepository Page<RouteOrder> byUserId = jdbcRouteRepository
.findByUserIdAndApproveOrderNo_ActualOrderNoNotNullOrApproveOrderNo_CreatorAndApproveOrderNo_ActualOrderNoNotNull(Long.valueOf(employeeNo), employeeNo, sort); .findByUserIdAndApproveOrderNo_ActualOrderNoNotNullOrApproveOrderNo_CreatorAndApproveOrderNo_ActualOrderNoNotNull(Long.valueOf(employeeNo), employeeNo, sort);

View File

@ -0,0 +1,17 @@
package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.order.Client;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
/**
* @author wanglf3
* @date 2024-02-28
* @vsrsion 1.0
**/
@Repository
public interface JdbcClientRepository extends CrudRepository<Client,Long> {
Client findByClientId(String clientId);
}

View File

@ -6,6 +6,7 @@ import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.Collection;
import java.util.List; import java.util.List;
@Repository @Repository
@ -23,4 +24,16 @@ public interface JdbcLocationRepository extends CrudRepository<Location, Long> {
List<Location> findByLocationNameContaining(String locationName); List<Location> findByLocationNameContaining(String locationName);
Location findByLocationName(String locationName); Location findByLocationName(String locationName);
List<Location> findByLocationNameIn(Collection<String> locationName);
List<Location> findByLocationIdIn(Collection<Long> locationId);
List<Location> findByLocationNameInAndLocationPathContainingAndLevel(Collection<String> locationName,
String locationPath,
Integer level);
List<Location> findByLocationPathNameInAndLevel(Collection<String> locationPathName,Integer level);
} }

View File

@ -1,6 +1,8 @@
package com.chint.infrastructure.repository.jdbc; package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.order.OrderDetail; import com.chint.domain.aggregates.order.OrderDetail;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.CrudRepository; import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
@ -12,4 +14,6 @@ public interface JdbcOrderDetailRepository extends CrudRepository<OrderDetail, L
OrderDetail findByOrderNo(String orderNo); OrderDetail findByOrderNo(String orderNo);
List<OrderDetail> findByLegId(Long legId); List<OrderDetail> findByLegId(Long legId);
Page<OrderDetail> findByEmployeeNo(String employeeNo, Pageable pageable);
} }

View File

@ -52,6 +52,9 @@ public class Result<T> implements Serializable {
public static <T> Result<T> tokenExpired(String msg) { public static <T> Result<T> tokenExpired(String msg) {
return new Result<T>(msg, "-1"); return new Result<T>(msg, "-1");
} }
public static <T> Result<T> ssoLoginFail(String msg) {
return new Result<T>(msg, "-2");
}
@Override @Override
public boolean equals(Object o) { public boolean equals(Object o) {

View File

@ -16,29 +16,49 @@ public class JwtTokenAdminInterceptor implements HandlerInterceptor {
@Override @Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
String token = request.getHeader(AuthMessageConstant.HEADER_TOKEN);
if (token == null) {
token = request.getHeader(AuthMessageConstant.HEADER_TOKEN_UP_CASE);
}
if (request.getRequestURI().contains("/pubilc")) {
return true;
}
if (token == null) {
throw new AuthException(AuthMessageConstant.JWT_REQUIRED);
}
try { try {
JWTUtil.verifyJWT(AuthMessageConstant.SECRET, token); String token = null;
var parseJWT = JWTUtil.parseJWT(AuthMessageConstant.SECRET, token); token = request.getHeader(AuthMessageConstant.HEADER_TOKEN);
var withJwt = User.withJwt(parseJWT); if (token != null) {
BaseContext.setCurrentUser(withJwt); return dealWithTokenInfo(token);
return true; // If verification succeeds, continue processing the request }
if (token == null) {
token = request.getHeader(AuthMessageConstant.HEADER_TOKEN_UP_CASE);
if (token != null) {
return dealWithTokenInfo(token);
}
}
if (token == null) {
token = request.getHeader(AuthMessageConstant.HEADER_CLIENT_CASE);
if (token != null) {
return dealWithClientInfo(token);
}
}
if (request.getRequestURI().contains("/pubilc")) {
return true;
}
if (token == null) {
throw new AuthException(AuthMessageConstant.JWT_REQUIRED);
}
} catch (TokenExpiredException e) { } catch (TokenExpiredException e) {
throw new JwtExpiredException(AuthMessageConstant.JWT_EXPIRED); throw new JwtExpiredException(AuthMessageConstant.JWT_EXPIRED);
} catch (Exception e) { } catch (Exception e) {
throw new AuthException(AuthMessageConstant.JWT_INVALID); throw new AuthException(AuthMessageConstant.JWT_INVALID);
} }
return false;
}
private boolean dealWithTokenInfo(String token) {
JWTUtil.verifyJWT(AuthMessageConstant.SECRET, token);
var parseJWT = JWTUtil.parseJWT(AuthMessageConstant.SECRET, token);
var withJwt = User.withJwt(parseJWT);
BaseContext.setCurrentUser(withJwt);
return true; // If verification succeeds, continue processing the request
}
private boolean dealWithClientInfo(String token) {
JWTUtil.verifyJWT(AuthMessageConstant.SECRET, token);
return true; // If verification succeeds, continue processing the request
} }
} }

View File

@ -0,0 +1,54 @@
package com.chint.interfaces.rest.ctrip;
import com.chint.interfaces.rest.base.PostRequest;
import com.chint.interfaces.rest.ctrip.dto.Authentification;
import com.chint.interfaces.rest.ctrip.dto.city.FlightCitySearchRequest;
import com.chint.interfaces.rest.ctrip.dto.city.FlightCitySearchResponse;
import com.google.gson.Gson;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import static com.chint.infrastructure.constant.CTripConstant.C_TRIP_FLIGHT_CITY_PATH;
import static com.chint.infrastructure.constant.CTripConstant.LANGUAGE_CN;
@Slf4j
@Component
public class CTripFlightCitySearchRequest {
@Value("${cTrip.baseUrl}")
public String C_TRIP_BASE_URL;
@Value("${cTrip.appKey}")
private String C_TRIP_APP_KEY;
@Autowired
private PostRequest postRequest;
@Autowired
private CTripTicketRequest ticketRequest;
private String flightCityUrl;
@PostConstruct
private void init() {
this.flightCityUrl = C_TRIP_BASE_URL + C_TRIP_FLIGHT_CITY_PATH;
}
public FlightCitySearchResponse getFlightCity(String Keyword, Integer AreaType) {
Gson gson = new Gson();
Authentification auth = new Authentification(C_TRIP_APP_KEY, ticketRequest.loadTicket());
FlightCitySearchRequest flightCitySearchRequest = new FlightCitySearchRequest();
flightCitySearchRequest.setAuth(auth);
flightCitySearchRequest.setKeyword(Keyword);
flightCitySearchRequest.setAreaType(AreaType);
flightCitySearchRequest.setLanguage(LANGUAGE_CN);
FlightCitySearchResponse flightCitySearchResponse = postRequest.post(flightCityUrl, flightCitySearchRequest, FlightCitySearchResponse.class);
log.info(gson.toJson(flightCitySearchResponse.getData().get(0)));
return flightCitySearchResponse;
}
}

View File

@ -0,0 +1,12 @@
package com.chint.interfaces.rest.ctrip.dto.city;
import com.chint.interfaces.rest.ctrip.dto.Authentification;
import lombok.Data;
@Data
public class FlightCitySearchRequest {
private String Keyword;
private Integer AreaType;
private String Language;
private Authentification auth;
}

View File

@ -0,0 +1,50 @@
package com.chint.interfaces.rest.ctrip.dto.city;
import lombok.Data;
import java.util.List;
@Data
public class FlightCitySearchResponse {
private String Keyword;
private List<DataItem> Data;
private Status Status;
// Getters and setters
@Data
public static class DataItem {
private String Name;
private int Type;
private String EName;
private String Spell;
private String ShortSpell;
private String Country;
private String Province;
private String Code;
private int CityId;
private String TimeZone;
private int POIID;
private List<DatasItem> Datas;
// Getters and setters
}
@Data
public static class DatasItem {
private String Name;
private int Type;
private String EName;
private String Country;
private String Province;
private String Code;
private int POIID;
// Getters and setters
}
@Data
public static class Status {
private int ErrorCode;
private boolean Success;
// Getters and setters
}
}

View File

@ -57,6 +57,9 @@ paila:
client-id: 0053df85723db94491e8 client-id: 0053df85723db94491e8
client-secret: 7368bcec4c0f004c40585f6ed1087d887897 client-secret: 7368bcec4c0f004c40585f6ed1087d887897
redirect-url: https://gxdev03.chint.com/businesstravelhome/#/ redirect-url: https://gxdev03.chint.com/businesstravelhome/#/
client-mobile-id: 9b24c91ead42ee4b6918
client-mobile-secret: e54494f1272ffd41b818980f1f8524fd68ef
redirect-mobile-url: https://gxdev03.chint.com/businesstravelmhome/#/
base-url: https://signin-test.chint.com base-url: https://signin-test.chint.com
token-name: token token-name: token

View File

@ -27,5 +27,8 @@ paila:
client-id: 0053df85723db94491e8 client-id: 0053df85723db94491e8
client-secret: 7368bcec4c0f004c40585f6ed1087d887897 client-secret: 7368bcec4c0f004c40585f6ed1087d887897
redirect-url: https://gxdev03.chint.com/businesstravelhome/#/ redirect-url: https://gxdev03.chint.com/businesstravelhome/#/
client-mobile-id: 9b24c91ead42ee4b6918
client-mobile-secret: e54494f1272ffd41b818980f1f8524fd68ef
redirect-mobile-url: https://gxdev03.chint.com/businesstravelmhome/#/
base-url: https://signin-test.chint.com base-url: https://signin-test.chint.com
token-name: token token-name: token

View File

@ -46,6 +46,9 @@ paila:
client-id: 0053df85723db94491e8 client-id: 0053df85723db94491e8
client-secret: 7368bcec4c0f004c40585f6ed1087d887897 client-secret: 7368bcec4c0f004c40585f6ed1087d887897
redirect-url: https://gxdev03.chint.com/businesstravelhome/#/ redirect-url: https://gxdev03.chint.com/businesstravelhome/#/
client-mobile-id: 9b24c91ead42ee4b6918
client-mobile-secret: e54494f1272ffd41b818980f1f8524fd68ef
redirect-mobile-url: https://gxdev03.chint.com/businesstravelmhome/#/
base-url: https://signin-test.chint.com base-url: https://signin-test.chint.com
token-name: token token-name: token

View File

@ -6,6 +6,7 @@ import com.chint.domain.service.supplier.SupplierService;
import com.chint.domain.value_object.SupplierCallbackData; import com.chint.domain.value_object.SupplierCallbackData;
import com.chint.infrastructure.util.BaseContext; import com.chint.infrastructure.util.BaseContext;
import com.chint.interfaces.rest.ctrip.*; import com.chint.interfaces.rest.ctrip.*;
import com.chint.interfaces.rest.ctrip.dto.city.FlightCitySearchResponse;
import com.chint.interfaces.rest.ctrip.dto.estimate.request.BookingRelatedApiRequest; 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.FlightProductInfo;
import com.chint.interfaces.rest.ctrip.dto.estimate.request.RouteInfo; import com.chint.interfaces.rest.ctrip.dto.estimate.request.RouteInfo;
@ -54,6 +55,9 @@ public class CTripTest {
@Autowired @Autowired
private CTripNoteController cTripNoteController; private CTripNoteController cTripNoteController;
@Autowired
private CTripFlightCitySearchRequest cTripFlightCitySearchRequest;
private User user = new User(1L, "230615020", 1, "卢麟哲", "1033719135@qq.com", "15857193365"); private User user = new User(1L, "230615020", 1, "卢麟哲", "1033719135@qq.com", "15857193365");
//@Test //@Test
@ -168,4 +172,10 @@ public class CTripTest {
BaseContext.setCurrentUser(user); BaseContext.setCurrentUser(user);
cTripNoteController.handlerData("30607415392","Paid","HotelContract"); cTripNoteController.handlerData("30607415392","Paid","HotelContract");
} }
@Test
void queryFlightCity(){
FlightCitySearchResponse flightCity = cTripFlightCitySearchRequest.getFlightCity("杭州", 2);
System.out.println(flightCity);
}
} }

View File

@ -17,6 +17,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.List; import java.util.List;
@Slf4j @Slf4j
@ -124,4 +125,10 @@ class RouteApplicationTests {
String login = pailaLoginStrategy.login("OC-5909-zRqrWjZGNThNXJiAV1kA7dPXTojGzVxK3nE"); String login = pailaLoginStrategy.login("OC-5909-zRqrWjZGNThNXJiAV1kA7dPXTojGzVxK3nE");
System.out.println(login); System.out.println(login);
} }
// @Test
void arrayToStr(){
List<Long> ids = List.of(1L,2L,3L,4L);
System.out.println(Arrays.toString(ids.toArray()));
}
} }