SupplierLoginController登录接口的更改,同程金额修改。
This commit is contained in:
parent
d1b96acf09
commit
9a278f0979
|
@ -2,19 +2,97 @@ 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.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.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) {
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 酒店
|
||||
*/
|
||||
public String hotelMinPrice(Leg leg) {
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 出租车
|
||||
*/
|
||||
public String taxi(Leg leg) {
|
||||
return KEEP_TWO_DECIMAL_ZERO;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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_NO_PERSON = 2; // (因私)
|
||||
|
||||
|
||||
|
||||
|
||||
public static final String L_Y_TRAIN_MAX_PRICE = "/openapi/api/Train/TrainHighPirceSearchByCityName";//火车票价格查询
|
||||
|
||||
|
||||
// status
|
||||
|
|
|
@ -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;
|
||||
|
@ -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.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 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 {
|
||||
|
@ -69,6 +82,7 @@ public class LYTest {
|
|||
Result post = postRequest.post(flyPriceUrl, description, Result.class);
|
||||
System.out.println(post);
|
||||
}
|
||||
|
||||
///查询酒店最小价格
|
||||
@Test
|
||||
void hotleMinPrice() {
|
||||
|
@ -83,22 +97,32 @@ public class LYTest {
|
|||
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 //外部差旅单同步
|
||||
@Test
|
||||
//外部差旅单同步
|
||||
void ApplyOrderSync() {
|
||||
AOSParam aosParam = new AOSParam();
|
||||
aosParam.setOutTravelApplyNo("No000001");
|
||||
|
@ -176,6 +200,7 @@ public class LYTest {
|
|||
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void loadToken() {
|
||||
System.out.println(lyTokenRequest.loadToken());
|
||||
|
@ -195,5 +220,4 @@ public class LYTest {
|
|||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue