From de52e6439044d278f60f604010a4fdd7907c0d97 Mon Sep 17 00:00:00 2001 From: liyj <1617420630@qq.com> Date: Tue, 17 Jun 2025 14:21:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=95=86=E5=BA=97=E5=90=8D?= =?UTF-8?q?=E7=A7=B0=E8=BF=94=E5=9B=9E=E7=BB=99=E5=95=86=E5=93=81=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E3=80=81=E5=93=81=E7=89=8C=E3=80=81=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E3=80=81=E8=A7=84=E6=A0=BC=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/base/ShopBaseProductCategory.java | 3 + .../modules/base/ShopBaseProductSpec.java | 4 ++ .../modules/base/ShopBaseProductType.java | 3 + .../ShopBaseProductCategoryController.java | 24 +++++-- .../admin/ShopBaseProductSpecController.java | 11 ++- .../admin/ShopBaseProductTypeController.java | 12 +++- .../ShopBaseProductCategoryServiceImpl.java | 5 ++ .../store/service/ShopStoreBaseService.java | 10 +++ .../impl/ShopStoreBaseServiceImpl.java | 72 +++++++++++++++++-- 9 files changed, 130 insertions(+), 14 deletions(-) diff --git a/mall-common/src/main/java/com/suisung/mall/common/modules/base/ShopBaseProductCategory.java b/mall-common/src/main/java/com/suisung/mall/common/modules/base/ShopBaseProductCategory.java index 52acca57..ca52aeb2 100644 --- a/mall-common/src/main/java/com/suisung/mall/common/modules/base/ShopBaseProductCategory.java +++ b/mall-common/src/main/java/com/suisung/mall/common/modules/base/ShopBaseProductCategory.java @@ -105,4 +105,7 @@ public class ShopBaseProductCategory implements Serializable { @TableField(exist = false) private String type_name; + @TableField(exist = false) + private String store_name; + } diff --git a/mall-common/src/main/java/com/suisung/mall/common/modules/base/ShopBaseProductSpec.java b/mall-common/src/main/java/com/suisung/mall/common/modules/base/ShopBaseProductSpec.java index c7d0cbe3..33725ad1 100644 --- a/mall-common/src/main/java/com/suisung/mall/common/modules/base/ShopBaseProductSpec.java +++ b/mall-common/src/main/java/com/suisung/mall/common/modules/base/ShopBaseProductSpec.java @@ -67,4 +67,8 @@ public class ShopBaseProductSpec implements Serializable { @ApiModelProperty(value = "所属店铺") private Integer store_id; + + @ApiModelProperty(value = "所属店铺") + @TableField(exist = false) + private String store_name; } diff --git a/mall-common/src/main/java/com/suisung/mall/common/modules/base/ShopBaseProductType.java b/mall-common/src/main/java/com/suisung/mall/common/modules/base/ShopBaseProductType.java index 0901b1a7..471949a1 100644 --- a/mall-common/src/main/java/com/suisung/mall/common/modules/base/ShopBaseProductType.java +++ b/mall-common/src/main/java/com/suisung/mall/common/modules/base/ShopBaseProductType.java @@ -86,4 +86,7 @@ public class ShopBaseProductType implements Serializable { @ApiModelProperty(value = "所属店铺") private Integer store_id; + @ApiModelProperty(value = "所属店铺") + @TableField(exist = false) + private String store_name; } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductCategoryController.java b/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductCategoryController.java index c288d60d..c540a3cc 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductCategoryController.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductCategoryController.java @@ -4,6 +4,7 @@ import cn.hutool.core.convert.Convert; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.suisung.mall.common.api.CommonResult; import com.suisung.mall.common.modules.base.ShopBaseProductCategory; +import com.suisung.mall.common.utils.FilterUtils; import com.suisung.mall.common.utils.I18nUtil; import com.suisung.mall.shop.base.service.ShopBaseProductCategoryService; import io.swagger.annotations.Api; @@ -63,12 +64,10 @@ public class ShopBaseProductCategoryController { @RequestMapping(value = "/categoryTree", method = RequestMethod.GET) public CommonResult getList(ShopBaseProductCategory category) { QueryWrapper queryWrapper = new QueryWrapper<>(); - String store_id = getCurrentUser().getStore_id(); - queryWrapper.eq("store_id", store_id); + new FilterUtils().applyStoreFilter(queryWrapper); queryWrapper.eq("category_is_enable", 1); Integer category_parent_id = category.getCategory_parent_id(); if (category_parent_id == null) category_parent_id = 0; - return CommonResult.success(shopBaseProductCategoryService.getCategoryTree(queryWrapper, category_parent_id)); } @@ -87,8 +86,7 @@ public class ShopBaseProductCategoryController { @ApiOperation(value = "商品分类表-分类强调区别, 类型强调共性-编辑", notes = "商品分类表-分类强调区别, 类型强调共性-编辑") @RequestMapping(value = "/edit", method = RequestMethod.POST) public CommonResult edit(ShopBaseProductCategory shopBaseProductCategory) { - String store_id = getCurrentUser().getStore_id(); - shopBaseProductCategory.setStore_id(store_id); + Integer category_id = shopBaseProductCategory.getCategory_id(); if (category_id == null) { shopBaseProductCategory.setPage_id_pc(0L); @@ -99,9 +97,16 @@ public class ShopBaseProductCategoryController { if (shopBaseProductCategory.getCategory_order() == null) { shopBaseProductCategory.setCategory_order(50); } + String store_id = getCurrentUser().getStore_id(); + shopBaseProductCategory.setStore_id(store_id); } else { //修改,不允许修改商品类型 // shopBaseProductCategory.setType_id(null); + ShopBaseProductCategory oldShopBaseProductCategory= shopBaseProductCategoryService.get(category_id); + if(null==oldShopBaseProductCategory){ + return CommonResult.failed("商品分类不存在"); + } + oldShopBaseProductCategory.setStore_id(oldShopBaseProductCategory.getStore_id()); } return CommonResult.success(shopBaseProductCategoryService.editCategory(shopBaseProductCategory)); @@ -116,6 +121,13 @@ public class ShopBaseProductCategoryController { @ApiOperation(value = "商品分类表-分类强调区别, 类型强调共性-通过category_id删除", notes = "商品分类表-分类强调区别, 类型强调共性-通过category_id删除") @RequestMapping(value = "/delete", method = RequestMethod.POST) public CommonResult delete(@RequestParam(name = "category_id") Integer category_id) { + if(getCurrentUser().isStore()){ + String store_id = getCurrentUser().getStore_id(); + ShopBaseProductCategory shopBaseProductCategory= shopBaseProductCategoryService.get(category_id); + if(!shopBaseProductCategory.getStore_id().equals(store_id)){ + return CommonResult.failed("非本人店铺分类不能删除"); + } + } QueryWrapper queryWrapper = new QueryWrapper<>(); queryWrapper.eq("category_parent_id", category_id); long count = shopBaseProductCategoryService.count(queryWrapper); @@ -133,7 +145,7 @@ public class ShopBaseProductCategoryController { @RequestMapping(value = "/tree", method = {RequestMethod.GET, RequestMethod.POST}) public CommonResult tree(ShopBaseProductCategory category) { QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("store_id", getCurrentUser().getStore_id()); + new FilterUtils().applyStoreFilter(queryWrapper); queryWrapper.orderByAsc("category_order"); if (category.getCategory_parent_id() != null) { queryWrapper.eq("category_parent_id", category.getCategory_parent_id()); diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductSpecController.java b/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductSpecController.java index 9252d9c4..9fa3a3b3 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductSpecController.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductSpecController.java @@ -3,6 +3,7 @@ package com.suisung.mall.shop.base.controller.admin; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.suisung.mall.common.api.CommonResult; import com.suisung.mall.common.domain.UserDto; import com.suisung.mall.common.exception.ApiException; @@ -14,6 +15,7 @@ import com.suisung.mall.common.utils.FilterUtils; import com.suisung.mall.common.utils.I18nUtil; import com.suisung.mall.shop.base.service.ShopBaseProductSpecService; import com.suisung.mall.shop.product.service.ShopProductSpecItemService; +import com.suisung.mall.shop.store.service.ShopStoreBaseService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -46,6 +48,8 @@ public class ShopBaseProductSpecController { @Autowired private ShopProductSpecItemService shopProductSpecItemService; + @Autowired + ShopStoreBaseService shopStoreBaseService; /** * 分页列表查询 * @@ -64,8 +68,11 @@ public class ShopBaseProductSpecController { if (CheckUtil.isNotEmpty(shopBaseProductSpec.getSpec_name())) { queryWrapper.like("spec_name", shopBaseProductSpec.getSpec_name()); } - - return CommonResult.success(shopBaseProductSpecService.lists(queryWrapper, pageNum, pageSize)); + Page pageList= shopBaseProductSpecService.lists(queryWrapper, pageNum, pageSize); + List shopBaseProductSpecList= pageList.getRecords(); + shopBaseProductSpecList=shopStoreBaseService.fixStoreDataShopBaseProductSpec(shopBaseProductSpecList); + pageList.setRecords(shopBaseProductSpecList); + return CommonResult.success(pageList); } /** diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductTypeController.java b/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductTypeController.java index 2f1f29cb..0dad97b6 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductTypeController.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/base/controller/admin/ShopBaseProductTypeController.java @@ -4,6 +4,7 @@ import cn.hutool.core.convert.Convert; import cn.hutool.core.util.StrUtil; import com.alibaba.csp.sentinel.adapter.servlet.util.FilterUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.suisung.mall.common.api.CommonResult; import com.suisung.mall.common.modules.base.ShopBaseProductType; import com.suisung.mall.common.modules.product.ShopProductInfo; @@ -12,6 +13,7 @@ import com.suisung.mall.common.utils.FilterUtils; import com.suisung.mall.shop.base.service.ShopBaseProductTypeService; import com.suisung.mall.shop.product.mapper.ShopProductInfoMapper; import com.suisung.mall.shop.product.service.ShopProductItemService; +import com.suisung.mall.shop.store.service.ShopStoreBaseService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -44,6 +46,9 @@ public class ShopBaseProductTypeController { @Autowired ShopProductInfoMapper shopProductInfoMapper; + @Autowired + ShopStoreBaseService shopStoreBaseService; + @Autowired private ShopBaseProductTypeService shopBaseProductTypeService; @@ -70,8 +75,11 @@ public class ShopBaseProductTypeController { if (CheckUtil.isNotEmpty(shopBaseProductType.getType_name())) { queryWrapper.like("type_name", shopBaseProductType.getType_name()); } - - return CommonResult.success(shopBaseProductTypeService.lists(queryWrapper, pageNum, pageSize)); + Page pageList= shopBaseProductTypeService.lists(queryWrapper, pageNum, pageSize); + List shopBaseProductTypes= pageList.getRecords(); + shopBaseProductTypes=shopStoreBaseService.fixStoreDataShopBaseProductType(shopBaseProductTypes); + pageList.setRecords(shopBaseProductTypes); + return CommonResult.success(pageList); } @ApiOperation(value = "商品类型表-强调共性,类别cat是强调区别.-通过type_id查询", notes = "商品类型表-强调共性,类别cat是强调区别.-通过type_id查询") diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/base/service/impl/ShopBaseProductCategoryServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/base/service/impl/ShopBaseProductCategoryServiceImpl.java index 4c334069..4c9174ba 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/base/service/impl/ShopBaseProductCategoryServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/base/service/impl/ShopBaseProductCategoryServiceImpl.java @@ -47,6 +47,7 @@ import com.suisung.mall.shop.product.service.ShopProductIndexService; import com.suisung.mall.shop.product.service.ShopProductItemService; import com.suisung.mall.shop.sixun.service.SxSyncCategoryService; import com.suisung.mall.shop.store.service.ShopStoreActivityItemService; +import com.suisung.mall.shop.store.service.ShopStoreBaseService; import com.suisung.mall.shop.user.service.ShopUserCartService; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -137,6 +138,9 @@ public class ShopBaseProductCategoryServiceImpl extends BaseServiceImpl categories = Convert.toList(Map.class, find(queryWrapper)); categories = shopProductBaseService.fixProductTypeDate(categories); + shopStoreBaseService.fixStoreData(categories); List categoryTree = getCategoryTree(categories, 0); redisService.set(redisKey, categoryTree); return categoryTree; diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStoreBaseService.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStoreBaseService.java index 04a690f1..6732db59 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStoreBaseService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStoreBaseService.java @@ -4,11 +4,15 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.suisung.mall.common.api.CommonResult; import com.suisung.mall.common.modules.account.AccountUserInfo; +import com.suisung.mall.common.modules.base.ShopBaseProductCategory; +import com.suisung.mall.common.modules.base.ShopBaseProductSpec; +import com.suisung.mall.common.modules.base.ShopBaseProductType; import com.suisung.mall.common.modules.base.ShopBaseStoreCategory; import com.suisung.mall.common.modules.store.ShopStoreBase; import com.suisung.mall.common.modules.store.ShopStoreCompany; import com.suisung.mall.common.pojo.dto.StandardAddressDTO; import com.suisung.mall.core.web.service.IBaseService; +import org.apache.poi.ss.formula.functions.T; import org.springframework.data.util.Pair; import javax.servlet.http.HttpServletResponse; @@ -59,6 +63,12 @@ public interface ShopStoreBaseService extends IBaseService { void fixStoreData(List rows); + void fixStoreDataByShopBaseProductCategory(List rows); + + List fixStoreDataShopBaseProductType(List rows); + + List fixStoreDataShopBaseProductSpec(List rows); + Map getBaseList(QueryWrapper queryWrapper, Integer pageNum, Integer pageSize); Map getBase(Integer store_id); diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java index dd0919c2..9dcd3438 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java @@ -6,6 +6,7 @@ import cn.hutool.core.collection.ListUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.map.MapUtil; import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; @@ -31,10 +32,7 @@ import com.suisung.mall.common.feignService.PayService; import com.suisung.mall.common.modules.account.AccountUserBase; import com.suisung.mall.common.modules.account.AccountUserInfo; import com.suisung.mall.common.modules.account.AccountUserSns; -import com.suisung.mall.common.modules.base.ShopBaseProductTag; -import com.suisung.mall.common.modules.base.ShopBaseStoreCategory; -import com.suisung.mall.common.modules.base.ShopBaseStoreGrade; -import com.suisung.mall.common.modules.base.ShopPageModule; +import com.suisung.mall.common.modules.base.*; import com.suisung.mall.common.modules.distribution.ShopDistributionPlantformUser; import com.suisung.mall.common.modules.invoicing.InvoicingCustomerLevel; import com.suisung.mall.common.modules.invoicing.InvoicingWarehouseBase; @@ -67,6 +65,7 @@ import com.suisung.mall.shop.store.service.*; import com.suisung.mall.shop.user.service.ShopUserFavoritesStoreService; import com.suisung.mall.shop.wechat.service.WxQrCodeService; import io.seata.spring.annotation.GlobalTransactional; +import org.apache.poi.ss.formula.functions.T; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -3657,5 +3656,70 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl rows) { + if (CollUtil.isNotEmpty(rows)) { + List store_ids = rows.stream().map(s -> Convert.toInt(s.getStore_id())).distinct().collect(Collectors.toList()); + List store_rows = gets(store_ids); + + for (ShopBaseProductCategory row : rows) { + Integer store_id = Convert.toInt(row.getStore_id()); + Optional storeOpl = store_rows.stream().filter(s -> ObjectUtil.equal(store_id, Convert.toInt(s.get("store_id")))).findFirst(); + + if (storeOpl.isPresent()) { + Map store = storeOpl.get(); + row.setStore_name((String) store.get("store_name")); + continue; + } + + row.setStore_name("(无)"); + } + } + } + + @Override + public List fixStoreDataShopBaseProductType(List rows) { + if (CollUtil.isNotEmpty(rows)) { + List shopBaseProductTypes= rows; + List store_ids = shopBaseProductTypes.stream().map(s -> Convert.toInt(s.getStore_id())).distinct().collect(Collectors.toList()); + List store_rows = gets(store_ids); + for (ShopBaseProductType row : shopBaseProductTypes) { + Integer store_id = Convert.toInt(row.getStore_id()); + Optional storeOpl = store_rows.stream().filter(s -> ObjectUtil.equal(store_id, Convert.toInt(s.get("store_id")))).findFirst(); + + if (storeOpl.isPresent()) { + Map store = storeOpl.get(); + row.setStore_name((String) store.get("store_name")); + continue; + } + row.setStore_name("(无)"); + } + return shopBaseProductTypes; + } + return Collections.emptyList(); + } + + @Override + public List fixStoreDataShopBaseProductSpec(List rows) { + if (CollUtil.isNotEmpty(rows)) { + List shopBaseProductSpecs= rows; + List store_ids = shopBaseProductSpecs.stream().map(s -> Convert.toInt(s.getStore_id())).distinct().collect(Collectors.toList()); + List store_rows = gets(store_ids); + for (ShopBaseProductSpec row : shopBaseProductSpecs) { + Integer store_id = Convert.toInt(row.getStore_id()); + Optional storeOpl = store_rows.stream().filter(s -> ObjectUtil.equal(store_id, Convert.toInt(s.get("store_id")))).findFirst(); + + if (storeOpl.isPresent()) { + Map store = storeOpl.get(); + row.setStore_name((String) store.get("store_name")); + continue; + } + row.setStore_name("(无)"); + } + return shopBaseProductSpecs; + } + return Collections.emptyList(); + } + } \ No newline at end of file