取号打票
This commit is contained in:
@@ -28,4 +28,7 @@ public interface RabbitConstants {
|
|||||||
String QUEUE_PRINT_PLACE = "queue.place.order.print";
|
String QUEUE_PRINT_PLACE = "queue.place.order.print";
|
||||||
String ROUTING_KEY_PRINT_PLACE = "routing.place.order.print";
|
String ROUTING_KEY_PRINT_PLACE = "routing.place.order.print";
|
||||||
|
|
||||||
|
// 排队小票打印
|
||||||
|
String QUEUE_PRINT_CALL_TABLE = "queue.print.call.table";
|
||||||
|
String ROUTING_KEY_CALL_TABLE = "routing.call.table";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
package cn.ysk.cashier.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class CallNumPrintDTO {
|
||||||
|
private Integer callQueueId;
|
||||||
|
private Integer shopId;
|
||||||
|
}
|
||||||
@@ -5,12 +5,14 @@ import lombok.EqualsAndHashCode;
|
|||||||
|
|
||||||
import javax.validation.constraints.NotEmpty;
|
import javax.validation.constraints.NotEmpty;
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
|
import javax.validation.constraints.Pattern;
|
||||||
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
public class TakeNumberDTO extends BaseCallTableDTO{
|
public class TakeNumberDTO extends BaseCallTableDTO{
|
||||||
private Integer userId;
|
private Integer userId;
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
|
@Pattern(regexp = "^1\\d{10}$|^(0\\d{2,3}-?|\\(0\\d{2,3}\\))?[1-9]\\d{4,7}(-\\d{1,8})?$",message = "手机号码格式错误")
|
||||||
private String phone;
|
private String phone;
|
||||||
private String note;
|
private String note;
|
||||||
private String name;
|
private String name;
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import javax.validation.constraints.NotNull;
|
|||||||
public class AddCartDTO {
|
public class AddCartDTO {
|
||||||
@NotEmpty
|
@NotEmpty
|
||||||
private String masterId;
|
private String masterId;
|
||||||
private Integer vipUserId;
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private Integer productId;
|
private Integer productId;
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import cn.hutool.core.util.StrUtil;
|
|||||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||||
import cn.hutool.extra.qrcode.QrConfig;
|
import cn.hutool.extra.qrcode.QrConfig;
|
||||||
import cn.ysk.cashier.cons.RedisConstant;
|
import cn.ysk.cashier.cons.RedisConstant;
|
||||||
|
import cn.ysk.cashier.dto.CallNumPrintDTO;
|
||||||
import cn.ysk.cashier.dto.calltable.*;
|
import cn.ysk.cashier.dto.calltable.*;
|
||||||
import cn.ysk.cashier.exception.BadRequestException;
|
import cn.ysk.cashier.exception.BadRequestException;
|
||||||
import cn.ysk.cashier.mybatis.entity.TbCallConfig;
|
import cn.ysk.cashier.mybatis.entity.TbCallConfig;
|
||||||
@@ -20,12 +21,14 @@ import cn.ysk.cashier.pojo.shop.TbShopInfo;
|
|||||||
import cn.ysk.cashier.pojo.shop.TbShopUser;
|
import cn.ysk.cashier.pojo.shop.TbShopUser;
|
||||||
import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
|
import cn.ysk.cashier.repository.shop.TbShopInfoRepository;
|
||||||
import cn.ysk.cashier.service.app.TbCallService;
|
import cn.ysk.cashier.service.app.TbCallService;
|
||||||
|
import cn.ysk.cashier.utils.RabbitMsgUtils;
|
||||||
import cn.ysk.cashier.utils.Utils;
|
import cn.ysk.cashier.utils.Utils;
|
||||||
import cn.ysk.cashier.utils.WxMiniUtils;
|
import cn.ysk.cashier.utils.WxMiniUtils;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -35,9 +38,11 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@AllArgsConstructor
|
|
||||||
public class TbCallServiceImpl implements TbCallService {
|
public class TbCallServiceImpl implements TbCallService {
|
||||||
|
|
||||||
|
@Value("${wx.mini.page.call}")
|
||||||
|
private String callPageUrl;
|
||||||
|
|
||||||
private final TbCallTableService callTableService;
|
private final TbCallTableService callTableService;
|
||||||
private final TbCallQueueService callQueueService;
|
private final TbCallQueueService callQueueService;
|
||||||
private final TbShopUserMapper shopUserMapper;
|
private final TbShopUserMapper shopUserMapper;
|
||||||
@@ -46,6 +51,19 @@ public class TbCallServiceImpl implements TbCallService {
|
|||||||
private final TbCallQueueMapper tbCallQueueMapper;
|
private final TbCallQueueMapper tbCallQueueMapper;
|
||||||
private final WxMiniUtils wxMiniUtils;
|
private final WxMiniUtils wxMiniUtils;
|
||||||
private final TbCallConfigService tbCallConfigService;
|
private final TbCallConfigService tbCallConfigService;
|
||||||
|
private final RabbitMsgUtils rabbitMsgUtils;
|
||||||
|
|
||||||
|
public TbCallServiceImpl(TbCallTableService callTableService, TbCallQueueService callQueueService, TbShopUserMapper shopUserMapper, TbShopInfoRepository shopInfoRepository, StringRedisTemplate redisTemplate, TbCallQueueMapper tbCallQueueMapper, WxMiniUtils wxMiniUtils, TbCallConfigService tbCallConfigService, RabbitMsgUtils rabbitMsgUtils) {
|
||||||
|
this.callTableService = callTableService;
|
||||||
|
this.callQueueService = callQueueService;
|
||||||
|
this.shopUserMapper = shopUserMapper;
|
||||||
|
this.shopInfoRepository = shopInfoRepository;
|
||||||
|
this.redisTemplate = redisTemplate;
|
||||||
|
this.tbCallQueueMapper = tbCallQueueMapper;
|
||||||
|
this.wxMiniUtils = wxMiniUtils;
|
||||||
|
this.tbCallConfigService = tbCallConfigService;
|
||||||
|
this.rabbitMsgUtils = rabbitMsgUtils;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object add(CallTableDTO addCallTableDTO) {
|
public Object add(CallTableDTO addCallTableDTO) {
|
||||||
@@ -186,6 +204,10 @@ public class TbCallServiceImpl implements TbCallService {
|
|||||||
callQueue.setShopName(shopInfo.getShopName());
|
callQueue.setShopName(shopInfo.getShopName());
|
||||||
|
|
||||||
callQueueService.save(callQueue);
|
callQueueService.save(callQueue);
|
||||||
|
|
||||||
|
// 打印排号票信息
|
||||||
|
rabbitMsgUtils.printCallNumTicket(callQueue.getId(), callQueue.getShopId());
|
||||||
|
|
||||||
HashMap<String, Object> data = new HashMap<>();
|
HashMap<String, Object> data = new HashMap<>();
|
||||||
data.put("tableName", callTable.getName());
|
data.put("tableName", callTable.getName());
|
||||||
data.put("tableNote", callTable.getNote());
|
data.put("tableNote", callTable.getNote());
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package cn.ysk.cashier.utils;
|
package cn.ysk.cashier.utils;
|
||||||
|
|
||||||
import cn.ysk.cashier.cons.rabbit.RabbitConstants;
|
import cn.ysk.cashier.cons.rabbit.RabbitConstants;
|
||||||
|
import cn.ysk.cashier.dto.CallNumPrintDTO;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
import org.springframework.amqp.rabbit.connection.CorrelationData;
|
||||||
@@ -30,7 +31,7 @@ public class RabbitMsgUtils implements RabbitTemplate.ConfirmCallback {
|
|||||||
|
|
||||||
private <T> void sendMsg(String exchange, String routingKey, T data, String note, boolean isJson) {
|
private <T> void sendMsg(String exchange, String routingKey, T data, String note, boolean isJson) {
|
||||||
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
|
CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
|
||||||
log.info("开始发送{}mq消息, msgId: {}, exchange: {}, routingKey: {}, data: {}", correlationId.getId(), note, exchange, routingKey, data);
|
log.info("开始发送{}mq消息, msgId: {}, exchange: {}, routingKey: {}, data: {}", note, correlationId.getId(), exchange, routingKey, data);
|
||||||
rabbitTemplate.convertAndSend(exchange, routingKey, isJson ? JSONObject.toJSONString(data) : data, correlationId);
|
rabbitTemplate.convertAndSend(exchange, routingKey, isJson ? JSONObject.toJSONString(data) : data, correlationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,4 +71,11 @@ public class RabbitMsgUtils implements RabbitTemplate.ConfirmCallback {
|
|||||||
sendMsg(RabbitConstants.EXCHANGE_PRINT, RabbitConstants.ROUTING_KEY_PRINT_PLACE, jsonObject, "订单打印", false);
|
sendMsg(RabbitConstants.EXCHANGE_PRINT, RabbitConstants.ROUTING_KEY_PRINT_PLACE, jsonObject, "订单打印", false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void printCallNumTicket(Integer callQueueId, Integer shopId) {
|
||||||
|
CallNumPrintDTO printDTO = new CallNumPrintDTO();
|
||||||
|
printDTO.setCallQueueId(callQueueId);
|
||||||
|
printDTO.setShopId(shopId);
|
||||||
|
sendMsg(RabbitConstants.EXCHANGE_PRINT, RabbitConstants.ROUTING_KEY_CALL_TABLE, printDTO, "排号小票打印", true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user