feat:增加BPM查询消费明细接口

This commit is contained in:
lulz1 2024-05-21 13:45:38 +08:00
parent f3228db853
commit d63851d30c
8 changed files with 126 additions and 5 deletions

View File

@ -0,0 +1,29 @@
package com.chint.application.dtos;
import lombok.Data;
import java.util.List;
@Data
public class OrderDetailBPMVO {
private String employeeNo;
private String userName;
private String sequenceNo;
private String orderNo;
private String startTime;
private String endTime;
private String purpose;
private String reason;
private double totalAmount;
private List<OrderDetailBPMItem> routeDetail;
@Data
public static class OrderDetailBPMItem {
private String type;
private String bsDate;
private String edDate;
private String departCitiesName;
private String arriveCitiesName;
private double amount;
}
}

View File

@ -0,0 +1,9 @@
package com.chint.application.dtos;
import lombok.Data;
@Data
public class OrderDetailQueryParamBPM {
private String employeeNo;
private String sequenceNo;
}

View File

@ -1,21 +1,30 @@
package com.chint.application.dtos.mapper;
import cn.hutool.core.bean.BeanUtil;
import com.chint.domain.aggregates.order.RouteOrder;
import com.chint.application.dtos.OrderDetailBPMVO;
import com.chint.domain.aggregates.order.*;
import com.chint.domain.aggregates.user.User;
import com.chint.domain.repository.LocationRepository;
import com.chint.domain.repository.UserRepository;
import com.chint.domain.value_object.RouteOrderFiledVO;
import com.chint.infrastructure.util.DateTimeUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_HOTEL;
import static com.chint.infrastructure.constant.LegConstant.LEG_TYPE_TAXI;
@Component
public class RouteOrderMapper {
@Autowired
private UserRepository userRepository;
@Autowired
private LocationRepository locationRepository;
public RouteOrderFiledVO mapToFiledVO(RouteOrder routeOrder) {
RouteOrderFiledVO routeOrderFiledVO = BeanUtil.copyProperties(routeOrder, RouteOrderFiledVO.class);
List<RouteOrderFiledVO.RouteOrderExtensionFiled> routeOrderExtensionFileds = routeOrder
@ -28,4 +37,62 @@ public class RouteOrderMapper {
routeOrderFiledVO.setUserName(byUserEmployeeNo.getName());
return routeOrderFiledVO;
}
public OrderDetailBPMVO mapToOrderDetailVOBPM(RouteOrder routeOrder) {
OrderDetailBPMVO orderDetailBPMVO = new OrderDetailBPMVO();
ApproveOrderNo approveOrderNo = routeOrder.getApproveOrderNo();
if (approveOrderNo != null) {
orderDetailBPMVO.setSequenceNo(approveOrderNo.getActualOrderNo());
orderDetailBPMVO.setOrderNo(routeOrder.getRouteOrderNo());
orderDetailBPMVO.setReason(approveOrderNo.getInstructions());
orderDetailBPMVO.setPurpose("");
}
String userId = routeOrder.getUserId();
User user = userRepository.findByUserEmployeeNo(userId);
orderDetailBPMVO.setEmployeeNo(userId);
orderDetailBPMVO.setUserName(user.getName());
orderDetailBPMVO.setStartTime(DateTimeUtil.timeToStrCommon(routeOrder.getStartTime()));
orderDetailBPMVO.setEndTime(DateTimeUtil.timeToStrCommon(routeOrder.getEndTime()));
List<OrderDetailBPMVO.OrderDetailBPMItem> detailBPMItems = routeOrder.getOrderDetails()
.stream()
.map(orderDetail -> {
OrderDetailBPMVO.OrderDetailBPMItem orderDetailBPMItem = new OrderDetailBPMVO.OrderDetailBPMItem();
Integer productType = orderDetail.getProductType();
orderDetailBPMItem.setType(Leg.translateLegType(productType));
orderDetailBPMItem.setBsDate(DateTimeUtil.timeToStrCommon(orderDetail.getStartTime()));
orderDetailBPMItem.setEdDate(DateTimeUtil.timeToStrCommon(orderDetail.getEndTime()));
orderDetailBPMItem.setAmount(Double.parseDouble(orderDetail.getPrice()));
if (productType.equals(LEG_TYPE_TAXI)) {
CarOrderDetail carOrderDetail = orderDetail.getCarOrderDetail();
orderDetailBPMItem.setArriveCitiesName(
carOrderDetail.getToCity() + "-" + carOrderDetail.getToStationName()
);
orderDetailBPMItem.setDepartCitiesName(
carOrderDetail.getFromCity() + "-" + carOrderDetail.getFromStationName()
);
} else {
orderDetailBPMItem.setArriveCitiesName(
locationRepository.findByLocationId(orderDetail.getOriginId())
.getLocationName());
orderDetailBPMItem.setDepartCitiesName(
locationRepository.findByLocationId(orderDetail.getDestinationId())
.getLocationName()
);
}
if (productType.equals(LEG_TYPE_HOTEL)) {
HotelOrderDetail hotelOrderDetail = orderDetail.getHotelOrderDetail();
if (hotelOrderDetail != null) {
orderDetailBPMItem.setAmount(Double.parseDouble(hotelOrderDetail.getOrderAmount()));
}
}
return orderDetailBPMItem;
}).toList();
orderDetailBPMVO.setRouteDetail(detailBPMItems);
return orderDetailBPMVO;
}
}

View File

@ -2,6 +2,7 @@ package com.chint.application.out;
import com.chint.application.commands.RefundOrderGenerateCommand;
import com.chint.application.dtos.*;
import com.chint.application.dtos.mapper.RouteOrderMapper;
import com.chint.application.dtos.response.OrderDetailRes;
import com.chint.application.queryies.OrderDetailQuery;
import com.chint.domain.aggregates.order.*;
@ -45,6 +46,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import static com.chint.infrastructure.constant.BPMConstant.H3_BPM;
import static com.chint.infrastructure.constant.CommonMessageConstant.SUCCESS;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_C_TRIP;
import static com.chint.infrastructure.constant.SupplierNameConstant.SUPPLIER_L_Y;
@ -83,6 +85,9 @@ public class OrderDetailController {
@Autowired
private UserRepository userRepository;
@Autowired
private RouteOrderMapper routeOrderMapper;
@ApiOperation("订单明细认证接口")
@PostMapping("/public/authentication")
public Result<Token> queryAuthentication(@RequestBody AuthenticationDto authenticationDto) {
@ -115,6 +120,15 @@ public class OrderDetailController {
return Result.Success(SUCCESS, routeOrderDetail);
}
@ApiOperation("根据行程规划单查询消费明细-BPM")
@PostMapping("/public/query/detail/bpm")
public Result<OrderDetailBPMVO> queryOrderDetail(@RequestBody OrderDetailQueryParamBPM param) {
RouteOrder routeOrder = routeRepository
.findByActualOrderNoAndSysCode(param.getSequenceNo(), H3_BPM);
return Result.Success(SUCCESS, routeOrderMapper.mapToOrderDetailVOBPM(routeOrder));
}
@ApiOperation("订单明细导出接口")
@PostMapping("/export")
public ResponseEntity<Resource> export(@RequestBody AuthenticationSignDto authenticationDto) {

View File

@ -175,7 +175,7 @@ public class Leg implements Serializable {
};
}
public String translateLegType(int type) {
public static String translateLegType(int type) {
return switch (type) {
case LegConstant.LEG_TYPE_TRAIN -> LegConstant.LEG_TYPE_TRAIN_NAME;
case LegConstant.LEG_TYPE_AIRPLANE -> LegConstant.LEG_TYPE_AIRPLANE_NAME;
@ -186,7 +186,7 @@ public class Leg implements Serializable {
};
}
private String translateLegTypeEn(int type) {
private static String translateLegTypeEn(int type) {
return switch (type) {
case LEG_TYPE_TRAIN -> LEG_TYPE_TRAIN_EN_NAME;
case LEG_TYPE_AIRPLANE -> LEG_TYPE_AIRPLANE_EN_NAME;

View File

@ -582,6 +582,8 @@ public class RouteOrder implements Serializable {
return routeOrderDetail;
}
public boolean checkIfMine(String routeRequestNo) {
if (routeRequestNo == null || routeRequestNo.isEmpty()) {
return false;

View File

@ -9,7 +9,7 @@ public class QuerySqlWrapper {
public static void loadQuerySql(StringJoiner whereClause, MapSqlParameterSource parameters, OrderRecordQueryDTO queryDTO){
if (queryDTO.getSystemType() != null) {
whereClause.add("(belong_sys_type = :systemType or belong_sys_type is null)");
whereClause.add("(belong_sys_type = :systemType or belong_sys_type is null or belong_sys_type = 'NOT')");
parameters.addValue("systemType", queryDTO.getSystemType());
}
if (queryDTO.getTrvaleSysType() != null) {

View File

@ -820,7 +820,7 @@ public class LYTest {
@Test
void searchTrain() {
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DT24041870754514251");
TrainDetailResponse trainOrderDetail = lySearchRequest.getTrainOrderDetail("DT24051473497548329");
Gson gson = new Gson();
String json = gson.toJson(trainOrderDetail);
System.out.println(json);