fix: 公开订单接口支持不传customerId(兼容旧订单)
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Agent
2026-03-29 07:25:12 +00:00
parent 4f5fbcdc8f
commit 19d7917b39

View File

@@ -33,17 +33,22 @@ public class PublicOrderController {
@GetMapping("/orders/{orderNo}") @GetMapping("/orders/{orderNo}")
public Result<Map<String, Object>> getOrderByNo( public Result<Map<String, Object>> getOrderByNo(
@PathVariable String orderNo, @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>() new com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<Order>()
.eq(Order::getOrderNo, orderNo) .eq(Order::getOrderNo, orderNo);
.eq(Order::getCustomerId, customerId)
); // 如果提供了customerId则校验
if (customerId != null && !customerId.isEmpty()) {
wrapper.eq(Order::getCustomerId, customerId);
}
Order order = orderMapper.selectOne(wrapper);
if (order == null) { if (order == null) {
return Result.error("订单不存在或客户信息不匹配"); return Result.error("订单不存在");
} }
// 查询订单明细 // 查询订单明细