苍穹外卖--WebSocket-客户催单功能实现
This commit is contained in:
@@ -99,4 +99,11 @@ public interface OrderService {
|
||||
* @param id
|
||||
*/
|
||||
void complete(Long id);
|
||||
|
||||
/**
|
||||
* 客户催单
|
||||
* @param id
|
||||
*/
|
||||
void reminder(Long id);
|
||||
|
||||
}
|
||||
|
||||
@@ -446,4 +446,28 @@ public class OrderServiceImpl implements OrderService {
|
||||
|
||||
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