修复商品索引参数问题
This commit is contained in:
parent
337775013e
commit
41a86ff7dc
@ -6,10 +6,14 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
|||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
import org.hibernate.validator.constraints.Length;
|
import org.hibernate.validator.constraints.Length;
|
||||||
|
|
||||||
import javax.persistence.Entity;
|
import javax.persistence.Entity;
|
||||||
import javax.persistence.Table;
|
import javax.persistence.Table;
|
||||||
|
import javax.validation.constraints.Max;
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 商品关联参数
|
* 商品关联参数
|
||||||
@ -17,6 +21,7 @@ import javax.persistence.Table;
|
|||||||
* @author pikachu
|
* @author pikachu
|
||||||
* @date 2020-02-23 9:14:33
|
* @date 2020-02-23 9:14:33
|
||||||
*/
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
@Table(name = "li_goods_params")
|
@Table(name = "li_goods_params")
|
||||||
@ -52,4 +57,11 @@ public class GoodsParams extends BaseEntity {
|
|||||||
@Length(max = 100, message = "参数值字符不能大于120")
|
@Length(max = 100, message = "参数值字符不能大于120")
|
||||||
private String paramValue;
|
private String paramValue;
|
||||||
|
|
||||||
|
@TableField(value = "is_index")
|
||||||
|
@ApiModelProperty(value = "是否可索引,0 不显示 1 显示", required = true)
|
||||||
|
@NotNull(message = "是否可索引必选")
|
||||||
|
@Min(value = 0, message = "是否可索引传值不正确")
|
||||||
|
@Max(value = 1, message = "是否可索引传值不正确")
|
||||||
|
private Integer isIndex = 0;
|
||||||
|
|
||||||
}
|
}
|
@ -2,11 +2,13 @@ package cn.lili.modules.goods.serviceimpl;
|
|||||||
|
|
||||||
import cn.lili.modules.goods.entity.dos.CategoryParameterGroup;
|
import cn.lili.modules.goods.entity.dos.CategoryParameterGroup;
|
||||||
import cn.lili.modules.goods.entity.dos.GoodsParams;
|
import cn.lili.modules.goods.entity.dos.GoodsParams;
|
||||||
|
import cn.lili.modules.goods.entity.dos.Parameters;
|
||||||
import cn.lili.modules.goods.entity.vos.GoodsParamsGroupVO;
|
import cn.lili.modules.goods.entity.vos.GoodsParamsGroupVO;
|
||||||
import cn.lili.modules.goods.entity.vos.GoodsParamsVO;
|
import cn.lili.modules.goods.entity.vos.GoodsParamsVO;
|
||||||
import cn.lili.modules.goods.mapper.GoodsParamsMapper;
|
import cn.lili.modules.goods.mapper.GoodsParamsMapper;
|
||||||
import cn.lili.modules.goods.service.CategoryParameterGroupService;
|
import cn.lili.modules.goods.service.CategoryParameterGroupService;
|
||||||
import cn.lili.modules.goods.service.GoodsParamsService;
|
import cn.lili.modules.goods.service.GoodsParamsService;
|
||||||
|
import cn.lili.modules.goods.service.ParametersService;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
@ -36,6 +38,9 @@ public class GoodsParamsServiceImpl extends ServiceImpl<GoodsParamsMapper, Goods
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CategoryParameterGroupService categoryParameterGroupService;
|
private CategoryParameterGroupService categoryParameterGroupService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ParametersService parametersService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addParams(List<GoodsParams> paramList, String goodsId) {
|
public void addParams(List<GoodsParams> paramList, String goodsId) {
|
||||||
//先删除现有商品参数
|
//先删除现有商品参数
|
||||||
@ -43,10 +48,12 @@ public class GoodsParamsServiceImpl extends ServiceImpl<GoodsParamsMapper, Goods
|
|||||||
//循环添加参数
|
//循环添加参数
|
||||||
if (paramList != null) {
|
if (paramList != null) {
|
||||||
for (GoodsParams param : paramList) {
|
for (GoodsParams param : paramList) {
|
||||||
|
Parameters parameters = parametersService.getById(param.getParamId());
|
||||||
GoodsParams goodsParams = new GoodsParams();
|
GoodsParams goodsParams = new GoodsParams();
|
||||||
goodsParams.setGoodsId(goodsId);
|
goodsParams.setGoodsId(goodsId);
|
||||||
goodsParams.setParamName(param.getParamName());
|
goodsParams.setParamName(param.getParamName());
|
||||||
goodsParams.setParamValue(param.getParamValue());
|
goodsParams.setParamValue(param.getParamValue());
|
||||||
|
goodsParams.setIsIndex(parameters.getIsIndex());
|
||||||
goodsParams.setParamId(param.getId());
|
goodsParams.setParamId(param.getId());
|
||||||
this.save(goodsParams);
|
this.save(goodsParams);
|
||||||
}
|
}
|
||||||
|
@ -89,12 +89,11 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
|||||||
@Override
|
@Override
|
||||||
public void add(List<Map<String, Object>> skuList, Goods goods) {
|
public void add(List<Map<String, Object>> skuList, Goods goods) {
|
||||||
// 检查是否需要生成索引
|
// 检查是否需要生成索引
|
||||||
boolean needIndex = checkNeedIndex(goods);
|
|
||||||
List<GoodsSku> newSkuList;
|
List<GoodsSku> newSkuList;
|
||||||
// 如果有规格
|
// 如果有规格
|
||||||
if (skuList != null && !skuList.isEmpty()) {
|
if (skuList != null && !skuList.isEmpty()) {
|
||||||
// 添加商品sku
|
// 添加商品sku
|
||||||
newSkuList = this.addGoodsSku(skuList, goods, needIndex);
|
newSkuList = this.addGoodsSku(skuList, goods);
|
||||||
} else {
|
} else {
|
||||||
throw new ServiceException("规格必须要有一个!");
|
throw new ServiceException("规格必须要有一个!");
|
||||||
}
|
}
|
||||||
@ -103,23 +102,8 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
|||||||
generateEsCheck(goods);
|
generateEsCheck(goods);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkNeedIndex(Goods goods) {
|
|
||||||
if (goods.getParams() != null && !goods.getParams().isEmpty()) {
|
|
||||||
List<GoodsParams> goodsParams = JSONUtil.toList(goods.getParams(), GoodsParams.class);
|
|
||||||
for (GoodsParams goodsParam : goodsParams) {
|
|
||||||
Parameters parameters = parametersService.getById(goodsParam.getParamId());
|
|
||||||
if (parameters.getIsIndex() == 1) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(List<Map<String, Object>> skuList, Goods goods, Boolean regeneratorSkuFlag) {
|
public void update(List<Map<String, Object>> skuList, Goods goods, Boolean regeneratorSkuFlag) {
|
||||||
// 检查是否需要生成索引
|
|
||||||
boolean needIndex = checkNeedIndex(goods);
|
|
||||||
// 是否存在规格
|
// 是否存在规格
|
||||||
if (skuList == null || skuList.isEmpty()) {
|
if (skuList == null || skuList.isEmpty()) {
|
||||||
throw new ServiceException("规格必须要有一个!");
|
throw new ServiceException("规格必须要有一个!");
|
||||||
@ -139,7 +123,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
|||||||
//删除sku相册
|
//删除sku相册
|
||||||
goodsGalleryService.removeByIds(oldSkuIds);
|
goodsGalleryService.removeByIds(oldSkuIds);
|
||||||
// 添加商品sku
|
// 添加商品sku
|
||||||
newSkuList = this.addGoodsSku(skuList, goods, needIndex);
|
newSkuList = this.addGoodsSku(skuList, goods);
|
||||||
|
|
||||||
//发送mq消息
|
//发送mq消息
|
||||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.SKU_DELETE.name();
|
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.SKU_DELETE.name();
|
||||||
@ -161,9 +145,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
|||||||
this.updateBatchById(newSkuList);
|
this.updateBatchById(newSkuList);
|
||||||
}
|
}
|
||||||
this.updateStock(newSkuList);
|
this.updateStock(newSkuList);
|
||||||
if (Boolean.TRUE.equals(needIndex)) {
|
generateEsCheck(goods);
|
||||||
generateEsCheck(goods);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -206,9 +188,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
|||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
GoodsSku goodsSku = this.getGoodsSkuByIdFromCache(skuId);
|
GoodsSku goodsSku = this.getGoodsSkuByIdFromCache(skuId);
|
||||||
|
|
||||||
|
GoodsVO goodsVO = goodsService.getGoodsVO(goodsId);
|
||||||
//如果规格为空则使用商品ID进行查询
|
//如果规格为空则使用商品ID进行查询
|
||||||
if (goodsSku == null) {
|
if (goodsSku == null) {
|
||||||
GoodsVO goodsVO = goodsService.getGoodsVO(goodsId);
|
|
||||||
skuId = goodsVO.getSkuList().get(0).getId();
|
skuId = goodsVO.getSkuList().get(0).getId();
|
||||||
goodsSku = this.getGoodsSkuByIdFromCache(skuId);
|
goodsSku = this.getGoodsSkuByIdFromCache(skuId);
|
||||||
//如果使用商品ID无法查询SKU则返回错误
|
//如果使用商品ID无法查询SKU则返回错误
|
||||||
@ -219,8 +201,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
|||||||
// 获取当前商品的索引信息
|
// 获取当前商品的索引信息
|
||||||
EsGoodsIndex goodsIndex = goodsIndexService.findById(skuId);
|
EsGoodsIndex goodsIndex = goodsIndexService.findById(skuId);
|
||||||
if (goodsIndex == null) {
|
if (goodsIndex == null) {
|
||||||
goodsIndex = new EsGoodsIndex(goodsSku);
|
goodsIndex = goodsIndexService.resetEsGoodsIndex(goodsSku, goodsVO.getGoodsParamsList());
|
||||||
goodsIndex.setPromotionMap(promotionService.getGoodsCurrentPromotionMap(goodsIndex));
|
|
||||||
}
|
}
|
||||||
//商品规格
|
//商品规格
|
||||||
GoodsSkuVO goodsSkuDetail = this.getGoodsSkuVO(goodsSku);
|
GoodsSkuVO goodsSkuDetail = this.getGoodsSkuVO(goodsSku);
|
||||||
@ -456,6 +437,10 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
|||||||
for (GoodsSku goodsSku : goodsSkuList) {
|
for (GoodsSku goodsSku : goodsSkuList) {
|
||||||
EsGoodsIndex esGoodsOld = goodsIndexService.findById(goodsSku.getId());
|
EsGoodsIndex esGoodsOld = goodsIndexService.findById(goodsSku.getId());
|
||||||
EsGoodsIndex goodsIndex = new EsGoodsIndex(goodsSku);
|
EsGoodsIndex goodsIndex = new EsGoodsIndex(goodsSku);
|
||||||
|
if (goods.getParams() != null && !goods.getParams().isEmpty()) {
|
||||||
|
List<GoodsParams> goodsParams = JSONUtil.toList(goods.getParams(), GoodsParams.class);
|
||||||
|
goodsIndex = new EsGoodsIndex(goodsSku, goodsParams);
|
||||||
|
}
|
||||||
//如果商品库存不为0,并且es中有数据
|
//如果商品库存不为0,并且es中有数据
|
||||||
if (goodsSku.getQuantity() > 0 && esGoodsOld == null) {
|
if (goodsSku.getQuantity() > 0 && esGoodsOld == null) {
|
||||||
goodsIndexService.addIndex(goodsIndex);
|
goodsIndexService.addIndex(goodsIndex);
|
||||||
@ -501,7 +486,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
|||||||
* @param skuList sku列表
|
* @param skuList sku列表
|
||||||
* @param goods 商品信息
|
* @param goods 商品信息
|
||||||
*/
|
*/
|
||||||
private List<GoodsSku> addGoodsSku(List<Map<String, Object>> skuList, Goods goods, Boolean needIndex) {
|
private List<GoodsSku> addGoodsSku(List<Map<String, Object>> skuList, Goods goods) {
|
||||||
List<GoodsSku> skus = new ArrayList<>();
|
List<GoodsSku> skus = new ArrayList<>();
|
||||||
List<EsGoodsIndex> goodsIndices = new ArrayList<>();
|
List<EsGoodsIndex> goodsIndices = new ArrayList<>();
|
||||||
for (Map<String, Object> skuVO : skuList) {
|
for (Map<String, Object> skuVO : skuList) {
|
||||||
@ -517,11 +502,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
|||||||
stringRedisTemplate.opsForValue().set(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity().toString());
|
stringRedisTemplate.opsForValue().set(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity().toString());
|
||||||
}
|
}
|
||||||
this.saveBatch(skus);
|
this.saveBatch(skus);
|
||||||
if (Boolean.TRUE.equals(needIndex)) {
|
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GENERATOR_GOODS_INDEX.name();
|
||||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GENERATOR_GOODS_INDEX.name();
|
//发送mq消息
|
||||||
//发送mq消息
|
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(goodsIndices), RocketmqSendCallbackBuilder.commonCallback());
|
||||||
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(goodsIndices), RocketmqSendCallbackBuilder.commonCallback());
|
|
||||||
}
|
|
||||||
return skus;
|
return skus;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package cn.lili.modules.search.entity.dos;
|
package cn.lili.modules.search.entity.dos;
|
||||||
|
|
||||||
|
import cn.hutool.core.text.CharSequenceUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import cn.lili.common.elasticsearch.EsSuffix;
|
import cn.lili.common.elasticsearch.EsSuffix;
|
||||||
import cn.lili.common.utils.StringUtils;
|
import cn.lili.common.utils.StringUtils;
|
||||||
|
import cn.lili.modules.goods.entity.dos.GoodsParams;
|
||||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
@ -275,22 +277,38 @@ public class EsGoodsIndex implements Serializable {
|
|||||||
this.intro = sku.getIntro();
|
this.intro = sku.getIntro();
|
||||||
this.grade = sku.getGrade();
|
this.grade = sku.getGrade();
|
||||||
this.releaseTime = new Date();
|
this.releaseTime = new Date();
|
||||||
if (StringUtils.isNotEmpty(sku.getSpecs())) {
|
// if (CharSequenceUtil.isNotEmpty(sku.getSpecs())) {
|
||||||
List<EsGoodsAttribute> attributes = new ArrayList<>();
|
// List<EsGoodsAttribute> attributes = new ArrayList<>();
|
||||||
JSONObject jsonObject = JSONUtil.parseObj(sku.getSpecs());
|
// JSONObject jsonObject = JSONUtil.parseObj(sku.getSpecs());
|
||||||
for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
|
// for (Map.Entry<String, Object> entry : jsonObject.entrySet()) {
|
||||||
if (!entry.getKey().equals("images")) {
|
// if (!entry.getKey().equals("images")) {
|
||||||
EsGoodsAttribute attribute = new EsGoodsAttribute();
|
// EsGoodsAttribute attribute = new EsGoodsAttribute();
|
||||||
attribute.setType(0);
|
// attribute.setType(1);
|
||||||
attribute.setName(entry.getKey());
|
// attribute.setName(entry.getKey());
|
||||||
attribute.setValue(entry.getValue().toString());
|
// attribute.setValue(entry.getValue().toString());
|
||||||
attributes.add(attribute);
|
// attributes.add(attribute);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
this.attrList = attributes;
|
// this.attrList = attributes;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public EsGoodsIndex(GoodsSku sku, List<GoodsParams> goodsParams) {
|
||||||
|
this(sku);
|
||||||
|
if (goodsParams != null && !goodsParams.isEmpty()) {
|
||||||
|
List<EsGoodsAttribute> attributes = new ArrayList<>();
|
||||||
|
for (GoodsParams goodsParam : goodsParams) {
|
||||||
|
EsGoodsAttribute attribute = new EsGoodsAttribute();
|
||||||
|
if (goodsParam.getIsIndex() == 1) {
|
||||||
|
attribute.setType(1);
|
||||||
|
attribute.setName(goodsParam.getParamName());
|
||||||
|
attribute.setValue(goodsParam.getParamValue());
|
||||||
|
attributes.add(attribute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.attrList = attributes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGoodsSku(GoodsSku sku) {
|
public void setGoodsSku(GoodsSku sku) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.lili.modules.search.service;
|
package cn.lili.modules.search.service;
|
||||||
|
|
||||||
|
import cn.lili.modules.goods.entity.dos.GoodsParams;
|
||||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||||
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
|
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
|
||||||
import cn.lili.modules.promotion.entity.dto.BasePromotion;
|
import cn.lili.modules.promotion.entity.dto.BasePromotion;
|
||||||
@ -145,7 +146,8 @@ public interface EsGoodsIndexService {
|
|||||||
* 重置当前商品索引
|
* 重置当前商品索引
|
||||||
*
|
*
|
||||||
* @param goodsSku 商品sku信息
|
* @param goodsSku 商品sku信息
|
||||||
|
* @param goodsParams 商品参数
|
||||||
* @return 商品索引
|
* @return 商品索引
|
||||||
*/
|
*/
|
||||||
EsGoodsIndex resetEsGoodsIndex(GoodsSku goodsSku);
|
EsGoodsIndex resetEsGoodsIndex(GoodsSku goodsSku, List<GoodsParams> goodsParams);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import cn.hutool.extra.pinyin.PinyinUtil;
|
|||||||
import cn.lili.common.elasticsearch.BaseElasticsearchService;
|
import cn.lili.common.elasticsearch.BaseElasticsearchService;
|
||||||
import cn.lili.common.elasticsearch.EsSuffix;
|
import cn.lili.common.elasticsearch.EsSuffix;
|
||||||
import cn.lili.config.elasticsearch.ElasticsearchProperties;
|
import cn.lili.config.elasticsearch.ElasticsearchProperties;
|
||||||
|
import cn.lili.modules.goods.entity.dos.GoodsParams;
|
||||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||||
import cn.lili.modules.goods.entity.dos.GoodsWords;
|
import cn.lili.modules.goods.entity.dos.GoodsWords;
|
||||||
import cn.lili.modules.goods.entity.enums.GoodsWordsTypeEnum;
|
import cn.lili.modules.goods.entity.enums.GoodsWordsTypeEnum;
|
||||||
@ -367,11 +368,12 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
|||||||
* 重置当前商品索引
|
* 重置当前商品索引
|
||||||
*
|
*
|
||||||
* @param goodsSku 商品sku信息
|
* @param goodsSku 商品sku信息
|
||||||
|
* @param goodsParams 商品参数
|
||||||
* @return 商品索引
|
* @return 商品索引
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public EsGoodsIndex resetEsGoodsIndex(GoodsSku goodsSku) {
|
public EsGoodsIndex resetEsGoodsIndex(GoodsSku goodsSku, List<GoodsParams> goodsParams) {
|
||||||
EsGoodsIndex index = new EsGoodsIndex(goodsSku);
|
EsGoodsIndex index = new EsGoodsIndex(goodsSku, goodsParams);
|
||||||
//获取活动信息
|
//获取活动信息
|
||||||
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsCurrentPromotionMap(index);
|
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsCurrentPromotionMap(index);
|
||||||
//写入促销信息
|
//写入促销信息
|
||||||
|
@ -68,23 +68,14 @@ public class ElasticsearchController {
|
|||||||
String goodsId = null;
|
String goodsId = null;
|
||||||
//库存锁是在redis做的,所以生成索引,同时更新一下redis中的库存数量
|
//库存锁是在redis做的,所以生成索引,同时更新一下redis中的库存数量
|
||||||
for (GoodsSku goodsSku : list) {
|
for (GoodsSku goodsSku : list) {
|
||||||
boolean needIndex = false;
|
|
||||||
if (goodsId == null || !goodsId.equals(goodsSku.getGoodsId())) {
|
if (goodsId == null || !goodsId.equals(goodsSku.getGoodsId())) {
|
||||||
goodsId = goodsSku.getGoodsId();
|
goodsId = goodsSku.getGoodsId();
|
||||||
Goods goods = goodsService.getById(goodsId);
|
Goods goods = goodsService.getById(goodsId);
|
||||||
|
EsGoodsIndex index = new EsGoodsIndex(goodsSku);
|
||||||
if (goods.getParams() != null && !goods.getParams().isEmpty()) {
|
if (goods.getParams() != null && !goods.getParams().isEmpty()) {
|
||||||
List<GoodsParams> goodsParams = JSONUtil.toList(goods.getParams(), GoodsParams.class);
|
List<GoodsParams> goodsParams = JSONUtil.toList(goods.getParams(), GoodsParams.class);
|
||||||
for (GoodsParams goodsParam : goodsParams) {
|
index = new EsGoodsIndex(goodsSku, goodsParams);
|
||||||
Parameters parameters = parametersService.getById(goodsParam.getParamId());
|
|
||||||
if (parameters.getIsIndex() == 1) {
|
|
||||||
needIndex = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (Boolean.TRUE.equals(needIndex)) {
|
|
||||||
EsGoodsIndex index = new EsGoodsIndex(goodsSku);
|
|
||||||
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsCurrentPromotionMap(index);
|
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsCurrentPromotionMap(index);
|
||||||
index.setPromotionMap(goodsCurrentPromotionMap);
|
index.setPromotionMap(goodsCurrentPromotionMap);
|
||||||
esGoodsIndices.add(index);
|
esGoodsIndices.add(index);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user