Bladeren bron

渠道逻辑变更

wcc 1 jaar geleden
bovenliggende
commit
d90c97d0f6

+ 6 - 0
game-module/game-module-manage/pom.xml

@@ -109,6 +109,12 @@
             <artifactId>advertising-tencent-base</artifactId>
             <artifactId>advertising-tencent-base</artifactId>
             <version>0.0.1-SNAPSHOT</version>
             <version>0.0.1-SNAPSHOT</version>
         </dependency>
         </dependency>
+        <!-- 广告回传 -->
+        <dependency>
+            <groupId>com.zanxiang.game</groupId>
+            <artifactId>game-back-base</artifactId>
+            <version>${project.version}</version>
+        </dependency>
     </dependencies>
     </dependencies>
 
 
     <build>
     <build>

+ 8 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/dto/AgentDTO.java

@@ -25,4 +25,12 @@ public class AgentDTO {
      * 腾讯用户行为数据源 id
      * 腾讯用户行为数据源 id
      */
      */
     private Long userActionSetId;
     private Long userActionSetId;
+    /**
+     * 回传策略 id
+     */
+    private Long backPolicyId;
+    /**
+     * 投放状态
+     */
+    private Integer putStatus;
 }
 }

+ 4 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/dto/AgentListDTO.java

@@ -27,6 +27,10 @@ public class AgentListDTO extends BaseListDTO<Agent> {
      * 投放状态
      * 投放状态
      */
      */
     private Integer putStatus;
     private Integer putStatus;
+    /**
+     * 投手
+     */
+    private Long putUserId;
 
 
     private LocalDate createBeginTime;
     private LocalDate createBeginTime;
 
 

+ 3 - 0
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/pojo/vo/AgentVO.java

@@ -2,6 +2,7 @@ package com.zanxiang.game.module.manage.pojo.vo;
 
 
 import com.zanxiang.advertising.tencent.base.pojo.vo.AdAccountRpcVO;
 import com.zanxiang.advertising.tencent.base.pojo.vo.AdAccountRpcVO;
 import com.zanxiang.advertising.tencent.base.pojo.vo.UserActionSetRpcVO;
 import com.zanxiang.advertising.tencent.base.pojo.vo.UserActionSetRpcVO;
+import com.zanxiang.erp.base.pojo.vo.SysUserRpcVO;
 import lombok.Data;
 import lombok.Data;
 
 
 import java.time.LocalDateTime;
 import java.time.LocalDateTime;
@@ -42,4 +43,6 @@ public class AgentVO {
     private GameInfoVO gameInfo;
     private GameInfoVO gameInfo;
 
 
     private UserActionSetRpcVO userActionSet;
     private UserActionSetRpcVO userActionSet;
+
+    private SysUserRpcVO userInfo;
 }
 }

+ 12 - 3
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/IAgentService.java

@@ -1,15 +1,24 @@
 package com.zanxiang.game.module.manage.service;
 package com.zanxiang.game.module.manage.service;
 
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.zanxiang.game.module.manage.pojo.dto.AgentDTO;
 import com.zanxiang.game.module.manage.pojo.dto.AgentDTO;
+import com.zanxiang.game.module.manage.pojo.dto.AgentListDTO;
+import com.zanxiang.game.module.manage.pojo.vo.AgentVO;
 import com.zanxiang.game.module.mybatis.entity.Agent;
 import com.zanxiang.game.module.mybatis.entity.Agent;
 
 
+import java.util.List;
+
 public interface IAgentService extends IService<Agent> {
 public interface IAgentService extends IService<Agent> {
+
+    IPage<AgentVO> listOfPage(AgentListDTO dto);
+
     /**
     /**
      * 建渠道
      * 建渠道
-     *
-     * @param dto
-     * @return
      */
      */
     boolean add(AgentDTO dto);
     boolean add(AgentDTO dto);
+
+    boolean configPutStatus(List<Long> agentIdList, Integer putStatus);
+
+    boolean configBackPolicy(List<Long> agentIdList, Long backPolicyId);
 }
 }

