|
@@ -1,15 +1,29 @@
|
|
|
package com.zanxiang.game.data.serve.service.impl;
|
|
|
|
|
|
+import com.zanxiang.game.data.serve.component.DataPowerComponent;
|
|
|
import com.zanxiang.game.data.serve.pojo.dto.PlayerDataListDTO;
|
|
|
-import com.zanxiang.game.data.serve.pojo.dto.PlayerDataListTotalDTO;
|
|
|
import com.zanxiang.game.data.serve.pojo.dto.PlayerRoleDataListDTO;
|
|
|
-import com.zanxiang.game.data.serve.pojo.dto.PlayerRoleDataListTotalDTO;
|
|
|
+import com.zanxiang.game.data.serve.pojo.enums.GameCategoryEnum;
|
|
|
+import com.zanxiang.game.data.serve.pojo.enums.OrderByEnum;
|
|
|
import com.zanxiang.game.data.serve.pojo.vo.PlayerDataVO;
|
|
|
import com.zanxiang.game.data.serve.pojo.vo.PlayerRoleDataVO;
|
|
|
import com.zanxiang.game.data.serve.service.IPlayerDataService;
|
|
|
import com.zanxiang.game.data.serve.utils.Page;
|
|
|
+import org.apache.commons.lang3.BooleanUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.nutz.dao.Cnd;
|
|
|
+import org.nutz.dao.Dao;
|
|
|
+import org.nutz.dao.Sqls;
|
|
|
+import org.nutz.dao.pager.Pager;
|
|
|
+import org.nutz.dao.sql.Criteria;
|
|
|
+import org.nutz.dao.sql.Sql;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.Collections;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* @author tianhua
|
|
|
* @time 2023/9/6
|
|
@@ -18,6 +32,11 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class PlayerDataServiceImpl implements IPlayerDataService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private Dao dao;
|
|
|
+ @Autowired
|
|
|
+ private DataPowerComponent dataPowerComponent;
|
|
|
+
|
|
|
/**
|
|
|
* 玩家列表
|
|
|
* @param dto PlayerDataListDTO
|
|
@@ -25,17 +44,145 @@ public class PlayerDataServiceImpl implements IPlayerDataService {
|
|
|
*/
|
|
|
@Override
|
|
|
public Page<PlayerDataVO> getPlayerDataList(PlayerDataListDTO dto) {
|
|
|
- return null;
|
|
|
- }
|
|
|
+ List<Long> gameIds = dto.getGameId() == null ? dataPowerComponent.getSubGameIdList() : Collections.singletonList(dto.getGameId());
|
|
|
+ List<Long> pitcherIds = StringUtils.isBlank(dto.getPitcherId()) ? dataPowerComponent.getSubUserIdList() : Collections.singletonList(Long.valueOf(dto.getPitcherId()));
|
|
|
|
|
|
- /**
|
|
|
- * 玩家列表总计一栏
|
|
|
- * @param dto PlayerDataListTotalDTO
|
|
|
- * @return PlayerDataVO
|
|
|
- */
|
|
|
- @Override
|
|
|
- public PlayerDataVO getPlayerDataListTotal(PlayerDataListTotalDTO dto) {
|
|
|
- return null;
|
|
|
+ //创建查询条件
|
|
|
+ Criteria cri = Cnd.cri();
|
|
|
+ if (StringUtils.isNotBlank(dto.getSourceSystem())) {
|
|
|
+ cri.where().andEquals("source_system", dto.getSourceSystem());
|
|
|
+ }
|
|
|
+ if (dto.getUserId() != null) {
|
|
|
+ cri.where().andEquals("id", dto.getUserId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(dto.getUserName())) {
|
|
|
+ cri.where().andLike("user_name", dto.getUserName());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(dto.getNickname())) {
|
|
|
+ cri.where().andLike("nick_name", dto.getNickname());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(dto.getMobile())) {
|
|
|
+ cri.where().andEquals("mobile", dto.getMobile());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(dto.getRegIp())) {
|
|
|
+ cri.where().andEquals("reg_ip", dto.getRegIp());
|
|
|
+ }
|
|
|
+ if (pitcherIds != null) {
|
|
|
+ cri.where().andInList("pitcher_id", pitcherIds);
|
|
|
+ }
|
|
|
+ //判断是否绑定手机
|
|
|
+ if (BooleanUtils.isFalse(dto.getIsBindMobile())) {
|
|
|
+ cri.where().andIsNull("mobile");
|
|
|
+ }
|
|
|
+ if (BooleanUtils.isTrue(dto.getIsBindMobile())) {
|
|
|
+ cri.where().andNotIsNull("mobile").andNotEquals("mobile", "null");
|
|
|
+ }
|
|
|
+ //判断是否实名
|
|
|
+ if (BooleanUtils.isFalse(dto.getIsAuth())) {
|
|
|
+ //未实名
|
|
|
+ cri.where().andEquals("authentication", 0);
|
|
|
+ }
|
|
|
+ if (BooleanUtils.isTrue(dto.getIsAuth())) {
|
|
|
+ //实名
|
|
|
+ cri.where().andInList("authentication", List.of(1L, 2L));
|
|
|
+ }
|
|
|
+ if (dto.getCpId() != null) {
|
|
|
+ cri.where().andEquals("cp_id", dto.getCpId());
|
|
|
+ }
|
|
|
+ if (gameIds != null) {
|
|
|
+ cri.where().andInList("game_id", gameIds);
|
|
|
+ }
|
|
|
+ if (dto.getGameCategoryId() != null) {
|
|
|
+ cri.where().andEquals("game_category_id", dto.getGameCategoryId());
|
|
|
+ }
|
|
|
+ if (dto.getRechargeBeginDate() != null && dto.getRechargeEndDate() != null) {
|
|
|
+ //充值时间
|
|
|
+ cri.where().andBetween("last_recharge_time", dto.getRechargeBeginDate(), dto.getRechargeEndDate());
|
|
|
+ }
|
|
|
+ //判断是否充值
|
|
|
+ if (BooleanUtils.isFalse(dto.getIsRecharge())) {
|
|
|
+ //未充值 充值金额为0
|
|
|
+ cri.where().andEquals("recharge_money", 0);
|
|
|
+ }
|
|
|
+ if (BooleanUtils.isTrue(dto.getIsAuth())) {
|
|
|
+ //充值金额大于0
|
|
|
+ cri.where().andNotEquals("recharge_money", 0);
|
|
|
+ }
|
|
|
+ if (dto.getStatus() != null) {
|
|
|
+ cri.where().andEquals("status", dto.getStatus());
|
|
|
+ }
|
|
|
+ if (dto.getChannelId() != null) {
|
|
|
+ //渠道id
|
|
|
+ cri.where().andEquals("agent_id", dto.getChannelId());
|
|
|
+ }
|
|
|
+ if (StringUtils.isNotBlank(dto.getAccountId())) {
|
|
|
+ cri.where().andEquals("account_id", dto.getAccountId());
|
|
|
+ }
|
|
|
+ if (dto.getBeginDate() != null && dto.getEndDate() != null) {
|
|
|
+ //注册时间
|
|
|
+ cri.where().andBetween("create_time", dto.getBeginDate(), dto.getEndDate());
|
|
|
+ }
|
|
|
+ if (dto.getRegPayIntervalTimeMin() != null) {
|
|
|
+ //充值到注册的最小间隔时间(分)
|
|
|
+ cri.where().andGTE("TIMESTAMPDIFF(MINUTE, create_time, last_recharge_time)", dto.getRegPayIntervalTimeMin());
|
|
|
+ }
|
|
|
+ if (dto.getRegPayIntervalTimeMax() != null) {
|
|
|
+ //充值到注册的最大间隔时间(分)
|
|
|
+ cri.where().andLTE("TIMESTAMPDIFF(MINUTE, create_time, last_recharge_time)", dto.getRegPayIntervalTimeMax());
|
|
|
+ }
|
|
|
+ //判断是否创角
|
|
|
+ if (BooleanUtils.isFalse(dto.getCreateRole())) {
|
|
|
+ //未创角 创角数为0
|
|
|
+ cri.where().andEquals("role_count", 0);
|
|
|
+ }
|
|
|
+ if (BooleanUtils.isTrue(dto.getCreateRole())) {
|
|
|
+ //创角数大于0
|
|
|
+ cri.where().andNotEquals("role_count", 0);
|
|
|
+ }
|
|
|
+ if (dto.getRoleCountMin() != null) {
|
|
|
+ //创角最小数
|
|
|
+ cri.where().andGTE("role_count", dto.getRoleCountMin());
|
|
|
+ }
|
|
|
+ if (dto.getRoleCountMax() != null) {
|
|
|
+ //创角最大数
|
|
|
+ cri.where().andLTE("role_count", dto.getRoleCountMax());
|
|
|
+ }
|
|
|
+
|
|
|
+ //设置pager
|
|
|
+ Pager pager = dao.createPager(dto.getPageNum(), dto.getPageSize());
|
|
|
+ //设置查询的记录数
|
|
|
+ Sql countSql = Sqls.create(getPlayerDataListCountSql() + cri);
|
|
|
+ countSql.setCallback(Sqls.callback.integer());
|
|
|
+ dao.execute(countSql);
|
|
|
+ pager.setRecordCount(countSql.getInt());
|
|
|
+ //默认排序
|
|
|
+ if (StringUtils.isBlank(dto.getSortType())) {
|
|
|
+ dto.setSortType(OrderByEnum.DESC.getOrderType());
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(dto.getSortFiled())) {
|
|
|
+ cri.getOrderBy().orderBy("update_time", dto.getSortType());
|
|
|
+ } else {
|
|
|
+ cri.getOrderBy().orderBy(dto.getSortFiled(), dto.getSortFiled());
|
|
|
+ }
|
|
|
+ //创建sql查询数据
|
|
|
+ Sql sql = Sqls.create(getPlayerDataListSql() + cri);
|
|
|
+ //sql设置pager
|
|
|
+ sql.setPager(pager);
|
|
|
+ //设置自定义回传对象
|
|
|
+ sql.setCallback(Sqls.callback.entities());
|
|
|
+ sql.setEntity(dao.getEntity(PlayerDataVO.class));
|
|
|
+ //执行sql
|
|
|
+ dao.execute(sql);
|
|
|
+ //处理结果
|
|
|
+ List<PlayerDataVO> list = sql.getList(PlayerDataVO.class).stream().map(vo -> {
|
|
|
+ //通过枚举得到游戏应用类型名称
|
|
|
+ if (vo.getGameCategoryId() != null) {
|
|
|
+ vo.setGameCategoryName(GameCategoryEnum.getNameByCategory(vo.getGameCategoryId()));
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ return new Page<>(list, pager);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -49,13 +196,196 @@ public class PlayerDataServiceImpl implements IPlayerDataService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 玩家角色列表总计一栏
|
|
|
- * @param dto PlayerRoleDataListTotalDTO
|
|
|
- * @return PlayerRoleDataVO
|
|
|
+ * 查询玩家列表数据SQL
|
|
|
+ * @return String
|
|
|
*/
|
|
|
- @Override
|
|
|
- public PlayerRoleDataVO getPlayerRoleDataListTotal(PlayerRoleDataListTotalDTO dto) {
|
|
|
- return null;
|
|
|
+ private String getPlayerDataListSql() {
|
|
|
+ return """
|
|
|
+ SELECT
|
|
|
+ *
|
|
|
+ FROM (
|
|
|
+ select
|
|
|
+ a.source_system as source_system ,
|
|
|
+ a.id as id ,
|
|
|
+ a.username as username ,
|
|
|
+ a.nickname as nickname ,
|
|
|
+ a.ip as reg_ip,
|
|
|
+ a.create_time as create_time ,
|
|
|
+ a.agent_id as agent_id ,
|
|
|
+ if(a.agent_id = 0, '自然量', c.agent_name) as agent_name ,
|
|
|
+ f.id as cp_id ,
|
|
|
+ f.cp_name as cp_name ,
|
|
|
+ a.game_id as game_id ,
|
|
|
+ e.game_name as game_name ,
|
|
|
+ e.classify as game_category_id ,
|
|
|
+ d.zx_pitcher_name as pitcher_name ,
|
|
|
+ d.zx_pitcher_id as pitcher_id ,
|
|
|
+ c.account_id as account_id,
|
|
|
+ c.account_type as account_type,
|
|
|
+ a.mobile as mobile ,
|
|
|
+ IFNULL(i.amount, 0) as recharge_money ,
|
|
|
+ IFNULL(i.amount_count, 0) as recharge_count,
|
|
|
+ IFNULL(b.role_num, 0) as role_count,
|
|
|
+ b.create_time as update_time ,
|
|
|
+ b.last_recharge_time as last_recharge_time,
|
|
|
+ a.status as status ,
|
|
|
+ b.role_name as last_game_role_name ,
|
|
|
+ h.id as relation_game_id ,
|
|
|
+ h.game_name as relation_game_name ,
|
|
|
+ a.relation_user_id as relation_user_id ,
|
|
|
+ a.relation_create_time as relation_create_time ,
|
|
|
+ TIMESTAMPDIFF(SECOND , a.create_time, b.last_recharge_time) as reg_pay_time_diff
|
|
|
+ FROM dm_game_order.t_game_user a
|
|
|
+ left join (
|
|
|
+ select
|
|
|
+ a.source_system ,
|
|
|
+ a.user_id ,
|
|
|
+ a.role_name ,
|
|
|
+ a.create_time ,
|
|
|
+ b.last_recharge_time ,
|
|
|
+ a.num,
|
|
|
+ c.role_num
|
|
|
+ from (
|
|
|
+ select
|
|
|
+ source_system ,
|
|
|
+ user_id ,
|
|
|
+ role_name ,
|
|
|
+ create_time ,
|
|
|
+ ROW_NUMBER() OVER(PARTITION BY user_id,source_system order by create_time desc) as num
|
|
|
+ from dm_game_order.t_user_login_log
|
|
|
+ ) a
|
|
|
+ left join (
|
|
|
+ select
|
|
|
+ source_system as b_source_system,
|
|
|
+ user_id as b_user_id,
|
|
|
+ role_name as role_name,
|
|
|
+ last_recharge_time ,
|
|
|
+ ROW_NUMBER() OVER(PARTITION BY user_id,source_system order by last_recharge_time desc) as b_num
|
|
|
+ from dm_game_order.t_game_user_role
|
|
|
+ ) b on a.user_id = b.b_user_id and a.source_system = b.b_source_system and a.num= b.b_num
|
|
|
+ left join (
|
|
|
+ select
|
|
|
+ source_system as c_source_system,
|
|
|
+ user_id as c_user_id,
|
|
|
+ count(user_id) as role_num
|
|
|
+ from dm_game_order.t_game_user_role
|
|
|
+ group by user_id , source_system
|
|
|
+ ) c on a.user_id = c.c_user_id and a.source_system = c.c_source_system
|
|
|
+ WHERE a.num = 1
|
|
|
+ )b on a.id =b.user_id and a.source_system = b.source_system
|
|
|
+ left join dm_game_order.t_pitcher_agent c on a.agent_id =c.id and a.source_system = c.source_system
|
|
|
+ left join dm_game_order.t_pitcher_map d on c.pitcher_id =d.zx_pitcher_id and c.source_system = d.source_system
|
|
|
+ left join dm_game_order.t_game e on a.game_id =e.id and a.source_system = e.source_system
|
|
|
+ left join dm_game_order.t_cp f on e.cp_id =f.id and e.source_system = f.source_system
|
|
|
+ left join dm_game_order.t_game_user g on a.relation_user_id = g.id and a.source_system = g.source_system
|
|
|
+ left join dm_game_order.t_game h on g.game_id = h.id and g.source_system = h.source_system
|
|
|
+ LEFT JOIN (
|
|
|
+ select
|
|
|
+ user_id ,
|
|
|
+ source_system ,
|
|
|
+ SUM(real_amount) as amount ,
|
|
|
+ COUNT(user_id) as amount_count
|
|
|
+ from dm_game_order.t_game_order
|
|
|
+ group by user_id , source_system
|
|
|
+ ) i on a.id = i.user_id and a.source_system = i.source_system
|
|
|
+ ) k
|
|
|
+ """;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询记录的条数SQL
|
|
|
+ * @return String
|
|
|
+ */
|
|
|
+ private String getPlayerDataListCountSql() {
|
|
|
+ return """
|
|
|
+ SELECT
|
|
|
+ COUNT(1)
|
|
|
+ FROM (
|
|
|
+ select
|
|
|
+ a.source_system as source_system ,
|
|
|
+ a.id as id ,
|
|
|
+ a.username as username ,
|
|
|
+ a.nickname as nickname ,
|
|
|
+ a.ip as reg_ip,
|
|
|
+ a.create_time as create_time ,
|
|
|
+ a.agent_id as agent_id ,
|
|
|
+ if(a.agent_id = 0, '自然量', c.agent_name) as agent_name ,
|
|
|
+ f.id as cp_id ,
|
|
|
+ f.cp_name as cp_name ,
|
|
|
+ a.game_id as game_id ,
|
|
|
+ e.game_name as game_name ,
|
|
|
+ e.classify as game_category_id ,
|
|
|
+ d.zx_pitcher_name as pitcher_name ,
|
|
|
+ d.zx_pitcher_id as pitcher_id ,
|
|
|
+ c.account_id as account_id,
|
|
|
+ c.account_type as account_type,
|
|
|
+ a.mobile as mobile ,
|
|
|
+ IFNULL(i.amount, 0) as recharge_money ,
|
|
|
+ IFNULL(i.amount_count, 0) as recharge_count,
|
|
|
+ IFNULL(b.role_num, 0) as role_count,
|
|
|
+ b.create_time as update_time ,
|
|
|
+ b.last_recharge_time as last_recharge_time,
|
|
|
+ a.status as status ,
|
|
|
+ b.role_name as last_game_role_name ,
|
|
|
+ h.id as relation_game_id ,
|
|
|
+ h.game_name as relation_game_name ,
|
|
|
+ a.relation_user_id as relation_user_id ,
|
|
|
+ a.relation_create_time as relation_create_time
|
|
|
+ FROM dm_game_order.t_game_user a
|
|
|
+ left join (
|
|
|
+ select
|
|
|
+ a.source_system ,
|
|
|
+ a.user_id ,
|
|
|
+ a.role_name ,
|
|
|
+ a.create_time ,
|
|
|
+ b.last_recharge_time ,
|
|
|
+ a.num,
|
|
|
+ c.role_num
|
|
|
+ from (
|
|
|
+ select
|
|
|
+ source_system ,
|
|
|
+ user_id ,
|
|
|
+ role_name ,
|
|
|
+ create_time ,
|
|
|
+ ROW_NUMBER() OVER(PARTITION BY user_id,source_system order by create_time desc) as num
|
|
|
+ from dm_game_order.t_user_login_log
|
|
|
+ ) a
|
|
|
+ left join (
|
|
|
+ select
|
|
|
+ source_system as b_source_system,
|
|
|
+ user_id as b_user_id,
|
|
|
+ role_name as role_name,
|
|
|
+ last_recharge_time ,
|
|
|
+ ROW_NUMBER() OVER(PARTITION BY user_id,source_system order by last_recharge_time desc) as b_num
|
|
|
+ from dm_game_order.t_game_user_role
|
|
|
+ ) b on a.user_id = b.b_user_id and a.source_system = b.b_source_system and a.num= b.b_num
|
|
|
+ left join (
|
|
|
+ select
|
|
|
+ source_system as c_source_system,
|
|
|
+ user_id as c_user_id,
|
|
|
+ count(user_id) as role_num
|
|
|
+ from dm_game_order.t_game_user_role
|
|
|
+ group by user_id , source_system
|
|
|
+ ) c on a.user_id = c.c_user_id and a.source_system = c.c_source_system
|
|
|
+ WHERE a.num = 1
|
|
|
+ )b on a.id =b.user_id and a.source_system = b.source_system
|
|
|
+ left join dm_game_order.t_pitcher_agent c on a.agent_id =c.id and a.source_system = c.source_system
|
|
|
+ left join dm_game_order.t_pitcher_map d on c.pitcher_id =d.zx_pitcher_id and c.source_system = d.source_system
|
|
|
+ left join dm_game_order.t_game e on a.game_id =e.id and a.source_system = e.source_system
|
|
|
+ left join dm_game_order.t_cp f on e.cp_id =f.id and e.source_system = f.source_system
|
|
|
+ left join dm_game_order.t_game_user g on a.relation_user_id = g.id and a.source_system = g.source_system
|
|
|
+ left join dm_game_order.t_game h on g.game_id = h.id and g.source_system = h.source_system
|
|
|
+ LEFT JOIN (
|
|
|
+ select
|
|
|
+ user_id ,
|
|
|
+ source_system ,
|
|
|
+ SUM(real_amount) as amount ,
|
|
|
+ COUNT(user_id) as amount_count
|
|
|
+ from dm_game_order.t_game_order
|
|
|
+ group by user_id , source_system
|
|
|
+ ) i on a.id = i.user_id and a.source_system = i.source_system
|
|
|
+ ) k
|
|
|
+ """;
|
|
|
}
|
|
|
|
|
|
}
|