%%% -------------------------------------------------------
%%% @doc
%%%     seven_day_goal.hrl
%%%     七日目标头文件
%%% @end
%%% -------------------------------------------------------

%% 替代型的功能Id
-define(REPLACE_TASK_TYPE, [
    {146,1}, {146,2}, {146,3}, {146,4}, {146,5}, {146,6}, {146,8},
    {152,0}, {152, 4}, {152, 8}, {149, 1}, {163, 0}, {143, 1}
]).

%% 羁绊数量如果减少了，需要重新统计
-define(SPECIAL_TASK_TYPE, [
    {149, 1}
]).

%% 七日目标数据
-record(seven_days_goal, {
    open_time = 0,         %% 功能开启时间戳
    days = 0,              %% 累计登录天数
    score = 0,             %% 积分
    task_reward = [],      %% 已领取的任务奖励[{day,mod_id,sub_id}]
    score_reward = [],     %% 已领取的积分奖励[score]
    skill_reward = [],     %% 已领取的技能奖励[day]
    task_status = [],      %% 任务完成状态[{key, progress}],Key:{天数, 模块Id, 子id} progress:进度
    other_data = []        %% eg:{red_equip, 活动开启时已激活的红装件数}
}).


%% 任务配置
-record(base_seven_goal_task, {
    days = 0              %% 天数
    , mod_id = 0          %% 模块Id
    , sub_id = 0          %% 子id
    , order_id = 0        %% 排序id
    , difficulty = 0      %% 任务难度
    , name = <<>>         %% 任务名称
    , jump_id = []        %% 跳转id
    , reward = []         %% 奖励
    , desc = <<>>         %% 描述
    , condition = []      %% 条件
    , task_tag = 0        %% 任务标签
}).

%% 积分奖励配置
-record(base_seven_goal_score, {
    score = 0            %% 积分
    , reward = []         %% 奖励
}).

%% 技能奖励配置
-record(base_seven_skill_reward, {
    days = 0             %% 天数
    , skill_reward = 0   %% 技能奖励
    , name = <<>>
    , desc = ""
}).

%% 活动开放天数(每个人开始时间不同)
-define(ACT_OPEN_DAYS, 30).


%% ----------------------------- SQL ---------------------------
-define(SQL_UPDATE_TASK_REWARD, <<"UPDATE seven_days_goal SET `task_reward` = '~ts' WHERE `role_id` = ~p">>).
-define(SQL_UPDATE_SCORE_REWARD, <<"UPDATE seven_days_goal SET `score_reward` = '~ts' WHERE `role_id` = ~p">>).
-define(SQL_UPDATE_SKILL_REWARD, <<"UPDATE seven_days_goal SET `skill_reward` = '~ts' WHERE `role_id` = ~p">>).
-define(SQL_UPDATE_TASK_STATUS, <<"UPDATE seven_days_goal SET `score` = ~p WHERE `role_id` = ~p">>).
-define(SQL_UPDATE_LOGIN_DAY, <<"UPDATE seven_days_goal SET `days` = ~p, `score` = ~p WHERE `role_id` = ~p">>).
-define(SQL_REPLACE_INTO_SEVEN_DAYS_GOAL, <<"replace into `seven_days_goal`(`role_id`, `open_time`, `days`, `score`, `other_data`) values (~p, ~p, ~p, ~p, '~ts')">>).
-define(SQL_SELECT_SEVEN_DAYS_GOAL, <<"SELECT  `open_time`, `days`, `score`, `task_reward`, `score_reward`,
    `skill_reward`, `other_data` FROM `seven_days_goal` where `role_id` = ~p">>).
-define(SQL_SELECT_SEVEN_DAYS_TASK, <<"SELECT  `days`, `mod_id`, `sub_id`, `progress` FROM `seven_day_task` where `role_id` = ~p">>).
-define(SQL_REPLACE_INTO_SEVEN_DAYS_TASK, <<"replace into `seven_day_task`(`role_id`, `days`, `mod_id`, `sub_id`, `progress`)
 values (~p, ~p, ~p, ~p, ~p)">>).
-define(SQL_SELECT_EXP_DUN_REC, <<"SELECT  `data`  FROM `dungeon_best_record` WHERE `player_id` = ~p and `dun_id` = ~p">>).
-define(SQL_UPDATE_OPEN_TIME, <<"UPDATE seven_days_goal SET `open_time` = ~p WHERE `role_id` = ~p">>).
-define(SQL_SELECT_PART_TASK, <<"SELECT  `days`, `mod_id`, `sub_id`, `progress` FROM `seven_day_task` where `role_id` = ~p and mod_id = ~p and sub_id = ~p">>).
-define(SQL_SELECT_TIME_AND_SCORE, <<"SELECT  `open_time`, `score` FROM `seven_days_goal` where `role_id` = ~p">>).
-define(SQL_SELECT_RFMT, <<"SELECT pl.nickname,pl.lv,prr.recency,prr.frequency,prr.monetary,prr.top
FROM player_low pl LEFT JOIN player_recharge_rfmt prr ON pl.id = prr.role_id WHERE pl.id = ~p">>).
-define(SQL_UPDATE_OTHER_DATA, <<"UPDATE seven_days_goal SET `other_data` = '~ts' WHERE `role_id` = ~p">>).