后台经济系统内容明细

交接经济系统,写这篇文章明确每一个页面逻辑思路

一、经济系统管理

1.1、区间配置

为了经济概况首页统计每个功能的每个区间的值,故有这个需求
目录:com.huishuo.game_manager.controller
接口类:EconSectionConfigController.java

1.2、数据字典

经济系统用到的数据字典表后台功能
目录:com.huishuo.game_manager.controller
接口类:EconDataDictionaryController.java

1.3、mfrId类别管理

功能
增删改查

为了每个道具干了什么用途而制定的一个道具配置功能
两种新增方式:新增和导入
道具区分区分免费赠送和充值获得两种

1.4、物品价值管理

目录:com.huishuo.game_manager.controller
接口类:SysPropValueController.java

功能:
增删改查

1.5、各个模块玩法配置

目录:com.huishuo.game_manager.business.econ.controller
接口类:EconModuleCfgController.java

功能
增改查
获取父级列表
配置列表
禁用/启用

二、各模块统计

目录:com.huishuo.game_manager.business.econ.controller
接口类:EconModuleStatisticsController.java

2.1、各模块统计-今日概况

逻辑:

  • 1、获取最新时间、渠道、玩家类型
  • 2、查询今日 各个大模块产消比例 = 模块产出值 / 模块投入值*100%
  • 3、获取最新时间的前一天
  • 4、查询昨日 各个大模块产消比例 = 模块产出值 / 模块投入值*100%

image.png

  • econ_module_cfg(经济系统-各模块统计(分钟))
  • econ_module_cfg(经济系统配置)
"SELECT cfg2.id ,IFNULL(cfg2.`name`,'未命名') `name`,IF(SUM(input)=0,0,CAST((SUM(output)*100/SUM(input)) AS DECIMAL (18,2))) ratio " +
                "FROM `econ_module_statistics_datetime` module " +
                "LEFT JOIN data_bi.econ_module_cfg cfg ON module.module_id=cfg.id AND cfg.type=1 " +
                "LEFT JOIN data_bi.econ_module_cfg cfg2 ON cfg2.id=cfg.parent_id AND cfg2.type=0 " +
                condition + " GROUP BY date,cfg2.id";

2.2、玩家流通数据-二级数据

逻辑:

  • 1、查询最新数据时间、条件做个判断
  • 2、根据父类id(等级Id)查询各个模块产消比

  • 经济系统-各模块统计(econ_module_statistics_date)
  • 经济系统配置查询(data_bi.econ_module_cfg)
"SELECT date,module_id moduleId,`name`,CONCAT(IF (SUM(input)=0,0,CAST((SUM(output)*100/SUM(input)) AS DECIMAL (18,2))),'%') ratio " +
                "FROM `econ_module_statistics_date` module " +
                "LEFT JOIN data_bi.econ_module_cfg cfg ON module.module_id=cfg.id AND cfg.type=1 " +
                condition + " AND cfg.parent_id=" + parentId +
                " GROUP BY date,module_id";
  • 3、根据模块id 查询各个模块产消比详情

  • econ_module_statistics_datetime(经济系统-各模块统计(分钟))
"SELECT date,SUM(input) input,SUM(output) output,SUM(input)-SUM(output) tax" +
                ",CONCAT(IF (SUM(input)=0,0,CAST((SUM(output)*100/SUM(input)) AS DECIMAL (18,2))),'%') ratio " +
                ",SUM(player_count)player_count " +
                ",SUM(player_count_negative)player_count_negative " +
                ",SUM(player_count_positive)player_count_positive " +
                ",CONCAT(IF (SUM(player_count)=0,0,CAST((SUM(player_count_positive)*100/SUM(player_count)) AS DECIMAL (18,2))),'%') player_count_positive_ratio " +
                "FROM `econ_module_statistics_datetime` module " +
                condition + " AND module_id=" + moduleId +
                " GROUP BY date";

三、玩家数据

目录:com.huishuo.game_manager.business.econ.controller
接口类:EconPlayerDataController.java

3.1、玩家流通数据页面(playerCirculationData)

方法:今日概况(todaysSituation)

根据条件查询 统计后的玩家数据-玩家流通数据表


econ_player_circulation_datetime(经济系统-玩家数据-玩家流通数据)
逻辑:

  • 1、查询出道具列表
  • 2、循环流通类型带来的三种类型(赠送、公会、漂流瓶)
  • 3、查询今日和昨天的流通数据

