|
@@ -15,14 +15,11 @@ import cn.newfeifan.mall.module.product.dal.mysql.spu.ProductSpuMapper;
|
|
import cn.newfeifan.mall.module.product.enums.spu.ProductSpuStatusEnum;
|
|
import cn.newfeifan.mall.module.product.enums.spu.ProductSpuStatusEnum;
|
|
import cn.newfeifan.mall.module.product.service.category.ProductCategoryService;
|
|
import cn.newfeifan.mall.module.product.service.category.ProductCategoryService;
|
|
import cn.newfeifan.mall.module.product.service.sku.ProductSkuService;
|
|
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 cn.newfeifan.mall.module.system.controller.admin.user.vo.user.UserShopDetailsVO;
|
|
|
|
+import cn.newfeifan.mall.module.system.service.user.AdminUserService;
|
|
import com.google.common.collect.Maps;
|
|
import com.google.common.collect.Maps;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.context.annotation.Lazy;
|
|
-import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
@@ -32,7 +29,6 @@ import java.util.*;
|
|
|
|
|
|
import static cn.newfeifan.mall.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
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.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.dal.dataobject.category.ProductCategoryDO.CATEGORY_LEVEL;
|
|
import static cn.newfeifan.mall.module.product.enums.ErrorCodeConstants.*;
|
|
import static cn.newfeifan.mall.module.product.enums.ErrorCodeConstants.*;
|
|
|
|
|
|
@@ -55,9 +51,7 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|
@Resource
|
|
@Resource
|
|
private ProductCategoryService categoryService;
|
|
private ProductCategoryService categoryService;
|
|
@Resource
|
|
@Resource
|
|
- private StringRedisTemplate stringRedisTemplate;
|
|
|
|
- @Resource
|
|
|
|
- private AdminUserMapper userMapper;
|
|
|
|
|
|
+ private AdminUserService userService;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -79,13 +73,14 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|
initSpuFromSkus(spu, skuSaveReqList);
|
|
initSpuFromSkus(spu, skuSaveReqList);
|
|
|
|
|
|
//加入商户、店铺信息
|
|
//加入商户、店铺信息
|
|
- ShopBO shop = getShop();
|
|
|
|
- spu.setShopId(shop.getShopId());
|
|
|
|
- spu.setMerchantId(shop.getMerId());
|
|
|
|
|
|
+ UserShopDetailsVO userShopDetails = userService.getUserShopDetails();
|
|
|
|
+
|
|
|
|
+ spu.setShopId(userShopDetails.getShopId());
|
|
|
|
+ spu.setMerchantId(userShopDetails.getMerchantId());
|
|
|
|
|
|
for (ProductSkuSaveReqVO productSkuSaveReqVO : skuSaveReqList) {
|
|
for (ProductSkuSaveReqVO productSkuSaveReqVO : skuSaveReqList) {
|
|
- productSkuSaveReqVO.setShopId(shop.getShopId());
|
|
|
|
- productSkuSaveReqVO.setMerchantId(shop.getMerId());
|
|
|
|
|
|
+ productSkuSaveReqVO.setShopId(userShopDetails.getShopId());
|
|
|
|
+ productSkuSaveReqVO.setMerchantId(userShopDetails.getMerchantId());
|
|
}
|
|
}
|
|
|
|
|
|
// 插入 SPU
|
|
// 插入 SPU
|
|
@@ -96,22 +91,6 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|
return spu.getId();
|
|
return spu.getId();
|
|
}
|
|
}
|
|
|
|
|
|
- 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
|
|
@Override
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public void updateSpu(ProductSpuSaveReqVO updateReqVO) {
|
|
public void updateSpu(ProductSpuSaveReqVO updateReqVO) {
|
|
@@ -245,9 +224,10 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public PageResult<ProductSpuDO> getSpuPage(ProductSpuPageReqVO pageReqVO) {
|
|
public PageResult<ProductSpuDO> getSpuPage(ProductSpuPageReqVO pageReqVO) {
|
|
- ShopBO shop = getShop();
|
|
|
|
- pageReqVO.setShopId(shop.getShopId());
|
|
|
|
- pageReqVO.setMerchantId(shop.getMerId());
|
|
|
|
|
|
+ UserShopDetailsVO userShopDetails = userService.getUserShopDetails();
|
|
|
|
+
|
|
|
|
+ pageReqVO.setShopId(userShopDetails.getShopId());
|
|
|
|
+ pageReqVO.setMerchantId(userShopDetails.getMerchantId());
|
|
return productSpuMapper.selectPage(pageReqVO);
|
|
return productSpuMapper.selectPage(pageReqVO);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -314,23 +294,23 @@ public class ProductSpuServiceImpl implements ProductSpuService {
|
|
public Map<Integer, Long> getTabsCountByMer() {
|
|
public Map<Integer, Long> getTabsCountByMer() {
|
|
Map<Integer, Long> counts = Maps.newLinkedHashMapWithExpectedSize(5);
|
|
Map<Integer, Long> counts = Maps.newLinkedHashMapWithExpectedSize(5);
|
|
|
|
|
|
- ShopBO shop = getShop();
|
|
|
|
|
|
+ UserShopDetailsVO userShopDetails = userService.getUserShopDetails();
|
|
|
|
|
|
// 查询销售中的商品数量
|
|
// 查询销售中的商品数量
|
|
counts.put(ProductSpuPageReqVO.FOR_SALE,
|
|
counts.put(ProductSpuPageReqVO.FOR_SALE,
|
|
- productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus(), shop.getMerId(),shop.getShopId()));
|
|
|
|
|
|
+ productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.ENABLE.getStatus(), userShopDetails.getMerchantId(),userShopDetails.getShopId()));
|
|
// 查询仓库中的商品数量
|
|
// 查询仓库中的商品数量
|
|
counts.put(ProductSpuPageReqVO.IN_WAREHOUSE,
|
|
counts.put(ProductSpuPageReqVO.IN_WAREHOUSE,
|
|
- productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.DISABLE.getStatus(), shop.getMerId(),shop.getShopId()));
|
|
|
|
|
|
+ productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.DISABLE.getStatus(), userShopDetails.getMerchantId(),userShopDetails.getShopId()));
|
|
// 查询售空的商品数量
|
|
// 查询售空的商品数量
|
|
counts.put(ProductSpuPageReqVO.SOLD_OUT,
|
|
counts.put(ProductSpuPageReqVO.SOLD_OUT,
|
|
- productSpuMapper.selectCount(ProductSpuDO::getStock, 0, shop.getMerId(),shop.getShopId()));
|
|
|
|
|
|
+ productSpuMapper.selectCount(ProductSpuDO::getStock, 0, userShopDetails.getMerchantId(),userShopDetails.getShopId()));
|
|
// 查询触发警戒库存的商品数量
|
|
// 查询触发警戒库存的商品数量
|
|
counts.put(ProductSpuPageReqVO.ALERT_STOCK,
|
|
counts.put(ProductSpuPageReqVO.ALERT_STOCK,
|
|
- productSpuMapper.selectCount(shop.getMerId(),shop.getShopId()));
|
|
|
|
|
|
+ productSpuMapper.selectCount(userShopDetails.getMerchantId(),userShopDetails.getShopId()));
|
|
// 查询回收站中的商品数量
|
|
// 查询回收站中的商品数量
|
|
counts.put(ProductSpuPageReqVO.RECYCLE_BIN,
|
|
counts.put(ProductSpuPageReqVO.RECYCLE_BIN,
|
|
- productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus(), shop.getMerId(),shop.getShopId()));
|
|
|
|
|
|
+ productSpuMapper.selectCount(ProductSpuDO::getStatus, ProductSpuStatusEnum.RECYCLE.getStatus(), userShopDetails.getMerchantId(),userShopDetails.getShopId()));
|
|
return counts;
|
|
return counts;
|
|
}
|
|
}
|
|
|
|
|