commit message

This commit is contained in:
Chopper
2021-05-13 10:41:46 +08:00
commit 3785bdb3bb
1424 changed files with 100110 additions and 0 deletions

View File

@@ -0,0 +1,126 @@
package cn.lili.test.CacheTest;
import cn.lili.common.cache.Cache;
import cn.lili.common.cache.CachePrefix;
import cn.lili.modules.statistics.util.StatisticsSuffix;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.DefaultTypedTuple;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.Date;
import java.util.Random;
import java.util.Set;
/**
* @author Chopper
* @version v1.0
* @Description:
* @since v7.0
* 2021/1/15 16:25
*/
@RunWith(SpringRunner.class)
@SpringBootTest
class CacheTest {
@Autowired
private Cache cache;
String KEY = "test1";
/**
* 计数器测试
*
* @throws InterruptedException
*/
@Test
void testCache() throws InterruptedException {
System.out.println(cache.incr(KEY, 3));
System.out.println(cache.incr(KEY, 1));
System.out.println(cache.incr(KEY, 1));
Thread.sleep(2000);
System.out.println(cache.incr(KEY, 1));
Thread.sleep(1000);
System.out.println(cache.incr(KEY, 1));
Thread.sleep(10000);
System.out.println(cache.incr(KEY, 1));
}
/**
* 缓存中的流量统计数据模拟
*/
@Test
void pageViewInit() {
String storeUV = "{STORE_UV}_2021-4-12-1376369067769724928";
String storePV = "{STORE_PV}_2021-4-12-1376369067769724928";
String UV = "{UV}_2021-4-12";
String PV = "{PV}_2021-4-12";
Random random = new Random();
for (int i = 0; i < 1000; i++) {
//PV
cache.incr(PV, 60 * 60 * 48);
cache.incr(storePV, 60 * 60 * 48);
//店铺UV 统计则需要对id去重复所以如下处理
cache.cumulative(storeUV, "192.168.0.1" + random.nextInt(100));
//平台UV统计
cache.cumulative(UV, "192.168.0.1" + random.nextInt(100));
}
}
/**
* 流量单元测试
* <p>
* 模拟1000次请求发查看这块执行时间,单节点性能简单尝试同时还有redis连接池问题这个只是简单压力模拟
* <p>
* 执行结果
* 1.251
* 1.167
* 1.363
*/
@Test
void testPageViewStatistics() {
Date start = new Date();
System.out.println(start.getTime());
for (int i = 0; i < 1000; i++) {
//PV 统计48小时过期 留下一定时间予以统计累计数据库
cache.incr(CachePrefix.PV.getPrefix() + StatisticsSuffix.suffix(i / 100 + ""), 60 * 60 * 48);
//店铺UV 统计则需要对id去重复所以如下处理
cache.cumulative(CachePrefix.UV.getPrefix() + StatisticsSuffix.suffix(i / 100 + "1321312312312312321312"), "192.168.0.1" + i);
//平台UV统计
cache.cumulative(CachePrefix.UV.getPrefix() + StatisticsSuffix.suffix(), "192.168.0.1" + i);
}
Date end = new Date();
System.out.println(end.getTime());
System.out.println(end.getTime() - start.getTime());
}
@Test
void testZincrby() {
cache.incrementScore("searchHotWord", "Chrome");
Assertions.assertTrue(true);
}
@Test
void testReverseRangeWithScores() {
Set searchHotWord = cache.reverseRangeWithScores("searchHotWord", 0, 100);
for (Object o : searchHotWord) {
DefaultTypedTuple str = (DefaultTypedTuple) o;
System.out.println(str.getScore());
System.out.println(str.getValue());
System.out.println("----------");
}
Assertions.assertTrue(true);
}
}

View File

