Exemplo n.º 1
0
        /// <summary>
        /// 新区充值返利领取
        /// </summary>
        /// <param name="dbMgr"></param>
        /// <param name="pool"></param>
        /// <param name="nID"></param>
        /// <param name="data"></param>
        /// <param name="count"></param>
        /// <param name="tcpOutPacket"></param>
        /// <returns></returns>
        private static TCPProcessCmdResults GetNewFanliAward(DBManager dbMgr, TCPOutPacketPool pool, int nID, int roleID, int activeid, string fromDate, string todate, List <int> minGateValueList, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string cmdData = null;
            string strcmd  = "";

            try
            {
                DBRoleInfo roleInfo = dbMgr.GetDBRoleInfo(roleID);

                if (null == roleInfo)
                {
                    strcmd       = string.Format("{0}:{1}:{2}", -1001, roleID, activeid);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }

                int roleYuanBaoInPeriod = NewZoneActiveMgr.ComputTotalFanliValue(dbMgr, roleInfo, activeid, fromDate, todate, minGateValueList);


                DBUserInfo userInfo = dbMgr.GetDBUserInfo(roleInfo.UserID);

                //避免同一用户账号同时多次操作
                lock (userInfo)
                {
                    if (roleYuanBaoInPeriod > 0)
                    {
                        //活动时间取前一天的
                        DateTime sub1DayDateTime = Global.GetAddDaysDataTime(DateTime.Now, -1, true);

                        DateTime startTime     = new DateTime(sub1DayDateTime.Year, sub1DayDateTime.Month, sub1DayDateTime.Day, 0, 0, 0);
                        DateTime endTime       = new DateTime(sub1DayDateTime.Year, sub1DayDateTime.Month, sub1DayDateTime.Day, 23, 59, 59);
                        string   huoDongKeyStr = Global.GetHuoDongKeyString(startTime.ToString("yyyy-MM-dd HH:mm:ss"), endTime.ToString("yyyy-MM-dd HH:mm:ss"));
                        //更新已领取状态
                        int ret = DBWriter.AddHongDongAwardRecordForUser(dbMgr, roleInfo.UserID, (int)(ActivityTypes.NewZoneFanli), huoDongKeyStr, 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        if (ret < 0)
                        {
                            strcmd       = string.Format("{0}:{1}:{2}", -1008, roleID, activeid);
                            tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                            return(TCPProcessCmdResults.RESULT_DATA);
                        }
                    }
                }

                strcmd = string.Format("{0}:{1}:{2}", 1, roleYuanBaoInPeriod, activeid);

                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "", false);
            }

            tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", (int)TCPGameServerCmds.CMD_DB_ERR_RETURN);
            return(TCPProcessCmdResults.RESULT_DATA);
        }
Exemplo n.º 2
0
        private static int ComputTotalFanliValue(DBManager dbMgr, DBRoleInfo roleInfo, int activeid, string fromDate, string todate, List <int> minGateValueList)
        {
            DateTime now = DateTime.Now;
            DateTime huodongStartTime = new DateTime(2000, 1, 1, 0, 0, 0);
            DateTime huodongEndTime   = default(DateTime);

            DateTime.TryParse(fromDate, out huodongStartTime);
            DateTime.TryParse(todate, out huodongEndTime);
            int retvalue = 0;
            int result;

            if (now.Ticks <= huodongStartTime.Ticks + 864000000000L)
            {
                result = 0;
            }
            else
            {
                for (int i = 1; i <= 7; i++)
                {
                    DateTime sub1DayDateTime = Global.GetAddDaysDataTime(now, -i, true);
                    DateTime startTime       = new DateTime(sub1DayDateTime.Year, sub1DayDateTime.Month, sub1DayDateTime.Day, 0, 0, 0);
                    DateTime endTime         = new DateTime(sub1DayDateTime.Year, sub1DayDateTime.Month, sub1DayDateTime.Day, 23, 59, 59);
                    string   huoDongKeyStr   = Global.GetHuoDongKeyString(startTime.ToString("yyyy-MM-dd HH:mm:ss"), endTime.ToString("yyyy-MM-dd HH:mm:ss"));
                    if (startTime < huodongStartTime)
                    {
                        break;
                    }
                    int    hasgettimes = 0;
                    string lastgettime = "";
                    DBQuery.GetAwardHistoryForUser(dbMgr, roleInfo.UserID, activeid, huoDongKeyStr, out hasgettimes, out lastgettime);
                    if (hasgettimes > 0)
                    {
                        break;
                    }
                    retvalue += NewZoneActiveMgr.ComputNewFanLiValue(dbMgr, roleInfo, activeid, startTime.ToString("yyyy-MM-dd HH:mm:ss"), endTime.ToString("yyyy-MM-dd HH:mm:ss"), minGateValueList);
                }
                result = retvalue;
            }
            return(result);
        }
