记得上下班打卡 | git大法好,push需谨慎

Commit e0ea79d5 authored by wangyifan's avatar wangyifan

goblin 改成从mongodb查询商品

parent bdae082e
...@@ -27,8 +27,6 @@ import com.liquidnet.service.goblin.dto.vo.GoblinArtistAuthApplyVo; ...@@ -27,8 +27,6 @@ import com.liquidnet.service.goblin.dto.vo.GoblinArtistAuthApplyVo;
import com.liquidnet.service.goblin.dto.vo.GoblinArtistTopicVo; import com.liquidnet.service.goblin.dto.vo.GoblinArtistTopicVo;
import com.liquidnet.service.goblin.dto.vo.GoblinGoodsInfoVo; import com.liquidnet.service.goblin.dto.vo.GoblinGoodsInfoVo;
import com.liquidnet.service.goblin.dto.vo.GoblinStoreInfoVo; import com.liquidnet.service.goblin.dto.vo.GoblinStoreInfoVo;
import com.liquidnet.service.goblin.entity.GoblinGoods;
import com.liquidnet.service.goblin.mapper.GoblinGoodsMapper;
import com.liquidnet.service.goblin.service.manage.IGoblinStoreMgtArtistService; import com.liquidnet.service.goblin.service.manage.IGoblinStoreMgtArtistService;
import com.liquidnet.service.goblin.util.GoblinRedisUtils; import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import com.liquidnet.service.goblin.util.QueueUtils; import com.liquidnet.service.goblin.util.QueueUtils;
...@@ -72,8 +70,6 @@ public class GoblinStoreMgtArtistServiceImpl implements IGoblinStoreMgtArtistSer ...@@ -72,8 +70,6 @@ public class GoblinStoreMgtArtistServiceImpl implements IGoblinStoreMgtArtistSer
@Autowired @Autowired
private QueueUtils queueUtils; private QueueUtils queueUtils;
@Autowired @Autowired
private GoblinGoodsMapper goodsMapper;
@Autowired
private KylinArtistMapper kylinArtistMapper; private KylinArtistMapper kylinArtistMapper;
private ResponseDto<GoblinStoreInfoVo> requireStore() { private ResponseDto<GoblinStoreInfoVo> requireStore() {
...@@ -396,14 +392,14 @@ public class GoblinStoreMgtArtistServiceImpl implements IGoblinStoreMgtArtistSer ...@@ -396,14 +392,14 @@ public class GoblinStoreMgtArtistServiceImpl implements IGoblinStoreMgtArtistSer
.map(GoblinArtistTopicVo.GoodsItem::getSpuId) .map(GoblinArtistTopicVo.GoodsItem::getSpuId)
.filter(StringUtils::isNotBlank) .filter(StringUtils::isNotBlank)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
Map<String, GoblinGoods> goodsMap = loadGoodsMapBySpuIds(spuIds); Map<String, GoblinGoodsInfoVo> goodsMap = loadGoodsMapBySpuIds(spuIds);
for (GoblinArtistTopicVo.GoodsItem goods : topic.getGoods()) { for (GoblinArtistTopicVo.GoodsItem goods : topic.getGoods()) {
GoblinStoreMgtArtistTopicDetailVo.GoodsItem item = new GoblinStoreMgtArtistTopicDetailVo.GoodsItem(); GoblinStoreMgtArtistTopicDetailVo.GoodsItem item = new GoblinStoreMgtArtistTopicDetailVo.GoodsItem();
item.setSpuId(goods.getSpuId()); item.setSpuId(goods.getSpuId());
item.setSort(goods.getSort()); item.setSort(goods.getSort());
item.setName(goods.getName()); item.setName(goods.getName());
item.setCoverPic(goods.getCoverPic()); item.setCoverPic(goods.getCoverPic());
GoblinGoods dbGoods = goodsMap.get(goods.getSpuId()); GoblinGoodsInfoVo dbGoods = goodsMap.get(goods.getSpuId());
if (dbGoods != null) { if (dbGoods != null) {
item.setName(dbGoods.getName()); item.setName(dbGoods.getName());
item.setCoverPic(dbGoods.getCoverPic()); item.setCoverPic(dbGoods.getCoverPic());
...@@ -470,7 +466,7 @@ public class GoblinStoreMgtArtistServiceImpl implements IGoblinStoreMgtArtistSer ...@@ -470,7 +466,7 @@ public class GoblinStoreMgtArtistServiceImpl implements IGoblinStoreMgtArtistSer
topicVo.setCreatedAt(now); topicVo.setCreatedAt(now);
topicVo.setUpdatedAt(now); topicVo.setUpdatedAt(now);
Map<String, GoblinGoods> goodsMap = loadGoodsMap(params.getGoods()); Map<String, GoblinGoodsInfoVo> goodsMap = loadGoodsMap(params.getGoods());
List<GoblinArtistTopicVo.GoodsItem> goodsItems = buildGoodsItems(params.getGoods(), goodsMap); List<GoblinArtistTopicVo.GoodsItem> goodsItems = buildGoodsItems(params.getGoods(), goodsMap);
ResponseDto<Void> goodsCheck = checkGoodsBelong(storeId, goodsMap, params.getGoods()); ResponseDto<Void> goodsCheck = checkGoodsBelong(storeId, goodsMap, params.getGoods());
if (!goodsCheck.isSuccess()) { if (!goodsCheck.isSuccess()) {
...@@ -523,7 +519,7 @@ public class GoblinStoreMgtArtistServiceImpl implements IGoblinStoreMgtArtistSer ...@@ -523,7 +519,7 @@ public class GoblinStoreMgtArtistServiceImpl implements IGoblinStoreMgtArtistSer
} }
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
Map<String, GoblinGoods> goodsMap = loadGoodsMap(params.getGoods()); Map<String, GoblinGoodsInfoVo> goodsMap = loadGoodsMap(params.getGoods());
ResponseDto<Void> goodsCheck = checkGoodsBelong(storeId, goodsMap, params.getGoods()); ResponseDto<Void> goodsCheck = checkGoodsBelong(storeId, goodsMap, params.getGoods());
if (!goodsCheck.isSuccess()) { if (!goodsCheck.isSuccess()) {
return ResponseDto.failure(goodsCheck.getMessage()); return ResponseDto.failure(goodsCheck.getMessage());
...@@ -681,14 +677,14 @@ public class GoblinStoreMgtArtistServiceImpl implements IGoblinStoreMgtArtistSer ...@@ -681,14 +677,14 @@ public class GoblinStoreMgtArtistServiceImpl implements IGoblinStoreMgtArtistSer
return StringUtils.trimToNull(customAvatarUrl); return StringUtils.trimToNull(customAvatarUrl);
} }
private ResponseDto<Void> checkGoodsBelong(String storeId, Map<String, GoblinGoods> goodsMap, private ResponseDto<Void> checkGoodsBelong(String storeId, Map<String, GoblinGoodsInfoVo> goodsMap,
List<GoblinStoreMgtArtistTopicGoodsItemParams> paramsGoods) { List<GoblinStoreMgtArtistTopicGoodsItemParams> paramsGoods) {
if (CollectionUtils.isEmpty(paramsGoods)) { if (CollectionUtils.isEmpty(paramsGoods)) {
return ResponseDto.success(null); return ResponseDto.success(null);
} }
for (GoblinStoreMgtArtistTopicGoodsItemParams item : paramsGoods) { for (GoblinStoreMgtArtistTopicGoodsItemParams item : paramsGoods) {
if (StringUtils.isBlank(item.getSpuId())) continue; if (StringUtils.isBlank(item.getSpuId())) continue;
GoblinGoods goods = goodsMap.get(item.getSpuId()); GoblinGoodsInfoVo goods = goodsMap.get(item.getSpuId());
if (goods == null || !Objects.equals(goods.getStoreId(), storeId) if (goods == null || !Objects.equals(goods.getStoreId(), storeId)
|| !Objects.equals(goods.getDelFlg(), "0")) { || !Objects.equals(goods.getDelFlg(), "0")) {
return ResponseDto.failure("存在非本店或已删除商品"); return ResponseDto.failure("存在非本店或已删除商品");
...@@ -735,7 +731,7 @@ public class GoblinStoreMgtArtistServiceImpl implements IGoblinStoreMgtArtistSer ...@@ -735,7 +731,7 @@ public class GoblinStoreMgtArtistServiceImpl implements IGoblinStoreMgtArtistSer
// ======================== 私有:商品 / 艺人 Map ======================== // ======================== 私有:商品 / 艺人 Map ========================
private Map<String, GoblinGoods> loadGoodsMap(List<GoblinStoreMgtArtistTopicGoodsItemParams> goods) { private Map<String, GoblinGoodsInfoVo> loadGoodsMap(List<GoblinStoreMgtArtistTopicGoodsItemParams> goods) {
if (CollectionUtils.isEmpty(goods)) { if (CollectionUtils.isEmpty(goods)) {
return Collections.emptyMap(); return Collections.emptyMap();
} }
...@@ -744,22 +740,27 @@ public class GoblinStoreMgtArtistServiceImpl implements IGoblinStoreMgtArtistSer ...@@ -744,22 +740,27 @@ public class GoblinStoreMgtArtistServiceImpl implements IGoblinStoreMgtArtistSer
return loadGoodsMapBySpuIds(spuIds); return loadGoodsMapBySpuIds(spuIds);
} }
private Map<String, GoblinGoods> loadGoodsMapBySpuIds(Set<String> spuIds) { private Map<String, GoblinGoodsInfoVo> loadGoodsMapBySpuIds(Set<String> spuIds) {
if (CollectionUtils.isEmpty(spuIds)) { if (CollectionUtils.isEmpty(spuIds)) {
return Collections.emptyMap(); return Collections.emptyMap();
} }
List<GoblinGoods> list = goodsMapper.selectList(new LambdaQueryWrapper<GoblinGoods>() List<GoblinGoodsInfoVo> list = mongoTemplate.find(
.in(GoblinGoods::getSpuId, spuIds)); new Query(Criteria.where("spuId").in(spuIds)),
Map<String, GoblinGoods> map = new HashMap<>(); GoblinGoodsInfoVo.class, GoblinGoodsInfoVo.class.getSimpleName());
for (GoblinGoods g : list) { Map<String, GoblinGoodsInfoVo> map = new HashMap<>();
if (list != null) {
for (GoblinGoodsInfoVo g : list) {
if (g != null && StringUtils.isNotBlank(g.getSpuId())) {
map.put(g.getSpuId(), g); map.put(g.getSpuId(), g);
} }
}
}
return map; return map;
} }
private List<GoblinArtistTopicVo.GoodsItem> buildGoodsItems( private List<GoblinArtistTopicVo.GoodsItem> buildGoodsItems(
List<GoblinStoreMgtArtistTopicGoodsItemParams> paramsGoods, List<GoblinStoreMgtArtistTopicGoodsItemParams> paramsGoods,
Map<String, GoblinGoods> goodsMap) { Map<String, GoblinGoodsInfoVo> goodsMap) {
List<GoblinArtistTopicVo.GoodsItem> items = new ArrayList<>(); List<GoblinArtistTopicVo.GoodsItem> items = new ArrayList<>();
if (CollectionUtils.isEmpty(paramsGoods)) { if (CollectionUtils.isEmpty(paramsGoods)) {
return items; return items;
...@@ -770,7 +771,7 @@ public class GoblinStoreMgtArtistServiceImpl implements IGoblinStoreMgtArtistSer ...@@ -770,7 +771,7 @@ public class GoblinStoreMgtArtistServiceImpl implements IGoblinStoreMgtArtistSer
GoblinArtistTopicVo.GoodsItem item = new GoblinArtistTopicVo.GoodsItem(); GoblinArtistTopicVo.GoodsItem item = new GoblinArtistTopicVo.GoodsItem();
item.setSpuId(p.getSpuId()); item.setSpuId(p.getSpuId());
item.setSort(p.getSort() == null ? index : p.getSort()); item.setSort(p.getSort() == null ? index : p.getSort());
GoblinGoods goods = goodsMap.get(p.getSpuId()); GoblinGoodsInfoVo goods = goodsMap.get(p.getSpuId());
if (goods != null) { if (goods != null) {
item.setName(goods.getName()); item.setName(goods.getName());
item.setCoverPic(goods.getCoverPic()); item.setCoverPic(goods.getCoverPic());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment