diff --git a/src/main/java/com/chint/domain/aggregates/user/UserDepartmentInfo.java b/src/main/java/com/chint/domain/aggregates/user/UserDepartmentInfo.java index 5a25c6a3..9621142f 100644 --- a/src/main/java/com/chint/domain/aggregates/user/UserDepartmentInfo.java +++ b/src/main/java/com/chint/domain/aggregates/user/UserDepartmentInfo.java @@ -8,8 +8,6 @@ import org.springframework.data.relational.core.mapping.Table; import java.io.Serial; import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; import java.util.Objects; @Data @@ -51,7 +49,7 @@ public class UserDepartmentInfo implements Serializable { private String custQualityLevel; private String status; - public boolean ifPrimary(){ + public boolean ifPrimary() { return ifPrimary == 1; } @@ -256,4 +254,14 @@ public class UserDepartmentInfo implements Serializable { } } + public boolean checkIfIn(String orgShortCode) { + return this.companyCode.contains(orgShortCode) || + this.departmentCodeOne.contains(orgShortCode) || + this.departmentCodeTwo.contains(orgShortCode) || + this.departmentCodeThree.contains(orgShortCode) || + this.departmentCodeFour.contains(orgShortCode) || + this.departmentCodeFive.contains(orgShortCode) || + this.departmentCodeSix.contains(orgShortCode) || + this.departmentCodeSeven.contains(orgShortCode); + } } diff --git a/src/main/java/com/chint/domain/factoriy/order_detail/AmapOrderExtensionFactoryImpl.java b/src/main/java/com/chint/domain/factoriy/order_detail/AmapOrderExtensionFactoryImpl.java index 7ac804db..ce52b9b4 100644 --- a/src/main/java/com/chint/domain/factoriy/order_detail/AmapOrderExtensionFactoryImpl.java +++ b/src/main/java/com/chint/domain/factoriy/order_detail/AmapOrderExtensionFactoryImpl.java @@ -3,10 +3,12 @@ package com.chint.domain.factoriy.order_detail; import cn.hutool.core.bean.BeanUtil; import com.chint.domain.aggregates.order.*; import com.chint.domain.aggregates.user.User; +import com.chint.domain.aggregates.user.UserDepartmentInfo; import com.chint.domain.repository.OrderDetailRepository; import com.chint.domain.repository.RouteRepository; import com.chint.domain.repository.UserRepository; import com.chint.domain.service.RouteRequestDomainService; +import com.chint.infrastructure.util.BigDecimalCalculator; import com.chint.interfaces.rest.amap.dto.detail.AmapOrderDetailResponse; import com.chint.interfaces.rest.amap.request.AmapOrderDetailRequest; import org.springframework.beans.factory.annotation.Autowired; @@ -14,9 +16,12 @@ import org.springframework.stereotype.Component; import java.math.BigDecimal; import java.math.RoundingMode; +import java.util.List; import static com.chint.infrastructure.constant.BelongSystemConstant.TRAVAL_SYS_TYPE_AMAP; import static com.chint.infrastructure.constant.FSSCConstant.FSSC_CAR_STATUS_SUCCESS; +import static com.chint.infrastructure.constant.OrderConstant.ORDER_EVENT_ETA; +import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP_CN_NAME; import static com.chint.interfaces.rest.amap.util.AmapStatusUtil.mapFSSCOrderStatus; @@ -54,6 +59,20 @@ public class AmapOrderExtensionFactoryImpl implements OrderExtensionFactory { RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(data.getRequestRouterNo()); CarOrderDetail carOrderDetail = BeanUtil.copyProperties(orderDetailFactory.buildWithRouteOrder(routeOrder), CarOrderDetail.class); + + routeOrder.getOrderDetails() + .stream() + .filter(it -> it.getOrderNo().equals(orderNo)) + .findFirst() + .ifPresent(orderDetail -> orderDetail.getOrderEventList() + .stream() + .filter(it -> it.getEventType().equals(ORDER_EVENT_ETA)) + .findFirst() + .ifPresentOrElse(it -> { + carOrderDetail.setOverStandard("是"); + carOrderDetail.setOverStandardReason(it.getExtension()); + }, () -> carOrderDetail.setOverStandard("否"))); + carOrderDetail.setOrderNo(orderNo); carOrderDetail.setDetailId(orderNo); @@ -62,11 +81,27 @@ public class AmapOrderExtensionFactoryImpl implements OrderExtensionFactory { carOrderDetail.setBookingName(user.getName()); carOrderDetail.setBookingUserPhone(data.getMobile()); + + List userDepartmentInfoList = user.getUserDepartmentInfoList(); + UserDepartmentInfo userDepartmentInfo = userDepartmentInfoList.stream().filter(it -> it.checkIfIn(routeOrder.getRouterOrderExtensionField().getBelongDeptCode())) + .findFirst() + .orElseGet(() -> userDepartmentInfoList.stream().filter(UserDepartmentInfo::ifPrimary).findFirst().orElse(null)); + + if (userDepartmentInfo != null) { + carOrderDetail.setBOOK_ORG_STRUCT_1(userDepartmentInfo.getCompanyName()); + carOrderDetail.setBOOK_ORG_STRUCT_2(userDepartmentInfo.getDepartmentNameOne()); + carOrderDetail.setBOOK_ORG_STRUCT_3(userDepartmentInfo.getDepartmentNameTwo()); + } + + //这里要更新用车的状态 carOrderDetail.setOrderStatus(mapFSSCOrderStatus(data.getShowStatus())); - carOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_AMAP); - return updateCarOrderDetailData(carOrderDetail, carOrderDetailData); + updateCarOrderDetailData(carOrderDetail, carOrderDetailData); + if (carOrderDetail.getUserName() == null) { + carOrderDetail.setUserName(user.getName()); + } + return carOrderDetail; } @Override @@ -83,8 +118,8 @@ public class AmapOrderExtensionFactoryImpl implements OrderExtensionFactory { //金额 BigDecimal amountCent = BigDecimal.valueOf(data.getEnterpriseAmount() + data.getPersonAmount()); carOrderDetail.setOrderAmount(String.valueOf(amountCent.divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP))); - carOrderDetail.setCompanyPaymentAmount(String.valueOf(data.getEnterpriseAmount())); - carOrderDetail.setPersonalPaymentAmount(String.valueOf(data.getPersonAmount())); + carOrderDetail.setCompanyPaymentAmount(BigDecimalCalculator.divide(String.valueOf(data.getEnterpriseAmount()), "100")); + carOrderDetail.setPersonalPaymentAmount(BigDecimalCalculator.divide(String.valueOf(data.getPersonAmount()), "100")); if (data.getPersonAmount() == 0 && data.getEnterpriseAmount() > 0) { carOrderDetail.setPaymentType("0"); @@ -111,6 +146,8 @@ public class AmapOrderExtensionFactoryImpl implements OrderExtensionFactory { carOrderDetail.setToCity(data.getEndCity()); carOrderDetail.setCarModel(data.getCarType()); } + + carOrderDetail.setSupplier(SUPPLIER_AMAP_CN_NAME); return carOrderDetail; } diff --git a/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactoryImpl.java b/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactoryImpl.java index 563b4ec5..53a5bb9a 100644 --- a/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactoryImpl.java +++ b/src/main/java/com/chint/domain/factoriy/order_detail/OrderDetailFactoryImpl.java @@ -63,13 +63,6 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory { baseOrderExtension.setBookingName(user.getName()); baseOrderExtension.setBookingUserPhone(user.getPhoneNumber()); - //配置供应商信息 -// String supplierName = routeOrder.getSupplierName(); -// if (supplierName.equals(SUPPLIER_C_TRIP)) { -// baseOrderExtension.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP); -// } else { -// baseOrderExtension.setTrvaleSysType(TRAVAL_SYS_TYPE_LY); -// } ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo(); if (approveOrderNo != null) { diff --git a/src/main/java/com/chint/domain/factoriy/order_record/AmapOrderRecordExtensionFactory.java b/src/main/java/com/chint/domain/factoriy/order_record/AmapOrderRecordExtensionFactory.java index cc786a89..da8f21a5 100644 --- a/src/main/java/com/chint/domain/factoriy/order_record/AmapOrderRecordExtensionFactory.java +++ b/src/main/java/com/chint/domain/factoriy/order_record/AmapOrderRecordExtensionFactory.java @@ -29,6 +29,10 @@ public class AmapOrderRecordExtensionFactory implements OrderRecordExtensionFact @Override public OrderCarRecord createCarOrderRecord(Object orderCarRecordData) { FinishedOrderResponse.ListElement carRecordData = (FinishedOrderResponse.ListElement) orderCarRecordData; + OrderRecordBasic orderRecordBasic = new OrderRecordBasic(); +// orderRecordBasic.loadBookingInfo( +// +// ) return null;