%% ---------------------------------------------------------------------------
%% @doc 交易
%% @author hek
%% @since  2016-11-14
%% @deprecated
%% ---------------------------------------------------------------------------
-module (pp_auction).
-export ([handle/3]).
-include("server.hrl").
-include("common.hrl").
-include("guild.hrl").
-include("rec_auction.hrl").
-include("def_fun.hrl").
-include("errcode.hrl").
-include ("def_goods.hrl").
%% 获取拍卖菜单
handle(Cmd = 15400, PS, []) ->
	#player_status{id = PlayerId, guild = #status_guild{id = GuildId}} = PS,
	mod_auction:send_auction_catalog({Cmd, PlayerId, GuildId}),
	ok;

%% 获取拍卖物品
handle(Cmd = 15401, PS, [AuctionType, Type, ModuleId]) when AuctionType == ?AUCTION_GUILD orelse AuctionType == ?AUCTION_WORLD ->
	#player_status{id = PlayerId, guild = #status_guild{id = GuildId}} = PS,
	mod_auction:send_auction_goods({Cmd, PlayerId, GuildId, AuctionType, Type, ModuleId}),
	ok;

%% 竞拍商品
handle(Cmd = 15403, PS, [GoodsId, PriceType, BGold, Gold]) ->
	#player_status{id = PlayerId, sid = Sid, guild = #status_guild{id = GuildId}} = PS,
	BGoldList = ?IF(BGold>0, [{?TYPE_BGOLD, 0, BGold}], []),
	GoldList = ?IF(Gold>0,  [{?TYPE_GOLD, 0, Gold}], []),
	PriceList  = BGoldList ++ GoldList,
	case lib_auction:pay_auction(PS, {Cmd, PlayerId, GuildId, GoodsId, PriceType, PriceList}) of
		{false, Res} ->
			?ERR_MSG(Cmd, Res),
			lib_server_send:send_to_sid(Sid, pt_154, Cmd, [Res, PriceType]);
		_ -> skip
	end;

%% 我的竞拍
handle(Cmd = 15405, PS, []) ->
	handle(Cmd, PS, [1]);
handle(Cmd = 15405, PS, [Type]) when Type==1 orelse Type==2 orelse Type==3 ->
	#player_status{id = PlayerId} = PS,
	mod_auction:send_my_auction({Cmd, PlayerId, Type}),
	ok;

%% 拍卖记录
handle(Cmd = 15406, PS, [AuctionType]) ->
	#player_status{id = PlayerId, guild = #status_guild{id = GuildId}} = PS,
	mod_auction:send_auction_log({Cmd, PlayerId, GuildId, AuctionType}),
	ok;

%% 预计分红
handle(Cmd = 15407, PS, []) ->
	#player_status{id = PlayerId, guild = #status_guild{id = GuildId}} = PS,
	mod_auction:send_auction_estimate_bonus({Cmd, PlayerId, GuildId}),
	ok;

%% 增加个人拍卖
% handle(_Cmd = 15410, PS, [AutoId, GoodsTypeId, Type]) ->
% 	{ok, NewPS} = lib_auction:add_personal_goods(PS, AutoId, GoodsTypeId, Type),
% 	{ok, NewPS};

handle(_Cmd, _PS, _Data) ->
    ?PRINT("no match :~p~n", [{_Cmd, _Data}]),
    {error, "pp_auction no match"}.
