Bläddra i källkod

修复代理中心bug

dos 3 månader sedan
förälder
incheckning
00da7c9bd3

+ 26 - 6
game-business/src/main/java/com/game/business/controller/AppAgentController.java

@@ -14,10 +14,12 @@ import com.game.business.service.IFinTranRecordService;
 import com.game.business.vo.AppAgentTeamVo;
 import com.game.business.vo.AppUserAgentJournalIndexVO;
 import com.game.business.vo.AppUserTeamTranserRecordVo;
+import com.game.common.constant.CacheConstants;
 import com.game.common.core.controller.BaseController;
 import com.game.common.core.domain.HttpRet;
 import com.game.common.core.domain.HttpRetPageArr;
 import com.game.common.core.page.TableDataInfo;
+import com.game.common.core.redis.RedisCache;
 import com.game.common.utils.MessageUtils;
 import com.game.common.utils.SecurityUtils;
 import io.swagger.annotations.Api;
@@ -31,6 +33,7 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
@@ -52,6 +55,9 @@ public class AppAgentController extends BaseController {
     @Autowired
     private IFinTranRecordService finTranRecordService;
 
+    @Autowired
+    private RedisCache redisCache;
+
 
     /**
      * 首页
@@ -64,6 +70,11 @@ public class AppAgentController extends BaseController {
         if(null != agentIndexDto.getUserId()){
             userId = agentIndexDto.getUserId();
         }
+        AppUserAgent appUserAgent = appUserAgentService.selectInfo(userId);
+        long topUserId = userId;
+        if(null != appUserAgent && appUserAgent.getPid() > 0){
+            topUserId = appUserAgent.getTopId();
+        }
         AppUserAgentJournalIndexVO vo = new AppUserAgentJournalIndexVO();
         Date nowDate = DateUtil.date();
         if(agentIndexDto.getType() == 1){
@@ -79,9 +90,19 @@ public class AppAgentController extends BaseController {
             appUserCountList = new ArrayList<>();
         }
         //佣金
-        vo.setMyCommission(appUserCountList.stream().mapToDouble(e->e.getLiveCommission() + e.getGameCommission()).sum());
+        double money = 0;
+        if(null != redisCache.getCacheMapValue(CacheConstants.USER_AGENT_TEAM_PHASE,String.valueOf(topUserId))){
+            money = redisCache.getCacheMapValue(CacheConstants.USER_AGENT_TEAM_PHASE,String.valueOf(topUserId));
+        }
+        if(null != appUserAgent.getDividendGuaranteeRate()){
+            money = money * appUserAgent.getDividendGuaranteeRate();
+        }
+        //预计分红
+        vo.setMyCommission(BigDecimal.valueOf(money).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
+        vo.setLiveCommission(appUserCountList.stream().mapToDouble(e->e.getLiveCommission()).sum());
+        vo.setGameCommission(appUserCountList.stream().mapToDouble(e->e.getGameCommission()).sum());
         //团队人数
-        vo.setTeamUser(appUserAgentService.countAgent(userId,null,null));
+        vo.setTeamUser(appUserCountList.stream().map(AppUserCount::getUserId).distinct().collect(Collectors.toList()).size());
         //团队充值
         vo.setTeamRecharge(appUserCountList.stream().mapToDouble(e->e.getRechargeAmount()).sum());
         //团队充值赠送金额
@@ -89,8 +110,7 @@ public class AppAgentController extends BaseController {
         //团队充值手续费
         vo.setRechargeCommission(appUserCountList.stream().mapToDouble(e->e.getRechargeCommission()).sum());
         //团队投注
-        vo.setTeamBetting(appUserAgentService.sumBetting(DateUtil.format(beginDate,"yyyy-MM-dd").concat(" 00:00:00")
-                ,DateUtil.format(endDate,"yyyy-MM-dd").concat(" 23:59:59"),userId));
+        vo.setTeamBetting(appUserCountList.stream().mapToDouble(e->e.getGameBetting()).sum());
         //团队直播消费
         vo.setTeamLive(appUserCountList.stream().mapToDouble(e->e.getLiveUseAmount()).sum());
         //团队投注赢
@@ -101,9 +121,9 @@ public class AppAgentController extends BaseController {
         vo.setActiveUser(appUserCountList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(()-> new TreeSet<>(Comparator.comparing(f->f.getUserId()))), ArrayList::new)).size());
         //昨日新增
         Date yesterDay = DateUtil.offsetDay(DateUtil.date(),-1);
-        vo.setYesterdayUser(appUserAgentService.countAgent(userId,DateUtil.format(yesterDay,"yyyy-MM-dd").concat(" 00:00:00")
+        vo.setYesterdayUser(appUserAgentService.countAgent(topUserId,DateUtil.format(yesterDay,"yyyy-MM-dd").concat(" 00:00:00")
                 ,DateUtil.format(yesterDay,"yyyy-MM-dd").concat(" 23:59:59")));
-        vo.setMonthUser(appUserAgentService.countAgent(userId,DateUtil.format(beginDate,"yyyy-MM-dd").concat(" 00:00:00")
+        vo.setMonthUser(appUserAgentService.countAgent(topUserId,DateUtil.format(beginDate,"yyyy-MM-dd").concat(" 00:00:00")
                 ,DateUtil.format(endDate,"yyyy-MM-dd").concat(" 23:59:59")));
 
         return HttpRet.success(MessageUtils.message("11022"),vo);

+ 11 - 0
game-business/src/main/java/com/game/business/controller/AppUserAgentController.java

@@ -95,6 +95,17 @@ public class AppUserAgentController extends BaseController
 
         appUserAgentService.insertAppUserAgent(appUserAgent);
 
+        //更新上级团队人数
+        String subset =  dbPuserAgent.getSubset();
+        if(StringUtils.isNotBlank("subset")){
+            subset = subset.concat(",");
+        }
+        subset = subset.concat(String.valueOf(appUser.getUserid()));
+        AppUserAgent updateUserAgent = new AppUserAgent();
+        updateUserAgent.setId(dbPuserAgent.getId());
+        updateUserAgent.setSubset(subset);
+        appUserAgentService.updateAppUserAgent(updateUserAgent);
+
         AppUserAgentVO appUserAgentVO = new AppUserAgentVO();
         BeanUtils.copyProperties(appUserAgent, appUserAgentVO);
         appUserAgentVO.setUserId(appUser.getUserid());

+ 6 - 0
game-business/src/main/java/com/game/business/domain/AppUserAgent.java

@@ -44,6 +44,12 @@ private static final long serialVersionUID=1L;
     @TableField(value = "pid")
     private Long pid;
 
+    /** 直属下级id集合 */
+    @ApiModelProperty(value = "直属下级id集合")
+    @Excel(name = "直属下级id集合")
+    @TableField(value = "subset")
+    private String subset;
+
     /** 顶级代理ID */
     @ApiModelProperty(value = "顶级代理ID")
     @Excel(name = "顶级代理ID")

+ 3 - 1
game-business/src/main/java/com/game/business/mapper/AppUserCountMapper.java

@@ -10,7 +10,7 @@ import java.util.List;
 public interface AppUserCountMapper extends BaseMapper<AppUserCount> {
 
     @Select(" <script>" +
-            "select a.* from app_user_count as a INNER JOIN" +
+            " select a.* from app_user_count as a INNER JOIN" +
             " (WITH RECURSIVE useragent AS" +
             " (" +
             " SELECT *" +
@@ -22,6 +22,8 @@ public interface AppUserCountMapper extends BaseMapper<AppUserCount> {
             " JOIN useragent s ON o.pid = s.user_id" +
             " )" +
             " SELECT user_id FROM useragent ) as b on a.user_id = b.user_id where a.str_date between #{beginTime} and #{endTime}" +
+            " union all" +
+            " select c.* from app_user_count as c where c.user_id = #{pid} and c.str_date between #{beginTime} and #{endTime} " +
             " </script>")
     public List<AppUserCount> selectTeamUserCount(@Param("pid") Long pid,@Param("beginTime") String beginTime,@Param("endTime") String endTime);
 

+ 1 - 1
game-business/src/main/java/com/game/business/mapper/AppUserMapper.java

@@ -62,6 +62,6 @@ public interface AppUserMapper extends BaseMapper<AppUser> {
 
     Long nextId();
 
-    @Select("select * from app_user where pid = 0 and and agent_flag = 1")
+    @Select("select * from app_user where pid = 0 and agent_flag = 1")
     public List<AppUser> selectTeamUserList();
 }

+ 5 - 0
game-business/src/main/java/com/game/business/service/IAppUserCountDividendService.java

@@ -69,4 +69,9 @@ public interface IAppUserCountDividendService extends IService<AppUserCountDivid
      * 发放分红
      * */
     public HttpRet<Boolean> send(String userId,String dateNo);
+
+    /**
+     * 重载团队盈亏缓存
+     * */
+    public void reloadCache(String dateTime,List<Long> userIds);
 }

+ 1 - 1
game-business/src/main/java/com/game/business/service/impl/AppUserAgentServiceImpl.java

@@ -133,7 +133,7 @@ public class AppUserAgentServiceImpl extends ServiceImpl<AppUserAgentMapper, App
     @Override
     public int countAgent(Long userId, String beginTime, String endTime) {
         LambdaQueryWrapper<AppUserAgent> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(AppUserAgent::getPid,userId);
+        queryWrapper.eq(AppUserAgent::getTopId,userId);
         if(StringUtils.isNotBlank(beginTime)){
             queryWrapper.ge(AppUserAgent::getCreateTime,beginTime);
         }

+ 69 - 6
game-business/src/main/java/com/game/business/service/impl/AppUserCountDividendServiceImpl.java

@@ -1,5 +1,6 @@
 package com.game.business.service.impl;
 
+import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 
@@ -7,27 +8,27 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Date;
 import java.util.function.Function;
 import java.util.stream.Collectors;
 
-import com.game.business.domain.AppUser;
-import com.game.business.domain.FinTranRecord;
-import com.game.business.service.IAppUserService;
-import com.game.business.service.IFinTranRecordService;
+import com.game.business.domain.*;
+import com.game.business.service.*;
 import com.game.common.constant.AppSceneType;
+import com.game.common.constant.CacheConstants;
 import com.game.common.constant.finance.FinTranAddedInfo;
 import com.game.common.constant.finance.FinTranType1;
 import com.game.common.constant.finance.FinTranType3;
 import com.game.common.constant.finance.TranCurrencyType;
 import com.game.common.core.domain.HttpRet;
+import com.game.common.core.redis.RedisCache;
 import com.game.common.utils.DateUtils;
 import com.game.common.utils.StringUtils;
+import lombok.extern.log4j.Log4j2;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 import com.game.business.mapper.AppUserCountDividendMapper;
-import com.game.business.domain.AppUserCountDividend;
-import com.game.business.service.IAppUserCountDividendService;
 import com.game.common.annotation.DataSource;
 import com.game.common.enums.DataSourceType;
 import org.springframework.transaction.annotation.Transactional;
@@ -39,6 +40,7 @@ import org.springframework.transaction.annotation.Transactional;
  * @date 2024-06-30
  */
 @Service
+@Log4j2
 public class AppUserCountDividendServiceImpl extends ServiceImpl<AppUserCountDividendMapper, AppUserCountDividend> implements IAppUserCountDividendService {
     @Autowired
     private AppUserCountDividendMapper appUserCountDividendMapper;
@@ -46,6 +48,12 @@ public class AppUserCountDividendServiceImpl extends ServiceImpl<AppUserCountDiv
     private IAppUserService appUserService;
     @Autowired
     private IFinTranRecordService finTranRecordService;
+    @Autowired
+    private IAppUserCountService appUserCountService;
+    @Autowired
+    private RedisCache redisCache;
+    @Autowired
+    private IAppUserAgentService appUserAgentService;
 
     /**
      * 查询用户代理分红
@@ -213,5 +221,60 @@ public class AppUserCountDividendServiceImpl extends ServiceImpl<AppUserCountDiv
         return HttpRet.success("发放成功",true);
     }
 
+    @Override
+    public void reloadCache(String dateTime, List<Long> userIds) {
+        Date uDate = new Date();
+        if (StringUtils.isNotBlank(dateTime)) {
+            uDate = DateUtil.parse(dateTime, "yyyy-MM-dd");
+        }
+        String beginTime = DateUtil.format(DateUtil.beginOfWeek(uDate), "yyyy-MM-dd");
+        String endTime = DateUtil.format(DateUtil.endOfWeek(uDate), "yyyy-MM-dd");
+        if (null == userIds) {
+            List<AppUser> list = appUserService.selectTeamUserList();
+            if (null != list && list.size() > 0) {
+                list.forEach(appUser -> {
+                    double money = calculation(appUser.getUserid(), beginTime, endTime);
+                    redisCache.setCacheMapValue(CacheConstants.USER_AGENT_TEAM_PHASE, String.valueOf(appUser.getUserid()), money);
+                });
+            }
+        } else {
+            userIds.forEach(e->{
+                AppUserAgent appUserAgent = appUserAgentService.selectInfo(e);
+                if (null != appUserAgent) {
+                    Long topUserId = appUserAgent.getTopId()<1?appUserAgent.getUserId():appUserAgent.getTopId();
+                    double money = calculation(topUserId, beginTime, endTime);
+                    redisCache.setCacheMapValue(CacheConstants.USER_AGENT_TEAM_PHASE, String.valueOf(topUserId), money);
+                }else{
+                    log.info("用户非代理停止计算周盈亏缓存");
+                }
+            });
+        }
+    }
+
+    private double calculation(Long userId,String beginTime,String endTime){
+        double money = 0;
+        List<AppUserCount> appUserCountList = appUserCountService.getAppUserCountNew(userId,beginTime,endTime);
+        if (null != appUserCountList && appUserCountList.size() > 0) {
+            //游戏输钱
+            double loseAmount = appUserCountList.stream().mapToDouble(e -> e.getGameLoseAmount()).sum();
+            //游戏赢钱
+            double winAmount = appUserCountList.stream().mapToDouble(e -> e.getGameWinAmount()).sum();
+            //提现手续费
+            double withdrawalCommission = appUserCountList.stream().mapToDouble(e -> e.getWithdrawalCommission()).sum();
+            //游戏佣金
+            double gameCommission = appUserCountList.stream().mapToDouble(e -> e.getGameCommission()).sum();
+            //直播佣金
+            double liveCommission = appUserCountList.stream().mapToDouble(e -> e.getLiveCommission()).sum();
+            //充值赠送
+            double rechargeGive = appUserCountList.stream().mapToDouble(e -> e.getRechargeGive()).sum();
+
+            //计算分红金额 (输-赢)
+//                        double money = (loseAmount - winAmount) - withdrawalCommission - gameCommission - liveCommission;
+            money = (loseAmount - winAmount)  - gameCommission - rechargeGive;
+
+        }
+        return money;
+    }
+
 
 }

+ 10 - 0
game-business/src/main/java/com/game/business/service/impl/AppUserCountServiceImpl.java

@@ -49,6 +49,9 @@ public class AppUserCountServiceImpl extends ServiceImpl<AppUserCountMapper, App
     @Autowired
     private IAppGameBettingService appGameBettingService;
 
+    @Autowired
+    private IAppUserCountDividendService appUserCountDividendService;
+
     @Override
     public List<AppUserCount> getAppUserCount(long userId,String beginTime,String endTIme) {
         LambdaQueryWrapper<AppUserCount> queryWrapper = new LambdaQueryWrapper<AppUserCount>();
@@ -113,6 +116,9 @@ public class AppUserCountServiceImpl extends ServiceImpl<AppUserCountMapper, App
                 if (appUserCount.getGameCommission() != null) {
                     appUserCount.setGameCommission(userCount.getGameCommission() + appUserCount.getGameCommission());
                 }
+                if (appUserCount.getGameBetting() != null) {
+                    appUserCount.setGameBetting(userCount.getGameBetting() + appUserCount.getGameBetting());
+                }
             }
             res = appUserCountMapper.updateById(appUserCount);
         }
@@ -158,6 +164,8 @@ public class AppUserCountServiceImpl extends ServiceImpl<AppUserCountMapper, App
                 ).sum());
                 this.createAppUserCount(appUserCount);
             });
+            //更新周盈亏数据
+            appUserCountDividendService.reloadCache(null,userIds);
         }
     }
 
@@ -214,6 +222,8 @@ public class AppUserCountServiceImpl extends ServiceImpl<AppUserCountMapper, App
                 }
                 this.createAppUserCount(appUserCount);
             });
+            //更新周盈亏数据
+            appUserCountDividendService.reloadCache(null,userIds);
         }
     }
 

+ 23 - 8
game-business/src/main/java/com/game/business/task/AppUserCountTask.java

@@ -8,6 +8,7 @@ import com.game.business.domain.*;
 import com.game.business.service.*;
 import com.game.common.constant.finance.FinTranType1;
 import com.game.common.constant.finance.FinTranType3;
+import com.game.common.core.redis.RedisCache;
 import com.game.common.entity.KeyValue;
 import com.game.common.utils.DateUtils;
 import com.game.common.utils.StringUtils;
@@ -56,6 +57,9 @@ public class AppUserCountTask {
     @Autowired
     private IAppUserCountDividendService appUserCountDividendService;
 
+    @Autowired
+    private RedisCache redisCache;
+
 
     /**
      * 统计用户前一天
@@ -269,14 +273,6 @@ public class AppUserCountTask {
                     String beginTimeStr = DateUtil.format(beginTime,"yyyy-MM-dd");
                     String endTimeStr = DateUtil.format(endTime,"yyyy-MM-dd");
                     List<AppUserCount> appUserCountList = appUserCountService.getAppUserCountNew(appUser.getUserid(),beginTimeStr,endTimeStr);
-                    //查询当前用户盈亏
-                    List<AppUserCount> curUserCouts = appUserCountService.getListByUserId(appUser.getUserid(),beginTimeStr,endTimeStr);
-                    if(null!=curUserCouts && curUserCouts.size()>0){
-                        if(null == appUserCountList){
-                            appUserCountList = new ArrayList<>();
-                        }
-                        appUserCountList.addAll(curUserCouts);
-                    }
                     if (null != appUserCountList && appUserCountList.size() > 0) {
                         //游戏输钱
                         double loseAmount = appUserCountList.stream().mapToDouble(e -> e.getGameLoseAmount()).sum();
@@ -339,6 +335,25 @@ public class AppUserCountTask {
 
     }
 
+    /**
+     * 更新用户下级列表
+     * */
+    public void statisticsTeam(){
+        AppUserAgent query = new AppUserAgent();
+        List<AppUserAgent> userAgents = appUserAgentService.selectAppUserAgentList(query);
+        userAgents.forEach(appUserAgent -> {
+            AppUserAgent updateAgent = new AppUserAgent();
+            updateAgent.setId(appUserAgent.getId());
+            List<String> userIds = userAgents.stream().filter(e->e.getPid().equals(appUserAgent.getUserId())).map(e->{return String.valueOf(e.getUserId());}).collect(Collectors.toList());
+            updateAgent.setSubset(String.join(",",userIds));
+            appUserAgentService.updateAppUserAgent(updateAgent);
+        });
+    }
+
+    public void reloadDividendCache(String dateTime,String topUserId){
+        appUserCountDividendService.reloadCache(dateTime,StringUtils.isBlank(topUserId)?null:Arrays.asList(Long.valueOf(topUserId)));
+    }
+
     /**
      * 金额为负数则转为正数
      * */

+ 3 - 0
game-business/src/main/java/com/game/business/vo/AppAgentTeamVo.java

@@ -56,6 +56,9 @@ public class AppAgentTeamVo {
     @ApiModelProperty(value = "直播分成比例")
     private Long liveRate;
 
+    @ApiModelProperty(value = "团队人数")
+    private Integer teamNum;
+
     /** 保底分红比例 */
     @ApiModelProperty(value = "保底分红比例")
     private Long dividendGuaranteeRate;

+ 6 - 0
game-business/src/main/java/com/game/business/vo/AppUserAgentJournalIndexVO.java

@@ -12,6 +12,12 @@ public class AppUserAgentJournalIndexVO {
     @ApiModelProperty(value = "我的佣金")
     private double myCommission = 0;
 
+    @ApiModelProperty(value = "游戏佣金")
+    private double gameCommission = 0;
+
+    @ApiModelProperty(value = "直播佣金")
+    private double liveCommission = 0;
+
     @ApiModelProperty(value = "团队充值(扣除手续费后的金额)")
     private double teamRecharge = 0;
 

+ 9 - 2
game-business/src/main/resources/mapper/business/AppUserAgentMapper.xml

@@ -9,6 +9,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="userId"    column="user_id"    />
         <result property="pid"    column="pid"    />
         <result property="topId"    column="top_id"    />
+        <result property="subset"    column="subset"    />
         <result property="liveRate"    column="live_rate"    />
         <result property="dividendGuaranteeRate"    column="dividend_guarantee_rate"    />
         <result property="auditStatus"    column="audit_status"    />
@@ -17,7 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectAppUserAgentVo">
-        select id, user_id, pid, top_id, live_rate, dividend_guarantee_rate, audit_status, create_time, update_time from app_user_agent
+        select id, user_id, pid, top_id,subset, live_rate, dividend_guarantee_rate, audit_status, create_time, update_time from app_user_agent
     </sql>
 
     <select id="selectAppUserAgentList" parameterType="com.game.business.domain.AppUserAgent" resultMap="AppUserAgentResult">
@@ -26,6 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userId != null "> and user_id = #{userId}</if>
             <if test="pid != null "> and pid = #{pid}</if>
             <if test="topId != null "> and top_id = #{topId}</if>
+            <if test="subset != null "> and subset = #{subset}</if>
             <if test="liveRate != null "> and live_rate = #{liveRate}</if>
             <if test="dividendGuaranteeRate != null "> and dividend_guarantee_rate = #{dividendGuaranteeRate}</if>
             <if test="auditStatus != null  and auditStatus != ''"> and audit_status = #{auditStatus}</if>
@@ -44,6 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userId != null">user_id,</if>
             <if test="pid != null">pid,</if>
             <if test="topId != null">top_id,</if>
+            <if test="subset != null and subset != ''">subset,</if>
             <if test="liveRate != null">live_rate,</if>
             <if test="dividendGuaranteeRate != null">dividend_guarantee_rate,</if>
             <if test="auditStatus != null">audit_status,</if>
@@ -55,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userId != null">#{userId},</if>
             <if test="pid != null">#{pid},</if>
             <if test="topId != null">#{topId},</if>
+            <if test="subset != null and subset != ''">#{subset},</if>
             <if test="liveRate != null">#{liveRate},</if>
             <if test="dividendGuaranteeRate != null">#{dividendGuaranteeRate},</if>
             <if test="auditStatus != null">#{auditStatus},</if>
@@ -69,6 +73,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="userId != null">user_id = #{userId},</if>
             <if test="pid != null">pid = #{pid},</if>
             <if test="topId != null">top_id = #{topId},</if>
+            <if test="subset != null and subset != ''">subset = #{subset},</if>
             <if test="liveRate != null">live_rate = #{liveRate},</if>
             <if test="dividendGuaranteeRate != null">dividend_guarantee_rate = #{dividendGuaranteeRate},</if>
             <if test="auditStatus != null">audit_status = #{auditStatus},</if>
@@ -183,6 +188,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             c.coin as coin,
             c.diamond_coin as diamondCoin,
             a.pid as pid,
+            IFNULL((LENGTH(a.subset) - LENGTH(REPLACE(a.subset, ',', ''))) + 1,0) as teamNum,
             IFNULL(sum(b.game_betting),0) as bettingAmount,
             IFNULL(sum(b.game_commission),0) as gameCommission,
             IFNULL(sum(b.live_commission),0) as liveCommission,
@@ -192,7 +198,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             IFNULL(sum(b.recharge_give),0) as rechargeGive,
             a.live_rate as liveRate,
             a.dividend_guarantee_rate as dividendGuaranteeRate
-        from app_user_agent as a inner join app_user_count as b on a.user_id = b.user_id left join mugozbg_live.app_user as c on a.user_id = c.userid where (a.pid = #{teamDto.pid} or a.user_id = #{teamDto.pid})
+        from app_user_agent as a inner join app_user_count as b on a.user_id = b.user_id left join mugozbg_live.app_user as c on a.user_id = c.userid
+        where (a.pid = #{teamDto.pid} or a.user_id = #{teamDto.pid})
         <if test="teamDto.userId != null ">
              and a.user_id = #{teamDto.userId}
         </if>

+ 6 - 0
game-common/src/main/java/com/game/common/constant/CacheConstants.java

@@ -41,4 +41,10 @@ public class CacheConstants
      * 登录账户密码错误次数 redis key
      */
     public static final String PWD_ERR_CNT_KEY = "pwd_err_cnt:";
+
+    /**
+     * 用户团队本周盈亏
+     */
+    public static final String USER_AGENT_TEAM_PHASE = "user_agent_team_phase";
+
 }