@Override
    @Transactional(rollbackFor = Exception.class)
    public Long createDiscountActivity(DiscountActivityCreateReqVO createReqVO) {
        // 校验商品是否冲突
        validateDiscountActivityProductConflicts(null, createReqVO.getProducts());

        // 插入活动
        DiscountActivityDO discountActivity = DiscountActivityConvert.INSTANCE.convert(createReqVO)
                .setStatus(CommonStatusEnum.ENABLE.getStatus());
        discountActivityMapper.insert(discountActivity);
        // 插入商品
        List<DiscountProductDO> discountProducts = BeanUtils.toBean(createReqVO.getProducts(), DiscountProductDO.class,
                product -> product.setActivityId(discountActivity.getId()).setActivityStatus(discountActivity.getStatus())
                        .setActivityStartTime(createReqVO.getStartTime()).setActivityEndTime(createReqVO.getEndTime()));
        discountProductMapper.insertBatch(discountProducts);
        // 返回
        return discountActivity.getId();
    }
@Test
    public void testCreateDiscountActivity_success() {
        // 准备参数
        DiscountActivityCreateReqVO reqVO = randomPojo(DiscountActivityCreateReqVO.class, o -> {
            // 用于触发进行中的状态
            o.setStartTime(addTime(Duration.ofDays(1))).setEndTime(addTime(Duration.ofDays(2)));
            // 设置商品
            o.setProducts(asList(new DiscountActivityBaseVO.Product().setSpuId(1L).setSkuId(2L)
                            .setDiscountType(PromotionDiscountTypeEnum.PRICE.getType()).setDiscountPrice(3),
                    new DiscountActivityBaseVO.Product().setSpuId(10L).setSkuId(20L)
                            .setDiscountType(PromotionDiscountTypeEnum.PERCENT.getType()).setDiscountPercent(30)));
        });

        // 调用
        Long discountActivityId = discountActivityService.createDiscountActivity(reqVO);
        // 断言
        assertNotNull(discountActivityId);
        // 校验活动
        DiscountActivityDO discountActivity = discountActivityMapper.selectById(discountActivityId);
        assertPojoEquals(reqVO, discountActivity);
        assertEquals(discountActivity.getStatus(), PromotionActivityStatusEnum.WAIT.getStatus());
        // 校验商品
        List<DiscountProductDO> discountProducts = discountProductMapper.selectList(DiscountProductDO::getActivityId, discountActivity.getId());
        assertEquals(discountProducts.size(), reqVO.getProducts().size());
        for (int i = 0; i < reqVO.getProducts().size(); i++) {
            DiscountActivityBaseVO.Product product = reqVO.getProducts().get(i);
            DiscountProductDO discountProduct = discountProducts.get(i);
            assertEquals(discountProduct.getActivityId(), discountActivity.getId());
            assertEquals(discountProduct.getSpuId(), product.getSpuId());
            assertEquals(discountProduct.getSkuId(), product.getSkuId());
            assertEquals(discountProduct.getDiscountType(), product.getDiscountType());
            assertEquals(discountProduct.getDiscountPrice(), product.getDiscountPrice());
            assertEquals(discountProduct.getDiscountPercent(), product.getDiscountPercent());
        }
    }