打印逻辑修改
This commit is contained in:
@@ -121,6 +121,8 @@ public class CartService {
|
||||
private MpOrderDetailMapper mpOrderDetailMapper;
|
||||
@Autowired
|
||||
private MpShopTableMapper mpShopTableMapper;
|
||||
@Autowired
|
||||
private MQUtils mQUtils;
|
||||
|
||||
public CartService(TbUserShopMsgMapper tbUserShopMsgMapper, WechatUtil wechatUtil, WxAccountUtil wxAccountUtil, TbShopOpenIdMapper shopOpenIdMapper, ProductService productService, TbProductMapper tbProductMapper, RedisTemplate<String, Object> redisTemplate, StringRedisTemplate stringRedisTemplate, ShopUtils shopUtils) {
|
||||
this.tbUserShopMsgMapper = tbUserShopMsgMapper;
|
||||
@@ -687,6 +689,10 @@ public class CartService {
|
||||
seatNum = tbCashierCart.getNumber();
|
||||
seatCost = tbCashierCart.getTotalAmount();
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(tbCashierCart.getOrderId())) {
|
||||
orderId = Integer.valueOf(tbCashierCart.getOrderId());
|
||||
}
|
||||
}
|
||||
|
||||
// 校验是否选择人数
|
||||
@@ -718,13 +724,22 @@ public class CartService {
|
||||
boolean isVip= tbShopUser != null && tbShopUser.getIsVip().equals((byte) 1);
|
||||
|
||||
// 查询历史orderDetail
|
||||
Integer finalOrderId = orderId;
|
||||
List<TbOrderDetail> oldOrderDetailList = mpOrderDetailMapper.selectList(new LambdaQueryWrapper<TbOrderDetail>()
|
||||
.in(TbOrderDetail::getCartId, cashierIds)
|
||||
.and(q -> q.in(TbOrderDetail::getCartId, cashierIds).or().eq(TbOrderDetail::getOrderId, finalOrderId))
|
||||
.eq(TbOrderDetail::getShopId, shopId));
|
||||
HashMap<String, TbOrderDetail> oldOrderDetailMap = new HashMap<>();
|
||||
oldOrderDetailList.forEach(item -> oldOrderDetailMap.put(item.getOrderId().toString() + item.getCartId(), item));
|
||||
|
||||
ArrayList<TbOrderDetail> removeOrderDetailList = new ArrayList<>();
|
||||
ArrayList<TbOrderDetail> addOrderDetail = new ArrayList<>();
|
||||
|
||||
oldOrderDetailList.forEach(item -> {
|
||||
oldOrderDetailMap.put(item.getOrderId().toString() + item.getCartId(), item);
|
||||
if (cashierCartList.contains(item.getCartId())) {
|
||||
oldOrderDetailMap.put(item.getOrderId().toString() + item.getCartId(), item);
|
||||
} else {
|
||||
removeOrderDetailList.add(item);
|
||||
}
|
||||
});
|
||||
boolean hasNewInfo = false;
|
||||
|
||||
//校验 库存 耗材
|
||||
@@ -817,6 +832,7 @@ public class CartService {
|
||||
if (orderDetail == null) {
|
||||
orderDetail = new TbOrderDetail();
|
||||
hasNewInfo = true;
|
||||
addOrderDetail.add(orderDetail);
|
||||
}
|
||||
orderDetail.setCreateTime(new Date());
|
||||
orderDetail.setNum(cart.getNumber());
|
||||
@@ -920,8 +936,6 @@ public class CartService {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (orderInfo != null) {
|
||||
log.info("订单状态:" + orderInfo.getStatus());
|
||||
if (!"unpaid".equals(orderInfo.getStatus())) {
|
||||
@@ -1001,6 +1015,7 @@ public class CartService {
|
||||
mpOrderDetailMapper.insert(orderDetail);
|
||||
}
|
||||
}
|
||||
|
||||
List<TbActivateOutRecord> outRecords = new ArrayList<>();
|
||||
for (TbCashierCart cashierCart : cashierCartList) {
|
||||
if (cashierCart.getIsVip().equals((byte) 1)) {
|
||||
@@ -1035,6 +1050,19 @@ public class CartService {
|
||||
|
||||
if(!CollectionUtils.isEmpty(outRecords)) outRecordMapper.insertBatch(outRecords);
|
||||
|
||||
// 打印票据
|
||||
if (!addOrderDetail.isEmpty() && shopEatTypeInfoDTO.isDineInAfter()) {
|
||||
mQUtils.printDishesTicket(orderInfo.getId(), false, addOrderDetail.toArray(new TbOrderDetail[0]));
|
||||
}
|
||||
|
||||
if (!removeOrderDetailList.isEmpty()) {
|
||||
// 退单票
|
||||
mpOrderDetailMapper.deleteBatchIds(removeOrderDetailList.stream().map(tbOrderDetail -> tbOrderDetail.getId()).collect(Collectors.toList()));
|
||||
if (shopEatTypeInfoDTO.isDineInAfter()) {
|
||||
mQUtils.printDishesTicket(orderInfo.getId(), true, removeOrderDetailList.toArray(new TbOrderDetail[0]));
|
||||
}
|
||||
}
|
||||
|
||||
// 发送mq消息
|
||||
JSONObject jsonObject2 = new JSONObject();
|
||||
jsonObject2.put("orderId", orderInfo.getId());
|
||||
@@ -1051,7 +1079,6 @@ public class CartService {
|
||||
redisUtil.deleteByKey(tableCartKey);
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(responseData.toString(), tableCartKey, jsonObject.getString("userId"), true);
|
||||
|
||||
|
||||
responseData.put("status", "success");
|
||||
responseData.put("msg", "成功");
|
||||
responseData.put("type", "order");
|
||||
@@ -1060,7 +1087,6 @@ public class CartService {
|
||||
// PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject12.toString(), jsonObject.getString("tableId").concat("-").concat(shopId), "", false);
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(responseData.toString(), tableCartKey, jsonObject.getString("userId"));
|
||||
|
||||
|
||||
redisUtil.saveMessage(RedisCst.ORDER_EXPIRED.concat(orderId.toString()), orderId.toString(), 60 * 16L);
|
||||
ThreadUtil.execAsync(() -> {
|
||||
ThreadUtil.sleep(5, TimeUnit.SECONDS);
|
||||
|
||||
@@ -5,11 +5,14 @@ import cn.hutool.core.util.RandomUtil;
|
||||
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.entity.dto.ReturnGroupOrderDto;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.ShopEatTypeInfoDTO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.ShopUserListVo;
|
||||
import com.chaozhanggui.system.cashierservice.exception.MsgException;
|
||||
import com.chaozhanggui.system.cashierservice.mapper.MpOrderDetailMapper;
|
||||
import com.chaozhanggui.system.cashierservice.model.PayReq;
|
||||
import com.chaozhanggui.system.cashierservice.model.TradeQueryReq;
|
||||
import com.chaozhanggui.system.cashierservice.netty.PushToClientChannelHandlerAdapter;
|
||||
@@ -162,6 +165,10 @@ public class PayService {
|
||||
private MQUtils mQUtils;
|
||||
@Autowired
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
@Autowired
|
||||
private ShopUtils shopUtils;
|
||||
@Autowired
|
||||
private MpOrderDetailMapper mpOrderDetailMapper;
|
||||
|
||||
public PayService(@Qualifier("tbShopSongOrderServiceImpl") TbShopSongOrderService shopSongOrderService) {
|
||||
this.shopSongOrderService = shopSongOrderService;
|
||||
@@ -468,7 +475,16 @@ public class PayService {
|
||||
|
||||
producer.putOrderCollect(jsonObject.toJSONString());
|
||||
|
||||
producer.printMechine(orderId);
|
||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(orderInfo.getShopId(), orderInfo.getTableId());
|
||||
// 打印消息
|
||||
if (!shopEatTypeInfoDTO.isDineInAfter()) {
|
||||
List<TbOrderDetail> detailList = mpOrderDetailMapper.selectList(new LambdaQueryWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getOrderId, orderInfo.getId())
|
||||
.eq(TbOrderDetail::getStatus, "closed"));
|
||||
mQUtils.printDishesTicket(orderInfo.getId(), false, detailList.toArray(new TbOrderDetail[0]));
|
||||
}
|
||||
mQUtils.printPlaceTicket(orderInfo.getId(), false);
|
||||
// producer.printMechine(orderId);
|
||||
sendOrderToClient(orderInfo);
|
||||
|
||||
// 发送mq消息并保存库存记录
|
||||
@@ -783,7 +799,16 @@ public class PayService {
|
||||
|
||||
|
||||
log.info("发送打印数据");
|
||||
producer.printMechine(orderInfo.getId() + "");
|
||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(orderInfo.getShopId(), orderInfo.getTableId());
|
||||
// 打印消息
|
||||
if (!shopEatTypeInfoDTO.isDineInAfter()) {
|
||||
List<TbOrderDetail> detailList = mpOrderDetailMapper.selectList(new LambdaQueryWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getOrderId, orderInfo.getId())
|
||||
.eq(TbOrderDetail::getStatus, "closed"));
|
||||
mQUtils.printDishesTicket(orderInfo.getId(), false, detailList.toArray(new TbOrderDetail[0]));
|
||||
}
|
||||
mQUtils.printPlaceTicket(orderInfo.getId(), false);
|
||||
// producer.printMechine(orderInfo.getId() + "");
|
||||
|
||||
return Result.success(CodeEnum.SUCCESS, orderId);
|
||||
case "2": //退款成功
|
||||
@@ -836,7 +861,16 @@ public class PayService {
|
||||
|
||||
|
||||
log.info("发送打印数据");
|
||||
producer.printMechine(orderInfo.getId() + "");
|
||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(orderInfo.getShopId(), orderInfo.getTableId());
|
||||
// 打印消息
|
||||
if (!shopEatTypeInfoDTO.isDineInAfter()) {
|
||||
List<TbOrderDetail> detailList = mpOrderDetailMapper.selectList(new LambdaQueryWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getOrderId, orderInfo.getId())
|
||||
.eq(TbOrderDetail::getStatus, "closed"));
|
||||
mQUtils.printDishesTicket(orderInfo.getId(), false, detailList.toArray(new TbOrderDetail[0]));
|
||||
}
|
||||
mQUtils.printPlaceTicket(orderInfo.getId(), false);
|
||||
// producer.printMechine(orderInfo.getId() + "");
|
||||
sendOrderToClient(orderInfo);
|
||||
redisUtil.deleteByKey(RedisCst.ORDER_EXPIRED.concat(orderInfo.getId().toString()));
|
||||
return Result.success(CodeEnum.SUCCESS, orderId);
|
||||
@@ -985,7 +1019,16 @@ public class PayService {
|
||||
producer.putOrderCollect(jsonObject.toJSONString());
|
||||
|
||||
log.info("发送打印数据");
|
||||
producer.printMechine(orderInfo.getId() + "");
|
||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(orderInfo.getShopId(), orderInfo.getTableId());
|
||||
// 打印消息
|
||||
if (!shopEatTypeInfoDTO.isDineInAfter()) {
|
||||
List<TbOrderDetail> detailList = mpOrderDetailMapper.selectList(new LambdaQueryWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getOrderId, orderInfo.getId())
|
||||
.eq(TbOrderDetail::getStatus, "closed"));
|
||||
mQUtils.printDishesTicket(orderInfo.getId(), false, detailList.toArray(new TbOrderDetail[0]));
|
||||
}
|
||||
mQUtils.printPlaceTicket(orderInfo.getId(), false);
|
||||
// producer.printMechine(orderInfo.getId() + "");
|
||||
sendOrderToClient(orderInfo);
|
||||
redisUtil.deleteByKey(RedisCst.ORDER_EXPIRED.concat(orderInfo.getId().toString()));
|
||||
|
||||
@@ -1039,7 +1082,16 @@ public class PayService {
|
||||
producer.putOrderCollect(jsonObject.toJSONString());
|
||||
|
||||
log.info("发送打印数据");
|
||||
producer.printMechine(orderInfo.getId() + "");
|
||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = shopUtils.checkEatModel(orderInfo.getShopId(), orderInfo.getTableId());
|
||||
// 打印消息
|
||||
if (!shopEatTypeInfoDTO.isDineInAfter()) {
|
||||
List<TbOrderDetail> detailList = mpOrderDetailMapper.selectList(new LambdaQueryWrapper<TbOrderDetail>()
|
||||
.eq(TbOrderDetail::getOrderId, orderInfo.getId())
|
||||
.eq(TbOrderDetail::getStatus, "closed"));
|
||||
mQUtils.printDishesTicket(orderInfo.getId(), false, detailList.toArray(new TbOrderDetail[0]));
|
||||
}
|
||||
mQUtils.printPlaceTicket(orderInfo.getId(), false);
|
||||
// producer.printMechine(orderInfo.getId() + "");
|
||||
JSONObject coupons = new JSONObject();
|
||||
coupons.put("type", "buy");
|
||||
coupons.put("orderId", orderInfo.getId().toString());
|
||||
|
||||
Reference in New Issue
Block a user