%%% -------------------------------------------------------
%%% @author huangyongxing@yeah.net
%%% @doc
%%% ta上报事件的触发接口封装
%%% @end
%%% @since 2021-05-24
%%% -------------------------------------------------------
-module(ta_agent_fire).
-export([
        online_track/0                  %% 在线人数上报
        ,online_track/2                 %% 在线人数上报
        ,create_role/1                  %% 创角事件
        ,role_login/3                   %% 登录事件
        ,role_logout/3                  %% 登出事件
    ]).

-compile(export_all).

-include("predefine.hrl").
-include("server.hrl").
-include("equipment.hrl").
-include("common.hrl").
-include("def_goods.hrl").
-include("figure.hrl").
-include("goods.hrl").
-include("shop.hrl").
-include("def_fun.hrl").
-include("warsoul.hrl").
-include("rec_recharge.hrl").
-include("task.hrl").
-include("offline_hosting.hrl").
-include("def_daily.hrl").
-include("activitycalen.hrl").
-include("local_boss.hrl").
-include("dungeon.hrl").
-include("def_module.hrl").
-include("welfare.hrl").
-include("market.hrl").
-include("guild_collect.hrl").
-include("guild.hrl").
%% 在线人数上报（特殊接口）
%% 【由定时器定时调用即可触发定期上报】
online_track() ->
    {OnlineCount, HostingNum} = lib_php_api:get_online_num(),
    online_track(OnlineCount, HostingNum).

%% 在线人数上报
%% 定期上报服务器的在线人数状况，
%% 由于TA系统中的事件以角色为单位，而这个在线人数并不是角色的属性或行为，
%% 所以这里实际上是通过虚拟一个用户来描述服务器的状态数据
%% （以游戏服编号为#account_id即可区分不同游戏服）
online_track(OnlineCount, HostingNum) ->
    case config:get_server_id() of
        ServerId when ServerId > 0 ->
            ServerIdBinStr = integer_to_binary(ServerId),
            IpBinStr = <<"127.0.0.1">>,
            Properties = #{
                server_id => ServerIdBinStr
                ,amount => OnlineCount
                ,hosting_amount => HostingNum
            },
            ta_agent:track_raw(ServerId, online_count, IpBinStr, Properties);
        _ ->
            ignore
    end.

%% 创角事件（特殊逻辑，缺少#player_status{}的情况下可参考此接口）
create_role([Id, Ip, Accname, Name, IsSimulator, IsChooseCareer, IsChangeName, Source, Career, TaGuestId]) ->
    IpBinStr = util:ip2bin(Ip),
    Now = utime:unixtime(),
    Properties = #{
        % 公共属性
        accname => Accname
        ,vip_level => 0
        ,role_level => 1
        ,current_power => 0
        ,total_pay_amount => 0
        % 事件特殊属性
        ,create_ip => IpBinStr
        ,name => Name
        ,is_simulator => IsSimulator
    },
    UserProperties = #{
        % 公共属性
        accname => Accname
        ,vip_level => 0
        ,role_level => 1
        ,current_power => 0
        ,total_pay_amount => 0
        % 用户属性
        ,channel => Source
        ,register_time => Now
        ,origin_server => config:get_server_id()
        ,server_open_time => util:get_open_time()
        ,career => Career
        ,create_role_time => Now
        ,reg_ip => IpBinStr
        ,is_choose_career => IsChooseCareer
        ,is_change_name => IsChangeName
    },
    SpclBaseData = #{'#distinct_id' => TaGuestId},
    ta_agent:track_raw(Id, create_role, IpBinStr, Properties, SpclBaseData, normal, Now),
    ta_agent:user_set_once_raw(Id, undefined, IpBinStr, UserProperties, Now).

%% 登录事件
role_login(#player_status{online = ?LOGIN_LOG_HOSTING}, _Channel, _TaGuestId) ->
    %% 离线托管不需要上报数据
    ignore;
role_login(PS, Channel, TaGuestId) ->
    #player_status{
        gold = Gold, bgold = BGold, coin = Coin, honour = Honour,
        ip = Ip, network_type = NetworkType,
        reconnect = Reconnect, last_login_time = LastLoginTime
    } = PS,
    OtherProperties = #{
        login_type => val_login_type(Reconnect)
        ,login_ip => Ip
        ,network_type => val_network(NetworkType)
        ,channel => Channel
        ,current_gold => Gold
        ,current_bgold => BGold
        ,current_trade => Coin
        ,current_fame => Honour
    },
    SpclBaseData = #{'#distinct_id' => TaGuestId},
    ta_agent:track(PS, role_login, OtherProperties, SpclBaseData, normal, LastLoginTime).

%% 登出事件
role_logout(#player_status{online = ?LOGIN_LOG_HOSTING}, _NowTime, _LogoutType) ->
    ignore;
role_logout(PS, NowTime, LogoutType) ->
    #player_status{
        gold = Gold, bgold = BGold, coin = Coin, honour = Honour,
        last_login_time = LastLoginTime,
        figure = #figure{lv = RoleLv, vip = Vip, power = Power}
    } = PS,
    OnlineTime = NowTime - LastLoginTime,
    OtherProperties = #{
        logout_type => val_logout_type(LogoutType)
        ,online_time => OnlineTime
        ,current_gold => Gold
        ,current_bgold => BGold
        ,current_trade => Coin
        ,current_fame => Honour
    },
    UserProperties = #{
        latest_logout_time => NowTime
        ,vip_level => Vip
        ,role_level => RoleLv
        ,current_power => Power
    },
    ta_agent:track(PS, role_logout, OtherProperties, normal, NowTime),
    ta_agent:user_set(PS, UserProperties).

