桌码绑定接口

This commit is contained in:
张松
2025-02-19 10:04:31 +08:00
parent 90b0a41e7a
commit 400515b641
4 changed files with 70 additions and 0 deletions

View File

@@ -1,10 +1,12 @@
package com.czg.service.account.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.img.ImgUtil;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.qrcode.QrCodeUtil;
import com.czg.account.dto.table.ShopTableAddDTO;
import com.czg.account.dto.table.ShopTableBindDTO;
import com.czg.account.entity.ShopTableArea;
import com.czg.account.entity.ShopTableCode;
import com.czg.account.service.ShopAreaService;
@@ -135,4 +137,33 @@ public class ShopTableServiceImpl extends ServiceImpl<ShopTableMapper, ShopTable
return tableCode;
}
@Override
public Boolean bind(Long shopId, ShopTableBindDTO shopTableBindDTO) {
if (!StrUtil.startWith(shopTableBindDTO.getTableCode(), "40")) {
throw new ApiNotPrintException("错误码");
}
ShopTableCode tableCode = shopTableCodeService.queryChain().eq(ShopTableCode::getTableCode, shopTableBindDTO.getTableCode())
.eq(ShopTableCode::getShopId, shopId).one();
if (tableCode == null) {
throw new ApiNotPrintException("错误码");
}
if (tableCode.getState() == 1) {
throw new ApiNotPrintException("此桌码已绑定,请勿重复绑定");
}
ShopTable shopTable = queryChain().eq(ShopTable::getShopId, shopId).eq(ShopTable::getId, shopTableBindDTO.getId()).one();
if (shopTable == null) {
throw new ApiNotPrintException("台桌不存在");
}
tableCode.setBindTime(DateUtil.date().toLocalDateTime());
tableCode.setState(1);
shopTableCodeService.updateById(tableCode);
shopTable.setTableCode(tableCode.getTableCode());
return updateById(shopTable);
}
}