新增店铺分类接口,优化部分获取用户信息方法
This commit is contained in:
parent
fa58814be5
commit
e8a75aaf48
@ -39,4 +39,7 @@ public interface ShopBaseStoreCategoryService extends IBaseService<ShopBaseStore
|
||||
*/
|
||||
BigDecimal getStoreCategoryRatio(Integer storeCategoryId);
|
||||
|
||||
|
||||
|
||||
// List<Map<String,Object>> getMobileCategoryTree(QueryWrapper<ShopBaseStoreCategory> queryWrapper);
|
||||
}
|
||||
|
||||
@ -6,16 +6,23 @@ import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.suisung.mall.common.modules.base.ShopBaseStoreCategory;
|
||||
import com.suisung.mall.common.utils.CommonUtil;
|
||||
import com.suisung.mall.core.web.service.RedisService;
|
||||
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
|
||||
import com.suisung.mall.shop.base.mapper.ShopBaseStoreCategoryMapper;
|
||||
import com.suisung.mall.shop.base.service.ShopBaseStoreCategoryService;
|
||||
import com.suisung.mall.shop.store.service.ShopStoreBaseService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.context.request.RequestAttributes;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.swing.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
|
||||
/**
|
||||
@ -34,6 +41,11 @@ public class ShopBaseStoreCategoryServiceImpl extends BaseServiceImpl<ShopBaseSt
|
||||
@Resource
|
||||
private ShopBaseStoreCategoryMapper shopBaseStoreCategoryMapper;
|
||||
|
||||
@Resource
|
||||
private ShopStoreBaseService shopStoreBaseService;
|
||||
@Resource
|
||||
private RedisService redisService;
|
||||
|
||||
@Override
|
||||
public List<ShopBaseStoreCategory> getCategoryTree(QueryWrapper<ShopBaseStoreCategory> queryWrapper) {
|
||||
List<ShopBaseStoreCategory> list = find(queryWrapper);
|
||||
@ -43,6 +55,7 @@ public class ShopBaseStoreCategoryServiceImpl extends BaseServiceImpl<ShopBaseSt
|
||||
@Override
|
||||
public List<Map> getCategoryTree(Integer store_category_parent_id, Integer category_is_enable) {
|
||||
|
||||
|
||||
QueryWrapper<ShopBaseStoreCategory> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("store_category_parent_id", store_category_parent_id);
|
||||
|
||||
@ -51,31 +64,63 @@ public class ShopBaseStoreCategoryServiceImpl extends BaseServiceImpl<ShopBaseSt
|
||||
cache_key = cache_key + ":category_is_enable:" + category_is_enable;
|
||||
queryWrapper.eq("category_is_enable", category_is_enable);
|
||||
}
|
||||
|
||||
Integer pageSize =ObjectUtil.defaultIfNull(getParameter("pageSize",Integer.class),10) ;
|
||||
cache_key = cache_key + ":" + LANG;
|
||||
|
||||
// 设置cache todo 关闭缓存(修改分类的时候没删除缓存)
|
||||
// List<Map> category_rows = (List<Map>) redisService.get(cache_key);
|
||||
//List<Map> category_rows = (List<Map>) redisService.get(cache_key);
|
||||
List<Map> category_rows = null;
|
||||
|
||||
boolean openFindStore = getParameter("openFindStore", false);//是否开启店铺列表查询
|
||||
if (CollUtil.isEmpty(category_rows)) {
|
||||
queryWrapper.orderByAsc("store_category_order");
|
||||
List<ShopBaseStoreCategory> categories = find(queryWrapper);
|
||||
category_rows = Convert.toList(Map.class, categories);
|
||||
|
||||
List<CompletableFuture<Void>> futures = new ArrayList<>();
|
||||
Map<String,Map> storeLis = new HashMap<>();
|
||||
if(openFindStore){
|
||||
long startTime = System.currentTimeMillis();
|
||||
for (Map category_row : category_rows) {
|
||||
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
|
||||
CompletableFuture<Void> future = CompletableFuture.supplyAsync(() -> {
|
||||
RequestContextHolder.setRequestAttributes(requestAttributes,true);
|
||||
Integer store_category_id = (Integer) category_row.get("store_category_id");
|
||||
Map<String, Object> row = new HashMap<>();
|
||||
row.put("store_category_id", String.valueOf(store_category_id));
|
||||
row.put("findStore",true);
|
||||
row.put("store_type","1");
|
||||
Map storeListMap= shopStoreBaseService.getStoreList(1, pageSize,row);
|
||||
storeLis.put(String.valueOf(store_category_id), storeListMap);
|
||||
return null;
|
||||
});
|
||||
futures.add(future);
|
||||
}
|
||||
|
||||
CompletableFuture<Void> allOfFuture = CompletableFuture.allOf(futures.toArray(new CompletableFuture[0]))
|
||||
.thenRun(() -> {
|
||||
long endTime = System.currentTimeMillis();
|
||||
SwingUtilities.invokeLater(() -> {
|
||||
log.debug("异步调用完成! 总耗时: "+(endTime - startTime) + "ms\n");
|
||||
});
|
||||
});
|
||||
allOfFuture.join();
|
||||
}
|
||||
|
||||
for (Map category_row : category_rows) {
|
||||
Integer store_category_id = (Integer) category_row.get("store_category_id");
|
||||
List<Map> rs = getCategoryTree(store_category_id, category_is_enable);
|
||||
|
||||
if(openFindStore){
|
||||
category_row.put("storeList", storeLis.get(String.valueOf(store_category_id)));
|
||||
}
|
||||
category_row.put("id", category_row.get("store_category_id"));
|
||||
category_row.put("name", category_row.get("store_category_name"));
|
||||
category_row.put("value", category_row.get("store_category_id"));
|
||||
category_row.put("index", "store_category_id");
|
||||
category_row.put("sub", rs);
|
||||
}
|
||||
|
||||
}
|
||||
if (CollUtil.isNotEmpty(category_rows)) {
|
||||
// redisService.set(cache_key, category_rows);
|
||||
// redisService.set(cache_key, category_rows);
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,4 +179,39 @@ public class ShopBaseStoreCategoryServiceImpl extends BaseServiceImpl<ShopBaseSt
|
||||
|
||||
return splitRatio;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归构建tree
|
||||
*
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
// public List<Map<String,Object>> buildMobileTree(List<Map<String,Object>> list, Integer pid) {
|
||||
// List<Map<String,Object>> tree = new ArrayList<>();
|
||||
// list.forEach(s -> {
|
||||
// if (((Integer) s.get("store_category_parent_id")).intValue() == pid.intValue()) {
|
||||
// s.put("children",buildMobileTree(list, ((Integer) s.get("store_category_id"))));
|
||||
// tree.add(s);
|
||||
// }
|
||||
// });
|
||||
// return tree;
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public List<Map<String,Object>> getMobileCategoryTree(QueryWrapper<ShopBaseStoreCategory> queryWrapper) {
|
||||
// queryWrapper.eq("category_is_enable", 1);
|
||||
// queryWrapper.select("store_category_parent_id","store_category_id","store_category_name", "category_image","category_is_leaf");
|
||||
// List<ShopBaseStoreCategory> list = find(queryWrapper);
|
||||
// List<Map<String,Object>> shopStoreMap=new ArrayList<>();
|
||||
// for (ShopBaseStoreCategory shopBaseStoreCategory : list) {
|
||||
// try {
|
||||
// shopStoreMap.add(CommonUtil.convertToMap(shopBaseStoreCategory)) ;
|
||||
// } catch (IllegalAccessException e) {
|
||||
// throw new RuntimeException(e);
|
||||
// }
|
||||
// }
|
||||
// return buildMobileTree(shopStoreMap, 0);
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -12,6 +12,7 @@ import com.suisung.mall.common.modules.store.ShopStoreBase;
|
||||
import com.suisung.mall.common.modules.store.ShopStoreCompany;
|
||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
||||
import com.suisung.mall.common.utils.CheckUtil;
|
||||
import com.suisung.mall.common.utils.ContextUtil;
|
||||
import com.suisung.mall.shop.base.service.ShopBaseStoreGradeService;
|
||||
import com.suisung.mall.shop.store.service.ShopMchEntryService;
|
||||
import com.suisung.mall.shop.store.service.ShopStoreBaseService;
|
||||
@ -69,7 +70,7 @@ public class ShopStoreBaseController extends BaseControllerImpl {
|
||||
queryWrapper.like("store_name", store_name);
|
||||
}
|
||||
|
||||
UserDto user = getCurrentUser();
|
||||
UserDto user = ContextUtil.getCurrentUser();
|
||||
if (user.isStore()) {
|
||||
queryWrapper.eq("store_id", Convert.toInt(user.getStore_id()));
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import com.suisung.mall.common.domain.UserDto;
|
||||
import com.suisung.mall.common.modules.store.ShopStoreProductCategory;
|
||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
||||
import com.suisung.mall.common.utils.CheckUtil;
|
||||
import com.suisung.mall.common.utils.ContextUtil;
|
||||
import com.suisung.mall.core.web.service.RedisService;
|
||||
import com.suisung.mall.shop.store.service.ShopStoreProductCategoryService;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -58,7 +59,7 @@ public class ShopStoreProductCategoryController extends BaseControllerImpl {
|
||||
@ApiOperation(value = "商品分类表-分类强调区别, 类型强调共性-分页列表查询", notes = "商品分类表-分类强调区别, 类型强调共性-分页列表查询")
|
||||
@RequestMapping(value = "/categoryTree", method = RequestMethod.GET)
|
||||
public CommonResult categoryTree(ShopStoreProductCategory category) {
|
||||
UserDto user = getCurrentUser();
|
||||
UserDto user = ContextUtil.getCurrentUser();
|
||||
Integer store_id = Integer.parseInt(user.getStore_id());
|
||||
QueryWrapper<ShopStoreProductCategory> queryWrapper = new QueryWrapper<>();
|
||||
if (user.isStore()) {
|
||||
@ -85,11 +86,11 @@ public class ShopStoreProductCategoryController extends BaseControllerImpl {
|
||||
@ApiOperation(value = "店铺商品分类表-编辑", notes = "店铺商品分类表-编辑")
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.POST)
|
||||
public CommonResult edit(ShopStoreProductCategory shopStoreProductCategory) {
|
||||
UserDto user = getCurrentUser();
|
||||
UserDto user = ContextUtil.getCurrentUser();
|
||||
Integer store_id = Convert.toInt(user.getStore_id());
|
||||
shopStoreProductCategory.setStore_id(store_id);
|
||||
UserDto currentUser = getCurrentUser();
|
||||
shopStoreProductCategoryService.cleanCategoryCache(Convert.toInt(currentUser.getStore_id()));
|
||||
// UserDto currentUser = getCurrentUser();
|
||||
shopStoreProductCategoryService.cleanCategoryCache(Convert.toInt(user.getStore_id()));
|
||||
|
||||
if (CheckUtil.isNotEmpty(shopStoreProductCategory.getStore_product_cat_id())) {
|
||||
long num = shopStoreProductCategoryService.count(new QueryWrapper<ShopStoreProductCategory>().eq("parent_id", shopStoreProductCategory.getStore_product_cat_id()));
|
||||
|
||||
@ -73,7 +73,7 @@ public class StoreController extends BaseControllerImpl {
|
||||
@RequestMapping(value = "/lists", method = RequestMethod.GET)
|
||||
public CommonResult lists(@RequestParam(name = "page", defaultValue = "1") Integer page,
|
||||
@RequestParam(name = "rows", defaultValue = "10") Integer rows) {
|
||||
return CommonResult.success(shopStoreBaseService.getStoreList(page, rows));
|
||||
return CommonResult.success(shopStoreBaseService.getStoreList(page, rows,new HashMap<>()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "列出店铺分类", notes = "列出店铺分类")
|
||||
@ -314,4 +314,26 @@ public class StoreController extends BaseControllerImpl {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * 列表查询
|
||||
// * @return
|
||||
// */
|
||||
// @ApiOperation(value = "店铺分类表-分类强调区别, 类型强调共性-分页列表查询", notes = "店铺分类表-分类强调区别, 类型强调共性-分页列表查询")
|
||||
// @RequestMapping(value = "/categoryTree", method = RequestMethod.GET)
|
||||
// public CommonResult categoryTree(ShopBaseStoreCategory category) {
|
||||
// QueryWrapper<ShopBaseStoreCategory> queryWrapper = new QueryWrapper<>();
|
||||
// if (category.getStore_category_parent_id() != null)
|
||||
// queryWrapper.eq("store_category_parent_id", category.getStore_category_parent_id());
|
||||
//
|
||||
// return CommonResult.success(shopBaseStoreCategoryService.getMobileCategoryTree(queryWrapper));
|
||||
// }
|
||||
|
||||
// @ApiOperation(value = "根据分类查询店铺", notes = "列表数据")
|
||||
// @RequestMapping(value = "/listStores", method = RequestMethod.GET)
|
||||
// public Page<ShopStoreBase> listStores(@RequestParam(name = "page", defaultValue = "1") Integer page,
|
||||
// @RequestParam(name = "rows", defaultValue = "10") Integer rows) {
|
||||
// return shopStoreBaseService.getMobileStoreList(page, rows);
|
||||
// }
|
||||
|
||||
}
|
||||
@ -39,7 +39,7 @@ public interface ShopStoreBaseService extends IBaseService<ShopStoreBase> {
|
||||
|
||||
Map contents();
|
||||
|
||||
Map getStoreList(Integer page, Integer rows);
|
||||
Map getStoreList(Integer page, Integer rows,Map<String,Object> params);
|
||||
|
||||
Map listsStoreCategory();
|
||||
|
||||
@ -200,4 +200,6 @@ public interface ShopStoreBaseService extends IBaseService<ShopStoreBase> {
|
||||
*/
|
||||
Boolean updateStoreBizState(Integer storeId, Integer bizState);
|
||||
|
||||
// Page<ShopStoreBase> getMobileStoreList(Integer page, Integer rows);
|
||||
|
||||
}
|
||||
|
||||
@ -67,6 +67,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.commons.collections.MapUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -719,13 +720,19 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map getStoreList(Integer page, Integer rows) {
|
||||
public Map getStoreList(Integer page, Integer rows,Map<String,Object> paramsMap) {
|
||||
|
||||
Map<String, Object> data;
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
|
||||
Integer store_id = getParameter("store_id", Integer.class);
|
||||
Integer store_category_id = getParameter("store_category_id", Integer.class);
|
||||
boolean findStore= MapUtils.getBoolean(paramsMap, "findStore", false);
|
||||
if(ObjectUtil.isNull(store_category_id)){
|
||||
if(null!=paramsMap.get("store_category_id")){
|
||||
store_category_id=MapUtils.getInteger(paramsMap,"store_category_id");
|
||||
}
|
||||
}
|
||||
Long distance = getParameter("distance", Long.class);
|
||||
if (CheckUtil.isEmpty(distance)) {
|
||||
distance = 20000000000L;
|
||||
@ -743,9 +750,13 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
Integer store_type = getParameter("store_type", Integer.class);
|
||||
Integer store_biz_state = getParameter("store_biz_state", Integer.class);
|
||||
|
||||
UserDto user = getCurrentUser();
|
||||
UserDto user = ContextUtil.getCurrentUser();
|
||||
if (store_type == null) {
|
||||
store_type = user != null && user.isStore() && shopStoreBaseService.ifSupplierMarket() ? 2 : 1;
|
||||
if(null!=paramsMap.get("store_type")){
|
||||
store_type=MapUtils.getInteger(paramsMap,"store_type");
|
||||
}else {
|
||||
store_type = user != null && user.isStore() && shopStoreBaseService.ifSupplierMarket() ? 2 : 1;
|
||||
}
|
||||
}
|
||||
queryWrapper.eq("store_type", store_type);
|
||||
|
||||
@ -760,7 +771,20 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
}
|
||||
|
||||
if (CheckUtil.isNotEmpty(store_category_id)) {
|
||||
queryWrapper.eq("store_category_id", store_category_id);
|
||||
List<Integer> store_category_ids = new ArrayList<>();
|
||||
QueryWrapper<ShopBaseStoreCategory> storeCategoryQueryWrapper = new QueryWrapper<>();
|
||||
storeCategoryQueryWrapper.eq("store_category_parent_id", store_category_id);
|
||||
storeCategoryQueryWrapper.select("store_category_id");
|
||||
List<ShopBaseStoreCategory> shopBaseStoreCategories= shopBaseStoreCategoryService.list(storeCategoryQueryWrapper);
|
||||
store_category_ids.add(store_category_id);
|
||||
for (ShopBaseStoreCategory storeCategory:shopBaseStoreCategories) {
|
||||
store_category_ids.add(storeCategory.getStore_category_id());
|
||||
}
|
||||
if(store_category_ids.size()>1){
|
||||
queryWrapper.in("store_category_id", store_category_ids);
|
||||
}else {
|
||||
queryWrapper.eq("store_category_id", store_category_id);
|
||||
}
|
||||
params.put("store_category_id", store_category_id);
|
||||
}
|
||||
|
||||
@ -867,7 +891,11 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
|
||||
data = shopStoreBaseService.getLists(queryWrapper, page, rows);
|
||||
}
|
||||
|
||||
//start只查询店铺
|
||||
if(findStore){
|
||||
return data;
|
||||
}
|
||||
//end 只查询店铺
|
||||
// 修正商家活动数据,放在此处,多循环了一次
|
||||
List<ShopStoreActivityBase> store_activity_rows = new ArrayList<>();
|
||||
List<Map<String, Object>> items = (List<Map<String, Object>>) data.get("items");
|
||||
@ -3800,5 +3828,35 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Page<ShopStoreBase> getMobileStoreList(Integer page, Integer rows) {
|
||||
// QueryWrapper<ShopStoreBase> queryWrapper=new QueryWrapper<>();
|
||||
// String store_category_id=getParameter("store_category_id");
|
||||
// String storeId=getParameter("store_id");
|
||||
// if(StringUtils.isEmpty(store_category_id)){
|
||||
// return new Page<>(page, rows);
|
||||
// }
|
||||
// QueryWrapper<ShopBaseStoreCategory> shopStoreBaseQueryWrapper=new QueryWrapper<>();
|
||||
// shopStoreBaseQueryWrapper.select("store_category_id");
|
||||
// shopStoreBaseQueryWrapper.eq("store_category_parent_id",store_category_id);
|
||||
//
|
||||
// List<ShopBaseStoreCategory> shopBaseStoreCategories= shopBaseStoreCategoryService.list(shopStoreBaseQueryWrapper);
|
||||
//
|
||||
// List<Integer> shopBaseStoreCategoryIds=Arrays.asList(Integer.parseInt(store_category_id));
|
||||
// for (ShopBaseStoreCategory shopBaseStoreCategory : shopBaseStoreCategories) {
|
||||
// shopBaseStoreCategoryIds.add(shopBaseStoreCategory.getStore_category_id());
|
||||
// }
|
||||
// if(shopBaseStoreCategoryIds.size()>1){
|
||||
// queryWrapper.in("store_category_id", shopBaseStoreCategoryIds);
|
||||
// }else {
|
||||
// queryWrapper.eq("store_category_id", Integer.parseInt(store_category_id));
|
||||
// }
|
||||
// if(StringUtils.isNotEmpty(storeId)){
|
||||
// queryWrapper.eq("store_id", Integer.parseInt(storeId));
|
||||
// }
|
||||
// queryWrapper.eq("store_is_open", 1);
|
||||
// return shopStoreBaseService.lists(queryWrapper,page,rows);
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user