%% 商城购买
%% shop_type: 1-交易商城|2-羁绊商城|3-彩钻商城|4-名望商城|5-红钻商城
%% cost_type: 1-彩钻|2-红钻|3-交易券|4-名望券|19-羁绊点
role_shop_by(Player, [Cfg, GoodsNum, IsQuick]) ->
    CurrencyLeft = case Cfg#shop.ctype of
                       ?TYPE_GOLD -> Player#player_status.gold;
                       ?TYPE_BGOLD -> Player#player_status.bgold;
                       ?TYPE_COIN -> Player#player_status.coin;
                       ?TYPE_HONOUR -> Player#player_status.honour;
                       ?TYPE_MATE -> lib_goods_api:get_currency(Player, ?GOODS_ID_MATE);
                       _ -> 0
                   end,
    OtherProperties = #{
        shop_type => var_shop_type(Cfg#shop.shop_type)
        ,sub_type => var_shop_type(Cfg#shop.shop_type * 100 + Cfg#shop.sub_type)
        ,goods_id => Cfg#shop.goods_id
        ,goods_num => GoodsNum
        ,cost_type => Cfg#shop.ctype
        ,cost_num => Cfg#shop.price * GoodsNum
        ,currency_left => CurrencyLeft
        ,is_quick => ?IF(IsQuick > 0, true, false)
    },
    ta_agent:track(Player, shop_buy, OtherProperties, normal, utime:unixtime()).

%% 订单完成
order_finish(Player, NowTime, [Id, ProductCfg, PlayerOld]) ->
    OtherProperties = #{
        order_id => Id
        ,pay_amount => ProductCfg#base_recharge_product.money
        ,act_value => ProductCfg#base_recharge_product.act_value
        ,pay_item_type => ProductCfg#base_recharge_product.product_type
        ,pay_sub_type => ProductCfg#base_recharge_product.product_subtype
        ,pay_item_id => ProductCfg#base_recharge_product.product_id
        ,pay_item => ProductCfg#base_recharge_product.product_name
        ,is_first_pay => ?IF(PlayerOld#player_status.is_pay, false, true)
    },
    ta_agent:track(Player, order_finish, OtherProperties, normal, NowTime).

%% 紫色以上品质的装备获取时记录
%% get_type:1宝箱|2赏金幻魔|3个人幻魔|4星域幻魔|5幻魔之家
equip_get(Player, GoodsId, GetType) ->
    case data_goods_type:get(GoodsId) of
        #ets_goods_type{type = ?GOODS_TYPE_STUFF, subtype = ?GOODS_STUFF_SUBTYPE_EQUIPMENT_CHIP, color = Color} ->
            OtherProperties = #{
                get_type => GetType
                ,goods_id => GoodsId
                ,goods_color => Color
            },
            ta_agent:track(Player, equip_get, OtherProperties);
        #ets_goods_type{type = ?GOODS_TYPE_EQUIP, color = Color} when Color >= ?PURPLE ->
            case data_equipment:get_equipment_info(GoodsId) of
                #base_equipment{series = Series, equip_type = EquipType, color = Color, career = Career}
                    when Color >= ?PURPLE ->
                    OtherProperties = #{
                        equip_series => Series
                        ,equip_type => EquipType
                        ,equip_career => var_career_type(Career)
                        ,get_type => GetType
                        ,goods_id => GoodsId
                        ,goods_color => Color
                    },
                    ta_agent:track(Player, equip_get, OtherProperties);
                _ ->
                    ignore
            end;
        _ ->
            ignore
    end.

%% 装备穿戴时记录
equip_wear(Player, Series, GoodsNew, GoodsOld) ->
    OtherProperties = #{
        equip_series => Series
        ,equip_type => GoodsNew#goods.subtype
        ,goods_id => GoodsNew#goods.goods_id
        ,old_goods_id => ?IF(is_record(GoodsOld, goods), GoodsOld#goods.goods_id, 0)
        ,goods_color_old => ?IF(is_record(GoodsOld, goods), GoodsOld#goods.color, 0)
        ,goods_color_new => GoodsNew#goods.color
        ,level => equipment_api:get_equipment_strength_lv(GoodsNew)
        ,star => max(equipment_api:get_equipment_great_lv(GoodsNew), 0)
    },
    ta_agent:track(Player, equip_wear, OtherProperties, normal, utime:unixtime()).

%% 装备强化时记录
equip_strengthen(Player, Goods, Ratio, Success, Lv) ->
    Series = equipment_api:get_equipment_series(Goods),
    OtherProperties = #{
        equip_series => Series
        ,equip_type => Goods#goods.subtype
        ,goods_id => Goods#goods.goods_id
        ,goods_color => Goods#goods.color
        ,strengthen_ratio => Ratio
        ,is_success => Success
        ,new_level => Lv
    },
    ta_agent:track(Player, equip_strengthen, OtherProperties, normal, utime:unixtime()).

%% 装备进化时记录
equip_great(Player, Goods, Ratio, Success, AutoBuy, CostGoods) ->
    Series  = equipment_api:get_equipment_series(Goods),
    GreatLv = equipment_api:get_equipment_great_lv(Goods),
    OtherProperties = #{
        equip_series => Series
        ,equip_type => Goods#goods.subtype
        ,goods_id => Goods#goods.goods_id
        ,goods_color => Goods#goods.color
        ,great_ratio => Ratio
        ,is_success => Success
        ,star_level => GreatLv
        ,is_makeup => AutoBuy
        ,cost_list => [One#goods.goods_id || {One, _} <- CostGoods]
        ,cost_equip_num => length(CostGoods)
    },
    ta_agent:track(Player, equip_great, OtherProperties, normal, utime:unixtime()).

%% 装备红装激活和升级时记录
equip_empower(Player, EmpowerConfig, NewLevel) ->
    case EmpowerConfig of
        #base_equipment_empower{
            series = Series,
            pos = Pos,
            cost = [{_, GoodsId, GoodsNum}|_]
        } ->
            OtherProperties = #{
                equip_series => Series
                ,equip_type => Pos
                ,new_level => NewLevel
                ,cost_goods => GoodsId
                ,cost_num => GoodsNum
            },
            ta_agent:track(Player, equip_empower, OtherProperties, normal, utime:unixtime());
        _ ->
            ok
    end.

%% 战魂上阵/替换/进化时记录
warsoul_equip(Player, [Type, Pos, OldId, EquipConfig, PlayerOld]) ->
    OtherProperties = #{
        type => var_warsoul_type(Type)
        ,pos => Pos
        ,old_goods_id => OldId
        ,new_goods_id => EquipConfig#base_war_soul_info.goods_id
        ,goods_color => EquipConfig#base_war_soul_info.color
        ,goods_star => EquipConfig#base_war_soul_info.star
        ,group_type => Player#player_status.role_war_soul#role_war_soul.array_id
        ,promote_power => Player#player_status.combat_power - PlayerOld#player_status.combat_power
    },
    ta_agent:track(Player, warsoul_equip, OtherProperties, normal, utime:unixtime()).

%% 羁绊关系变更时记录：运营决定暂时不上报，触发代码已注释
mate_friend(Player, [Friends, Type, Intimacy]) ->
    OtherProperties = #{
        friend_id => Friends
        ,type => var_mate_type(Type)
        ,intimacy => Intimacy
    },
    ta_agent:track(Player, mate_friend, OtherProperties, normal, utime:unixtime()).

%% 完成任务时记录
task_completed(Player, Now, [TaskId, Type, Duration]) ->
    Task = lib_task:get_data(TaskId),
    OtherProperties = #{
        task_id => Task#task.id
        ,type => var_task_type(Type)
        ,task_name => Task#task.name
        ,task_type => var_task(Task#task.type)
        ,duration => Duration
    },
    ta_agent:track(Player, task_completed, OtherProperties, normal, Now),
    Player.