方法:二级数据(detail)

根据日期、渠道、vip、玩家类型、该所有道具(circulation_prop_id)为条件查询出实时和按天的数据


econ_data_dictionary(经济系统配置)
econ_player_circulation_datetime(经济系统-玩家数据-玩家流通数据(分钟))
econ_player_circulation_date(经济系统-玩家数据-玩家流通数据(天))
逻辑:

  • 获取当日数据和经济系统配置里面玩家流通数据的数据集合
  • 查询玩家数据-玩家流通数据(SUM(give_count+receive_count) totalCount)
  • 不同类型返回不同的列表表头数据

核心sql
image.png

方法:玩家流通数据-3-4级数据(detail)

逻辑:

  • 检查玩家类型
  • 获取流通类型
  • 格式化渠道ID和开始结束时间以及当日七日
  • 根据等级为3或者4分别处理逻辑(道具id查询查询按天或是时间的统计Sum的数据)

核心sql
image.png

方法:最后一层数据的vip分布-人数(detail)

统计各个vip下的人员分布人数

逻辑:

  • 得出各个条件
  • 根据等级为3或者4算出时间或者天的vip分布
    image.png

3.2、玩家变化信息规则页面(playerChangeRuleCfgIndex)

计算每个表的某个字段的(求和、计数、最大值、最小值、平均数)的一个功能
有增删改查
新增单表,双表的两种方式(双表是两个单表的加减乘除一个功能)
image.png

3.3、玩家流水数据页面(playerFlowData)

玩家流水数据-列表

逻辑:

  • 得出各个条件(渠道、渠道组合、玩家类型、道具ID、vip、时间、房间)
  • 查询系统产生值
  • 查询系统产生值 econ_mfr_prop_date
  • 不同的mfr统计然后一起返回列表
    image.png

点击表头计算出VIP分布、房间分布、区间分布

想统计某一列头的数据在vip、房间、区间分布的各种数据
例如vip分布:统计这个vip下的该类型的总和(产出、消耗)
image.png

玩家流水数据-VIP分布玩家

例如玩家在某个范围内的区间分布(用到Hivin)
image.png

四、经济系统

类:EconEconomicSituationController.java

经济概况(todaysSituation)

备注:
EconSituationStat 接口
流程:
todaysSituation-->EconSituationStat-->(方法:EconType getEconType())-->具体controller

四、经济系统

类:EconEconomicSituationController.java

4.1、经济概况(todaysSituation)

备注:
EconSituationStat 接口
流程:
todaysSituation-->EconSituationStat-->(方法:EconType getEconType())-->具体controller
img.png

今日概况

  • 接口:econ/economicSituation/todaysSituation
  • 返回数据类型:
code: 0
date: "2021-03-10 11:00:00"
rmbPayValue: 100000
situation: [{name: "OUTPUT", today: 0, yesterday: 0, date: "2021-03-10 11:00:00"},…]
traceId: "c660443e"

概况数据

  • 接口:econ/economicSituation/situationList
  • 返回数据类型:
code: 0
columns: [{name: "时间", key: "date"}, {name: "总充值", key: "RECHARGE"}, {name: "系统产出值", key: "OUTPUT"},…]
data: [{POOL_INVENTORY2: -1027998041, date: "2021-03-04 11:00:00", INVENTORY: 1000000, OUTPUT: 0,…},…]
dayData: [{POOL_INVENTORY2: -1029651721, date: "2021-03-04", INVENTORY: 95393910, POOL_INVENTORY: -1653680,…},…]
traceId: "4cdc1566"

4.2、总充值

当日总充值

  • 接口:econ/economicSituation/detail
    数据使用总充值接口汇总

总充值

  • 接口:econ/economicSituation/detail
  • 返回数据类型:
code: 0
detail: {dayData: [{date: "2021-03-04", activeValue: 30.02, payValue: 0},…],…}
chartData: [{date: "2021-03-09 11:00:00", activeValue: 0, payValue: 0},…]
columns: [{name: "时间", key: "date"}, {name: "系统付费价值充值", key: "payValue", interval: true},…]
data: [{date: "2021-03-04 11:00:00", activeValue: 30, payValue: 0},…]
dayData: [{date: "2021-03-04", activeValue: 30.02, payValue: 0},…]
rmbPayValue: 100000
traceId: "171bc0ce"

