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

Commit d25ee55b authored by 张国柄's avatar 张国柄

~api:正在下单-参与活动的spu:添加搜索SPU名称功能;

parent 50e849e1
......@@ -19,9 +19,10 @@ public interface IGoblinStoreZhengzaiService {
/**
* 正在下单 商铺参与活动的商品列表
* @param marketId
* @param keyword 搜索内容,支持`SPU名称`、`SKU名称`、`SKU编码`
* @return
*/
ResponseDto<List<GoblinZhengzaiGoodVo>> getSpuList(String marketId);
ResponseDto<List<GoblinZhengzaiGoodVo>> getSpuList(String marketId, String keyword);
ResponseDto<List<GoblinAppOrderListVo>> orderList(int page);
......
......@@ -12,6 +12,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import javax.validation.constraints.Size;
import java.util.List;
@Slf4j
......@@ -37,9 +38,11 @@ public class GoblinStoreZhengzaiController {
@ApiOperation("正在下单-参与活动的spu")
@ApiImplicitParams({
@ApiImplicitParam(type = "form", required = true, dataType = "String", name = "marketId", value = "活动id", example = "1"),
@ApiImplicitParam(type = "form", required = false, dataType = "String", name = "kw", value = "搜索内容【1~64位】,支持`SPU名称`、`SKU名称`、`SKU编码`", example = ""),
})
public ResponseDto<List<GoblinZhengzaiGoodVo>> getStoreList(@RequestParam("marketId") @Valid String marketId) {
return goblinStoreZhengzaiService.getSpuList(marketId);
public ResponseDto<List<GoblinZhengzaiGoodVo>> getStoreList(@RequestParam("marketId") @Valid String marketId,
@RequestParam(value = "kw", required = false) @Size(min = 1, max = 64, message = "搜索内容长度超出范围1~64位") String keyword) {
return goblinStoreZhengzaiService.getSpuList(marketId, keyword);
}
@PostMapping("list")
......
......@@ -13,6 +13,7 @@ import com.liquidnet.service.goblin.util.GoblinMongoUtils;
import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import com.liquidnet.service.goblin.util.ObjectUtil;
import com.liquidnet.service.goblin.util.QueueUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -65,7 +66,7 @@ public class GoblinStoreZhengzaiServiceImpl implements IGoblinStoreZhengzaiServi
}
@Override
public ResponseDto<List<GoblinZhengzaiGoodVo>> getSpuList(String marketId) {
public ResponseDto<List<GoblinZhengzaiGoodVo>> getSpuList(String marketId, String keyword) {
String uid = CurrentUtil.getCurrentUid();
GoblinStoreInfoVo storeInfoVo = redisUtils.getStoreInfoVoByUid(uid);
if (storeInfoVo == null) {
......@@ -83,6 +84,9 @@ public class GoblinStoreZhengzaiServiceImpl implements IGoblinStoreZhengzaiServi
}
List<GoblinMarketRelationVo> relationVo = redisUtils.getMarketRelation(GoblinStatusConst.MarketPreStatus.MARKET_PRE_ZHENGZAI.getValue(), marketId);
List<String> spuIdList = relationVo.stream().map(GoblinMarketRelationVo::getSpuId).collect(Collectors.toList());
if (StringUtils.isNotBlank(keyword)) {
spuIdList = mongoUtils.getSpuIdListBySpuIdListAndKeyword(spuIdList, keyword);
}
List<GoblinZhengzaiGoodVo> voList = ObjectUtil.getGoblinZhengzaiGoodVoArrayList();
for (String spuId : spuIdList) {
GoblinGoodsInfoVo vo = redisUtils.getGoodsInfoVo(spuId);
......
......@@ -606,6 +606,27 @@ public class GoblinMongoUtils {
return pagedResult.setList(goodsListVos).setTotal(count, filterParam.getPageSize());
}
/**
* 在指定SPU商品中模糊搜索,并返回符合条件的SPUID
*
* @param spuIdList SPUID列表
* @param keyword 搜索内容
* @return List<String>
*/
public List<String> getSpuIdListBySpuIdListAndKeyword(List<String> spuIdList, String keyword) {
Criteria criteria = Criteria.where("delFlg").is("0").and("spuId").in(spuIdList);
if (StringUtils.isNotBlank(keyword)) {
Pattern pattern = Pattern.compile("^.*" + keyword + ".*$", Pattern.CASE_INSENSITIVE);
criteria.orOperator(
Criteria.where("name").regex(pattern)
);
}
Query query = Query.query(criteria);
query.fields().include("spuId");
List<GoblinStoreMgtGoodsListVo> goodsListVos = mongoTemplate.find(query, GoblinStoreMgtGoodsListVo.class, GoblinGoodsInfoVo.class.getSimpleName());
return CollectionUtils.isEmpty(goodsListVos) ? CollectionUtil.arrayListString() : goodsListVos.stream().map(GoblinStoreMgtGoodsListVo::getSpuId).distinct().collect(Collectors.toList());
}
public List<String> getMgtSpuNosForMarketBySpuNos(List<String> spuNos, Object... shelvesStatus) {
Query query = Query.query(Criteria.where("spuNo").in(spuNos.toArray())
.and("marketId").exists(true).and("delFlg").is("0").and("shelvesStatus").in(shelvesStatus));
......
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