%% 输入礼包卡使用时记录，领取失败的也需要记录
gift_card(Player, [CardNo, CardType, GiftType, IsSuccess, FailType]) ->
    OtherProperties = #{
        card_no => CardNo
        ,card_type => CardType
        ,gift_type => GiftType
        ,is_success => IsSuccess
        ,fail_type => case data_errorcode_msg:get(FailType) of
                          #errorcode_msg{about = Msg} -> Msg;
                          _ -> ""
                      end
    },
    ta_agent:track(Player, gift_card, OtherProperties, normal, utime:unixtime()),
    ok.

%% 名望券获得
honour_get(PS, [AddAmount, ProductType, About]) ->
    #player_status{
         honour = Honour
    } = PS,
    OtherProperties = #{
        get_amount => AddAmount,
        change_after => Honour,
        get_type => ProductType,
        assist_type => unicode:characters_to_binary(About)
    },
    ta_agent:track(PS, fame_get, OtherProperties, normal, utime:unixtime()),
    ok.

%% 名望券消耗
honour_consume(PS, [CostAmount, ProductType]) ->
    #player_status{
        honour = Honour
    } = PS,
    OtherProperties = #{
        cost_amount => CostAmount,
        change_after => Honour,
        consume_type => ProductType
    },
    ta_agent:track(PS, fame_consume, OtherProperties, normal, utime:unixtime()),
    ok.

%% 彩钻石获得
gold_get(PS, [AddAmount, ProductType]) ->
    #player_status{
        gold = Gold
    } = PS,
    OtherProperties = #{
        get_amount => AddAmount,
        change_after => Gold,
        get_type => ProductType
    },
    ta_agent:track(PS, gold_get, OtherProperties, normal, utime:unixtime()),
    ok.

%% 彩钻消耗
gold_consume(PS, [CostAmount, ProductType]) ->
    #player_status{
        gold = Gold
    } = PS,
    OtherProperties = #{
        cost_amount => CostAmount,
        change_after => Gold,
        consume_type => ProductType
    },
    ta_agent:track(PS, gold_consume, OtherProperties, normal, utime:unixtime()),
    ok.

%% 红钻消耗
bgold_consume(PS, [CostAmount, ProductType]) ->
    #player_status{
        bgold = BGold
    } = PS,
    OtherProperties = #{
        cost_amount => CostAmount,
        change_after => BGold,
        consume_type => ProductType
    },
    ta_agent:track(PS, bgold_consume, OtherProperties, normal, utime:unixtime()),
    ok.

%% 交易券获得
coin_get(PS, [AddAmount, ProductType]) ->
    #player_status{
        coin = Coin
    } = PS,
    OtherProperties = #{
        get_amount => AddAmount,
        change_after => Coin,
        get_type => ProductType
    },
    ta_agent:track(PS, trade_get, OtherProperties, normal, utime:unixtime()),
    ok.

%% 交易券消耗
coin_consume(PS, [CostAmount, ProductType]) ->
    #player_status{
        coin = Coin
    } = PS,
    OtherProperties = #{
        cost_amount => CostAmount,
        change_after => Coin,
        consume_type => ProductType
    },
    ta_agent:track(PS, trade_consume, OtherProperties, normal, utime:unixtime()),
    ok.

%% 进阶升级
foster_up(PS, [Type, Stage, Star, Exp, AddExp, NeedExp, EndTime, IsAuto,
    CostGoods, CostNum, CostGold, CostBGold, CurrentGold, CurrentBGold]) ->
    OtherProperties = #{
        type => unicode:characters_to_binary(Type),
        step_level => Stage,
        star_level => Star,
        exp => Exp,
        add_exp => AddExp,
        need_exp => NeedExp,
        end_time => EndTime,
        is_auto => IsAuto,
        cost_goods => CostGoods,
        cost_num => CostNum,
        cost_gold => CostGold,
        cost_bgold => CostBGold,
        current_gold => CurrentGold,
        current_bgold => CurrentBGold
    },
    ta_agent:track(PS, foster_up, OtherProperties, normal, utime:unixtime()),
    ok.

%% 完成七日目标任务
seven_goal_task(PS, [Days, ModId, SubId, TaskName]) ->
    OtherProperties = #{
        days => Days,
        mod_id => ModId,
        sub_id => SubId,
        task_name => TaskName
    },
    ta_agent:track(PS, seven_goal, OtherProperties),
    ok.

%% 珍宝升星
treasure_up(PS, [Type, TreasureId, OldStar, NewStar, CostGoods, CostNum]) ->
    OtherProperties = #{
        type => Type,
        treasure_id => TreasureId,
        old_star => OldStar,
        new_star => NewStar,
        cost_goods => CostGoods,
        cost_num => CostNum
    },
    ta_agent:track(PS, treasure_up, OtherProperties, normal, utime:unixtime()),
    ok.

%% 宠物激活/升星
pet_star_up(PS, [PetId, RareDegree, ColorId, RaceId, OldStar, NewStar, CostGoods, CostNum]) ->
    OtherProperties = #{
        pet_id => PetId,
        rare_degree => RareDegree,
        color_id => ColorId,
        race_id => RaceId,
        old_star => OldStar,
        new_star => NewStar,
        cost_goods => CostGoods,
        cost_num => CostNum
    },
    ta_agent:track(PS, pet_up, OtherProperties, normal, utime:unixtime()),
    ok.

%% 宝宝同心值变化
child_heart(PS, [Type, TaskId, CostBGold, GetHeart, CurrentHeart]) ->
    OtherProperties = #{
        type => unicode:characters_to_binary(Type),
        task_id => TaskId,
        cost_bgold => CostBGold,
        get_heart => GetHeart,
        current_heart => CurrentHeart
    },
    ta_agent:track(PS, child_heart, OtherProperties, normal, utime:unixtime()),
    ok.

%% 宝宝技能激活/升级
child_vehicle(PS, [GoodsId, NewStage, CostNum]) ->
    OtherProperties = #{
        goods_id => GoodsId,
        new_stage => NewStage,
        cost_num => CostNum
    },
    ta_agent:track(PS, child_vehicle, OtherProperties, normal, utime:unixtime()),
    ok.

%% 宝宝时装激活/升级
child_fashion(PS, [GoodsId, NewLevel, CostNum]) ->
    OtherProperties = #{
        goods_id => GoodsId,
        new_level => NewLevel,
        cost_num => CostNum
    },
    ta_agent:track(PS, child_fashion, OtherProperties, normal, utime:unixtime()),
    ok.

