예제 #1
0
 public void processEvent(EventObject eventObject)
 {
     if (eventObject.getEventType() == 36)
     {
         ChargeItemBaseEventObject obj = eventObject as ChargeItemBaseEventObject;
         if (this.CheckValidChargeItem(obj.ChargeItemConfig.ChargeItemID))
         {
             Dictionary <int, int> ZhiGouInfoDict = this.BuildThemeZhiGouInfoForClient(obj.Player);
             obj.Player.sendCmd <Dictionary <int, int> >(906, ZhiGouInfoDict, false);
             if (obj.Player._IconStateMgr.CheckThemeZhiGou(obj.Player))
             {
                 obj.Player._IconStateMgr.SendIconStateToClient(obj.Player);
             }
         }
     }
 }
예제 #2
0
 public void HandleClientChargeItem(GameClient client, byte HandleDel = 0)
 {
     if (client != null && !GameManager.IsKuaFuServer)
     {
         lock (client.ClientData.ChargeItemMutex)
         {
             List <TempItemChargeInfo> list = new List <TempItemChargeInfo>();
             string cmd = string.Format("{0}:{1}:{2}", client.strUserID, client.ClientData.RoleID, HandleDel);
             list = Global.sendToDB <List <TempItemChargeInfo>, string>(13320, cmd, client.ServerId);
             if (list != null && list.Count != 0)
             {
                 if (HandleDel == 1)
                 {
                     this.ComputeClientChargeItem(client, list);
                 }
                 Dictionary <int, ChargeItemData> ChargeItemDict = Data.ChargeItemDict;
                 for (int i = 0; i < list.Count; i++)
                 {
                     TempItemChargeInfo tempitem = list[i];
                     if (tempitem.isDel == 0)
                     {
                         int            ProcessChargeMoney = 0;
                         int            ReturnUserMoney    = 0;
                         ChargeItemData configdata         = null;
                         if (!ChargeItemDict.TryGetValue(tempitem.zhigouID, out configdata))
                         {
                             LogManager.WriteLog(LogTypes.Error, string.Format("充值直购zhigouID错误 uid={0},rid={1},money={2},itemid={3},chargeTm={4}", new object[]
                             {
                                 tempitem.userID,
                                 tempitem.chargeRoleID,
                                 tempitem.addUserMoney,
                                 tempitem.zhigouID,
                                 tempitem.chargeTime
                             }), null, true);
                             ProcessChargeMoney = 1;
                         }
                         else if (string.Compare(tempitem.chargeTime, configdata.FromDate) < 0 || string.Compare(tempitem.chargeTime, configdata.ToDate) > 0)
                         {
                             LogManager.WriteLog(LogTypes.Error, string.Format("充值直购Time错误 uid={0},rid={1},money={2},itemid={3},chargeTm={4}", new object[]
                             {
                                 tempitem.userID,
                                 tempitem.chargeRoleID,
                                 tempitem.addUserMoney,
                                 tempitem.zhigouID,
                                 tempitem.chargeTime
                             }), null, true);
                             ProcessChargeMoney = 1;
                         }
                         else
                         {
                             int Money = 0;
                             if (!Data.ChargeData.ChargeIDVsMoneyDict.TryGetValue(configdata.ChargeDangID, out Money))
                             {
                                 LogManager.WriteLog(LogTypes.Error, string.Format("充值直购Dang错误 uid={0},rid={1},money={2},itemid={3},chargeTm={4}", new object[]
                                 {
                                     tempitem.userID,
                                     tempitem.chargeRoleID,
                                     tempitem.addUserMoney,
                                     tempitem.zhigouID,
                                     tempitem.chargeTime
                                 }), null, true);
                                 ProcessChargeMoney = 1;
                             }
                             else
                             {
                                 int ZhiGouImplicit = GameManager.PlatConfigMgr.GetGameConfigItemInt("zhigou_implicit", 0);
                                 if (ZhiGouImplicit > 0)
                                 {
                                     if (tempitem.addUserMoney < Money)
                                     {
                                         LogManager.WriteLog(LogTypes.Error, string.Format("充值直购Money错误 uid={0},rid={1},money={2},itemid={3},chargeTm={4}", new object[]
                                         {
                                             tempitem.userID,
                                             tempitem.chargeRoleID,
                                             tempitem.addUserMoney,
                                             tempitem.zhigouID,
                                             tempitem.chargeTime
                                         }), null, true);
                                         ProcessChargeMoney = 1;
                                     }
                                     else
                                     {
                                         ReturnUserMoney = Math.Max(tempitem.addUserMoney - Money, 0);
                                     }
                                 }
                                 else if (tempitem.addUserMoney != Money)
                                 {
                                     LogManager.WriteLog(LogTypes.Error, string.Format("充值直购Money错误 uid={0},rid={1},money={2},itemid={3},chargeTm={4}", new object[]
                                     {
                                         tempitem.userID,
                                         tempitem.chargeRoleID,
                                         tempitem.addUserMoney,
                                         tempitem.zhigouID,
                                         tempitem.chargeTime
                                     }), null, true);
                                     ProcessChargeMoney = 1;
                                 }
                             }
                         }
                         int PurchaseNum    = this.GetChargeItemPurchaseNum(client, tempitem.zhigouID);
                         int DayPurchaseNum = this.GetChargeItemDayPurchaseNum(client, tempitem.zhigouID);
                         if (configdata != null && configdata.SinglePurchase > 0 && PurchaseNum >= configdata.SinglePurchase)
                         {
                             ProcessChargeMoney = 1;
                         }
                         if (configdata != null && configdata.DayPurchase > 0)
                         {
                             EverydayActivity everyAct = HuodongCachingMgr.GetEverydayActivity();
                             if (everyAct == null || !everyAct.CheckValidChargeItem(tempitem.zhigouID))
                             {
                                 ProcessChargeMoney = 1;
                             }
                             if (DayPurchaseNum >= configdata.DayPurchase)
                             {
                                 ProcessChargeMoney = 1;
                             }
                         }
                         if (configdata != null && configdata.ThemePurchase > 0)
                         {
                             ThemeZhiGouActivity zhigouAct = HuodongCachingMgr.GetThemeZhiGouActivity();
                             if (zhigouAct == null || !zhigouAct.CheckValidChargeItem(tempitem.zhigouID))
                             {
                                 ProcessChargeMoney = 1;
                             }
                             if (DayPurchaseNum >= configdata.ThemePurchase)
                             {
                                 ProcessChargeMoney = 1;
                             }
                         }
                         SpecPriorityActivity spAct = HuodongCachingMgr.GetSpecPriorityActivity();
                         if (spAct != null && !spAct.CheckValidChargeItem(tempitem.zhigouID))
                         {
                             ProcessChargeMoney = 1;
                         }
                         RegressActiveDayBuy radbAct = HuodongCachingMgr.GetRegressActiveDayBuy();
                         if (radbAct != null && !radbAct.CheckValidChargeItem(client, tempitem.zhigouID))
                         {
                             ProcessChargeMoney = 1;
                         }
                         cmd = string.Format("{0}:{1}:{2}", tempitem.ID, ProcessChargeMoney, ReturnUserMoney);
                         string[]             dbFields        = null;
                         TCPProcessCmdResults dbRequestResult = Global.RequestToDBServer(Global._TCPManager.tcpClientPool, Global._TCPManager.TcpOutPacketPool, 13321, cmd, out dbFields, client.ServerId);
                         if (dbRequestResult != TCPProcessCmdResults.RESULT_FAILED && dbFields.Length > 0)
                         {
                             if (ProcessChargeMoney == 0)
                             {
                                 this.AddChargeItemPurchaseNum(client, tempitem.zhigouID);
                                 this.AddChargeItemDayPurchaseNum(client, tempitem.zhigouID, tempitem.chargeTime);
                             }
                             if (configdata != null && ProcessChargeMoney == 0)
                             {
                                 ChargeItemBaseEventObject evObj_ChargeItem = new ChargeItemBaseEventObject(client, configdata);
                                 GlobalEventSource.getInstance().fireEvent(evObj_ChargeItem);
                             }
                             if (ProcessChargeMoney != 1)
                             {
                                 if (null != configdata)
                                 {
                                     List <GoodsData> awardList = new List <GoodsData>();
                                     if (configdata.GoodsDataOne != null)
                                     {
                                         awardList.AddRange(configdata.GoodsDataOne);
                                     }
                                     List <GoodsData> proGoods = GoodsHelper.GetAwardPro(client, configdata.GoodsDataTwo);
                                     if (proGoods != null)
                                     {
                                         awardList.AddRange(proGoods);
                                     }
                                     this.GiveClientChargeItem(client, awardList);
                                     this.HandleClientChargeMoney(client.strUserID, client.ClientData.RoleID, tempitem.addUserMoney - ReturnUserMoney, false, 0);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }