浏览代码

fix 修改分类状态问题

pengzhenggao 1 周之前
父节点
当前提交
b868ef0e36

+ 2 - 1
fuintBackend/fuint-application/src/main/java/com/fuint/common/service/GoodsService.java

@@ -1,5 +1,6 @@
 package com.fuint.common.service;
 
+import com.baomidou.mybatisplus.extension.service.IService;
 import com.fuint.common.dto.GoodsDto;
 import com.fuint.common.dto.GoodsSpecValueDto;
 import com.fuint.common.dto.GoodsTopDto;
@@ -20,7 +21,7 @@ import java.util.Map;
  * Created by FSQ
  * CopyRight https://www.fuint.cn
  */
-public interface GoodsService {
+public interface GoodsService extends IService<MtGoods> {
 
     /**
      * 分页查询商品列表

+ 1 - 1
fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/CateServiceImpl.java

@@ -136,7 +136,7 @@ public class CateServiceImpl extends ServiceImpl<MtGoodsCateMapper, MtGoodsCate>
             throw new BusinessCheckException("超级管理员方帐号无法执行该操作,请使用商户帐号操作");
         }
         mtCate.setName(reqDto.getName());
-        mtCate.setStatus(StatusEnum.ENABLED.getKey());
+        mtCate.setStatus(reqDto.getStatus()!=null?reqDto.getStatus():StatusEnum.ENABLED.getKey());
         mtCate.setLogo(reqDto.getLogo());
         mtCate.setDescription(reqDto.getDescription());
         mtCate.setOperator(reqDto.getOperator());

+ 5 - 5
fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/StaffServiceImpl.java

@@ -17,17 +17,17 @@ import com.fuint.repository.model.MtMerchant;
 import com.fuint.repository.model.MtStaff;
 import com.fuint.repository.model.MtStore;
 import com.fuint.repository.model.MtUser;
-import com.fuint.utils.StringUtil;
 import com.github.pagehelper.Page;
 import com.github.pagehelper.PageHelper;
 import lombok.AllArgsConstructor;
+import org.apache.commons.lang.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.stereotype.Service;
+
 import java.util.*;
 
 /**
@@ -103,7 +103,7 @@ public class StaffServiceImpl extends ServiceImpl<MtStaffMapper, MtStaff> implem
 
         lambdaQueryWrapper.orderByDesc(MtStaff::getId);
         List<MtStaff> dataList = mtStaffMapper.selectList(lambdaQueryWrapper);
-        if (dataList != null && dataList.size() > 0) {
+      /*  if (dataList != null && dataList.size() > 0) {
             for (MtStaff mtStaff : dataList) {
                 // 隐藏手机号中间四位
                 String phone = mtStaff.getMobile();
@@ -111,7 +111,7 @@ public class StaffServiceImpl extends ServiceImpl<MtStaffMapper, MtStaff> implem
                     mtStaff.setMobile(phone.substring(0, 3) + "****" + phone.substring(7));
                 }
             }
-        }
+        }*/
         PageRequest pageRequest = PageRequest.of(paginationRequest.getCurrentPage(), paginationRequest.getPageSize());
         PageImpl pageImpl = new PageImpl(dataList, pageRequest, pageHelper.getTotal());
         PaginationResponse<MtStaff> paginationResponse = new PaginationResponse(pageImpl, MtStaff.class);
@@ -148,7 +148,7 @@ public class StaffServiceImpl extends ServiceImpl<MtStaffMapper, MtStaff> implem
             if (mtStaffOld.getAuditedStatus().equals(StatusEnum.ENABLED.getKey())) {
                 mtStaff.setAuditedTime(new Date());
             }
-            mtStaff.setAuditedStatus(StatusEnum.getKeyByVAalue(mtStaff.getAuditedStatus()));
+            mtStaff.setAuditedStatus(mtStaff.getAuditedStatus());
             mtStaff.setMerchantId(mtStaffOld.getMerchantId());
         }
 

+ 3 - 0
fuintBackend/fuint-application/src/main/java/com/fuint/common/service/impl/TableInfoServiceImpl.java

@@ -223,6 +223,9 @@ public class TableInfoServiceImpl extends ServiceImpl<MtTableInfoMapper, MtTable
         if (accountInfo == null){
             throw new BusinessCheckException(I18nUtil.getMessage("notAuthenticated"));
         }
+        if (accountInfo.getStoreId() == null || accountInfo.getStoreId() <=0){
+            throw new BusinessCheckException(I18nUtil.getMessage("superAdminNotAllowedUseMerchantAccount"));
+        }
         //分页查询
         IPage<MtTableInfo> mtTableInfoIPage = this.baseMapper.selectPage(new Page<>(param.getPage(), param.getPageSize()), new LambdaQueryWrapper<MtTableInfo>()
                  .eq((accountInfo.getStoreId()!=null && accountInfo.getStoreId()>0),MtTableInfo::getStoreId,accountInfo.getStoreId())

+ 11 - 5
fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendCateController.java

@@ -1,13 +1,11 @@
 package com.fuint.module.backendApi.controller;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.fuint.common.Constants;
 import com.fuint.common.dto.AccountInfo;
 import com.fuint.common.dto.GoodsCateDto;
 import com.fuint.common.enums.StatusEnum;
-import com.fuint.common.service.AccountService;
-import com.fuint.common.service.CateService;
-import com.fuint.common.service.SettingService;
-import com.fuint.common.service.StoreService;
+import com.fuint.common.service.*;
 import com.fuint.common.util.CommonUtil;
 import com.fuint.common.util.I18nUtil;
 import com.fuint.common.util.TokenUtil;
@@ -16,6 +14,7 @@ import com.fuint.framework.pagination.PaginationRequest;
 import com.fuint.framework.pagination.PaginationResponse;
 import com.fuint.framework.web.BaseController;
 import com.fuint.framework.web.ResponseObject;
+import com.fuint.repository.model.MtGoods;
 import com.fuint.repository.model.MtGoodsCate;
 import com.fuint.repository.model.MtStore;
 import com.fuint.repository.model.TAccount;
@@ -63,6 +62,8 @@ public class BackendCateController extends BaseController {
      */
     private StoreService storeService;
 
+    private GoodsService goodsService;
+
     /**
      * 获取商品分类列表
      *
@@ -156,7 +157,12 @@ public class BackendCateController extends BaseController {
         if (mtCate == null) {
             return getFailureResult(201, I18nUtil.getMessage("missingClass"));
         }
-
+        int count = goodsService.count(new LambdaQueryWrapper<MtGoods>()
+                .eq(MtGoods::getCateId, mtCate.getId())
+                .eq(MtGoods::getStoreId, accountInfo.getStoreId()));
+        if (count>0 && status.equals(StatusEnum.FORBIDDEN.getKey())){
+            return getFailureResult(1001, I18nUtil.getMessage(I18nUtil.getMessage("deleteFailureCategoryHasProducts")));
+        }
         String operator = accountInfo.getAccountName();
 
         MtGoodsCate cate = new MtGoodsCate();

+ 3 - 3
fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendStaffController.java

@@ -146,7 +146,7 @@ public class BackendStaffController extends BaseController {
     @ApiOperation(value = "保存员工信息")
     @RequestMapping(value = "/save", method = RequestMethod.POST)
     @CrossOrigin
-    @PreAuthorize("@pms.hasPermission('staff:list')")
+    @PreAuthorize("@pms.hasPermission('staff:add')")
     public ResponseObject saveHandler(HttpServletRequest request, @RequestBody Map<String, Object> params) throws BusinessCheckException {
         String token = request.getHeader("Access-Token");
         Long id = params.get("id") == null ||params.get("id").equals("") ? null :Long.parseLong( params.get("id").toString());
@@ -227,13 +227,13 @@ public class BackendStaffController extends BaseController {
         }
 
         MtStaff staffInfo = staffService.queryStaffById(id);
-        if (staffInfo != null) {
+        /*if (staffInfo != null) {
             // 隐藏手机号中间四位
             String phone = staffInfo.getMobile();
             if (phone != null && StringUtil.isNotEmpty(phone) && phone.length() == 11) {
                 staffInfo.setMobile(phone.substring(0, 3) + "****" + phone.substring(7));
             }
-        }
+        }*/
         Map<String, Object> result = new HashMap<>();
         result.put("staffInfo", staffInfo);
 

+ 25 - 16
fuintBackend/fuint-application/src/main/java/com/fuint/module/backendApi/controller/BackendTableInfoController.java

@@ -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"));
     }
 
 

+ 1 - 1
fuintBackend/fuint-application/src/main/resources/i18n/messages_en_US.properties

@@ -91,7 +91,7 @@ storeStatusAbnormal=Store status is abnormal
 settlementDataNonExistent=Settlement data does not exist
 noEligibleOrdersForSettlement=No eligible orders for settlement
 articleStatusAbnormal=Article status is abnormal
-deleteFailureCategoryHasProducts=Deletion failed, this category has products
+deleteFailureCategoryHasProducts=this category has products
 loginInfoInvalid=Login information is invalid
 merchantNonExistent=Merchant does not exist
 merchantDisabledContactPlatform=Merchant has been disabled, please contact the platform

+ 7 - 1
fuintBackend/fuint-application/src/main/resources/i18n/messages_zh_CN.properties

@@ -91,7 +91,7 @@ storeStatusAbnormal=店铺状态异常
 settlementDataNonExistent=结算数据不存在
 noEligibleOrdersForSettlement=暂无符合结算条件的订单
 articleStatusAbnormal=文章状态异常
-deleteFailureCategoryHasProducts=删除失败,该分类有商品存在
+deleteFailureCategoryHasProducts=该分类有商品存在
 loginInfoInvalid=登录信息失效
 merchantNonExistent=商户不存在
 merchantDisabledContactPlatform=商户已被禁用,请联系平台方
@@ -102,3 +102,9 @@ existCat=分类名称已存在
 unrmvTblRef=有餐桌引用不能删除
 nonEmptyCategoryName=分类名称不能为空
 
+
+inUseTable=餐桌正在被使用
+tableDeletedOrNonExistent=餐桌不存在或已被删除
+tableInUseAlready=餐桌已被使用
+nonExistentCategory=分类不存在
+

+ 10 - 6
fuintBackend/fuint-repository/src/main/java/com/fuint/repository/model/MtTableInfo.java

@@ -1,16 +1,14 @@
 package com.fuint.repository.model;
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import java.io.Serializable;
-import java.util.Date;
+import com.baomidou.mybatisplus.annotation.*;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.io.Serializable;
+import java.util.Date;
+
 /**
  * 餐桌信息实体
  *
@@ -32,17 +30,21 @@ public class MtTableInfo implements Serializable {
     private Long categoryId;
 
     @ApiModelProperty("记录创建时间")
+    @TableField(fill = FieldFill.INSERT)
     private Date createTime;
 
     @ApiModelProperty("创建用户id")
+    @TableField(fill = FieldFill.INSERT)
     private String createUserId;
 
     @ApiModelProperty("是否删除 0否 1是")
+    @TableLogic
     private Integer deleteFlag;
 
     @ApiModelProperty("餐桌ID,主键,自增")
     @TableId(value = "ID", type = IdType.ID_WORKER)
     private Long id;
+
     @ApiModelProperty("店铺id")
     private Long storeId;
 
@@ -61,9 +63,11 @@ public class MtTableInfo implements Serializable {
     private Integer tableStatus;
 
     @ApiModelProperty("记录更新时间")
+    @TableField(fill = FieldFill.INSERT_UPDATE)
     private Date updateTime;
 
     @ApiModelProperty("修改用户id")
+    @TableField(fill = FieldFill.INSERT_UPDATE)
     private String updateUserId;
 
 }