%% 宝宝技能激活/升级
child_skill(PS, [SkillId, NewLevel, CostGoods, CostNum]) ->
    OtherProperties = #{
        skill_id => SkillId,
        new_level => NewLevel,
        cost_goods => CostGoods,
        cost_num => CostNum
    },
    ta_agent:track(PS, child_skill, OtherProperties, normal, utime:unixtime()),
    ok.

%% 玩家退出狂战领域场景时记录
madness_land(Player, [FamStage, Score, DieCount, Interval]) ->
    OtherProperties = #{
        fam_stage => FamStage
        ,score => Score
        ,revive_times => DieCount
        ,use_time => Interval
    },
    ta_agent:track(Player, madness_land, OtherProperties),
    ok.

%% 龙神宝库抽奖
warsoul_draw(PS, [Type, AwardList, PurpleNum, Orange4, Orange5, Red, IsPrize, IsAbsolute,
    TotalTimes, CostGold, CostTicket, CurrentGold, CurrentTicket]) ->
    OtherProperties = #{
        type => Type,
        award_list => AwardList,
        purple_num => PurpleNum,
        orange4_num => Orange4,
        orange5_num => Orange5,
        red_num => Red,
        is_prize => IsPrize,
        is_absolute => IsAbsolute,
        total_times => TotalTimes,
        cost_gold => CostGold,
        cost_ticket => CostTicket,
        current_gold => CurrentGold,
        current_ticket => CurrentTicket
    },
    ta_agent:track(PS, warsoul_draw, OtherProperties),
    ok.

%% 圣物抽奖
nucleon_draw(PS, [PoolType, Type, Orange1, Orange2, SectionPiece,
	CostGoods, CostGold, CostBGold, CurrentGold, CurrentBGold]) ->
	OtherProperties = #{
		pool_type => PoolType,
		type => Type,
		color_orange1 => Orange1,
		color_orange2 => Orange2,
		section_piece => SectionPiece,
		cost_goods => CostGoods,
		cost_gold => CostGold,
		cost_bgold => CostBGold,
		current_gold => CurrentGold,
		current_bgold => CurrentBGold
	},
	ta_agent:track(PS, nucleon_draw, OtherProperties),
	ok.

%% 圣物变化
nucleon_state(PS, [Pos, LevelPos, Type, OldGoodsId, GoodsId, OldColor, NewColor,
    OldStar, NewStar, PromotePower]) ->
    OtherProperties = #{
        pos => Pos,
        level_pos => LevelPos,
        type => Type,
        old_goods_id => OldGoodsId,
        goods_id => GoodsId,
        old_color => OldColor,
        new_color => NewColor,
        old_star => OldStar,
        new_star => NewStar,
        promote_power => PromotePower
    },
    ta_agent:track(PS, nucleon_state, OtherProperties),
    ok.

%% 社团状态变动
guild_state(PS, [EventType, GuildId, GuildName, GuildLevel, GuildNum,
    GuildPower, GuildRank, OldPosition, NewPosition]) ->
    OtherProperties = #{
        event_type => EventType,
        guild_id => GuildId,
        guild_name => GuildName,
        guild_level => GuildLevel,
        guild_num => GuildNum,
        guild_power => GuildPower,
        guild_rank => GuildRank,
        old_position => OldPosition,
        new_position => NewPosition
    },
    ta_agent:track(PS, guild_state, OtherProperties),
    ok.

%% 社团活跃变动
guild_activity(PS, [GuildId, GuildName, GuildLevel, GuildNum,
    TaskType, Live, PersonLive, GuildLive]) ->
    OtherProperties = #{
        guild_id => GuildId,
        guild_name => GuildName,
        guild_level => GuildLevel,
        guild_num => GuildNum,
        task_type => TaskType,
        live => Live,
        person_live => PersonLive,
        guild_live => GuildLive
    },
    ta_agent:track(PS, guild_activity, OtherProperties),
    ok.

%% 宠物副本
pet_dungeon(PS, [DunType, DunWave, IsFirst, DropSelect,
    ResultType, ResultSubType, DunStar, DunScore, PetHpLeft, UseTime]) ->
    OtherProperties = #{
        dun_type => DunType,
        dun_wave => DunWave,
        is_first => IsFirst,
        drop_select => DropSelect,
        result_type => ResultType,
        result_subtype => ResultSubType,
        dun_star => DunStar,
        dun_score => DunScore,
        pet_hp_left => PetHpLeft,
        use_time => UseTime
    },
    ta_agent:track(PS, pet_dungeon, OtherProperties),
    ok.

%% 舞池
activity_beach(PS, [IsHosting, UseTime, IsCountDown]) ->
    OtherProperties = #{
        is_offline_hosting => IsHosting,
        use_time => UseTime,
        is_count_down => IsCountDown
    },
    ta_agent:track(PS, activity_beach, OtherProperties),
    ok.

%% 社团晚宴
guild_ballroom(PS, [IsHosting, IsCountDown, LikeTimes, FreeTimes, PayTimes, UseTime]) ->
    OtherProperties = #{
        is_offline_hosting => IsHosting,
        is_count_down => IsCountDown,
        glamour_like_times => LikeTimes,
        glamour_free_items => FreeTimes,
        glamour_pay_items => PayTimes,
        use_time => UseTime
    },
    ta_agent:track(PS, guild_ballroom, OtherProperties),
    ok.

%% 社团boss
guild_boss(PS, [IsHosting, IsCountDown, EncourageTimes, ReviveTimes, DamagePercent]) ->
    OtherProperties = #{
        is_offline_hosting => IsHosting,
        is_count_down => IsCountDown,
        encourage_times => EncourageTimes,
        revive_times => ReviveTimes,
        damage_percent => DamagePercent
    },
    ta_agent:track(PS, guild_boss, OtherProperties),
    ok.

%% 饥饿游戏
wasteland_war_kv(PS, [WarRound, ResultType, CrystalScore, KillScore, RankNum, ReviveTimes, UseTime]) ->
    OtherProperties = #{
        war_round => WarRound,
        result_type => ResultType,
        crystal_score => CrystalScore,
        kill_score => KillScore,
        rank_num => RankNum,
        revive_times => ReviveTimes,
        use_time => UseTime
    },
    ta_agent:track(PS, wasteland_war_kv, OtherProperties),
    ok.

%% 衣橱时装
fashion_up(PS, [PosId, FashionId, ColorId, OptionType, CostGood, CostNum, OldStar, NewStar]) ->
    OtherProperties = #{
        pos_id => PosId,
        fashion_id => FashionId,
        color_id => ColorId,
        option_type => OptionType,
        cost_goods => CostGood,
        cost_num => CostNum,
        old_star => OldStar,
        new_star => NewStar
    },
    ta_agent:track(PS, fashion_up, OtherProperties),
    ok.

