台桌状态

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

@@ -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());