| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- using System.Collections.Generic;
- using cfg.GfgCfg;
- using ET;
- using GFGGame;
- namespace ET
- {
- public class S2C_SyncRechargeItemGetHandler : AMHandler<S2C_SyncRechargeItemGet>
- {
- protected override async ETTask Run(Session session, S2C_SyncRechargeItemGet message)
- {
- var dTime = TimeHelper.ServerNow() - message.OrderTime;
- ShopSProxy.OnBuySuccess(message.BuyId, message.Times, message.TotalTimes,
- dTime <= GameGlobal.maxShowOrderTime);
- GameGlobal.maxShowOrderTime = GameConst.DEFAULT_MAX_ORDER_TIME;
- }
- }
- public class NoticeMonthCardOpen : AMHandler<S2C_NoticeMonthCardOpen>
- {
- protected override async ETTask Run(Session session, S2C_NoticeMonthCardOpen message)
- {
- MonthlyCardPrivilegeCfg privilegeCfg =
- CommonDataManager.Tables.TblMonthlyCardPrivilegeCfg.GetOrDefault(MonthCardPrivilegeType.Privilege1);
- List<ItemParamProto> itemData = new List<ItemParamProto>();
- if (message.MonthCardType == MonthCardType.Gold)
- {
- ItemParamProto itemParam = new ItemParamProto()
- {
- ItemId = privilegeCfg.Params1[0],
- Count = privilegeCfg.Value1[0]
- };
- itemData.Add(itemParam);
- }
- else if (message.MonthCardType == MonthCardType.BlackGold)
- {
- ItemParamProto itemParam = new ItemParamProto()
- {
- ItemId = privilegeCfg.Params1[0],
- Count = privilegeCfg.Value2[0]
- };
- itemData.Add(itemParam);
- }
- BonusController.TryShowBonusList(itemData);
- await ETTask.CompletedTask;
- }
- }
- }
- namespace GFGGame
- {
- public class ShopSProxy
- {
- public static async ETTask<bool> ReqShopInfo()
- {
- S2C_RequestShopInfo response = null;
- response = (S2C_RequestShopInfo)await MessageHelper.SendToServer(new C2S_RequestShopInfo());
- if (response != null)
- {
- if (response.Error == ErrorCode.ERR_Success)
- {
- for (int i = 0; i < response.ks.Count; i++)
- {
- ShopDataManager.Instance.UpdateGoodsData(response.ks[i], response.vs[i]);
- }
- return true;
- }
- }
- return false;
- }
- public static async ETTask<bool> ReqShopBuy(int buyId, long buyCount = 1)
- {
- S2C_ShopBuy response = null;
- response = (S2C_ShopBuy)await MessageHelper.SendToServer(new C2S_ShopBuy()
- { BuyId = buyId, Times = (int)buyCount });
- if (response != null)
- {
- if (response.Error == ErrorCode.ERR_Success)
- {
- ShopCfg shopCfg = CommonDataManager.Tables.TblShopCfg.GetOrDefault(response.BuyId);
- if (shopCfg.CostTypeReal == CostType.RMB)
- {
- QDManager.Pay(response.BuyId, response.Times, response.OrderId, response.Price);
- return false;
- }
- else
- {
- OnBuySuccess(response.BuyId, response.Times, response.TotalTimes, true);
- return true;
- }
- }
- }
- return false;
- }
- public static void OnBuySuccess(int buyId, int times, int totalTimes, bool showItems)
- {
- ShopDataManager.Instance.UpdateGoodsData(buyId, totalTimes);
- ShopCfg shopCfg = CommonDataManager.Tables.TblShopCfg.GetOrDefault(buyId);
- ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(shopCfg.ItemId);
- EventAgent.DispatchEvent(ConstMessage.CONTINUOUS_REBATE_GIFT_SHOP_BUY, shopCfg);
- if (showItems)
- {
- //判断倍数
- var multiple = 1;
- //if (totalTimes <= shopCfg.doubleTimes)a
- //{
- // multiple = 2;
- //}
- List<ItemData> itemDatas = new List<ItemData>();
- itemDatas.Add(ItemUtil.createItemData(itemCfg.Id, times * shopCfg.ItemNum * multiple));
- if (shopCfg.DoubleItemId > 0 && totalTimes <= shopCfg.DoubleTimes)
- {
- ItemCfg doubleItemIdCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(shopCfg.DoubleItemId);
- itemDatas.Add(ItemUtil.createItemData(doubleItemIdCfg.Id, times * shopCfg.ItemNum * multiple));
- }
- BonusController.TryShowBonusList(itemDatas);
- }
- EventAgent.DispatchEvent(ConstMessage.SHOP_BUY);
- EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
- }
- /**********************************************会员中心**********************************************/
- //领取VIP等级礼包
- public static async ETTask<bool> ReqGetVipGiftBag(int vipLv)
- {
- S2C_GetVipLevelGift response = null;
- response = (S2C_GetVipLevelGift)await MessageHelper.SendToServer(new C2S_GetVipLevelGift()
- { VipLevel = vipLv });
- if (response != null)
- {
- if (response.Error == ErrorCode.ERR_Success)
- {
- //int[][] bonus = VipCfgArray.Instance.GetCfg(vipLv - 1).bonusOnceArr;
- var bonus = CommonDataManager.Tables.TblVipCfg.GetOrDefault(vipLv - 1).BonusOnce;
- BonusController.TryShowBonusList(bonus.ToGfgGameItemParam());
- return true;
- }
- }
- return false;
- }
- //领取VIP周礼包
- public static async ETTask<bool> ReqGetVipWeekGiftBag(int vipLv)
- {
- S2C_GetVipWeekGift response = null;
- response = (S2C_GetVipWeekGift)await MessageHelper.SendToServer(new C2S_GetVipWeekGift()
- { VipLevel = vipLv });
- if (response != null)
- {
- if (response.Error == ErrorCode.ERR_Success)
- {
- var bonus = CommonDataManager.Tables.TblVipCfg.GetOrDefault(vipLv).BonusWeek;
- BonusController.TryShowBonusList(bonus.ToGfgGameItemParam());
- return true;
- }
- }
- return false;
- }
- /*********************************************************月卡***************************************************/
- //领取每日返还珍珠
- public static async ETTask<bool> ReqGetMonthCardReward(int monthCardType)
- {
- S2C_GetMonthCardReward response = null;
- response = (S2C_GetMonthCardReward)await MessageHelper.SendToServer(new C2S_GetMonthCardReward()
- { MonthCardType = monthCardType });
- if (response != null)
- {
- if (response.Error == ErrorCode.ERR_Success)
- {
- MonthlyCardPrivilegeCfg privilegeCfg =
- CommonDataManager.Tables.TblMonthlyCardPrivilegeCfg.GetOrDefault(MonthCardPrivilegeType
- .Privilege1);
- List<ItemParamProto> itemData = new List<ItemParamProto>();
- if (monthCardType == MonthCardType.Gold)
- {
- itemData.Add(new ItemParamProto()
- {
- ItemId = privilegeCfg.Params1[1],
- Count = privilegeCfg.Value1[1]
- });
- }
- else if (monthCardType == MonthCardType.BlackGold)
- {
- itemData.Add(new ItemParamProto()
- {
- ItemId = privilegeCfg.Params1[1],
- Count = privilegeCfg.Value2[1]
- });
- }
- BonusController.TryShowBonusList(itemData);
- EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
- return true;
- }
- }
- return false;
- }
- //领取专属单品
- public static async ETTask<bool> ReqGetMonthCardItem(int month)
- {
- S2C_GetMonthCardItem response = null;
- response = (S2C_GetMonthCardItem)await MessageHelper.SendToServer(new C2S_GetMonthCardItem());
- if (response != null)
- {
- if (response.Error == ErrorCode.ERR_Success)
- {
- MonthlyCardClothesCfg clothesCfg =
- CommonDataManager.Tables.TblMonthlyCardClothesCfg.Get(TimeUtil.GetCurYear(), month);
- List<ItemData> itemDatas =
- ItemUtil.CreateItemDataList(clothesCfg.Clothes.ToGfgGameItemParam());
- BonusController.TryShowBonusList(itemDatas);
- return true;
- }
- }
- return false;
- }
- //获取成长基金消息
- public static async ETTask<bool> ReqGetGrowthFundInfo(int activityID = 3002)
- {
- ShopDataManager.Instance.GrowthFundRewardList.Clear();
- S2C_GetGrowthFundRewrdStatus response = null;
- response = (S2C_GetGrowthFundRewrdStatus)await MessageHelper.SendToServer(new C2S_GetGrowthFundRewrdStatus()
- { ActivityId = activityID });
- if (response != null)
- {
- if (response.Error == ErrorCode.ERR_Success)
- {
- ShopDataManager.Instance.GrowthFundRewardList = response.RewrdIds;
- return true;
- }
- }
- return false;
- }
- //领取成长基金奖励
- public static async ETTask<bool> ReqGetGrowthFundReward(int activityID, int id)
- {
- S2C_GetGrowthFundRewrd response = null;
- response = (S2C_GetGrowthFundRewrd)await MessageHelper.SendToServer(new C2S_GetGrowthFundRewrd()
- { ActivityId = activityID, RewrdId = id });
- if (response != null)
- {
- if (response.Error == ErrorCode.ERR_Success)
- {
- ShopDataManager.Instance.GrowthFundRewardList.Add(id);
- BonusController.TryShowBonusList(ItemUtil.CreateItemDataList(response.BonusList));
- return true;
- }
- }
- return false;
- }
- //创建支付宝订单
- public static async ETTask<S2C_CreateAliOrder> ReqCreateAliOrder(long tempOrderId)
- {
- var response = (S2C_CreateAliOrder)await MessageHelper.SendToServer(new C2S_CreateAliOrder()
- { OrderTempId = tempOrderId });
- return response;
- }
- //创建微信订单
- public static async ETTask<S2C_CreateWeChatPayOrder> ReqCreateWeChatOrder(long tempOrderId)
- {
- var response = (S2C_CreateWeChatPayOrder)await MessageHelper.SendToServer(new C2S_CreateWeChatPayOrder()
- { OrderTempId = tempOrderId });
- return response;
- }
- }
- }
|