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

This commit is contained in:
dengwc 2024-03-27 14:28:37 +08:00
commit a34688a971
47 changed files with 634 additions and 125 deletions

View File

@ -2,11 +2,10 @@ package com.chint.application.dtos;
import com.chint.domain.value_object.BaseQuery;
import com.chint.domain.value_object.LegData;
import lombok.Data;
@Data
public class AuthenticationDto extends BaseQuery {
private String clientid ;
private String clientid;
private String secretkey;
}

View File

@ -1,7 +1,9 @@
package com.chint.application.out;
import com.chint.domain.aggregates.system.FsscSystem;
import com.chint.domain.aggregates.system.SystemCode;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.SystemCodeRepository;
import com.chint.domain.service.JTCompanyDomainService;
import com.chint.infrastructure.util.BaseContext;
import com.chint.infrastructure.util.Result;
@ -15,12 +17,12 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.chint.infrastructure.constant.BPMConstant.*;
import static com.chint.infrastructure.constant.BPMConstant.FSSC;
import static com.chint.infrastructure.constant.BPMConstant.XN_FSSC;
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
import static com.chint.infrastructure.constant.FSSCConstant.*;
@ -44,6 +46,12 @@ public class FSSCController {
@Autowired
private PostRequest postRequest;
@Autowired
private SystemCodeRepository systemCodeRepository;
@Value("${chint.envMark}")
private String envMark;
private Map<String, String> urlCache = new HashMap<>();
@PostConstruct
@ -60,27 +68,34 @@ public class FSSCController {
User user = BaseContext.getCurrentUser();
String employeeNo = user.getEmployeeNo();
//这里需要根据companyCode进行匹配到正确的申请单网址
List<String> systemCodes = user.getFsscSystemList()
.stream()
.map(FsscSystem::getSystemCode)
.toList();
List<FsscSystem> res = new ArrayList<>();
if (systemCodes.contains(FSSC)) {
FsscSystem fsscSystem = new FsscSystem(FSSC_NAME, FSSC,
postRequest.getReDirectUrl(FSSC_LOAD_URL + generateFsscUrlPath(employeeNo)));
res.add(fsscSystem);
List<FsscSystem> fsscSystemList = user.getFsscSystemList();
if (fsscSystemList != null && !fsscSystemList.isEmpty()) {
fsscSystemList.forEach(it -> {
SystemCode sysCode = systemCodeRepository.findBySysCode(it.getSystemCode());
String redirectUrl = getRedirectUrl(sysCode, employeeNo);
it.setRedirectUrl(redirectUrl);
});
} else {
return Result.Success(SUCCESS, List.of());
}
//如果用户的公司编码属于集团 那么加入集团财务共享跳转地址
if (systemCodes.contains(XN_FSSC)) {
FsscSystem fsscSystem = new FsscSystem(XN_FSSC_NAME, XN_FSSC,
postRequest.getReDirectUrl(FSSC_LOAD_URL + generateXNFsscUrlPath(employeeNo)));
res.add(fsscSystem);
return Result.Success(SUCCESS, fsscSystemList);
}
return Result.Success(SUCCESS, res);
private String getRedirectUrl(SystemCode sysCode, String employeeNo) {
String reDirectUrl = null;
String dataBaseUrl;
//获取的登录基础地址
if (envMark.equals("prod")) {
dataBaseUrl = sysCode.getSystemCodeUrl().getRedirectUrlProd();
} else {
dataBaseUrl = sysCode.getSystemCodeUrl().getRedirectUrlDev();
}
if (sysCode.getSystemCodeUrl().getRedirectType() == 1) {
reDirectUrl = postRequest.getReDirectUrl(generateUrlPathFromDataBase(dataBaseUrl, employeeNo));
}
return reDirectUrl;
}
public String generateFsscUrlPath(String employeeNo) {
@ -91,4 +106,7 @@ public class FSSCController {
return XN_FSSC_REDIRECT_PATH_APPROVAL_ONE + employeeNo + FSSC_REDIRECT_PATH_APPROVAL_TWO;
}
public String generateUrlPathFromDataBase(String dataBaseUrl, String employeeNo) {
return dataBaseUrl + employeeNo + FSSC_REDIRECT_PATH_APPROVAL_TWO;
}
}

View File

@ -4,7 +4,6 @@ import com.chint.application.commands.RefundOrderGenerateCommand;
import com.chint.application.dtos.AuthenticationDto;
import com.chint.application.dtos.AuthenticationSignDto;
import com.chint.application.dtos.OrderDetailQueryParam;
import com.chint.application.dtos.OrderSearchResult;
import com.chint.application.dtos.response.OrderDetailRes;
import com.chint.application.queryies.OrderDetailQuery;
import com.chint.domain.aggregates.order.*;
@ -17,6 +16,7 @@ import com.chint.infrastructure.echo_framework.annotation.TransitionTo;
import com.chint.infrastructure.util.Digest;
import com.chint.infrastructure.util.PageResult;
import com.chint.infrastructure.util.Result;
import com.chint.infrastructure.util.Token;
import com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest;
import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse;
import com.chint.interfaces.rest.ly.LYSearchRequest;
@ -68,27 +68,38 @@ public class OrderDetailController {
@Autowired
private OrderExtensionCreator orderExtensionCreator;
@ApiOperation("订单明细认证接口")
@PostMapping("/public/authentication")
public Result<OrderSearchResult> queryAuthentication(@RequestBody AuthenticationDto authenticationDto) {
OrderSearchResult orderSearchResult = null;
try {
orderSearchResult = authenticateService.authenticateClient(authenticationDto);
if (orderSearchResult != null) {
return Result.Success(SUCCESS, orderSearchResult);
public Result<Token> queryAuthentication(@RequestBody AuthenticationDto authenticationDto) {
Token token = authenticateService.authenticateClient(authenticationDto);
if (token != null) {
return Result.Success(SUCCESS, token);
} else {
return Result.error("认证失败");
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
@ApiOperation("订单明细查询接口")
@PostMapping("/query")
public Result<PageResult<Object>> query(@RequestBody AuthenticationSignDto authenticationDto) {
if (signCheck(authenticationDto)) {
return orderDetailPageQuery.orderDetailInfoPageQuery(authenticationDto);
} else {
return Result.error("签名错误");
}
}
@ApiOperation("订单结算查询接口")
@PostMapping("/record/query")
public Result<PageResult<Object>> queryRecord(@RequestBody AuthenticationSignDto authenticationDto) {
if (signCheck(authenticationDto)) {
return orderDetailPageQuery.orderDetailInfoPageQuery(authenticationDto);
} else {
return Result.error("签名错误");
}
}
private boolean signCheck(AuthenticationSignDto authenticationDto) {
Integer productType = authenticationDto.getProductType();
String systemType = authenticationDto.getSystemType();
String startTime = authenticationDto.getStartTime();
@ -96,13 +107,8 @@ public class OrderDetailController {
Integer pageSize = authenticationDto.getPageSize();
Integer pageNum = authenticationDto.getPageNum();
String orgsign = authenticationDto.getSign();
String sign = Digest.md5(+productType + systemType + startTime + endTime + pageSize + pageNum);
System.out.println(sign);
if (StringUtils.isNotBlank(orgsign) && orgsign.equals(sign)) {
return orderDetailPageQuery.orderDetailInfoPageQuery(authenticationDto);
} else {
return Result.error("签名错误");
}
String sign = Digest.md5(productType + systemType + startTime + endTime + pageSize + pageNum);
return orgsign.equals(sign);
}
@ApiOperation("查询我的订单")

View File

@ -139,6 +139,10 @@ public class OrderDetailQuery {
return Result.Success(SUCCESS, PageResult.totalPageNum(res.size(), paginatedResults));
}
public Result<PageResult<Object>> orderRecordInfoPageQuery(AuthenticationSignDto authenticationDto) {
return null;
}
private Object processHotelOrderDetail(OrderDetail orderDetail, String systemType) {
HotelOrderDetail hotelOrderDetail = orderDetail.getHotelOrderDetail();

View File

@ -5,10 +5,10 @@ import com.chint.domain.aggregates.location.basedata.PrefectureLevelCityInfoEnti
import com.chint.domain.aggregates.order.Location;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.standards.CityTag;
import com.chint.domain.service.TrainStandardsService;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.exceptions.LocationException;
import com.chint.domain.repository.*;
import com.chint.domain.service.TrainStandardsService;
import com.chint.domain.value_object.FlightPriceData;
import com.chint.domain.value_object.HotelPriceData;
import com.chint.domain.value_object.PriceQueryData;
@ -150,7 +150,7 @@ public class CTripEstimatePrice implements EstimatePrice {
public FlightPriceData queryFlightPrice(PriceQueryData priceQueryData) {
checkPriceQueryData(priceQueryData);
FlightProductInfo flightProductInfo = new FlightProductInfo();
FlightPriceData flightPriceData = new FlightPriceData();
String employeeNo;
String standardLevel;
if (priceQueryData.getRouteId() != null) {
@ -176,6 +176,13 @@ public class CTripEstimatePrice implements EstimatePrice {
getCityId(originLocation);
Location arriveLocation = locationRepository.findById(priceQueryData.getArriveCity());
getCityId(arriveLocation);
//增加判断如果查不到城市id就返回为空
if (originLocation.getCityId() == null || arriveLocation.getCityId() == null) {
flightPriceData.setSuccess(false);
flightPriceData.setMaxPrice(NO_PRICE_ERROR);
return flightPriceData;
}
routeInfo.setArriveCityID(
originLocation.getCityId().toString());
routeInfo.setDepartCityID(
@ -187,7 +194,7 @@ public class CTripEstimatePrice implements EstimatePrice {
BookingRelatedApiRequest bookingRelatedApiRequest = cTripEstimateRequest
.generateBaseRequest(flightProductInfo, null, null, employeeNo, standardLevel);
BookingRelatedApiResponse estimate = cTripEstimateRequest.estimate(bookingRelatedApiRequest);
FlightPriceData flightPriceData = new FlightPriceData();
if (estimate.getStatus().getSuccess()) {
Optional.ofNullable(
@ -334,10 +341,13 @@ public class CTripEstimatePrice implements EstimatePrice {
private Location getCityId(Location location) {
if (location.getCityId() == null) {
if (location.getLevel().equals(LOCATION_LEVEL_COUNTY)) {
CountryLevelInfoEntity byCityName = countryLevelInfoRepository
.findByCityName(location.getLocationName())
List<CountryLevelInfoEntity> list = countryLevelInfoRepository
.findByCityName(location.getLocationName());
if (list != null && !list.isEmpty()) {
CountryLevelInfoEntity byCityName = list
.get(0);
location.setCityId(byCityName.getCountyId());
}
} else {
List<PrefectureLevelCityInfoEntity> prefectureLevelCityInfoEntity = prefectureLevelRepository
.findByCityName(location.getLocationName());

View File

@ -20,4 +20,7 @@ public class Client implements Serializable {
private Long id;
private String clientId;
private String clientSecret;
private Integer clientType;
private Integer systemCodeId;
}

View File

@ -1,9 +1,13 @@
package com.chint.domain.aggregates.order.order_record;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;
@Data
@Table("order_car_record")
public class OrderCarRecord extends OrderBaseRecord {
@Id
private Long id;
private Long orderDetailId;
private String trvaleSysType; // 数据来源商旅平台 XC携程 TC同程

View File

@ -1,9 +1,13 @@
package com.chint.domain.aggregates.order.order_record;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;
@Data
@Table("order_flight_record")
public class OrderFlightRecord extends OrderBaseRecord{
@Id
private Long id;
private Long orderDetailId;
private String trvaleSysType; // 数据来源商旅平台 XC携程 TC同程

View File

@ -1,9 +1,13 @@
package com.chint.domain.aggregates.order.order_record;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;
@Data
@Table("order_hotel_record")
public class OrderHotelRecord extends OrderBaseRecord{
@Id
private Long id;
private Long orderDetailId;
private String trvaleSysType; // 数据来源商旅平台 XC携程 TC同程

View File

@ -1,9 +1,13 @@
package com.chint.domain.aggregates.order.order_record;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.Table;
@Data
@Table("order_train_record")
public class OrderTrainRecord extends OrderBaseRecord{
@Id
private Long id;
private Long orderDetailId;
private String trvaleSysType; // 数据来源商旅平台 XC携程 TC同程

View File

@ -1,11 +1,25 @@
package com.chint.domain.aggregates.system;
import com.chint.interfaces.rest.base.PostRequest;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
public class FsscSystem {
private final String systemName;
private final String systemCode;
private final String redirectUrl;
private String systemName;
private String systemCode;
private String redirectUrl;
public FsscSystem(String systemName, String systemCode) {
this.systemName = systemName;
this.systemCode = systemCode;
}
public FsscSystem(String systemName, String systemCode, String redirectUrl) {
this.systemName = systemName;
this.systemCode = systemCode;
this.redirectUrl = redirectUrl;
}
}

View File

@ -16,4 +16,5 @@ public class JTCompany implements Serializable {
private Long id;
private String companyName;
private String companyCode;
private Long systemCodeId;
}

View File

@ -23,4 +23,6 @@ public class SystemCode implements Serializable {
private Integer ifImmediateResponse; //是否立马回复审批结果0不是1是
@MappedCollection(idColumn = "system_id", keyColumn = "system_key")
private List<CompanyInfo> companyInfos;
@MappedCollection(idColumn = "system_code_id")
private SystemCodeUrl systemCodeUrl;
}

View File

@ -0,0 +1,21 @@
package com.chint.domain.aggregates.system;
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;
@Data
@Table("system_code_url")
public class SystemCodeUrl implements Serializable {
@Serial
private static final long serialVersionUID = 5003392233348155635L;
@Id
private Long id;
private Long systemCodeId;
private String redirectUrlDev;
private String redirectUrlProd;
private Integer redirectType;
}

View File

@ -99,6 +99,12 @@ public class User implements Serializable {
this.companyCode = companyCode;
}
public User addFssc(String CompanyName, String sysCode) {
FsscSystem fsscSystem = new FsscSystem(CompanyName, sysCode);
this.addFsscSystemToList(fsscSystem);
return this;
}
public User addXNFssc(String loadUrl, PostRequest postRequest) {
FsscSystem fsscSystem = new FsscSystem(XN_FSSC_NAME, XN_FSSC, postRequest.getReDirectUrl(loadUrl + generateXNFsscUrlPath()));
this.addFsscSystemToList(fsscSystem);
@ -110,7 +116,8 @@ public class User implements Serializable {
this.addFsscSystemToList(fsscSystem);
return this;
}
public User addJTFssc(String companyName,String loadUrl, PostRequest postRequest) {
public User addJTFssc(String companyName, String loadUrl, PostRequest postRequest) {
FsscSystem fsscSystem = new FsscSystem(companyName, FSSC, postRequest.getReDirectUrl(loadUrl + generateFsscUrlPath()));
this.addFsscSystemToList(fsscSystem);
return this;

View File

@ -0,0 +1,42 @@
package com.chint.domain.factoriy.order_record;
import com.chint.domain.aggregates.order.CarOrderDetail;
import com.chint.domain.aggregates.order.FlightOrderDetail;
import com.chint.domain.aggregates.order.HotelOrderDetail;
import com.chint.domain.aggregates.order.TrainOrderDetail;
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.service.OrderDetailDomainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Component
public class CTripOrderRecordExtensionFactory implements OrderRecordExtensionFactory{
@Autowired
private OrderDetailDomainService orderDetailDomainService;
@Override
public OrderCarRecord createCarOrderRecord(Object orderCarRecordData) {
return null;
}
@Override
public OrderTrainRecord createTrainOrderRecord(Object orderTrainRecordData) {
return null;
}
@Override
public OrderFlightRecord createFlightOrderRecord(Object orderFlightRecordData) {
return null;
}
@Override
public OrderHotelRecord createHotelOrderRecord(Object orderHotelRecordData) {
return null;
}
}

View File

@ -0,0 +1,58 @@
package com.chint.domain.factoriy.order_record;
import cn.hutool.core.bean.BeanUtil;
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 lombok.Data;
@Data
public class OrderRecordBasic {
// 数据来源商旅平台
private String trvaleSysType;
// 对应所属系统
private String belongSysType;
// 订单号
private String orderNo;
// 消费明细唯一标识
private String detailId;
// 核算企业id
private String accountCompanyId;
// 核算企业名称
private String accountCompanyName;
// 申请单号
private String receiptsNum;
// 行程编号
private String scheduleNum;
// 预订人Code
private String bookingUserCode;
// 预订人姓名
private String bookingName;
// 预订人电话
private String bookingUserPhone;
// 资源供应商
private String supplier;
// 超标原因
private String overStandardReason;
// 项目订单号
private String projectOrderNo;
// 成本中心
private String offlineCcomyCode;
public OrderCarRecord carRecord() {
return BeanUtil.copyProperties(this, OrderCarRecord.class);
}
public OrderFlightRecord flightRecord() {
return BeanUtil.copyProperties(this, OrderFlightRecord.class);
}
public OrderHotelRecord hotelRecord() {
return BeanUtil.copyProperties(this, OrderHotelRecord.class);
}
public OrderTrainRecord trainRecord() {
return BeanUtil.copyProperties(this, OrderTrainRecord.class);
}
}

View File

@ -0,0 +1,19 @@
package com.chint.domain.factoriy.order_record;
import com.chint.domain.aggregates.order.*;
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;
public interface OrderRecordExtensionFactory {
OrderCarRecord createCarOrderRecord(Object orderCarRecordData);
OrderTrainRecord createTrainOrderRecord(Object orderTrainRecordData);
OrderFlightRecord createFlightOrderRecord(Object orderFlightRecordData);
OrderHotelRecord createHotelOrderRecord(Object orderHotelRecordData);
}

View File

@ -1,8 +1,61 @@
package com.chint.domain.factoriy.order_record;
import com.chint.domain.aggregates.order.ApproveOrderNo;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import static com.chint.infrastructure.constant.BelongSystemConstant.*;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
@Component
public class OrderRecordFactory {
@Autowired
private UserRepository userRepository;
public OrderRecordBasic buildWithRouteOrder(RouteOrder routeOrder) {
routeOrder.reloadStatus();
OrderRecordBasic orderRecordBasic = new OrderRecordBasic();
//完成身份信息
String userId = routeOrder.getUserId();
User user = userRepository.findByUserEmployeeNo(userId);
orderRecordBasic.setBookingUserCode(user.getEmployeeNo());
orderRecordBasic.setBookingName(user.getName());
orderRecordBasic.setBookingUserPhone(user.getPhoneNumber());
//配置供应商信息
String supplierName = routeOrder.getSupplierName();
if (supplierName.equals(SUPPLIER_C_TRIP)) {
orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP);
} else {
orderRecordBasic.setTrvaleSysType(TRAVAL_SYS_TYPE_LY);
}
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
if (approveOrderNo != null) {
orderRecordBasic.setAccountCompanyId(approveOrderNo.getAccountCompanyCode());
orderRecordBasic.setAccountCompanyName(approveOrderNo.getAccountCompanyName());
orderRecordBasic.setProjectOrderNo(approveOrderNo.getProjectName());
String sysCode = routeOrder.getApproveOrderNo().getSysCode();
if (sysCode != null) {
if (sysCode.equals(BELONG_SYS_CODE_FSSC)) {
orderRecordBasic.setBelongSysType(BELONG_SYS_TYPE_FSSC);
}
if (sysCode.equals(BELONG_SYS_CODE_H3BPM)) {
orderRecordBasic.setBelongSysType(BELONG_SYS_TYPE_H3BPM);
}
if (sysCode.equals(BELONG_SYS_CODE_XNFSSC)) {
orderRecordBasic.setBelongSysType(BELONG_SYS_TYPE_XNFSSC);
}
if (sysCode.equals(BELONG_SYS_CODE_ANFSSC)) {
orderRecordBasic.setBelongSysType(BELONG_SYS_TYPE_ANFSSC);
}
}
}
return orderRecordBasic;
}
}

View File

@ -13,4 +13,6 @@ public interface ClientRepository {
Client save(Client client);
Client findByClientId(String clientId);
Client findByClientIdAndEnv(String clientId,String envMark);
}

View File

@ -0,0 +1,9 @@
package com.chint.domain.repository;
import com.chint.domain.aggregates.order.order_record.OrderCarRecord;
import java.util.List;
public interface OrderCarRecordRepository {
List<OrderCarRecord> saveAll(List<OrderCarRecord> orderCarRecordList);
}

View File

@ -0,0 +1,9 @@
package com.chint.domain.repository;
import com.chint.domain.aggregates.order.order_record.OrderFlightRecord;
import java.util.List;
public interface OrderFlightRecordRepository {
List<OrderFlightRecord> saveAll(List<OrderFlightRecord> orderFlightRecordList);
}

View File

@ -0,0 +1,9 @@
package com.chint.domain.repository;
import com.chint.domain.aggregates.order.order_record.OrderHotelRecord;
import java.util.List;
public interface OrderHotelRecordRepository {
List<OrderHotelRecord> saveAll(List<OrderHotelRecord> orderHotelRecordList);
}

View File

@ -0,0 +1,10 @@
package com.chint.domain.repository;
import com.chint.domain.aggregates.order.order_record.OrderHotelRecord;
import com.chint.domain.aggregates.order.order_record.OrderTrainRecord;
import java.util.List;
public interface OrderTrainRecordRepository {
List<OrderTrainRecord> saveAll(List<OrderTrainRecord> orderTrainRecordList);
}

View File

@ -3,6 +3,7 @@ package com.chint.domain.service;
import com.chint.domain.aggregates.system.JTCompany;
import com.chint.domain.repository.JTCompanyRepository;
import com.chint.domain.repository.SystemCodeRepository;
import jakarta.annotation.PostConstruct;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
@ -18,6 +19,9 @@ public class JTCompanyDomainService {
@Autowired
private JTCompanyRepository jtCompanyRepository;
@Autowired
private SystemCodeRepository systemCodeRepository;
private Set<JTCompany> companyBlackList = new HashSet<>();
@ -33,7 +37,7 @@ public class JTCompanyDomainService {
if (companyName != null) {
boolean contains = companyBlackList.stream().map(JTCompany::getCompanyName).toList().contains(companyName);
//如果找不到的话 再次查询数据进行一次查找
if(!contains){
if (!contains) {
companyBlackList.addAll(jtCompanyRepository.findAll());
contains = companyBlackList.stream().map(JTCompany::getCompanyName).toList().contains(companyName);
}
@ -50,4 +54,9 @@ public class JTCompanyDomainService {
}
return false;
}
public String findSystemCodeByCompanyCode(String companyCode) {
JTCompany byCompanyCode = jtCompanyRepository.findByCompanyCode(companyCode);
return systemCodeRepository.findById(byCompanyCode.getSystemCodeId()).getSystemCode();
}
}

View File

@ -53,7 +53,6 @@ public class LegDomainService {
}
}
if (lastOrderStatus.equals(ORDER_EVENT_CANCEL_NAME)) {
LegEvent legEvent = legEventFactory.creatLegEvent(LEG_EVENT_CANCEL);
leg.addEvent(legEvent);

View File

@ -2,9 +2,12 @@ package com.chint.domain.service;
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.factoriy.order_detail.OrderDetailFactory;
import com.chint.domain.repository.OrderDetailRepository;
import com.chint.domain.repository.RouteRepository;
import com.chint.domain.repository.*;
import com.chint.domain.service.order_search.OrderSearchSelector;
import com.chint.domain.service.supplier.OrderDataAdapterSelector;
import com.chint.domain.value_object.OrderLegData;
@ -36,6 +39,19 @@ public class OrderDetailDomainService {
@Autowired
private OrderDataAdapterSelector orderDataAdapterSelector;
@Autowired
private OrderCarRecordRepository orderCarRecordRepository;
@Autowired
private OrderHotelRecordRepository orderHotelRecordRepository;
@Autowired
private OrderFlightRecordRepository orderFlightRecordRepository;
@Autowired
private OrderTrainRecordRepository orderTrainRecordRepository;
public void syncOrderDetailStatus(List<OrderLegData> orderLegDataList) {
for (OrderLegData orderLegData : orderLegDataList) {
orderDetailRepository.findByOrderNo(orderLegData.getOutOrderNo()).ifPresent(
@ -67,4 +83,18 @@ public class OrderDetailDomainService {
syncOrderDetailStatus(orderLegDataList);
return true;
}
public List<OrderCarRecord> saveCarOrderRecordBatch(List<OrderCarRecord> orderCarRecordList) {
return orderCarRecordRepository.saveAll(orderCarRecordList);
}
public List<OrderFlightRecord> saveFlightOrderRecordBatch(List<OrderFlightRecord> orderFlightRecordList) {
return orderFlightRecordRepository.saveAll(orderFlightRecordList);
}
public List<OrderTrainRecord> saveTrainOrderRecordBatch(List<OrderTrainRecord> orderTrainRecordList) {
return orderTrainRecordRepository.saveAll(orderTrainRecordList);
}
public List<OrderHotelRecord> saveHotelOrderRecordBatch(List<OrderHotelRecord> orderHotelRecordList) {
return orderHotelRecordRepository.saveAll(orderHotelRecordList);
}
}

View File

@ -162,6 +162,8 @@ public class OrderDomainService {
return list;
}
@ListenTo(command = "OrderCreateCommand", order = 0)
public RouteOrder createOrder(OrderCreateCommand command) {
User user = command.getUser();
@ -628,4 +630,5 @@ public class OrderDomainService {
}
}
}
}

View File

@ -4,9 +4,10 @@ import com.chint.application.dtos.AuthenticationDto;
import com.chint.application.dtos.OrderSearchResult;
import com.chint.domain.value_object.UserLoginParam;
import com.chint.domain.value_object.UserLoginResult;
import com.chint.infrastructure.util.Token;
public interface AuthenticateService {
UserLoginResult authenticateEmployeeNo(UserLoginParam userLoginParam);
OrderSearchResult authenticateClient(AuthenticationDto authenticationDto)throws Exception;
Token authenticateClient(AuthenticationDto authenticationDto);
}

View File

@ -44,6 +44,9 @@ public class AuthenticateServiceImpl implements AuthenticateService {
@Value("${chint.url}")
public String SYSTEM_HOME_URL;//国内
@Value("${chint.envMark}")
private String envMark;
@Autowired
public AuthenticateServiceImpl(UserRepository userRepository, UserHttpRequest httpRequest) {
this.userRepository = userRepository;
@ -97,24 +100,28 @@ public class AuthenticateServiceImpl implements AuthenticateService {
}
@Override
public OrderSearchResult authenticateClient(AuthenticationDto authenticationDto) throws Exception {
Client client = clientRepository.findByClientId(authenticationDto.getClientid());
public Token authenticateClient(AuthenticationDto authenticationDto) {
//区分测试环境还是正式环境
String clientType;
if (envMark.equals("prod")) {
clientType = "1";
} else {
clientType = "0";
}
Client client = clientRepository.findByClientIdAndEnv(authenticationDto.getClientid(), clientType);
if (client != null) {
if (client.getClientSecret().equals(authenticationDto.getSecretkey())) {
Map<String, Object> claims = new HashMap<>();
claims.put(AuthMessageConstant.CLIENT_ID, client.getClientId());
claims.put(AuthMessageConstant.CLIENT_SECRET, client.getClientSecret());
String jwt = JWTUtil.createJWT(AuthMessageConstant.SECRET, AuthMessageConstant.EXPIRATION_CLIENT_TIME_MS,
AuthMessageConstant.SUBJECT, claims);
OrderSearchResult result = new OrderSearchResult();
result.setToken(Token.of(jwt));
return result;
AuthMessageConstant.HEADER_CLIENT_CASE, claims);
return Token.of(jwt);
} else {
throw new AuthException(AuthMessageConstant.JWT_INVALID);
throw new AuthException(CLIENT_SECRET_INVALID);
}
} else {
throw new AuthException(CLIENT_ID_INVALID);
}
}
}

View File

@ -112,7 +112,6 @@ public class LegEventHandler implements LegEventService {
//保存提交审批所提供的资料
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
approveOrderNo.setActualOrderNo(data.getActualOrderNo());
// approveOrderNo.setAccountCompany(data.getAccountCompany());
approveOrderNo.setInstructions(data.getInstructions());
approveOrderNo.setCreator(data.getCreator());
approveOrderNo.setAccountCompanyCode(data.getAccountCompanyCode());

View File

@ -11,6 +11,8 @@ import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.servlet.HandlerInterceptor;
import static com.chint.infrastructure.constant.AuthMessageConstant.JWT_INVALID;
public class JwtTokenAdminInterceptor implements HandlerInterceptor {
@ -44,13 +46,16 @@ public class JwtTokenAdminInterceptor implements HandlerInterceptor {
} catch (TokenExpiredException e) {
throw new JwtExpiredException(AuthMessageConstant.JWT_EXPIRED);
} catch (Exception e) {
throw new AuthException(AuthMessageConstant.JWT_INVALID);
throw new AuthException(JWT_INVALID);
}
return false;
}
private boolean dealWithTokenInfo(String token) {
JWTUtil.verifyJWT(AuthMessageConstant.SECRET, token);
boolean res = JWTUtil.verifyJWT(AuthMessageConstant.SECRET, token);
if (!res) {
return res;
}
var parseJWT = JWTUtil.parseJWT(AuthMessageConstant.SECRET, token);
var withJwt = User.withJwt(parseJWT);
BaseContext.setCurrentUser(withJwt);
@ -58,7 +63,12 @@ public class JwtTokenAdminInterceptor implements HandlerInterceptor {
}
private boolean dealWithClientInfo(String token) {
JWTUtil.verifyJWT(AuthMessageConstant.SECRET, token);
return true; // If verification succeeds, continue processing the request
boolean res = JWTUtil.verifyJWT(AuthMessageConstant.SECRET, token);
if (res) {
return true;
} else {
// throw new AuthException(JWT_INVALID);
return true;
}
}
}

View File

@ -3,6 +3,8 @@ package com.chint.infrastructure.constant;
public class AuthMessageConstant {
// JWT 验证消息
public static final String JWT_INVALID = "无效的 JWT 令牌";
public static final String CLIENT_ID_INVALID = "无效的 client_id";
public static final String CLIENT_SECRET_INVALID = "无效的 client_secret";
public static final String JWT_EXPIRED = "登录信息已过期";
public static final String JWT_REQUIRED = "需要 JWT 令牌";
public static final String JWT_ACCESS_DENIED = "JWT 令牌不足以访问此资源";

View File

@ -1,6 +1,5 @@
package com.chint.infrastructure.repository;
import com.chint.application.dtos.AuthenticationDto;
import com.chint.domain.aggregates.order.Client;
import com.chint.domain.repository.ClientRepository;
import com.chint.infrastructure.repository.jdbc.JdbcClientRepository;
@ -18,15 +17,21 @@ public class ClientRepositoryImpl implements ClientRepository {
@Autowired
private JdbcClientRepository jdbcClientRepository;
@Override
public Client save(Client client) {
return jdbcClientRepository.save(client);
}
@Override
public Client findByClientId(String clientId){
public Client findByClientId(String clientId) {
return jdbcClientRepository.findByClientId(clientId);
}
@Override
public Client findByClientIdAndEnv(String clientId, String envMark) {
return jdbcClientRepository.findByClientIdAndClientType(clientId, Integer.valueOf(envMark));
}
}

View File

@ -0,0 +1,22 @@
package com.chint.infrastructure.repository;
import com.chint.domain.aggregates.order.order_record.OrderCarRecord;
import com.chint.domain.repository.OrderCarRecordRepository;
import com.chint.infrastructure.repository.jdbc.JdbcOrderCarRecordRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.List;
@Repository
public class OrderCarRecordRepositoryImpl implements OrderCarRecordRepository {
@Autowired
private JdbcOrderCarRecordRepository orderCarRecordRepository;
@Override
public List<OrderCarRecord> saveAll(List<OrderCarRecord> orderCarRecordList) {
List<OrderCarRecord> res = new ArrayList<>();
orderCarRecordRepository.saveAll(orderCarRecordList).forEach(res::add);
return res;
}
}

View File

@ -0,0 +1,24 @@
package com.chint.infrastructure.repository;
import com.chint.domain.aggregates.order.order_record.OrderFlightRecord;
import com.chint.domain.repository.OrderFlightRecordRepository;
import com.chint.infrastructure.repository.jdbc.JdbcOrderFlightRecordRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.List;
@Repository
public class OrderFlightRecordRepositoryImpl implements OrderFlightRecordRepository {
@Autowired
private JdbcOrderFlightRecordRepository jdbcOrderFlightRecordRepository;
@Override
public List<OrderFlightRecord> saveAll(List<OrderFlightRecord> orderFlightRecordList) {
List<OrderFlightRecord> res = new ArrayList<>();
jdbcOrderFlightRecordRepository.saveAll(orderFlightRecordList).forEach(res::add);
return res;
}
}

View File

@ -0,0 +1,25 @@
package com.chint.infrastructure.repository;
import com.chint.domain.aggregates.order.order_record.OrderFlightRecord;
import com.chint.domain.aggregates.order.order_record.OrderHotelRecord;
import com.chint.domain.repository.OrderHotelRecordRepository;
import com.chint.infrastructure.repository.jdbc.JdbcOrderFlightRecordRepository;
import com.chint.infrastructure.repository.jdbc.JdbcOrderHotelRecordRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.List;
@Repository
public class OrderHotelRecordRepositoryImpl implements OrderHotelRecordRepository {
@Autowired
private JdbcOrderHotelRecordRepository jdbcOrderHotelRecordRepository;
@Override
public List<OrderHotelRecord> saveAll(List<OrderHotelRecord> orderHotelRecordList) {
List<OrderHotelRecord> res = new ArrayList<>();
jdbcOrderHotelRecordRepository.saveAll(orderHotelRecordList).forEach(res::add);
return res;
}
}

View File

@ -0,0 +1,24 @@
package com.chint.infrastructure.repository;
import com.chint.domain.aggregates.order.order_record.OrderHotelRecord;
import com.chint.domain.aggregates.order.order_record.OrderTrainRecord;
import com.chint.domain.repository.OrderTrainRecordRepository;
import com.chint.infrastructure.repository.jdbc.JdbcOrderHotelRecordRepository;
import com.chint.infrastructure.repository.jdbc.JdbcOrderTrainRecordRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.List;
@Repository
public class OrderTrainRecordRepositoryImpl implements OrderTrainRecordRepository {
@Autowired
private JdbcOrderTrainRecordRepository jdbcOrderTrainRecordRepository;
@Override
public List<OrderTrainRecord> saveAll(List<OrderTrainRecord> orderTrainRecordList) {
List<OrderTrainRecord> res = new ArrayList<>();
jdbcOrderTrainRecordRepository.saveAll(orderTrainRecordList).forEach(res::add);
return res;
}
}

View File

@ -5,13 +5,9 @@ import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.repository.SystemCodeRepository;
import com.chint.infrastructure.repository.jdbc.JdbcSystemCodeRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Repository;
import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND;
@Repository
public class SystemCodeRepositoryImpl implements SystemCodeRepository {
@ -31,6 +27,6 @@ public class SystemCodeRepositoryImpl implements SystemCodeRepository {
@Override
public SystemCode findById(Long id) {
return jdbcSystemCodeRepository.findById(id).orElseThrow(() -> new NotFoundException(NOT_FOUND));
return jdbcSystemCodeRepository.findById(id).orElseThrow(() -> new NotFoundException("该产业公司不在实施范围内"));
}
}

View File

@ -11,7 +11,9 @@ import org.springframework.stereotype.Repository;
**/
@Repository
public interface JdbcClientRepository extends CrudRepository<Client,Long> {
public interface JdbcClientRepository extends CrudRepository<Client, Long> {
Client findByClientId(String clientId);
Client findByClientIdAndClientType(String clientId, Integer clientType);
}

View File

@ -0,0 +1,9 @@
package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.order.order_record.OrderCarRecord;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface JdbcOrderCarRecordRepository extends CrudRepository<OrderCarRecord,Long> {
}

View File

@ -0,0 +1,9 @@
package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.order.order_record.OrderFlightRecord;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface JdbcOrderFlightRecordRepository extends CrudRepository<OrderFlightRecord,Long> {
}

View File

@ -0,0 +1,9 @@
package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.order.order_record.OrderHotelRecord;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface JdbcOrderHotelRecordRepository extends CrudRepository<OrderHotelRecord,Long> {
}

View File

@ -0,0 +1,9 @@
package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.order.order_record.OrderTrainRecord;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface JdbcOrderTrainRecordRepository extends CrudRepository<OrderTrainRecord,Long> {
}

View File

@ -56,8 +56,6 @@ public class CTripOrderRecordAutoSave {
checkIfRefund(String.valueOf(record.getOrderId()), String.valueOf(record.getAmount()), record.getCreateTime());
}
});
cTripOrderDetailRepository.saveAllFlightRecord(flightRecords);
}
}
@ -75,7 +73,6 @@ public class CTripOrderRecordAutoSave {
//业务需求这里加入是否退款判断
list.forEach(record -> {
CtripHotelOrderDetail hotelByRecordId = cTripOrderDetailRepository.findHotelByRecordId(record.getRecordId());
if (hotelByRecordId != null) {
record.setId(hotelByRecordId.getId());
@ -85,7 +82,6 @@ public class CTripOrderRecordAutoSave {
checkIfRefund(String.valueOf(record.getOrderId()), String.valueOf(record.getAmount()), record.getCreateTime());
}
});
cTripOrderDetailRepository.saveAllHotelRecord(list);
}
}

View File

@ -3,7 +3,6 @@ package com.chint.interfaces.rest.user;
import com.chint.domain.aggregates.standards.Ranks;
import com.chint.domain.aggregates.standards.StaffRank;
import com.chint.domain.aggregates.system.JTCompany;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.JTCompanyRepository;
import com.chint.domain.repository.StaffRankRepository;
@ -21,11 +20,10 @@ import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import static com.chint.infrastructure.constant.RankConstant.*;
import static com.chint.infrastructure.constant.RankConstant.DEFAULT_RANK_NAME;
import static com.chint.infrastructure.constant.RankConstant.JT_COMPANY_CODE;
@Slf4j
@ -120,13 +118,16 @@ public class UserHttpRequestImpl implements UserHttpRequest {
getDataFromUserSFData(user, userData);
if (user.getCompanyCode().equals(XN_COMPANY_CODE)) {
user.addXNFssc(FSSC_LOAD_URL, postRequest);
}
//如果用户的公司编码属于集团 那么加入集团财务共享跳转地址
if (jtCompanyDomainService.ifCompanyInJT(null, userData.getCompany())) {
user.addJTFssc(userData.getCompany_cn(), FSSC_LOAD_URL, postRequest);
}
String sysCode = jtCompanyDomainService.findSystemCodeByCompanyCode(user.getCompanyCode());
user.addFssc(userData.getCompany_cn(), sysCode);
// if (user.getCompanyCode().equals(XN_COMPANY_CODE)) {
// user.addXNFssc(FSSC_LOAD_URL, postRequest);
// }
// //如果用户的公司编码属于集团 那么加入集团财务共享跳转地址
// if (jtCompanyDomainService.ifCompanyInJT(null, userData.getCompany())) {
// user.addJTFssc(userData.getCompany_cn(), FSSC_LOAD_URL, postRequest);
// }
return user;
}
@ -164,25 +165,31 @@ public class UserHttpRequestImpl implements UserHttpRequest {
}
private void processSpecialCompanies(List<UserDataDTO> userDataDTOS, User user) {
Set<String> companyCodes = userDataDTOS.stream()
.map(UserDataDTO::getCompany)
.collect(Collectors.toSet());
List<String> inJtCompanyCodes = companyCodes
.stream()
.filter(code -> jtCompanyDomainService.ifCompanyInJT(null, code))
List<UserDataDTO> list = userDataDTOS.stream()
.filter(it -> jtCompanyDomainService.ifCompanyInJT(null, it.getCompany()))
.toList();
for (String inJtCompanyCode : inJtCompanyCodes) {
JTCompany byCompanyCode = jtCompanyRepository.findByCompanyCode(inJtCompanyCode);
user.addJTFssc(byCompanyCode.getCompanyName(), FSSC_LOAD_URL, postRequest);
}
if (companyCodes.contains(XN_COMPANY_CODE)) {
user.addXNFssc(FSSC_LOAD_URL, postRequest);
}
list.forEach(it -> user.addFssc(it.getCompany_cn(),
jtCompanyDomainService.findSystemCodeByCompanyCode(it.getCompany())));
// Set<String> companyCodes = userDataDTOS.stream()
// .map(UserDataDTO::getCompany)
// .collect(Collectors.toSet());
//
//
// List<String> inJtCompanyCodes = companyCodes
// .stream()
// .filter(code -> jtCompanyDomainService.ifCompanyInJT(null, code))
// .toList();
//
// for (String inJtCompanyCode : inJtCompanyCodes) {
// JTCompany byCompanyCode = jtCompanyRepository.findByCompanyCode(inJtCompanyCode);
// user.addJTFssc(byCompanyCode.getCompanyName(), FSSC_LOAD_URL, postRequest);
// }
//
// if (companyCodes.contains(XN_COMPANY_CODE)) {
// user.addXNFssc(FSSC_LOAD_URL, postRequest);
// }
}
private User getDataFromUserSFData(User user, UserDataDTO userData) {

View File

@ -269,10 +269,10 @@ class RouteApplicationTests {
@Test
void loginSignProd() {
String sfno = "230306198";
String sfno = "181203012";
String syscode = "FSSC";
String billcode = "CLSQ240315000308";
String companycode = "浙江正泰电器股份有限公司";
String billcode = "CLSQ240225000099";
String companycode = "正泰集团股份有限公司";
String timespan = "1708908662738";
String key = "ZhengTaiRoute";
String s = Digest.md5(sfno + syscode + billcode + companycode + key + timespan);