@@ -0,0 +1,258 @@
package cn.lili.test.elasticsearch;
import cn.hutool.json.JSONUtil;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.goods.entity.dos.GoodsSku;
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
import cn.lili.modules.goods.service.GoodsSkuService;
import cn.lili.modules.promotion.service.PromotionService;
import cn.lili.modules.search.entity.dos.EsGoodsAttribute;
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
import cn.lili.modules.search.entity.dos.EsGoodsRelatedInfo;
import cn.lili.modules.search.entity.dto.EsGoodsSearchDTO;
import cn.lili.modules.search.repository.EsGoodsIndexRepository;
import cn.lili.modules.search.service.EsGoodsIndexService;
import cn.lili.modules.search.service.EsGoodsSearchService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.domain.Page;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author paulG
* @since 2020/10/14
**/
@RunWith(SpringRunner.class)
@SpringBootTest
class EsTest {
@Autowired
private EsGoodsIndexService esGoodsIndexService;
@Autowired
private EsGoodsIndexRepository goodsIndexRepository;
@Autowired
private EsGoodsSearchService goodsSearchService;
@Autowired
private GoodsSkuService goodsSkuService;
@Autowired
private StringRedisTemplate stringRedisTemplate;
@Autowired
private PromotionService promotionService;
@Test
void searchGoods() {
EsGoodsSearchDTO goodsSearchDTO = new EsGoodsSearchDTO();
// goodsSearchDTO.setKeyword("黄");
goodsSearchDTO.setProp("IETF_HTTP/3");
// goodsSearchDTO.setPrice("100_20000");
// goodsSearchDTO.setStoreCatId(1L);
// goodsSearchDTO.setBrandId(123L);
// goodsSearchDTO.setCategoryId(2L);
// goodsSearchDTO.setNameIds(Arrays.asList("1344113311566553088", "1344113367694729216"));
PageVO pageVo = new PageVO();
pageVo.setPageNumber(0);
pageVo.setPageSize(100);
pageVo.setOrder("desc");
pageVo.setNotConvert(true);
Page<EsGoodsIndex> esGoodsIndices = goodsSearchService.searchGoods(goodsSearchDTO, pageVo);
Assertions.assertNotNull(esGoodsIndices);
esGoodsIndices.getContent().forEach(System.out::println);
// esGoodsIndices.getContent().forEach(i -> {
// if (i.getPromotionMap() != null){
// String s = i.getPromotionMap().keySet().parallelStream().filter(j -> j.contains(PromotionTypeEnum.FULL_DISCOUNT.name())).findFirst().orElse(null);
// if (s != null) {
// FullDiscount basePromotion = (FullDiscount) i.getPromotionMap().get(s);
// System.out.println(basePromotion);
// }
// }
// });
}
@Test
void aggregationSearch() {
EsGoodsSearchDTO goodsSearchDTO = new EsGoodsSearchDTO();
// goodsSearchDTO.setKeyword("电脑");
// goodsSearchDTO.setProp("颜色_故宫文创@版本_小新Pro13s");
// goodsSearchDTO.setCategoryId("2");
// goodsSearchDTO.setPrice("100_20000");
PageVO pageVo = new PageVO();
pageVo.setPageNumber(0);
pageVo.setPageSize(10);
pageVo.setOrder("desc");
EsGoodsRelatedInfo selector = goodsSearchService.getSelector(goodsSearchDTO, pageVo);
Assertions.assertNotNull(selector);
System.out.println(JSONUtil.toJsonStr(selector));
}
@Test
void init() {
LambdaQueryWrapper<GoodsSku> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(GoodsSku::getIsAuth, GoodsAuthEnum.PASS.name());
queryWrapper.eq(GoodsSku::getMarketEnable, GoodsStatusEnum.UPPER.name());
List<GoodsSku> list = goodsSkuService.list(queryWrapper);
List<EsGoodsIndex> esGoodsIndices = new ArrayList<>();
for (GoodsSku goodsSku : list) {
EsGoodsIndex index = new EsGoodsIndex(goodsSku);
Map<String, Object> goodsCurrentPromotionMap = promotionService.getGoodsCurrentPromotionMap(index);
index.setPromotionMap(goodsCurrentPromotionMap);
esGoodsIndices.add(index);
stringRedisTemplate.opsForValue().set(GoodsSkuService.getStockCacheKey(goodsSku.getId()), goodsSku.getQuantity().toString());
}
esGoodsIndexService.initIndex(esGoodsIndices);
Assertions.assertTrue(true);
}
@Test
void addIndex() {
List<EsGoodsAttribute> esGoodsAttributeList = new ArrayList<>();
EsGoodsAttribute attribute = new EsGoodsAttribute();
attribute.setType(0);
attribute.setName("颜色");
attribute.setValue("16.1英寸 6核R5 16G 512G 高色域");
esGoodsAttributeList.add(attribute);
attribute = new EsGoodsAttribute();
attribute.setType(0);
attribute.setName("版本");
attribute.setValue("RedmiBook 18英寸 深空灰");
esGoodsAttributeList.add(attribute);
EsGoodsIndex goodsIndex = initGoodsIndexData("122", "0|2", "140", "142", "A142", "RedmiBook 18 锐龙版 超轻薄全面屏(6核R5-4500U 16G 512G 100% sRGB高色域)灰 手提 笔记本电脑 小米 红米 ", "131", "小米自营旗舰店", 10000D);
goodsIndex.setAttrList(esGoodsAttributeList);
//GoodsSku goodsSkuByIdFromCache = goodsSkuService.getGoodsSkuByIdFromCache("121");
//EsGoodsIndex goodsIndex = new EsGoodsIndex(goodsSkuByIdFromCache);
esGoodsIndexService.addIndex(goodsIndex);
Assertions.assertTrue(true);
}
@Test
void searchAll() {
Iterable<EsGoodsIndex> all = goodsIndexRepository.findAll();
Assertions.assertNotNull(all);
all.forEach(System.out::println);
}
@Test
void updateIndex() {
// EsGoodsIndex goodsIndex = new EsGoodsIndex();
// goodsIndex.setId("121");
// goodsIndex.setBrandId("113");
// goodsIndex.setGoodsId("113");
// goodsIndex.setCategoryPath("0|1");
// goodsIndex.setBuyCount(100);
// goodsIndex.setCommentNum(100);
// goodsIndex.setGoodsName("惠普HP战66 三代AMD版14英寸轻薄笔记本电脑锐龙7nm 六核R5-4500U 16G 512G 400尼特高色域一年上门 ");
// 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(100);
// goodsIndex.setPrice(100D);
// goodsIndex.setSelfOperated(true);
// goodsIndex.setStoreId("113");
// goodsIndex.setStoreName("惠普自营官方旗舰店");
// goodsIndex.setStoreCategoryPath("1");
// goodsIndex.setThumbnail("picture");
// goodsIndex.setSn("A113");
// Map<String, BasePromotion> promotionMap = new HashMap<>();
// Coupon coupon = new Coupon();
// coupon.setStoreId("113");
// coupon.setStoreName("惠普自营官方旗舰店");
// coupon.setPromotionStatus(PromotionStatusEnum.START.name());
// coupon.setReceivedNum(0);
// coupon.setConsumeLimit(11D);
// coupon.setCouponLimitNum(10);
// coupon.setCouponName("满11减10");
// coupon.setCouponType(CouponTypeEnum.PRICE.name());
// coupon.setGetType(CouponGetEnum.FREE.name());
// coupon.setPrice(10D);
// promotionMap.put(PromotionTypeEnum.COUPON.name(), coupon);
// goodsIndex.setPromotionMap(promotionMap);
// List<EsGoodsAttribute> esGoodsAttributeList = new ArrayList<>();
// EsGoodsAttribute attribute = new EsGoodsAttribute();
// attribute.setType(0);
// attribute.setName("颜色");
// attribute.setValue("14英寸");
// esGoodsAttributeList.add(attribute);
// esGoodsAttributeList.add(attribute);
// attribute = new EsGoodsAttribute();
// attribute.setName("版本");
// attribute.setValue("【战66新品】R5-4500 8G 256G");
// esGoodsAttributeList.add(attribute);
// attribute = new EsGoodsAttribute();
// attribute.setName("配置");
// attribute.setValue("i5 8G 512G 2G独显");
// esGoodsAttributeList.add(attribute);
// goodsIndex.setAttrList(esGoodsAttributeList);
// GoodsSku goodsSkuByIdFromCache = goodsSkuService.getGoodsSkuByIdFromCache("121");
// EsGoodsIndex goodsIndex = new EsGoodsIndex(goodsSkuByIdFromCache);
EsGoodsIndex byId = esGoodsIndexService.findById("121");
byId.setPromotionMap(null);
esGoodsIndexService.updateIndex(byId);
Assertions.assertTrue(true);
}
@Test
void deleteIndex() {
esGoodsIndexService.deleteIndex(null);
Assertions.assertTrue(true);
}
@Test
void cleanPromotion() {
esGoodsIndexService.cleanInvalidPromotion();
Assertions.assertTrue(true);
}
private EsGoodsIndex initGoodsIndexData(String brandId, String categoryPath, String goodsId, String id, String sn, String goodsName, String storeId, String storeName, Double price) {
EsGoodsIndex goodsIndex = new EsGoodsIndex();
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");
goodsIndex.setId(id);
goodsIndex.setBrandId(brandId);
goodsIndex.setGoodsId(goodsId);
goodsIndex.setCategoryPath(categoryPath);
goodsIndex.setGoodsName(goodsName);
goodsIndex.setPrice(price);
goodsIndex.setSn(sn);
goodsIndex.setStoreId(storeId);
goodsIndex.setStoreName(storeName);
return goodsIndex;
}
}