+ 54 - 15
game-module/game-module-manage/src/main/java/com/zanxiang/game/module/manage/service/impl/AgentServiceImpl.java

@@ -1,14 +1,17 @@
 package com.zanxiang.game.module.manage.service.impl;
 package com.zanxiang.game.module.manage.service.impl;
 
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.zanxiang.advertising.tencent.base.AdvertisingTencentServer;
 import com.zanxiang.advertising.tencent.base.AdvertisingTencentServer;
 import com.zanxiang.advertising.tencent.base.pojo.vo.UserActionSetRpcVO;
 import com.zanxiang.advertising.tencent.base.pojo.vo.UserActionSetRpcVO;
 import com.zanxiang.advertising.tencent.base.rpc.IAdAccountRpc;
 import com.zanxiang.advertising.tencent.base.rpc.IAdAccountRpc;
 import com.zanxiang.advertising.tencent.base.rpc.IUserActionSetRpc;
 import com.zanxiang.advertising.tencent.base.rpc.IUserActionSetRpc;
+import com.zanxiang.erp.base.pojo.vo.SysUserRpcVO;
+import com.zanxiang.erp.base.rpc.ISysUserRpc;
 import com.zanxiang.erp.security.util.SecurityUtil;
 import com.zanxiang.erp.security.util.SecurityUtil;
-import com.zanxiang.game.module.base.utils.StringUtils;
 import com.zanxiang.game.module.manage.pojo.dto.AgentDTO;
 import com.zanxiang.game.module.manage.pojo.dto.AgentDTO;
 import com.zanxiang.game.module.manage.pojo.dto.AgentListDTO;
 import com.zanxiang.game.module.manage.pojo.dto.AgentListDTO;
 import com.zanxiang.game.module.manage.pojo.enums.AccountTypeEnum;
 import com.zanxiang.game.module.manage.pojo.enums.AccountTypeEnum;
@@ -17,12 +20,12 @@ import com.zanxiang.game.module.manage.pojo.vo.GameInfoVO;
 import com.zanxiang.game.module.manage.service.IAgentService;
 import com.zanxiang.game.module.manage.service.IAgentService;
 import com.zanxiang.game.module.manage.service.IGameService;
 import com.zanxiang.game.module.manage.service.IGameService;
 import com.zanxiang.game.module.mybatis.entity.Agent;
 import com.zanxiang.game.module.mybatis.entity.Agent;
-import com.zanxiang.game.module.mybatis.entity.Game;
 import com.zanxiang.game.module.mybatis.mapper.AgentMapper;
 import com.zanxiang.game.module.mybatis.mapper.AgentMapper;
 import com.zanxiang.module.util.bean.BeanUtil;
 import com.zanxiang.module.util.bean.BeanUtil;
 import com.zanxiang.module.util.exception.BaseException;
 import com.zanxiang.module.util.exception.BaseException;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.apache.dubbo.config.annotation.DubboReference;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
@@ -51,6 +54,8 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent>
     private IAdAccountRpc adAccountRpc;
     private IAdAccountRpc adAccountRpc;
     @DubboReference(providedBy = AdvertisingTencentServer.SERVER_DUBBO_NAME)
     @DubboReference(providedBy = AdvertisingTencentServer.SERVER_DUBBO_NAME)
     private IUserActionSetRpc userActionSetRpc;
     private IUserActionSetRpc userActionSetRpc;
