规范店铺模块调用商品模块方法

This commit is contained in:
Chopper 2021-11-30 10:00:46 +08:00
parent b65cdfc1fb
commit 71e51b3b6f
4 changed files with 25 additions and 15 deletions

View File

@ -369,9 +369,8 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
*/
private void updateGoodsNum(MessageExt messageExt) {
Goods goods;
try {
goods = JSONUtil.toBean(new String(messageExt.getBody()), Goods.class);
Goods goods = JSONUtil.toBean(new String(messageExt.getBody()), Goods.class);
//更新店铺商品数量
assert goods != null;
storeService.updateStoreGoodsNum(goods.getStoreId());

View File

@ -6,6 +6,7 @@ import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
import cn.lili.modules.goods.entity.vos.GoodsVO;
import cn.lili.modules.store.entity.dos.Store;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
@ -148,4 +149,10 @@ public interface GoodsService extends IService<Goods> {
* @param goodsId 商品ID
*/
void updateGoodsCommentNum(String goodsId);
/**
* 批量更新商品的店铺信息
* @param store
*/
void updateStoreDetail(Store store);
}

View File

@ -16,6 +16,7 @@ import cn.lili.common.security.enums.UserEnums;
import cn.lili.modules.goods.entity.dos.Category;
import cn.lili.modules.goods.entity.dos.Goods;
import cn.lili.modules.goods.entity.dos.GoodsGallery;
import cn.lili.modules.goods.entity.dos.GoodsSku;
import cn.lili.modules.goods.entity.dto.GoodsOperationDTO;
import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
@ -29,6 +30,7 @@ import cn.lili.modules.member.entity.dos.MemberEvaluation;
import cn.lili.modules.member.entity.enums.EvaluationGradeEnum;
import cn.lili.modules.member.service.MemberEvaluationService;
import cn.lili.modules.store.entity.dos.FreightTemplate;
import cn.lili.modules.store.entity.dos.Store;
import cn.lili.modules.store.entity.vos.StoreVO;
import cn.lili.modules.store.service.FreightTemplateService;
import cn.lili.modules.store.service.StoreService;
@ -42,6 +44,7 @@ import cn.lili.rocketmq.tags.GoodsTagsEnum;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -121,8 +124,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
@Override
public List<Goods> getByBrandIds(List<String> brandIds) {
LambdaQueryWrapper<Goods> lambdaQueryWrapper = new LambdaQueryWrapper<Goods> ();
lambdaQueryWrapper.in(Goods::getBrandId,brandIds);
LambdaQueryWrapper<Goods> lambdaQueryWrapper = new LambdaQueryWrapper<Goods>();
lambdaQueryWrapper.in(Goods::getBrandId, brandIds);
return list(lambdaQueryWrapper);
}
@ -396,6 +399,16 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
this.updateById(goods);
}
@Override
public void updateStoreDetail(Store store) {
UpdateWrapper updateWrapper = new UpdateWrapper<>()
.eq("store_id", store.getId())
.set("store_name", store.getStoreName())
.set("self_operated", store.getSelfOperated());
this.update(updateWrapper);
goodsSkuService.update(updateWrapper);
}
/**
* 添加商品默认图片
*

View File

@ -64,9 +64,6 @@ public class StoreDetailServiceImpl extends ServiceImpl<StoreDetailMapper, Store
@Autowired
private GoodsService goodsService;
@Autowired
private GoodsSkuService goodsSkuService;
@Autowired
private RocketmqCustomProperties rocketmqCustomProperties;
@ -104,16 +101,10 @@ public class StoreDetailServiceImpl extends ServiceImpl<StoreDetailMapper, Store
return result;
}
@Override
public void updateStoreGoodsInfo(Store store) {
goodsService.update(new LambdaUpdateWrapper<Goods>()
.eq(Goods::getStoreId, store.getId())
.set(Goods::getStoreName, store.getStoreName())
.set(Goods::getSelfOperated, store.getSelfOperated()));
goodsSkuService.update(new LambdaUpdateWrapper<GoodsSku>()
.eq(GoodsSku::getStoreId, store.getId())
.set(GoodsSku::getStoreName, store.getStoreName())
.set(GoodsSku::getSelfOperated, store.getSelfOperated()));
goodsService.updateStoreDetail(store);
Map<String, Object> updateIndexFieldsMap = EsIndexUtil.getUpdateIndexFieldsMap(
MapUtil.builder().put("storeId", store.getId()).build(),