%% 圣物觉醒
nucleon_section_up(PS, [Pos, Next, GoodsNum]) ->
    OtherProperties = #{
        pos => Pos,
        level => Next,
        cost_num => GoodsNum
    },
    ta_agent:track(PS, nucleon_section, OtherProperties, normal, utime:unixtime()),
    ok.

%% 材料副本
foster_dungeon(PS, [DunType, IsSweep, ResultType, DunTimes]) ->
    OtherProperties = #{
        dun_type => DunType,
        is_sweep => IsSweep,
        result_type => ResultType,
        dun_times => DunTimes
    },
    ta_agent:track(PS, foster_dungeon, OtherProperties),
    ok.

%% 无尽回廊
tower_dungeon(PS, [DunType, DunLevel, ResultType, ResultSubType, DunStar, PowerAdvice, UseTime]) ->
    OtherProperties = #{
        dun_type => DunType,
        dun_level => DunLevel,
        result_type => ResultType,
        result_subtype => ResultSubType,
        dun_star => DunStar,
        power_advice => PowerAdvice,
        use_time => UseTime
    },
    ta_agent:track(PS, tower_dungeon, OtherProperties),
    ok.

%% 幻光副本
llusory_light(Player, [DunType, OldDunWave, NewDunWave, ResultType, ResultSubType, UseTime]) ->
    OtherProperties = #{
        dun_type => DunType,
        old_dun_wave => OldDunWave,
        new_dun_wave => NewDunWave,
        result_type => ResultType,
        result_subtype => ResultSubType,
        use_time => UseTime
    },
    ta_agent:track(Player, llusory_light, OtherProperties),
    ok.

%% 经验副本
exp_dungeon(Player, [OldDunWave, NewDunWave, PowerAdvice, ResultType, ResultSubType, UseTime]) ->
    OtherProperties = #{
        old_dun_wave => OldDunWave,
        new_dun_wave => NewDunWave,
        power_advice => PowerAdvice,
        result_type => ResultType,
        result_subtype => ResultSubType,
        use_time => UseTime
    },
    ta_agent:track(Player, exp_dungeon, OtherProperties),
    ok.

%% 护送
ta_convoy(Player, [ColorId, ResultType, OldColor, RefreshTime, CostCard, CostBGold, DoubleRet]) ->
    OtherProperties = #{
        color_id => ColorId,
        result_type => ResultType,
        old_color => OldColor,
        refresh_times => RefreshTime,
        cost_card => CostCard,
        cost_bgold => CostBGold,
        double_type => DoubleRet
    },
    ta_agent:track(Player, convoy, OtherProperties),
    ok.

ta_fast_exp_drop(Player, [RewardTimes, SupVipTpye, UpLv, CostGold]) ->
    OtherProperties = #{
        type => RewardTimes,
        supervip_state => SupVipTpye,
        level_up => UpLv,
        cost_gold => CostGold
    },
    ta_agent:track(Player, onhook_fast, OtherProperties),
    ok.

%% 玩家rfmt数据(充值相关)
charge_rfmt(Player, Rfmt) ->
    RfmtBin = util:term_to_bitstring(Rfmt),
    UserProperties = #{
        charge_rfmt => RfmtBin
    },
    ta_agent:user_set(Player, UserProperties),
    ok.

%% 玩家累计充值金额
total_pay_amount(Player, Now, NewTotalMoney) ->
    UserProperties = #{
        total_pay_amount => NewTotalMoney
    },
    ta_agent:user_set(Player, UserProperties, normal, Now),
    ok.

%% 每天3:59记录，只对今日有登录的玩家进行统计
role_daily_active(Player) ->
    Now = utime:unixtime(),
    AtTime = utime:get_next_logic_midnight(Now, 4),
    OtherProperties = get_daily_active_properties(Player),
    ta_agent:track(Player, role_daily_active, OtherProperties, {at_time, AtTime}, Now),
    Player.

%% 每天23:59记录，只对今日登录的玩家进行统计
role_daily_attr(Player) ->
    #player_status{
        id = RoleId,
        gold = Gold,
        bgold = Bgold,
        coin = Coin,
        honour = Honour,
        recharge_statistic = #role_recharge_statistic{
            recency = R       %% 评级：充值间隔   last_pay_time与登录时间戳相差的天数区间
            , frequency = F     %% 评级：充值频率   最近30天内的充值次数
            , monetary = M      %% 评级：历史总充值
            , top = T           %% 评级：最高额充值
        }
    } = Player,
    Now = utime:unixtime(),
    AtTime = utime:tomorrow(Now),
    Properties = get_daily_attr_properties(RoleId),
    OtherProperties = Properties#{
        total_online_time => lib_daily:get_count(RoleId, ?MOD_WELFARE, ?COUNTER_WELFARE_ONLINE_TIME)
        ,current_gold => Gold
        ,current_bgold => Bgold
        ,current_trade => Coin
        ,current_fame => Honour
        ,charge_rfmt => [R, F, M, T]
    },
    ta_agent:track(Player, role_daily_attr, OtherProperties, {at_time, AtTime}, Now),
    Player.

