Compare commits
No commits in common. "706c6f0c8b73e4b77a1ae5e397037481f285082f" and "3d8999d51e863d1bad34a775007a25fdc9bc15ab" have entirely different histories.
706c6f0c8b
...
3d8999d51e
@ -39,7 +39,4 @@ public interface ShopBaseStoreCategoryService extends IBaseService<ShopBaseStore
|
|||||||
*/
|
*/
|
||||||
BigDecimal getStoreCategoryRatio(Integer storeCategoryId);
|
BigDecimal getStoreCategoryRatio(Integer storeCategoryId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// List<Map<String,Object>> getMobileCategoryTree(QueryWrapper<ShopBaseStoreCategory> queryWrapper);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,24 +6,17 @@ import cn.hutool.core.util.ObjectUtil;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.suisung.mall.common.modules.base.ShopBaseStoreCategory;
|
import com.suisung.mall.common.modules.base.ShopBaseStoreCategory;
|
||||||
import com.suisung.mall.common.utils.CommonUtil;
|
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.core.web.service.impl.BaseServiceImpl;
|
||||||
import com.suisung.mall.shop.base.mapper.ShopBaseStoreCategoryMapper;
|
import com.suisung.mall.shop.base.mapper.ShopBaseStoreCategoryMapper;
|
||||||
import com.suisung.mall.shop.base.service.ShopBaseStoreCategoryService;
|
import com.suisung.mall.shop.base.service.ShopBaseStoreCategoryService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import com.suisung.mall.shop.store.service.ShopStoreBaseService;
|
|
||||||
import org.springframework.stereotype.Service;
|
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.annotation.Resource;
|
||||||
import javax.swing.*;
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,11 +36,6 @@ public class ShopBaseStoreCategoryServiceImpl extends BaseServiceImpl<ShopBaseSt
|
|||||||
@Resource
|
@Resource
|
||||||
private ShopBaseStoreCategoryMapper shopBaseStoreCategoryMapper;
|
private ShopBaseStoreCategoryMapper shopBaseStoreCategoryMapper;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private ShopStoreBaseService shopStoreBaseService;
|
|
||||||
@Resource
|
|
||||||
private RedisService redisService;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ShopBaseStoreCategory> getCategoryTree(QueryWrapper<ShopBaseStoreCategory> queryWrapper) {
|
public List<ShopBaseStoreCategory> getCategoryTree(QueryWrapper<ShopBaseStoreCategory> queryWrapper) {
|
||||||
List<ShopBaseStoreCategory> list = find(queryWrapper);
|
List<ShopBaseStoreCategory> list = find(queryWrapper);
|
||||||
@ -57,7 +45,6 @@ public class ShopBaseStoreCategoryServiceImpl extends BaseServiceImpl<ShopBaseSt
|
|||||||
@Override
|
@Override
|
||||||
public List<Map> getCategoryTree(Integer store_category_parent_id, Integer category_is_enable) {
|
public List<Map> getCategoryTree(Integer store_category_parent_id, Integer category_is_enable) {
|
||||||
|
|
||||||
|
|
||||||
QueryWrapper<ShopBaseStoreCategory> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ShopBaseStoreCategory> queryWrapper = new QueryWrapper<>();
|
||||||
queryWrapper.eq("store_category_parent_id", store_category_parent_id);
|
queryWrapper.eq("store_category_parent_id", store_category_parent_id);
|
||||||
|
|
||||||
@ -66,63 +53,31 @@ public class ShopBaseStoreCategoryServiceImpl extends BaseServiceImpl<ShopBaseSt
|
|||||||
cache_key = cache_key + ":category_is_enable:" + category_is_enable;
|
cache_key = cache_key + ":category_is_enable:" + category_is_enable;
|
||||||
queryWrapper.eq("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_key = cache_key + ":" + LANG;
|
||||||
|
|
||||||
// 设置cache todo 关闭缓存(修改分类的时候没删除缓存)
|
// 设置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;
|
List<Map> category_rows = null;
|
||||||
boolean openFindStore = getParameter("openFindStore", false);//是否开启店铺列表查询
|
|
||||||
if (CollUtil.isEmpty(category_rows)) {
|
if (CollUtil.isEmpty(category_rows)) {
|
||||||
queryWrapper.orderByAsc("store_category_order");
|
queryWrapper.orderByAsc("store_category_order");
|
||||||
List<ShopBaseStoreCategory> categories = find(queryWrapper);
|
List<ShopBaseStoreCategory> categories = find(queryWrapper);
|
||||||
category_rows = Convert.toList(Map.class, categories);
|
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) {
|
for (Map category_row : category_rows) {
|
||||||
Integer store_category_id = (Integer) category_row.get("store_category_id");
|
Integer store_category_id = (Integer) category_row.get("store_category_id");
|
||||||
List<Map> rs = getCategoryTree(store_category_id, category_is_enable);
|
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("id", category_row.get("store_category_id"));
|
||||||
category_row.put("name", category_row.get("store_category_name"));
|
category_row.put("name", category_row.get("store_category_name"));
|
||||||
category_row.put("value", category_row.get("store_category_id"));
|
category_row.put("value", category_row.get("store_category_id"));
|
||||||
category_row.put("index", "store_category_id");
|
category_row.put("index", "store_category_id");
|
||||||
category_row.put("sub", rs);
|
category_row.put("sub", rs);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CollUtil.isNotEmpty(category_rows)) {
|
if (CollUtil.isNotEmpty(category_rows)) {
|
||||||
// redisService.set(cache_key, category_rows);
|
// redisService.set(cache_key, category_rows);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -200,39 +155,4 @@ public class ShopBaseStoreCategoryServiceImpl extends BaseServiceImpl<ShopBaseSt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 递归构建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);
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5497,10 +5497,7 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
// 1. 批量新增
|
// 1. 批量新增
|
||||||
if (CollUtil.isNotEmpty(newProducts)) {
|
if (CollUtil.isNotEmpty(newProducts)) {
|
||||||
// 4. 批量生成新商品的ID
|
// 4. 批量生成新商品的ID
|
||||||
List<Long> newIds=new ArrayList<>();
|
List<Long> newIds = shopNumberSeqService.batchCreateNextNo("product_id", newProducts.size());
|
||||||
synchronized (this){
|
|
||||||
newIds = shopNumberSeqService.batchCreateNextNo("product_id", newProducts.size());
|
|
||||||
}
|
|
||||||
if (newIds == null || newIds.size() != newProducts.size()) {
|
if (newIds == null || newIds.size() != newProducts.size()) {
|
||||||
return Pair.of(false, "生成商品编号异常");
|
return Pair.of(false, "生成商品编号异常");
|
||||||
}
|
}
|
||||||
@ -5568,7 +5565,6 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
//计算规格
|
//计算规格
|
||||||
if (existingProducts.get(productId) != null) {
|
if (existingProducts.get(productId) != null) {
|
||||||
udpateShopProductItemList.get(i).get(0).setItem_id(existingProducts.get(productId));
|
udpateShopProductItemList.get(i).get(0).setItem_id(existingProducts.get(productId));
|
||||||
udpateShopProductItemList.get(i).get(0).setItem_src_id(String.valueOf(existingProducts.get(productId)));
|
|
||||||
udpateItemIds.add(existingProducts.get(productId));
|
udpateItemIds.add(existingProducts.get(productId));
|
||||||
}
|
}
|
||||||
// 处理商品项
|
// 处理商品项
|
||||||
@ -5920,16 +5916,12 @@ public class ShopProductBaseServiceImpl extends BaseServiceImpl<ShopProductBaseM
|
|||||||
List<ShopProductInfo> newShopProductInfoList) {
|
List<ShopProductInfo> newShopProductInfoList) {
|
||||||
List<Serializable> itemIds = new ArrayList<>();
|
List<Serializable> itemIds = new ArrayList<>();
|
||||||
if (CollUtil.isEmpty(items)) return itemIds;
|
if (CollUtil.isEmpty(items)) return itemIds;
|
||||||
List<Long> generatedIds =new ArrayList<>();
|
List<Long> generatedIds = shopNumberSeqService.batchCreateNextNo("item_id", items.size());
|
||||||
synchronized (this){
|
|
||||||
generatedIds = shopNumberSeqService.batchCreateNextNo("item_id", items.size());
|
|
||||||
}
|
|
||||||
// Map<String,String> cacheMap=new HashMap<>();
|
// Map<String,String> cacheMap=new HashMap<>();
|
||||||
for (int i = 0; i < items.size(); i++) {
|
for (int i = 0; i < items.size(); i++) {
|
||||||
Long itemId = generatedIds.get(i);
|
Long itemId = generatedIds.get(i);
|
||||||
ShopProductItem item = items.get(i);
|
ShopProductItem item = items.get(i);
|
||||||
item.setItem_id(itemId);
|
item.setItem_id(itemId);
|
||||||
item.setItem_src_id(String.valueOf(itemId));
|
|
||||||
// if(StringUtils.isNotEmpty(item.getItem_spec())){
|
// if(StringUtils.isNotEmpty(item.getItem_spec())){
|
||||||
// String product_uniqid=ShopJsonUtils.generateJsonWithOrgJson(item.getSpec_item_ids(),new Object[]{itemId,item.getItem_unit_price(),"",1002});
|
// String product_uniqid=ShopJsonUtils.generateJsonWithOrgJson(item.getSpec_item_ids(),new Object[]{itemId,item.getItem_unit_price(),"",1002});
|
||||||
// cacheMap.put(item.getProductName(),product_uniqid);
|
// cacheMap.put(item.getProductName(),product_uniqid);
|
||||||
|
|||||||
@ -12,7 +12,6 @@ import com.suisung.mall.common.modules.store.ShopStoreBase;
|
|||||||
import com.suisung.mall.common.modules.store.ShopStoreCompany;
|
import com.suisung.mall.common.modules.store.ShopStoreCompany;
|
||||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
||||||
import com.suisung.mall.common.utils.CheckUtil;
|
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.base.service.ShopBaseStoreGradeService;
|
||||||
import com.suisung.mall.shop.store.service.ShopMchEntryService;
|
import com.suisung.mall.shop.store.service.ShopMchEntryService;
|
||||||
import com.suisung.mall.shop.store.service.ShopStoreBaseService;
|
import com.suisung.mall.shop.store.service.ShopStoreBaseService;
|
||||||
@ -70,7 +69,7 @@ public class ShopStoreBaseController extends BaseControllerImpl {
|
|||||||
queryWrapper.like("store_name", store_name);
|
queryWrapper.like("store_name", store_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
UserDto user = ContextUtil.getCurrentUser();
|
UserDto user = getCurrentUser();
|
||||||
if (user.isStore()) {
|
if (user.isStore()) {
|
||||||
queryWrapper.eq("store_id", Convert.toInt(user.getStore_id()));
|
queryWrapper.eq("store_id", Convert.toInt(user.getStore_id()));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import com.suisung.mall.common.domain.UserDto;
|
|||||||
import com.suisung.mall.common.modules.store.ShopStoreProductCategory;
|
import com.suisung.mall.common.modules.store.ShopStoreProductCategory;
|
||||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
||||||
import com.suisung.mall.common.utils.CheckUtil;
|
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.core.web.service.RedisService;
|
||||||
import com.suisung.mall.shop.store.service.ShopStoreProductCategoryService;
|
import com.suisung.mall.shop.store.service.ShopStoreProductCategoryService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
@ -59,7 +58,7 @@ public class ShopStoreProductCategoryController extends BaseControllerImpl {
|
|||||||
@ApiOperation(value = "商品分类表-分类强调区别, 类型强调共性-分页列表查询", notes = "商品分类表-分类强调区别, 类型强调共性-分页列表查询")
|
@ApiOperation(value = "商品分类表-分类强调区别, 类型强调共性-分页列表查询", notes = "商品分类表-分类强调区别, 类型强调共性-分页列表查询")
|
||||||
@RequestMapping(value = "/categoryTree", method = RequestMethod.GET)
|
@RequestMapping(value = "/categoryTree", method = RequestMethod.GET)
|
||||||
public CommonResult categoryTree(ShopStoreProductCategory category) {
|
public CommonResult categoryTree(ShopStoreProductCategory category) {
|
||||||
UserDto user = ContextUtil.getCurrentUser();
|
UserDto user = getCurrentUser();
|
||||||
Integer store_id = Integer.parseInt(user.getStore_id());
|
Integer store_id = Integer.parseInt(user.getStore_id());
|
||||||
QueryWrapper<ShopStoreProductCategory> queryWrapper = new QueryWrapper<>();
|
QueryWrapper<ShopStoreProductCategory> queryWrapper = new QueryWrapper<>();
|
||||||
if (user.isStore()) {
|
if (user.isStore()) {
|
||||||
@ -86,11 +85,11 @@ public class ShopStoreProductCategoryController extends BaseControllerImpl {
|
|||||||
@ApiOperation(value = "店铺商品分类表-编辑", notes = "店铺商品分类表-编辑")
|
@ApiOperation(value = "店铺商品分类表-编辑", notes = "店铺商品分类表-编辑")
|
||||||
@RequestMapping(value = "/edit", method = RequestMethod.POST)
|
@RequestMapping(value = "/edit", method = RequestMethod.POST)
|
||||||
public CommonResult edit(ShopStoreProductCategory shopStoreProductCategory) {
|
public CommonResult edit(ShopStoreProductCategory shopStoreProductCategory) {
|
||||||
UserDto user = ContextUtil.getCurrentUser();
|
UserDto user = getCurrentUser();
|
||||||
Integer store_id = Convert.toInt(user.getStore_id());
|
Integer store_id = Convert.toInt(user.getStore_id());
|
||||||
shopStoreProductCategory.setStore_id(store_id);
|
shopStoreProductCategory.setStore_id(store_id);
|
||||||
// UserDto currentUser = getCurrentUser();
|
UserDto currentUser = getCurrentUser();
|
||||||
shopStoreProductCategoryService.cleanCategoryCache(Convert.toInt(user.getStore_id()));
|
shopStoreProductCategoryService.cleanCategoryCache(Convert.toInt(currentUser.getStore_id()));
|
||||||
|
|
||||||
if (CheckUtil.isNotEmpty(shopStoreProductCategory.getStore_product_cat_id())) {
|
if (CheckUtil.isNotEmpty(shopStoreProductCategory.getStore_product_cat_id())) {
|
||||||
long num = shopStoreProductCategoryService.count(new QueryWrapper<ShopStoreProductCategory>().eq("parent_id", 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)
|
@RequestMapping(value = "/lists", method = RequestMethod.GET)
|
||||||
public CommonResult lists(@RequestParam(name = "page", defaultValue = "1") Integer page,
|
public CommonResult lists(@RequestParam(name = "page", defaultValue = "1") Integer page,
|
||||||
@RequestParam(name = "rows", defaultValue = "10") Integer rows) {
|
@RequestParam(name = "rows", defaultValue = "10") Integer rows) {
|
||||||
return CommonResult.success(shopStoreBaseService.getStoreList(page, rows,new HashMap<>()));
|
return CommonResult.success(shopStoreBaseService.getStoreList(page, rows));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "列出店铺分类", notes = "列出店铺分类")
|
@ApiOperation(value = "列出店铺分类", notes = "列出店铺分类")
|
||||||
@ -314,26 +314,4 @@ 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 contents();
|
||||||
|
|
||||||
Map getStoreList(Integer page, Integer rows,Map<String,Object> params);
|
Map getStoreList(Integer page, Integer rows);
|
||||||
|
|
||||||
Map listsStoreCategory();
|
Map listsStoreCategory();
|
||||||
|
|
||||||
@ -219,6 +219,4 @@ public interface ShopStoreBaseService extends IBaseService<ShopStoreBase> {
|
|||||||
*/
|
*/
|
||||||
BigDecimal getStorePackingFee(Integer storeId);
|
BigDecimal getStorePackingFee(Integer storeId);
|
||||||
|
|
||||||
// Page<ShopStoreBase> getMobileStoreList(Integer page, Integer rows);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,7 +69,6 @@ import com.suisung.mall.shop.user.service.ShopUserFavoritesStoreService;
|
|||||||
import com.suisung.mall.shop.wechat.service.WxQrCodeService;
|
import com.suisung.mall.shop.wechat.service.WxQrCodeService;
|
||||||
import io.seata.spring.annotation.GlobalTransactional;
|
import io.seata.spring.annotation.GlobalTransactional;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.collections.MapUtils;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -729,19 +728,13 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map getStoreList(Integer page, Integer rows,Map<String,Object> paramsMap) {
|
public Map getStoreList(Integer page, Integer rows) {
|
||||||
|
|
||||||
Map<String, Object> data;
|
Map<String, Object> data;
|
||||||
Map<String, Object> params = new HashMap<>();
|
Map<String, Object> params = new HashMap<>();
|
||||||
|
|
||||||
Integer store_id = getParameter("store_id", Integer.class);
|
Integer store_id = getParameter("store_id", Integer.class);
|
||||||
Integer store_category_id = getParameter("store_category_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);
|
Long distance = getParameter("distance", Long.class);
|
||||||
if (CheckUtil.isEmpty(distance)) {
|
if (CheckUtil.isEmpty(distance)) {
|
||||||
distance = 20000000000L;
|
distance = 20000000000L;
|
||||||
@ -759,13 +752,9 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
|||||||
Integer store_type = getParameter("store_type", Integer.class);
|
Integer store_type = getParameter("store_type", Integer.class);
|
||||||
Integer store_biz_state = getParameter("store_biz_state", Integer.class);
|
Integer store_biz_state = getParameter("store_biz_state", Integer.class);
|
||||||
|
|
||||||
UserDto user = ContextUtil.getCurrentUser();
|
UserDto user = getCurrentUser();
|
||||||
if (store_type == null) {
|
if (store_type == null) {
|
||||||
if(null!=paramsMap.get("store_type")){
|
store_type = user != null && user.isStore() && shopStoreBaseService.ifSupplierMarket() ? 2 : 1;
|
||||||
store_type=MapUtils.getInteger(paramsMap,"store_type");
|
|
||||||
}else {
|
|
||||||
store_type = user != null && user.isStore() && shopStoreBaseService.ifSupplierMarket() ? 2 : 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
queryWrapper.eq("store_type", store_type);
|
queryWrapper.eq("store_type", store_type);
|
||||||
|
|
||||||
@ -780,20 +769,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CheckUtil.isNotEmpty(store_category_id)) {
|
if (CheckUtil.isNotEmpty(store_category_id)) {
|
||||||
List<Integer> store_category_ids = new ArrayList<>();
|
queryWrapper.eq("store_category_id", store_category_id);
|
||||||
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);
|
params.put("store_category_id", store_category_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -900,11 +876,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
|||||||
|
|
||||||
data = shopStoreBaseService.getLists(queryWrapper, page, rows);
|
data = shopStoreBaseService.getLists(queryWrapper, page, rows);
|
||||||
}
|
}
|
||||||
//start只查询店铺
|
|
||||||
if(findStore){
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
//end 只查询店铺
|
|
||||||
// 修正商家活动数据,放在此处,多循环了一次
|
// 修正商家活动数据,放在此处,多循环了一次
|
||||||
List<ShopStoreActivityBase> store_activity_rows = new ArrayList<>();
|
List<ShopStoreActivityBase> store_activity_rows = new ArrayList<>();
|
||||||
List<Map<String, Object>> items = (List<Map<String, Object>>) data.get("items");
|
List<Map<String, Object>> items = (List<Map<String, Object>>) data.get("items");
|
||||||
@ -3947,34 +3919,5 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
|
|||||||
return BigDecimal.ZERO;
|
return BigDecimal.ZERO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// @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);
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -122,7 +122,7 @@ public interface SyncThirdDataService {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
Map<String, Double> getProductStockFromRedis();
|
Map<String, Integer> getProductStockFromRedis();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 下单或支付后,批量累加减商品库存,使用 Redis Hash 的原子自增操作,保证并发安全
|
* 下单或支付后,批量累加减商品库存,使用 Redis Hash 的原子自增操作,保证并发安全
|
||||||
|
|||||||
@ -35,9 +35,7 @@ import com.suisung.mall.common.feignService.SearchService;
|
|||||||
import com.suisung.mall.common.modules.account.AccountUserBase;
|
import com.suisung.mall.common.modules.account.AccountUserBase;
|
||||||
import com.suisung.mall.common.modules.base.ShopBaseProductBrand;
|
import com.suisung.mall.common.modules.base.ShopBaseProductBrand;
|
||||||
import com.suisung.mall.common.modules.base.ShopBaseProductCategory;
|
import com.suisung.mall.common.modules.base.ShopBaseProductCategory;
|
||||||
import com.suisung.mall.common.modules.product.ShopProductBase;
|
|
||||||
import com.suisung.mall.common.modules.product.ShopProductIndex;
|
import com.suisung.mall.common.modules.product.ShopProductIndex;
|
||||||
import com.suisung.mall.common.modules.product.ShopProductItem;
|
|
||||||
import com.suisung.mall.common.modules.sixun.SxSyncGoods;
|
import com.suisung.mall.common.modules.sixun.SxSyncGoods;
|
||||||
import com.suisung.mall.common.modules.sixun.SxSyncVip;
|
import com.suisung.mall.common.modules.sixun.SxSyncVip;
|
||||||
import com.suisung.mall.common.modules.store.ShopStoreActivityBase;
|
import com.suisung.mall.common.modules.store.ShopStoreActivityBase;
|
||||||
@ -52,11 +50,13 @@ import com.suisung.mall.common.utils.I18nUtil;
|
|||||||
import com.suisung.mall.common.utils.StringUtils;
|
import com.suisung.mall.common.utils.StringUtils;
|
||||||
import com.suisung.mall.shop.base.service.ShopBaseProductBrandService;
|
import com.suisung.mall.shop.base.service.ShopBaseProductBrandService;
|
||||||
import com.suisung.mall.shop.base.service.ShopBaseProductCategoryService;
|
import com.suisung.mall.shop.base.service.ShopBaseProductCategoryService;
|
||||||
|
import com.suisung.mall.shop.base.service.ShopBaseProductSpecService;
|
||||||
import com.suisung.mall.shop.number.service.ShopNumberSeqService;
|
import com.suisung.mall.shop.number.service.ShopNumberSeqService;
|
||||||
import com.suisung.mall.shop.page.service.OssService;
|
import com.suisung.mall.shop.page.service.OssService;
|
||||||
import com.suisung.mall.shop.product.service.ShopProductBaseService;
|
import com.suisung.mall.shop.product.service.ShopProductBaseService;
|
||||||
import com.suisung.mall.shop.product.service.ShopProductIndexService;
|
import com.suisung.mall.shop.product.service.ShopProductIndexService;
|
||||||
import com.suisung.mall.shop.product.service.ShopProductItemService;
|
import com.suisung.mall.shop.product.service.ShopProductItemService;
|
||||||
|
import com.suisung.mall.shop.product.service.ShopProductSpecItemService;
|
||||||
import com.suisung.mall.shop.sixun.dao.SxDataDao;
|
import com.suisung.mall.shop.sixun.dao.SxDataDao;
|
||||||
import com.suisung.mall.shop.sixun.dto.DataBaseInfo;
|
import com.suisung.mall.shop.sixun.dto.DataBaseInfo;
|
||||||
import com.suisung.mall.shop.sixun.dto.SxCategoryModel;
|
import com.suisung.mall.shop.sixun.dto.SxCategoryModel;
|
||||||
@ -788,7 +788,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
|||||||
// storeDataResultMap = sme.stream().filter(m -> !(m.getValue().equals((double) 0))).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
// storeDataResultMap = sme.stream().filter(m -> !(m.getValue().equals((double) 0))).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
Map<String, Double> storeDataResultMap = getProductStockFromRedis();
|
Map<String, Integer> storeDataResultMap = getProductStockFromRedis();
|
||||||
|
|
||||||
return new ThirdApiRes().success("success", storeDataResultMap);
|
return new ThirdApiRes().success("success", storeDataResultMap);
|
||||||
}
|
}
|
||||||
@ -812,7 +812,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Double> getProductStockFromRedis() {
|
public Map<String, Integer> getProductStockFromRedis() {
|
||||||
try {
|
try {
|
||||||
// 从 Redis 获取 hash 结构的所有键值对
|
// 从 Redis 获取 hash 结构的所有键值对
|
||||||
Map<Object, Object> redisHash = redisTemplate.opsForHash().entries(RedisKey.STOREDATARELEASE);
|
Map<Object, Object> redisHash = redisTemplate.opsForHash().entries(RedisKey.STOREDATARELEASE);
|
||||||
@ -823,7 +823,7 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
|||||||
return redisHash.entrySet().stream()
|
return redisHash.entrySet().stream()
|
||||||
.collect(Collectors.toMap(
|
.collect(Collectors.toMap(
|
||||||
entry -> String.valueOf(entry.getKey()),
|
entry -> String.valueOf(entry.getKey()),
|
||||||
entry -> Convert.toDouble(entry.getValue(), 0.00) // 转换失败时默认为 0
|
entry -> Convert.toInt(entry.getValue(), 0) // 转换失败时默认为 0
|
||||||
));
|
));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("从 Redis 获取商品库存失败: {}", e.getMessage(), e);
|
logger.error("从 Redis 获取商品库存失败: {}", e.getMessage(), e);
|
||||||
@ -845,53 +845,14 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
QueryWrapper<ShopProductItem> queryWrapper = new QueryWrapper<>();
|
|
||||||
queryWrapper.eq("item_src_id", productKey);
|
|
||||||
List<ShopProductItem> shopProductItems=shopProductItemService.list(queryWrapper);
|
|
||||||
if(shopProductItems==null || shopProductItems.isEmpty()){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ShopProductItem spuItem = shopProductItems.get(0);
|
|
||||||
cn.hutool.json.JSONArray array_item_spec= JSONUtil.parseArray(spuItem.getItem_spec());
|
|
||||||
if(array_item_spec.isEmpty()){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
cn.hutool.json.JSONObject item = (cn.hutool.json.JSONObject) ((cn.hutool.json.JSONObject) array_item_spec.get(0)).get("item");
|
|
||||||
String name = Convert.toStr(item.get("name"));
|
|
||||||
BigDecimal itemQuaryty = getBigDecimal(delta, name);
|
|
||||||
Long productId = spuItem.getProduct_id();
|
|
||||||
ShopProductBase productBase = shopProductBaseService.get(productId);
|
|
||||||
if(productBase==null){
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
String itemId=productBase.getProduct_number();
|
|
||||||
// 使用 Redis 的 HINCRBY 保证原子性和高性能
|
// 使用 Redis 的 HINCRBY 保证原子性和高性能
|
||||||
redisTemplate.opsForHash().increment(RedisKey.STOREDATARELEASE, itemId, itemQuaryty.doubleValue());
|
redisTemplate.opsForHash().increment(RedisKey.STOREDATARELEASE, productKey, delta);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("库存累计失败,productKey={}, delta={}, error={}", productKey, delta, e.getMessage(), e);
|
logger.error("库存累计失败,productKey={}, delta={}, error={}", productKey, delta, e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 计算最终数量 如果是g转换为kg,如果是数量就是直接值
|
|
||||||
* @param delta
|
|
||||||
* @param name
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private static BigDecimal getBigDecimal(Integer delta, String name) {
|
|
||||||
BigDecimal itemQuaryty = new BigDecimal(delta);
|
|
||||||
if(name.contains("kg")){
|
|
||||||
String weightStr= name.split("kg")[0];
|
|
||||||
itemQuaryty=new BigDecimal(weightStr).multiply(new BigDecimal(delta));
|
|
||||||
}
|
|
||||||
if(name.contains("g")){
|
|
||||||
String weightStr= name.split("g")[0];
|
|
||||||
itemQuaryty=new BigDecimal(weightStr).multiply(new BigDecimal(delta)).divide(new BigDecimal(1000),4,RoundingMode.HALF_UP);
|
|
||||||
}
|
|
||||||
return itemQuaryty;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 压缩商家数据,并上传cos
|
* 压缩商家数据,并上传cos
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user