关键数据

  • 接口:econ/economicSituation/threeLevelDetail
  • 返回数据类型:
code: 0
detail: {data: [], dayData: [],…}
columns: [{name: "付费点", key: "payPoint"}, {name: "当日充值金额", key: "payAmount"},…]
data: []
dayData: []
traceId: "577298f2"

4.3、系统产出值

当日系统产出值

  • 接口:econ/economicSituation/detail
  • 返回数据类型:
code: 0
detail: {dayData: [], chartData: [], data: [],…}
chartData: []
columns: [{name: "时间", key: "date"}, {key: "PayGold", name: "付费金币价值", interval: true},…]
data: []
dayData: []
rmbPayValue: 100000
traceId: "7897e1fe"

系统产出值

  • 接口:econ/economicSituation/threeLevelDetail
  • 返回数据类型:
detail: {,…}
columns: [{name: "时间", key: "date"}, {name: "充值获取", key: "payValue", interval: true},…]
0: {name: "时间", key: "date"}
1: {name: "充值获取", key: "payValue", interval: true}
2: {name: "免费赠送", key: "freeValue", interval: true}
data: [{date: "2021-03-04 11:00:00", payValue: 0, freeValue: 0},…]
dayData: [{date: "2021-03-04", payValue: 0, freeValue: 0}, {date: "2021-03-05", payValue: 0, freeValue: 0},…]
traceId: "dc40772b"

关键数据

  • 接口:econ/economicSituation/threeLevelDetail
  • 返回数据类型:
detail: {lastLevel: true, dayData: [], data: [], columns: [{name: "时间", key: "date"}]}
columns: [{name: "时间", key: "date"}]
0: {name: "时间", key: "date"}
data: []
dayData: []
lastLevel: true
traceId: "3ffb5c4c"

4.4、系统话费兑换

当日系统话费兑换

接口:econ/economicSituation/detail

系统话费兑换

接口:econ/economicSituation/detail

关键数据

接口:econ/economicSituation/threeLevelDetail

4.5、系统付费税收

当日系统付费税收

接口:econ/economicSituation/detail

系统付费税收

接口:econ/economicSituation/detail

关键数据

接口:econ/economicSituation/threeLevelDetail

4.5、系统库存变化

统一接口:econ/economicSituation/detail
img_1.png

当日系统库存

系统库存

其他库存

VIP

4.6、系统库存

统一接口:econ/economicSituation/detail

当日系统库存

系统库存

其他库存

VIP

4.7、池子库存变化

当日池子库存变化

接口:econ/economicSituation/detail

池子库存变化

接口:econ/economicSituation/detail

关键数据

接口:econ/economicSituation/threeLevelDetail

4.8、池子库存

当日池子库存

接口:econ/economicSituation/detail

池子库存

接口:econ/economicSituation/detail

  • 返回数据类型:
code: 0
detail: {,…}
chartData: [{date: "2021-03-09 11:00:00", CouponPool: -29611234, GoldPool: 0, SummonPool: -2999432500,…},…]
columns: [{name: "时间", key: "date"}, {name: "合计", key: "total"}, {name: "金池", key: "GoldPool"},…]
0: {name: "时间", key: "date"}
1: {name: "合计", key: "total"}
2: {name: "金池", key: "GoldPool"}
3: {name: "奖券池", key: "CouponPool"}
4: {name: "转化池", key: "ConversionPool"}
5: {name: "召唤池", key: "SummonPool"}
6: {name: "房间彩金", key: "RoomPool"}
7: {name: "福利池", key: "WelfarePool"}
8: {name: "炮炮流转池", key: "SiloCirculationPool"}
9: {name: "击杀流转池", key: "KillCirculationPool"}
10: {name: "龙珠道具池", key: "DragonPropPool"}
11: {name: "龙珠福利池", key: "DragonWelfarePool"}
12: {name: "小游戏记录值", key: "SmallGamePool"}
13: {name: "朱雀彩金池", key: "WorldBossPool"}
14: {name: "付费暴击池", key: "BaojiPayPool"}
15: {name: "免费暴击池", key: "BaojiFreePool"}
16: {name: "波动池", key: "FluctuatePool"}
17: {name: "能量池", key: "EnergyPool"}
data: [{date: "2021-03-04 11:00:00", CouponPool: -29624775, GoldPool: 0, SummonPool: -2999432500,…},…]
dayData: [{date: "2021-03-03 23:59:59", CouponPool: -29624775, GoldPool: 0, SummonPool: -2999432500,…},…]
rmbPayValue: 100000
traceId: "a4625a56"