%% 物品拍卖成功或物品下架时记录
%% OpType:1成交|2主动下架|3超时下架|4系统回购（主体记录卖家）
auction_state(Player, {MarketGoods, OpType, BuyType}) ->
    GoodsCfg = data_goods_type:get(MarketGoods#market_goods.goods_type_id),
    OtherProperties = #{
        auction_type => MarketGoods#market_goods.sell_type
        ,goods_only_id => MarketGoods#market_goods.id
        ,option_type => OpType
        ,market_sell_type => MarketGoods#market_goods.type
        ,market_sell_sub_type => MarketGoods#market_goods.sub_type
        ,goods_color =>MarketGoods#market_goods.color
        ,goods_id => MarketGoods#market_goods.goods_type_id
        ,equip_series => MarketGoods#market_goods.series
        ,equip_career => var_career_type(MarketGoods#market_goods.career)
        ,is_player => ?IF(MarketGoods#market_goods.role_id < 655, false, true)
        ,is_public => ?IF(GoodsCfg#ets_goods_type.market_show_time > 0, true, false)
        ,is_auction => %% 社团上架的只能一口价
            ?IF((MarketGoods#market_goods.sell_type =:= ?MARKET_SELL_TYPE_GUILD andalso MarketGoods#market_goods.buyout_price > 0)
                orelse GoodsCfg#ets_goods_type.trade_price == 0,
                false, true)
        ,bid_times => MarketGoods#market_goods.bid_count
        ,is_fixed_price => ?IF(MarketGoods#market_goods.price == MarketGoods#market_goods.buyout_price, true, false)
        ,is_auto => ?IF(BuyType > ?MARKET_BUY_TYPE_NORMAL, true, false )
        ,origin_price => ?IF(GoodsCfg#ets_goods_type.trade_price == 0, GoodsCfg#ets_goods_type.buyout_price, GoodsCfg#ets_goods_type.trade_price)
        ,deal_price => MarketGoods#market_goods.price
        ,shelves_time => MarketGoods#market_goods.time
        ,public_time => MarketGoods#market_goods.time + GoodsCfg#ets_goods_type.market_show_time
    },
    ta_agent:track(Player, auction_state, OtherProperties),
    Player.

%% 排行榜
ta_rank(Player, [EventType, Rank, GuildId, GuildName, LastLoginTime]) ->
    OtherProperties = #{
        rank_order => Rank,
        guild_id => GuildId,
        guild_name => GuildName,
        last_login => LastLoginTime
    },
    ta_agent:track(Player, EventType, OtherProperties),
    ok.

%% 无尽领域
void_fam(Player, [MaxFloor, Score, DieNum, StayTime]) ->
    OtherProperties = #{
        max_floor => MaxFloor,
        score => Score,
        revive_times => DieNum,
        use_time => StayTime
    },
    ta_agent:track(Player, void_fam, OtherProperties),
    ok.

%% 多人讨伐副本
multi_dungeon(Player, [MaxRating, DunId, ResultSubType, PassTime, SingleMode, PlayerNum, RobotNum, AssistNum]) ->
    OtherProperties = #{
        dun_type => DunId,
        is_single_mode => SingleMode,
        player_num => PlayerNum,
        robot_num => RobotNum,
        assist_num => AssistNum,
        result_subtype => ResultSubType,
        dun_star => MaxRating,
        use_time => PassTime
    },
    ta_agent:track(Player, multi_dungeon, OtherProperties),
    ok.

%% 守卫信标
guard_dungeon(Player,
    [ReviveCount, IsLeader, PlayerNum, RobotNum, PowerNeed, DunId, Role2Power, Role3Power, ResultSubType, PassTime, DunWave, HpTop, HpMid, HpBot]) ->
    OtherProperties = #{
        dun_type => DunId,
        player_num => PlayerNum,
        robot_num => RobotNum,
        is_captain => IsLeader,
        power_need => PowerNeed,
        power_player2 => Role2Power,
        power_player3 => Role3Power,
        result_subtype => ResultSubType,
        dun_wave_aft => DunWave,
        hp_top => HpTop,
        hp_mid => HpMid,
        hp_bot => HpBot,
        revive_times => ReviveCount,
        use_time => PassTime
    },
    ta_agent:track(Player, guard_dungeon, OtherProperties),
    ok.

%% 社团采集
guild_seal(Player, [EnterRec, CollectCount, AssistCount, StayTime]) ->
    OtherProperties = #{
        is_count_down => EnterRec,
        collet_times => CollectCount,
        assist_times => AssistCount,
        use_time => StayTime
    },
    ta_agent:track(Player, guild_seal, OtherProperties),
    ok.

%% 赏金boss
ta_gold_boss_belong(Player, [BossId, BossLv, BossSeries, IsFirstKill, InspireTicket, InspireBGold, InspireGold, ReviveCount, TeamRoleNum, SupportNum,
 HurtPercent, TeamRank, UseTime]) ->
    OtherProperties = #{
        boss_id => BossId,
        boss_lv => BossLv,
        boss_series => BossSeries,
        is_first_kill => IsFirstKill,
        inspire_ticket => InspireTicket,
        inspire_bgold => InspireBGold,
        inspire_gold => InspireGold,
        revive_times => ReviveCount,
        team_num => TeamRoleNum,
        assist_num => SupportNum,
        damage_percent => HurtPercent,
        damage_rank => TeamRank,
        use_time => UseTime
    },
    ta_agent:track(Player, gold_boss_belong, OtherProperties),
    ok.

%% 废都boss
ta_deserted_boss_belong(Player, [BossType, BossId, BossLv, Grade, IsFirstKill, ReviveCount, TeamRoleNum, SupportNum,
 HurtPercent, Rank, UseTime]) ->
    OtherProperties = #{
        boss_type => BossType,
        boss_id => BossId,
        boss_lv => BossLv,
        boss_series => Grade,
        is_first_kill => IsFirstKill,
        revive_times => ReviveCount,
        team_num => TeamRoleNum,
        assist_num => SupportNum,
        damage_percent => HurtPercent,
        damage_rank => Rank,
        use_time => UseTime
    },
    ta_agent:track(Player, deserted_boss_belong, OtherProperties),
    ok.

%% 单人boss(副本)
single_boss_belong(Player, [Mid, MinLv, Grade, IsFirstKill, ReviveCount, UseTime]) ->
    OtherProperties = #{
        boss_id => Mid,
        boss_lv => MinLv,
        boss_series => Grade,
        is_first_kill => IsFirstKill,
        revive_times => ReviveCount,
        use_time => UseTime
    },
    ta_agent:track(Player, single_boss_belong, OtherProperties),
    ok.

%% 星域争霸挑战
cross_point_fight(Player, [DunId, Type, GetPoint]) ->
    case data_dungeon:get_dun(DunId) of
        #dun_cfg{type = DunType, name = Name} ->
            #player_status{guild = #status_guild{id = GuildId}} = Player,
            OtherProperties = #{
                dun_type => DunType,
                dun_name => Name,
                guild_id => GuildId,
                country_id => czone_api:env_get_faction(),
                challenge_type => Type,
                get_point => GetPoint,
                current_point => lib_role_legion:get_legion(Player),
                left_activity => lib_role_legion:get_process(Player)
            },
            ta_agent:track(Player, cross_point_fight, OtherProperties);
        _ ->
            ignore
    end,
    ok.

%% 橙装合成
orange_compose(Player, #base_goods_compose_or_evolution_info{target_goods_id = GoodsId, cost_goods = [{_, CostId, CostNum}|_]}) ->
    case data_equipment:get_equipment_info(GoodsId) of
        #base_equipment{series = Series, equip_type = EquipType, career = Career}->
            OtherProperties = #{
                equip_series => Series
                ,equip_type => EquipType
                ,equip_career => var_career_type(Career)
                ,goods_id => GoodsId
                ,cost_goods => CostId
                ,cost_num => CostNum
            },
            ta_agent:track(Player, orange_compose, OtherProperties);
        _ ->
            ignore
    end;
orange_compose(_, _) -> ignore.

