店铺小票打印记录需求
This commit is contained in:
@@ -5,17 +5,23 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.*;
|
||||
import com.chaozhanggui.system.cashierservice.entity.*;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbOrderDetailMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbOrderInfoMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderDetail;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbOrderInfo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbPrintMachine;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopInfo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.CallNumPrintDTO;
|
||||
import com.chaozhanggui.system.cashierservice.mybatis.MpPrintMachineMapper;
|
||||
import com.chaozhanggui.system.cashierservice.rabbit.print.PrinterHandler;
|
||||
import com.chaozhanggui.system.cashierservice.util.*;
|
||||
import com.chaozhanggui.system.cashierservice.util.Utils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@@ -45,6 +51,9 @@ public class PrintConsumer {
|
||||
Integer orderId = jsonObject.getInteger("orderId");
|
||||
JSONArray orderDetailIds = jsonObject.getJSONArray("orderDetailIds");
|
||||
Boolean isReturn = jsonObject.getBoolean("isReturn");
|
||||
Long currentUserId = jsonObject.getLong("currentUserId");
|
||||
String currentUserName = jsonObject.getString("currentUserName");
|
||||
String currentUserNickName = jsonObject.getString("currentUserNickName");
|
||||
|
||||
TbOrderInfo orderInfo = tbOrderInfoMapper.selectByPrimaryKey(orderId);
|
||||
Utils.checkValueUnReturn(orderInfo, "订单信息不存在");
|
||||
@@ -59,6 +68,9 @@ public class PrintConsumer {
|
||||
}
|
||||
getPrintMachine(Integer.valueOf(orderInfo.getShopId()), "cash", "one").forEach(machine -> {
|
||||
log.info("打印机信息: {}", machine);
|
||||
machine.setCurrentUserId(currentUserId);
|
||||
machine.setCurrentUserName(currentUserName);
|
||||
machine.setCurrentUserNickName(currentUserNickName);
|
||||
printerHandler.handleRequest(machine, isReturn, orderInfo, orderDetails, null);
|
||||
});
|
||||
|
||||
@@ -99,6 +111,9 @@ public class PrintConsumer {
|
||||
CallNumPrintDTO printDTO = JSONObject.parseObject(msg, CallNumPrintDTO.class);
|
||||
|
||||
getPrintMachine(printDTO.getShopId(), "cash", "callTicket").forEach(machine -> {
|
||||
machine.setCurrentUserId(printDTO.getCurrentUserId());
|
||||
machine.setCurrentUserName(printDTO.getCurrentUserName());
|
||||
machine.setCurrentUserNickName(printDTO.getCurrentUserNickName());
|
||||
printerHandler.handleRequest(machine, false, null, null, printDTO);
|
||||
});
|
||||
|
||||
|
||||
@@ -15,18 +15,20 @@ import com.chaozhanggui.system.cashierservice.entity.po.CallNumPrintPO;
|
||||
import com.chaozhanggui.system.cashierservice.mapper.TbCallQueueMapper;
|
||||
import com.chaozhanggui.system.cashierservice.mapper.TbCallTableMapper;
|
||||
import com.chaozhanggui.system.cashierservice.model.OrderDetailPO;
|
||||
import com.chaozhanggui.system.cashierservice.service.ShopPrintLogService;
|
||||
import com.chaozhanggui.system.cashierservice.util.DateUtils;
|
||||
import com.chaozhanggui.system.cashierservice.util.PrinterUtils;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class YxyPrinter extends PrinterHandler{
|
||||
public class YxyPrinter extends PrinterHandler {
|
||||
private final TbCallQueueMapper tbCallQueueMapper;
|
||||
private final TbCallTableMapper tbCallTableMapper;
|
||||
@Value("${wx.mini.page.call}")
|
||||
@@ -34,6 +36,9 @@ public class YxyPrinter extends PrinterHandler{
|
||||
|
||||
private final TbShopInfoMapper shopInfoMapper;
|
||||
|
||||
@Resource
|
||||
private ShopPrintLogService shopPrintLogService;
|
||||
|
||||
public YxyPrinter(TbShopInfoMapper shopInfoMapper, TbProductMapper productMapper, TbProductSkuMapper productSkuMapper, TbShopUserMapper shopUserMapper, TbCallQueueMapper tbCallQueueMapper, TbCallTableMapper tbCallTableMapper) {
|
||||
super("yxyPrinter", productMapper, productSkuMapper, shopUserMapper);
|
||||
this.shopInfoMapper = shopInfoMapper;
|
||||
@@ -46,10 +51,10 @@ public class YxyPrinter extends PrinterHandler{
|
||||
if ("miniapp".equals(orderInfo.getOrderType())) {
|
||||
if (OrderUseTypeEnum.TAKEOUT.getValue().equals(orderInfo.getUseType())) {
|
||||
pickupNum = orderInfo.getOutNumber();
|
||||
}else {
|
||||
} else {
|
||||
pickupNum = orderInfo.getTableName();
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
pickupNum = orderInfo.getMasterId();
|
||||
}
|
||||
return pickupNum;
|
||||
@@ -63,7 +68,8 @@ public class YxyPrinter extends PrinterHandler{
|
||||
Math.abs(orderDetail.getNum()), orderDetail.getRemark(), orderDetail.getNote());
|
||||
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔退款订单,请及时处理\"}";
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
|
||||
String resp = PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
|
||||
shopPrintLogService.save(machine, "退款单", data, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -73,7 +79,8 @@ public class YxyPrinter extends PrinterHandler{
|
||||
orderDetail.getNum(), orderDetail.getRemark(), orderDetail.getNote());
|
||||
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
|
||||
String resp = PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
|
||||
shopPrintLogService.save(machine, "新订单", data, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,7 +96,8 @@ public class YxyPrinter extends PrinterHandler{
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, printType, "return");
|
||||
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
PrinterUtils.printTickets(voiceJson, 1, 1, machine.getAddress(), data);
|
||||
String resp = PrinterUtils.printTickets(voiceJson, 1, 1, machine.getAddress(), data);
|
||||
shopPrintLogService.save(machine, printType, data, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,7 +116,8 @@ public class YxyPrinter extends PrinterHandler{
|
||||
String data = PrinterUtils.getCashPrintData(detailPO, printType, orderInfo.getOrderType());
|
||||
// String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一笔新的订单,请及时处理\"}";
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"\"}";
|
||||
PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
|
||||
String resp = PrinterUtils.printTickets(voiceJson, 3, 1, machine.getAddress(), data);
|
||||
shopPrintLogService.save(machine, printType, data, resp);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -137,7 +146,10 @@ public class YxyPrinter extends PrinterHandler{
|
||||
po.setShopNote(StrUtil.format("过号顺延{}桌 {}桌后需重新排号 谢谢理解!", tbCallTable.getPostponeNum(), tbCallTable.getPostponeNum()));
|
||||
String data = PrinterUtils.getCallNumPrintData(po);
|
||||
String voiceJson = "{\"bizType\":\"2\",\"content\":\"您有一条新的排号记录\"}";
|
||||
PrinterUtils.printTickets(voiceJson, 3, 1, "ZF544PG03W00005", data);
|
||||
String resp = PrinterUtils.printTickets(voiceJson, 3, 1, "ZF544PG03W00005", data);
|
||||
TbPrintMachine machine = new TbPrintMachine();
|
||||
machine.setAddress("ZF544PG03W00005");
|
||||
shopPrintLogService.save(machine, "叫号单", data, resp);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Reference in New Issue
Block a user