commit
00805d6a49
@ -25,6 +25,7 @@ import cn.lili.modules.goods.service.GoodsService;
|
||||
import cn.lili.modules.goods.service.GoodsSkuService;
|
||||
import cn.lili.modules.member.entity.dos.FootPrint;
|
||||
import cn.lili.modules.member.entity.dos.MemberEvaluation;
|
||||
import cn.lili.modules.member.entity.dto.CollectionDTO;
|
||||
import cn.lili.modules.member.service.FootprintService;
|
||||
import cn.lili.modules.member.service.GoodsCollectionService;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
@ -198,10 +199,6 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
List<String> skuIds = JSONUtil.toList(message, String.class);
|
||||
goodsCollectionService.deleteSkuCollection(skuIds);
|
||||
break;
|
||||
//收藏商品
|
||||
case GOODS_COLLECTION:
|
||||
storeService.updateStoreCollectionNum(new String(messageExt.getBody()));
|
||||
break;
|
||||
//商品评价
|
||||
case GOODS_COMMENT_COMPLETE:
|
||||
MemberEvaluation memberEvaluation = JSONUtil.toBean(new String(messageExt.getBody()), MemberEvaluation.class);
|
||||
@ -369,9 +366,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());
|
||||
|
@ -6,6 +6,8 @@ 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.member.entity.dto.CollectionDTO;
|
||||
import cn.lili.modules.store.entity.dos.Store;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
@ -148,4 +150,11 @@ public interface GoodsService extends IService<Goods> {
|
||||
* @param goodsId 商品ID
|
||||
*/
|
||||
void updateGoodsCommentNum(String goodsId);
|
||||
|
||||
/**
|
||||
* 批量更新商品的店铺信息
|
||||
* @param store
|
||||
*/
|
||||
void updateStoreDetail(Store store);
|
||||
|
||||
}
|
@ -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;
|
||||
@ -26,9 +27,11 @@ import cn.lili.modules.goods.entity.vos.GoodsVO;
|
||||
import cn.lili.modules.goods.mapper.GoodsMapper;
|
||||
import cn.lili.modules.goods.service.*;
|
||||
import cn.lili.modules.member.entity.dos.MemberEvaluation;
|
||||
import cn.lili.modules.member.entity.dto.CollectionDTO;
|
||||
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 +45,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 +125,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 +400,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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加商品默认图片
|
||||
*
|
||||
|
@ -0,0 +1,28 @@
|
||||
package cn.lili.modules.member.entity.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 收藏数量变化DTO
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0
|
||||
* 2021-11-30 10:14
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public class CollectionDTO {
|
||||
|
||||
/**
|
||||
* 变化的模型id
|
||||
* 商品id/店铺id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 变化的数量
|
||||
* -1 减少1 / +1 增加1
|
||||
*/
|
||||
private Integer num;
|
||||
}
|
@ -3,6 +3,7 @@ package cn.lili.modules.member.serviceimpl;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.modules.member.entity.dto.CollectionDTO;
|
||||
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
|
||||
import cn.lili.rocketmq.tags.GoodsTagsEnum;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
@ -73,10 +74,6 @@ public class GoodsCollectionServiceImpl extends ServiceImpl<GoodsCollectionMappe
|
||||
goodsCollection = new GoodsCollection(UserContext.getCurrentUser().getId(), skuId);
|
||||
|
||||
this.save(goodsCollection);
|
||||
//商品收藏消息
|
||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_COLLECTION.name();
|
||||
//发送mq消息
|
||||
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(skuId), RocketmqSendCallbackBuilder.commonCallback());
|
||||
return goodsCollection;
|
||||
}
|
||||
throw new ServiceException(ResultCode.USER_COLLECTION_EXIST);
|
||||
|
@ -3,6 +3,8 @@ package cn.lili.modules.member.serviceimpl;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.modules.member.entity.dto.CollectionDTO;
|
||||
import cn.lili.modules.store.service.StoreService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.member.entity.dos.StoreCollection;
|
||||
@ -13,6 +15,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Optional;
|
||||
@ -26,6 +29,10 @@ import java.util.Optional;
|
||||
@Service
|
||||
public class StoreCollectionServiceImpl extends ServiceImpl<StoreCollectionMapper, StoreCollection> implements StoreCollectionService {
|
||||
|
||||
|
||||
@Autowired
|
||||
private StoreService storeService;
|
||||
|
||||
@Override
|
||||
public IPage<StoreCollectionVO> storeCollection(PageVO pageVo) {
|
||||
QueryWrapper<StoreCollectionVO> queryWrapper = new QueryWrapper();
|
||||
@ -49,6 +56,7 @@ public class StoreCollectionServiceImpl extends ServiceImpl<StoreCollectionMappe
|
||||
.eq(StoreCollection::getStoreId, storeId)) == null) {
|
||||
StoreCollection storeCollection = new StoreCollection(UserContext.getCurrentUser().getId(), storeId);
|
||||
this.save(storeCollection);
|
||||
storeService.updateStoreCollectionNum(new CollectionDTO(storeId, 1));
|
||||
return storeCollection;
|
||||
}
|
||||
throw new ServiceException(ResultCode.USER_COLLECTION_EXIST);
|
||||
@ -59,6 +67,7 @@ public class StoreCollectionServiceImpl extends ServiceImpl<StoreCollectionMappe
|
||||
QueryWrapper<StoreCollection> queryWrapper = new QueryWrapper();
|
||||
queryWrapper.eq("member_id", UserContext.getCurrentUser().getId());
|
||||
queryWrapper.eq("store_id", storeId);
|
||||
storeService.updateStoreCollectionNum(new CollectionDTO(storeId, -1));
|
||||
return this.remove(queryWrapper);
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
* 店铺数据处理层
|
||||
@ -37,4 +38,13 @@ public interface StoreMapper extends BaseMapper<Store> {
|
||||
IPage<StoreVO> getStoreList(IPage<StoreVO> page, @Param(Constants.WRAPPER) Wrapper<StoreVO> queryWrapper);
|
||||
|
||||
|
||||
/**
|
||||
* 修改店铺收藏数据
|
||||
*
|
||||
* @param storeId 店铺id
|
||||
* @param num 收藏数量
|
||||
*/
|
||||
@Update("update li_store set collection_num = collection_num + #{num} where id = #{storeId}")
|
||||
void updateCollection(String storeId, Integer num);
|
||||
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
package cn.lili.modules.store.service;
|
||||
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.member.entity.dto.CollectionDTO;
|
||||
import cn.lili.modules.store.entity.dos.Store;
|
||||
import cn.lili.modules.store.entity.dto.*;
|
||||
import cn.lili.modules.store.entity.vos.StoreSearchParams;
|
||||
@ -132,7 +133,7 @@ public interface StoreService extends IService<Store> {
|
||||
/**
|
||||
* 更新店铺收藏数量
|
||||
*
|
||||
* @param goodsId 店铺ID
|
||||
* @param collectionDTO 收藏信息
|
||||
*/
|
||||
void updateStoreCollectionNum(String goodsId);
|
||||
void updateStoreCollectionNum(CollectionDTO collectionDTO);
|
||||
}
|
@ -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(),
|
||||
|
@ -16,6 +16,7 @@ import cn.lili.modules.goods.service.GoodsService;
|
||||
import cn.lili.modules.goods.service.GoodsSkuService;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
import cn.lili.modules.member.entity.dos.StoreCollection;
|
||||
import cn.lili.modules.member.entity.dto.CollectionDTO;
|
||||
import cn.lili.modules.member.service.MemberService;
|
||||
import cn.lili.modules.member.service.StoreCollectionService;
|
||||
import cn.lili.modules.page.service.PageDataService;
|
||||
@ -319,15 +320,8 @@ public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStoreCollectionNum(String goodsId) {
|
||||
String storeId = goodsSkuService.getById(goodsId).getStoreId();
|
||||
//获取店铺收藏数量
|
||||
Integer collectionNum = storeCollectionService.count(new LambdaQueryWrapper<StoreCollection>()
|
||||
.eq(StoreCollection::getStoreId, storeId));
|
||||
//修改店铺收藏数量
|
||||
this.update(new LambdaUpdateWrapper<Store>()
|
||||
.set(Store::getCollectionNum, collectionNum)
|
||||
.eq(Store::getId, storeId));
|
||||
public void updateStoreCollectionNum(CollectionDTO collectionDTO) {
|
||||
baseMapper.updateCollection(collectionDTO.getId(), collectionDTO.getNum());
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user