+    @Autowired
+    private ISysUserRpc sysUserRpc;
 
 
     public IPage<AgentVO> listOfPage(AgentListDTO dto) {
     public IPage<AgentVO> listOfPage(AgentListDTO dto) {
         IPage<Agent> agentIPage = page(dto.toPage(), new LambdaQueryWrapper<Agent>()
         IPage<Agent> agentIPage = page(dto.toPage(), new LambdaQueryWrapper<Agent>()
@@ -62,8 +67,14 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent>
                 .eq(dto.getPutStatus() != null, Agent::getPutStatus, dto.getPutStatus())
                 .eq(dto.getPutStatus() != null, Agent::getPutStatus, dto.getPutStatus())
                 .ge(dto.getCreateBeginTime() != null, Agent::getCreateTime, dto.getCreateBeginTime() == null ? null : LocalDateTime.of(dto.getCreateBeginTime(), LocalTime.MIDNIGHT))
                 .ge(dto.getCreateBeginTime() != null, Agent::getCreateTime, dto.getCreateBeginTime() == null ? null : LocalDateTime.of(dto.getCreateBeginTime(), LocalTime.MIDNIGHT))
                 .le(dto.getCreateEndTime() != null, Agent::getCreateTime, dto.getCreateEndTime() == null ? null : LocalDateTime.of(dto.getCreateEndTime(), LocalTime.MIDNIGHT))
                 .le(dto.getCreateEndTime() != null, Agent::getCreateTime, dto.getCreateEndTime() == null ? null : LocalDateTime.of(dto.getCreateEndTime(), LocalTime.MIDNIGHT))
+                .eq(Agent::getCreateBy, dto.getPutUserId() == null ? SecurityUtil.getUserId() : dto.getPutUserId())
                 .orderByDesc(Agent::getCreateTime)
                 .orderByDesc(Agent::getCreateTime)
         );
         );
+        IPage<AgentVO> result = new Page<>(agentIPage.getCurrent(), agentIPage.getSize(), agentIPage.getTotal());
+        if (CollectionUtils.isNotEmpty(agentIPage.getRecords())) {
+            result.setRecords(toVOBatch(agentIPage.getRecords()));
+        }
+        return result;
     }
     }
 
 
     @Override
     @Override
@@ -75,17 +86,40 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent>
         ) > 0) {
         ) > 0) {
             throw new BaseException("一个账号只能建一个渠道,投一个游戏!!!");
             throw new BaseException("一个账号只能建一个渠道,投一个游戏!!!");
         }
         }
-        Agent agent = Agent.builder()
+        return save(Agent.builder()
                 .agentName(dto.getAgentName())
                 .agentName(dto.getAgentName())
                 .agentKey(UUID.randomUUID().toString().replaceAll("-", ""))
                 .agentKey(UUID.randomUUID().toString().replaceAll("-", ""))
                 .accountType(dto.getAccountType())
                 .accountType(dto.getAccountType())
                 .accountId(dto.getAccountId())
                 .accountId(dto.getAccountId())
                 .gameId(dto.getGameId())
                 .gameId(dto.getGameId())
                 .userActionSetId(dto.getUserActionSetId())
                 .userActionSetId(dto.getUserActionSetId())
+                .backPolicyId(dto.getBackPolicyId())
+                .putStatus(dto.getPutStatus())
                 .createTime(LocalDateTime.now())
                 .createTime(LocalDateTime.now())
                 .createBy(SecurityUtil.getUserId())
                 .createBy(SecurityUtil.getUserId())
-                .build();
-        return save(agent);
+                .build());
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean configPutStatus(List<Long> agentIdList, Integer putStatus) {
+        return update(new LambdaUpdateWrapper<Agent>()
+                .set(Agent::getPutStatus, putStatus)
+                .set(Agent::getUpdateBy, SecurityUtil.getUserId())
+                .set(Agent::getUpdateTime, agentIdList)
+                .in(Agent::getId, agentIdList)
+        );
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public boolean configBackPolicy(List<Long> agentIdList, Long backPolicyId) {
+        return update(new LambdaUpdateWrapper<Agent>()
+                .set(Agent::getBackPolicyId, backPolicyId)
+                .set(Agent::getUpdateBy, SecurityUtil.getUserId())
+                .set(Agent::getUpdateTime, agentIdList)
+                .in(Agent::getId, agentIdList)
+        );
     }
     }
 
 
     private List<AgentVO> toVOBatch(List<Agent> agentList) {
     private List<AgentVO> toVOBatch(List<Agent> agentList) {
@@ -94,31 +128,36 @@ public class AgentServiceImpl extends ServiceImpl<AgentMapper, Agent>
         }
         }
         Set<Long> gameIds = new HashSet<>(agentList.size());
         Set<Long> gameIds = new HashSet<>(agentList.size());
         Set<Long> txAccountIds = new HashSet<>(agentList.size());
         Set<Long> txAccountIds = new HashSet<>(agentList.size());
