feat:添加高德消费明细回推功能
This commit is contained in:
parent
a20503afd9
commit
0f3f9618c6
|
@ -0,0 +1,24 @@
|
|||
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("amap_policy")
|
||||
public class AmapPolicy implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 98723461917034612L;
|
||||
@Id
|
||||
private Long id;
|
||||
private String amapPolicyCode;
|
||||
private Integer ifDefault;
|
||||
private Integer status;
|
||||
@MappedCollection(idColumn = "amap_policy_id", keyColumn = "amap_policy_key")
|
||||
private List<AmapPolicyOrg> amapPolicyOrgList;
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
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("amap_policy_org")
|
||||
public class AmapPolicyOrg implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 962936458352934612L;
|
||||
@Id
|
||||
private Long id;
|
||||
private Long amapPolicyId;
|
||||
private Long orgId;
|
||||
private String orgCode;
|
||||
}
|
|
@ -2,20 +2,19 @@ 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("amap_route_relationship")
|
||||
public class AmapRouteRelationship implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long serialVersionUID = 1908273612230514678L;
|
||||
@Id
|
||||
private Long id;
|
||||
private String applyRecordId;
|
||||
private String outApplyRecordId;
|
||||
private String amapPolicyCode;
|
||||
}
|
||||
|
|
|
@ -1,30 +1,30 @@
|
|||
package com.chint.domain.factoriy.order_detail;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.chint.domain.aggregates.order.*;
|
||||
import com.chint.domain.exceptions.NotFoundException;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.repository.OrderDetailRepository;
|
||||
import com.chint.domain.repository.RouteRepository;
|
||||
import com.chint.interfaces.rest.amap.dto.detail.OrderDetailResponse;
|
||||
import com.chint.interfaces.rest.amap.request.OrderDetailRequest;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.car.Address;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.car.CarQuickOrderInfoEntity;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.car.OrderFee;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.car.Vehicle;
|
||||
import com.chint.domain.repository.UserRepository;
|
||||
import com.chint.domain.service.RouteRequestDomainService;
|
||||
import com.chint.interfaces.rest.amap.dto.detail.AmapOrderDetailResponse;
|
||||
import com.chint.interfaces.rest.amap.request.AmapOrderDetailRequest;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static com.chint.infrastructure.constant.BelongSystemConstant.TRAVAL_SYS_TYPE_CTRIP;
|
||||
import static com.chint.infrastructure.constant.CommonMessageConstant.NOT_FOUND;
|
||||
import static com.chint.infrastructure.constant.FSSCConstant.*;
|
||||
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.interfaces.rest.amap.util.AmapStatusUtil.mapFSSCOrderStatus;
|
||||
|
||||
|
||||
@Component
|
||||
public class AmapOrderExtensionFactoryImpl implements OrderExtensionFactory{
|
||||
public class AmapOrderExtensionFactoryImpl implements OrderExtensionFactory {
|
||||
|
||||
@Autowired
|
||||
private OrderDetailRequest orderDetailRequest;
|
||||
private AmapOrderDetailRequest orderDetailRequest;
|
||||
|
||||
@Autowired
|
||||
private RouteRequestDomainService routeRequestDomainService;
|
||||
|
||||
@Autowired
|
||||
private OrderDetailRepository orderDetailRepository;
|
||||
|
@ -32,68 +32,60 @@ public class AmapOrderExtensionFactoryImpl implements OrderExtensionFactory{
|
|||
@Autowired
|
||||
private RouteRepository routeRepository;
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@Autowired
|
||||
private OrderDetailFactory orderDetailFactory;
|
||||
|
||||
@Override
|
||||
public CarOrderDetail createCarOrderDetail(Object carOrderDetailData) {
|
||||
OrderDetailResponse.Data data = (OrderDetailResponse.Data) carOrderDetailData;
|
||||
AmapOrderDetailResponse response = (AmapOrderDetailResponse) carOrderDetailData;
|
||||
AmapOrderDetailResponse.Data data = response.getData();
|
||||
//订单详情查询
|
||||
OrderDetailResponse response=orderDetailRequest.queryOrderDetail(data.getAmapOrderId());
|
||||
if (!response.getCode().equals(1)){
|
||||
if (!response.getCode().equals(1)) {
|
||||
return null;
|
||||
}
|
||||
String orderNo=response.getData().getAmapOrderId();
|
||||
OrderDetail orderDetail = orderDetailRepository.findByOrderNo(orderNo)
|
||||
.orElseThrow(() -> new NotFoundException(NOT_FOUND));
|
||||
RouteOrder routeOrder = routeRepository.queryById(orderDetail.getRouteId());
|
||||
CarOrderDetail carOrderDetail = orderDetailFactory.buildCarWithRouteOrderAndOrderDetail(routeOrder, orderDetail);
|
||||
String orderNo = data.getAmapOrderId();
|
||||
|
||||
RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(data.getRequestRouterNo());
|
||||
|
||||
CarOrderDetail carOrderDetail = BeanUtil.copyProperties(orderDetailFactory.buildWithRouteOrder(routeOrder), CarOrderDetail.class);
|
||||
carOrderDetail.setOrderNo(orderNo);
|
||||
carOrderDetail.setDetailId(orderNo);
|
||||
|
||||
User user = userRepository.findByUserEmployeeNo(routeOrder.getUserId());
|
||||
carOrderDetail.setBookingUserCode(user.getEmployeeNo());
|
||||
carOrderDetail.setBookingName(user.getName());
|
||||
carOrderDetail.setBookingUserPhone(data.getMobile());
|
||||
|
||||
//这里要更新用车的状态
|
||||
OrderEvent lastEvent = orderDetail.getLastEvent();
|
||||
if (lastEvent != null) {
|
||||
carOrderDetail.setOrderStatus(lastEvent.mapToCarOrderDetailStatus());
|
||||
} else {
|
||||
carOrderDetail.setOrderStatus(FSSC_CAR_STATUS_SUCCESS);
|
||||
}
|
||||
//根据状态2来判断该订单已经被取消,和总退款费用判断是否退款
|
||||
if (data.getShowStatus() == 2) {
|
||||
carOrderDetail.setOrderStatus(FSSC_ORDER_STATUS_CANCEL);
|
||||
Integer totalRefundamount=data.getTotalEnterpriseRefundAmount()+data.getTotalPersonRefundAmount();
|
||||
if (totalRefundamount>0) {
|
||||
carOrderDetail.setOrderStatus(FSSC_CAR_STATUS_REFUND);
|
||||
}
|
||||
}
|
||||
carOrderDetail.setOrderStatus(mapFSSCOrderStatus(data.getShowStatus()));
|
||||
|
||||
|
||||
carOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_CTRIP);
|
||||
if(carOrderDetail.getOrderNo() == null || carOrderDetail.getDetailId() == null){
|
||||
carOrderDetail.setOrderNo(orderNo);
|
||||
carOrderDetail.setDetailId(orderNo);
|
||||
}
|
||||
return carOrderDetail;
|
||||
carOrderDetail.setTrvaleSysType(TRAVAL_SYS_TYPE_AMAP);
|
||||
return updateCarOrderDetailData(carOrderDetail, carOrderDetailData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CarOrderDetail updateCarOrderDetailData(CarOrderDetail carOrderDetail, Object carOrderDetailData) {
|
||||
OrderDetailResponse.Data data = (OrderDetailResponse.Data) carOrderDetailData;
|
||||
if (data!=null){
|
||||
AmapOrderDetailResponse response = (AmapOrderDetailResponse) carOrderDetailData;
|
||||
AmapOrderDetailResponse.Data data = response.getData();
|
||||
if (data != null) {
|
||||
carOrderDetail.setUserName(data.getPassengerName());
|
||||
carOrderDetail.setUserCode(data.getUserId());
|
||||
carOrderDetail.setPhone(data.getPassengerPhone());
|
||||
carOrderDetail.setBOOK_ORG_STRUCT_1(data.getDepartmentName());
|
||||
|
||||
carOrderDetail.setCreateTime(data.getRequestTime());
|
||||
carOrderDetail.setOrderAmount(String.valueOf(data.getEnterpriseAmount()+data.getPersonAmount()));
|
||||
carOrderDetail.setOrderAmount(String.valueOf(data.getEnterpriseAmount() + data.getPersonAmount()));
|
||||
carOrderDetail.setCompanyPaymentAmount(String.valueOf(data.getEnterpriseAmount()));
|
||||
carOrderDetail.setPersonalPaymentAmount(String.valueOf(data.getPersonAmount()));
|
||||
|
||||
if (data.getPersonAmount()==0&&data.getEnterpriseAmount()>0) {
|
||||
if (data.getPersonAmount() == 0 && data.getEnterpriseAmount() > 0) {
|
||||
carOrderDetail.setPaymentType("0");
|
||||
} else if(data.getPersonAmount()>0&&data.getEnterpriseAmount()==0){
|
||||
} else if (data.getPersonAmount() > 0 && data.getEnterpriseAmount() == 0) {
|
||||
carOrderDetail.setPaymentType("1");
|
||||
}else {
|
||||
} else {
|
||||
carOrderDetail.setPaymentType("2");
|
||||
}
|
||||
|
||||
|
|
|
@ -26,11 +26,13 @@ public class OrderDetailFactoryImpl implements OrderDetailFactory {
|
|||
public OrderDetail create(OrderLegData orderLegData) {
|
||||
OrderDetail orderDetail = OrderDetail.of(orderLegData.getOutOrderNo(), orderLegData.getSupplierName());
|
||||
DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
if (orderLegData.getStartTime() != null) {
|
||||
orderDetail.setStartTime(LocalDateTime.parse(orderLegData.getStartTime(), dateTimeFormatter));
|
||||
String startTime = orderLegData.getStartTime();
|
||||
if (startTime != null && !startTime.isEmpty()) {
|
||||
orderDetail.setStartTime(LocalDateTime.parse(startTime, dateTimeFormatter));
|
||||
}
|
||||
if (orderLegData.getEndTime() != null) {
|
||||
orderDetail.setEndTime(LocalDateTime.parse(orderLegData.getEndTime(), dateTimeFormatter));
|
||||
String endTime = orderLegData.getEndTime();
|
||||
if (endTime != null && !endTime.isEmpty()) {
|
||||
orderDetail.setEndTime(LocalDateTime.parse(endTime, dateTimeFormatter));
|
||||
}
|
||||
orderDetail.setOrderDate(LocalDateTime.parse(orderLegData.getOrderTime(), dateTimeFormatter));
|
||||
// orderDetail.setCurrencyType(CurrencyType.getByCode(orderLegData.getCurrencyCode()));
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package com.chint.domain.factoriy.order_detail;
|
||||
|
||||
import com.chint.domain.exceptions.NotFoundException;
|
||||
import com.chint.domain.factoriy.order_record.AmapOrderRecordExtensionFactory;
|
||||
import com.chint.infrastructure.constant.CommonMessageConstant;
|
||||
import com.chint.infrastructure.constant.SupplierNameConstant;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import static com.chint.infrastructure.constant.SupplierNameConstant.*;
|
||||
|
||||
@Component
|
||||
public class OrderExtensionCreator {
|
||||
|
||||
|
@ -14,10 +17,14 @@ public class OrderExtensionCreator {
|
|||
@Autowired
|
||||
private CTripOrderExtensionFactoryImpl cTripOrderExtensionFactory;
|
||||
|
||||
@Autowired
|
||||
private AmapOrderExtensionFactoryImpl amapOrderExtensionFactory;
|
||||
|
||||
public OrderExtensionFactory of(String supplierName) {
|
||||
return switch (supplierName) {
|
||||
case SupplierNameConstant.SUPPLIER_C_TRIP -> cTripOrderExtensionFactory;
|
||||
case SupplierNameConstant.SUPPLIER_L_Y -> lyOrderExtensionFactory;
|
||||
case SUPPLIER_C_TRIP -> cTripOrderExtensionFactory;
|
||||
case SUPPLIER_L_Y -> lyOrderExtensionFactory;
|
||||
case SUPPLIER_AMAP -> amapOrderExtensionFactory;
|
||||
default -> throw new NotFoundException(CommonMessageConstant.NOT_FOUND);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -9,7 +9,11 @@ import com.chint.domain.aggregates.order.order_record.ly_order_record.*;
|
|||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.aggregates.user.UserDepartmentInfo;
|
||||
import com.chint.domain.repository.RouteRepository;
|
||||
import com.chint.infrastructure.repository.jdbc.*;
|
||||
import com.chint.domain.service.RouteRequestDomainService;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcOrderDetailRepository;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcOrderTravelRepository;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcRouteRepository;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcUserRepository;
|
||||
import com.chint.infrastructure.util.BeanCopyUtils;
|
||||
import com.chint.interfaces.rest.data_center.user.UserHttpRequest;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
@ -51,6 +55,9 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
|||
@Autowired
|
||||
private JdbcOrderTravelRepository orderTravelRepository;
|
||||
|
||||
@Autowired
|
||||
private RouteRequestDomainService routeRequestDomainService;
|
||||
|
||||
@Autowired
|
||||
private CTripOrderRecordExtensionFactory cTripOrderRecordExtensionFactory;
|
||||
|
||||
|
@ -105,7 +112,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
|||
String orderSerialNo = lyOrderFlightRecord.getOrderSerialNo();//订单号
|
||||
AtomicReference<OrderDetail> orderDetailRef = new AtomicReference<>();
|
||||
AtomicReference<RouteOrder> routeOrderRef = new AtomicReference<>();
|
||||
OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo, orderDetailRef::set, routeOrderRef::set);
|
||||
OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo, orderDetailRef::set, routeOrderRef::set, lyOrderFlightRecord.getOutApplayOrderNo());
|
||||
BeanUtils.copyProperties(orderRecordBasic, orderFlightRecord);
|
||||
OrderDetail orderDetail = orderDetailRef.get();//获取订单明细
|
||||
RouteOrder routeOrder = routeOrderRef.get();//获取财务共享订单
|
||||
|
@ -222,7 +229,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
|||
String orderSerialNo = lyOrderHotelRecord.getOrderSerialNo();//订单号
|
||||
AtomicReference<OrderDetail> orderDetailRef = new AtomicReference<>();
|
||||
AtomicReference<RouteOrder> routeOrderRef = new AtomicReference<>();
|
||||
OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo, orderDetailRef::set, routeOrderRef::set);
|
||||
OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo, orderDetailRef::set, routeOrderRef::set, lyOrderHotelRecord.getOutApplayOrderNo());
|
||||
BeanUtils.copyProperties(orderRecordBasic, orderHotelRecord);
|
||||
OrderDetail orderDetail = orderDetailRef.get();//订单明细
|
||||
RouteOrder routeOrder = routeOrderRef.get();//财务共享订单数据
|
||||
|
@ -330,7 +337,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
|||
String orderSerialNo = lyOrderTrainRecord.getOrderSerialNo();//订单号
|
||||
AtomicReference<OrderDetail> orderDetailRef = new AtomicReference<>();
|
||||
AtomicReference<RouteOrder> routeOrderRef = new AtomicReference<>();
|
||||
OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo, orderDetailRef::set, routeOrderRef::set);
|
||||
OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo, orderDetailRef::set, routeOrderRef::set, lyOrderTrainRecord.getOutApplayOrderNo());
|
||||
BeanUtils.copyProperties(orderRecordBasic, orderTrainRecord);
|
||||
OrderDetail orderDetail = orderDetailRef.get();//订单明细
|
||||
RouteOrder routeOrder = routeOrderRef.get();//财务共享订单数据
|
||||
|
@ -450,7 +457,7 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
|||
String orderSerialNo = lyOrderCarRecord.getOrderSerialNo();//订单号
|
||||
AtomicReference<OrderDetail> orderDetailRef = new AtomicReference<>();
|
||||
AtomicReference<RouteOrder> routeOrderRef = new AtomicReference<>();
|
||||
OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo, orderDetailRef::set, routeOrderRef::set);
|
||||
OrderRecordBasic orderRecordBasic = getOrderRecordBasic(orderSerialNo, orderDetailRef::set, routeOrderRef::set, lyOrderCarRecord.getOutApplayOrderNo());
|
||||
BeanUtils.copyProperties(orderRecordBasic, orderCarRecord);
|
||||
OrderDetail orderDetail = orderDetailRef.get();//订单明细
|
||||
RouteOrder routeOrder = routeOrderRef.get();//财务共享订单数据
|
||||
|
@ -548,20 +555,24 @@ public class LyOrderRecordExtensionFactory implements OrderRecordExtensionFactor
|
|||
}
|
||||
|
||||
//获取公共对象
|
||||
public OrderRecordBasic getOrderRecordBasic(String orderSerialNo, Consumer<OrderDetail> consumerOrderDetail, Consumer<RouteOrder> consumerRouteOrder) {
|
||||
OrderDetail orderDetail = jdbcOrderDetailRepository.findByOrderNo(orderSerialNo);
|
||||
consumerOrderDetail.accept(orderDetail == null ? new OrderDetail() : orderDetail);//设置订单明细数据
|
||||
if (Objects.isNull(orderDetail)) {
|
||||
consumerRouteOrder.accept(new RouteOrder());
|
||||
return new OrderRecordBasic();
|
||||
}
|
||||
Long routeId = orderDetail.getRouteId();
|
||||
RouteOrder routeOrder = routeRepository.queryById(routeId);
|
||||
public OrderRecordBasic getOrderRecordBasic(String orderSerialNo, Consumer<OrderDetail> consumerOrderDetail, Consumer<RouteOrder> consumerRouteOrder, String routeOrderNo) {
|
||||
RouteOrder routeOrder = routeRequestDomainService.getRouteOrder(routeOrderNo);
|
||||
consumerRouteOrder.accept(routeOrder == null ? new RouteOrder() : routeOrder);
|
||||
if (Objects.isNull(routeOrder)) {
|
||||
return new OrderRecordBasic();
|
||||
} else {
|
||||
OrderDetail orderDetail = routeOrder
|
||||
.getOrderDetails()
|
||||
.stream()
|
||||
.filter(it -> it.getOrderNo().equals(orderSerialNo))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
consumerOrderDetail.accept(orderDetail == null ? new OrderDetail() : orderDetail);//设置订单明细数据
|
||||
if (Objects.isNull(orderDetail)) {
|
||||
consumerRouteOrder.accept(new RouteOrder());
|
||||
return new OrderRecordBasic();
|
||||
}
|
||||
}
|
||||
// return orderRecordFactory.buildWithRouteOrder(routeOrder);
|
||||
return new OrderRecordBasic();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package com.chint.domain.repository;
|
||||
|
||||
import com.chint.domain.aggregates.supplier.AmapPolicy;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public interface AmapPolicyRepository {
|
||||
Optional<AmapPolicy> findByDefault();
|
||||
}
|
|
@ -4,6 +4,7 @@ import com.chint.domain.aggregates.order.*;
|
|||
import com.chint.domain.aggregates.supplier.AmapRouteRelationship;
|
||||
import com.chint.domain.aggregates.user.User;
|
||||
import com.chint.domain.exceptions.CommandException;
|
||||
import com.chint.domain.repository.AmapPolicyRepository;
|
||||
import com.chint.domain.repository.AmapRouteRelationshipRepository;
|
||||
import com.chint.domain.repository.UserRepository;
|
||||
import com.chint.domain.service.LegDomainService;
|
||||
|
@ -45,6 +46,9 @@ public class AmapOrderSyncAdapter implements SupplierOrderSync {
|
|||
@Autowired
|
||||
private LegDomainService legDomainService;
|
||||
|
||||
@Autowired
|
||||
private AmapPolicyRepository amapPolicyRepository;
|
||||
|
||||
private Gson gson = new Gson();
|
||||
|
||||
@Override
|
||||
|
@ -71,6 +75,7 @@ public class AmapOrderSyncAdapter implements SupplierOrderSync {
|
|||
AmapRouteRelationship amapRouteRelationship = new AmapRouteRelationship();
|
||||
amapRouteRelationship.setApplyRecordId(response.getData());
|
||||
amapRouteRelationship.setOutApplyRecordId(routeRequest.getRouteRequestNo());
|
||||
amapRouteRelationship.setAmapPolicyCode(travelApplicationDto.getRegulationId());
|
||||
amapRouteRelationshipRepository.save(amapRouteRelationship);
|
||||
}
|
||||
|
||||
|
@ -130,11 +135,15 @@ public class AmapOrderSyncAdapter implements SupplierOrderSync {
|
|||
areaCodes.add(amapLocationRequest.getACodeByLocationName(location.getLocationName()));
|
||||
}
|
||||
processContent.setValidCityList(areaCodes);
|
||||
processContent.setAmountLimited(1);
|
||||
processContent.setAllowCrossCity(1);
|
||||
// processContent.setAmountLimited(1);
|
||||
// processContent.setAllowCrossCity(1);
|
||||
|
||||
dto.setProcessContent(gson.toJson(processContent));
|
||||
dto.setStatus("1");
|
||||
|
||||
amapPolicyRepository.findByDefault()
|
||||
.ifPresent(policy -> dto.setRegulationId(policy.getAmapPolicyCode()));
|
||||
|
||||
return dto;
|
||||
}
|
||||
|
||||
|
@ -157,7 +166,7 @@ public class AmapOrderSyncAdapter implements SupplierOrderSync {
|
|||
travelApplicationDto.setApplyRecordId(amapRouteRelationship.getApplyRecordId());
|
||||
TravelApplicationDtoResponse response = travelApplicationRequest.modify(travelApplicationDto);
|
||||
Integer code = response.getCode();
|
||||
if(code.equals(1)){
|
||||
if (code.equals(1)) {
|
||||
amapRouteRelationshipRepository.removeByOutApplyRecordId(outApplyRecordId);
|
||||
}
|
||||
return code.equals(1);
|
||||
|
|
|
@ -1,133 +1,78 @@
|
|||
package com.chint.domain.service.supplier;
|
||||
|
||||
import com.chint.domain.aggregates.order.Location;
|
||||
import com.chint.domain.exceptions.NotFoundException;
|
||||
import com.chint.domain.repository.LocationRepository;
|
||||
import com.chint.domain.value_object.OrderLegData;
|
||||
import com.chint.domain.value_object.SupplierCallbackData;
|
||||
import com.chint.domain.value_object.enums.CurrencyType;
|
||||
import com.chint.infrastructure.constant.CommonMessageConstant;
|
||||
import com.chint.infrastructure.constant.LegConstant;
|
||||
import com.chint.infrastructure.constant.OrderConstant;
|
||||
import com.chint.infrastructure.constant.SupplierNameConstant;
|
||||
import com.chint.interfaces.rest.amap.dto.detail.OrderDetailResponse;
|
||||
import com.chint.interfaces.rest.amap.request.OrderDetailRequest;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.ItineraryEntity;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.car.CarBasicInfo;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.car.CarQuickOrderInfoEntity;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.car.OrderProduct;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.flight.FlightInfo;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.flight.FlightOrderInfoEntity;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.hotel.HotelOrderInfoEntity;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.train.TrainOrderInfoEntity;
|
||||
import com.chint.interfaces.rest.amap.dto.detail.AmapOrderDetailResponse;
|
||||
import com.chint.interfaces.rest.amap.request.AmapOrderDetailRequest;
|
||||
import com.google.gson.Gson;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
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;
|
||||
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_L_Y;
|
||||
|
||||
/**
|
||||
* 高德订单处理
|
||||
*
|
||||
* @Author:nxj
|
||||
* @Date:2024/4/30 14:01
|
||||
*/
|
||||
@Component
|
||||
public class AmapOrderDataAdapter implements OrderDataAdapter{
|
||||
public class AmapOrderDataAdapter implements OrderDataAdapter {
|
||||
|
||||
|
||||
@Autowired
|
||||
private LocationRepository locationRepository;
|
||||
|
||||
@Autowired
|
||||
private OrderDetailRequest orderDetailRequest;
|
||||
private AmapOrderDetailRequest orderDetailRequest;
|
||||
|
||||
@Override
|
||||
public Optional<OrderLegData> adapt(SupplierCallbackData supplierData) {
|
||||
OrderDetailResponse data=(OrderDetailResponse) supplierData.getData();
|
||||
OrderDetailResponse response=orderDetailRequest.queryOrderDetail(data.getData().getAmapOrderId());
|
||||
if (!response.getCode().equals(1)){
|
||||
AmapOrderDetailResponse amapOrderDetailResponse = (AmapOrderDetailResponse) supplierData.getData();
|
||||
AmapOrderDetailResponse.Data data = amapOrderDetailResponse.getData();
|
||||
if (data == null) {
|
||||
return Optional.empty();
|
||||
}else {
|
||||
OrderDetailResponse.Data result=response.getData();
|
||||
return Optional.of(
|
||||
OrderLegData.builder()
|
||||
.productType(LEG_TYPE_TAXI)
|
||||
.outOrderNo(result.getAmapOrderId())
|
||||
.price(String.valueOf(result.getEnterpriseAmount()+response.getData().getPersonAmount()))
|
||||
.supplierName(supplierData.getSupplierName())
|
||||
.currencyCode(CurrencyType.RENMINBI.getCode())
|
||||
//没有返回差旅申请单号
|
||||
.selfOrderNo(response.getData().getApplyRecord().getOutApplyRecordId())
|
||||
.orderStatus(supplierData.getSelfOrderStatus())
|
||||
.carOrderDetailData(response)
|
||||
.orderTime(result.getRequestTime())
|
||||
.startTime(result.getGetOnTime())
|
||||
.endTime(result.getGetOffTime())
|
||||
.orderStatus(supplierData.getSelfOrderStatus())
|
||||
.originOrderStatus(supplierData.getOutOrderStatus())
|
||||
.destinationName(result.getEndName())
|
||||
.supplierName(SUPPLIER_L_Y)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
String applyRecord = data.getApplyRecord();
|
||||
Gson gson = new Gson();
|
||||
AmapOrderDetailResponse.ApplyRecord record = gson.fromJson(applyRecord, AmapOrderDetailResponse.ApplyRecord.class);
|
||||
String price;
|
||||
if (data.getEnterpriseAmount() == null && data.getPersonAmount() == null) {
|
||||
price = "0";
|
||||
} else {
|
||||
Integer enterpriseAmount = data.getEnterpriseAmount();
|
||||
Integer personAmount = data.getPersonAmount();
|
||||
price = String.valueOf((enterpriseAmount == null ? 0 : enterpriseAmount) + (personAmount == null ? 0 : personAmount));
|
||||
}
|
||||
return Optional.of(
|
||||
OrderLegData.builder()
|
||||
.productType(LEG_TYPE_TAXI)
|
||||
.outOrderNo(data.getAmapOrderId())
|
||||
.price(price)
|
||||
.supplierName(supplierData.getSupplierName())
|
||||
.currencyCode(CurrencyType.RENMINBI.getCode())
|
||||
.selfOrderNo(record.getOutApplyRecordId())
|
||||
.orderStatus(supplierData.getSelfOrderStatus())
|
||||
.carOrderDetailData(amapOrderDetailResponse)
|
||||
.orderTime(data.getRequestTime())
|
||||
.startTime(data.getGetOnTime())
|
||||
.endTime(data.getGetOffTime())
|
||||
.orderStatus(supplierData.getSelfOrderStatus())
|
||||
.originOrderStatus(supplierData.getOutOrderStatus())
|
||||
.destinationName(data.getEndName())
|
||||
.supplierName(SUPPLIER_AMAP)
|
||||
.build());
|
||||
}
|
||||
|
||||
private OrderLegData.Builder findSingleElementList(ItineraryEntity itineraryEntity,
|
||||
OrderLegData.Builder builder) {
|
||||
|
||||
// 处理租车订单
|
||||
List<CarQuickOrderInfoEntity> carOrderInfoList = itineraryEntity.getCarQuickOrderInfoList();
|
||||
if (carOrderInfoList != null && carOrderInfoList.size() == 1) {
|
||||
CarQuickOrderInfoEntity carOrderInfo = carOrderInfoList.get(0);
|
||||
OrderProduct orderProduct = carOrderInfo.getOrderProduct();
|
||||
CarBasicInfo carBasicInfo = carOrderInfo.getBasicInfo();
|
||||
|
||||
|
||||
Long departCityId = Long.valueOf(orderProduct.getDepartAddress().getCityId());
|
||||
Location departCityName = locationRepository.findByCityIdAndLevelThree(departCityId);
|
||||
if(departCityName == null){
|
||||
departCityName = locationRepository.findByCityIdAndLevelFour(departCityId);
|
||||
}
|
||||
|
||||
Long arriveCityId = Long.valueOf(orderProduct.getArriveAddress().getCityId());
|
||||
Location arriveCityName = locationRepository.findByCityIdAndLevelThree(arriveCityId);
|
||||
if(arriveCityName == null){
|
||||
arriveCityName = locationRepository.findByCityIdAndLevelFour(arriveCityId);
|
||||
}
|
||||
return builder.productType(LegConstant.LEG_TYPE_TAXI)
|
||||
.carOrderDetailData(carOrderInfo)
|
||||
.currencyCode(CurrencyType.RENMINBI.getCode())
|
||||
.orderTime(carBasicInfo.getCreateTime())
|
||||
.startTime(orderProduct.getServiceBeginTime())
|
||||
.endTime(orderProduct.getServiceEndTime())
|
||||
.originId(departCityName.getLocationId())
|
||||
.destinationId(arriveCityName.getLocationId())
|
||||
.price(String.valueOf(carBasicInfo.getOrderAmount()))
|
||||
.selfOrderNo(carBasicInfo.getJouneryID())
|
||||
.outOrderNo(String.valueOf(carBasicInfo.getOrderId()))
|
||||
.orderStatus(translateCarOrderStatus(carBasicInfo.getOrderStatus()))
|
||||
.originOrderStatus(carBasicInfo.getOrderStatus());
|
||||
|
||||
}
|
||||
|
||||
// 如果没有找到任何只含一个元素的列表,返回null
|
||||
return null;
|
||||
}
|
||||
|
||||
private Location getLocationId(String cityName, Long cityId) {
|
||||
Location byName = locationRepository.findByCityIdAndLevelThree(cityId);
|
||||
if (byName == null) {
|
||||
List<Location> listByCityName = locationRepository.findListByCityName(cityName);
|
||||
if (listByCityName != null && !listByCityName.isEmpty()) {
|
||||
byName = listByCityName.get(0);
|
||||
}
|
||||
}
|
||||
return byName;
|
||||
}
|
||||
|
||||
private Integer translateCarOrderStatus(String carOrderStatus) {
|
||||
return switch (carOrderStatus) {
|
||||
|
|
|
@ -39,4 +39,14 @@ public class SupplierCallbackData {
|
|||
this.extension = extension;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SupplierCallbackData outOrderStatus(String outOrderStatus) {
|
||||
this.outOrderStatus = outOrderStatus;
|
||||
return this;
|
||||
}
|
||||
|
||||
public SupplierCallbackData selfOrderStatus(Integer selfOrderStatus) {
|
||||
this.selfOrderStatus = selfOrderStatus;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package com.chint.infrastructure.constant;
|
|||
public class BelongSystemConstant {
|
||||
public static final String TRAVAL_SYS_TYPE_CTRIP = "XC";
|
||||
public static final String TRAVAL_SYS_TYPE_LY = "TC";
|
||||
public static final String TRAVAL_SYS_TYPE_AMAP = "GD";
|
||||
public static final String BELONG_SYS_CODE_FSSC = "FSSC";
|
||||
public static final String BELONG_SYS_CODE_H3BPM = "H3BPM";
|
||||
public static final String BELONG_SYS_CODE_XNFSSC = "XNFSSC";
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package com.chint.infrastructure.repository;
|
||||
|
||||
import com.chint.domain.aggregates.supplier.AmapPolicy;
|
||||
import com.chint.domain.repository.AmapPolicyRepository;
|
||||
import com.chint.infrastructure.repository.jdbc.JdbcAmapPolicyRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public class AmapPolicyRepositoryImpl implements AmapPolicyRepository {
|
||||
@Autowired
|
||||
private JdbcAmapPolicyRepository jdbcAmapPolicyRepository;
|
||||
|
||||
@Override
|
||||
public Optional<AmapPolicy> findByDefault() {
|
||||
return jdbcAmapPolicyRepository.findByIfDefault(1);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package com.chint.infrastructure.repository.jdbc;
|
||||
|
||||
import com.chint.domain.aggregates.supplier.AmapPolicy;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface JdbcAmapPolicyRepository extends CrudRepository<AmapPolicy, Long> {
|
||||
Optional<AmapPolicy> findByIfDefault(Integer ifDefault);
|
||||
}
|
|
@ -1,14 +1,11 @@
|
|||
package com.chint.interfaces.rest.amap.dto.detail;
|
||||
|
||||
import com.chint.interfaces.rest.amap.BaseResponse;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class OrderDetailResponse extends BaseResponse {
|
||||
public class AmapOrderDetailResponse extends BaseResponse {
|
||||
|
||||
private Data data;
|
||||
|
||||
|
@ -35,7 +32,7 @@ public class OrderDetailResponse extends BaseResponse {
|
|||
private String licensePlate;//车牌号
|
||||
private String carType;//车辆型号
|
||||
private String carColor;//车辆颜色
|
||||
private Integer rideType;//运力类型1:经济;2:品质专车;3:六座商务;4:豪华;5:出租车;6:优享;11:优惠推荐;13:企业同行;14:企业拼车;15:代驾
|
||||
private String rideType;//运力类型1:经济;2:品质专车;3:六座商务;4:豪华;5:出租车;6:优享;11:优惠推荐;13:企业同行;14:企业拼车;15:代驾
|
||||
private String rideTypeName;//运力显示文案
|
||||
private Boolean isFixedPrice;//是否为特价车车型
|
||||
private String cpName;//CP名称(例如滴滴、首汽约车等)
|
||||
|
@ -47,19 +44,19 @@ public class OrderDetailResponse extends BaseResponse {
|
|||
private String totalFee;//总费用(分)
|
||||
private String originalFeeDetail;//费用明细(取消费、起步费、里程费、时长费、停车费、过桥费、附加费、加价红包、信息费、其他费用等等)
|
||||
private String feeDetail;//费用明细(时长费,里程费,附加费,附加费用明细,其他费用,其他费用明细)
|
||||
private int showStatus;//0-派单中,1-完成待支付,2-取消待支付,3-关闭,4-订单完成,5-待出发,6-待上车,7-行程中(订单当前状态)
|
||||
private Integer showStatus;//0-派单中,1-完成待支付,2-取消待支付,3-关闭,4-订单完成,5-待出发,6-待上车,7-行程中(订单当前状态)
|
||||
private String enterpriseCpStatus;//详见:订单子状态映射表
|
||||
private int orderServiceType;//业务类型: 1-实时单,2-预约单,3-接机 4-送机,6-市内拼车,8-代驾
|
||||
private int orderEnterance;//发单入口:0:实时 1:预约 2:接机 3:送机 4:接站 5:送站 8:代驾 10:代叫实时 11:代叫预约 12:代叫接机 13:代叫送机 14:代叫接站 15:代叫送站
|
||||
private Integer orderServiceType;//业务类型: 1-实时单,2-预约单,3-接机 4-送机,6-市内拼车,8-代驾
|
||||
private String orderEnterance;//发单入口:0:实时 1:预约 2:接机 3:送机 4:接站 5:送站 8:代驾 10:代叫实时 11:代叫预约 12:代叫接机 13:代叫送机 14:代叫接站 15:代叫送站
|
||||
private String flightNo;//航班号
|
||||
private Date flightDate;//接送机-航班出发日期,接机必填
|
||||
private Date actualDepartTime;//接机场景,行程的真实出发时间,航班延误、提前到达情况下更新
|
||||
private String flightDate;//接送机-航班出发日期,接机必填
|
||||
private String actualDepartTime;//接机场景,行程的真实出发时间,航班延误、提前到达情况下更新
|
||||
private String depAirCode;//出发机场三字码
|
||||
private String arrAirCode;//到达机场三字码
|
||||
private Integer pickUpDelayTime;//航班到达后,延迟N毫秒后用车
|
||||
private String pickUpDelayTime;//航班到达后,延迟N毫秒后用车
|
||||
private String remark;//1.企业获取token时传递的备注信息(remark数据)2.使用制度用车时,内容是员工填写的用车备注;3.如果为多备注制度,默认返回为JSON结构; 如果不需要JSON结构,可以在ES后台“企业功能配置”设置为精简模式
|
||||
private List<RiskTag> riskTags;//风险标记数据
|
||||
private List<RefundItem> refundItems;//所有退款数据
|
||||
private Object riskTags;//风险标记数据
|
||||
private Object refundItems;//所有退款数据
|
||||
private Integer totalEnterpriseRefundAmount;//企业退款总金额(分)
|
||||
private Integer totalPersonRefundAmount;//个人退款总金额(分)
|
||||
private Integer enterpriseAmount;//企业支付金额(分)
|
||||
|
@ -70,7 +67,7 @@ public class OrderDetailResponse extends BaseResponse {
|
|||
private String passengerPhone;//代叫单 乘车人手机号
|
||||
private String passengerName;//代叫单 乘车人姓名
|
||||
private String privateTag;//1 因私订单 0非因私订单
|
||||
private ApplyRecord applyRecord;//申请单详情
|
||||
private String applyRecord;//申请单详情
|
||||
private String extInfo;//员工扩展属性 JSON【长度:1000字符】,该信息为创建员工时提交的extInfo值
|
||||
private String tokenExtInfo;//该信息为提交token时,userInfo里的extInfo值
|
||||
private String showPayChannel;//支付方式:个人支付(3)、企业支付(1)、混合支付(2)
|
||||
|
@ -95,6 +92,13 @@ public class OrderDetailResponse extends BaseResponse {
|
|||
private Integer personalPayStatus;//审批驳回后的个付状态(1-待支付,2-支付成功,3-超期未支付)
|
||||
private String reasonForPersonPay;//需要个人支付的原因
|
||||
private String financeCostcenterCode;//成本中心编码
|
||||
|
||||
public String getRequestRouterNo() {
|
||||
Gson gson = new Gson();
|
||||
String record = this.getApplyRecord();
|
||||
ApplyRecord applyRecord1 = gson.fromJson(record, ApplyRecord.class);
|
||||
return applyRecord1.getOutApplyRecordId();
|
||||
}
|
||||
}
|
||||
|
||||
@lombok.Data
|
||||
|
@ -129,4 +133,6 @@ public class OrderDetailResponse extends BaseResponse {
|
|||
private String title;//名称
|
||||
private String value;//费用
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,196 @@
|
|||
package com.chint.interfaces.rest.amap.dto.note;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class AmapNoteParam {
|
||||
private Integer eid; // 企业ID
|
||||
private String sign; // 签名
|
||||
private String timestamp; // 请求发生时的时间戳,单位ms
|
||||
private String amapOrderId; // 高德订单号
|
||||
private String userId; // 企业用户ID
|
||||
private String mobile; // 企业用户手机号
|
||||
private String departmentId; // 企业用户部门ID
|
||||
private String departmentName; // 企业用户部门名称
|
||||
private String requestTime; // 约车时间(如:2018-12-12 20:00:00)
|
||||
private String departTime; // 出行时间(如:2018-12-12 20:00:00)
|
||||
private String getOnTime; // 实际的上车时间(司机开始行程时间)
|
||||
private String getOffTime; // 实际的下车时间(司机结束行程时间)
|
||||
private String startName; // 起点名称
|
||||
private String startAdcode; // 起点城市编码(地级市)
|
||||
private String startLng; // 起点经度(如:39.984948)
|
||||
private String startLat; // 起点纬度(如:116.467588)
|
||||
private String startCity; // 起点城市
|
||||
private String endName; // 终点名称
|
||||
private String endAdcode; // 终点城市编码(地级市)
|
||||
private String endLng; // 终点经度(如:40.040786)
|
||||
private String endLat; // 终点纬度(如:116.475628)
|
||||
private String endCity; // 终点城市
|
||||
private String driverPhone; // 司机电话
|
||||
private String driverName; // 司机姓名
|
||||
private String licensePlate; // 车牌号
|
||||
private String rideType; // 运力类型( 1:经济,2:品质专车,3:六座商务,4:豪华,5:出租车,6:优享,11:优惠推荐,13:企业同行,14:企业拼车)
|
||||
private String rideTypeName; // 运力显示文案
|
||||
private String cpName; // CP名称(例如滴滴、首汽约车等)
|
||||
private String estimatePrice; // 预估价(分)
|
||||
private String estimateMileage; // 预估里程(米)
|
||||
private String estimateTime; // 预估时间(秒)
|
||||
private String duration; // 总时长(分)
|
||||
private String mileage; // 总里程(米)
|
||||
private String totalFee; // 总费用(分)
|
||||
private String originalFeeDetail; // 费用明细(取消费、起步费、里程费、时长费、停车费、过桥费、附加费、加价红包、信息费、其他费用、预约服务费、高速服务费、企业服务费等等)
|
||||
private String feeDetail; // 费用明细(时长费,里程费,附加费,附加费用明细,其他费用,其他费用明细)
|
||||
private Integer showStatus; // 0-派单中(下单、平台改派、追加运力),1-完成待支付,2-取消待支付,3-关闭(无司机应答、司机取消、乘客取消、服务商取消、平台关单),4-订单完成(支付完成),5-待出发(司机接单),6-待上车(司机到达起点),7-行程中(开始计费)
|
||||
private String enterpriseCpStatus; // 详见:订单子状态映射表
|
||||
private Integer orderServiceType; // 业务类型: 1-实时单,2-预约单,3-接机 4-送机,6-市内拼车,8-代驾
|
||||
private String statusUpdateTime; // 订单状态更新时间(如:2018-12-12 20:00:00)
|
||||
private String remark; // 企业获取token时传递的备注信息 使用制度用车时,内容是员工填写的用车备注; 如果为多备注制度,默认返回为JSON结构; 如果不需要JSON结构,可以在ES后台“企业功能配置”设置为精简模式
|
||||
private String carType; // 司机车型
|
||||
private String carColor; // 车辆颜色
|
||||
private List<RiskTagStr> riskTags; // 所有风险标记数据
|
||||
private List<RefundItemStr> refundItems; // 所有退款数据
|
||||
private Integer totalEnterpriseRefundAmount; // 企业退款总金额(分)
|
||||
private Integer totalPersonRefundAmount; // 个人退款总金额(分)
|
||||
private Integer enterpriseAmount; // 企业支付金额(分)
|
||||
private String enterpriseCarPool; // 是否企业拼车 0 - 否 1 - 是
|
||||
private Integer personAmount; // 个人支付金额(分)
|
||||
private Short subGdServiceId; // 服务子类型, 默认null, null或0为普通单, 1代叫单
|
||||
private String privacyNumber; // 叫车人 隐私号(叫车人与司机绑定的隐私号)
|
||||
private String passengerPrivacyNumber; // 代叫单 乘车人隐私号(乘车人与司机绑定的隐私号)
|
||||
private String passengerPhone; // 代叫单 乘车人手机号
|
||||
private String passengerName; // 代叫单 乘车人姓名
|
||||
private String privateTag; // 1 因私订单 0非因私订单
|
||||
private String applyRecord; // 申请单详情
|
||||
private String showPayChannel; // 个人支付(3)、企业支付(1)、混合支付(2)
|
||||
private String sceneType; // 因公出行场景(只有使用了ES制度的才有) (0-个人用车、1-加班、2-定点通勤、3-外勤用车、4-出差、5-接送机)
|
||||
private String extInfo; // 员工扩展属性 JSON【长度:1000字符】
|
||||
private String attachInfo; // 员工扩展信息,由附加信息接口传入
|
||||
private String startBillLocationName; // 实际上车地点
|
||||
private String startBillTime; // 实际上车时间
|
||||
private String endBillLocationName; // 实际下车地点
|
||||
private String endBillTime; // 实际下车时间
|
||||
private String realStartLat; // 实际上车纬度
|
||||
private String realStartLng; // 实际上车经度
|
||||
private String realEndLat; // 实际下车纬度
|
||||
private String realEndLng; // 实际下车经度
|
||||
private String driverAcceptTime; // 司机接单时间
|
||||
private String payTime; // 订单支付时间
|
||||
private String initOrderServiceType; // 传入的orderServiceType
|
||||
private String regulationContent; // 下单时刻的制度内容
|
||||
private String regulationId; // 打车时使用的制度id
|
||||
private String regulationName; // 打车时使用的制度名称
|
||||
private String sensitiveOrderReason; // 敏感订单员工确认原因的原因选项和填写的备注
|
||||
private String flightNo; // 航班号 (接送机返回)
|
||||
private Date flightDate; // 接送机-航班出发日期 (接送机返回)
|
||||
private Date actualDepartTime; // 接机场景,行程的真实出发时间,航班延误、提前到达情况下更新 (接送机返回)
|
||||
private String depAirCode; // 出发机场三字码 (接送机返回)
|
||||
private String arrAirCode; // 到达机场三字码 (接送机返回)
|
||||
private Integer pickUpDelayTime; // 航班到达后,延迟N毫秒后用车 (接送机返回)
|
||||
private Integer personalPayStatus; // 个付状态(1-待支付,2-支付成功,3-超期未支付)
|
||||
private String reasonForPersonPay; // 需要个人支付的原因
|
||||
|
||||
|
||||
@Data
|
||||
public static class RiskTagStr {
|
||||
private String riskTagJson;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class RiskTag {
|
||||
private Integer riskCode;
|
||||
private String riskDesp;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class RefundItemStr {
|
||||
private String refundItemJson;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class RefundItem {
|
||||
private Integer enterpriseRefundAmount;
|
||||
private Integer personRefundAmount;
|
||||
private String refundTime;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class ApplyRecord {
|
||||
private String outApplyRecordId;
|
||||
private String enterpriseCustomFields;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class Regulation {
|
||||
private String regulationName;
|
||||
}
|
||||
|
||||
public static AmapNoteParam convert(Map<String, String> params) {
|
||||
AmapNoteParam param = new AmapNoteParam();
|
||||
param.setEid(getInteger(params, "eid"));
|
||||
param.setSign(params.get("sign"));
|
||||
param.setTimestamp(params.get("timestamp"));
|
||||
param.setAmapOrderId(params.get("amapOrderId"));
|
||||
param.setUserId(params.get("userId"));
|
||||
param.setMobile(params.get("mobile"));
|
||||
param.setDepartmentId(params.get("departmentId"));
|
||||
param.setDepartmentName(params.get("departmentName"));
|
||||
param.setRequestTime(params.get("requestTime"));
|
||||
param.setDepartTime(params.get("departTime"));
|
||||
param.setGetOnTime(params.get("getOnTime"));
|
||||
param.setGetOffTime(params.get("getOffTime"));
|
||||
param.setStartName(params.get("startName"));
|
||||
param.setStartAdcode(params.get("startAdcode"));
|
||||
param.setStartLng(params.get("startLng"));
|
||||
param.setStartLat(params.get("startLat"));
|
||||
param.setStartCity(params.get("startCity"));
|
||||
param.setEndName(params.get("endName"));
|
||||
param.setEndAdcode(params.get("endAdcode"));
|
||||
param.setEndLng(params.get("endLng"));
|
||||
param.setEndLat(params.get("endLat"));
|
||||
param.setEndCity(params.get("endCity"));
|
||||
param.setDriverPhone(params.get("driverPhone"));
|
||||
param.setDriverName(params.get("driverName"));
|
||||
param.setLicensePlate(params.get("licensePlate"));
|
||||
param.setRideType(params.get("rideType"));
|
||||
param.setRideTypeName(params.get("rideTypeName"));
|
||||
param.setCpName(params.get("cpName"));
|
||||
param.setEstimatePrice(params.get("estimatePrice"));
|
||||
param.setEstimateMileage(params.get("estimateMileage"));
|
||||
param.setEstimateTime(params.get("estimateTime"));
|
||||
param.setDuration(params.get("duration"));
|
||||
param.setMileage(params.get("mileage"));
|
||||
param.setTotalFee(params.get("totalFee"));
|
||||
param.setOriginalFeeDetail(params.get("originalFeeDetail"));
|
||||
param.setFeeDetail(params.get("feeDetail"));
|
||||
param.setShowStatus(getInteger(params, "showStatus"));
|
||||
param.setEnterpriseCpStatus(params.get("enterpriseCpStatus"));
|
||||
param.setOrderServiceType(getInteger(params, "orderServiceType"));
|
||||
param.setStatusUpdateTime(params.get("statusUpdateTime"));
|
||||
param.setRemark(params.get("remark"));
|
||||
param.setCarType(params.get("carType"));
|
||||
param.setCarColor(params.get("carColor"));
|
||||
// 处理日期和列表等复杂类型
|
||||
return param;
|
||||
}
|
||||
|
||||
private static Integer getInteger(Map<String, String> params, String key) {
|
||||
if (params.containsKey(key) && params.get(key) != null && !params.get(key).isEmpty()) {
|
||||
return Integer.parseInt(params.get(key));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static Date parseDate(String dateString) throws ParseException {
|
||||
if (dateString != null && !dateString.isEmpty()) {
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
return sdf.parse(dateString);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.chint.interfaces.rest.amap.dto.note;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class AmapNoteResponse {
|
||||
private boolean result;
|
||||
private String message;
|
||||
private String timestamp;
|
||||
private int code;
|
||||
|
||||
public static AmapNoteResponse success(String message) {
|
||||
AmapNoteResponse amapNoteResponse = new AmapNoteResponse();
|
||||
amapNoteResponse.setResult(true);
|
||||
amapNoteResponse.setMessage(message);
|
||||
amapNoteResponse.setCode(1);
|
||||
amapNoteResponse.setTimestamp(String.valueOf(System.currentTimeMillis()));
|
||||
return amapNoteResponse;
|
||||
}
|
||||
|
||||
public static AmapNoteResponse error(String message) {
|
||||
AmapNoteResponse amapNoteResponse = new AmapNoteResponse();
|
||||
amapNoteResponse.setResult(false);
|
||||
amapNoteResponse.setMessage(message);
|
||||
amapNoteResponse.setCode(0);
|
||||
amapNoteResponse.setTimestamp(String.valueOf(System.currentTimeMillis()));
|
||||
return amapNoteResponse;
|
||||
}
|
||||
}
|
|
@ -53,9 +53,9 @@ public class TravelApplicationDto extends BaseRequestParam {
|
|||
//企业自定义字段(企业自行定义数据结构进行解析)长度限制1024
|
||||
private String enterpriseCustomFields;
|
||||
//申请单总限额(分),不传表示不限
|
||||
private String totalQuotaAmount;
|
||||
// private String totalQuotaAmount;
|
||||
//是否占用个人月度限额, 0 否 1 是,默认为0
|
||||
private String usePersonalAmount;
|
||||
// private String usePersonalAmount;
|
||||
/**
|
||||
* 支持的叫车业务类型
|
||||
*(1 实时单,2 预约单,3 接送机,5 接送站,6 代叫车;
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
package com.chint.interfaces.rest.amap.in;
|
||||
|
||||
import com.chint.application.commands.OrderStatusChangeCommand;
|
||||
import com.chint.domain.aggregates.order.OrderDetail;
|
||||
import com.chint.domain.service.supplier.SupplierService;
|
||||
import com.chint.domain.value_object.SupplierCallbackData;
|
||||
import com.chint.infrastructure.echo_framework.command.Command;
|
||||
import com.chint.interfaces.rest.amap.dto.detail.AmapOrderDetailResponse;
|
||||
import com.chint.interfaces.rest.amap.dto.note.AmapNoteParam;
|
||||
import com.chint.interfaces.rest.amap.dto.note.AmapNoteResponse;
|
||||
import com.chint.interfaces.rest.amap.request.AmapOrderDetailRequest;
|
||||
import com.google.gson.Gson;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.util.UriUtils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TAXI;
|
||||
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_AMAP;
|
||||
import static com.chint.interfaces.rest.amap.util.AmapStatusUtil.checkCarStatus;
|
||||
import static com.chint.interfaces.rest.amap.util.AmapStatusUtil.mapCarStatus;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/public/amap")
|
||||
public class AmapNoteController {
|
||||
|
||||
private Gson gson = new Gson();
|
||||
|
||||
@Autowired
|
||||
private AmapOrderDetailRequest amapOrderDetailRequest;
|
||||
|
||||
@Autowired
|
||||
private SupplierService supplierService;
|
||||
|
||||
@PostMapping("/status")
|
||||
public AmapNoteResponse statusEvent(@RequestBody String in) {
|
||||
// 拆分成键值对
|
||||
String[] pairs = in.split("&");
|
||||
Map<String, String> params = new HashMap<>();
|
||||
|
||||
// 解码每个参数值并存储在Map中
|
||||
for (String pair : pairs) {
|
||||
int idx = pair.indexOf("=");
|
||||
String key = idx > 0 ? pair.substring(0, idx) : pair;
|
||||
String value = idx > 0 && pair.length() > idx + 1 ? pair.substring(idx + 1) : null;
|
||||
// 解码参数值
|
||||
if (value != null) {
|
||||
value = UriUtils.decode(value, StandardCharsets.UTF_8);
|
||||
}
|
||||
params.put(key, value);
|
||||
}
|
||||
|
||||
AmapNoteParam amapNoteParam = AmapNoteParam.convert(params);
|
||||
String json = gson.toJson(amapNoteParam);
|
||||
log.info(json);
|
||||
|
||||
AmapOrderDetailResponse response = amapOrderDetailRequest.queryOrderDetail(amapNoteParam.getAmapOrderId());
|
||||
AmapOrderDetailResponse.Data data = response.getData();
|
||||
|
||||
if (checkCarStatus(data.getShowStatus())) {
|
||||
|
||||
Integer eventType = mapCarStatus(data.getShowStatus());
|
||||
|
||||
SupplierCallbackData supplierCallbackData = SupplierCallbackData.of(SUPPLIER_AMAP)
|
||||
.data(response)
|
||||
.productType(LEG_TYPE_TAXI)
|
||||
.outOrderStatus(String.valueOf(data.getShowStatus()))
|
||||
.selfOrderStatus(eventType);
|
||||
OrderDetail orderDetail = supplierService.handleSupplierCallback(supplierCallbackData);
|
||||
|
||||
Command.of(OrderStatusChangeCommand.class)
|
||||
.orderDetail(orderDetail)
|
||||
.orderNo(data.getAmapOrderId())
|
||||
.outStatus(String.valueOf(data.getShowStatus()))
|
||||
.eventType(eventType)
|
||||
.sendToQueue();
|
||||
|
||||
return AmapNoteResponse.success("接收成功");
|
||||
} else {
|
||||
return AmapNoteResponse.success("未产生实际费用,不保存订单明细");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package com.chint.interfaces.rest.amap.request;
|
||||
|
||||
import com.chint.interfaces.rest.amap.dto.detail.OrderDetailResponse;
|
||||
import com.chint.interfaces.rest.amap.dto.detail.AmapOrderDetailResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
@ -11,7 +11,7 @@ import java.util.Map;
|
|||
import static com.chint.infrastructure.constant.AmapConstant.ORDER_DETAIL_URL;
|
||||
|
||||
@Component
|
||||
public class OrderDetailRequest {
|
||||
public class AmapOrderDetailRequest {
|
||||
|
||||
@Value("${amap.baseUrl}")
|
||||
private String baseUrl;
|
||||
|
@ -23,9 +23,9 @@ public class OrderDetailRequest {
|
|||
* @param amapOrderId 高德订单号
|
||||
* @return
|
||||
*/
|
||||
public OrderDetailResponse queryOrderDetail(String amapOrderId) {
|
||||
public AmapOrderDetailResponse queryOrderDetail(String amapOrderId) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("amapOrderId", amapOrderId);
|
||||
return amapRequest.get(baseUrl + ORDER_DETAIL_URL, map, OrderDetailResponse.class);
|
||||
return amapRequest.get(baseUrl + ORDER_DETAIL_URL, map, AmapOrderDetailResponse.class);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.chint.interfaces.rest.amap.util;
|
||||
|
||||
import static com.chint.infrastructure.constant.FSSCConstant.FSSC_CAR_STATUS_REFUND;
|
||||
import static com.chint.infrastructure.constant.FSSCConstant.FSSC_CAR_STATUS_SUCCESS;
|
||||
import static com.chint.infrastructure.constant.OrderConstant.*;
|
||||
|
||||
public class AmapStatusUtil {
|
||||
public static boolean checkCarStatus(Integer showStatus) {
|
||||
return showStatus != null &&
|
||||
showStatus != 0 && //派单中(下单、平台改派、追加运力)
|
||||
showStatus != 1 && //完成待支付
|
||||
showStatus != 2 && //取消待支付
|
||||
showStatus != 3 && //关闭(无司机应答、司机取消、乘客取消、服务商取消、平台关单)
|
||||
showStatus != 5 && //待出发(司机接单)
|
||||
showStatus != 6 && //待上车(司机到达起点)
|
||||
showStatus != 7; //行程中(开始计费)
|
||||
}
|
||||
|
||||
|
||||
public static Integer mapCarStatus(Integer showStatus) {
|
||||
return switch (showStatus) {
|
||||
case 0 -> ORDER_EVENT_ORDERED; //派单中(下单、平台改派、追加运力)
|
||||
case 1 ->
|
||||
//完成待支付
|
||||
ORDER_EVENT_ORDERED;
|
||||
case 2 ->
|
||||
//取消待支付
|
||||
ORDER_EVENT_ORDERED;
|
||||
case 3 ->
|
||||
//关闭(无司机应答、司机取消、乘客取消、服务商取消、平台关单)
|
||||
ORDER_EVENT_REFUND;
|
||||
case 4 ->
|
||||
// 成功
|
||||
ORDER_EVENT_ORDERED;
|
||||
case 5 ->
|
||||
//待出发(司机接单)
|
||||
ORDER_EVENT_ORDERED;
|
||||
case 6 ->
|
||||
//待上车(司机到达起点)
|
||||
ORDER_EVENT_ORDERED;
|
||||
case 7 ->
|
||||
//行程中(开始计费)
|
||||
ORDER_EVENT_ORDERED;
|
||||
default ->
|
||||
// 处理未知或未映射的状态
|
||||
-99;
|
||||
};
|
||||
}
|
||||
|
||||
public static String mapFSSCOrderStatus(Integer showStatus) {
|
||||
Integer eventType = mapCarStatus(showStatus);
|
||||
return switch (eventType) {
|
||||
case ORDER_EVENT_ORDERED -> FSSC_CAR_STATUS_SUCCESS; //派单中(下单、平台改派、追加运力)
|
||||
case ORDER_EVENT_PAYED -> FSSC_CAR_STATUS_SUCCESS; //派单中(下单、平台改派、追加运力)
|
||||
case ORDER_EVENT_FINISH -> FSSC_CAR_STATUS_SUCCESS;
|
||||
case ORDER_EVENT_REFUND -> FSSC_CAR_STATUS_REFUND;
|
||||
default ->
|
||||
// 处理未知或未映射的状态
|
||||
"99";
|
||||
};
|
||||
}
|
||||
}
|
|
@ -9,17 +9,16 @@ import com.chint.interfaces.rest.amap.AmapLoginRequest;
|
|||
import com.chint.interfaces.rest.amap.AmapUserRequest;
|
||||
import com.chint.interfaces.rest.amap.BaseResponse;
|
||||
import com.chint.interfaces.rest.amap.dto.UserQueryResponse;
|
||||
import com.chint.interfaces.rest.amap.dto.detail.OrderDetailResponse;
|
||||
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.OrderDetailRequest;
|
||||
import com.chint.interfaces.rest.amap.request.AmapOrderDetailRequest;
|
||||
import com.chint.interfaces.rest.amap.request.SettleBillRequest;
|
||||
import com.chint.interfaces.rest.amap.request.TakeCarRequest;
|
||||
import com.chint.interfaces.rest.amap.request.TokenRequest;
|
||||
import com.chint.interfaces.rest.base.dto.H5LoginResponse;
|
||||
import com.chint.interfaces.rest.ctrip.CTripOrderSearchRequest;
|
||||
import com.chint.interfaces.rest.ctrip.dto.search.SearchOrderResponse;
|
||||
import com.google.gson.Gson;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -42,7 +41,7 @@ public class AmapTest {
|
|||
private AmapLocationRequest amapLocationRequest;
|
||||
|
||||
@Autowired
|
||||
private OrderDetailRequest orderDetailRequest;
|
||||
private AmapOrderDetailRequest orderDetailRequest;
|
||||
|
||||
private Gson gson = new Gson();
|
||||
|
||||
|
@ -56,7 +55,7 @@ public class AmapTest {
|
|||
@Test
|
||||
public void search() {
|
||||
Gson gson = new Gson();
|
||||
OrderDetailResponse orderDetailResponse = orderDetailRequest.queryOrderDetail("40920084001340019626730137");
|
||||
AmapOrderDetailResponse orderDetailResponse = orderDetailRequest.queryOrderDetail("40920084001340019626730137");
|
||||
System.out.println(gson.toJson(orderDetailResponse));
|
||||
}
|
||||
|
||||
|
@ -75,7 +74,7 @@ public class AmapTest {
|
|||
BaseContext.setCurrentUser(user);
|
||||
SupplierCallbackData supplierCallbackData =
|
||||
SupplierCallbackData.of(SUPPLIER_AMAP);
|
||||
OrderDetailResponse response = orderDetailRequest.queryOrderDetail("40920084001340019626730137");
|
||||
AmapOrderDetailResponse response = orderDetailRequest.queryOrderDetail("40920084001340019626730137");
|
||||
supplierCallbackData.data(response);
|
||||
supplierCallbackData.setSelfOrderStatus(1);
|
||||
supplierService.handleSupplierCallback(supplierCallbackData);
|
||||
|
@ -86,7 +85,7 @@ public class AmapTest {
|
|||
*/
|
||||
@Test
|
||||
public void queryorderDetail() {
|
||||
OrderDetailResponse orderDetailResponse = orderDetailRequest.queryOrderDetail("40920084001340019626730137");
|
||||
AmapOrderDetailResponse orderDetailResponse = orderDetailRequest.queryOrderDetail("40920084001340019626730137");
|
||||
System.out.println("orderDetailResponse = " + orderDetailResponse);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue