台桌状态

This commit is contained in:
2025-05-09 11:07:58 +08:00
parent 4321847add
commit fc255e5969
11 changed files with 141 additions and 18 deletions

View File

@@ -1,7 +1,9 @@
package com.czg.service.order.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.exceptions.ValidateException;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.*;
@@ -14,6 +16,7 @@ import com.czg.config.RabbitPublisher;
import com.czg.config.RedisCst;
import com.czg.entity.notify.CzgPayNotifyDTO;
import com.czg.entity.notify.CzgRefundNotifyDTO;
import com.czg.enums.ShopTableStatusEnum;
import com.czg.enums.ShopUserFlowBizEnum;
import com.czg.exception.ApiNotPrintException;
import com.czg.exception.CzgException;
@@ -253,6 +256,8 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
} else {
param.setPayMode("未知");
}
table.setStatus(ShopTableStatusEnum.UNSETTLED.getValue());
shopTableService.updateById(table);
}
List<OrderDetail> orderDetails = cartService.getCartByTableCode(shopInfo.getId(), param.getTableCode(), param.getPlaceNum());
AssertUtil.isListEmpty(orderDetails, "下单失败 购物车为空");
@@ -791,6 +796,20 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
}
}
}
if (StrUtil.isNotBlank(orderInfo.getTableCode())) {
ShopTable table = shopTableService.getOneByTableCode(orderInfo.getShopId(), orderInfo.getTableCode());
if (table != null) {
ShopInfo shopInfo = shopInfoService.getById(orderInfo.getShopId());
if ("auto".equals(shopInfo.getTableClearType())) {
table.setStatus(ShopTableStatusEnum.IDLE.getValue());
} else {
DateTime dateTime = DateUtil.offsetMinute(DateUtil.date(), shopInfo.getTableClearTime());
table.setCreateTime(LocalDateTimeUtil.of(dateTime));
redisService.set(RedisCst.classKeyExpired.EXPIRED_TABLE + table.getId(), "", 60L * shopInfo.getTableClearTime());
}
shopTableService.updateById(table);
}
}
orderDetailService.updateChain().set(OrderDetail::getStatus, OrderStatusEnums.DONE.getCode()).eq(OrderDetail::getOrderId, orderInfo.getId()).update();
// if (!"after-pay".equals(orderInfo.getPayMode())) {
//发送打票信息
@@ -812,6 +831,13 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo
updateChain().set(OrderInfo::getStatus, OrderStatusEnums.CANCELLED.getCode())
.where(OrderInfo::getId).eq(orderId)
.update();
if (StrUtil.isNotBlank(orderInfo.getTableCode())) {
ShopTable table = shopTableService.getOneByTableCode(orderInfo.getShopId(), orderInfo.getTableCode());
if (table != null) {
shopTableService.updateById(table);
}
}
rabbitPublisher.sendOrderCancelMsg(orderId.toString());
} else {
log.info("订单取消失败,订单Id:{},订状态:{}", orderInfo.getId(), orderInfo.getStatus());