%%%-------------------------------------------------------------------
%%% @author : tyl
%%% @doc    时装工坊-头文件
%%% Module  : fashion_workroom.hrl
%%% Created : 2021-05-20
%%% @end
%%%-------------------------------------------------------------------

-define(DEFAULT_TARGET_LEN, 5).     %% 默认打造目标数量
-define(DEFAULT_STORE_LEN, 10).     %% 默认商城商品数量
-define(DEFAULT_TYPE_NEED, 3).      %% 默认需要商城商品类型数量

%% 工坊数据
-record(status_workroom, {
	forge_targets  = []     %% 打造列表[{pos,goods_id}...]
	,suit_list     = []     %% 套装列表[#suit_info{}...]
	,shop          = []     %% 商城信息
	,attr_list     = []     %% 属性
}).

%% 套装信息
-record(suit_info, {
	suit_id        = 0     %% 套装Id
	,own_num       = 0     %% 拥有件数
	,active_num    = 0     %% 激活件数
	,sum_star      = 0     %% 总星级(全部激活才有)
}).

%% 商城数据
-record(workroom_shop, {
	shop_goods     = []     %% 商城物品[#shop_good{}...]
	,last_refresh  = 0      %% 上次更新时间
	,refresh_count = 0      %% 刷新次数
}).

%% 商品信息
-record(shop_good, {
	pos         = 0         %% 位置
	,goods_id   = 0         %% 商品Id
	,has_buy    = 0         %% 是否已经购买
}).

%% ------------------- 配置 -------------------------------------
%% 打造配置表
-record(base_workroom_forge, {
	fashion_type    = 0     %% 时装类型
	,goods_id       = 0     %% 时装物品Id
	,cost           = []    %% 消耗材料
	,open_day       = 0     %% 开启天数
	,open_time      = 0     %% 开启时间
	,is_recommend   = 0     %% 是否推荐
	,sequence       = 0     %% 序号
}).

%% 套装配置表
-record(base_workroom_suit, {
	suit_id         = 0     %% 套装Id
	,goods_list     = []    %% 套装物品列表
	,sequence       = 0     %% 序号
	,suit_name      = ""    %% 套装名称
	,is_recommend   = 0     %% 是否推荐
	,attr_list      = []    %% 件数属性
}).

%% 套装星级配置表
-record(base_workroom_suit_star, {
	suit_id         = 0     %% 套装Id
	,sum_star       = 0     %% 套装总星级
	,attr_list      = []    %% 属性
}).

%% 商店配置表
-record(base_workroom_store, {
	fashion_id      = 0     %% 时装Id
	,price_list     = []    %% 价格
	,weight         = 0     %% 权重(万分比)
	,limit          = 0     %% 数量限制
	,tag            = 0     %% 标签(角标)
}).

%% ------------------- db -------------------------------------
-define(SQL_INSERT_FORGET_TARGET, <<"REPLACE INTO workroom_forge_target (`role_id`, `pos`, `goods_id`) VALUES ~ts">>).
-define(SQL_INSERT_FORGET_TARGET_VALUE, <<"(~p, ~p, ~p)">>).
-define(SQL_SELECT_FORGET_TARGET, <<"SELECT `pos`, `goods_id` FROM workroom_forge_target WHERE `role_id` = ~p">>).
-define(SQL_DELETE_FORGET_TARGET, <<"DELETE FROM  workroom_forge_target  WHERE `role_id` = ~p">>).

-define(SQL_INSERT_WORKROOM_SUIT, <<"REPLACE INTO workroom_suit (`role_id`, `suit_id`, `own_num`, `active_num`, `sum_star`) VALUES ~ts">>).
-define(SQL_INSERT_WORKROOM_SUIT_VALUE, <<"(~p, ~p, ~p, ~p, ~p)">>).
-define(SQL_SELECT_WORKROOM_SUIT, <<"SELECT `suit_id`, `own_num`, `active_num`, `sum_star` FROM workroom_suit WHERE `role_id` = ~p">>).

-define(SQL_INSERT_WORKROOM_SHOP, <<"REPLACE INTO workroom_shop (`role_id`, `last_refresh`, `refresh_count`) VALUES (~p, ~p, ~p)">>).
-define(SQL_SELECT_WORKROOM_SHOP, <<"SELECT `last_refresh`, `refresh_count` FROM workroom_shop WHERE `role_id` = ~p limit 1">>).

-define(SQL_INSERT_SHOP_GOODS, <<"REPLACE INTO workroom_shop_goods (`role_id`, `pos`, `goods_id`, `has_buy`) VALUES ~ts">>).
-define(SQL_INSERT_SHOP_GOODS_VALUE, <<" (~p, ~p, ~p, ~p)">>).
-define(SQL_SELECT_SHOP_GOODS, <<"SELECT `pos`, `goods_id`, `has_buy` FROM workroom_shop_goods WHERE `role_id` = ~p">>).
-define(SQL_UPDATE_SHOP_GOODS, <<"UPDATE workroom_shop_goods set `has_buy` = ~p WHERE `role_id` = ~p AND `goods_id`=~p">>).
-define(SQL_DELETE_SHOP_GOODS, <<"DELETE FROM  workroom_shop_goods  WHERE `role_id` = ~p">>).