SupplierLoginController登录接口的更改,同程金额修改。

This commit is contained in:
dengwc 2024-02-05 15:26:12 +08:00
parent d1b96acf09
commit 9a278f0979
4 changed files with 129 additions and 16 deletions

View File

@ -2,19 +2,97 @@ package com.chint.domain.service.amount_estimate;
import com.chint.domain.aggregates.order.Leg; import com.chint.domain.aggregates.order.Leg;
import com.chint.domain.aggregates.order.RouteOrder; 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.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 org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.time.format.DateTimeFormatter;
import java.util.Map;
import static com.chint.infrastructure.constant.Constant.*;
import static com.chint.infrastructure.constant.Constant.ORDER_STATUS_NOT_ORDERED_NAME;
@Component @Component
public class LYEstimate implements AmountEstimate { public class LYEstimate implements AmountEstimate {
@Autowired
private LYPostRequest postRequest;
@Override @Override
public String amountEstimate(Leg leg) { 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 @Override
public String amountEstimate(RouteOrder routeOrder) { 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) {
return "";
}
/**
* 酒店
*/
public String hotelMinPrice(Leg leg) {
return "";
}
/**
* 出租车
*/
public String taxi(Leg leg) {
return KEEP_TWO_DECIMAL_ZERO;
}
} }

View File

@ -172,9 +172,7 @@ public class Constant {
public static final Integer L_Y_TRAVEL_TYPE_PERSON = 1; // (因公) public static final Integer L_Y_TRAVEL_TYPE_PERSON = 1; // (因公)
public static final Integer L_Y_TRAVEL_TYPE_NO_PERSON = 2; // (因私) public static final Integer L_Y_TRAVEL_TYPE_NO_PERSON = 2; // (因私)
public static final String L_Y_TRAIN_MAX_PRICE = "/openapi/api/Train/TrainHighPirceSearchByCityName";//火车票价格查询
// status // status

View File

@ -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;
}

View File

@ -1,6 +1,8 @@
package com.chint; package com.chint;
import com.alibaba.fastjson2.JSON;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import com.chint.infrastructure.constant.Constant;
import com.chint.infrastructure.util.BaseContext; import com.chint.infrastructure.util.BaseContext;
import com.chint.interfaces.rest.ly.LYLoginRequest; import com.chint.interfaces.rest.ly.LYLoginRequest;
import com.chint.interfaces.rest.ly.LYPostRequest; import com.chint.interfaces.rest.ly.LYPostRequest;
@ -12,13 +14,24 @@ 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.HotleMinPrice;
import com.chint.interfaces.rest.ly.dto.estimateprice.TicketNewPrice; 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.TrainMaxPrice;
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.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; 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.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 @SpringBootTest
public class LYTest { public class LYTest {
@ -49,7 +62,7 @@ public class LYTest {
public static final String L_Y_HOTLE_MIN_PRICE_PATH = "/api/Hotel/GetHotelMinPrice"; 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"; 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 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 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 flyPriceUrl = L_Y_BASE_URL + L_Y_FLYORDER_PRICE_PATH;
private final String minPriceUrl = L_Y_BASE_URL + L_Y_HOTLE_MIN_PRICE_PATH; private final String minPriceUrl = L_Y_BASE_URL + L_Y_HOTLE_MIN_PRICE_PATH;
@ -69,6 +82,7 @@ public class LYTest {
Result post = postRequest.post(flyPriceUrl, description, Result.class); Result post = postRequest.post(flyPriceUrl, description, Result.class);
System.out.println(post); System.out.println(post);
} }
///查询酒店最小价格 ///查询酒店最小价格
@Test @Test
void hotleMinPrice() { void hotleMinPrice() {
@ -83,23 +97,33 @@ public class LYTest {
Result post = postRequest.post(minPriceUrl, description, Result.class); Result post = postRequest.post(minPriceUrl, description, Result.class);
System.out.println(post); System.out.println(post);
} }
//火车票最高价查询 //火车票最高价查询
@Test @Test
void maxPrice() { void maxPrice() {
String maxPriceUrl = Constant.L_Y_BASE_URL + Constant.L_Y_TRAIN_MAX_PRICE;
TrainMaxPrice trainMaxPrice = new TrainMaxPrice(); TrainMaxPrice trainMaxPrice = new TrainMaxPrice();
trainMaxPrice.setTicketType(0); 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.setDepartDate("2024-02-06");
trainMaxPrice.setDepartCityName("温州"); trainMaxPrice.setDepartCityName("温州");
trainMaxPrice.setArriveCityName("贵阳"); trainMaxPrice.setArriveCityName("贵阳");
Description<TrainMaxPrice> description = new Description<TrainMaxPrice>(); Description<TrainMaxPrice> description = new Description<TrainMaxPrice>();
description.setParam(trainMaxPrice); description.setParam(trainMaxPrice);
Result post = postRequest.post(maxPriceUrl, description, Result.class); 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 //外部差旅单同步 @Test
void ApplyOrderSync(){ //外部差旅单同步
void ApplyOrderSync() {
AOSParam aosParam = new AOSParam(); AOSParam aosParam = new AOSParam();
aosParam.setOutTravelApplyNo("No000001"); aosParam.setOutTravelApplyNo("No000001");
aosParam.setTravelApplyType(1); // 差旅类型根据实际情况填写 aosParam.setTravelApplyType(1); // 差旅类型根据实际情况填写
@ -125,7 +149,7 @@ public class LYTest {
AOSItem aosItem = new AOSItem(); AOSItem aosItem = new AOSItem();
aosItem.setStartDate("2021-04-20"); aosItem.setStartDate("2021-04-20");
aosItem.setEndDate("2021-04-25"); aosItem.setEndDate("2021-04-25");
aosItem.setDepartCity( "北京"); aosItem.setDepartCity("北京");
aosItem.setArriveCity("上海"); aosItem.setArriveCity("上海");
aosItems.add(aosItem); aosItems.add(aosItem);
aosDetail.setItemList(aosItems); // 差旅内容 aosDetail.setItemList(aosItems); // 差旅内容
@ -176,14 +200,15 @@ public class LYTest {
} }
@Test @Test
void loadToken(){ void loadToken() {
System.out.println(lyTokenRequest.loadToken()); System.out.println(lyTokenRequest.loadToken());
} }
@Test @Test
void saveCurrentUser2Ly(){ void saveCurrentUser2Ly() {
// BaseContext.setCurrentUser(user); // BaseContext.setCurrentUser(user);
BaseContext.setCurrentUser(hxh); BaseContext.setCurrentUser(hxh);
System.out.println(lyUserRequest.saveCurrentUser()); System.out.println(lyUserRequest.saveCurrentUser());
} }
@ -195,5 +220,4 @@ public class LYTest {
} }
} }