View File

@@ -0,0 +1,33 @@
package cn.lili.test.order;
import cn.lili.modules.order.order.service.OrderService;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
/**
* @author paulG
* @since 2020/12/1
**/
@RunWith(SpringRunner.class)
@SpringBootTest
class OrderServiceTest {
@Autowired
private OrderService orderService;
@Test
void QueryParam() {
// OrderSearchParams orderSearchParams = new OrderSearchParams();
// orderSearchParams.setPageSize(0);
// orderSearchParams.setPageNumber(10);
// IPage<OrderSimpleVO> orderVOIPage = orderService.queryByParams(orderSearchParams);
// Assertions.assertNotNull(orderVOIPage);
// orderVOIPage.getRecords().forEach(System.out::println);
}
}

View File

@@ -0,0 +1,203 @@
package cn.lili.test.promotion;
import cn.lili.common.vo.PageVO;
import cn.lili.config.rocketmq.RocketmqCustomProperties;
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
import cn.lili.modules.goods.service.GoodsSkuService;
import cn.lili.modules.promotion.entity.dos.Coupon;
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
import cn.lili.modules.promotion.entity.enums.*;
import cn.lili.modules.promotion.entity.vos.CouponSearchParams;
import cn.lili.modules.promotion.entity.vos.CouponVO;
import cn.lili.modules.promotion.service.CouponService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.ArrayList;
import java.util.List;
/**
* @author paulG
* @since 2020/10/29
**/
@RunWith(SpringRunner.class)
@SpringBootTest
class CouponTest {
@Autowired
private CouponService couponService;
@Autowired
private GoodsSkuService goodsSkuService;
@Autowired
private RocketMQTemplate rocketMQTemplate;
@Autowired
private RocketmqCustomProperties rocketmqCustomProperties;
@Test
void addCoupon() {
CouponVO couponVO = new CouponVO();
couponVO.setCouponName("Coupon V" + couponVO.getId());
couponVO.setCouponType(CouponTypeEnum.DISCOUNT.name());
couponVO.setDescription(couponVO.getCouponName() + " are expensive");
couponVO.setGetType(CouponGetEnum.FREE.name());
couponVO.setPromotionStatus(PromotionStatusEnum.NEW.name());
// couponVO.setStoreId("0");
// couponVO.setStoreName("platform");
couponVO.setStoreId("131");
couponVO.setStoreName("小米自营旗舰店");
couponVO.setPublishNum(1000);
couponVO.setCouponLimitNum(0);
couponVO.setConsumeThreshold(500D);
// couponVO.setPrice(200D);
couponVO.setCouponDiscount(0.1D);
couponVO.setScopeType(CouponScopeTypeEnum.PORTION_GOODS.name());
couponVO.setScopeId("121");
couponVO.setStartTime(cn.hutool.core.date.DateUtil.parse("2020-11-30 15:58:00"));
couponVO.setEndTime(cn.hutool.core.date.DateUtil.parse("2020-12-30 23:50:00"));
if (couponVO.getCouponType().equals(CouponTypeEnum.DISCOUNT.name())) {
couponVO.setPromotionName(couponVO.getCouponDiscount() + "折券");
} else {
couponVO.setPromotionName(couponVO.getPrice() + "元券");
}
List<PromotionGoods> promotionGoodsList = new ArrayList<>();
// GoodsSku sku121 = goodsSkuService.getGoodsSkuByIdFromCache("121");
PromotionGoods promotionGoods = new PromotionGoods();
promotionGoods.setPrice(0.0);
promotionGoods.setLimitNum(0);
promotionGoods.setNum(1000);
promotionGoods.setStartTime(couponVO.getStartTime());
promotionGoods.setEndTime(couponVO.getEndTime());
promotionGoods.setTitle(couponVO.getPromotionName());
promotionGoods.setPromotionId(couponVO.getId());
promotionGoods.setQuantity(1000);
promotionGoods.setPromotionStatus(couponVO.getPromotionStatus());
promotionGoods.setPromotionType(PromotionTypeEnum.COUPON.name());
promotionGoodsList.add(promotionGoods);
//
// GoodsSku sku50112 = goodsSkuService.getGoodsSkuByIdFromCache("50112");
// promotionGoods = new PromotionGoods(sku50112);
// promotionGoods.setPrice(80000d);
// promotionGoods.setLimitNum(0);
// promotionGoods.setPromotionQuantity(1000);
// promotionGoods.setNum(1000);
// promotionGoods.setStartTime(couponVO.getStartTime());
// promotionGoods.setEndTime(couponVO.getEndTime());
// promotionGoods.setTitle(couponVO.getPromotionName());
// promotionGoods.setPromotionStatus(couponVO.getPromotionStatus());
// promotionGoodsList.add(promotionGoods);
//
couponVO.setPromotionGoodsList(promotionGoodsList);
Assertions.assertNotNull(couponService.add(couponVO));
}
@Test
void update() {
CouponVO couponVO = new CouponVO();
couponVO.setId("1326081397400297472");
couponVO.setCouponName("Coupon V" + couponVO.getId());
couponVO.setCouponType(CouponTypeEnum.DISCOUNT.name());
couponVO.setDescription(couponVO.getId() + " is expensive");
couponVO.setGetType(CouponGetEnum.FREE.name());
couponVO.setPromotionStatus(PromotionStatusEnum.START.name());
couponVO.setStoreId("132");
couponVO.setStoreName("联想自营旗舰店");
couponVO.setStoreCommission(99.99D);
couponVO.setPublishNum(1000);
couponVO.setCouponLimitNum(0);
couponVO.setCouponDiscount(10D);
couponVO.setPrice(0D);
couponVO.setScopeType(CouponScopeTypeEnum.PORTION_GOODS.name());
couponVO.setScopeId("134,133");
couponVO.setStartTime(cn.hutool.core.date.DateUtil.parse("2020-11-10 17:01:00"));
couponVO.setEndTime(cn.hutool.core.date.DateUtil.parse("2020-11-10 17:10:00"));
if (couponVO.getCouponType().equals(CouponTypeEnum.DISCOUNT.name())) {
couponVO.setPromotionName(couponVO.getCouponDiscount() + "折券");
} else {
couponVO.setPromotionName(couponVO.getPrice() + "元券");
}
List<PromotionGoods> promotionGoodsList = new ArrayList<>();
PromotionGoods promotionGoods = new PromotionGoods();
promotionGoods.setSkuId("134");
promotionGoods.setGoodsName("联想(Lenovo)YOGA S740商务办公本 英特尔酷睿i5 14英寸超轻薄笔记本电脑(i5 16G 512G 独显 雷电3 WiFi6)灰");
promotionGoods.setPrice(20000d);
promotionGoods.setStoreId("132");
promotionGoods.setStoreName("联想自营旗舰店");
promotionGoods.setLimitNum(0);
promotionGoods.setQuantity(1000);
promotionGoods.setThumbnail("thumbnail");
promotionGoods.setNum(1000);
promotionGoods.setStartTime(couponVO.getStartTime());
promotionGoods.setEndTime(couponVO.getEndTime());
promotionGoods.setTitle(couponVO.getPromotionName());
promotionGoods.setPromotionStatus(couponVO.getPromotionStatus());
promotionGoodsList.add(promotionGoods);
promotionGoods = new PromotionGoods();
promotionGoods.setSkuId("133");
promotionGoods.setGoodsName("联想(Lenovo)小新Pro13s“锦绣前程”故宫文创版13.3英寸轻薄笔记本电脑(I5 16G 512G 2.5K 100%sRGB)");
promotionGoods.setPrice(100000d);
promotionGoods.setStoreId("132");
promotionGoods.setStoreName("联想自营旗舰店");
promotionGoods.setLimitNum(0);
promotionGoods.setQuantity(1000);
promotionGoods.setThumbnail("thumbnail");
promotionGoods.setNum(1000);
promotionGoods.setStartTime(couponVO.getStartTime());
promotionGoods.setEndTime(couponVO.getEndTime());
promotionGoods.setTitle(couponVO.getPromotionName());
promotionGoods.setPromotionStatus(couponVO.getPromotionStatus());
promotionGoodsList.add(promotionGoods);
couponVO.setPromotionGoodsList(promotionGoodsList);
Assertions.assertNotNull(couponService.updateCoupon(couponVO));
}
@Test
void searchFromMongo() {
CouponSearchParams queryParam = new CouponSearchParams();
queryParam.setStoreId("");
PageVO pageVo = new PageVO();
pageVo.setPageNumber(0);
pageVo.setPageSize(10);
IPage<CouponVO> couponsByPageFromMongo = couponService.getCouponsByPageFromMongo(queryParam, pageVo);
Assertions.assertNotNull(couponsByPageFromMongo);
couponsByPageFromMongo.getRecords().forEach(System.out::println);
}
@Test
void searchFromMysql() {
CouponSearchParams queryParam = new CouponSearchParams();
PageVO pageVo = new PageVO();
pageVo.setPageNumber(0);
pageVo.setPageSize(10);
IPage<Coupon> coupons = couponService.getCouponsByPage(queryParam, pageVo);
Assertions.assertNotNull(coupons);
coupons.getRecords().forEach(System.out::println);
}
@Test
void delete() {
// Assertions.assertTrue(couponService.deleteCoupon("1326001296591577088"));
GoodsStatusEnum goodsStatusEnum = GoodsStatusEnum.DOWN;
System.out.println("name:: " + goodsStatusEnum.name());
System.out.println("description:: " + goodsStatusEnum.description());
Assertions.assertTrue(true);
}
}