Exemplo n.º 3
0
        private static List <PaiHangItemData> GetRankListByActiveLimit(DBManager dbMgr, string fromDate, string toDate, List <int> minGateValueList, int activeId, int maxPaiHang = 3)
        {
            List <InputKingPaiHangData> listPaiHangReal = new List <InputKingPaiHangData>();
            List <PaiHangItemData>      ranklist        = new List <PaiHangItemData>();

            switch (activeId)
            {
            case 34:
                listPaiHangReal = Global.GetInputKingPaiHangListByHuoDongLimit(dbMgr, fromDate, toDate, null, maxPaiHang);
                break;

            case 35:
                listPaiHangReal = Global.GetUsedMoneyKingPaiHangListByHuoDongLimit(dbMgr, fromDate, toDate, null, maxPaiHang);
                break;

            case 36:
            {
                string paiHangDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                if (!Global.IsInActivityPeriod(fromDate, toDate))
                {
                    paiHangDate = toDate;
                }
                return(NewZoneActiveMgr.GetActiveKingTypeRanklist(dbMgr, minGateValueList, activeId, paiHangDate, maxPaiHang));
            }

            case 37:
            {
                DateTime now = DateTime.Now;
                DateTime huodongStartTime = new DateTime(2000, 1, 1, 0, 0, 0);
                DateTime.TryParse(fromDate, out huodongStartTime);
                DateTime sub1DayDateTime = Global.GetAddDaysDataTime(now, -1, true);
                string   startTime       = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0).ToString("yyyy-MM-dd HH:mm:ss");
                string   endTime         = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59).ToString("yyyy-MM-dd HH:mm:ss");
                listPaiHangReal = Global.GetInputKingPaiHangListByHuoDongLimit(dbMgr, startTime, endTime, null, maxPaiHang);
                break;
            }
            }
            int    preUserPaiHang = 0;
            int    preValueid     = 0;
            string uid            = "";
            bool   bFirst         = true;

            for (int i = 0; i < listPaiHangReal.Count; i++)
            {
                InputKingPaiHangData phData = listPaiHangReal[i];
                phData.PaiHang = -1;
                if (activeId != 35)
                {
                    Global.GetUserMaxLevelRole(dbMgr, phData.UserID, out phData.MaxLevelRoleName, out phData.MaxLevelRoleZoneID);
                }
                else
                {
                    Global.GetRoleNameAndUserID(dbMgr, Global.SafeConvertToInt32(phData.UserID, 10), out phData.MaxLevelRoleName, out uid);
                }
                for (int j = 0; j < minGateValueList.Count; j++)
                {
                    int values = phData.PaiHangValue;
                    if (activeId == 35)
                    {
                        values = phData.PaiHangValue;
                    }
                    if (values >= minGateValueList[j])
                    {
                        if (bFirst)
                        {
                            phData.PaiHang = j + 1;
                        }
                        else if (j == preValueid)
                        {
                            phData.PaiHang = preUserPaiHang + 1;
                        }
                        else if (j + 1 > preUserPaiHang)
                        {
                            phData.PaiHang = j + 1;
                        }
                        else
                        {
                            phData.PaiHang = preUserPaiHang + 1;
                        }
                        PaiHangItemData item = new PaiHangItemData();
                        item.Val1 = values;
                        if (activeId == 35)
                        {
                            item.RoleID = Convert.ToInt32(phData.UserID);
                        }
                        item.RoleName = phData.MaxLevelRoleName;
                        item.Val2     = phData.PaiHang;
                        item.uid      = phData.UserID;
                        ranklist.Add(item);
                        preValueid     = j;
                        preUserPaiHang = phData.PaiHang;
                        bFirst         = false;
                        break;
                    }
                }
                if (phData.PaiHang < 0 || phData.PaiHang >= minGateValueList.Count)
                {
                    break;
                }
            }
            if (activeId == 37)
            {
                for (int j = 0; j < ranklist.Count; j++)
                {
                    int rank = j + minGateValueList.Count - ranklist.Count;
                    ranklist[j].Val1 = ranklist[j].Val1 * minGateValueList[rank] / 100;
                }
            }
            return(ranklist);
        }