关键数据

接口:econ/economicSituation/threeLevelDetail

code: 0
detail: {chartData: [], data: [], columns: [{name: "时间", key: "date"}, {name: "合计", key: "total"}],…}
chartData: []
columns: [{name: "时间", key: "date"}, {name: "合计", key: "total"}]
0: {name: "时间", key: "date"}
1: {name: "合计", key: "total"}
data: []
dayData: []
traceId: "40ba739f"

4.9、平衡计算

平衡计算列表

接口:econ/economicSituation/detail

{traceId: "c48555fe", code: 0, detail: {,…}, rmbPayValue: 100000}
code: 0
detail: {,…}
columns: [{name: "时间", key: "date"}, {name: "总体产生比例", key: "overallGenerationRatio"},…]
dayData: [{date: "2021-03-04", overallGenerationRatio: "0.00%", rechargePayValueGenerationRatio: "0.00%",…},…]
rmbPayValue: 100000
traceId: "c48555fe"

五、management(流水进入)

类名:StartupListener.java
方法:contextInitialized()

  • 1、解析日志文件
  • 2、登录前打点存储
  • 3、用户反馈存储
  • 4、登录前打点存储、用户反馈--存储、读取日志文件
  • 5、获取在线人数
    • cmd接口:gm_query_online_user_number
    • 入库:data_bi.bi_live_data、
      data_bi.bi_online_number
    • 预警
    • 福利配置
  • 6、每小时更新,在线人数
    • cmd接口:gm_query_online_user_number
    • 入库:data_bi.bi_live_data_h
  • 7、每小时更新,房间人数
    • 查询:data_tslog.room_enter_flow
    • 入库:data_bi.bi_room_active_number_h
  • 8、每小时更新,悬赏任务
    • 查询:data_tslog.task_off_reward_flow、
      data_catchfish_develop.physical_value、
      data_tslog.user_attend_task_off_reward_flow
    • 入库:data_bi.task_off_reward_statistics
    • 更新:data_bi.task_off_reward_statistics
      每日更新
  • 9、(2 道具库存)
    • 查询:account_info、user_prop、data_bi_pay_value.active_player
    • 入库:data_bi.op_prop_inventory
  • 10、(1 玩家信息)
    • 查询:data_bi_pay_value.active_player、
      data_bi_pay_value.lost_player
    • 更新:lost_player表:userInfo、redPacket、redPacket字段
  • 11、(3 卡密库存)
    • 查询:card_exchange(录入、消耗、库存)
    • 入库:op_cards_close_inventory(type分别为三种类型)

每天定时更新,玩家数据-玩家输赢

  • 12、当天所有比赛统计v9
  • 14、海王统计 每天执行
  • 15、海王道具次数统计 每天执行
  • 16、夺宝惩罚奖励 每天执行
  • 17、桌子 每天执行
  • 18、统计玩家道具新增消耗流水
  • 19、玩家分享 每天执行

六、management(mongodb)

6.1、库存来源

类:EconInventoryTask.java
方法:mongodbInventoryTask
来源:mongodb
入库:data_bi.econ_inventory

邮箱库存

1、组织字段:Fields类型字段、
image.png
2、mongoDb查询数据
3、拼接字段再更新入库
image.png

漂流瓶库存

代码和邮件一样

工会库存

代码和邮件一样

6.2、实时库存(cron = "0 0/15 * * * ?")

类:EconInventoryTask.java
方法:poolInventoryTask
来源:db_game.game_room_pool
入库:data_bi.econ_pool_inventory
1、定义房间库存字符串

SELECT t.pool_type 'pool_id',id,IFNULL(sum(t.pool),0) 'pool' FROM db_game.game_room_pool t GROUP BY t.pool_type,id UNION SELECT 10001 'pool_id',id,IFNULL(sum(t.pool),0) 'pool' FROM db_game.energy_pool t GROUP BY id

2、执行查询sql
3、拼接即将插入的数据
4、入库

INSERT INTO `data_bi`.`econ_pool_inventory` (`date_time`, `pool_id`, `pool_name`,`id`,`inventory`) VALUES

6.3、实时每隔15分组更新库存(cron = "0 0/15 * * * ?")

