|
@@ -5,7 +5,7 @@ import com.fuint.common.dto.AccountInfo;
|
|
|
import com.fuint.common.dto.ext.TableInfoDto;
|
|
|
import com.fuint.common.enums.StatusEnum;
|
|
|
import com.fuint.common.param.PageParam;
|
|
|
-import com.fuint.common.service.SettingService;
|
|
|
+import com.fuint.common.service.CartService;
|
|
|
import com.fuint.common.service.TableCategoryService;
|
|
|
import com.fuint.common.service.TableInfoService;
|
|
|
import com.fuint.common.util.I18nUtil;
|
|
@@ -15,6 +15,7 @@ import com.fuint.framework.web.BaseController;
|
|
|
import com.fuint.framework.web.PageResult;
|
|
|
import com.fuint.framework.web.ResponseObject;
|
|
|
import com.fuint.repository.bean.TableInfoBean;
|
|
|
+import com.fuint.repository.model.MtCart;
|
|
|
import com.fuint.repository.model.MtTableInfo;
|
|
|
import com.fuint.utils.StringUtil;
|
|
|
import io.swagger.annotations.Api;
|
|
@@ -47,7 +48,7 @@ public class BackendTableInfoController extends BaseController {
|
|
|
|
|
|
private TableCategoryService categoryService;
|
|
|
|
|
|
- private SettingService settingService;
|
|
|
+ private CartService cartService;
|
|
|
|
|
|
/**
|
|
|
* 餐桌信息列表查询
|
|
@@ -87,6 +88,9 @@ public class BackendTableInfoController extends BaseController {
|
|
|
if (mtTableInfo == null) {
|
|
|
return getFailureResult(201);
|
|
|
}
|
|
|
+ if (Integer.parseInt(status)==1){
|
|
|
+ return getFailureResult(1001, I18nUtil.getMessage("inUseTable"));
|
|
|
+ }
|
|
|
mtTableInfo.setTableStatus(Integer.parseInt(status));
|
|
|
|
|
|
tableInfoService.updateTableInfo(mtTableInfo);
|
|
@@ -166,7 +170,7 @@ public class BackendTableInfoController extends BaseController {
|
|
|
|
|
|
// 校验分类是否存在
|
|
|
if (!categoryService.existCategory(dto.getCategoryId())) {
|
|
|
- return getFailureResult(2001, "关联分类不存在");
|
|
|
+ return getFailureResult(2001, I18nUtil.getMessage("nonExistentCategory"));
|
|
|
}
|
|
|
|
|
|
// 构造实体
|
|
@@ -179,7 +183,7 @@ public class BackendTableInfoController extends BaseController {
|
|
|
entity.setStoreId(account.getStoreId());
|
|
|
// 保存数据
|
|
|
boolean result = tableInfoService.saveTable(entity);
|
|
|
- return result ? getSuccessResult(true) : getFailureResult(500, "保存失败");
|
|
|
+ return result ? getSuccessResult(true) : getFailureResult(500, I18nUtil.getMessage("saveErr"));
|
|
|
}
|
|
|
|
|
|
@ApiOperation("修改餐桌信息接口")
|
|
@@ -200,7 +204,7 @@ public class BackendTableInfoController extends BaseController {
|
|
|
// 2. 校验基础数据
|
|
|
MtTableInfo existTable = tableInfoService.getById(dto.getId());
|
|
|
if (existTable == null || existTable.getDeleteFlag() == 1) {
|
|
|
- return getFailureResult(201, "餐桌不存在或已被删除");
|
|
|
+ return getFailureResult(201, I18nUtil.getMessage("tableDeletedOrNonExistent"));
|
|
|
}
|
|
|
|
|
|
// 3. 业务校验
|
|
@@ -210,7 +214,7 @@ public class BackendTableInfoController extends BaseController {
|
|
|
MtTableInfo updateEntity = buildUpdateEntity(dto, existTable, account);
|
|
|
boolean result = tableInfoService.updateTable(updateEntity);
|
|
|
|
|
|
- return result ? getSuccessResult(true) : getFailureResult(500, "更新失败");
|
|
|
+ return result ? getSuccessResult(true) : getFailureResult(500, I18nUtil.getMessage("updateErr"));
|
|
|
}
|
|
|
|
|
|
|
|
@@ -230,22 +234,27 @@ public class BackendTableInfoController extends BaseController {
|
|
|
if (account == null) {
|
|
|
return getFailureResult(1001, I18nUtil.getMessage("notAuthenticated"));
|
|
|
}
|
|
|
-
|
|
|
+ Long storeId = account.getStoreId();
|
|
|
+ if (storeId==null || storeId<=0){
|
|
|
+ return getFailureResult(1001, I18nUtil.getMessage("superAdminNotAllowedUseMerchantAccount"));
|
|
|
+ }
|
|
|
// 2. 校验数据存在性
|
|
|
MtTableInfo table = tableInfoService.getById(id);
|
|
|
if (table == null || table.getDeleteFlag().equals(1)) {
|
|
|
- return getFailureResult(201, "餐桌不存在或已被删除");
|
|
|
+ return getFailureResult(201, I18nUtil.getMessage("tableDeletedOrNonExistent"));
|
|
|
}
|
|
|
|
|
|
+ //校验在购物车是否使用了
|
|
|
+ int count = cartService.count(new LambdaQueryWrapper<MtCart>()
|
|
|
+ .eq(MtCart::getTableId, table.getId()));
|
|
|
+ if (count>0){
|
|
|
+ return getFailureResult(201, I18nUtil.getMessage("inUseTable"));
|
|
|
+ }
|
|
|
// 3. 执行逻辑删除
|
|
|
MtTableInfo updateEntity = new MtTableInfo();
|
|
|
updateEntity.setId(id);
|
|
|
- updateEntity.setDeleteFlag(1);
|
|
|
- updateEntity.setUpdateUserId(account.getAccountName());
|
|
|
- updateEntity.setUpdateTime(new Date());
|
|
|
-
|
|
|
- boolean result = tableInfoService.updateById(updateEntity);
|
|
|
- return result ? getSuccessResult(true) : getFailureResult(500, "删除失败");
|
|
|
+ boolean result = tableInfoService.removeById(updateEntity);
|
|
|
+ return result ? getSuccessResult(true) : getFailureResult(500, I18nUtil.getMessage("deleteErr"));
|
|
|
}
|
|
|
|
|
|
|
|
@@ -264,7 +273,7 @@ public class BackendTableInfoController extends BaseController {
|
|
|
.eq(MtTableInfo::getTableNumber, dto.getTableNumber())
|
|
|
.eq(MtTableInfo::getDeleteFlag, 0);
|
|
|
if (tableInfoService.count(query) > 0) {
|
|
|
- throw new BusinessCheckException("桌号已被使用");
|
|
|
+ throw new BusinessCheckException(I18nUtil.getMessage("tableInUseAlready"));
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -317,7 +326,7 @@ public class BackendTableInfoController extends BaseController {
|
|
|
entity.setStoreId(storeId);
|
|
|
// 保存数据
|
|
|
boolean result = tableInfoService.saveTable(entity);
|
|
|
- return result ? getSuccessResult(true) : getFailureResult(500, "保存失败");
|
|
|
+ return result ? getSuccessResult(true) : getFailureResult(500, I18nUtil.getMessage("saveErr"));
|
|
|
}
|
|
|
|
|
|
|