feat:高德打车结算功能 , 高德差旅申请单同步增加差标管控

This commit is contained in:
lulz1 2024-05-29 13:11:09 +08:00
parent ab83133cc6
commit 05d16296c9
21 changed files with 391 additions and 48 deletions

View File

@ -12,13 +12,26 @@ public class OrderRecordGenerateCommand extends Command {
//将昨天的结算数据生成为财务共享需要的数据
private LocalDateTime startTime = LocalDateTime.of(LocalDate.now().minusDays(1), LocalTime.MIDNIGHT);
private LocalDateTime endTime = LocalDateTime.of(LocalDate.now().minusDays(1), LocalTime.MAX);
private String date;
private String supplierName;
public OrderRecordGenerateCommand startTime(LocalDateTime startTime) {
this.setStartTime(startTime);
return this;
}
public OrderRecordGenerateCommand endTime(LocalDateTime endTime) {
this.setEndTime(endTime);
return this;
}
public OrderRecordGenerateCommand supplierName(String supplierName) {
this.setSupplierName(supplierName);
return this;
}
public OrderRecordGenerateCommand date(String date) {
this.setDate(date);
return this;
}
}

View File

@ -3,6 +3,7 @@ package com.chint.application.dtos;
import lombok.Data;
@Data
public class CTripRecordMonthSaveDTO {
public class RecordMonthSaveDTO {
private String date;
private String supplierName;
}

View File

@ -2,9 +2,10 @@ package com.chint.application.in;
import com.chint.application.commands.LYOrderRecordGenerateCommand;
import com.chint.application.commands.OrderRecordGenerateCommand;
import com.chint.application.dtos.CTripRecordMonthSaveDTO;
import com.chint.application.dtos.RecordMonthSaveDTO;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.domain.factoriy.order_record.LyStatementOrder;
import com.chint.domain.service.OrderRecordDomainService;
import com.chint.infrastructure.echo_framework.command.Command;
import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository;
import com.chint.infrastructure.util.DateTimeUtil;
@ -24,6 +25,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
@RestController
@ -43,6 +46,9 @@ public class AutoWorkController {
@Autowired
private JdbcRouteRepository jdbcRouteRepository;
@Autowired
private OrderRecordDomainService orderRecordDomainService;
@ApiOperation("用户状态检查,离职用户将关闭开卡")
@PostMapping("/user/status/check")
@ -62,21 +68,45 @@ public class AutoWorkController {
return Result.Success(SUCCESS);
}
@Transactional
@ApiOperation("拉取按月份的携程流水")
@PostMapping("/cTrip/record/save/month")
public Result<String> autoSaveCTripRecordByMonth(@RequestBody CTripRecordMonthSaveDTO cTripRecordMonthSaveDTO) {
String date = cTripRecordMonthSaveDTO.getDate();
cTripOrderRecordAutoSave.saveAllByDate(date);
@ApiOperation("拉取按月份的流水并自动生成结算记录")
@PostMapping("/record/pullAndSave/month")
public Result<String> autoDownloadDataAndSaveRecordByMonth(@RequestBody RecordMonthSaveDTO recordMonthSaveDTO) {
String date = recordMonthSaveDTO.getDate();
if (recordMonthSaveDTO.getSupplierName().equals(SUPPLIER_C_TRIP)) {
cTripOrderRecordAutoSave.saveAllByDate(date);
} else if (recordMonthSaveDTO.getSupplierName().equals(SUPPLIER_AMAP)) {
orderRecordDomainService.saveAllAmapCarOrderRecord(date);
}
//将昨天的结算数据生成为财务共享需要的数据
Command.of(OrderRecordGenerateCommand.class)
.startTime(DateTimeUtil.firstDayOfMonth(date))
.endTime(DateTimeUtil.endDayOfMonth(date))
.date(date)
.supplierName(recordMonthSaveDTO.getSupplierName())
.sendToQueue();
return Result.Success(SUCCESS);
}
@Transactional
@ApiOperation("根据月份生成结算记录")
@PostMapping("/record/save/month")
public Result<String> autoSaveRecordByMonth(@RequestBody RecordMonthSaveDTO recordMonthSaveDTO) {
String date = recordMonthSaveDTO.getDate();
//将昨天的结算数据生成为财务共享需要的数据
Command.of(OrderRecordGenerateCommand.class)
.startTime(DateTimeUtil.firstDayOfMonth(date))
.endTime(DateTimeUtil.endDayOfMonth(date))
.date(date)
.supplierName(recordMonthSaveDTO.getSupplierName())
.sendToQueue();
return Result.Success(SUCCESS);
}
@ApiOperation("自动拉取同程上个月的流水号")
@PostMapping("/ly/record/save")
public Result<String> autoSaveLYRecord() {

View File

@ -39,6 +39,7 @@ import static com.chint.infrastructure.constant.CommonMessageConstant.LEG_LOCATI
import static com.chint.infrastructure.constant.CommonMessageConstant.NO_PRICE_ERROR;
import static com.chint.infrastructure.constant.LocationConstant.LOCATION_LEVEL_COUNTY;
import static com.chint.infrastructure.constant.RankConstant.STANDARD_LEVEL_ONE;
import static com.chint.infrastructure.constant.UtilConstant.KEEP_TWO_DECIMAL_ZERO;
@Component
public class CTripEstimatePrice implements EstimatePrice {
@ -262,7 +263,8 @@ public class CTripEstimatePrice implements EstimatePrice {
Boolean success = estimate.getStatus().getSuccess();
if (success) {
HotelValuationResult hotelValuationResult = estimate.getData().getHotelValuationResult();
String price = hotelValuationResult.getMaxPrice().toString();
BigDecimal maxPrice = hotelValuationResult.getMaxPrice();
String price = maxPrice == null ? KEEP_TWO_DECIMAL_ZERO : maxPrice.toString(); ;
if (Double.parseDouble(price) == 0) {
hotelPriceData.setSuccess(false);

View File

@ -4,7 +4,6 @@ package com.chint.domain.aggregates.order;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Transient;
import org.springframework.data.relational.core.mapping.MappedCollection;
import org.springframework.data.relational.core.mapping.Table;
@ -165,6 +164,11 @@ public class HotelOrderDetail implements Serializable {
if (this.customers == null) {
this.customers = new ArrayList<>();
}
if (this.customers.stream().anyMatch(it -> it.getUserName().equals(customer.getUserName()) &&
it.getPhone().equals(customer.getPhone()) &&
it.getUserCode().equals(customer.getUserCode()))) {
return this;
}
this.customers.add(customer);
return this;
}

View File

@ -8,6 +8,9 @@ import org.springframework.data.relational.core.mapping.Table;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;
import java.util.Optional;
import static com.chint.infrastructure.constant.LegConstant.*;
@Data
@Table("supplier")
@ -20,4 +23,29 @@ public class Supplier implements Serializable {
private String cnName;
@MappedCollection(idColumn = "supplier_id", keyColumn = "supplier_key")
private List<SupplierProduct> supplierProductList;
public Optional<SupplierProduct> carSupplierProduct() {
return getSupplierProductByProductType(LEG_TYPE_TAXI);
}
public Optional<SupplierProduct> hotelSupplierProduct() {
return getSupplierProductByProductType(LEG_TYPE_HOTEL);
}
public Optional<SupplierProduct> flightSupplierProduct() {
return getSupplierProductByProductType(LEG_TYPE_AIRPLANE);
}
public Optional<SupplierProduct> trainSupplierProduct() {
return getSupplierProductByProductType(LEG_TYPE_TRAIN);
}
private Optional<SupplierProduct> getSupplierProductByProductType(Integer productType) {
if (supplierProductList == null || supplierProductList.isEmpty()) {
return Optional.empty();
} else {
return supplierProductList.stream()
.filter(it -> it.getProductType().equals(productType)).findFirst();
}
}
}

View File

@ -3,10 +3,12 @@ package com.chint.domain.aggregates.supplier;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.relational.core.mapping.MappedCollection;
import org.springframework.data.relational.core.mapping.Table;
import java.io.Serial;
import java.io.Serializable;
import java.util.List;
@Data
@Table("supplier_product")
@ -20,4 +22,6 @@ public class SupplierProduct implements Serializable {
private Integer productType;
private Integer ifCanOrder;
private String ifCanCancelRule;
@MappedCollection(idColumn = "supplier_product_id", keyColumn = "supplier_product_key")
private List<SupplierProductStandardLevel> supplierProductStandardLevelList;
}

View File

@ -0,0 +1,26 @@
package com.chint.domain.aggregates.supplier;
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("supplier_product_standard_level")
public class SupplierProductStandardLevel implements Serializable {
@Serial
private static final long serialVersionUID = 1864551962257811354L;
@Id
private Long id;
private Long supplierProductId;
private Long standardLevelId;
private String standardLevelName;
private Integer status;
private String extension;
public boolean inUse() {
return status == 1;
}
}

View File

@ -1,19 +1,128 @@
package com.chint.domain.factoriy.order_record;
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.amap_order_record.AmapCarOrderRecord;
import com.chint.infrastructure.util.BigDecimalCalculator;
import com.chint.interfaces.rest.amap.dto.settlement.FinishedOrderResponse;
import org.springframework.stereotype.Component;
import java.util.Optional;
import static com.chint.infrastructure.constant.UtilConstant.KEEP_TWO_DECIMAL_ZERO;
@Component
public class AmapOrderRecordExtensionFactory implements OrderRecordExtensionFactory {
private final String isCancel = "取消费订单";
private final String isNotCancel = "非取消费订单";
private OrderRecordBasic buildWithRecord(Object orderCarRecordData) {
AmapCarOrderRecord carRecordData = (AmapCarOrderRecord) orderCarRecordData;
OrderRecordBasic orderRecordBasic = new OrderRecordBasic();
orderRecordBasic.loadBookingInfo(carRecordData.getEUserId(),
carRecordData.getRealName(),
null,
carRecordData.getRealName(),
carRecordData.getEUserId()
);
return orderRecordBasic;
}
@Override
public OrderCarRecord createCarOrderRecord(Object orderCarRecordData, Optional<RouteOrder> routeOrder) {
AmapCarOrderRecord carRecordData = (AmapCarOrderRecord) orderCarRecordData;
OrderCarRecord orderCarRecord = buildWithRecord(orderCarRecordData).carRecord();
Optional<OrderDetail> orderDetail = routeOrder
.stream()
.flatMap(order -> order
.getOrderDetails()
.stream()
.filter(it -> it.getOrderNo().equals(carRecordData.getAmapOrderId())))
.findFirst();
String orderStatus;
if (carRecordData.getIsCancelFeeOrder().equals(isCancel)) {
orderStatus = "3";
} else {
orderStatus = "1";
}
orderCarRecord.loadBasicOrderInfo(carRecordData.getAmapOrderId(),
orderStatus,
carRecordData.getGmtCreate())
.loadBelongDeport(
routeOrder.stream().flatMap(order ->
Optional.ofNullable(order.getRouterOrderExtensionField().getBelongDeptCode()).stream()
).findFirst().orElseGet(carRecordData::getDepartmentId)
);
String ds = carRecordData.getDs();
orderCarRecord.loadTravelInfo(
carRecordData.getGmtCreateStartTime106(),
carRecordData.getGmtCreateEndTime106(),
carRecordData.getCityName(),
carRecordData.getEndCity(),
carRecordData.getStartName(),
carRecordData.getEndName()
).loadVehicleAndTravelInfo(
carRecordData.getAmapRideType(),
orderDetail.flatMap(it -> Optional.ofNullable(it.getCarOrderDetail().getRunTime())).orElse(KEEP_TWO_DECIMAL_ZERO),
String.valueOf(carRecordData.getMileage())
).loadFinancialInfo(
ds.substring(0, 6),
ds,
String.valueOf(carRecordData.getOrderAmount()),
BigDecimalCalculator.add(String.valueOf(carRecordData.getOrderAmount()), String.valueOf(carRecordData.getServicefee()))
).loadFeeDetails(
"",
"",
String.valueOf(carRecordData.getServicefee()),
String.valueOf(carRecordData.getCancelFee()),
String.valueOf(carRecordData.getHighwayFee()),
""
);
Double enterpriseAmount = carRecordData.getEnterpriseAmount();
Double individualAmount = carRecordData.getIndividualAmount();
String paymentType;
if (enterpriseAmount > 0 && enterpriseAmount < carRecordData.getOrderAmount()) {
paymentType = "2"; // 企业支付部分个人支付部分
} else if (enterpriseAmount.equals(carRecordData.getOrderAmount())) {
paymentType = "0"; // 全部由企业支付
} else {
paymentType = "1"; // 全部由个人支付
}
String outApplyRecordId = carRecordData.getOutApplyRecordId();
orderCarRecord.loadPayment(
paymentType,
String.valueOf(enterpriseAmount),
String.valueOf(individualAmount)
).loadOrganizationalInfo(
carRecordData.getDep1(),
carRecordData.getDep2(),
carRecordData.getDep3()
).loadSource(
outApplyRecordId == null || outApplyRecordId.isEmpty() ? "N" : "Y"
).loadRelatedOrderInfo(
orderDetail.flatMap(it -> Optional.ofNullable(it.getOrderId())).orElse(Long.parseLong(carRecordData.getAmapOrderId())),
carRecordData.getAmapOrderId(),
carRecordData.getOutApplyRecordId(),
carRecordData.getOutApplyRecordId(),
carRecordData.getAmapOrderId(),
carRecordData.getAmapOrderId()
);
orderDetail.ifPresentOrElse(orderCarRecord::loadComplianceInfo, orderCarRecord::loadComplianceInfoNot);
return orderCarRecord;
}
@Override
public OrderCarRecord createCarOrderRecord(Object orderCarRecordData) {
@ -43,19 +152,6 @@ public class AmapOrderRecordExtensionFactory implements OrderRecordExtensionFact
return null;
}
private OrderRecordBasic buildWithRecord(Object orderCarRecordData) {
FinishedOrderResponse.ListElement carRecordData = (FinishedOrderResponse.ListElement) orderCarRecordData;
OrderRecordBasic orderRecordBasic = new OrderRecordBasic();
// orderRecordBasic.loadBookingInfo(
// carRecordData.get
// )
return null;
}
@Override
public OrderCarRecord createCarOrderRecord(Object orderCarRecordData, Optional<RouteOrder> routeOrder) {
return null;
}
@Override
public OrderTrainRecord createTrainOrderRecord(Object orderTrainRecordData, Optional<RouteOrder> routeOrder) {

View File

@ -0,0 +1,12 @@
package com.chint.domain.repository;
import com.chint.domain.aggregates.order.order_record.amap_order_record.AmapCarOrderRecord;
import java.util.List;
public interface AmapCarOrderRecordRepository {
List<AmapCarOrderRecord> saveAll(List<AmapCarOrderRecord> records);
List<AmapCarOrderRecord> findByDs(String ds);
}

View File

@ -4,10 +4,10 @@ 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.repository.OrderCarRecordRepository;
import com.chint.domain.repository.OrderFlightRecordRepository;
import com.chint.domain.repository.OrderHotelRecordRepository;
import com.chint.domain.repository.OrderTrainRecordRepository;
import com.chint.domain.aggregates.order.order_record.amap_order_record.AmapCarOrderRecord;
import com.chint.domain.repository.*;
import com.chint.interfaces.rest.amap.dto.settlement.FinishedOrderResponse;
import com.chint.interfaces.rest.amap.request.AmapSettleBillRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -29,6 +29,12 @@ public class OrderRecordDomainService {
@Autowired
private SystemDomainService systemDomainService;
@Autowired
private AmapCarOrderRecordRepository amapCarOrderRecordRepository;
@Autowired
private AmapSettleBillRequest amapSettleBillRequest;
@Transactional
public void reloadClerkAndSave(String accountPeriod) {
List<OrderCarRecord> orderCarRecordList = orderCarRecordRepository.findByAccountPeriod(accountPeriod);
@ -49,4 +55,10 @@ public class OrderRecordDomainService {
}
public void saveAllAmapCarOrderRecord(String date) {
List<FinishedOrderResponse.ListElement> listElements = amapSettleBillRequest.amapRecordByMonth(date);
List<AmapCarOrderRecord> list = listElements.stream().map(AmapCarOrderRecord::of).toList();
amapCarOrderRecordRepository.saveAll(list);
}
}

View File

@ -1,14 +1,46 @@
package com.chint.domain.service.order_record;
import com.chint.application.commands.OrderRecordGenerateCommand;
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.amap_order_record.AmapCarOrderRecord;
import com.chint.domain.aggregates.order.order_record.ctrip_order_record.CTripHotelRecord;
import com.chint.domain.factoriy.order_record.OrderRecordExtensionFactory;
import com.chint.domain.factoriy.order_record.OrderRecordFactorySelector;
import com.chint.domain.repository.AmapCarOrderRecordRepository;
import com.chint.domain.service.OrderDetailDomainService;
import com.chint.domain.service.RouteRequestDomainService;
import com.chint.infrastructure.echo_framework.annotation.ListenTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.Function;
import java.util.stream.Collectors;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
@Component
public class AmapOrderRecordDomainService implements OrderRecordDomainService{
@Autowired
private AmapCarOrderRecordRepository aMapCarOrderRecordRepository;
@Autowired
private OrderRecordFactorySelector orderRecordFactorySelector;
@Autowired
private RouteRequestDomainService routeRequestDomainService;
@Autowired
private OrderDetailDomainService orderDetailDomainService;
@Override
public List<OrderHotelRecord> generateHotelRecord(OrderRecordGenerateCommand command) {
return List.of();
@ -24,8 +56,23 @@ public class AmapOrderRecordDomainService implements OrderRecordDomainService{
return List.of();
}
@ListenTo(command = "OrderRecordGenerateCommand", order = 0)
@Override
public List<OrderCarRecord> generateCarRecord(OrderRecordGenerateCommand command) {
return List.of();
if (!command.getSupplierName().equals(SUPPLIER_AMAP)) {
return List.of();
}
List<AmapCarOrderRecord> amapCarOrderRecordList = aMapCarOrderRecordRepository.findByDs(command.getDate());
OrderRecordExtensionFactory orderRecordExtensionFactory = orderRecordFactorySelector.extensionFactoryOfSupplierName(SUPPLIER_C_TRIP);
List<String> routeOrderNoList = amapCarOrderRecordList.stream().map(AmapCarOrderRecord::getOutApplyRecordId).distinct().toList();
List<RouteOrder> routeOrderList = routeRequestDomainService.getRouteOrder(routeOrderNoList);
// 根据RouteOrder的checkIfMine方法创建一个包含自己订单的Map
Map<String, Optional<RouteOrder>> collect = routeOrderNoList.parallelStream().collect(Collectors.toMap(Function.identity(),
it -> routeOrderList.stream().filter(routeOrder -> routeOrder != null && routeOrder.checkIfMine(it)).findFirst()));
List<OrderCarRecord> orderCarRecordList = amapCarOrderRecordList
.stream()
.map(it -> orderRecordExtensionFactory.createCarOrderRecord(it, collect.get(it.getOutApplyRecordId())))
.toList();
return orderDetailDomainService.saveCarOrderRecordBatch(orderCarRecordList);
}
}

View File

@ -40,7 +40,6 @@ public class CTripOrderRecordDomainService implements OrderRecordDomainService {
private CTripOrderDetailRepository cTripOrderDetailRepository;
@Autowired
private OrderRecordFactorySelector orderRecordFactorySelector;
@Autowired
private RouteRequestDomainService routeRequestDomainService;
@ -50,6 +49,9 @@ public class CTripOrderRecordDomainService implements OrderRecordDomainService {
@ListenTo(command = "OrderRecordGenerateCommand", order = 0)
@Override
public List<OrderHotelRecord> generateHotelRecord(OrderRecordGenerateCommand command) {
if (!command.getSupplierName().equals(SUPPLIER_C_TRIP)) {
return List.of();
}
List<CTripHotelRecord> records = cTripOrderDetailRepository.findHotelRecordByCreateTime(command.getStartTime(), command.getEndTime());
OrderRecordExtensionFactory orderRecordExtensionFactory = orderRecordFactorySelector.extensionFactoryOfSupplierName(SUPPLIER_C_TRIP);
List<String> routeOrderNoList = records.stream().map(CTripHotelRecord::getRouteOrderNo).distinct().toList();
@ -73,13 +75,16 @@ public class CTripOrderRecordDomainService implements OrderRecordDomainService {
@ListenTo(command = "OrderRecordGenerateCommand", order = 1)
@Override
public List<OrderFlightRecord> generateFlightRecord(OrderRecordGenerateCommand command) {
if (!command.getSupplierName().equals(SUPPLIER_C_TRIP)) {
return List.of();
}
List<CTripFlightRecord> records = cTripOrderDetailRepository.findFlightRecordByCreateTime(command.getStartTime(), command.getEndTime());
OrderRecordExtensionFactory orderRecordExtensionFactory = orderRecordFactorySelector.extensionFactoryOfSupplierName(SUPPLIER_C_TRIP);
List<String> routeOrderNoList = records.stream().map(CTripFlightRecord::getRouteOrderNo).distinct().toList();
List<RouteOrder> routeOrderList = routeRequestDomainService.getRouteOrder(routeOrderNoList);
// 根据RouteOrder的checkIfMine方法创建一个包含自己订单的Map
Map<String, Optional<RouteOrder>> collect = routeOrderNoList.parallelStream().collect(Collectors.toMap(Function.identity(),
it -> routeOrderList.stream().filter(routeOrder ->routeOrder != null && routeOrder.checkIfMine(it)).findFirst()));
it -> routeOrderList.stream().filter(routeOrder -> routeOrder != null && routeOrder.checkIfMine(it)).findFirst()));
List<OrderFlightRecord> orderFlightRecordList = records
.stream()
.map(it -> orderRecordExtensionFactory.createFlightOrderRecord(it, collect.get(it.getRouteOrderNo())))
@ -90,13 +95,16 @@ public class CTripOrderRecordDomainService implements OrderRecordDomainService {
@ListenTo(command = "OrderRecordGenerateCommand", order = 2)
@Override
public List<OrderCarRecord> generateCarRecord(OrderRecordGenerateCommand command) {
if (!command.getSupplierName().equals(SUPPLIER_C_TRIP)) {
return List.of();
}
List<CTripCarRecord> records = cTripOrderDetailRepository.findCarRecordByCreateTime(command.getStartTime(), command.getEndTime());
OrderRecordExtensionFactory orderRecordExtensionFactory = orderRecordFactorySelector.extensionFactoryOfSupplierName(SUPPLIER_C_TRIP);
List<String> routeOrderNoList = records.stream().map(CTripCarRecord::getRouteOrderNo).distinct().toList();
List<RouteOrder> routeOrderList = routeRequestDomainService.getRouteOrder(routeOrderNoList);
// 根据RouteOrder的checkIfMine方法创建一个包含自己订单的Map
Map<String, Optional<RouteOrder>> collect = routeOrderNoList.parallelStream().collect(Collectors.toMap(Function.identity(),
it -> routeOrderList.stream().filter(routeOrder ->routeOrder != null && routeOrder.checkIfMine(it)).findFirst()));
it -> routeOrderList.stream().filter(routeOrder -> routeOrder != null && routeOrder.checkIfMine(it)).findFirst()));
List<OrderCarRecord> orderCarRecordList = records
.stream()
.map(it -> orderRecordExtensionFactory.createCarOrderRecord(it, collect.get(it.getRouteOrderNo())))

View File

@ -2,10 +2,14 @@ package com.chint.domain.service.order_sync;
import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.supplier.AmapRouteRelationship;
import com.chint.domain.aggregates.supplier.Supplier;
import com.chint.domain.aggregates.supplier.SupplierProductStandardLevel;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.exceptions.AuthException;
import com.chint.domain.exceptions.CommandException;
import com.chint.domain.repository.AmapPolicyRepository;
import com.chint.domain.repository.AmapRouteRelationshipRepository;
import com.chint.domain.repository.SupplierRepository;
import com.chint.domain.repository.UserRepository;
import com.chint.domain.service.LegDomainService;
import com.chint.infrastructure.util.DateTimeUtil;
@ -26,6 +30,7 @@ import java.util.List;
import java.util.Optional;
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TAXI;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP;
@Slf4j
@Component
@ -49,6 +54,9 @@ public class AmapOrderSyncAdapter implements SupplierOrderSync {
@Autowired
private AmapPolicyRepository amapPolicyRepository;
@Autowired
private SupplierRepository supplierRepository;
private Gson gson = new Gson();
@Override
@ -139,9 +147,19 @@ public class AmapOrderSyncAdapter implements SupplierOrderSync {
dto.setProcessContent(gson.toJson(processContent));
dto.setStatus("1");
amapPolicyRepository.findByStandardLevel(routeRequestFields.getStandardLevel())
.ifPresent(policy -> dto.setRegulationId(policy.getAmapPolicyCode()));
Optional<Supplier> supplier = supplierRepository.findBySupplierName(SUPPLIER_AMAP);
supplier.flatMap(Supplier::carSupplierProduct).ifPresent(carSupplierProduct -> {
if (carSupplierProduct.getSupplierProductStandardLevelList()
.stream()
.filter(SupplierProductStandardLevel::inUse)
.map(SupplierProductStandardLevel::getStandardLevelName)
.anyMatch(standardLevel -> standardLevel.equals(routeRequestFields.getStandardLevel()))) {
amapPolicyRepository.findByStandardLevel(routeRequestFields.getStandardLevel())
.ifPresent(policy -> dto.setRegulationId(policy.getAmapPolicyCode()));
} else {
throw new AuthException("你目前的差标不支持使用高德打车");
}
});
return dto;
}

View File

@ -0,0 +1,29 @@
package com.chint.infrastructure.repository;
import com.chint.domain.aggregates.order.order_record.amap_order_record.AmapCarOrderRecord;
import com.chint.domain.repository.AmapCarOrderRecordRepository;
import com.chint.infrastructure.repository.jdbc.JdbcAmapCarOrderRecordRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import java.util.ArrayList;
import java.util.List;
@Repository
public class AmapCarOrderRecordRepositoryImpl implements AmapCarOrderRecordRepository {
@Autowired
private JdbcAmapCarOrderRecordRepository jdbcAmapCarOrderRecordRepository;
@Override
public List<AmapCarOrderRecord> saveAll(List<AmapCarOrderRecord> records) {
List<AmapCarOrderRecord> res = new ArrayList<>();
jdbcAmapCarOrderRecordRepository.saveAll(records).forEach(res::add);
return res;
}
@Override
public List<AmapCarOrderRecord> findByDs(String ds) {
return jdbcAmapCarOrderRecordRepository.findByDsContaining(ds);
}
}

View File

@ -0,0 +1,12 @@
package com.chint.infrastructure.repository.jdbc;
import com.chint.domain.aggregates.order.order_record.amap_order_record.AmapCarOrderRecord;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface JdbcAmapCarOrderRecordRepository extends CrudRepository<AmapCarOrderRecord, Long> {
List<AmapCarOrderRecord> findByDsContaining(String ds);
}

View File

@ -7,14 +7,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import static com.chint.infrastructure.constant.AmapConstant.FINISHED_ORDER_URL;
@Component
public class SettleBillRequest {
public class AmapSettleBillRequest {
@Value("${amap.baseUrl}")
private String baseUrl;
@ -49,12 +48,16 @@ public class SettleBillRequest {
}
public List<FinishedOrderResponse.ListElement> amapRecordLastMonth(){
public List<FinishedOrderResponse.ListElement> amapRecordLastMonth() {
String lastMonthStr = DateTimeUtil.lastMonthStr();
LocalDateTime firstDayOfMonth = DateTimeUtil.firstDayOfMonth(lastMonthStr);
LocalDateTime endDayOfMonth = DateTimeUtil.endDayOfMonth(lastMonthStr);
return null;
String firstDayOfMonth = DateTimeUtil.timeToStrYYYYMMDD(DateTimeUtil.firstDayOfMonth(lastMonthStr));
String endDayOfMonth = DateTimeUtil.timeToStrYYYYMMDD(DateTimeUtil.endDayOfMonth(lastMonthStr));
return pageFinishedOrder(firstDayOfMonth, endDayOfMonth);
}
public List<FinishedOrderResponse.ListElement> amapRecordByMonth(String date) {
String firstDayOfMonth = DateTimeUtil.timeToStrYYYYMMDD(DateTimeUtil.firstDayOfMonth(date));
String endDayOfMonth = DateTimeUtil.timeToStrYYYYMMDD(DateTimeUtil.endDayOfMonth(date));
return pageFinishedOrder(firstDayOfMonth, endDayOfMonth);
}
}

View File

@ -13,10 +13,9 @@ import com.chint.interfaces.rest.amap.BaseResponse;
import com.chint.interfaces.rest.amap.dto.UserQueryResponse;
import com.chint.interfaces.rest.amap.dto.detail.AmapOrderDetailResponse;
import com.chint.interfaces.rest.amap.dto.location.LocationResponse;
import com.chint.interfaces.rest.amap.dto.settlement.FinishedOrderResponse;
import com.chint.interfaces.rest.amap.dto.token.TokenResponse;
import com.chint.interfaces.rest.amap.request.AmapOrderDetailRequest;
import com.chint.interfaces.rest.amap.request.SettleBillRequest;
import com.chint.interfaces.rest.amap.request.AmapSettleBillRequest;
import com.chint.interfaces.rest.amap.request.TakeCarRequest;
import com.chint.interfaces.rest.amap.request.TokenRequest;
import com.chint.interfaces.rest.base.dto.H5LoginResponse;
@ -26,7 +25,6 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
import java.util.Optional;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP;
@ -56,7 +54,7 @@ public class AmapTest {
@Autowired
private SettleBillRequest settleBillRequest;
private AmapSettleBillRequest settleBillRequest;
@Test
public void search() {

View File

@ -246,7 +246,7 @@ public class CTripTest {
@Test
void search() {
BaseContext.setCurrentUser(user);
SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("32527114975");
SearchOrderResponse response = orderSearchRequest.searchOrderResponseByOrderId("31674878596");
System.out.println(response);
}

View File

@ -828,7 +828,7 @@ public class LYTest {
@Test
void searchHotel() {
HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240330143900871266");
HotelDetailResponse hotelOrderDetail = lySearchRequest.getHotelOrderDetail("HO20240523153100458921");
Gson gson = new Gson();
String json = gson.toJson(hotelOrderDetail);
System.out.println(json);

View File

@ -299,10 +299,10 @@ class RouteApplicationTests {
@Test
void loginSign() {
String sfno = "220531010";
String sfno = "030710001";
String syscode = "FSSC";
String billcode = "CLSQ240225000099";
String companycode = "A70000021";
String companycode = "正泰集团股份有限公司";
String timespan = "1708908662738";
String s = Digest.md5(sfno + syscode + billcode + companycode + LOGIN_SECRET_KEY + timespan);
System.out.println(s);