-        Set<Long> txUserActionSetIds = new HashSet<>(agentList.size());
-        Set<Long> byteAccountIds = new HashSet<>(agentList.size());
+        Set<Long> userIds = new HashSet<>(1);
         agentList.forEach(agent -> {
         agentList.forEach(agent -> {
             gameIds.add(agent.getGameId());
             gameIds.add(agent.getGameId());
             if (AccountTypeEnum.TENCENT.getValue().equals(agent.getAccountType())) {
             if (AccountTypeEnum.TENCENT.getValue().equals(agent.getAccountType())) {
                 txAccountIds.add(agent.getAccountId());
                 txAccountIds.add(agent.getAccountId());
-                txUserActionSetIds.add(agent.getUserActionSetId());
-            } else {
-                byteAccountIds.add(agent.getAccountId());
             }
             }
+            userIds.add(agent.getCreateBy());
         });
         });
-        Map<Long, UserActionSetRpcVO> userActionSetMap = new HashMap<>(0);
+        Map<String, UserActionSetRpcVO> userActionSetMap = new HashMap<>();
         if (CollectionUtils.isNotEmpty(txAccountIds)) {
         if (CollectionUtils.isNotEmpty(txAccountIds)) {
-            for(Long txAccountId : txAccountIds) {
-                userActionSetMap = userActionSetRpc.getByAccount(txAccountId).getData();
+            for (Long txAccountId : txAccountIds) {
+                List<UserActionSetRpcVO> userActionSetList = userActionSetRpc.getByAccount(txAccountId).getData();
+                if (CollectionUtils.isEmpty(userActionSetList)) {
+                    continue;
+                }
+                userActionSetMap.putAll(userActionSetList.stream().collect(Collectors.toMap(obj -> obj.getAccountId() + "_" + obj.getUserActionSetId(), Function.identity())));
             }
             }
         }
         }
         Map<Long, GameInfoVO> gameMap = gameService.infoByIds(gameIds).stream().collect(Collectors.toMap(GameInfoVO::getId, Function.identity()));
         Map<Long, GameInfoVO> gameMap = gameService.infoByIds(gameIds).stream().collect(Collectors.toMap(GameInfoVO::getId, Function.identity()));
+        Map<Long, SysUserRpcVO> userMap = sysUserRpc.userInfoByIds(SecurityUtil.getCompanyId(), new ArrayList<>(userIds)).getData().stream()
+                .collect(Collectors.toMap(SysUserRpcVO::getUserId, Function.identity()));
         return agentList.stream().map(agent -> {
         return agentList.stream().map(agent -> {
             AgentVO vo = BeanUtil.copy(agent, AgentVO.class);
             AgentVO vo = BeanUtil.copy(agent, AgentVO.class);
             vo.setGameInfo(gameMap.get(agent.getGameId()));
             vo.setGameInfo(gameMap.get(agent.getGameId()));
-            vo.setUserActionSet();
+            if (AccountTypeEnum.TENCENT.getValue().equals(agent.getAccountType())) {
+                vo.setUserActionSet(userActionSetMap.get(agent.getAccountId() + "_" + agent.getUserActionSetId()));
+            }
+            vo.setUserInfo(userMap.get(agent.getCreateBy()));
             return vo;
             return vo;
         }).collect(Collectors.toList());
         }).collect(Collectors.toList());
-
     }
     }
 
 
     private AgentVO toVOSimple(Agent agent) {
     private AgentVO toVOSimple(Agent agent) {