1.代客下单 台桌状态同步更新
This commit is contained in:
parent
7d1571628f
commit
91751b0f32
|
|
@ -7,6 +7,7 @@ import cn.ysk.cashier.dto.shoptable.*;
|
|||
import cn.ysk.cashier.pojo.order.TbCashierCart;
|
||||
import cn.ysk.cashier.service.product.TbProductService;
|
||||
import cn.ysk.cashier.service.shop.TbShopTableService;
|
||||
import cn.ysk.cashier.utils.RabbitMsgUtils;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
||||
|
|
@ -28,6 +29,7 @@ public class TbPlaceController {
|
|||
|
||||
private final TbProductService tbProductService;
|
||||
private final Validator validator;
|
||||
private final RabbitMsgUtils rabbitMsgUtils;
|
||||
|
||||
|
||||
@AnonymousAccess
|
||||
|
|
@ -43,11 +45,12 @@ public class TbPlaceController {
|
|||
return new ResponseEntity<>(tbProductService.activateProduct(page, size, categoryId, shopId, productId),HttpStatus.OK);
|
||||
}
|
||||
|
||||
public TbPlaceController(TbShopTableService tbShopTableService, TbProductService tbProductService, Validator validator, RabbitTemplate rabbitTemplate) {
|
||||
public TbPlaceController(TbShopTableService tbShopTableService, TbProductService tbProductService, Validator validator, RabbitTemplate rabbitTemplate, RabbitMsgUtils rabbitMsgUtils) {
|
||||
this.tbShopTableService = tbShopTableService;
|
||||
this.tbProductService = tbProductService;
|
||||
this.validator = validator;
|
||||
this.rabbitTemplate = rabbitTemplate;
|
||||
this.rabbitMsgUtils = rabbitMsgUtils;
|
||||
}
|
||||
|
||||
@AnonymousAccess
|
||||
|
|
@ -199,13 +202,15 @@ public class TbPlaceController {
|
|||
private final RabbitTemplate rabbitTemplate;
|
||||
@AnonymousAccess
|
||||
@GetMapping("/test")
|
||||
public void test() {
|
||||
public void test(
|
||||
@RequestParam Integer id
|
||||
) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("type", "create");
|
||||
jsonObject.put("orderId", "2980");
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.CART_ORDER_COLLECT_PUT, RabbitConstants.CART_ORDER_COLLECT_ROUTINGKEY_PUT, jsonObject.toJSONString(), new CorrelationData(UUID.randomUUID().toString()));
|
||||
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.PRINT_MECHINE_COLLECT_PUT, RabbitConstants.PRINT_MECHINE_COLLECT_ROUTINGKEY_PUT, "2980", new CorrelationData(UUID.randomUUID().toString()));
|
||||
jsonObject.put("orderId", id);
|
||||
// rabbitTemplate.convertAndSend(RabbitConstants.CART_ORDER_COLLECT_PUT, RabbitConstants.CART_ORDER_COLLECT_ROUTINGKEY_PUT, jsonObject.toJSONString(), new CorrelationData(UUID.randomUUID().toString()));
|
||||
rabbitMsgUtils.printTicket(String.valueOf(id));
|
||||
// rabbitTemplate.convertAndSend(RabbitConstants.PRINT_MECHINE_COLLECT_PUT, RabbitConstants.PRINT_MECHINE_COLLECT_ROUTINGKEY_PUT, id, new CorrelationData(UUID.randomUUID().toString()));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -711,6 +711,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
|
||||
@Override
|
||||
public TbOrderInfo createOrder(CreateOrderDTO createOrderDTO) {
|
||||
|
||||
String day = DateUtils.getDay();
|
||||
LambdaQueryWrapper<TbCashierCart> queryWrapper = new LambdaQueryWrapper<TbCashierCart>()
|
||||
.eq(TbCashierCart::getShopId, createOrderDTO.getShopId())
|
||||
|
|
@ -847,6 +848,9 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
|||
// 推送耗材信息
|
||||
pushConsMsg(orderInfo, cashierCarts);
|
||||
|
||||
mpShopTableMapper.update(null, new LambdaUpdateWrapper<TbShopTable>()
|
||||
.eq(TbShopTable::getQrcode, createOrderDTO.getTableId())
|
||||
.set(TbShopTable::getStatus, TableStateEnum.PENDING.getState()));
|
||||
|
||||
return orderInfo;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,19 +28,18 @@ public class RabbitMsgUtils implements RabbitTemplate.ConfirmCallback {
|
|||
}
|
||||
}
|
||||
|
||||
private <T> void sendMsg(String exchange, String routingKey, T data, String note) {
|
||||
private <T> void sendMsg(String exchange, String routingKey, T data, String note, boolean isJson) {
|
||||
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
|
||||
log.info("开始发送{}mq消息, msgId: {}, exchange: {}, routingKey: {}, data: {}", correlationId.getId(), note, exchange, routingKey, data);
|
||||
rabbitTemplate.convertAndSend(exchange, routingKey, JSONObject.toJSONString(data), correlationId);
|
||||
rabbitTemplate.convertAndSend(exchange, routingKey, isJson ? JSONObject.toJSONString(data) : data, correlationId);
|
||||
}
|
||||
|
||||
public <T> void sendOrderCollectMsg(T data) {
|
||||
sendMsg(RabbitConstants.CART_ORDER_COLLECT_PUT, RabbitConstants.CART_ORDER_COLLECT_ROUTINGKEY_PUT, data, "订单信息收集");
|
||||
sendMsg(RabbitConstants.CART_ORDER_COLLECT_PUT, RabbitConstants.CART_ORDER_COLLECT_ROUTINGKEY_PUT, data, "订单信息收集", true);
|
||||
}
|
||||
|
||||
public void printTicket(String orderId){
|
||||
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
|
||||
rabbitTemplate.convertAndSend(RabbitConstants.PRINT_MECHINE_COLLECT_PUT, RabbitConstants.PRINT_MECHINE_COLLECT_ROUTINGKEY_PUT, orderId, correlationId);
|
||||
sendMsg(RabbitConstants.PRINT_MECHINE_COLLECT_PUT, RabbitConstants.PRINT_MECHINE_COLLECT_ROUTINGKEY_PUT, orderId, "打印票", false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue