improve esGoods parameter selector buckets(not get category and brand from db, add EsGoodsIndex Field BrandName,BrandUrl,CategoryNamePath)

This commit is contained in:
paulGao
2021-09-07 01:55:58 +08:00
parent 8f10b6b2a6
commit 4063c8b063
19 changed files with 650 additions and 195 deletions

View File

@@ -1,5 +1,6 @@
package cn.lili.test.elasticsearch;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.json.JSONUtil;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.goods.entity.dos.GoodsSku;
@@ -20,12 +21,13 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Page;
import org.springframework.data.elasticsearch.core.SearchPage;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -56,6 +58,50 @@ class EsTest {
private PromotionService promotionService;
public static void main(String[] args) {
EsGoodsIndex goodsIndex = new EsGoodsIndex();
goodsIndex.setGoodsName("1111");
goodsIndex.setBuyCount(99);
goodsIndex.setCommentNum(99);
goodsIndex.setGrade(100D);
goodsIndex.setHighPraiseNum(100);
goodsIndex.setIntro("I'd like a cup of tea, please");
goodsIndex.setIsAuth("1");
goodsIndex.setMarketEnable("1");
goodsIndex.setMobileIntro("I want something cold to drink");
goodsIndex.setPoint(0);
goodsIndex.setSelfOperated(true);
goodsIndex.setThumbnail("picture");
goodsIndex.setStoreCategoryPath("1");
String ignoreField = "serialVersionUID,promotionMap,id,goodsId";
List<EsGoodsIndex> goodsIndices = new ArrayList<>();
Map<String, Field> fieldMap = ReflectUtil.getFieldMap(EsGoodsIndex.class);
for (int i = 0; i < 10; i++) {
EsGoodsIndex a = new EsGoodsIndex();
for (Map.Entry<String, Field> entry : fieldMap.entrySet()) {
Object fieldValue = ReflectUtil.getFieldValue(goodsIndex, entry.getValue());
if (fieldValue != null && !ignoreField.contains(entry.getKey())) {
ReflectUtil.setFieldValue(a, entry.getValue(), fieldValue);
}
}
goodsIndices.add(a);
}
;
// BeanUtil.copyProperties(goodsIndex, a);
System.out.println(cn.hutool.core.date.DateUtil.endOfDay(new Date()));
// ReflectUtil.getFieldValue(goodsIndex, )
// for (Object o : ReflectUtil.getFieldsValue(goodsIndex)) {
// if (o != null) {
// System.out.println(o);
// }
// }
}
@Test
void searchGoods() {
EsGoodsSearchDTO goodsSearchDTO = new EsGoodsSearchDTO();

View File

@@ -35,18 +35,19 @@ class SeckillTest {
@Test
void add() {
SeckillVO seckillVO = new SeckillVO();
seckillVO.setId("123456");
seckillVO.setId("10000");
seckillVO.setStoreIds("132");
seckillVO.setSeckillApplyStatus(SeckillApplyStatusEnum.NOT_APPLY.name());
seckillVO.setPromotionStatus(PromotionStatusEnum.NEW.name());
seckillVO.setApplyEndTime(DateUtil.parse("2020-11-13 23:50:00"));
seckillVO.setStartTime(DateUtil.parse("2020-11-14 12:00:00"));
seckillVO.setEndTime(DateUtil.parse("2020-11-14 18:00:00"));
seckillVO.setHours("13,14,15,16,17");
seckillVO.setApplyEndTime(DateUtil.parse("2021-09-06 14:20:00"));
seckillVO.setStartTime(DateUtil.parse("2021-09-06 14:22:00"));
seckillVO.setEndTime(DateUtil.parse("2021-09-06 23:59:00"));
seckillVO.setHours("15,17,19");
seckillVO.setPromotionName("Seckill" + seckillVO.getId());
seckillVO.setSeckillRule("rule" + seckillVO.getId());
seckillVO.setStoreId("0");
seckillVO.setStoreId("1376433565247471616");
seckillVO.setStoreName("platform");
Assertions.assertTrue(seckillService.saveSeckill(seckillVO));
}
@@ -54,32 +55,32 @@ class SeckillTest {
void addApply() {
List<SeckillApplyVO> seckillApplyVOS = new ArrayList<>();
SeckillApplyVO seckillApplyVO = new SeckillApplyVO();
seckillApplyVO.setGoodsName("Apple MacBook Pro 13.3 新款八核M1芯片 8G 256G SSD 深空灰 笔记本电脑 轻薄本 MYD82CH/A");
seckillApplyVO.setSkuId("50111");
seckillApplyVO.setOriginalPrice(20000D);
seckillApplyVO.setPrice(19000D);
seckillApplyVO.setGoodsName("Apple iPhone 12");
seckillApplyVO.setSkuId("1387977574860193792");
seckillApplyVO.setOriginalPrice(4000D);
seckillApplyVO.setPrice(3600D);
seckillApplyVO.setPromotionApplyStatus(PromotionApplyStatusEnum.APPLY.name());
seckillApplyVO.setQuantity(100);
seckillApplyVO.setQuantity(1);
seckillApplyVO.setSalesNum(0);
seckillApplyVO.setSeckillId("123456");
seckillApplyVO.setStoreId("501");
seckillApplyVO.setStoreName("Apple产品自营旗舰");
seckillApplyVO.setTimeLine(17);
seckillApplyVO.setSeckillId("10000");
seckillApplyVO.setStoreId("1376369067769724928");
seckillApplyVO.setStoreName("Lilishop自营");
seckillApplyVO.setTimeLine(15);
seckillApplyVOS.add(seckillApplyVO);
seckillApplyVO = new SeckillApplyVO();
seckillApplyVO.setGoodsName("RedmiBook 16 锐龙版 超轻薄全面屏(6核R5-4500U 16G 512G 100% sRGB高色域)灰 手提 笔记本电脑 小米 红米");
seckillApplyVO.setSkuId("141");
seckillApplyVO.setOriginalPrice(10000D);
seckillApplyVO.setPrice(9000D);
seckillApplyVO.setGoodsName("Apple iPhone 12");
seckillApplyVO.setSkuId("1387977574864388096");
seckillApplyVO.setOriginalPrice(4000D);
seckillApplyVO.setPrice(3600D);
seckillApplyVO.setPromotionApplyStatus(PromotionApplyStatusEnum.APPLY.name());
seckillApplyVO.setQuantity(100);
seckillApplyVO.setQuantity(1);
seckillApplyVO.setSalesNum(0);
seckillApplyVO.setSeckillId("123456");
seckillApplyVO.setStoreId("131");
seckillApplyVO.setStoreName("小米自营旗舰");
seckillApplyVO.setTimeLine(16);
seckillApplyVO.setSeckillId("10000");
seckillApplyVO.setStoreId("1376369067769724928");
seckillApplyVO.setStoreName("Lilishop自营");
seckillApplyVO.setTimeLine(15);
seckillApplyVOS.add(seckillApplyVO);
seckillApplyService.addSeckillApply("123456", "501", seckillApplyVOS);
seckillApplyService.addSeckillApply("10000", "1376369067769724928", seckillApplyVOS);
Assertions.assertTrue(true);
}