提交代码

This commit is contained in:
lulz1 2024-03-29 21:08:18 +08:00
parent 6e62a17d19
commit 86c90598ce
14 changed files with 237 additions and 26 deletions

View File

@ -22,6 +22,7 @@ import java.util.Optional;
import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND;
import static com.chint.infrastructure.constant.LegConstant.*;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_ETA;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_PREPARE_NAME;
@Data
@ -134,7 +135,7 @@ public class OrderDetail implements Serializable {
}
public OrderEvent getLastEvent() {
if(this.orderEventList == null){
if (this.orderEventList == null) {
return null;
}
return this.orderEventList.isEmpty() ? null : this.orderEventList.get(this.orderEventList.size() - 1);
@ -143,6 +144,16 @@ public class OrderDetail implements Serializable {
// .orElseThrow(() -> new NotFoundException(NOT_FOUND));
}
public Optional<OrderEvent> getETAEvent() {
if (this.orderEventList == null) {
return Optional.empty();
}
return this.orderEventList
.stream()
.filter(it -> it.getEventType().equals(ORDER_EVENT_ETA))
.findFirst();
}
public OrderDetail price(String price) {
this.price = price;
return this;

View File

@ -1,5 +1,7 @@
package com.chint.domain.aggregates.order.order_record;
import com.chint.domain.aggregates.order.OrderDetail;
import com.chint.domain.aggregates.order.OrderEvent;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@ -7,6 +9,11 @@ import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;
import java.util.List;
import java.util.Optional;
import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_ETA;
@Data
@Table("order_car_record")
@NoArgsConstructor
@ -62,6 +69,7 @@ public class OrderCarRecord extends OrderBaseRecord {
private String projectOrderNo; // 项目订单号
private String offlineCcomyCode; // 成本中心
private String orderSource; // 预订来源线上/线下
private String payAmount;//支付总金额
//添加行程信息
@ -101,10 +109,12 @@ public class OrderCarRecord extends OrderBaseRecord {
// 加载财务信息
public OrderCarRecord loadFinancialInfo(String accountPeriod,
String billNo,
String orderAmount) {
String orderAmount,
String payAmount) {
this.setAccountPeriod(accountPeriod);
this.setBillNo(billNo);
this.setOrderAmount(orderAmount);
this.setPayAmount(payAmount);
return this;
}
@ -151,10 +161,14 @@ public class OrderCarRecord extends OrderBaseRecord {
}
// 加载超标信息
public OrderCarRecord loadComplianceInfo(String overStandard,
String overStandardReason) {
this.setOverStandard(overStandard);
this.setOverStandardReason(overStandardReason);
public OrderCarRecord loadComplianceInfo(OrderDetail orderDetail) {
orderDetail.getETAEvent().ifPresentOrElse(it->{
this.setOverStandard("");
this.setOverStandardReason(overStandardReason);
},()->{
this.setOverStandard("");
this.setOverStandardReason("");
});
return this;
}

View File

@ -12,7 +12,7 @@ import org.springframework.data.relational.core.mapping.Table;
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
public class OrderHotelRecord extends OrderBaseRecord{
public class OrderHotelRecord extends OrderBaseRecord {
@Id
private Long id;
private Long orderDetailId;
@ -83,14 +83,19 @@ public class OrderHotelRecord extends OrderBaseRecord{
}
// 加载酒店和入住信息
public OrderHotelRecord loadHotelAndStayInfo(String hotelName, String hotelAddress, String checkInDate, String departureDate,
int roomCount, String roomTypeName, String country, String province, String checkInCity) {
public OrderHotelRecord loadHotelInfo(String hotelName, String hotelAddress, String checkInDate, String departureDate,
int roomCount, String roomTypeName) {
this.setHotelName(hotelName);
this.setHotelAddress(hotelAddress);
this.setCheckInDate(checkInDate);
this.setDepartureDate(departureDate);
this.setRoomCount(roomCount);
this.setRoomTypeName(roomTypeName);
return this;
}
// 加载地理信息位置
public OrderHotelRecord loadLocationInfo(String country, String province, String checkInCity) {
this.setCountry(country);
this.setProvince(province);
this.setCheckInCity(checkInCity);
@ -199,5 +204,4 @@ public class OrderHotelRecord extends OrderBaseRecord{
}
}

View File

@ -0,0 +1,107 @@
package com.chint.domain.aggregates.order.order_record.ctrip_order_record;
import cn.hutool.core.bean.BeanUtil;
import com.chint.interfaces.rest.ctrip.dto.order.OrderHotelResponse;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;
@Data
@Table("c_trip_hotel_order_detail")
public class CTripHotelOrderDetail implements Serializable {
@Serial
private static final long serialVersionUID = 1027124557206346513L;
@Id
private Long id;
private Long cTripHotelRecordId;
private Long OrderId;
private String EmployeeName;
private String EmployeeID;
private String WorkCity;
private String OrderDate;
private String RoomName;
private String RoomNameEN;
private Integer RoomQuantity;
private String ClientName;
private String StartTime;
private String EndTime;
private Double PostAmount;
private String IsHasSpecialInvoice;
private String ServerFrom;
private String LowPriceRC;
private String LowPriceRC_VV;
private String LowPriceRCInfo;
private String LowPriceRCInfoEN;
private String AgreementRC;
private String AgreementRC_VV;
private String AgreementRCInfo;
private String AgreementRCInfoEN;
private String CostCenter;
private String CostCenter2;
private String CostCenter3;
private String CostCenter4;
private String CostCenter5;
private String CostCenter6;
private String JourneyReason;
private String Project;
private String DefineTitleContent;
private String DefineTitleContent2;
private String HotelRelatedJourneyNo;
private String Remarks;
private String PayType;
private String BalanceType;
private String IsMixPayment;
private Double SettlementACCNTAmt;
private Double SettlementPersonAmt;
private Double CouponAmount;
private String Dept1;
private String Dept2;
private String Dept3;
private String Dept4;
private String Dept5;
private String Dept6;
private String Dept7;
private String Dept8;
private String Dept9;
private String Dept10;
private String MinPriceRC;
private String MinPriceRC_VV;
private String RankName;
private String RankNameEn;
private String ConfirmType;
private String ConfirmType2;
private String ConfirmPerson;
private String ConfirmPerson2;
private String ConfirmPersonCC;
private String ConfirmPersonCC2;
private String ConfirmPersonName;
private String ConfirmPersonName2;
private String ConfirmPersonCCName;
private String ConfirmPersonCCName2;
private Double TPMaxPrice;
private String RoomType;
private Integer MealType;
private String ProjectCode;
private String CancelReason;
private String CancelReasonDesc;
private String ContractRoomExistedFlag;
private String RefundTime;
private String RepeatBookingRC;
private String RepeatBookingDesc;
private String RepeatBookingRC_VV;
private String UserNamePinyin;
private String ConfigCurrency;
private Double ConfigExchangeToSettlement;
private Double TPConfigMinPrice;
private Double TPConfigMaxPrice;
private String ReservationType;
private String PreEmail;
public static CTripHotelOrderDetail of(OrderHotelResponse.SettlementOrderDetail data) {
return BeanUtil.copyProperties(data, CTripHotelOrderDetail.class);
}
}

View File

@ -20,12 +20,15 @@ public class CTripHotelRecord {
private CTripHotelRecordBase cTripHotelRecordBase;
@MappedCollection(idColumn = "c_trip_hotel_record_id")
private CTripHotelInfo cTripHotelInfo;
@MappedCollection(idColumn = "c_trip_hotel_record_id")
private CTripHotelOrderDetail cTripHotelOrderDetail;
public static CTripHotelRecord of(CTripHotelRecordBase cTripHotelRecordBase, CTripHotelInfo cTripHotelInfo) {
public static CTripHotelRecord of(CTripHotelRecordBase cTripHotelRecordBase, CTripHotelInfo cTripHotelInfo, CTripHotelOrderDetail cTripHotelOrderDetail) {
CTripHotelRecord cTripHotelRecord = new CTripHotelRecord();
cTripHotelRecord.setRecordId(String.valueOf(cTripHotelRecordBase.getRecordId()));
cTripHotelRecord.setCTripHotelRecordBase(cTripHotelRecordBase);
cTripHotelRecord.setCTripHotelInfo(cTripHotelInfo);
cTripHotelRecord.setCTripHotelOrderDetail(cTripHotelOrderDetail);
cTripHotelRecord.setCreateTime(DateTimeUtil.strToTimeMM(cTripHotelRecordBase.getCreateTime()));
return cTripHotelRecord;
}

View File

@ -1,19 +1,25 @@
package com.chint.domain.factoriy.order_record;
import com.chint.application.dtos.response.LocationRes;
import com.chint.domain.aggregates.order.CarOrderDetail;
import com.chint.domain.aggregates.order.Location;
import com.chint.domain.aggregates.order.OrderDetail;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.order.order_record.OrderCarRecord;
import com.chint.domain.aggregates.order.order_record.OrderFlightRecord;
import com.chint.domain.aggregates.order.order_record.OrderHotelRecord;
import com.chint.domain.aggregates.order.order_record.OrderTrainRecord;
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripCarQuickInfo;
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripCarRecord;
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripCarRecordBase;
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.*;
import com.chint.domain.repository.LocationRepository;
import com.chint.domain.repository.RouteRepository;
import com.chint.domain.service.OrderDetailDomainService;
import com.chint.infrastructure.repository.jdbc.JdbcCtripHotelOrderDetailRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Optional;
@Component
public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFactory {
@ -23,21 +29,25 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
private JdbcCtripHotelOrderDetailRepository jdbcCtripHotelOrderDetailRepository;
@Autowired
private OrderRecordFactory orderRecordFactory;
@Autowired
private RouteRepository routeRepository;
@Autowired
private LocationRepository locationRepository;
@Override
public OrderCarRecord createCarOrderRecord(Object orderCarRecordData) {
CTripCarRecord cTripCarRecord = (CTripCarRecord) orderCarRecordData;
String routeOrderNo = cTripCarRecord.getRouteOrderNo();
RouteOrder byOrderNo = routeRepository.findByOrderNo(routeOrderNo);
OrderCarRecord orderCarRecord = orderRecordFactory
.buildWithRouteOrder(byOrderNo)
.carRecord();
CTripCarRecordBase cTripCarRecordBase = cTripCarRecord.getCTripCarRecordBase();
//携程的打车订单可以直接通过订单号获取对应的订单
Optional<OrderDetail> orderDetail = byOrderNo.getOrderDetails().stream().filter(it -> it.getOrderNo().equals(String.valueOf(
cTripCarRecordBase.getOrderId()
))).findFirst();
CTripCarQuickInfo cTripCarQuickInfo = cTripCarRecord.getCTripCarQuickInfo();
//添加行程信息
@ -62,7 +72,8 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
String batchNo = cTripCarRecordBase.getBatchNoStartDate().substring(0, 6);
orderCarRecord.loadFinancialInfo(batchNo,
cTripCarRecordBase.getSubAccCheckBatchNo(),
String.valueOf(cTripCarRecordBase.getAmount()));
String.valueOf(cTripCarRecordBase.getAmount()),
String.valueOf(cTripCarRecordBase.getRealAmountHasPost()));
// 加载费用细节, 未税金额税费服务费取消费额外费用额外费用名称 , 携程马上用车产品没有税费和额外费用字段
orderCarRecord.loadFeeDetails(String.valueOf(cTripCarRecordBase.getAmount()),
@ -91,16 +102,27 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
orderCarRecord.loadPayment(paymentType,
String.valueOf(realAmountHasPost - personAmount),
String.valueOf(personAmount));
if(cTripCarRecord.getRouteOrderNo() == null ||
if (cTripCarRecord.getRouteOrderNo() == null ||
cTripCarRecord.getRouteOrderNo().isEmpty() ||
cTripCarRecord.getRouteOrderNo().isBlank()){
cTripCarRecord.getRouteOrderNo().isBlank()) {
orderCarRecord.loadSource("N");
} else {
orderCarRecord.loadSource("Y");
}
// 加载超标信息, 加载订单关联信息 加载订单状态 单号创建时间等信息
orderDetail.ifPresent(it -> {
CarOrderDetail carOrderDetail = it.getCarOrderDetail();
orderCarRecord.loadComplianceInfo(it)
.loadRelatedOrderInfo(it.getOrderId(),
carOrderDetail.getDetailId(),
carOrderDetail.getReceiptsNum(),
carOrderDetail.getParentOrderNo(),
carOrderDetail.getOriginalOrderNo())
.loadBasicOrderInfo(carOrderDetail.getOrderNo(),
carOrderDetail.getOrderStatus(),
carOrderDetail.getCreateTime());
});
return orderCarRecord;
}
@ -119,6 +141,38 @@ public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFac
@Override
public OrderHotelRecord createHotelOrderRecord(Object orderHotelRecordData) {
CTripHotelRecord cTripHotelRecord = (CTripHotelRecord) orderHotelRecordData;
CTripHotelOrderDetail cTripHotelOrderDetail = cTripHotelRecord.getCTripHotelOrderDetail();
String routeOrderNo = cTripHotelRecord.getRouteOrderNo();
RouteOrder byOrderNo = routeRepository.findByOrderNo(routeOrderNo);
OrderHotelRecord orderHotelRecord = orderRecordFactory
.buildWithRouteOrder(byOrderNo)
.hotelRecord();
CTripHotelInfo cTripHotelInfo = cTripHotelRecord.getCTripHotelInfo();
// 加载酒店和入住信息
orderHotelRecord.loadHotelInfo(cTripHotelInfo.getHotelName(),
cTripHotelInfo.getHotelName(),
cTripHotelOrderDetail.getStartTime(),
cTripHotelOrderDetail.getEndTime(),
cTripHotelOrderDetail.getRoomQuantity(),
cTripHotelOrderDetail.getRoomName());
// 加载地理信息位置
Integer cityID = cTripHotelInfo.getCityID();
List<Location> locations = locationRepository.findByCityId(Long.valueOf(cityID));
if (locations != null && !locations.isEmpty()) {
Location location = locations.get(0);
LocationRes locationRes = LocationRes.copyFrom(location);
orderHotelRecord.loadLocationInfo(locationRes.getCountry(), locationRes.getProvince(), cTripHotelInfo.getCityName());
} else {
//如果找不到该地区那么只能先用空的
orderHotelRecord.loadLocationInfo("", "", cTripHotelInfo.getCityName());
}
// 加载酒店品牌和星级信息
// orderHotelRecord.loadBrandAndStarRateInfo()
return null;
}

View File

@ -21,6 +21,7 @@ public interface LocationRepository {
Location findByCityIdAndLevelFour(Long cityId);
List<Location> findByCityIdAndLocationType(Long cityId , Integer LocationType);
List<Location> findByCityId(Long cityId);
List<Location> findByLocationType(Integer LocationType);
List<Location> findAllLevelThreeAndFour();
@ -56,7 +57,6 @@ public interface LocationRepository {
List<Location> findChinaCityByLevel(String locationNames, Integer level);
List<Location> findNotChintCityByLevel(String locationNames, Integer level);
}

View File

@ -2,6 +2,7 @@ package com.chint.domain.service;
import com.chint.domain.aggregates.system.JTCompany;
import com.chint.domain.exceptions.AuthException;
import com.chint.domain.repository.JTCompanyRepository;
import com.chint.domain.repository.SystemCodeRepository;
import jakarta.annotation.PostConstruct;
@ -57,6 +58,9 @@ public class JTCompanyDomainService {
public String findSystemCodeByCompanyCode(String companyCode) {
JTCompany byCompanyCode = jtCompanyRepository.findByCompanyCode(companyCode);
if(byCompanyCode == null){
throw new AuthException("用户所在公司不在实施范围内");
}
return systemCodeRepository.findById(byCompanyCode.getSystemCodeId()).getSystemCode();
}
}

View File

@ -4,6 +4,7 @@ import com.chint.domain.aggregates.system.JTCompany;
import com.chint.domain.repository.JTCompanyRepository;
import com.chint.infrastructure.repository.jdbc.JdbcJTCompanyRepositoryImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
@ -23,6 +24,7 @@ public class JTCompanyRepositoryImpl implements JTCompanyRepository {
return all;
}
@Cacheable(value = "JTCompanyByCompanyCode" , key = "#companyCode")
@Override
public JTCompany findByCompanyCode(String companyCode) {
return jdbcJTCompanyRepository.findByCompanyCode(companyCode);

View File

@ -80,6 +80,11 @@ public class LocationRepositoryImpl implements LocationRepository {
return jdbcLocationRepository.findByCityIdAndLocationType(cityId, LocationType);
}
@Override
public List<Location> findByCityId(Long cityId) {
return jdbcLocationRepository.findByCityId(cityId);
}
@Override
public List<Location> findByLocationType(Integer LocationType) {
return jdbcLocationRepository.findByLocationType(LocationType);

View File

@ -16,6 +16,7 @@ public interface JdbcLocationRepository extends CrudRepository<Location, Long> {
List<Location> findByLocationType(Integer locationType);
List<Location> findByCityIdAndLocationType(Long cityId, Integer locationType);
List<Location> findByCityId(Long cityId);
Location findByLocationId(Long locationId);

View File

@ -72,7 +72,7 @@ public class CTripOrderRecordAutoSave {
String.valueOf(settlementDetail.getRecordId()));
if (record == null) {
record = CTripHotelRecord.of(CTripHotelRecordBase.changeInfo(settlementDetail),
CTripHotelInfo.of(it.getHotelDetail()));
CTripHotelInfo.of(it.getHotelDetail()),CTripHotelOrderDetail.of(it.getOrderDetail()));
}
//补充额外的字段
OrderHotelResponse.SettlementOrderDetail orderDetail = it.getOrderDetail();

View File

@ -811,9 +811,9 @@ public class LYTest {
System.out.println(json);
}
// @Test
@Test
void searchTrain() {
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DT24032167537614664");
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DTC24032868398852849");
Gson gson = new Gson();
String json = gson.toJson(trainOrderDetail);
System.out.println(json);

View File

@ -1248,4 +1248,10 @@ class RouteApplicationTests {
void testInBlackList(){
orderDomainService.checkCompanyNameIfBlack("乐清正泰电器销售有限公司");
}
// @Test
void testSplid(){
String str = "20240301";
System.out.println(str.substring(0, 5));
}
}