Exemplo n.º 4
0
        public static TCPProcessCmdResults ProcessGetNewzoneActiveAward(DBManager dbMgr, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(data, 0, count);
            }
            catch (Exception)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            TCPProcessCmdResults ret = TCPProcessCmdResults.RESULT_FAILED;

            try
            {
                string[] fields = cmdData.Split(new char[]
                {
                    ':'
                });
                if (fields.Length != 5)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData), null, true);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                int      roleID        = Convert.ToInt32(fields[0]);
                string   fromDate      = fields[1].Replace('$', ':');
                string   toDate        = fields[2].Replace('$', ':');
                int      activetype    = Global.SafeConvertToInt32(fields[4], 10);
                string[] minYuanBaoArr = fields[3].Split(new char[]
                {
                    '_'
                });
                List <int> minGateValueList = new List <int>();
                foreach (string item in minYuanBaoArr)
                {
                    minGateValueList.Add(Global.SafeConvertToInt32(item, 10));
                }
                switch (activetype)
                {
                case 34:
                    ret = NewZoneActiveMgr.GetRechargeKingAward(dbMgr, pool, nID, roleID, activetype, fromDate, toDate, minGateValueList, out tcpOutPacket);
                    break;

                case 35:
                    ret = NewZoneActiveMgr.GetConsumeKingAward(dbMgr, pool, nID, roleID, activetype, fromDate, toDate, minGateValueList, out tcpOutPacket);
                    break;

                case 36:
                    ret = NewZoneActiveMgr.GetBossKillAward(dbMgr, pool, nID, roleID, activetype, fromDate, toDate, minGateValueList, out tcpOutPacket);
                    break;

                case 37:
                    ret = NewZoneActiveMgr.GetNewFanliAward(dbMgr, pool, nID, roleID, activetype, fromDate, toDate, minGateValueList, out tcpOutPacket);
                    break;
                }
            }
            catch (Exception ex)
            {
            }
            return(ret);
        }
