Procházet zdrojové kódy

feat : 推广渠道接口调试修改

bilingfeng před 2 roky
rodič
revize
28cbfe4032

+ 0 - 6
game-module/game-manage/src/main/java/com/zanxiang/manage/domain/params/PromoChannelAddUpdateParam.java

@@ -13,12 +13,6 @@ import javax.validation.constraints.NotNull;
 @Data
 public class PromoChannelAddUpdateParam {
 
-    /**
-     * 主键
-     */
-    @ApiModelProperty(notes = "主键, 不传是新建, 传是更新")
-    private Long id;
-
     /**
      * 账号联动选择列表主键id
      */

+ 7 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/domain/params/PromoChannelListParam.java

@@ -3,12 +3,14 @@ package com.zanxiang.manage.domain.params;
 import com.zanxiang.common.base.BasePage;
 import com.zanxiang.mybatis.entity.PromoChannel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
 
 /**
  * @author : lingfeng
  * @time : 2022-11-23
  * @description : 推广列表参数
  */
+@Data
 public class PromoChannelListParam extends BasePage<PromoChannel> {
 
     /**
@@ -29,6 +31,11 @@ public class PromoChannelListParam extends BasePage<PromoChannel> {
     @ApiModelProperty(notes = "推广渠道标识")
     private String channel;
 
+    /**
+     * 投手项目组
+     */
+    private String pitcherGroupId;
+
     /**
      * 投手id
      */

+ 1 - 1
game-module/game-manage/src/main/java/com/zanxiang/manage/domain/vo/PromoMediaListVO.java

@@ -17,7 +17,7 @@ public class PromoMediaListVO {
      * 主键
      */
     @ApiModelProperty(notes = "主键")
-    private Integer id;
+    private Long id;
 
     /**
      * 推广媒体

+ 26 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/service/Impl/PromoAccountServiceImpl.java

@@ -297,4 +297,30 @@ public class PromoAccountServiceImpl extends ServiceImpl<PromoAccountMapper, Pro
         }
         return promoAccountList.stream().map(PromoAccount::getId).collect(Collectors.toList());
     }
+
+    /**
+     * 推广账号条件
+     *
+     * @param pitcherGroupId 投手组id
+     * @param pitcherId      投手id
+     * @param mediaId        媒体id
+     * @param accountType    帐户类型
+     */
+    @Override
+    public Map<Long, PromoAccountDTO> promoAccountCondition(String pitcherGroupId, String pitcherId, Long mediaId,
+                                                            String account, Integer accountType) {
+        //条件判断
+        if (Strings.isBlank(pitcherGroupId) && Strings.isBlank(pitcherId) && mediaId == null
+                && Strings.isBlank(account) && accountType == null) {
+            return null;
+        }
+        List<PromoAccount> promoAccountList = super.list(new LambdaQueryWrapper<PromoAccount>()
+                .eq(Strings.isBlank(pitcherGroupId), PromoAccount::getPitcherGroupId, pitcherGroupId)
+                .eq(Strings.isBlank(pitcherId), PromoAccount::getPitcherId, pitcherId)
+                .eq(mediaId != null, PromoAccount::getMediaId, mediaId)
+                .eq(Strings.isBlank(account), PromoAccount::getAccount, account)
+                .eq(accountType != null, PromoAccount::getAccountType, accountType));
+        List<PromoAccountDTO> promoAccountDTOList = BeanUtils.copyList(promoAccountList, PromoAccountDTO.class);
+        return promoAccountDTOList.stream().collect(Collectors.toMap(PromoAccountDTO::getId, Function.identity()));
+    }
 }

+ 42 - 31
game-module/game-manage/src/main/java/com/zanxiang/manage/service/Impl/PromoChannelServiceImpl.java

@@ -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);
     }

+ 10 - 0
game-module/game-manage/src/main/java/com/zanxiang/manage/service/PromoAccountService.java

@@ -91,4 +91,14 @@ public interface PromoAccountService extends IService<PromoAccount> {
      * @return : 返回所有渠道信息
      */
     Map<Long, PromoAccountDTO> promoAccountMap();
+
+    /**
+     * 推广账号条件
+     *
+     * @param pitcherGroupId 投手组id
+     * @param pitcherId      投手id
+     * @param mediaId        媒体id
+     * @param accountType    帐户类型
+     */
+    Map<Long, PromoAccountDTO> promoAccountCondition(String pitcherGroupId, String pitcherId, Long mediaId, String account, Integer accountType);
 }