View File

@@ -0,0 +1,138 @@
package cn.lili.test.promotion;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.json.JSONUtil;
import cn.lili.common.vo.PageVO;
import cn.lili.modules.goods.entity.dos.GoodsSku;
import cn.lili.modules.goods.service.GoodsSkuService;
import cn.lili.modules.promotion.entity.dos.FullDiscount;
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
import cn.lili.modules.promotion.entity.enums.PromotionStatusEnum;
import cn.lili.modules.promotion.entity.enums.PromotionTypeEnum;
import cn.lili.modules.promotion.entity.vos.FullDiscountSearchParams;
import cn.lili.modules.promotion.service.FullDiscountService;
import cn.lili.modules.order.cart.entity.vo.FullDiscountVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.ArrayList;
import java.util.List;
/**
* @author paulG
* @since 2020/10/22
**/
@RunWith(SpringRunner.class)
@SpringBootTest
class FullDiscountTest {
@Autowired
private FullDiscountService fullDiscountService;
@Autowired
private GoodsSkuService goodsSkuService;
@Test
void addFullDiscount() {
FullDiscountVO fullDiscountVO = new FullDiscountVO();
fullDiscountVO.setStoreId("131");
fullDiscountVO.setStoreName("小米自营旗舰店");
fullDiscountVO.setNumber(1);
fullDiscountVO.setDescription("full discount test " + RandomUtil.randomNumber());
fullDiscountVO.setIsFullMinus(true);
fullDiscountVO.setFullMoney(130D);
fullDiscountVO.setFullMinus(100D);
fullDiscountVO.setPromotionStatus(PromotionStatusEnum.NEW.name());
fullDiscountVO.setIsFreeFreight(true);
fullDiscountVO.setPromotionName("FullDiscount-" + fullDiscountVO.getId());
fullDiscountVO.setTitle("" + fullDiscountVO.getFullMoney() + "" + fullDiscountVO.getFullMinus());
fullDiscountVO.setStartTime(cn.hutool.core.date.DateUtil.parse("2020-11-30 10:35:00"));
fullDiscountVO.setEndTime(cn.hutool.core.date.DateUtil.parse("2020-12-25 23:20:00"));
List<PromotionGoods> promotionGoodsLis = new ArrayList<>();
GoodsSku sku121 = goodsSkuService.getGoodsSkuByIdFromCache("121");
PromotionGoods promotionGoods = new PromotionGoods(sku121);
promotionGoods.setPrice(sku121.getPrice());
promotionGoods.setLimitNum(100);
promotionGoods.setStartTime(fullDiscountVO.getStartTime());
promotionGoods.setEndTime(fullDiscountVO.getEndTime());
promotionGoods.setNum(10);
promotionGoods.setQuantity(100);
promotionGoods.setPromotionId(fullDiscountVO.getId());
promotionGoods.setPromotionStatus(PromotionStatusEnum.NEW.name());
promotionGoods.setPromotionType(PromotionTypeEnum.FULL_DISCOUNT.name());
promotionGoods.setTitle("" + fullDiscountVO.getFullMoney() + "" + fullDiscountVO.getFullMinus());
promotionGoodsLis.add(promotionGoods);
fullDiscountVO.setPromotionGoodsList(promotionGoodsLis);
Assertions.assertNotNull(fullDiscountService.addFullDiscount(fullDiscountVO));
}
@Test
void searchFromMongo() {
PageVO pageVo = new PageVO();
pageVo.setPageSize(10);
pageVo.setPageNumber(0);
pageVo.setNotConvert(true);
pageVo.setSort("startTime");
pageVo.setOrder("asc");
IPage<FullDiscountVO> fullDiscountByPageFromMongo = fullDiscountService.getFullDiscountByPageFromMongo(new FullDiscountSearchParams(), null);
Assertions.assertNotNull(fullDiscountByPageFromMongo);
FullDiscount fullDiscount = JSONUtil.toBean(JSONUtil.parseObj(fullDiscountByPageFromMongo.getPages()), FullDiscount.class);
System.out.println(fullDiscount);
// fullDiscountByPageFromMongo.forEach(System.out::println);
}
@Test
void update() {
FullDiscountVO fullDiscountVO = new FullDiscountVO();
fullDiscountVO.setId("1325981729404248064");
fullDiscountVO.setStoreId("132");
fullDiscountVO.setStoreName("联想自营旗舰店");
fullDiscountVO.setNumber(1);
fullDiscountVO.setDescription("Not worth");
fullDiscountVO.setIsFullMinus(true);
fullDiscountVO.setFullMoney(100D);
fullDiscountVO.setFullMinus(80D);
fullDiscountVO.setPromotionStatus(PromotionStatusEnum.NEW.name());
fullDiscountVO.setIsFreeFreight(true);
fullDiscountVO.setPromotionName("FullDiscount-" + fullDiscountVO.getId());
fullDiscountVO.setTitle("" + fullDiscountVO.getFullMoney() + "" + fullDiscountVO.getFullMinus());
fullDiscountVO.setStartTime(cn.hutool.core.date.DateUtil.parse("2020-11-10 10:15:00"));
fullDiscountVO.setEndTime(cn.hutool.core.date.DateUtil.parse("2020-11-10 10:30:00"));
List<PromotionGoods> promotionGoodsLis = new ArrayList<>();
PromotionGoods promotionGoods = new PromotionGoods();
promotionGoods.setSkuId("134");
promotionGoods.setPromotionStatus(PromotionStatusEnum.NEW.name());
promotionGoods.setPrice(18000D);
promotionGoods.setStartTime(fullDiscountVO.getStartTime());
promotionGoods.setEndTime(fullDiscountVO.getEndTime());
promotionGoods.setNum(1);
promotionGoods.setQuantity(100);
promotionGoods.setPromotionType(PromotionTypeEnum.FULL_DISCOUNT.name());
promotionGoods.setTitle("" + fullDiscountVO.getFullMoney() + "" + fullDiscountVO.getFullMinus());
promotionGoods.setLimitNum(100);
promotionGoods.setPromotionId("200");
promotionGoods.setStoreId("132");
promotionGoodsLis.add(promotionGoods);
fullDiscountVO.setPromotionGoodsList(promotionGoodsLis);
Assertions.assertNotNull(fullDiscountService.modifyFullDiscount(fullDiscountVO));
}
@Test
void delete() {
Assertions.assertTrue(fullDiscountService.deleteFullDiscount("1325995092947525632"));
}
}

