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

Commit bbbf90da authored by wangyifan's avatar wangyifan

收钱吧-从数据库查询店铺信息

parent 1736355b
package com.liquidnet.service.goblin.service.impl.manage; package com.liquidnet.service.goblin.service.impl.manage;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.liquidnet.common.third.sqb.biz.SqbBiz; import com.liquidnet.common.third.sqb.biz.SqbBiz;
import com.liquidnet.common.third.sqb.param.request.CommonRequest; import com.liquidnet.common.third.sqb.param.request.CommonRequest;
import com.liquidnet.common.third.sqb.param.request.MallListQueryRequest; import com.liquidnet.common.third.sqb.param.request.MallListQueryRequest;
...@@ -18,7 +19,9 @@ import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtGoodsSqbAddParam; ...@@ -18,7 +19,9 @@ import com.liquidnet.service.goblin.dto.manage.GoblinStoreMgtGoodsSqbAddParam;
import com.liquidnet.service.goblin.dto.manage.vo.GoblinMgtCategorySpecVo; import com.liquidnet.service.goblin.dto.manage.vo.GoblinMgtCategorySpecVo;
import com.liquidnet.service.goblin.dto.vo.*; import com.liquidnet.service.goblin.dto.vo.*;
import com.liquidnet.service.goblin.entity.GoblinSqbGoodsExt; import com.liquidnet.service.goblin.entity.GoblinSqbGoodsExt;
import com.liquidnet.service.goblin.entity.GoblinSqbMallInfo;
import com.liquidnet.service.goblin.mapper.GoblinSqbGoodsExtMapper; import com.liquidnet.service.goblin.mapper.GoblinSqbGoodsExtMapper;
import com.liquidnet.service.goblin.mapper.GoblinSqbMallInfoMapper;
import com.liquidnet.service.goblin.service.manage.IGoblinStoreMgtSqbGoodsService; import com.liquidnet.service.goblin.service.manage.IGoblinStoreMgtSqbGoodsService;
import com.liquidnet.service.goblin.util.GoblinMongoUtils; import com.liquidnet.service.goblin.util.GoblinMongoUtils;
import com.liquidnet.service.goblin.util.GoblinRedisUtils; import com.liquidnet.service.goblin.util.GoblinRedisUtils;
...@@ -51,19 +54,26 @@ public class GoblinStoreMgtSqbGoodsServiceImpl implements IGoblinStoreMgtSqbGood ...@@ -51,19 +54,26 @@ public class GoblinStoreMgtSqbGoodsServiceImpl implements IGoblinStoreMgtSqbGood
GoblinSqbGoodsExtMapper goblinSqbGoodsExtMapper; GoblinSqbGoodsExtMapper goblinSqbGoodsExtMapper;
@Autowired @Autowired
private SqbBiz goblinShouQianBaService; private SqbBiz goblinShouQianBaService;
@Autowired
private GoblinSqbMallInfoMapper goblinSqbMallInfoMapper;
@Override @Override
public ResponseDto<List<GoblinSqbPerfGoodsVo>> getProductList() { public ResponseDto<List<GoblinSqbPerfGoodsVo>> getProductList() {
try { try {
List<GoblinSqbPerfGoodsVo> result = new ArrayList<>(); List<GoblinSqbPerfGoodsVo> result = new ArrayList<>();
List<MallListQueryData> mallList = fetchAllMalls();
// 从mysql查询配置的店铺信息(收钱吧只有一个环境,所以通过数据库配置来获取店铺)
List<GoblinSqbMallInfo> mallList = goblinSqbMallInfoMapper.selectList(new QueryWrapper<GoblinSqbMallInfo>()
.lambda()
.eq(GoblinSqbMallInfo::getStatus, 1));
// List<MallListQueryData> mallList = fetchAllMalls();
if (CollectionUtils.isEmpty(mallList)) { if (CollectionUtils.isEmpty(mallList)) {
return ResponseDto.success(new ArrayList<>()); return ResponseDto.success(new ArrayList<>());
} }
// 获取本地已同步的商品 SPU 映射,用于标记同步状态 // 获取本地已同步的商品 SPU 映射,用于标记同步状态
List<String> mallSns = mallList.stream().map(MallListQueryData::getMallSn).distinct() List<String> mallSns = mallList.stream().map(GoblinSqbMallInfo::getMallSn).distinct()
.collect(Collectors.toList()); .collect(Collectors.toList());
List<GoblinSqbGoodsExt> syncedGoods = goblinSqbGoodsExtMapper.selectList( List<GoblinSqbGoodsExt> syncedGoods = goblinSqbGoodsExtMapper.selectList(
new LambdaQueryWrapper<GoblinSqbGoodsExt>() new LambdaQueryWrapper<GoblinSqbGoodsExt>()
...@@ -73,7 +83,7 @@ public class GoblinStoreMgtSqbGoodsServiceImpl implements IGoblinStoreMgtSqbGood ...@@ -73,7 +83,7 @@ public class GoblinStoreMgtSqbGoodsServiceImpl implements IGoblinStoreMgtSqbGood
.map(g -> g.getMallSn() + ":" + g.getSqbSpuId()) .map(g -> g.getMallSn() + ":" + g.getSqbSpuId())
.collect(Collectors.toSet()); .collect(Collectors.toSet());
for (MallListQueryData mall : mallList) { for (GoblinSqbMallInfo mall : mallList) {
List<MallProductsQueryData> products = fetchAllProducts(mall); List<MallProductsQueryData> products = fetchAllProducts(mall);
if (!CollectionUtils.isEmpty(products)) { if (!CollectionUtils.isEmpty(products)) {
for (MallProductsQueryData product : products) { for (MallProductsQueryData product : products) {
...@@ -91,7 +101,7 @@ public class GoblinStoreMgtSqbGoodsServiceImpl implements IGoblinStoreMgtSqbGood ...@@ -91,7 +101,7 @@ public class GoblinStoreMgtSqbGoodsServiceImpl implements IGoblinStoreMgtSqbGood
return ResponseDto.failure("查询收钱吧商品失败: " + e.getMessage()); return ResponseDto.failure("查询收钱吧商品失败: " + e.getMessage());
} }
} }
private static GoblinSqbPerfGoodsVo getGoblinSqbPerfGoodsVo(MallListQueryData mall, MallProductsQueryData product) { private static GoblinSqbPerfGoodsVo getGoblinSqbPerfGoodsVo(GoblinSqbMallInfo mall, MallProductsQueryData product) {
GoblinSqbPerfGoodsVo goblinSqbPerfGoodsVo = new GoblinSqbPerfGoodsVo(); GoblinSqbPerfGoodsVo goblinSqbPerfGoodsVo = new GoblinSqbPerfGoodsVo();
goblinSqbPerfGoodsVo.setMallSn(mall.getMallSn()); goblinSqbPerfGoodsVo.setMallSn(mall.getMallSn());
goblinSqbPerfGoodsVo.setMallName(mall.getMallName()); goblinSqbPerfGoodsVo.setMallName(mall.getMallName());
...@@ -144,7 +154,7 @@ public class GoblinStoreMgtSqbGoodsServiceImpl implements IGoblinStoreMgtSqbGood ...@@ -144,7 +154,7 @@ public class GoblinStoreMgtSqbGoodsServiceImpl implements IGoblinStoreMgtSqbGood
/** /**
* 循环获取某个商城下的所有商品列表(支持搜索和游标分页) * 循环获取某个商城下的所有商品列表(支持搜索和游标分页)
*/ */
private List<MallProductsQueryData> fetchAllProducts(MallListQueryData mall) { private List<MallProductsQueryData> fetchAllProducts(GoblinSqbMallInfo mall) {
MallProductsQueryRequest productRequest = new MallProductsQueryRequest(); MallProductsQueryRequest productRequest = new MallProductsQueryRequest();
productRequest.setAppid(goblinShouQianBaService.getSqbConfig().getAppId()); productRequest.setAppid(goblinShouQianBaService.getSqbConfig().getAppId());
productRequest.setSeller(buildSeller()); productRequest.setSeller(buildSeller());
......
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