苍穹外卖--WebSocket-客户催单功能实现

This commit is contained in:
2025-12-01 15:04:53 +08:00
parent cdc50bebf7
commit 8972018b65
3 changed files with 45 additions and 0 deletions

View File

@@ -99,4 +99,11 @@ public interface OrderService {
* @param id
*/
void complete(Long id);
/**
* 客户催单
* @param id
*/
void reminder(Long id);
}

View File

@@ -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);
}
}