%%-----------------------------------------------------------------------------
%% @doc 福利大厅
%%-----------------------------------------------------------------------------

%% 计数器：每日
-define(COUNTER_WELFARE_SIGN_IN, 	  1).	%% 每日签到状态
-define(COUNTER_WELFARE_ONLINE_TIME,  2).	%% 每日在线时长
-define(COUNTER_WELFARE_ONLINE_AWARD, 3).	%% 在线奖励领取状态
-define(COUNTER_WELFARE_LEVEL_AWARD,  4).	%% 等级奖励领取状态
%% 计数器：全服
-define(COUNTER_GLOBAL_LEVEL_AWARD, 1).

%% 奖励领取状态
-define(WELFARE_AWARD_STATE(State, No),
	(State band (1 bsl (No - 1)))
).
%% 设置奖励领取状态
-define(WELFARE_SET_AWARD_STATE(State, No),
	(State bxor (1 bsl (No - 1)))
).

-record(status_welfare, {
	%% 每日签到: 签到状态由计数器控制
	sign_in_round = 0	%% 签到周期
	, sign_in_days = 0  %% 签到天数
	, cumulative_sign_in_info = 0 %% 累计签到奖励情况
	%% 在线奖励: 在线时长和奖励领取情况存放于日计数器
	, online_type = 1   %% 在线奖励类型：某个时机会变成2
	%% 冲级大礼
	, level_award_state = 0
	%% 资源下载
	, download_award_state = 0
}).

%-----------------------------------------------------------------------------
%% @doc DB
%-----------------------------------------------------------------------------
%% 上线初始化
-define(SQL_GET_WELFARE_DATA, <<"select round,days,online_type,level_award_state,download_award_state,cumulative_sign_in_info from player_welfare where role_id=~p">>).
%% 保存数据
-define(SQL_SAVE_WELFARE_DATA, <<"replace into player_welfare(role_id,round,days,online_type,level_award_state,download_award_state,cumulative_sign_in_info) values(~p,~p,~p,~p,~p,~p,~p)">>).
%%在线数据
-define(sql_select_online, <<"select `count`,`refresh_time` from `counter_daily_twelve` where `role_id` = ~p and `module`=~p and `sub_module`=0 and `type`=~p">>).


%-----------------------------------------------------------------------------
%% @doc 配置
%-----------------------------------------------------------------------------
-record(base_welfare_sign_in_award, {
	round,
	day,
	award,
	vip_lv,
	vip_ratio
}).

-record(base_welfare_level_award, {
	id,
	level,
	career,
	sex,
	award,
	limit_award,
	limit_num
}).