View File

@@ -0,0 +1,60 @@
package cn.lili.test.promotion;
import cn.hutool.json.JSONUtil;
import cn.lili.common.utils.ResultUtil;
import cn.lili.common.vo.PageVO;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.promotion.entity.dto.BasePromotion;
import cn.lili.modules.promotion.entity.dto.PromotionGoodsDTO;
import cn.lili.modules.promotion.entity.enums.PromotionTypeEnum;
import cn.lili.modules.promotion.service.PromotionPriceService;
import cn.lili.modules.promotion.service.PromotionService;
import cn.lili.modules.promotion.service.PromotionGoodsService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.Map;
/**
* @author paulG
* @since 2020/11/23
**/
@RunWith(SpringRunner.class)
@SpringBootTest
class PromotionPriceTest {
@Autowired
private PromotionPriceService promotionPriceService;
@Autowired
private PromotionService promotionService;
@Autowired
private PromotionGoodsService promotionGoodsServiceService;
@Test
void testSeckillPrice() {
Map<String, Object> currentPromotion = promotionService.getCurrentPromotion();
for (Map.Entry<String, Object> entry : currentPromotion.entrySet()) {
BasePromotion promotion = (BasePromotion) entry.getValue();
System.out.println(entry.getKey() + "-" + promotion.getId());
}
Assertions.assertTrue(true);
}
@Test
void testSeckillPrice1() {
IPage<PromotionGoodsDTO> promotionGoods = promotionGoodsServiceService.getCurrentPromotionGoods(PromotionTypeEnum.FULL_DISCOUNT.name(), new PageVO());
ResultMessage<IPage<PromotionGoodsDTO>> data = ResultUtil.data(promotionGoods);
String s = JSONUtil.toJsonStr(data);
System.out.println(s);
Assertions.assertTrue(true);
}
}

