|
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.zanxiang.common.enums.DeleteEnum;
|
|
|
import com.zanxiang.common.enums.PromoAccountTypeEnum;
|
|
@@ -29,6 +30,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.LocalTime;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
@@ -65,12 +67,34 @@ public class PromoChannelServiceImpl extends ServiceImpl<PromoChannelMapper, Pro
|
|
|
*/
|
|
|
@Override
|
|
|
public IPage<PromoChannelListVO> list(PromoChannelListParam param) {
|
|
|
+ //游戏条件处理
|
|
|
+ Map<Long, GameDTO> gameMap = gameService.gameCondition(null, param.getGameId(), param.getGameCategory());
|
|
|
+ //根据条件, 匹配不到游戏
|
|
|
+ if (gameMap != null && gameMap.isEmpty()) {
|
|
|
+ return new Page<>();
|
|
|
+ }
|
|
|
+ //推广账号条件
|
|
|
+ Map<Long, PromoAccountDTO> promoAccountMap = promoAccountService.promoAccountCondition(param.getPitcherGroupId(),
|
|
|
+ param.getPitcherId(), param.getMediaId(), param.getAccount(), param.getAccountType());
|
|
|
+ //根据条件, 匹配不到账号
|
|
|
+ if (gameMap != null && gameMap.isEmpty()) {
|
|
|
+ return new Page<>();
|
|
|
+ }
|
|
|
+ //相关结果
|
|
|
Map<Long, PromoMediaDTO> promoMediaMap = promoMediaService.promoMediaMap();
|
|
|
Map<Long, PromoSiteDTO> promoSiteMap = promoSiteService.promoSiteMap();
|
|
|
- Map<Long, PromoAccountDTO> promoAccountMap = promoAccountService.promoAccountMap();
|
|
|
- Map<Long, GameDTO> gameMap = gameService.gameMap();
|
|
|
Map<Long, GameCategoryDTO> gameCategoryMap = gameCategoryService.gameCategoryMap();
|
|
|
+ //相关条件
|
|
|
+ Set<Long> gameIdSet = gameMap == null ? null : gameMap.keySet();
|
|
|
+ Set<Long> promoAccountIdSet = promoAccountMap == null ? null : promoAccountMap.keySet();
|
|
|
return page(param.toPage(), new QueryWrapper<PromoChannel>().lambda()
|
|
|
+ .in(CollectionUtils.isNotEmpty(gameIdSet), PromoChannel::getGameId, gameIdSet)
|
|
|
+ .in(CollectionUtils.isNotEmpty(promoAccountIdSet), PromoChannel::getAccountId, promoAccountIdSet)
|
|
|
+ .like(Strings.isNotBlank(param.getChannel()), PromoChannel::getChannel, param.getChannel())
|
|
|
+ .ge(param.getBeginDate() != null, PromoChannel::getCreateTime, param.getBeginDate() == null ? null : LocalDateTime.of(param.getBeginDate(), LocalTime.MIN))
|
|
|
+ .le(param.getEndDate() != null, PromoChannel::getCreateTime, param.getEndDate() == null ? null : LocalDateTime.of(param.getEndDate(), LocalTime.MAX))
|
|
|
+ .eq(param.getProviderId() != null, PromoChannel::getProviderId, param.getProviderId())
|
|
|
+ .eq(param.getStatus() != null, PromoChannel::getStatus, param.getStatus())
|
|
|
.orderByDesc(PromoChannel::getCreateTime))
|
|
|
.convert(promoAccount -> this.toVo(promoAccountMap, promoMediaMap, promoAccount, promoSiteMap, gameMap, gameCategoryMap));
|
|
|
}
|
|
@@ -131,39 +155,26 @@ public class PromoChannelServiceImpl extends ServiceImpl<PromoChannelMapper, Pro
|
|
|
public Boolean addOrUpdate(PromoChannelAddUpdateParam param) {
|
|
|
PromoAccount promoAccount = promoAccountService.getById(param.getPromoAccountId());
|
|
|
PromoSite promoSite = promoSiteService.getById(param.getPromoSiteId());
|
|
|
- Long id = param.getId();
|
|
|
- //更新
|
|
|
- if (id != null) {
|
|
|
- PromoChannel promoChannel = super.getById(param.getId());
|
|
|
- promoChannel.setAccountId(promoAccount.getId());
|
|
|
- promoChannel.setMediaId(promoAccount.getMediaId());
|
|
|
- promoChannel.setPromoSiteId(promoSite.getId());
|
|
|
- promoChannel.setProviderId(param.getProviderId());
|
|
|
- promoChannel.setGameId(param.getGameId());
|
|
|
- promoChannel.setRemark(param.getRemark());
|
|
|
- promoChannel.setUpdateTime(LocalDateTime.now());
|
|
|
- return super.updateById(promoChannel);
|
|
|
- }
|
|
|
- //创建对象
|
|
|
- PromoChannel promoChannel = PromoChannel.builder()
|
|
|
- .accountId(promoAccount.getId())
|
|
|
- .mediaId(promoAccount.getMediaId())
|
|
|
- .promoSiteId(promoSite.getId())
|
|
|
- .providerId(param.getProviderId())
|
|
|
- .gameId(param.getGameId())
|
|
|
- .remark(param.getRemark())
|
|
|
- .status(StatusEnum.YES.getCode())
|
|
|
- .isDelete(DeleteEnum.NO.getCode())
|
|
|
- .createTime(LocalDateTime.now())
|
|
|
- .updateTime(LocalDateTime.now())
|
|
|
- .build();
|
|
|
//创建渠道
|
|
|
Integer channelCount = param.getChannelCount();
|
|
|
List<PromoChannel> promoChannelList = new ArrayList<>();
|
|
|
for (int i = 0; i < channelCount; i++) {
|
|
|
- PromoChannel channel = BeanUtils.copy(promoChannel, PromoChannel.class);
|
|
|
- channel.setChannel(UUID.randomUUID().toString().replace("-", ""));
|
|
|
- promoChannelList.add(channel);
|
|
|
+ UUID id = UUID.randomUUID();
|
|
|
+ String[] idArray = id.toString().split("-");
|
|
|
+ String channel = Long.toBinaryString(System.currentTimeMillis() + channelCount) + idArray[1];
|
|
|
+ promoChannelList.add(PromoChannel.builder()
|
|
|
+ .accountId(promoAccount.getId())
|
|
|
+ .mediaId(promoAccount.getMediaId())
|
|
|
+ .promoSiteId(promoSite.getId())
|
|
|
+ .providerId(param.getProviderId())
|
|
|
+ .gameId(param.getGameId())
|
|
|
+ .remark(param.getRemark())
|
|
|
+ .channel(channel)
|
|
|
+ .status(StatusEnum.YES.getCode())
|
|
|
+ .isDelete(DeleteEnum.NO.getCode())
|
|
|
+ .createTime(LocalDateTime.now())
|
|
|
+ .updateTime(LocalDateTime.now())
|
|
|
+ .build());
|
|
|
}
|
|
|
return super.saveBatch(promoChannelList);
|
|
|
}
|