台桌状态
This commit is contained in:
@@ -11,6 +11,7 @@ import com.czg.account.dto.table.ShopTableAddDTO;
|
||||
import com.czg.account.dto.table.ShopTableBindDTO;
|
||||
import com.czg.account.dto.table.ShopTableClearDTO;
|
||||
import com.czg.account.dto.table.ShopTableDTO;
|
||||
import com.czg.account.entity.ShopAd;
|
||||
import com.czg.account.entity.ShopTable;
|
||||
import com.czg.account.entity.ShopTableArea;
|
||||
import com.czg.account.entity.ShopTableCode;
|
||||
@@ -20,22 +21,28 @@ import com.czg.account.service.ShopTableService;
|
||||
import com.czg.account.vo.ShopTableVO;
|
||||
import com.czg.enums.ShopTableStatusEnum;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.czg.service.account.mapper.ShopTableMapper;
|
||||
import com.czg.system.enums.SysParamCodeEnum;
|
||||
import com.czg.system.service.SysParamsService;
|
||||
import com.czg.utils.PageUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.mybatisflex.core.paginate.Page;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import jakarta.annotation.PostConstruct;
|
||||
import jakarta.annotation.Resource;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.dubbo.config.annotation.DubboReference;
|
||||
import org.apache.dubbo.config.annotation.DubboService;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -55,6 +62,20 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
|
||||
private ShopTableAreaService shopAreaService;
|
||||
@Resource
|
||||
private ShopTableCodeService shopTableCodeService;
|
||||
@DubboReference
|
||||
private SysParamsService sysParamsService;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
updateChain()
|
||||
.set(ShopTable::getClearTime, null)
|
||||
.set(ShopTable::getStatus, ShopTableStatusEnum.IDLE.getValue())
|
||||
.isNotNull(ShopTable::getTableCode)
|
||||
.isNotNull(ShopTable::getClearTime)
|
||||
.lt(ShopTable::getClearTime, LocalDateTime.now())
|
||||
.update();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Boolean add(Long shopId, ShopTableAddDTO shopTableAddDTO) {
|
||||
@@ -78,7 +99,7 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
|
||||
shopTable.setName(name);
|
||||
shopTable.setMaxCapacity(shopTableAddDTO.getMaxCapacity());
|
||||
shopTable.setAreaId(shopTableAddDTO.getAreaId());
|
||||
shopTable.setStatus(ShopTableStatusEnum.CLOSED.getValue());
|
||||
shopTable.setStatus(ShopTableStatusEnum.UNBOUND.getValue());
|
||||
tableArrayList.add(shopTable);
|
||||
}
|
||||
|
||||
@@ -174,7 +195,7 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
|
||||
File qrFile = new File(dir, tableCode + ".png");
|
||||
|
||||
// 生成二维码图片
|
||||
QrCodeUtil.generate("https://kysh.sxczgkj.cn/codeplate?code=" + tableCode, 300, 300, qrFile);
|
||||
QrCodeUtil.generate(sysParamsService.getSysParamValue(SysParamCodeEnum.TABLE_CODE_URL.getCode()) + tableCode, 300, 300, qrFile);
|
||||
}
|
||||
|
||||
// 先保存数据库记录,确保生成ZIP前无异常
|
||||
@@ -250,13 +271,17 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
|
||||
@Override
|
||||
public Boolean updateInfo(long shopId, ShopTableDTO shopTableDTO) {
|
||||
ShopTable shopTable = BeanUtil.copyProperties(shopTableDTO, ShopTable.class);
|
||||
ShopTable shopTableSource = getOne(new QueryWrapper().eq(ShopTable::getShopId, shopId).eq(ShopTable::getId, shopTableDTO.getId()));
|
||||
if (StrUtil.isBlank(shopTableSource.getTableCode()) && StrUtil.isNotBlank(shopTable.getStatus()) && ShopTableStatusEnum.UNBOUND.equalsVal(shopTable.getStatus())) {
|
||||
throw new ApiNotPrintException("修改失败,该台桌未绑定桌码,绑定桌码后自动进入空闲状态");
|
||||
}
|
||||
return update(shopTable, new QueryWrapper().eq(ShopTable::getShopId, StpKit.USER.getShopId()).eq(ShopTable::getId, shopTableDTO.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean clear(long shopId, ShopTableClearDTO shopTableClearDTO) {
|
||||
ShopTable shopTable = getOne(new QueryWrapper().eq(ShopTable::getShopId, shopId).eq(ShopTable::getId, shopTableClearDTO.getId()));
|
||||
if (!ShopTableStatusEnum.CLEANING.equalsVal(shopTable.getStatus())) {
|
||||
if (!ShopTableStatusEnum.SETTLED.equalsVal(shopTable.getStatus())) {
|
||||
throw new ApiNotPrintException("台桌不处于待清台状态");
|
||||
}
|
||||
shopTable.setStatus(ShopTableStatusEnum.IDLE.getValue());
|
||||
@@ -269,6 +294,14 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
|
||||
.eq(ShopTable::getId, shopTableClearDTO.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean expiredTable(long tableId) {
|
||||
ShopTable shopTable = new ShopTable();
|
||||
shopTable.setClearTime(null);
|
||||
shopTable.setStatus(ShopTableStatusEnum.IDLE.getValue());
|
||||
return update(shopTable, QueryWrapper.create().eq(ShopTable::getId, tableId));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<ShopTableVO> pageInfo(Long shopId, Integer areaId, String tableCode, String status, String name, Boolean isBind) {
|
||||
PageHelper.startPage(PageUtil.buildPageHelp());
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user