View File

@@ -0,0 +1,93 @@
package cn.lili.test.promotion;
import cn.hutool.core.date.DateUtil;
import cn.lili.modules.promotion.entity.enums.PromotionApplyStatusEnum;
import cn.lili.modules.promotion.entity.enums.PromotionStatusEnum;
import cn.lili.modules.promotion.entity.enums.SeckillApplyStatusEnum;
import cn.lili.modules.promotion.entity.vos.SeckillApplyVO;
import cn.lili.modules.promotion.entity.vos.SeckillVO;
import cn.lili.modules.promotion.service.SeckillApplyService;
import cn.lili.modules.promotion.service.SeckillService;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.util.ArrayList;
import java.util.List;
/**
* @author paulG
* @since 2020/10/29
**/
@RunWith(SpringRunner.class)
@SpringBootTest
class SeckillTest {
@Autowired
private SeckillService seckillService;
@Autowired
private SeckillApplyService seckillApplyService;
@Test
void add() {
SeckillVO seckillVO = new SeckillVO();
seckillVO.setId("123456");
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.setPromotionName("Seckill" + seckillVO.getId());
seckillVO.setSeckillRule("rule" + seckillVO.getId());
seckillVO.setStoreId("0");
seckillVO.setStoreName("platform");
Assertions.assertTrue(seckillService.saveSeckill(seckillVO));
}
@Test
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.setPromotionApplyStatus(PromotionApplyStatusEnum.APPLY.name());
seckillApplyVO.setQuantity(100);
seckillApplyVO.setSalesNum(0);
seckillApplyVO.setSeckillId("123456");
seckillApplyVO.setStoreId("501");
seckillApplyVO.setStoreName("Apple产品自营旗舰店");
seckillApplyVO.setTimeLine(17);
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.setPromotionApplyStatus(PromotionApplyStatusEnum.APPLY.name());
seckillApplyVO.setQuantity(100);
seckillApplyVO.setSalesNum(0);
seckillApplyVO.setSeckillId("123456");
seckillApplyVO.setStoreId("131");
seckillApplyVO.setStoreName("小米自营旗舰店");
seckillApplyVO.setTimeLine(16);
seckillApplyVOS.add(seckillApplyVO);
seckillApplyService.addSeckillApply("123456", "501", seckillApplyVOS);
Assertions.assertTrue(true);
}
@Test
void audit() {
seckillApplyService.auditBatchApply(new String[]{"1327169604003061760"}, "123456", PromotionApplyStatusEnum.PASS.name(), "");
Assertions.assertTrue(true);
}
}

View File

@@ -0,0 +1,39 @@
package cn.lili.test.rocketmq;
import cn.lili.common.rocketmq.RocketmqSendCallbackBuilder;
import cn.lili.common.rocketmq.tags.MqOrderTagsEnum;
import cn.lili.config.rocketmq.RocketmqCustomProperties;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.test.context.junit4.SpringRunner;
/**
* @author paulG
* @since 2021/1/15
**/
@RunWith(SpringRunner.class)
@SpringBootTest
class MsgExtRocketMqTest {
@Autowired
private RocketMQTemplate rocketMQTemplate;
@Autowired
private RocketmqCustomProperties rocketmqCustomProperties;
@Test
void searchAll() {
String destination = rocketmqCustomProperties.getOrderTopic() + ":" + MqOrderTagsEnum.STATUS_CHANGE.name();
Message<String> message = MessageBuilder.withPayload("Context").build();
rocketMQTemplate.asyncSend(destination, message, RocketmqSendCallbackBuilder.commonCallback());
rocketMQTemplate.send(destination, message);
Assertions.assertTrue(true);
}
}