home_boss_belong(Player, [BossId, BossLv, BossSeries, TeamNum, HomeType, Floor, ReviveTimes, DamagePercent, DamegeRank, UseTime]) ->
    HomeStr =
    if HomeType == 1 -> <<"公共"/utf8>>;
        HomeType == 2 -> <<"社团"/utf8>>;
        true -> <<"公共"/utf8>>
    end,
    OtherProperties = #{
        boss_id => BossId,
        boss_lv => BossLv,
        boss_series => BossSeries,
        team_num => TeamNum,
        home_type => HomeStr,
        floor => Floor,
        revive_times => ReviveTimes,
        damage_percent => DamagePercent,
        damage_rank => DamegeRank,
        use_time => UseTime
    },
    ta_agent:track(Player, boss_home_belong, OtherProperties),
    ok.
    
%% -------------------------------------------------------
%% TA系统属性值定义 - 开始
%% 相关事件属性值不多，暂时先硬编码到代码中，如有必要再统一改配置
%% 海外版翻译可排除本模块，函数名通常以“val_”为前缀
%% -------------------------------------------------------
%% 登录类型
val_login_type(?RE_LOGIN)  -> <<"重连"/utf8>>;
val_login_type(_Reconnect) -> <<"登录"/utf8>>.

%% 网络类型
val_network(1) -> <<"WIFI">>;
val_network(2) -> <<"移动网络"/utf8>>;
val_network(_) -> <<"未知网络"/utf8>>.

%% 登出类型
val_logout_type(?LOGOUT_LOG_NORMAL)      -> <<"正常退出"/utf8>>;
val_logout_type(?LOGOUT_LOG_ERROR)       -> <<"异常退出"/utf8>>;
val_logout_type(?LOGOUT_LOG_SERVER_STOP) -> <<"停服退出"/utf8>>;
val_logout_type(?LOGOUT_LOG_LIMIT_LOGIN) -> <<"停服退出"/utf8>>;
val_logout_type(_LogNormalOrErr) -> <<"其他"/utf8>>.

%% 羁绊操作类型
var_mate_type(1)  -> <<"申请羁绊"/utf8>>;
var_mate_type(2)  -> <<"建立羁绊"/utf8>>;
var_mate_type(3)  -> <<"强制解除"/utf8>>;
var_mate_type(_)  -> <<"协议解除"/utf8>>.

%% 任务操作类型
var_task_type(1)  -> <<"领取任务"/utf8>>;
var_task_type(_)  -> <<"任务完成"/utf8>>.

%% 任务类型
var_task(?TASK_TYPE_MAIN)     -> <<"主线任务"/utf8>>;
var_task(?TASK_TYPE_SIDE)     -> <<"支线任务"/utf8>>;
var_task(?TASK_TYPE_TURN)     -> <<"转生任务"/utf8>>;
var_task(?TASK_TYPE_CHAPTER)  -> <<"章节任务"/utf8>>;
var_task(?TASK_TYPE_NUCLEON)  -> <<"灵能任务"/utf8>>;
var_task(?TASK_TYPE_GUILD)    -> <<"公会周任务"/utf8>>;
var_task(?TASK_TYPE_DAILY)    -> <<"日常支线任务"/utf8>>;
var_task(?TASK_TYPE_FOUR)     -> <<"循环任务"/utf8>>;
var_task(_)  -> <<"无"/utf8>>.

%% 战魂操作类型
var_warsoul_type(1)  -> <<"战魂上阵"/utf8>>;
var_warsoul_type(_)  -> <<"战魂进化"/utf8>>.

%% 商店
var_shop_type(1)  -> <<"交易商城"/utf8>>;
    var_shop_type(100)  -> <<"热门推荐"/utf8>>;
    var_shop_type(101)  -> <<"随身守护"/utf8>>;
    var_shop_type(102)  -> <<"首饰戒指"/utf8>>;
    var_shop_type(103)  -> <<"强力技能"/utf8>>;
    var_shop_type(104)  -> <<"日常消耗"/utf8>>;
var_shop_type(2)  -> <<"名望商城"/utf8>>;
    var_shop_type(200)  -> <<"热门推荐"/utf8>>;
    var_shop_type(201)  -> <<"珍品项链"/utf8>>;
    var_shop_type(202)  -> <<"强力技能"/utf8>>;
    var_shop_type(203)  -> <<"日常消耗"/utf8>>;
var_shop_type(3)  -> <<"红钻商城"/utf8>>;
    var_shop_type(301)  -> <<"日常消耗"/utf8>>;
var_shop_type(4)  -> <<"羁绊商城"/utf8>>;
    var_shop_type(401)  -> <<"常用道具"/utf8>>;
var_shop_type(5)  -> <<"彩钻商城"/utf8>>;
    var_shop_type(500)  -> <<"热门推荐"/utf8>>;
    var_shop_type(501)  -> <<"成长助力"/utf8>>;
    var_shop_type(502)  -> <<"日常消耗"/utf8>>;
    var_shop_type(503)  -> <<"极品戒指"/utf8>>;
    var_shop_type(504)  -> <<"强化守护"/utf8>>;
var_shop_type(_)  -> <<"无"/utf8>>.

