feat: 完成添加订单接口,其他待完善;订单增加重量字段
This commit is contained in:
parent
30b6456b76
commit
a1445e792d
@ -1,15 +1,27 @@
|
||||
package com.aircraft.modules.order.biz;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.aircraft.modules.order.domain.OrderMain;
|
||||
import com.aircraft.modules.order.domain.OrderOperator;
|
||||
import com.aircraft.modules.order.domain.dto.AddOrderDTO;
|
||||
import com.aircraft.modules.order.domain.dto.OrderMainPageQueryDTO;
|
||||
import com.aircraft.modules.order.domain.enums.MainOrderStatusEnum;
|
||||
import com.aircraft.modules.order.domain.enums.OrderSettlementStatusEnum;
|
||||
import com.aircraft.modules.order.domain.vo.OrderMainPageQueryVO;
|
||||
import com.aircraft.modules.order.service.IOrderMainService;
|
||||
import com.aircraft.modules.order.service.IOrderOperatorService;
|
||||
import com.aircraft.utils.PageResult;
|
||||
import com.aircraft.utils.SecurityUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -31,7 +43,7 @@ public class OrderBiz {
|
||||
private IOrderOperatorService orderOperatorService;
|
||||
|
||||
public List<OrderMainPageQueryVO> queryAll(OrderMainPageQueryDTO pageQueryDTO) {
|
||||
|
||||
UserDetails currentUser = SecurityUtils.getCurrentUser();
|
||||
// TODO 根据不同的用户角色获取不同的订单数据
|
||||
List<OrderMain> list = orderMainService.queryAll(pageQueryDTO);
|
||||
|
||||
@ -46,4 +58,64 @@ public class OrderBiz {
|
||||
List<OrderMainPageQueryVO> orderMainList = new ArrayList<>();
|
||||
return orderMainList;
|
||||
}
|
||||
|
||||
public ResponseEntity<PageResult<Object>> relevanceOrder() {
|
||||
// TODO获取当前登录用户,通过手机号和订单号进行关联
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void addOrder(AddOrderDTO addOrderDTO) {
|
||||
|
||||
// TODO 获取当前登录用户(飞行端用户)
|
||||
UserDetails currentUser = SecurityUtils.getCurrentUser();
|
||||
// 发起人ID
|
||||
Long orderInitiatorId = SecurityUtils.getCurrentUserId();
|
||||
|
||||
// 新增订单
|
||||
OrderMain orderMain = orderMainService.addOrder(buildOrderParam(addOrderDTO, orderInitiatorId));
|
||||
// 构建保存操作人信息
|
||||
List<Long> operatorIds = addOrderDTO.getOperatorIds();
|
||||
List<OrderOperator> orderOperatorList = new ArrayList<>();
|
||||
for (Long operatorId : operatorIds) {
|
||||
OrderOperator orderOperator = new OrderOperator();
|
||||
orderOperator.setOrderId(orderMain.getId());
|
||||
orderOperator.setOperatorId(operatorId);
|
||||
orderOperatorList.add(orderOperator);
|
||||
}
|
||||
// 批量新增订单操作人
|
||||
orderOperatorService.batchAddOrderOperator(orderOperatorList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建新增订单参数
|
||||
*
|
||||
* @param addOrderDTO {@link AddOrderDTO}
|
||||
* @param orderInitiatorId 当前登录人即为订单发起人
|
||||
* @return {@link OrderMain}
|
||||
*/
|
||||
private OrderMain buildOrderParam(AddOrderDTO addOrderDTO, Long orderInitiatorId) {
|
||||
// TODO 生成订单编号《待优化 年月日+时分秒 +五位随机数Redis进行自增》
|
||||
String orderNO = "JS" + System.currentTimeMillis();
|
||||
List<Long> routeIds = addOrderDTO.getRouteIds();
|
||||
// 逗号分隔成字符串
|
||||
String routeIdsStr = CollectionUtil.join(routeIds, StrUtil.COMMA);
|
||||
// TODO 根据重量计算总金额<取自金额配置表 待完善>
|
||||
BigDecimal amount = addOrderDTO.getCargoWeight().multiply(new BigDecimal("0.01"));
|
||||
OrderMain orderMain = new OrderMain();
|
||||
orderMain.setOrderNo(orderNO);
|
||||
orderMain.setOrderInitiatorId(orderInitiatorId);
|
||||
orderMain.setOrderType(addOrderDTO.getOrderType());
|
||||
orderMain.setPhone(addOrderDTO.getPhone());
|
||||
orderMain.setAttractionId(addOrderDTO.getAttractionId());
|
||||
orderMain.setCustomerId(addOrderDTO.getCustomerId());
|
||||
orderMain.setRouteIds(routeIdsStr);
|
||||
orderMain.setCargoWeight(addOrderDTO.getCargoWeight());
|
||||
orderMain.setAmount(amount);
|
||||
orderMain.setSurchargeAmount(addOrderDTO.getSurchargeAmount());
|
||||
orderMain.setOrderCreateTime(addOrderDTO.getOrderCreateTime());
|
||||
orderMain.setMainOrderStatus(MainOrderStatusEnum.NOT_STARTED.getCode());
|
||||
orderMain.setSettlementStatus(OrderSettlementStatusEnum.NOT_SETTLED.getCode());
|
||||
return orderMain;
|
||||
}
|
||||
}
|
||||
|
@ -2,16 +2,18 @@ package com.aircraft.modules.order.controller;
|
||||
|
||||
|
||||
import com.aircraft.modules.order.biz.OrderBiz;
|
||||
import com.aircraft.modules.order.domain.OrderMain;
|
||||
import com.aircraft.modules.order.domain.dto.AddOrderDTO;
|
||||
import com.aircraft.modules.order.domain.dto.OrderMainPageQueryDTO;
|
||||
import com.aircraft.modules.order.domain.vo.OrderMainPageQueryVO;
|
||||
import com.aircraft.utils.PageResult;
|
||||
import com.aircraft.utils.PageUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import io.swagger.annotations.ApiParam;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@ -35,11 +37,33 @@ public class OrderMainController {
|
||||
private OrderBiz orderBiz;
|
||||
|
||||
@ApiOperation("查询订单列表")
|
||||
@GetMapping
|
||||
public ResponseEntity<PageResult<OrderMainPageQueryVO>> queryDept(OrderMainPageQueryDTO pageQueryDTO) {
|
||||
@GetMapping("/allOrder")
|
||||
public ResponseEntity<PageResult<OrderMainPageQueryVO>> queryOrderList(OrderMainPageQueryDTO pageQueryDTO) {
|
||||
// TODO 待完善<考虑根据不同的登录获取不同的分页查询>
|
||||
List<OrderMainPageQueryVO> orderList = orderBiz.queryAll(pageQueryDTO);
|
||||
return new ResponseEntity<>(PageUtil.toPage(orderList),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("新增订单")
|
||||
@GetMapping("/addOrder")
|
||||
public ResponseEntity<Object> addOrder(AddOrderDTO addOrderDTO) {
|
||||
orderBiz.addOrder(addOrderDTO);
|
||||
return new ResponseEntity<Object>(HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("新增订单任务")
|
||||
@GetMapping("/addOrderTask")
|
||||
public ResponseEntity<Object> addOrderTask(OrderMainPageQueryDTO pageQueryDTO) {
|
||||
|
||||
List<OrderMainPageQueryVO> orderList = orderBiz.queryAll(pageQueryDTO);
|
||||
return new ResponseEntity<>(PageUtil.toPage(orderList),HttpStatus.OK);
|
||||
}
|
||||
|
||||
@ApiOperation("用户端关联订单")
|
||||
@PostMapping("/relevanceOrder")
|
||||
public ResponseEntity<Object> relevanceOrder(@ApiParam(value = "订单编号", required = true, example = "JS2025071300001")String orderNO) {
|
||||
orderBiz.relevanceOrder();
|
||||
return new ResponseEntity<>(HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,8 @@ import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 订单明细表
|
||||
@ -43,6 +45,12 @@ public class OrderDetail extends BaseEntity {
|
||||
*/
|
||||
private Long routeId;
|
||||
|
||||
|
||||
/**
|
||||
* 货物重量
|
||||
*/
|
||||
private BigDecimal cargoWeight;
|
||||
|
||||
/**
|
||||
* 载人数量
|
||||
*/
|
||||
|
@ -1,14 +1,15 @@
|
||||
package com.aircraft.modules.order.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.aircraft.base.BaseEntity;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 订单主表
|
||||
@ -38,7 +39,7 @@ public class OrderMain extends BaseEntity {
|
||||
/**
|
||||
* 订单类型
|
||||
*/
|
||||
private Boolean orderType;
|
||||
private Integer orderType;
|
||||
|
||||
/**
|
||||
* 订单发起人ID
|
||||
@ -56,15 +57,20 @@ public class OrderMain extends BaseEntity {
|
||||
private Long attractionId;
|
||||
|
||||
/**
|
||||
* 客户名称
|
||||
* 客户ID
|
||||
*/
|
||||
private String customerName;
|
||||
private Long customerId;
|
||||
|
||||
/**
|
||||
* 路线ID,多个用逗号分隔
|
||||
*/
|
||||
private String routeIds;
|
||||
|
||||
/**
|
||||
* 货物重量
|
||||
*/
|
||||
private BigDecimal cargoWeight;
|
||||
|
||||
/**
|
||||
* 订单金额
|
||||
*/
|
||||
|
@ -16,9 +16,9 @@ import lombok.EqualsAndHashCode;
|
||||
* @since 2025-07-10
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("fms_od_order_operator")
|
||||
public class OrderOperator extends BaseEntity {
|
||||
public class OrderOperator{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -0,0 +1,90 @@
|
||||
package com.aircraft.modules.order.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.DecimalMin;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* 新增订单DTO
|
||||
*
|
||||
* @author chenxiky
|
||||
* @version 1.0.0
|
||||
* @since 2025/7/14
|
||||
*/
|
||||
@Data
|
||||
public class AddOrderDTO {
|
||||
/**
|
||||
* 订单类型: 目前只有一种类型载物:值为 1
|
||||
*/
|
||||
@ApiModelProperty(value = "飞行员(负责人)id")
|
||||
private Integer orderType;
|
||||
|
||||
/**
|
||||
* 客户ID
|
||||
*/
|
||||
@NotNull(message = "客户ID不能为空")
|
||||
@ApiModelProperty(value = "客户ID")
|
||||
private Long customerId;
|
||||
|
||||
/**
|
||||
* 客户手机号
|
||||
*/
|
||||
@NotBlank(message = "客户手机号不能为空")
|
||||
@ApiModelProperty(value = "客户手机号")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 景区ID
|
||||
*/
|
||||
@NotNull(message = "景区ID不能为空")
|
||||
@ApiModelProperty(value = "景区ID")
|
||||
private Long attractionId;
|
||||
|
||||
/**
|
||||
* 路线ID集合
|
||||
*/
|
||||
@NotNull
|
||||
@NotEmpty(message = "路线ID集合不能为空")
|
||||
@ApiModelProperty(value = "路线ID集合")
|
||||
private List<Long> routeIds;
|
||||
|
||||
/**
|
||||
* 货物重量
|
||||
*/
|
||||
@NotNull
|
||||
@DecimalMin(value = "0.01", message = "货物重量必须大于0")
|
||||
@ApiModelProperty(value = "货物重量")
|
||||
private BigDecimal cargoWeight;
|
||||
|
||||
/**
|
||||
* 额外费用
|
||||
*/
|
||||
@ApiModelProperty(value = "额外费用")
|
||||
private BigDecimal surchargeAmount;
|
||||
|
||||
/**
|
||||
* 操作人集合ID
|
||||
*/
|
||||
@NotNull(message = "操作人集合ID不能为空")
|
||||
@NotEmpty
|
||||
@ApiModelProperty(value = "操作人集合ID")
|
||||
private List<Long> operatorIds;
|
||||
|
||||
/**
|
||||
* 下单时间
|
||||
*/
|
||||
@NotNull(message = "下单时间不能为空")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "下单时间", example = "2023-08-01 12:00:00")
|
||||
private Date orderCreateTime;
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.aircraft.modules.order.domain.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@ -13,4 +14,22 @@ import lombok.Data;
|
||||
@Data
|
||||
public class OrderMainPageQueryDTO {
|
||||
|
||||
/**
|
||||
* 景区ID
|
||||
*/
|
||||
@ApiModelProperty("景区ID")
|
||||
private Long attractionId;
|
||||
|
||||
/**
|
||||
* 客户ID
|
||||
*/
|
||||
@ApiModelProperty("客户ID")
|
||||
private Long customerId;
|
||||
|
||||
/**
|
||||
* 客户手机号
|
||||
*/
|
||||
@ApiModelProperty(value = "下单时间", example = "13788888888")
|
||||
private String phone;
|
||||
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.aircraft.modules.order.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@ -13,4 +14,38 @@ import lombok.Data;
|
||||
@Data
|
||||
public class OrderMainPageQueryVO {
|
||||
|
||||
/**
|
||||
* ID
|
||||
*/
|
||||
@ApiModelProperty(value = "ID")
|
||||
private Long id;
|
||||
/**
|
||||
* 订单类型
|
||||
*/
|
||||
@ApiModelProperty(value = "订单类型")
|
||||
private Integer orderType;
|
||||
|
||||
/**
|
||||
* 客户ID
|
||||
*/
|
||||
@ApiModelProperty(value = "客户ID")
|
||||
private Long customerId;
|
||||
|
||||
/**
|
||||
* 景区ID
|
||||
*/
|
||||
@ApiModelProperty(value = "景区ID")
|
||||
private Long attractionId;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@ApiModelProperty(value = "手机号")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 路线名称,拼接返回
|
||||
*/
|
||||
@ApiModelProperty(value = "路线")
|
||||
private String routeName;
|
||||
}
|
||||
|
@ -25,4 +25,12 @@ public interface IOrderMainService extends IService<OrderMain> {
|
||||
List<OrderMain> queryAll(OrderMainPageQueryDTO pageQueryDTO);
|
||||
|
||||
List<OrderMain> queryAllOrders();
|
||||
|
||||
/**
|
||||
* 新增订单
|
||||
*
|
||||
* @param orderMain {@link OrderMain}
|
||||
* @return {@link OrderMain}
|
||||
*/
|
||||
OrderMain addOrder(OrderMain orderMain);
|
||||
}
|
||||
|
@ -22,4 +22,12 @@ public interface IOrderOperatorService extends IService<OrderOperator> {
|
||||
* @return {@link List<OrderOperator>}
|
||||
*/
|
||||
List<OrderOperator> queryAllByOrderIds(List<Long> orderIds);
|
||||
|
||||
/**
|
||||
* 批量新增
|
||||
*
|
||||
* @param orderOperatorList {@link List<OrderOperator>}
|
||||
* @return boolean
|
||||
*/
|
||||
boolean batchAddOrderOperator(List<OrderOperator> orderOperatorList);
|
||||
}
|
||||
|
@ -27,6 +27,9 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
|
||||
|
||||
// TODO 构建查询条件
|
||||
LambdaQueryWrapper<OrderMain> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(OrderMain::getAttractionId, pageQueryDTO.getAttractionId());
|
||||
queryWrapper.eq(OrderMain::getCustomerId, pageQueryDTO.getCustomerId());
|
||||
queryWrapper.eq(OrderMain::getPhone, pageQueryDTO.getPhone());
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
@ -38,4 +41,10 @@ public class OrderMainServiceImpl extends ServiceImpl<OrderMainMapper, OrderMain
|
||||
// 直接调用 MyBatis-Plus 提供的 baseMapper.selectList 方法
|
||||
return baseMapper.selectList(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderMain addOrder(OrderMain orderMain) {
|
||||
this.save(orderMain);
|
||||
return orderMain;
|
||||
}
|
||||
}
|
||||
|
@ -27,4 +27,9 @@ public class OrderOperatorServiceImpl extends ServiceImpl<OrderOperatorMapper, O
|
||||
queryWrapper.in(OrderOperator::getOrderId, orderIds);
|
||||
return list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean batchAddOrderOperator(List<OrderOperator> orderOperatorList) {
|
||||
return this.saveBatch(orderOperatorList);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user