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

This commit is contained in:
wanglf3 2024-03-14 17:40:30 +08:00
commit 6d3249cad5
13 changed files with 152 additions and 15 deletions

View File

@ -0,0 +1,17 @@
package com.chint.application.commands;
import com.chint.infrastructure.echo_framework.command.Command;
import lombok.Data;
@Data
public class CTripOrderRefundCommand extends Command {
private String orderNo;
private String amount;
public CTripOrderRefundCommand Info(String orderNo, String amount) {
this.orderNo = orderNo;
this.amount = amount;
return this;
}
}

View File

@ -20,7 +20,6 @@ public class CtripCarOrderDetail implements Serializable {
@Serial
private static final long serialVersionUID = 4583214623558870145L;
@Id
private Long id;
private Long recordId;

View File

@ -25,7 +25,6 @@ public class CtripFlightOrderDetail implements Serializable {
private static final long serialVersionUID = -2563945926793686074L;
@Id
private Long id;
private Long recordId;
private Long orderId;
private Integer sequence;

View File

@ -80,7 +80,6 @@ public class CtripTrainOrderDetail implements Serializable {
CtripTrainOrderDetail ctripTrainOrderDetail = new CtripTrainOrderDetail();
if (trainSettlementDetail != null){
ctripTrainOrderDetail.setRecordId(trainSettlementDetail.getRecordID());
ctripTrainOrderDetail.setOrderId(trainSettlementDetail.getOrderID());
ctripTrainOrderDetail.setCorpId(trainSettlementDetail.getCorpId());

View File

@ -18,16 +18,23 @@ public interface CTripOrderDetailRepository {
void saveAllFlightRecord(List<CtripFlightOrderDetail> cTripFlightOrderDetailList);
CtripFlightOrderDetail findFlightByRecordId(Long id);
CtripHotelOrderDetail save(CtripHotelOrderDetail cTripHotelOrderDetailList);
void saveAllHotelRecord(List<CtripHotelOrderDetail> ctripHotelOrderDetailList);
CtripHotelOrderDetail findHotelByRecordId(Long id);
CtripTrainOrderDetail save(CtripTrainOrderDetail ctripTrainOrderDetail);
void saveAllTrainRecord(List<CtripTrainOrderDetail> ctripTrainOrderDetailList);
CtripTrainOrderDetail findTrainByRecordId(Long id);
CtripCarOrderDetail save(CtripCarOrderDetail ctripCarOrderDetail);
void saveAllCarRecord(List<CtripCarOrderDetail> ctripCarOrderDetailList);
CtripCarOrderDetail findCarByRecordId(Long id);
}

View File

@ -48,6 +48,11 @@ public class CTripOrderDetailImpl implements CTripOrderDetailRepository {
jdbcCtripFlightOrderDetailRepository.saveAll(cTripFlightOrderDetailList);
}
@Override
public CtripFlightOrderDetail findFlightByRecordId(Long recordId) {
return jdbcCtripFlightOrderDetailRepository.findByRecordId(recordId);
}
@Override
public CtripHotelOrderDetail save(CtripHotelOrderDetail ctripHotelOrderDetail) {
@ -59,6 +64,11 @@ public class CTripOrderDetailImpl implements CTripOrderDetailRepository {
jdbcCtripHotelOrderDetailRepository.saveAll(ctripHotelOrderDetailList);
}
@Override
public CtripHotelOrderDetail findHotelByRecordId(Long recordId) {
return jdbcCtripHotelOrderDetailRepository.findByRecordId(recordId);
}
@Override
public CtripTrainOrderDetail save(CtripTrainOrderDetail ctripTrainOrderDetail) {
@ -70,6 +80,11 @@ public class CTripOrderDetailImpl implements CTripOrderDetailRepository {
jdbcCtripTrainOrderDetailRepository.saveAll(ctripTrainOrderDetailList);
}
@Override
public CtripTrainOrderDetail findTrainByRecordId(Long recordId) {
return jdbcCtripTrainOrderDetailRepository.findByRecordId(recordId);
}
@Override
public CtripCarOrderDetail save(CtripCarOrderDetail ctripCarOrderDetail) {
@ -80,6 +95,11 @@ public class CTripOrderDetailImpl implements CTripOrderDetailRepository {
public void saveAllCarRecord(List<CtripCarOrderDetail> ctripCarOrderDetailList) {
jdbcCtripCarOrderDetailRepository.saveAll(ctripCarOrderDetailList);
}
@Override
public CtripCarOrderDetail findCarByRecordId(Long recordId) {
return jdbcCtripCarOrderDetailRepository.findByRecordId(recordId);
}
//
// @Override
// public Client findByClientId(String clientId){

View File

@ -1,12 +1,12 @@
package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.order.ctrip.CtripCarOrderDetail;
import com.chint.domain.aggregates.order.ctrip.CtripHotelOrderDetail;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface JdbcCtripCarOrderDetailRepository extends CrudRepository<CtripCarOrderDetail,Long> {
public interface JdbcCtripCarOrderDetailRepository extends CrudRepository<CtripCarOrderDetail, Long> {
// CityEntity findByCityName(String cityName);
CtripCarOrderDetail findByRecordId(Long recordId);
}

View File

@ -9,4 +9,5 @@ import org.springframework.stereotype.Repository;
public interface JdbcCtripFlightOrderDetailRepository extends CrudRepository<CtripFlightOrderDetail,Long> {
// CityEntity findByCityName(String cityName);
CtripFlightOrderDetail findByRecordId(Long recordId);
}

View File

@ -9,4 +9,6 @@ import org.springframework.stereotype.Repository;
public interface JdbcCtripHotelOrderDetailRepository extends CrudRepository<CtripHotelOrderDetail,Long> {
// CityEntity findByCityName(String cityName);
CtripHotelOrderDetail findByRecordId(Long recordId);
}

View File

@ -1,13 +1,12 @@
package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.order.ctrip.CtripCarOrderDetail;
import com.chint.domain.aggregates.order.ctrip.CtripHotelOrderDetail;
import com.chint.domain.aggregates.order.ctrip.CtripTrainOrderDetail;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface JdbcCtripTrainOrderDetailRepository extends CrudRepository<CtripTrainOrderDetail,Long> {
public interface JdbcCtripTrainOrderDetailRepository extends CrudRepository<CtripTrainOrderDetail, Long> {
// CityEntity findByCityName(String cityName);
CtripTrainOrderDetail findByRecordId(Long recordId);
}

View File

@ -1,17 +1,18 @@
package com.chint.interfaces.rest.ctrip.order;
import com.chint.application.commands.CTripOrderRefundCommand;
import com.chint.domain.aggregates.order.ctrip.CtripCarOrderDetail;
import com.chint.domain.aggregates.order.ctrip.CtripFlightOrderDetail;
import com.chint.domain.aggregates.order.ctrip.CtripHotelOrderDetail;
import com.chint.domain.aggregates.order.ctrip.CtripTrainOrderDetail;
import com.chint.domain.repository.CTripOrderDetailRepository;
import com.chint.infrastructure.echo_framework.command.Command;
import com.chint.interfaces.rest.ctrip.dto.order.OrderCarResponse;
import com.chint.interfaces.rest.ctrip.dto.order.OrderFlightResponse;
import com.chint.interfaces.rest.ctrip.dto.order.OrderHotelResponse;
import com.chint.interfaces.rest.ctrip.dto.order.OrderTrainResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.List;
@ -27,7 +28,7 @@ public class CTripOrderRecordAutoSave {
private CTripOrderDetailRepository cTripOrderDetailRepository;
public void saveAll(){
public void saveAll() {
this.cTripFlightRecordAutoSave();
this.cTripHotelRecordAutoSave();
this.cTripTrainRecordAutoSave();
@ -45,6 +46,20 @@ public class CTripOrderRecordAutoSave {
.map(OrderFlightResponse.FlightOrderSettlementInfo::getOrderSettlementBaseInfo)
.map(CtripFlightOrderDetail::changeInfo)
.toList();
//业务需求这里加入是否退款判断
flightRecords.forEach(record -> {
//根据id进行更新
CtripFlightOrderDetail flightByRecordId = cTripOrderDetailRepository.findFlightByRecordId(record.getRecordId());
if (flightByRecordId != null) {
record.setId(flightByRecordId.getId());
}
if (record.getAmount() < 0) {
checkIfRefund(String.valueOf(record.getOrderId()), String.valueOf(record.getAmount()));
}
});
cTripOrderDetailRepository.saveAllFlightRecord(flightRecords);
}
}
@ -59,6 +74,20 @@ public class CTripOrderRecordAutoSave {
.map(OrderHotelResponse.LstHotelSettlementDetail::getSettlementDetail)
.map(CtripHotelOrderDetail::changeInfo)
.toList();
//业务需求这里加入是否退款判断
list.forEach(record -> {
CtripHotelOrderDetail hotelByRecordId = cTripOrderDetailRepository.findHotelByRecordId(record.getRecordId());
if (hotelByRecordId != null) {
record.setId(hotelByRecordId.getId());
}
if (record.getAmount() < 0) {
checkIfRefund(String.valueOf(record.getOrderId()), String.valueOf(record.getAmount()));
}
});
cTripOrderDetailRepository.saveAllHotelRecord(list);
}
}
@ -73,6 +102,22 @@ public class CTripOrderRecordAutoSave {
.map(OrderTrainResponse.CorpTrainSettlementInfo::getTrainSettlementDetail)
.map(CtripTrainOrderDetail::changeInfo)
.toList();
//业务需求这里加入是否退款判断
list.forEach(record -> {
CtripTrainOrderDetail trainByRecordId = cTripOrderDetailRepository.findTrainByRecordId(record.getRecordId());
if (trainByRecordId != null) {
record.setRecordId(trainByRecordId.getId());
}
if (record.getRealAmount() < 0) {
checkIfRefund(String.valueOf(record.getOrderId()), String.valueOf(record.getRealAmount()));
}
});
cTripOrderDetailRepository.saveAllTrainRecord(list);
}
}
@ -87,7 +132,27 @@ public class CTripOrderRecordAutoSave {
.map(OrderCarResponse.CarOrderSettlementDetail::getSettlementBaseInfo)
.map(CtripCarOrderDetail::changeInfo)
.toList();
//业务需求这里加入是否退款判断
list.forEach(record -> {
CtripCarOrderDetail carByRecordId = cTripOrderDetailRepository.findCarByRecordId(record.getRecordId());
if (carByRecordId != null) {
record.setId(carByRecordId.getId());
}
if (record.getRealAmount() < 0) {
checkIfRefund(String.valueOf(record.getOrderId()), String.valueOf(record.getRealAmount()));
}
});
cTripOrderDetailRepository.saveAllCarRecord(list);
}
}
public void checkIfRefund(String orderNo, String amount) {
System.out.println("开始触发创建携程退款订单");
Command.of(CTripOrderRefundCommand.class).Info(orderNo, amount).sendToQueue();
}
}

View File

@ -5,7 +5,6 @@ import com.chint.dc.api.dto.DataCenterOption;
import com.chint.dc.api.service.DataCenterService;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.exceptions.NotFoundException;
import com.chint.infrastructure.constant.SFConstant;
import com.chint.interfaces.rest.user.dto.AccessKeyDTO;
import com.chint.interfaces.rest.user.dto.UserDataDTO;
import com.google.gson.Gson;
@ -49,7 +48,7 @@ public class UserSFRequest {
}
}
@Cacheable(value = "UserDataFromSF",key = "#user.employeeNo")
@Cacheable(value = "UserDataFromSF", key = "#user.employeeNo")
public List<UserDataDTO> getUserSFDataFromOpenApi(User user) {
Gson gson = new Gson();
AccessKeyDTO akSkLoad = akSkLoad();
@ -72,4 +71,27 @@ public class UserSFRequest {
throw new NotFoundException(NOT_FOUND);
}
}
public List<UserDataDTO> getUserSFDataFromOpenApiBatch() {
Gson gson = new Gson();
AccessKeyDTO akSkLoad = akSkLoad();
DataCenterOption option = new DataCenterOption();
option.setSk(akSkLoad.sk);
option.setAk(akSkLoad.ak);
option.setUrl(OPENAI_BASE_URL);
DataCenterService dataCenterService = new DataCenterService(option);
LinkedHashMap map = new LinkedHashMap<String, Object>();
map.put("start", 1);
map.put("pageSize", 99);
DataCenterResult result = dataCenterService.post(USER_DATA_PATH, map);
Type type = new TypeToken<List<UserDataDTO>>() {
}.getType();
List<UserDataDTO> userDataDTOs = gson.fromJson(result.getData().toString(), type);
for (UserDataDTO userDataDTO : userDataDTOs) {
System.out.println(gson.toJson(userDataDTO));
}
return userDataDTOs;
}
}

View File

@ -4,12 +4,19 @@ server:
chint:
loginSecretKey: ZhengTaiRoute
datasource:
# driver-class-name: com.mysql.cj.jdbc.Driver
# host: 10.10.68.67
# port: 6603
# database: itinerary_booking
# username: tripbookpro
# password: W@Xbf25d&lG5k*L01X#
driver-class-name: com.mysql.cj.jdbc.Driver
host: 10.10.68.67
host: 10.10.24.44
# host: 10.9.56.48
port: 6603
database: itinerary_booking
username: tripbookpro
password: W@Xbf25d&lG5k*L01X#
username: tripbook
password: W@Xgf25d&lRk*L0X#
url: https://trip.chint.com/
redis:
host: 10.10.68.66