ShopSProxy.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. using System.Collections.Generic;
  2. using cfg.GfgCfg;
  3. using ET;
  4. using GFGGame;
  5. namespace ET
  6. {
  7. public class S2C_SyncRechargeItemGetHandler : AMHandler<S2C_SyncRechargeItemGet>
  8. {
  9. protected override async ETTask Run(Session session, S2C_SyncRechargeItemGet message)
  10. {
  11. var dTime = TimeHelper.ServerNow() - message.OrderTime;
  12. ShopSProxy.OnBuySuccess(message.BuyId, message.Times, message.TotalTimes,
  13. dTime <= GameGlobal.maxShowOrderTime);
  14. GameGlobal.maxShowOrderTime = GameConst.DEFAULT_MAX_ORDER_TIME;
  15. }
  16. }
  17. public class NoticeMonthCardOpen : AMHandler<S2C_NoticeMonthCardOpen>
  18. {
  19. protected override async ETTask Run(Session session, S2C_NoticeMonthCardOpen message)
  20. {
  21. MonthlyCardPrivilegeCfg privilegeCfg =
  22. CommonDataManager.Tables.TblMonthlyCardPrivilegeCfg.GetOrDefault(MonthCardPrivilegeType.Privilege1);
  23. List<ItemParamProto> itemData = new List<ItemParamProto>();
  24. if (message.MonthCardType == MonthCardType.Gold)
  25. {
  26. ItemParamProto itemParam = new ItemParamProto()
  27. {
  28. ItemId = privilegeCfg.Params1[0],
  29. Count = privilegeCfg.Value1[0]
  30. };
  31. itemData.Add(itemParam);
  32. }
  33. else if (message.MonthCardType == MonthCardType.BlackGold)
  34. {
  35. ItemParamProto itemParam = new ItemParamProto()
  36. {
  37. ItemId = privilegeCfg.Params1[0],
  38. Count = privilegeCfg.Value2[0]
  39. };
  40. itemData.Add(itemParam);
  41. }
  42. BonusController.TryShowBonusList(itemData);
  43. await ETTask.CompletedTask;
  44. }
  45. }
  46. }
  47. namespace GFGGame
  48. {
  49. public class ShopSProxy
  50. {
  51. public static async ETTask<bool> ReqShopInfo()
  52. {
  53. S2C_RequestShopInfo response = null;
  54. response = (S2C_RequestShopInfo)await MessageHelper.SendToServer(new C2S_RequestShopInfo());
  55. if (response != null)
  56. {
  57. if (response.Error == ErrorCode.ERR_Success)
  58. {
  59. for (int i = 0; i < response.ks.Count; i++)
  60. {
  61. ShopDataManager.Instance.UpdateGoodsData(response.ks[i], response.vs[i]);
  62. }
  63. return true;
  64. }
  65. }
  66. return false;
  67. }
  68. public static async ETTask<bool> ReqShopBuy(int buyId, long buyCount = 1)
  69. {
  70. S2C_ShopBuy response = null;
  71. response = (S2C_ShopBuy)await MessageHelper.SendToServer(new C2S_ShopBuy()
  72. { BuyId = buyId, Times = (int)buyCount });
  73. if (response != null)
  74. {
  75. if (response.Error == ErrorCode.ERR_Success)
  76. {
  77. ShopCfg shopCfg = CommonDataManager.Tables.TblShopCfg.GetOrDefault(response.BuyId);
  78. if (shopCfg.CostTypeReal == CostType.RMB)
  79. {
  80. QDManager.Pay(response.BuyId, response.Times, response.OrderId, response.Price);
  81. return false;
  82. }
  83. else
  84. {
  85. OnBuySuccess(response.BuyId, response.Times, response.TotalTimes, true);
  86. return true;
  87. }
  88. }
  89. }
  90. return false;
  91. }
  92. public static void OnBuySuccess(int buyId, int times, int totalTimes, bool showItems)
  93. {
  94. ShopDataManager.Instance.UpdateGoodsData(buyId, totalTimes);
  95. ShopCfg shopCfg = CommonDataManager.Tables.TblShopCfg.GetOrDefault(buyId);
  96. ItemCfg itemCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(shopCfg.ItemId);
  97. EventAgent.DispatchEvent(ConstMessage.CONTINUOUS_REBATE_GIFT_SHOP_BUY, shopCfg);
  98. if (showItems)
  99. {
  100. //判断倍数
  101. var multiple = 1;
  102. //if (totalTimes <= shopCfg.doubleTimes)a
  103. //{
  104. // multiple = 2;
  105. //}
  106. List<ItemData> itemDatas = new List<ItemData>();
  107. itemDatas.Add(ItemUtil.createItemData(itemCfg.Id, times * shopCfg.ItemNum * multiple));
  108. if (shopCfg.DoubleItemId > 0 && totalTimes <= shopCfg.DoubleTimes)
  109. {
  110. ItemCfg doubleItemIdCfg = CommonDataManager.Tables.TblItemCfg.GetOrDefault(shopCfg.DoubleItemId);
  111. itemDatas.Add(ItemUtil.createItemData(doubleItemIdCfg.Id, times * shopCfg.ItemNum * multiple));
  112. }
  113. BonusController.TryShowBonusList(itemDatas);
  114. }
  115. EventAgent.DispatchEvent(ConstMessage.SHOP_BUY);
  116. EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
  117. }
  118. /**********************************************会员中心**********************************************/
  119. //领取VIP等级礼包
  120. public static async ETTask<bool> ReqGetVipGiftBag(int vipLv)
  121. {
  122. S2C_GetVipLevelGift response = null;
  123. response = (S2C_GetVipLevelGift)await MessageHelper.SendToServer(new C2S_GetVipLevelGift()
  124. { VipLevel = vipLv });
  125. if (response != null)
  126. {
  127. if (response.Error == ErrorCode.ERR_Success)
  128. {
  129. //int[][] bonus = VipCfgArray.Instance.GetCfg(vipLv - 1).bonusOnceArr;
  130. var bonus = CommonDataManager.Tables.TblVipCfg.GetOrDefault(vipLv - 1).BonusOnce;
  131. BonusController.TryShowBonusList(bonus.ToGfgGameItemParam());
  132. return true;
  133. }
  134. }
  135. return false;
  136. }
  137. //领取VIP周礼包
  138. public static async ETTask<bool> ReqGetVipWeekGiftBag(int vipLv)
  139. {
  140. S2C_GetVipWeekGift response = null;
  141. response = (S2C_GetVipWeekGift)await MessageHelper.SendToServer(new C2S_GetVipWeekGift()
  142. { VipLevel = vipLv });
  143. if (response != null)
  144. {
  145. if (response.Error == ErrorCode.ERR_Success)
  146. {
  147. var bonus = CommonDataManager.Tables.TblVipCfg.GetOrDefault(vipLv).BonusWeek;
  148. BonusController.TryShowBonusList(bonus.ToGfgGameItemParam());
  149. return true;
  150. }
  151. }
  152. return false;
  153. }
  154. /*********************************************************月卡***************************************************/
  155. //领取每日返还珍珠
  156. public static async ETTask<bool> ReqGetMonthCardReward(int monthCardType)
  157. {
  158. S2C_GetMonthCardReward response = null;
  159. response = (S2C_GetMonthCardReward)await MessageHelper.SendToServer(new C2S_GetMonthCardReward()
  160. { MonthCardType = monthCardType });
  161. if (response != null)
  162. {
  163. if (response.Error == ErrorCode.ERR_Success)
  164. {
  165. MonthlyCardPrivilegeCfg privilegeCfg =
  166. CommonDataManager.Tables.TblMonthlyCardPrivilegeCfg.GetOrDefault(MonthCardPrivilegeType
  167. .Privilege1);
  168. List<ItemParamProto> itemData = new List<ItemParamProto>();
  169. if (monthCardType == MonthCardType.Gold)
  170. {
  171. itemData.Add(new ItemParamProto()
  172. {
  173. ItemId = privilegeCfg.Params1[1],
  174. Count = privilegeCfg.Value1[1]
  175. });
  176. }
  177. else if (monthCardType == MonthCardType.BlackGold)
  178. {
  179. itemData.Add(new ItemParamProto()
  180. {
  181. ItemId = privilegeCfg.Params1[1],
  182. Count = privilegeCfg.Value2[1]
  183. });
  184. }
  185. BonusController.TryShowBonusList(itemData);
  186. EventAgent.DispatchEvent(ConstMessage.RED_CHANGE);
  187. return true;
  188. }
  189. }
  190. return false;
  191. }
  192. //领取专属单品
  193. public static async ETTask<bool> ReqGetMonthCardItem(int month)
  194. {
  195. S2C_GetMonthCardItem response = null;
  196. response = (S2C_GetMonthCardItem)await MessageHelper.SendToServer(new C2S_GetMonthCardItem());
  197. if (response != null)
  198. {
  199. if (response.Error == ErrorCode.ERR_Success)
  200. {
  201. MonthlyCardClothesCfg clothesCfg =
  202. CommonDataManager.Tables.TblMonthlyCardClothesCfg.Get(TimeUtil.GetCurYear(), month);
  203. List<ItemData> itemDatas =
  204. ItemUtil.CreateItemDataList(clothesCfg.Clothes.ToGfgGameItemParam());
  205. BonusController.TryShowBonusList(itemDatas);
  206. return true;
  207. }
  208. }
  209. return false;
  210. }
  211. //获取成长基金消息
  212. public static async ETTask<bool> ReqGetGrowthFundInfo(int activityID = 3002)
  213. {
  214. ShopDataManager.Instance.GrowthFundRewardList.Clear();
  215. S2C_GetGrowthFundRewrdStatus response = null;
  216. response = (S2C_GetGrowthFundRewrdStatus)await MessageHelper.SendToServer(new C2S_GetGrowthFundRewrdStatus()
  217. { ActivityId = activityID });
  218. if (response != null)
  219. {
  220. if (response.Error == ErrorCode.ERR_Success)
  221. {
  222. ShopDataManager.Instance.GrowthFundRewardList = response.RewrdIds;
  223. return true;
  224. }
  225. }
  226. return false;
  227. }
  228. //领取成长基金奖励
  229. public static async ETTask<bool> ReqGetGrowthFundReward(int activityID, int id)
  230. {
  231. S2C_GetGrowthFundRewrd response = null;
  232. response = (S2C_GetGrowthFundRewrd)await MessageHelper.SendToServer(new C2S_GetGrowthFundRewrd()
  233. { ActivityId = activityID, RewrdId = id });
  234. if (response != null)
  235. {
  236. if (response.Error == ErrorCode.ERR_Success)
  237. {
  238. ShopDataManager.Instance.GrowthFundRewardList.Add(id);
  239. BonusController.TryShowBonusList(ItemUtil.CreateItemDataList(response.BonusList));
  240. return true;
  241. }
  242. }
  243. return false;
  244. }
  245. //创建支付宝订单
  246. public static async ETTask<S2C_CreateAliOrder> ReqCreateAliOrder(long tempOrderId)
  247. {
  248. var response = (S2C_CreateAliOrder)await MessageHelper.SendToServer(new C2S_CreateAliOrder()
  249. { OrderTempId = tempOrderId });
  250. return response;
  251. }
  252. //创建微信订单
  253. public static async ETTask<S2C_CreateWeChatPayOrder> ReqCreateWeChatOrder(long tempOrderId)
  254. {
  255. var response = (S2C_CreateWeChatPayOrder)await MessageHelper.SendToServer(new C2S_CreateWeChatPayOrder()
  256. { OrderTempId = tempOrderId });
  257. return response;
  258. }
  259. }
  260. }