Exemplo n.º 5
0
 private static TCPProcessCmdResults GetRechargeKingAward(DBManager dbMgr, TCPOutPacketPool pool, int nID, int roleID, int activeid, string fromDate, string toDate, List <int> minGateValueList, out TCPOutPacket tcpOutPacket)
 {
     tcpOutPacket = null;
     try
     {
         DBRoleInfo roleInfo = dbMgr.GetDBRoleInfo(ref roleID);
         string     strcmd;
         if (null == roleInfo)
         {
             strcmd       = string.Format("{0}:{1}:0", -1001, roleID);
             tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
             return(TCPProcessCmdResults.RESULT_DATA);
         }
         List <PaiHangItemData> listPaiHang = NewZoneActiveMgr.GetRankListByActiveLimit(dbMgr, fromDate, toDate, minGateValueList, activeid, minGateValueList.Count);
         int paiHang            = -1;
         int inputMoneyInPeriod = 0;
         for (int i = 0; i < listPaiHang.Count; i++)
         {
             if (roleInfo.UserID == listPaiHang[i].uid)
             {
                 paiHang            = listPaiHang[i].Val2;
                 inputMoneyInPeriod = listPaiHang[i].Val1;
             }
         }
         if (paiHang <= 0)
         {
             strcmd       = string.Format("{0}:{1}:0", -1003, roleID);
             tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
             return(TCPProcessCmdResults.RESULT_DATA);
         }
         if (inputMoneyInPeriod <= 0)
         {
             strcmd       = string.Format("{0}:{1}:0", -10006, roleID);
             tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
             return(TCPProcessCmdResults.RESULT_DATA);
         }
         if (paiHang <= 0)
         {
             strcmd       = string.Format("{0}:{1}:0", -10007, roleID);
             tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
             return(TCPProcessCmdResults.RESULT_DATA);
         }
         string     huoDongKeyStr = Global.GetHuoDongKeyString(fromDate, toDate);
         int        hasgettimes   = 0;
         string     lastgettime   = "";
         DBUserInfo userInfo      = dbMgr.GetDBUserInfo(roleInfo.UserID);
         lock (userInfo)
         {
             DBQuery.GetAwardHistoryForUser(dbMgr, roleInfo.UserID, 34, huoDongKeyStr, out hasgettimes, out lastgettime);
             if (hasgettimes > 0)
             {
                 strcmd       = string.Format("{0}:{1}:0", -10005, roleID);
                 tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                 return(TCPProcessCmdResults.RESULT_DATA);
             }
             int ret = DBWriter.AddHongDongAwardRecordForUser(dbMgr, roleInfo.UserID, 34, huoDongKeyStr, 1L, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
             if (ret < 0)
             {
                 strcmd       = string.Format("{0}:{1}:0", -1008, roleID);
                 tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                 return(TCPProcessCmdResults.RESULT_DATA);
             }
         }
         strcmd       = string.Format("{0}:{1}:{2}", 1, paiHang, activeid);
         tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
         return(TCPProcessCmdResults.RESULT_DATA);
     }
     catch (Exception ex)
     {
         DataHelper.WriteFormatExceptionLog(ex, "", false, false);
     }
     tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
     return(TCPProcessCmdResults.RESULT_DATA);
 }
Exemplo n.º 6
0
        public static TCPProcessCmdResults ProcessQueryActiveInfo(DBManager dbMgr, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(data, 0, count);
            }
            catch (Exception)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID), null, true);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            try
            {
                string[] fields = cmdData.Split(new char[]
                {
                    ':'
                });
                if (fields.Length != 5)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}", (TCPGameServerCmds)nID, fields.Length, cmdData), null, true);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                int      roleID        = Convert.ToInt32(fields[0]);
                string   fromDate      = fields[1].Replace('$', ':');
                string   toDate        = fields[2].Replace('$', ':');
                int      activeid      = Global.SafeConvertToInt32(fields[4], 10);
                string[] minYuanBaoArr = fields[3].Split(new char[]
                {
                    '_'
                });
                DBRoleInfo roleInfo = dbMgr.GetDBRoleInfo(ref roleID);
                if (null == roleInfo)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("发起请求的角色不存在,CMD={0}, RoleID={1}", (TCPGameServerCmds)nID, roleID), null, true);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                List <int> minGateValueList = new List <int>();
                foreach (string item in minYuanBaoArr)
                {
                    minGateValueList.Add(Global.SafeConvertToInt32(item, 10));
                }
                List <PaiHangItemData> listPaiHang = NewZoneActiveMgr.GetRankListByActiveLimit(dbMgr, fromDate, toDate, minGateValueList, activeid, minGateValueList.Count);
                int    inputMoneyInPeriod          = 0;
                string huoDongKeyStr = Global.GetHuoDongKeyString(fromDate, toDate);
                int    hasgettimes   = 0;
                string lastgettime   = "";
                switch (activeid)
                {
                case 34:
                    DBQuery.GetAwardHistoryForUser(dbMgr, roleInfo.UserID, 34, huoDongKeyStr, out hasgettimes, out lastgettime);
                    if (hasgettimes > 0)
                    {
                        hasgettimes = 1;
                    }
                    break;

                case 35:
                    DBQuery.GetAwardHistoryForUser(dbMgr, roleInfo.UserID, 35, huoDongKeyStr, out hasgettimes, out lastgettime);
                    if (hasgettimes > 0)
                    {
                        hasgettimes = 1;
                    }
                    break;

                case 36:
                    DBQuery.GetAwardHistoryForRole(dbMgr, roleID, roleInfo.ZoneID, activeid, huoDongKeyStr, out hasgettimes, out lastgettime);
                    if (hasgettimes > 0)
                    {
                        hasgettimes = 1;
                    }
                    break;

                case 37:
                    inputMoneyInPeriod = NewZoneActiveMgr.ComputTotalFanliValue(dbMgr, roleInfo, activeid, fromDate, toDate, minGateValueList);
                    if (inputMoneyInPeriod == 0)
                    {
                        hasgettimes = 1;
                    }
                    break;
                }
                NewZoneActiveData consumedata = new NewZoneActiveData
                {
                    YuanBao  = inputMoneyInPeriod,
                    ActiveId = activeid,
                    Ranklist = listPaiHang,
                    GetState = hasgettimes
                };
                tcpOutPacket = DataHelper.ObjectToTCPOutPacket <NewZoneActiveData>(consumedata, pool, nID);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "", false, false);
            }
            tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
            return(TCPProcessCmdResults.RESULT_DATA);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 充值达人领取
        /// </summary>
        /// <param name="dbMgr"></param>
        /// <param name="pool"></param>
        /// <param name="nID"></param>
        /// <param name="data"></param>
        /// <param name="count"></param>
        /// <param name="tcpOutPacket"></param>
        /// <returns></returns>
        private static TCPProcessCmdResults GetRechargeKingAward(DBManager dbMgr, TCPOutPacketPool pool, int nID, int roleID, int activeid, string fromDate, string toDate, List <int> minGateValueList, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string cmdData = null;



            try
            {
                string strcmd = "";

                DBRoleInfo roleInfo = dbMgr.GetDBRoleInfo(roleID);
                if (null == roleInfo)
                {
                    strcmd       = string.Format("{0}:{1}:0", -1001, roleID);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }

                //返回排行信息,通过活动限制值过滤后的排名,可能没有第一名等名次
                //  List<InputKingPaiHangData> listPaiHang = Global.GetInputKingPaiHangListByHuoDongLimit(dbMgr, fromDate, toDate, minGateValueList);
                List <PaiHangItemData> listPaiHang = NewZoneActiveMgr.GetRankListByActiveLimit(dbMgr, fromDate, toDate, minGateValueList, activeid, minGateValueList.Count);
                //排行值
                int paiHang = -1;
                //活动时间范围的充值,真实货币单位
                int inputMoneyInPeriod = 0;

                for (int n = 0; n < listPaiHang.Count; n++)
                {
                    if (roleInfo.UserID == listPaiHang[n].uid)
                    {
                        paiHang            = listPaiHang[n].Val2;//得到排行值
                        inputMoneyInPeriod = listPaiHang[n].Val1;
                    }
                }

                //判断是否在排行内
                if (paiHang <= 0)
                {
                    strcmd       = string.Format("{0}:{1}:0", -1003, roleID);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }

                //在排行内但未充值,GetUserInputPaiHang()内已经做了过滤
                if (inputMoneyInPeriod <= 0)
                {
                    strcmd       = string.Format("{0}:{1}:0", -10006, roleID);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }

                //时间范围内获取的元宝数
                int roleGetYuanBaoInPeriod = Global.TransMoneyToYuanBao(inputMoneyInPeriod);

                //对排行进行修正之后,超出了奖励范围,即充值元宝数量没有达到最低的元宝数量要求
                if (paiHang <= 0)
                {
                    strcmd       = string.Format("{0}:{1}:0", -10007, roleID);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }

                //活动关键字,能够唯一标志某内活动的一个实例【在某段时间内的活动】
                string huoDongKeyStr = Global.GetHuoDongKeyString(fromDate, toDate);

                int    hasgettimes = 0;
                string lastgettime = "";

                DBUserInfo userInfo = dbMgr.GetDBUserInfo(roleInfo.UserID);

                //避免同一用户账号同时多次操作
                lock (userInfo)
                {
                    //判断是否领取过---活动关键字字符串唯一确定了每次活动,针对同类型不同时间的活动
                    DBQuery.GetAwardHistoryForUser(dbMgr, roleInfo.UserID, (int)(ActivityTypes.NewZoneRechargeKing), huoDongKeyStr, out hasgettimes, out lastgettime);

                    //这个活动每次每个用户最多领取一次
                    if (hasgettimes > 0)
                    {
                        strcmd       = string.Format("{0}:{1}:0", -10005, roleID);
                        tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                        return(TCPProcessCmdResults.RESULT_DATA);
                    }

                    //更新已领取状态
                    int ret = DBWriter.AddHongDongAwardRecordForUser(dbMgr, roleInfo.UserID, (int)(ActivityTypes.NewZoneRechargeKing), huoDongKeyStr, 1, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    if (ret < 0)
                    {
                        strcmd       = string.Format("{0}:{1}:0", -1008, roleID);
                        tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                        return(TCPProcessCmdResults.RESULT_DATA);
                    }
                }

                strcmd = string.Format("{0}:{1}:{2}", 1, paiHang, activeid);

                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception ex)
            {
                //System.Windows.Application.Current.Dispatcher.Invoke((MethodInvoker)delegate
                //{
                // 格式化异常错误信息
                DataHelper.WriteFormatExceptionLog(ex, "", false);
                //throw ex;
                //});
            }

            tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", (int)TCPGameServerCmds.CMD_DB_ERR_RETURN);
            return(TCPProcessCmdResults.RESULT_DATA);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 新服活动查询,除了冲级狂人
        /// </summary>
        /// <param name="dbMgr"></param>
        /// <param name="pool"></param>
        /// <param name="nID"></param>
        /// <param name="data"></param>
        /// <param name="count"></param>
        /// <param name="tcpOutPacket"></param>
        /// <returns></returns>
        public static TCPProcessCmdResults ProcessQueryActiveInfo(DBManager dbMgr, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string cmdData = null;

            try
            {
                cmdData = new UTF8Encoding().GetString(data, 0, count);
            }
            catch (Exception) //解析错误
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}", (TCPGameServerCmds)nID));

                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", (int)TCPGameServerCmds.CMD_DB_ERR_RETURN);
                return(TCPProcessCmdResults.RESULT_DATA);
            }

            try
            {
                string[] fields = cmdData.Split(':');
                if (fields.Length != 5)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Recv={1}, CmdData={2}",
                                                                      (TCPGameServerCmds)nID, fields.Length, cmdData));

                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", (int)TCPGameServerCmds.CMD_DB_ERR_RETURN);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }

                int    roleID   = Convert.ToInt32(fields[0]);
                string fromDate = fields[1].Replace('$', ':');
                string toDate   = fields[2].Replace('$', ':');
                int    activeid = Global.SafeConvertToInt32(fields[4]);
                //排名最低元宝要求列表,依次为第一名的最小元宝,第二名的最小元宝......
                string[] minYuanBaoArr = fields[3].Split('_');

                DBRoleInfo roleInfo = dbMgr.GetDBRoleInfo(roleID);

                if (null == roleInfo)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("发起请求的角色不存在,CMD={0}, RoleID={1}",
                                                                      (TCPGameServerCmds)nID, roleID));

                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", (int)TCPGameServerCmds.CMD_DB_ERR_RETURN);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }

                List <int> minGateValueList = new List <int>();
                foreach (var item in minYuanBaoArr)
                {
                    minGateValueList.Add(Global.SafeConvertToInt32(item));
                }

                //返回排行信息,返回消费王排行数据列表,可能没有第一名等名次
                List <PaiHangItemData> listPaiHang = NewZoneActiveMgr.GetRankListByActiveLimit(dbMgr, fromDate, toDate, minGateValueList, activeid, minGateValueList.Count);

                //更新最大等级角色名称 和区号
                //foreach (var item in listPaiHang)
                //{
                //    string id = "";
                //    Global.GetRoleNameAndUserID(dbMgr, item.RoleID, out item.RoleName, out id);
                //}
                //活动时间范围内的充值数,真实货币单位
                int inputMoneyInPeriod = 0;


                //活动关键字,能够唯一标志某内活动的一个实例【在某段时间内的活动】
                string huoDongKeyStr = Global.GetHuoDongKeyString(fromDate, toDate);

                int    hasgettimes = 0;
                string lastgettime = "";

                //判断是否领取过---活动关键字字符串唯一确定了每次活动,针对同类型不同时间的活动
                switch ((ActivityTypes)activeid)
                {
                case ActivityTypes.NewZoneConsumeKing:
                    // huoDongKeyStr = Global.GetHuoDongKeyString(fromDate, toDate);
                    //判断是否领取过---活动关键字字符串唯一确定了每次活动,针对同类型不同时间的活动
                    DBQuery.GetAwardHistoryForUser(dbMgr, roleInfo.UserID, (int)(ActivityTypes.NewZoneConsumeKing), huoDongKeyStr, out hasgettimes, out lastgettime);

                    //这个活动每次每个用户最多领取一次
                    if (hasgettimes > 0)
                    {
                        hasgettimes = 1;
                    }
                    break;

                case ActivityTypes.NewZoneRechargeKing:
                {
                    // huoDongKeyStr = Global.GetHuoDongKeyString(fromDate, toDate);
                    //判断是否领取过---活动关键字字符串唯一确定了每次活动,针对同类型不同时间的活动
                    DBQuery.GetAwardHistoryForUser(dbMgr, roleInfo.UserID, (int)(ActivityTypes.NewZoneRechargeKing), huoDongKeyStr, out hasgettimes, out lastgettime);

                    //这个活动每次每个用户最多领取一次
                    if (hasgettimes > 0)
                    {
                        hasgettimes = 1;
                    }
                }
                break;

                case ActivityTypes.NewZoneBosskillKing:
                {
                    // huoDongKeyStr = Global.GetHuoDongKeyString(fromDate, toDate);
                    //判断是否领取过---活动关键字字符串唯一确定了每次活动,针对同类型不同时间的活动
                    DBQuery.GetAwardHistoryForRole(dbMgr, roleID, roleInfo.ZoneID, activeid, huoDongKeyStr, out hasgettimes, out lastgettime);

                    //这个活动每次每个角色最多领取一次
                    if (hasgettimes > 0)
                    {
                        hasgettimes = 1;
                    }
                }
                break;

                case ActivityTypes.NewZoneFanli:
                {
                    inputMoneyInPeriod = NewZoneActiveMgr.ComputTotalFanliValue(dbMgr, roleInfo, activeid, fromDate, toDate, minGateValueList);
                    if (inputMoneyInPeriod == 0)
                    {
                        hasgettimes = 1;
                    }
                }

                break;
                }


                NewZoneActiveData consumedata = new NewZoneActiveData()
                {
                    YuanBao  = inputMoneyInPeriod,
                    ActiveId = activeid,
                    Ranklist = listPaiHang,
                    GetState = hasgettimes
                };
                //生成排行信息的tcp对象流
                tcpOutPacket = DataHelper.ObjectToTCPOutPacket <NewZoneActiveData>(consumedata, pool, nID);

                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "", false);
            }

            tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", (int)TCPGameServerCmds.CMD_DB_ERR_RETURN);
            return(TCPProcessCmdResults.RESULT_DATA);
        }