备份同步差旅申请的代码

This commit is contained in:
lulz1 2024-04-08 16:58:34 +08:00
parent 67f89d754f
commit 81f8299d6a
10 changed files with 128 additions and 15 deletions

View File

@ -1,23 +1,40 @@
package com.chint.application.in; package com.chint.application.in;
import com.chint.domain.service.RouteRequestDomainService;
import com.chint.domain.value_object.SyncLegData; import com.chint.domain.value_object.SyncLegData;
import com.chint.infrastructure.util.Result; import com.chint.infrastructure.util.Result;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
@RestController @RestController
@RequestMapping("/route/request") @RequestMapping("/route/request")
public class RouteRequestController { public class RouteRequestController {
@Transactional @Autowired
@ApiOperation("根据整个行程规划单到差旅平台") private RouteRequestDomainService routeRequestDomainService;
@PostMapping("/sync/whole")
public Result<String> syncByWholeRouterOrder(@RequestBody SyncLegData syncLegData) {
return null; @Transactional
@ApiOperation("同步行程规划单到差旅平台")
@PostMapping("/sync/whole")
public Result<String> syncRouterOrder(@RequestBody SyncLegData syncLegData) {
routeRequestDomainService.syncRouteRequestToSupplier(syncLegData);
return Result.Success(SUCCESS);
} }
@Transactional
@ApiOperation("取消行程规划单到差旅平台")
@PostMapping("/sync/whole")
public Result<String> cancelWholeRouterOrder(@RequestBody SyncLegData syncLegData) {
routeRequestDomainService.cancelRouteRequest(syncLegData);
return Result.Success(SUCCESS);
}
} }

View File