类:EconInventoryTask.java
方法:run
来源1:db_game.game_room_pool
入库1:data_bi.econ_inventory
公会来源2:gang_presd_warehouse
公会入库2:data_bi.econ_inventory

  • 1、遍历所有类型除了15、30、1小时以外的活跃集合
  • 2、统计数据
    • 2.1、准备一个库存sql集合枚举
private static String userInfoSql = "select a.channel_id 'channel_id',%s  'vip',%s 'play_type',sum(u.pay_gold) 'pay_gold',sum(u.lottery) 'lottery',sum(u.energy) 'energy' from db_game.user_info u,db_game.account_info a " +
            "where u.uid = a.uid0 " +
            " %s "+
            " %s "+
            "group by a.channel_id %s";
    private static String userPropSql = "select a.channel_id 'channel_id',%s 'vip',%s 'play_type',p.id 'id',sum(p.quantity) 'inventory'  from db_game.user_info u,db_game.account_info a,db_game.user_prop p " +
            " where u.uid = a.uid0 " +
            " and p.uid = u.uid " +
            " and p.id in ( :ids ) " +
            " %s "+
            " %s "+
            " group by a.channel_id,p.id %s";
    private static String payDishSql=" select a.channel_id,%s 'vip',%s 'play_type',2002 'id',sum(c.pay_dish) inventory from db_game.user_info u,db_game.account_info a,db_game.user_ctrl_info c " +
            "    where c.uid = a.uid0 " +
            "    and u.uid = c.uid " +
            "    %s " +
            "    %s "+
            "    group by a.channel_id %s";
    private static String guessTotalSql = " select a.channel_id,%s 'vip',%s 'play_type',1039 'id',sum(c.morale) inventory from db_game.user_info u,db_game.account_info a,db_game.user_guess_total c " +
            "    where c.uid = a.uid0 " +
            "    and u.uid = c.uid " +
            "    %s " +
            "    %s "+
            "    group by a.channel_id %s";
    private static String bossEnergyScoreSql = " select a.channel_id,%s 'vip',%s 'play_type',"+Item.boss_energy_score.id+" 'id',sum(c.energy_score) inventory from db_game.user_info u,db_game.account_info a,db_game.gold_fish_lottery  c " +
            "    where c.uid = a.uid0 " +
            "    and u.uid = c.uid " +
            "    %s " +
            "    %s "+
            "    group by a.channel_id %s";
- 2.3、准备一个分组vip枚举
All("-1",""),
GROUP("u.vip",",u.vip"),
Free("-2",""," and u.user_charged = 0 ");
- 2.4、准备查询分类的枚举:全部、活跃、活跃且付费、新增、新增且付费、15分活跃、30分活跃、1个小时活跃
- 2.5、依次循环这准备好的3个嵌套循环,拼接成sql(库存sql+玩家类型+vip分组 )
String sql = String.format(preHandleAndGetSql(inventorySql), vipGroup.getField(), playTypeCondition.getPlayType() + "", playTypeCondition.getCondition(date),vipGroup.getCondition() , vipGroup.getGroup());
- 2.6、确保数据源正确(有新数据源就更换从库数据源)
- 2.7、循环上面每一种类型统计查询上面拼接的sql得到一个集合List<List<String>>
  • 3、将上面数据进行条数判断,大于5的就取第五条,否则就取普通库存(因为库存类型只有4种:普通库存、邮箱库存、漂流瓶库存、工会库存),最终拼接的到sql
  • 4、再更新sql
  • 5、每天时间到了后缀是:00:15:00,就准备好15、30、1小时的活跃集合
  • 6、统计数据、再更新数据(逻辑和第二步一样)
  • 7、更新库存变化(econ_inventory 里面 player_type=1002的是库存变化,活跃付费用户变化量=活跃付费用户-0点付费用户的库存(1002),其他类型都是按-0算)
  • 8、公会仓库库存
    • 8.1、准备基础sql,查询并得到
      String sql = "SELECT id,SUM(quantity)sum FROM gang_presd_warehouse WHERE id IN (ids) GROUP BY id"
    • 8.2、准备字典为inventory_ids类型的sql,并且查询得到道具数组拼接成逗号隔开的字符串类型
      select * from data_bi.econ_data_dictionary where type='inventory_ids' ORDER BY order_num
    • 8.3、循环sql,组装数据。接着拼接成;隔开的字符串执行sql