苍穹外卖--WebSocket-客户催单功能实现
This commit is contained in:
@@ -104,4 +104,18 @@ public class OrderController {
|
|||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户端催单
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@GetMapping("/reminder/{id}")
|
||||||
|
@ApiOperation("客户端催单")
|
||||||
|
public Result reminder(@PathVariable Long id) {
|
||||||
|
|
||||||
|
//调用业务层催单功能
|
||||||
|
orderService.reminder(id);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -99,4 +99,11 @@ public interface OrderService {
|
|||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
void complete(Long id);
|
void complete(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户催单
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
void reminder(Long id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -446,4 +446,28 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
|
|
||||||
orderMapper.update(orders);
|
orderMapper.update(orders);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户催单
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void reminder(Long id) {
|
||||||
|
//根据主键id查询订单信息
|
||||||
|
Orders order = orderMapper.getById(id);
|
||||||
|
//校验订单是否存在
|
||||||
|
if (order == null) {
|
||||||
|
throw new OrderBusinessException(MessageConstant.ORDER_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
//这里催单了,那就要让服务器向管理端发送催单提示
|
||||||
|
Map map = new HashMap();
|
||||||
|
map.put("type", 2);
|
||||||
|
map.put("orderId", order.getId());
|
||||||
|
map.put("content","订单号:"+order.getNumber());
|
||||||
|
//将java对象转为json字符串
|
||||||
|
String json = JSON.toJSONString(map);
|
||||||
|
webSocketServer.sendToAllClient(json);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user