|
@@ -112,6 +112,44 @@ public class MarketingServiceImpl extends ServiceImpl<MarketingMapper, Marketing
|
|
|
private DistributedLocker distributedLocker;
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void copyById(Long marketingId) {
|
|
|
+ Marketing marketing = this.getById(marketingId);
|
|
|
+ if (Objects.isNull(marketing)) {
|
|
|
+ throw new ServiceException("活动不存在");
|
|
|
+ }
|
|
|
+ // 初始化活动
|
|
|
+ marketing.setId(null);
|
|
|
+ marketing.setFakeNum(0);
|
|
|
+ marketing.setRealNum(0);
|
|
|
+ marketing.setIsOn(MarketingStatusEnum.OFF.getValue());
|
|
|
+ marketing.setIsSend(0);
|
|
|
+ marketing.setTriggerStatus(0);
|
|
|
+ marketing.setCreatedTime(null);
|
|
|
+ Assert.isTrue(this.save(marketing), "复制营销活动失败");
|
|
|
+
|
|
|
+ List<MarketingAwards> marketingAwardsList = marketingAwardsService.list(new LambdaQueryWrapper<MarketingAwards>().eq(MarketingAwards::getMarketingId, marketingId));
|
|
|
+ if (CollectionUtils.isEmpty(marketingAwardsList)) {
|
|
|
+ throw new ServiceException("活动奖级信息不存在");
|
|
|
+ }
|
|
|
+ for (MarketingAwards marketingAwards : marketingAwardsList) {
|
|
|
+ List<MarketingAwardsPrize> marketingAwardsPrizeList = marketingAwardsPrizeService.list(new LambdaQueryWrapper<MarketingAwardsPrize>()
|
|
|
+ .eq(MarketingAwardsPrize::getMarketingId, marketingId)
|
|
|
+ .eq(MarketingAwardsPrize::getAwardsId, marketingAwards.getId()));
|
|
|
+ marketingAwards.setId(null);
|
|
|
+ marketingAwards.setMarketingId(marketing.getId());
|
|
|
+ Assert.isTrue(marketingAwardsService.save(marketingAwards),"复制营销活动奖级失败");
|
|
|
+ for (MarketingAwardsPrize marketingAwardsPrize : marketingAwardsPrizeList) {
|
|
|
+ marketingAwardsPrize.setId(null);
|
|
|
+ marketingAwardsPrize.setAwardsId(marketingAwards.getId());
|
|
|
+ marketingAwardsPrize.setMarketingId(marketing.getId());
|
|
|
+ }
|
|
|
+ Assert.isTrue(marketingAwardsPrizeService.saveBatch(marketingAwardsPrizeList),"复制营销活动奖品失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void generateCode(Long marketingId, Long userId) {
|