|
@@ -17,14 +17,9 @@ import cn.newfeifan.mall.module.product.service.brand.ProductBrandService;
|
|
|
import cn.newfeifan.mall.module.product.service.category.ProductCategoryService;
|
|
|
import cn.newfeifan.mall.module.product.service.favorite.ProductFavoriteService;
|
|
|
import cn.newfeifan.mall.module.product.service.sku.ProductSkuService;
|
|
|
-import cn.newfeifan.mall.module.system.dal.dataobject.user.AdminUserDO;
|
|
|
-import cn.newfeifan.mall.module.system.dal.mysql.user.AdminUserMapper;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
import com.google.common.collect.Maps;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
-import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
@@ -34,7 +29,6 @@ import java.util.*;
|
|
|
|
|
|
import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
import static cn.newfeifan.mall.framework.common.util.collection.CollectionUtils.*;
|
|
|
-import static cn.newfeifan.mall.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
|
|
import static cn.newfeifan.mall.module.product.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL;
|
|
|
import static cn.newfeifan.mall.module.product.enums.ErrorCodeConstants.*;
|
|
|
|
|
@@ -62,13 +56,6 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|
|
@Resource
|
|
|
private ProductFavoriteService favoriteService;
|
|
|
|
|
|
-
|
|
|
- @Resource
|
|
|
- private StringRedisTemplate stringRedisTemplate;
|
|
|
-
|
|
|
- @Resource
|
|
|
- private AdminUserMapper userMapper;
|
|
|
-
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Long createSpu(ProductSpuSaveReqVO createReqVO) {
|
|
@@ -302,42 +289,24 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|
|
public Map<Integer, Long> getTabsCount(Long merId) {
|
|
|
Map<Integer, Long> counts = Maps.newLinkedHashMapWithExpectedSize(5);
|
|
|
|
|
|
- ShopBO shop = getShop();
|
|
|
-
|
|
|
// 查询销售中的商品数量
|
|
|
counts.put(ProductSpuPageReqVO.FOR_SALE,
|
|
|
- productSpuMapper.selectCountByMerId(shop.getShopId(),shop.getMerId(),ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus()));
|
|
|
+ productSpuMapper.selectCountByMerId(merId,ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus()));
|
|
|
// 查询仓库中的商品数量
|
|
|
counts.put(ProductSpuPageReqVO.IN_WAREHOUSE,
|
|
|
- productSpuMapper.selectCountByMerId(shop.getShopId(),shop.getMerId(),ProductSpuDO::getStatus, ProductSpuStatusEnum.DISABLE.getStatus()));
|
|
|
+ productSpuMapper.selectCountByMerId(merId,ProductSpuDO::getStatus, ProductSpuStatusEnum.DISABLE.getStatus()));
|
|
|
// 查询售空的商品数量
|
|
|
counts.put(ProductSpuPageReqVO.SOLD_OUT,
|
|
|
- productSpuMapper.selectCountByMerId(shop.getShopId(),shop.getMerId(),ProductSpuDO::getStock, 0));
|
|
|
+ productSpuMapper.selectCountByMerId(merId,ProductSpuDO::getStock, 0));
|
|
|
// 查询触发警戒库存的商品数量
|
|
|
counts.put(ProductSpuPageReqVO.ALERT_STOCK,
|
|
|
- productSpuMapper.selectCountByMerId(shop.getShopId(),shop.getMerId()));
|
|
|
+ productSpuMapper.selectCountByMerId(merId));
|
|
|
// 查询回收站中的商品数量
|
|
|
counts.put(ProductSpuPageReqVO.RECYCLE_BIN,
|
|
|
- productSpuMapper.selectCountByMerId(shop.getShopId(),shop.getMerId(),ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus()));
|
|
|
+ productSpuMapper.selectCountByMerId(merId,ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus()));
|
|
|
return counts;
|
|
|
}
|
|
|
|
|
|
- private ShopBO getShop(){
|
|
|
- Long loginUserId = getLoginUserId();
|
|
|
- String s = stringRedisTemplate.opsForValue().get("shop:" + loginUserId);
|
|
|
- if (StringUtils.isEmpty(s)) {
|
|
|
- AdminUserDO adminUserDO = userMapper.selectById(loginUserId);
|
|
|
- ShopBO shop = new ShopBO();
|
|
|
- shop.setShopId(adminUserDO.getShopId());
|
|
|
- shop.setMerId(adminUserDO.getMerchantId());
|
|
|
- log.info("====shop:{}", shop);
|
|
|
- return shop;
|
|
|
- } else {
|
|
|
- log.info("====shop:{}", s);
|
|
|
- return JSONObject.parseObject(s, ShopBO.class);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
@Override
|
|
|
public Long getSpuCountByCategoryId(Long categoryId) {
|