|
|
@@ -404,5 +404,65 @@ public class UserOrderController extends BaseController {
|
|
|
} catch (Exception ignored) {}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 确认取餐(自取类型订单,state=2 → state=3)
|
|
|
+ */
|
|
|
+ @PostMapping("/confirmPickup")
|
|
|
+ @Auth
|
|
|
+ @Anonymous
|
|
|
+ public AjaxResult confirmPickup(@RequestHeader String token, @RequestParam String ddId) {
|
|
|
+ JwtUtil jwtUtil = new JwtUtil();
|
|
|
+ String userId = jwtUtil.getusid(token);
|
|
|
+
|
|
|
+ PosOrder order = posOrderService.getOne(
|
|
|
+ new LambdaQueryWrapper<PosOrder>()
|
|
|
+ .eq(PosOrder::getDdId, ddId)
|
|
|
+ .eq(PosOrder::getUserId, Long.valueOf(userId))
|
|
|
+ );
|
|
|
+ if (order == null) {
|
|
|
+ return error("订单不存在");
|
|
|
+ }
|
|
|
+ if (order.getType() == null || order.getType() != 1) {
|
|
|
+ return error("仅自取订单可确认取餐");
|
|
|
+ }
|
|
|
+ if (order.getState() == null || order.getState() != 2) {
|
|
|
+ return error("当前订单状态不可确认取餐");
|
|
|
+ }
|
|
|
+ if (order.getPayStatus() == null || order.getPayStatus() != 1) {
|
|
|
+ return error("订单未支付,不可确认取餐");
|
|
|
+ }
|
|
|
+ if (order.getAfterSaleStatus() != null && order.getAfterSaleStatus() > 0) {
|
|
|
+ return error("订单存在售后处理中,不可确认取餐");
|
|
|
+ }
|
|
|
+ order.setState(3L);
|
|
|
+ posOrderService.updateById(order);
|
|
|
+ return success("确认取餐成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 取消订单(未接单前,state=0 → state=4)
|
|
|
+ */
|
|
|
+ @PostMapping("/cancelOrder")
|
|
|
+ @Auth
|
|
|
+ @Anonymous
|
|
|
+ public AjaxResult cancelOrder(@RequestHeader String token, @RequestParam String ddId) {
|
|
|
+ JwtUtil jwtUtil = new JwtUtil();
|
|
|
+ String userId = jwtUtil.getusid(token);
|
|
|
+
|
|
|
+ PosOrder order = posOrderService.getOne(
|
|
|
+ new LambdaQueryWrapper<PosOrder>()
|
|
|
+ .eq(PosOrder::getDdId, ddId)
|
|
|
+ .eq(PosOrder::getUserId, Long.valueOf(userId))
|
|
|
+ );
|
|
|
+ if (order == null) {
|
|
|
+ return error("订单不存在");
|
|
|
+ }
|
|
|
+ if (order.getState() == null || order.getState() != 0) {
|
|
|
+ return error("仅待处理状态的订单可取消");
|
|
|
+ }
|
|
|
+ order.setState(4L);
|
|
|
+ posOrderService.updateById(order);
|
|
|
+ return success("取消订单成功");
|
|
|
+ }
|
|
|
|
|
|
}
|