fix: 公开订单接口支持不传customerId(兼容旧订单)
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -33,17 +33,22 @@ public class PublicOrderController {
|
||||
@GetMapping("/orders/{orderNo}")
|
||||
public Result<Map<String, Object>> getOrderByNo(
|
||||
@PathVariable String orderNo,
|
||||
@RequestParam String customerId) {
|
||||
@RequestParam(required = false) String customerId) {
|
||||
|
||||
// 查询订单
|
||||
Order order = orderMapper.selectOne(
|
||||
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<Order> wrapper =
|
||||
new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<Order>()
|
||||
.eq(Order::getOrderNo, orderNo)
|
||||
.eq(Order::getCustomerId, customerId)
|
||||
);
|
||||
.eq(Order::getOrderNo, orderNo);
|
||||
|
||||
// 如果提供了customerId,则校验
|
||||
if (customerId != null && !customerId.isEmpty()) {
|
||||
wrapper.eq(Order::getCustomerId, customerId);
|
||||
}
|
||||
|
||||
Order order = orderMapper.selectOne(wrapper);
|
||||
|
||||
if (order == null) {
|
||||
return Result.error("订单不存在或客户信息不匹配");
|
||||
return Result.error("订单不存在");
|
||||
}
|
||||
|
||||
// 查询订单明细
|
||||
|
||||
Reference in New Issue
Block a user