@ -3,10 +3,8 @@ package com.chint.domain.factoriy.order_detail;
import com.chint.domain.aggregates.order.*; import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.user.User; import com.chint.domain.aggregates.user.User;
import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.repository.LocationRepository; import com.chint.domain.repository.*;
import com.chint.domain.repository.OrderDetailRepository; import com.chint.domain.service.RouteRequestDomainService;
import com.chint.domain.repository.RouteRepository;
import com.chint.domain.repository.UserRepository;
import com.chint.infrastructure.util.BigDecimalCalculator; import com.chint.infrastructure.util.BigDecimalCalculator;
import com.chint.interfaces.rest.ctrip.dto.search.car.*; import com.chint.interfaces.rest.ctrip.dto.search.car.*;
import com.chint.interfaces.rest.ctrip.dto.search.flight.*; import com.chint.interfaces.rest.ctrip.dto.search.flight.*;
@ -46,6 +44,13 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
@Autowired @Autowired
private OrderDetailFactory orderDetailFactory; private OrderDetailFactory orderDetailFactory;
@Autowired
private RouteRequestRepository routeRequestRepository;
@Autowired
private RouteRequestDomainService routeRequestDomainService;
@Override @Override
public CarOrderDetail createCarOrderDetail(Object carOrderDetailData) { public CarOrderDetail createCarOrderDetail(Object carOrderDetailData) {
//获取基础信息数据 //获取基础信息数据
@ -53,7 +58,7 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
CarBasicInfo carBasicInfo = carQuickOrderInfoEntity.getBasicInfo(); CarBasicInfo carBasicInfo = carQuickOrderInfoEntity.getBasicInfo();
String orderNo = carBasicInfo.getOrderId(); String orderNo = carBasicInfo.getOrderId();
String journeyNo = carBasicInfo.getJourneyID(); String journeyNo = carBasicInfo.getJourneyID();
RouteOrder routeOrder = routeRepository.findByOrderNo(journeyNo); RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(journeyNo);
OrderDetail orderDetail = routeOrder.getOrderDetails() OrderDetail orderDetail = routeOrder.getOrderDetails()
.stream() .stream()
.filter(it -> it.getOrderNo().equals(orderNo)) .filter(it -> it.getOrderNo().equals(orderNo))
@ -76,7 +81,7 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
orderFeeList.forEach(it -> { orderFeeList.forEach(it -> {
if (it.getFeeName().equals("取消费")) { if (it.getFeeName().equals("取消费")) {
carOrderDetail.setCancellationFee(it.getAmount().toString()); carOrderDetail.setCancellationFee(it.getAmount().toString());
if(it.getAmount() > 0){ if (it.getAmount() > 0) {
carOrderDetail.setOrderStatus(FSSC_CAR_STATUS_REFUND); carOrderDetail.setOrderStatus(FSSC_CAR_STATUS_REFUND);
} else { } else {
carOrderDetail.setOrderStatus(FSSC_ORDER_STATUS_CANCEL); carOrderDetail.setOrderStatus(FSSC_ORDER_STATUS_CANCEL);
@ -156,7 +161,7 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
BasicInfo flightOrderBasicInfo = flightOrderInfoEntity.getBasicInfo(); BasicInfo flightOrderBasicInfo = flightOrderInfoEntity.getBasicInfo();
String orderNo = flightOrderBasicInfo.getOrderID(); String orderNo = flightOrderBasicInfo.getOrderID();
String journeyNo = flightOrderBasicInfo.getJourneyID(); String journeyNo = flightOrderBasicInfo.getJourneyID();
RouteOrder routeOrder = routeRepository.findByOrderNo(journeyNo); RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(journeyNo);
Optional<OrderDetail> first = routeOrder Optional<OrderDetail> first = routeOrder
.getOrderDetails() .getOrderDetails()
@ -359,7 +364,7 @@ public class CTripOrderExtensionFactoryImpl implements OrderExtensionFactory {
Optional<OrderDetail> byOrderNo = orderDetailRepository.findByOrderNo(orderNo); Optional<OrderDetail> byOrderNo = orderDetailRepository.findByOrderNo(orderNo);
String journeyNo = hotelOrderInfoEntity.getJourneyNo(); String journeyNo = hotelOrderInfoEntity.getJourneyNo();
RouteOrder routeOrder = routeRepository.findByOrderNo(journeyNo).reloadStatus(); RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(journeyNo).reloadStatus();
ApproveOrderNo approveOrderNo = null; ApproveOrderNo approveOrderNo = null;
User user = null; User user = null;

View File

@ -6,6 +6,7 @@ import com.chint.domain.aggregates.user.User;
import com.chint.domain.exceptions.NotFoundException; import com.chint.domain.exceptions.NotFoundException;
import com.chint.domain.repository.OrderDetailRepository; import com.chint.domain.repository.OrderDetailRepository;
import com.chint.domain.repository.RouteRepository; import com.chint.domain.repository.RouteRepository;
import com.chint.domain.repository.RouteRequestRepository;
import com.chint.domain.repository.UserRepository; import com.chint.domain.repository.UserRepository;
import com.chint.interfaces.rest.ly.dto.carorderdatapushback.PriceDetail; import com.chint.interfaces.rest.ly.dto.carorderdatapushback.PriceDetail;
import com.chint.interfaces.rest.ly.dto.hotelorderdatapushbach.Resident; import com.chint.interfaces.rest.ly.dto.hotelorderdatapushbach.Resident;
@ -56,8 +57,12 @@ public class LYOrderExtensionFactoryImpl implements OrderExtensionFactory {
@Autowired @Autowired
private OrderDetailFactory orderDetailFactory; private OrderDetailFactory orderDetailFactory;
@Autowired
private RouteRequestRepository routeRequestRepository;
private DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss"); private DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd hh:mm:ss");
@Override @Override
public CarOrderDetail createCarOrderDetail(Object carOrderDetailData) { public CarOrderDetail createCarOrderDetail(Object carOrderDetailData) {
CarDetailResponse.DataWrapper data = (CarDetailResponse.DataWrapper) carOrderDetailData; CarDetailResponse.DataWrapper data = (CarDetailResponse.DataWrapper) carOrderDetailData;

View File

@ -0,0 +1,8 @@
package com.chint.domain.repository;
import com.chint.domain.aggregates.order.RouteRequest;
public interface RouteRequestRepository {
RouteRequest findByRouteRequestNo(String routeRequestNo);
}

View File

@ -7,6 +7,7 @@ import com.chint.domain.aggregates.order.RouteRequestEvent;
import com.chint.domain.factoriy.order.RouteOrderFactory; import com.chint.domain.factoriy.order.RouteOrderFactory;
import com.chint.domain.repository.LegRepository; import com.chint.domain.repository.LegRepository;
import com.chint.domain.repository.RouteRepository; import com.chint.domain.repository.RouteRepository;
import com.chint.domain.repository.RouteRequestRepository;
import com.chint.domain.service.order_sync.SyncAdapter; import com.chint.domain.service.order_sync.SyncAdapter;
import com.chint.domain.value_object.SyncLegData; import com.chint.domain.value_object.SyncLegData;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -35,6 +36,9 @@ public class RouteRequestDomainService {
@Autowired @Autowired
private LegRepository legRepository; private LegRepository legRepository;
@Autowired
private RouteRequestRepository routeRequestRepository;
public RouteRequest syncRouteRequestToSupplier(SyncLegData syncLegData) { public RouteRequest syncRouteRequestToSupplier(SyncLegData syncLegData) {
RouteOrder routeOrder = routeRepository.queryById(syncLegData.getRouteId()); RouteOrder routeOrder = routeRepository.queryById(syncLegData.getRouteId());
@ -56,6 +60,30 @@ public class RouteRequestDomainService {
return routeRequest; return routeRequest;
} }
public void cancelRouteRequest(SyncLegData syncLegData) {
Long routeId = syncLegData.getRouteId();
RouteOrder routeOrder = routeRepository.queryById(routeId);
Optional<RouteRequest> optionalRouteRequest;
if (syncLegData.getRouteRequestId() != null) {
//如果指定的对应的差旅申请单 那么取消对应的差旅申请单
optionalRouteRequest = routeOrder.getRouteRequestList()
.stream()
.filter(it -> it.getId().equals(syncLegData.getRouteRequestId()))
.findFirst();
} else {
//如果指定的行程单号和供应商 该供应商对应的差旅申请单
optionalRouteRequest = routeOrder.getRouteRequestList()
.stream()
.filter(it -> it.getSupplier().equals(syncLegData.getSupplierName()))
.findFirst();
}
optionalRouteRequest.ifPresent(it -> {
it.addEvent(RouteRequestEvent.cancel(it.getSupplier()));
syncAdapter.of(it.getSupplier()).cancelRouteRequest(it);
});
routeRepository.save(routeOrder);
}
//获取目前已经同步到供应商的差旅申请单 //获取目前已经同步到供应商的差旅申请单
private RouteRequest getRouteRequest(RouteOrder routeOrder, List<Long> legIds, String supplier) { private RouteRequest getRouteRequest(RouteOrder routeOrder, List<Long> legIds, String supplier) {
@ -85,4 +113,13 @@ public class RouteRequestDomainService {
.ifPresent(it::setLeg)); .ifPresent(it::setLeg));
return routeRequest; return routeRequest;
} }
public RouteOrder getRouteOrder(String journeyNo) {
RouteOrder byOrderNo = routeRepository.findByOrderNo(journeyNo);
if (byOrderNo == null) {
RouteRequest byRouteRequestNo = routeRequestRepository.findByRouteRequestNo(journeyNo);
byOrderNo = routeRepository.queryById(byRouteRequestNo.getRouteId());
}
return byOrderNo;
}
} }

View File

@ -13,6 +13,7 @@ import com.chint.domain.factoriy.order.RouteOrderFactory;
import com.chint.domain.factoriy.order_detail.OrderDetailFactory; import com.chint.domain.factoriy.order_detail.OrderDetailFactory;
import com.chint.domain.repository.*; import com.chint.domain.repository.*;
import com.chint.domain.service.OrderDomainService; import com.chint.domain.service.OrderDomainService;
import com.chint.domain.service.RouteRequestDomainService;
import com.chint.domain.service.order_sync.SyncAdapter; import com.chint.domain.service.order_sync.SyncAdapter;
import com.chint.domain.value_object.ApprovalSimpleData; import com.chint.domain.value_object.ApprovalSimpleData;
import com.chint.domain.value_object.ApproveRouteData; import com.chint.domain.value_object.ApproveRouteData;
@ -88,6 +89,9 @@ public class LegEventHandler implements LegEventService {
@Autowired @Autowired
private OrderDomainService orderDomainService; private OrderDomainService orderDomainService;
@Autowired
private RouteRequestDomainService routeRequestDomainService;
@Value("${chint.envMark}") @Value("${chint.envMark}")
private String envMark; private String envMark;
@ -218,7 +222,7 @@ public class LegEventHandler implements LegEventService {
public ResultContainer routeUpdateOrder(RouteUpdateOrderCommand command) { public ResultContainer routeUpdateOrder(RouteUpdateOrderCommand command) {
OrderLegData data = command.getData(); OrderLegData data = command.getData();
String orderNo = data.getSelfOrderNo(); String orderNo = data.getSelfOrderNo();
RouteOrder routeOrder = routeRepository.findByOrderNo(orderNo); RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(orderNo);
//获取行程规划单创建者作为该订单 //获取行程规划单创建者作为该订单
String employeeNo = routeOrder.getUserId(); String employeeNo = routeOrder.getUserId();
User byUserEmployeeNo = userRepository.findByUserEmployeeNo(employeeNo); User byUserEmployeeNo = userRepository.findByUserEmployeeNo(employeeNo);

View File

@ -7,6 +7,7 @@ import java.util.List;
@Data @Data
public class SyncLegData { public class SyncLegData {
private Long routeId; private Long routeId;
private Long routeRequestId;
private List<Long> routeIds; private List<Long> routeIds;
private List<Long> legIds; private List<Long> legIds;
private String supplierName; private String supplierName;

View File

@ -0,0 +1,19 @@
package com.chint.infrastructure.repository;
import com.chint.domain.aggregates.order.RouteRequest;
import com.chint.domain.repository.RouteRequestRepository;
import com.chint.infrastructure.repository.jdbc.JdbcRouteRequestRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
@Repository
public class RouteRequestRepositoryImpl implements RouteRequestRepository {
@Autowired
private JdbcRouteRequestRepository jdbcRouteRequestRepository;
@Override
public RouteRequest findByRouteRequestNo(String routeRequestNo) {
return jdbcRouteRequestRepository.findByRouteRequestNo(routeRequestNo);
}
}

View File

@ -0,0 +1,11 @@
package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.order.RouteRequest;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface JdbcRouteRequestRepository extends CrudRepository<RouteRequest, Long> {
RouteRequest findByRouteRequestNo(String routeRequestNo);
}

View File

@ -196,7 +196,7 @@ public class UserHttpRequestImpl implements UserHttpRequest {
.findFirst() .findFirst()
.ifPresent(it -> { .ifPresent(it -> {
User byUserEmployeeNo = userRepository.findByUserEmployeeNo(user.getEmployeeNo()); User byUserEmployeeNo = userRepository.findByUserEmployeeNo(user.getEmployeeNo());
if(byUserEmployeeNo == null){ if (byUserEmployeeNo == null) {
userRepository.save( userRepository.save(
getDataFromUserSFData(user, it) getDataFromUserSFData(user, it)
); );
@ -290,6 +290,12 @@ public class UserHttpRequestImpl implements UserHttpRequest {
//根据入账公司没有找到部门编码的话直接获取主岗编码 //根据入账公司没有找到部门编码的话直接获取主岗编码
deptCode = user.lowestDeptCode(); deptCode = user.lowestDeptCode();
} }
if (deptCode == null) {
//如果还是空的话 就返回null
return null;
}
//清除部门编码里面的字母 //清除部门编码里面的字母
return deptCode.replaceAll("\\D", ""); return deptCode.replaceAll("\\D", "");
} }