新增商店名称返回给商品分类、品牌、类型、规格列表

This commit is contained in:
liyj 2025-06-17 14:21:39 +08:00
parent 397634d57d
commit de52e64390
9 changed files with 130 additions and 14 deletions

View File

@ -105,4 +105,7 @@ public class ShopBaseProductCategory implements Serializable {
@TableField(exist = false)
private String type_name;
@TableField(exist = false)
private String store_name;
}

View File

@ -67,4 +67,8 @@ public class ShopBaseProductSpec implements Serializable {
@ApiModelProperty(value = "所属店铺")
private Integer store_id;
@ApiModelProperty(value = "所属店铺")
@TableField(exist = false)
private String store_name;
}

View File

@ -86,4 +86,7 @@ public class ShopBaseProductType implements Serializable {
@ApiModelProperty(value = "所属店铺")
private Integer store_id;
@ApiModelProperty(value = "所属店铺")
@TableField(exist = false)
private String store_name;
}

View File

@ -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<ShopBaseProductCategory> queryWrapper = new QueryWrapper<>();
String store_id = getCurrentUser().getStore_id();
queryWrapper.eq("store_id", store_id);
new FilterUtils<ShopBaseProductCategory>().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<ShopBaseProductCategory> 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<ShopBaseProductCategory> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("store_id", getCurrentUser().getStore_id());
new FilterUtils<ShopBaseProductCategory>().applyStoreFilter(queryWrapper);
queryWrapper.orderByAsc("category_order");
if (category.getCategory_parent_id() != null) {
queryWrapper.eq("category_parent_id", category.getCategory_parent_id());

View File

@ -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<ShopBaseProductSpec> pageList= shopBaseProductSpecService.lists(queryWrapper, pageNum, pageSize);
List<ShopBaseProductSpec> shopBaseProductSpecList= pageList.getRecords();
shopBaseProductSpecList=shopStoreBaseService.fixStoreDataShopBaseProductSpec(shopBaseProductSpecList);
pageList.setRecords(shopBaseProductSpecList);
return CommonResult.success(pageList);
}
/**

View File

@ -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<ShopBaseProductType> pageList= shopBaseProductTypeService.lists(queryWrapper, pageNum, pageSize);
List<ShopBaseProductType> shopBaseProductTypes= pageList.getRecords();
shopBaseProductTypes=shopStoreBaseService.fixStoreDataShopBaseProductType(shopBaseProductTypes);
pageList.setRecords(shopBaseProductTypes);
return CommonResult.success(pageList);
}
@ApiOperation(value = "商品类型表-强调共性,类别cat是强调区别.-通过type_id查询", notes = "商品类型表-强调共性,类别cat是强调区别.-通过type_id查询")

View File

@ -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<ShopBase
@Autowired
private SxSyncCategoryService sxSyncCategoryService;
@Autowired
private ShopStoreBaseService shopStoreBaseService;
private final String LANG = "zh_CN"; // todo 多语言动态
@Override
@ -256,6 +260,7 @@ public class ShopBaseProductCategoryServiceImpl extends BaseServiceImpl<ShopBase
queryWrapper.orderByAsc("category_order");
List<Map> categories = Convert.toList(Map.class, find(queryWrapper));
categories = shopProductBaseService.fixProductTypeDate(categories);
shopStoreBaseService.fixStoreData(categories);
List<Map> categoryTree = getCategoryTree(categories, 0);
redisService.set(redisKey, categoryTree);
return categoryTree;

View File

@ -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<ShopStoreBase> {
void fixStoreData(List<Map> rows);
void fixStoreDataByShopBaseProductCategory(List<ShopBaseProductCategory> rows);
List<ShopBaseProductType> fixStoreDataShopBaseProductType(List<ShopBaseProductType> rows);
List<ShopBaseProductSpec> fixStoreDataShopBaseProductSpec(List<ShopBaseProductSpec> rows);
Map getBaseList(QueryWrapper<ShopStoreBase> queryWrapper, Integer pageNum, Integer pageSize);
Map getBase(Integer store_id);

View File

@ -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<ShopStoreBaseMappe
row.put("store_latitude", gps.getWgLat());
}
@Override
public void fixStoreDataByShopBaseProductCategory(List<ShopBaseProductCategory> rows) {
if (CollUtil.isNotEmpty(rows)) {
List<Integer> store_ids = rows.stream().map(s -> Convert.toInt(s.getStore_id())).distinct().collect(Collectors.toList());
List<Map> store_rows = gets(store_ids);
for (ShopBaseProductCategory row : rows) {
Integer store_id = Convert.toInt(row.getStore_id());
Optional<Map> 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<ShopBaseProductType> fixStoreDataShopBaseProductType(List<ShopBaseProductType> rows) {
if (CollUtil.isNotEmpty(rows)) {
List<ShopBaseProductType> shopBaseProductTypes= rows;
List<Integer> store_ids = shopBaseProductTypes.stream().map(s -> Convert.toInt(s.getStore_id())).distinct().collect(Collectors.toList());
List<Map> store_rows = gets(store_ids);
for (ShopBaseProductType row : shopBaseProductTypes) {
Integer store_id = Convert.toInt(row.getStore_id());
Optional<Map> 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<ShopBaseProductSpec> fixStoreDataShopBaseProductSpec(List<ShopBaseProductSpec> rows) {
if (CollUtil.isNotEmpty(rows)) {
List<ShopBaseProductSpec> shopBaseProductSpecs= rows;
List<Integer> store_ids = shopBaseProductSpecs.stream().map(s -> Convert.toInt(s.getStore_id())).distinct().collect(Collectors.toList());
List<Map> store_rows = gets(store_ids);
for (ShopBaseProductSpec row : shopBaseProductSpecs) {
Integer store_id = Convert.toInt(row.getStore_id());
Optional<Map> 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();
}
}