%% 装备职业
var_career_type([1,2])  -> <<"剑士"/utf8>>;
var_career_type([3,4])  -> <<"双枪"/utf8>>;
var_career_type([1,3])  -> <<"男性"/utf8>>;
var_career_type([2,4])  -> <<"女性"/utf8>>;
var_career_type(_)  -> <<"通用"/utf8>>.
%% -------------------------------------------------------
%% TA系统属性值定义 - 结束
%% 此部分在最后，其他接口添加请放在“TA系统属性值定义”之前
%% -------------------------------------------------------
get_daily_active_properties(Player) ->
    #player_status{id = RoleId} = Player,
    [
        {_, Activity},
        {_, DailyHonourGet},
        {_, DailyHonour},
        {_, DailyCoin},
        {_, DailyGlamour},
        {_, DailyDunMulti},
        {_, DailyFlower},
        {_, DailyArena},
        {_, DailyTask},
        {_, GuildTask},
        {_, DailyGuildMeeting},
        {_, DailyGuildBoss1},
        {_, DailyGuildBoss2},
        {_, DailyGuildCollect},
        {_, DailyBeach},
        {_, DailyPersonalBoss},
        {_, DailyRewardBoss},
        {_, DailyDesertedBoss},
        {_, DailyDesertedElite},
        {_, DailyConvoy},
        {_, DailyTowerNormal},
        {_, DailyTowerHard},
        {_, DailyDunVisus},
        {_, DailyDunMount},
        {_, DailyDunBaoju},
        {_, DailyDunAi},
        {_, DailyDunWing},
        {_, DailyDunWeapon},
        {_, DailyDunCipo},
        {_, DailyDunhuajia},
        {_, DailyDunAiWing},
        {_, DailyExp},
        {_, DailyHostingValue}
    ] = lib_daily:get_count_offline(RoleId,
        [
            {?MOD_ACTIVITY,   0, ?ACTIVITY_LIVE_DAILY}       %% 活跃度
            %%% {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, Module * ?AC_LIVE_ADD + ModuleSub}
            , {?MOD_ACTIVITY, 0, ?ACTIVITY_HONOUR_DAILY}     %% 名望券数量
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_PLAYER * ?AC_LIVE_ADD + 6}        %% 今日名望券
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_PLAYER * ?AC_LIVE_ADD + 5}        %% 交易券
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_GLAMOUR * ?AC_LIVE_ADD + 0}       %% 社团赛马
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_DUN_MULTI * ?AC_LIVE_ADD + 1}     %% 小队讨伐
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_FLOWER * ?AC_LIVE_ADD + 0}        %% 好友送礼
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_ARENA * ?AC_LIVE_ADD + 0}         %% 竞技场
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_TASK * ?AC_LIVE_ADD + 1}          %% 每日跑环
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_TASK * ?AC_LIVE_ADD + 2}          %% 公会周长
            , {?MOD_GUILD, 0, 4}         %% 社团晚宴
            , {?MOD_GUILD_BOSS, 1, 1}    %% 社团BOSS
            , {?MOD_GUILD_BOSS, 2, 1}    %% 社团BOSS
            , {?MOD_GUILD_COLLECT, 0, ?GUILD_COLLECT_2}     %% 封印裂隙
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_BEACH * ?AC_LIVE_ADD + 0}             %% 舞池派对
            , {?MOD_DUNGEON, ?MOD_DUN_TAKE_PART_IN, ?DUNGEON_TYPE_PER_BOSS}                 %% 个人幻魔
            , {?MOD_LOCAL_BOSS, 0, ?COUNT_REWARD_BOSS_DAILY_KILL}                           %% 赏金幻魔:总次数
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_DESERTED_BOSS * ?AC_LIVE_ADD + 1}     %% 星域幻魔
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_DESERTED_BOSS * ?AC_LIVE_ADD + 2}     %% 星域精英怪
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_CONVOY * ?AC_LIVE_ADD + ?MOD_SUB_HUSONG_ANGEL}    %% 米团外送
            , {?MOD_DUNGEON, ?MOD_DUNGEON_SUCCESS, ?DUNGEON_TYPE_TOWER}                      %% 无尽回廊-普通通关次数
            , {?MOD_DUNGEON, 0, ?MOD_DUN_TOWER_3_STAR}                                       %% 无尽回廊-困难3星通关次数
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_DUNGEON * ?AC_LIVE_ADD + ?DUNGEON_TYPE_VISUS}     %% 幻光副本
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_DUNGEON * ?AC_LIVE_ADD + 1001}  %% 座驾副本
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_DUNGEON * ?AC_LIVE_ADD + 1002}  %% 宝具副本
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_DUNGEON * ?AC_LIVE_ADD + 1003}  %% 伙伴副本
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_DUNGEON * ?AC_LIVE_ADD + 1004}  %% 神翼副本
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_DUNGEON * ?AC_LIVE_ADD + 1005}  %% 武器副本
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_DUNGEON * ?AC_LIVE_ADD + 1006}  %% 磁炮副本
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_DUNGEON * ?AC_LIVE_ADD + 1007}  %% 幻甲副本
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_DUNGEON * ?AC_LIVE_ADD + 1008}  %% 星翼副本
            , {?MOD_ACTIVITY, ?MOD_ACTIVITY_NUM, ?MOD_DUNGEON * ?AC_LIVE_ADD + 5001}  %% 经验副本
            , {?MOD_OFFLINE_HOSTING, 0, 1}                 %% 今日获得的托管值
        ]
    ),
    %% 当前托管值
    #ets_offline_hosting{value = HostingValueNow} = offline_hosting_data:host_setting_lookup(RoleId),
    #{
        active_degree => Activity
        ,fame_actime => DailyHonour div 1500
        ,trade_actime => DailyCoin div 3500
        ,horse_actime => DailyGlamour
        ,team_actime => DailyDunMulti
        ,gift_actime => DailyFlower
        ,arena_actime => DailyArena
        ,daily_task_actime => DailyTask
        ,guild_task_actime => GuildTask
        ,dinner_actime => DailyGuildMeeting
        ,guild_boss_actime => DailyGuildBoss1 + DailyGuildBoss2
        ,collect_actime => DailyGuildCollect
        ,dance_actime => DailyBeach
        ,person_boss => DailyPersonalBoss
        ,money_boss => DailyRewardBoss
        ,deserted_boss => DailyDesertedBoss
        ,deserted_elite => DailyDesertedElite
        ,escort_actime => DailyConvoy
        ,cloister_actime_normal => DailyTowerNormal
        ,cloister_actime_hard => DailyTowerHard
        ,light_actime => DailyDunVisus
        ,mount_actime => DailyDunMount
        ,trump_actime => DailyDunBaoju
        ,partner_actime => DailyDunAi
        ,wing_actime => DailyDunWing
        ,weapon_actime => DailyDunWeapon
        ,magnet_actime => DailyDunCipo
        ,armor_actime => DailyDunhuajia
        ,starwing_actime => DailyDunAiWing
        ,exp_dun_actime => DailyExp
        ,fame_get => DailyHonourGet
        ,current_hosting => HostingValueNow
        ,today_hosting => DailyHostingValue
        ,cross_activity => lib_role_legion:get_process(Player)
    }.

get_daily_attr_properties(RoleId) ->
    [
        {_, BgoldGet},
        {_, HonourGet},
        {_, HonourCost},
        {_, GoldCost},
        {_, BgoldCost},
        {_, CoinCost}
    ] = lib_daily:get_count_offline(RoleId,
        [
            {?MOD_GOODS, 0, ?GOODS_COUNTER_DAILY_BGOLD_GET}      %% 今日获得红钻
            , {?MOD_GOODS, 0, ?GOODS_COUNTER_DAILY_HONOUR_GET}   %% 今日获得名望券
            , {?MOD_GOODS, 0, ?GOODS_COUNTER_DAILY_HONOUR_COST}  %% 今日消费名望券总量
            , {?MOD_GOODS, 0, ?GOODS_COUNTER_DAILY_GOLD_COST}    %% 今日消费彩钻总量
            , {?MOD_GOODS, 0, ?GOODS_COUNTER_DAILY_BGOLD_COST}   %% 今日消费红钻总量
            , {?MOD_GOODS, 0, ?GOODS_COUNTER_DAILY_COIN_COST}    %% 今日消费交易券总量
        ]
    ),
    #{
        get_bgold => BgoldGet
        ,get_fame => HonourGet
        ,consume_fame => HonourCost
        ,consume_gold => GoldCost
        ,consume_bgold => BgoldCost
        ,consume_trade => CoinCost
    }.
