Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
4b6aa38719
|
@ -1,7 +1,10 @@
|
|||
package com.chint.application.out;
|
||||
|
||||
|
||||
import com.chint.application.services.SupplierLoginService;
|
||||
import com.chint.infrastructure.util.Result;
|
||||
import com.chint.interfaces.rest.ly.dto.login.LYRedirectUrlResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
@ -12,10 +15,14 @@ import static com.chint.infrastructure.constant.Constant.SUCCESS;
|
|||
@RequestMapping("/supplier")
|
||||
public class SupplierLoginController {
|
||||
|
||||
@Autowired
|
||||
private SupplierLoginService supplierLoginService;
|
||||
|
||||
@PostMapping("/ly/login")
|
||||
public Result<String> lyLogin() {
|
||||
return Result.Success(SUCCESS);
|
||||
public Result<LYRedirectUrlResponse> lyLogin() {
|
||||
//登录
|
||||
LYRedirectUrlResponse data = supplierLoginService.lyLogin();
|
||||
return Result.Success(SUCCESS,data);
|
||||
}
|
||||
|
||||
@PostMapping("/CTrip/login")
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package com.chint.application.services;
|
||||
|
||||
import com.chint.interfaces.rest.ly.LYLoginRequest;
|
||||
import com.chint.interfaces.rest.ly.dto.login.LYRedirectUrlResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import static com.chint.infrastructure.constant.Constant.L_Y_ENTRANCE_HOME;
|
||||
|
||||
@Service
|
||||
public class SupplierLoginService {
|
||||
|
||||
@Autowired
|
||||
private LYLoginRequest lyLoginRequest;
|
||||
|
||||
/**
|
||||
* 登录接口
|
||||
*/
|
||||
public LYRedirectUrlResponse lyLogin() {
|
||||
return lyLoginRequest.login(L_Y_ENTRANCE_HOME);
|
||||
}
|
||||
}
|
|
@ -2,19 +2,124 @@ package com.chint.domain.service.amount_estimate;
|
|||
|
||||
import com.chint.domain.aggregates.order.Leg;
|
||||
import com.chint.domain.aggregates.order.RouteOrder;
|
||||
import com.chint.infrastructure.constant.Constant;
|
||||
import com.chint.infrastructure.util.BigDecimalCalculator;
|
||||
import com.chint.interfaces.rest.ly.LYPostRequest;
|
||||
import com.chint.interfaces.rest.ly.dto.commonresult.Result;
|
||||
import com.chint.interfaces.rest.ly.dto.estimateprice.Description;
|
||||
import com.chint.interfaces.rest.ly.dto.estimateprice.HotleMinPrice;
|
||||
import com.chint.interfaces.rest.ly.dto.estimateprice.TicketNewPrice;
|
||||
import com.chint.interfaces.rest.ly.dto.estimateprice.TrainMaxPrice;
|
||||
import com.chint.interfaces.rest.ly.vo.estimateprice.TrainPriceVo;
|
||||
import com.google.gson.Gson;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.chint.infrastructure.constant.Constant.*;
|
||||
import static com.chint.infrastructure.constant.Constant.ORDER_STATUS_NOT_ORDERED_NAME;
|
||||
|
||||
@Component
|
||||
public class LYEstimate implements AmountEstimate {
|
||||
|
||||
@Autowired
|
||||
private LYPostRequest postRequest;
|
||||
|
||||
@Override
|
||||
public String amountEstimate(Leg leg) {
|
||||
return null;
|
||||
return switch (leg.getLegType()) {
|
||||
//火车
|
||||
case LEG_TYPE_TRAIN -> trainMaxPrice(leg);
|
||||
//飞机
|
||||
case LEG_TYPE_AIRPLANE -> ticketNewPrice(leg);
|
||||
//酒店
|
||||
case LEG_TYPE_HOTEL -> hotelMinPrice(leg);
|
||||
//出租车
|
||||
case LEG_TYPE_TAXI -> taxi(leg);
|
||||
//其他
|
||||
default -> KEEP_TWO_DECIMAL_ZERO;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取总估算金额
|
||||
*/
|
||||
@Override
|
||||
public String amountEstimate(RouteOrder routeOrder) {
|
||||
return null;
|
||||
return routeOrder.getLegItems()
|
||||
.stream()
|
||||
.map(Leg::getEstimateAmount)
|
||||
.reduce(BigDecimalCalculator::add)
|
||||
.orElse(KEEP_TWO_DECIMAL_ZERO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 火车票最高价格
|
||||
*/
|
||||
public String trainMaxPrice(Leg leg) {
|
||||
String maxPriceUrl = Constant.L_Y_BASE_URL + Constant.L_Y_TRAIN_MAX_PRICE;//地址
|
||||
TrainMaxPrice trainMaxPrice = new TrainMaxPrice();
|
||||
trainMaxPrice.setTicketType(0);
|
||||
trainMaxPrice.setDepartDate(leg.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));//开始时间
|
||||
trainMaxPrice.setDepartCityName(leg.getOriginLocationId().getLocationName());//出发城市
|
||||
trainMaxPrice.setArriveCityName(leg.getDestinationLocation().getLocationName());//到达城市
|
||||
Description<TrainMaxPrice> description = new Description<>();
|
||||
description.setParam(trainMaxPrice);
|
||||
Result post = postRequest.post(maxPriceUrl, description, Result.class);
|
||||
Gson gson = new Gson();
|
||||
//获取对应返回数据
|
||||
TrainPriceVo trainPriceVo = gson.fromJson(String.valueOf(post.getData()), TrainPriceVo.class);
|
||||
Map<String, BigDecimal> map = trainPriceVo.getDailySeatHigestPrices();
|
||||
//取最大金额
|
||||
BigDecimal maxPrice = map.values().stream()
|
||||
.max(BigDecimal::compareTo)
|
||||
.orElse(BigDecimal.ZERO);
|
||||
return maxPrice.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 飞机票价格
|
||||
*/
|
||||
public String ticketNewPrice(Leg leg) {
|
||||
//地址
|
||||
String flyPriceUrl = Constant.L_Y_BASE_URL + Constant.L_Y_FLY_PRICE;
|
||||
TicketNewPrice ticketNewPrice = new TicketNewPrice();
|
||||
ticketNewPrice.setOrderSerialNo("");
|
||||
Description<TicketNewPrice> description = new Description<TicketNewPrice>();
|
||||
description.setParam(ticketNewPrice);
|
||||
Result post = postRequest.post(flyPriceUrl, description, Result.class);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询酒店价格
|
||||
*/
|
||||
public String hotelMinPrice(Leg leg) {
|
||||
//1.查询附近酒店
|
||||
ArrayList<String> hotelCodes = new ArrayList<>();
|
||||
hotelCodes.add("114");//添加酒店,一次最多50个
|
||||
//2.查询酒店价格
|
||||
String minPriceUrl = Constant.L_Y_BASE_URL + Constant.L_Y_HOTEL_MIN_PRICE;
|
||||
HotleMinPrice hotleMinPrice = new HotleMinPrice();
|
||||
hotleMinPrice.setBeginDate(leg.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));//开始时间
|
||||
hotleMinPrice.setEndDate(leg.getEndTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));//结束时间
|
||||
hotleMinPrice.setHotelIdList(hotelCodes);//添加酒店
|
||||
Description<HotleMinPrice> description = new Description<>();
|
||||
description.setParam(hotleMinPrice);
|
||||
Result post = postRequest.post(minPriceUrl, description, Result.class);
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 出租车默认为"0.00"
|
||||
*/
|
||||
public String taxi(Leg leg) {
|
||||
return KEEP_TWO_DECIMAL_ZERO;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -172,10 +172,12 @@ public class Constant {
|
|||
public static final Integer L_Y_TRAVEL_TYPE_PERSON = 1; // (因公)
|
||||
public static final Integer L_Y_TRAVEL_TYPE_NO_PERSON = 2; // (因私)
|
||||
|
||||
public static final String L_Y_TRAIN_MAX_PRICE = "/openapi/api/Train/TrainHighPirceSearchByCityName";//火车票价格查询
|
||||
|
||||
public static final String L_Y_FLY_PRICE = "/openapi/api/DomesticFlight/CheckFlightOrderBookableStatus";//飞机表估算价格
|
||||
|
||||
|
||||
|
||||
public static final String L_Y_HOTEL_List = "/openapi/api/Hotel/GetHotelCityList"; //酒店城市列表
|
||||
public static final String L_Y_HOTEL_MIN_PRICE = "/openapi/api/Hotel/GetHotelMinPrice";//酒店估算价格
|
||||
|
||||
// status
|
||||
public static final int STATUS_DISABLED = 0;
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
package com.chint.interfaces.rest.ly.dto.estimateprice;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class HotelCityList {
|
||||
private String keyword;//城市名
|
||||
private Integer type;//1.国内, 2.国际, 3.都返回
|
||||
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.chint.interfaces.rest.ly.vo.estimateprice;
|
||||
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class TrainPriceVo {
|
||||
|
||||
private Map<String, BigDecimal> dailySeatHigestPrices;
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
package com.chint;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.infrastructure.constant.Constant;
|
||||
import com.chint.infrastructure.util.BaseContext;
|
||||
import com.chint.interfaces.rest.ly.LYLoginRequest;
|
||||
import com.chint.interfaces.rest.ly.LYPostRequest;
|
||||
|
@ -8,17 +10,25 @@ import com.chint.interfaces.rest.ly.LYTokenRequest;
|
|||
import com.chint.interfaces.rest.ly.LYUserRequest;
|
||||
import com.chint.interfaces.rest.ly.dto.applyordersync.*;
|
||||
import com.chint.interfaces.rest.ly.dto.commonresult.Result;
|
||||
import com.chint.interfaces.rest.ly.dto.estimateprice.Description;
|
||||
import com.chint.interfaces.rest.ly.dto.estimateprice.HotleMinPrice;
|
||||
import com.chint.interfaces.rest.ly.dto.estimateprice.TicketNewPrice;
|
||||
import com.chint.interfaces.rest.ly.dto.estimateprice.TrainMaxPrice;
|
||||
import com.chint.interfaces.rest.ly.dto.estimateprice.*;
|
||||
import com.chint.interfaces.rest.ly.vo.estimateprice.TrainPriceVo;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.internal.LinkedTreeMap;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.chint.infrastructure.constant.Constant.L_Y_ENTRANCE_HOME;
|
||||
import static com.chint.infrastructure.constant.Constant.*;
|
||||
|
||||
@SpringBootTest
|
||||
public class LYTest {
|
||||
|
@ -49,7 +59,7 @@ public class LYTest {
|
|||
public static final String L_Y_HOTLE_MIN_PRICE_PATH = "/api/Hotel/GetHotelMinPrice";
|
||||
public static final String L_Y_HOTLE_LIST_PATH = "/api/Hotel/GetHotelCityList";
|
||||
private final String travelApplyOrderUrl = L_Y_BASE_URL + L_Y_ORDER_PATH;
|
||||
// private final String maxPriceUrl = L_Y_BASE_URL + L_Y_MAX_PRICE_PATH;
|
||||
// private final String maxPriceUrl = L_Y_BASE_URL + L_Y_MAX_PRICE_PATH;
|
||||
private final String maxPriceUrl = "https://api.qa.dttrip.cn/openapi/api/Train/TrainHighPirceSearchByCityName";
|
||||
private final String flyPriceUrl = L_Y_BASE_URL + L_Y_FLYORDER_PRICE_PATH;
|
||||
private final String minPriceUrl = L_Y_BASE_URL + L_Y_HOTLE_MIN_PRICE_PATH;
|
||||
|
@ -62,6 +72,7 @@ public class LYTest {
|
|||
//机票订单最新价格校验
|
||||
@Test
|
||||
void ticketNewPrice() {
|
||||
String flyPriceUrl = Constant.L_Y_BASE_URL + Constant.L_Y_FLY_PRICE;
|
||||
TicketNewPrice ticketNewPrice = new TicketNewPrice();
|
||||
ticketNewPrice.setOrderSerialNo("");
|
||||
Description<TicketNewPrice> description = new Description<TicketNewPrice>();
|
||||
|
@ -69,37 +80,58 @@ public class LYTest {
|
|||
Result post = postRequest.post(flyPriceUrl, description, Result.class);
|
||||
System.out.println(post);
|
||||
}
|
||||
|
||||
///查询酒店最小价格
|
||||
@Test
|
||||
void hotleMinPrice() {
|
||||
String HotelListUrl = Constant.L_Y_BASE_URL + Constant.L_Y_HOTEL_List;
|
||||
HotelCityList hotelCityList = new HotelCityList();
|
||||
hotelCityList.setKeyword("广州");
|
||||
hotelCityList.setType(1);
|
||||
Description<HotelCityList> HotelRequest = new Description<>();
|
||||
HotelRequest.setParam(hotelCityList);
|
||||
Result result = postRequest.post(HotelListUrl, HotelRequest, Result.class);
|
||||
System.out.println("result = " + result);
|
||||
|
||||
String minPriceUrl = Constant.L_Y_BASE_URL + Constant.L_Y_HOTEL_MIN_PRICE;
|
||||
HotleMinPrice hotleMinPrice = new HotleMinPrice();
|
||||
hotleMinPrice.setBeginDate("2024-02-04");
|
||||
hotleMinPrice.setEndDate("2024-02-05");
|
||||
ArrayList<String> strings = new ArrayList<>();
|
||||
strings.add("114");
|
||||
hotleMinPrice.setHotelIdList(strings);
|
||||
Description<HotleMinPrice> description = new Description<HotleMinPrice>();
|
||||
Description<HotleMinPrice> description = new Description<>();
|
||||
description.setParam(hotleMinPrice);
|
||||
Result post = postRequest.post(minPriceUrl, description, Result.class);
|
||||
System.out.println(post);
|
||||
}
|
||||
|
||||
//火车票最高价查询
|
||||
@Test
|
||||
void maxPrice() {
|
||||
String maxPriceUrl = Constant.L_Y_BASE_URL + Constant.L_Y_TRAIN_MAX_PRICE;
|
||||
TrainMaxPrice trainMaxPrice = new TrainMaxPrice();
|
||||
trainMaxPrice.setTicketType(0);
|
||||
LocalDateTime dateTime = LocalDateTime.of(2024, 2, 6, 0, 0);
|
||||
dateTime.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
||||
trainMaxPrice.setDepartDate("2024-02-06");
|
||||
trainMaxPrice.setDepartCityName("温州");
|
||||
trainMaxPrice.setArriveCityName("贵阳");
|
||||
|
||||
Description<TrainMaxPrice> description = new Description<TrainMaxPrice>();
|
||||
description.setParam(trainMaxPrice);
|
||||
Result post = postRequest.post(maxPriceUrl, description, Result.class);
|
||||
System.out.println(post);
|
||||
Gson gson = new Gson();
|
||||
TrainPriceVo trainPriceVo = gson.fromJson(String.valueOf(post.getData()), TrainPriceVo.class);
|
||||
Map<String, BigDecimal> map = trainPriceVo.getDailySeatHigestPrices();
|
||||
BigDecimal max = map.values().stream()
|
||||
.max(BigDecimal::compareTo)
|
||||
.orElse(BigDecimal.ZERO);
|
||||
System.out.println(max);
|
||||
}
|
||||
|
||||
@Test //外部差旅单同步
|
||||
void ApplyOrderSync(){
|
||||
@Test
|
||||
//外部差旅单同步
|
||||
void ApplyOrderSync() {
|
||||
AOSParam aosParam = new AOSParam();
|
||||
aosParam.setOutTravelApplyNo("No000001");
|
||||
aosParam.setTravelApplyType(1); // 差旅类型,根据实际情况填写
|
||||
|
@ -125,7 +157,7 @@ public class LYTest {
|
|||
AOSItem aosItem = new AOSItem();
|
||||
aosItem.setStartDate("2021-04-20");
|
||||
aosItem.setEndDate("2021-04-25");
|
||||
aosItem.setDepartCity( "北京");
|
||||
aosItem.setDepartCity("北京");
|
||||
aosItem.setArriveCity("上海");
|
||||
aosItems.add(aosItem);
|
||||
aosDetail.setItemList(aosItems); // 差旅内容
|
||||
|
@ -176,14 +208,15 @@ public class LYTest {
|
|||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void loadToken(){
|
||||
void loadToken() {
|
||||
System.out.println(lyTokenRequest.loadToken());
|
||||
}
|
||||
|
||||
@Test
|
||||
void saveCurrentUser2Ly(){
|
||||
// BaseContext.setCurrentUser(user);
|
||||
void saveCurrentUser2Ly() {
|
||||
// BaseContext.setCurrentUser(user);
|
||||
BaseContext.setCurrentUser(hxh);
|
||||
System.out.println(lyUserRequest.saveCurrentUser());
|
||||
}
|
||||
|
@ -195,5 +228,4 @@ public class LYTest {
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue