/// <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);
        }
Beispiel #2
0
 private static int _ProcessSuperInputFanLi(DBManager dbMgr, DBUserInfo dbUserInfo, SingleChargeData chargeData, int addUserMoney, int ChargeID, string chargeTm)
 {
     try
     {
         string SuperInputFanLiKey = chargeData.SuperInputFanLiKey;
         if (string.IsNullOrEmpty(SuperInputFanLiKey))
         {
             return(0);
         }
         string[] KeyFileds = SuperInputFanLiKey.Split(new char[]
         {
             '_'
         });
         if (KeyFileds.Length != 2)
         {
             return(0);
         }
         DateTime startTime = DateTime.Parse(KeyFileds[0]);
         DateTime endTime   = DateTime.Parse(KeyFileds[1]);
         if (TimeUtil.NowDateTime() < startTime || TimeUtil.NowDateTime() > endTime)
         {
             return(0);
         }
         JieriSuperInputData configData = UserMoneyMgr.GetJieriSuperInputDataByChargeTm(chargeData, chargeTm);
         if (null == configData)
         {
             return(0);
         }
         string beginStr     = configData.BeginTime.ToString("yyyy-MM-dd HH:mm:ss").Replace(':', '$');
         string endStr       = configData.EndTime.ToString("yyyy-MM-dd HH:mm:ss").Replace(':', '$');
         string keyStr       = string.Format("res_{0}_{1}_{2}", beginStr, endStr, configData.ID);
         long   reservetimes = 0L;
         string lastgettime  = "";
         int    ret          = DBQuery.GetAwardHistoryForUser(dbMgr, dbUserInfo.UserID, 71, keyStr, out reservetimes, out lastgettime);
         if (reservetimes <= 0L)
         {
             return(0);
         }
         reservetimes -= 1L;
         lastgettime   = chargeTm;
         ret           = DBWriter.UpdateHongDongAwardRecordForUser(dbMgr, dbUserInfo.UserID, 71, keyStr, reservetimes, lastgettime);
         if (ret < 0)
         {
             ret = DBWriter.AddHongDongAwardRecordForUser(dbMgr, dbUserInfo.UserID, 71, keyStr, reservetimes, lastgettime);
         }
         return(configData.ID);
     }
     catch (Exception ex)
     {
         LogManager.WriteException("_ProcessSuperInputFanLi:" + ex.ToString());
     }
     return(0);
 }
        private int _UpdateAwardFlag(DBManager dbMgr, string userid, string fromDate, string toDate, int zoneId, int awardId, int awardFlag)
        {
            string lastgettime_just_placeholder = string.Empty;
            int    hasgettimes_just_placeholder = 0;
            int    result = 1;
            string actKey = this._GetActAwardKey_NoZoneID(fromDate, toDate, zoneId, awardId);

            if (DBQuery.GetAwardHistoryForUser(dbMgr, userid, 61, actKey, out hasgettimes_just_placeholder, out lastgettime_just_placeholder) < 0)
            {
                if (DBWriter.AddHongDongAwardRecordForUser(dbMgr, userid, 61, actKey, (long)awardFlag, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")) < 0)
                {
                    result = -1008;
                }
            }
            else if (DBWriter.UpdateHongDongAwardRecordForUser(dbMgr, userid, 61, actKey, (long)awardFlag, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")) < 0)
            {
            }
            return(result);
        }
Beispiel #4
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 ProcessGetActiveAwards(DBManager dbMgr, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string[] fields = null;

            if (!GetCmdDataField(nID, data, count, out fields))
            {
                return(TCPProcessCmdResults.RESULT_FAILED);
            }

            int        roleID      = Convert.ToInt32(fields[0]);
            int        activeid    = Global.SafeConvertToInt32(fields[1]);
            int        hasgettimes = Global.SafeConvertToInt32(fields[2]);
            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);
            }

            string huoDongKeyStr = "not_limit";
            string extData       = "";
            string strcmd        = "";

            switch (activeid)
            {
            case (int)ActivityTypes.MeiRiChongZhiHaoLi:
            {
                DateTime startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
                DateTime endTime   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
                huoDongKeyStr = Global.GetHuoDongKeyString(startTime.ToString("yyyy-MM-dd HH:mm:ss"), endTime.ToString("yyyy-MM-dd HH:mm:ss"));
            }
            break;

            case (int)(ActivityTypes.TotalCharge):

                break;

            case (int)(ActivityTypes.TotalConsume):
            {
            }
            break;

            case (int)(ActivityTypes.HeFuRecharge):
            {
                // 检查参数个数
                if (4 != fields.Length)
                {
                    return(TCPProcessCmdResults.RESULT_DATA);
                }

                int hefutime = Global.SafeConvertToInt32(fields[2]);

                // 存放排名返还比例的数组
                Dictionary <int, float> CoeDict = new Dictionary <int, float>();

                string   strconfig = fields[3];
                string[] strattr   = strconfig.Split('|');
                for (int i = 0; i < strattr.Length; i++)
                {
                    string[] strcoe = strattr[i].Split(',');
                    if (2 != strcoe.Length)
                    {
                        continue;
                    }

                    int   rank = Global.SafeConvertToInt32(strcoe[0]);
                    float coe  = (float)Convert.ToDouble(strcoe[1]);
                    CoeDict[rank] = coe;
                }


                int    ifhastime   = 0;
                string lastgettime = "";
                //判断是否领取过---活动关键字字符串唯一确定了每次活动,针对同类型不同时间的活动
                DBQuery.GetAwardHistoryForUser(dbMgr, roleInfo.UserID, (int)(ActivityTypes.HeFuRecharge), huoDongKeyStr, out ifhastime, out lastgettime);

                // 计算玩家从那天开始领取
                int userdayflag = 0;
                // 如果领取过就用最后一次领取时的开始计算
                if (ifhastime > 0)
                {
                    userdayflag = Global.GetOffsetDay(DateTime.Parse(lastgettime));
                }
                // 如过没领取过就用GameServer发来的合服时间开始计算
                else
                {
                    userdayflag = hefutime;
                }

                // 如果今天已经领取了
                int currday = Global.GetOffsetDay(DateTime.Now);
                if (userdayflag == currday)
                {
                    // 返回给GameServer告诉玩家没有可以领取的钻石了
                    strcmd       = string.Format("{0}:{1}:{2}", 1, activeid, 0);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }

                // 昨天的日期
                int yesterday = Global.GetOffsetDay(DateTime.Now) - 1;

                int userrebate = 0;
                // 从开始计算到昨天的个人能获得的返利数量
                for (int i = userdayflag; i <= yesterday; i++)
                {
                    DateTime now       = Global.GetRealDate(i);
                    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");
                    // 查询玩家某日充值数量
                    int input = DBQuery.GetUserInputMoney(dbMgr, roleInfo.UserID, roleInfo.ZoneID, startTime, endTime);
                    input = Global.TransMoneyToYuanBao(input);
                    // 查询玩家某日充值排名
                    int rank = GameDBManager.DayRechargeRankMgr.GetRoleRankByDay(dbMgr, roleInfo.UserID, i);
                    // 查询玩家排名返还比例
                    if (!CoeDict.ContainsKey(rank))
                    {
                        // log it
                        continue;
                    }

                    userrebate += (int)(input * CoeDict[rank]);
                }

                // 返回给GameServer给玩家加钻石
                // 领取记录去真正给元宝的地方更新
                strcmd       = string.Format("{0}:{1}:{2}", 1, activeid, userrebate);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            break;
            }
            //避免同一角色同时多次操作
            lock (roleInfo)
            {
                int ret = DBWriter.UpdateHongDongAwardRecordForUser(dbMgr, roleInfo.UserID, activeid, huoDongKeyStr, hasgettimes, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                if (ret < 0)
                {
                    ret = DBWriter.AddHongDongAwardRecordForUser(dbMgr, roleInfo.UserID, activeid, huoDongKeyStr, hasgettimes, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                }
                if (ret < 0)
                {
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", (int)TCPGameServerCmds.CMD_DB_ERR_RETURN);
                    return(TCPProcessCmdResults.RESULT_FAILED);
                }
            }
            strcmd       = string.Format("{0}:{1}:{2}", 1, activeid, hasgettimes);
            tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
            return(TCPProcessCmdResults.RESULT_DATA);
        }
Beispiel #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);
 }
        public static TCPProcessCmdResults ProcessGetActiveAwards(DBManager dbMgr, TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            string[]             fields = null;
            TCPProcessCmdResults result;

            if (!RechargeRepayActiveMgr.GetCmdDataField(nID, data, count, out fields))
            {
                result = TCPProcessCmdResults.RESULT_FAILED;
            }
            else
            {
                int        roleID          = Convert.ToInt32(fields[0]);
                int        activeid        = Global.SafeConvertToInt32(fields[1], 10);
                int        hasgettimes     = Global.SafeConvertToInt32(fields[2], 10);
                long       hasgettimesLong = Global.SafeConvertToInt64(fields[2], 10);
                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);
                    result       = TCPProcessCmdResults.RESULT_DATA;
                }
                else
                {
                    string huoDongKeyStr = "not_limit";
                    int    num           = activeid;
                    string strcmd;
                    if (num <= 27)
                    {
                        if (num != 23)
                        {
                            if (num == 27)
                            {
                                DateTime startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
                                DateTime endTime   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
                                huoDongKeyStr = Global.GetHuoDongKeyString(startTime.ToString("yyyy-MM-dd HH:mm:ss"), endTime.ToString("yyyy-MM-dd HH:mm:ss"));
                            }
                        }
                        else
                        {
                            if (5 != fields.Length)
                            {
                                return(TCPProcessCmdResults.RESULT_DATA);
                            }
                            int hefutime    = Global.SafeConvertToInt32(fields[2], 10);
                            int hefuEndtime = Global.SafeConvertToInt32(fields[3], 10);
                            huoDongKeyStr = Global.GetHuoDongKeyString(hefutime.ToString(), hefuEndtime.ToString());
                            Dictionary <int, float> CoeDict = new Dictionary <int, float>();
                            string   strconfig = fields[4];
                            string[] strattr   = strconfig.Split(new char[]
                            {
                                '|'
                            });
                            for (int i = 0; i < strattr.Length; i++)
                            {
                                string[] strcoe = strattr[i].Split(new char[]
                                {
                                    ','
                                });
                                if (2 == strcoe.Length)
                                {
                                    int   rank = Global.SafeConvertToInt32(strcoe[0], 10);
                                    float coe  = (float)Convert.ToDouble(strcoe[1]);
                                    CoeDict[rank] = coe;
                                }
                            }
                            int    ifhastime   = 0;
                            string lastgettime = "";
                            DBQuery.GetAwardHistoryForUser(dbMgr, roleInfo.UserID, 23, huoDongKeyStr, out ifhastime, out lastgettime);
                            int lastgetday = 0;
                            if (!string.IsNullOrEmpty(lastgettime))
                            {
                                lastgetday = Global.GetOffsetDay(DateTime.Parse(lastgettime));
                            }
                            int userdayflag;
                            if (lastgetday < hefutime)
                            {
                                userdayflag = hefutime;
                            }
                            else if (ifhastime > 0)
                            {
                                userdayflag = lastgetday;
                            }
                            else
                            {
                                userdayflag = hefutime;
                            }
                            int currday = Global.GetOffsetDay(DateTime.Now);
                            if (userdayflag == currday)
                            {
                                strcmd       = string.Format("{0}:{1}:{2}", 1, activeid, 0);
                                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                                return(TCPProcessCmdResults.RESULT_DATA);
                            }
                            int overDay = Global.GetOffsetDay(DateTime.Now) - 1;
                            if (overDay > hefuEndtime)
                            {
                                overDay = hefuEndtime;
                            }
                            int userrebate = 0;
                            for (int i = userdayflag; i <= overDay; i++)
                            {
                                DateTime now        = Global.GetRealDate(i);
                                string   startTime2 = new DateTime(now.Year, now.Month, now.Day, 0, 0, 0).ToString("yyyy-MM-dd HH:mm:ss");
                                string   endTime2   = new DateTime(now.Year, now.Month, now.Day, 23, 59, 59).ToString("yyyy-MM-dd HH:mm:ss");
                                int      rank       = GameDBManager.DayRechargeRankMgr.GetRoleRankByDay(dbMgr, roleInfo.UserID, i);
                                if (CoeDict.ContainsKey(rank))
                                {
                                    RankDataKey key   = new RankDataKey(RankType.Charge, startTime2, endTime2, null);
                                    int         input = roleInfo.RankValue.GetRankValue(key);
                                    userrebate += (int)((float)input * CoeDict[rank]);
                                }
                            }
                            strcmd       = string.Format("{0}:{1}:{2}", 1, activeid, userrebate);
                            tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                            return(TCPProcessCmdResults.RESULT_DATA);
                        }
                    }
                    else
                    {
                        switch (num)
                        {
                        case 38:
                        case 39:
                            lock (roleInfo)
                            {
                                int ret = DBWriter.UpdateHongDongAwardRecordForUser(dbMgr, roleInfo.UserID, activeid, huoDongKeyStr, hasgettimesLong, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                                if (ret < 0)
                                {
                                    ret = DBWriter.AddHongDongAwardRecordForUser(dbMgr, roleInfo.UserID, activeid, huoDongKeyStr, hasgettimesLong, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                                }
                                if (ret < 0)
                                {
                                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                                    return(TCPProcessCmdResults.RESULT_FAILED);
                                }
                            }
                            strcmd       = string.Format("{0}:{1}:{2}", 1, activeid, hasgettimesLong);
                            tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                            return(TCPProcessCmdResults.RESULT_DATA);

                        default:
                            switch (num)
                            {
                            case 46:
                            {
                                if (fields.Length != 5)
                                {
                                    return(TCPProcessCmdResults.RESULT_DATA);
                                }
                                string fromDateCmd = fields[3].Replace('$', ':');
                                string toDateCmd   = fields[4].Replace('$', ':');
                                huoDongKeyStr = Global.GetHuoDongKeyString(fromDateCmd, toDateCmd);
                                break;
                            }

                            case 48:
                            {
                                DateTime startTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 0, 0, 0);
                                DateTime endTime   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 23, 59, 59);
                                huoDongKeyStr = Global.GetHuoDongKeyString(startTime.ToString("yyyy-MM-dd HH:mm:ss"), endTime.ToString("yyyy-MM-dd HH:mm:ss"));
                                break;
                            }
                            }
                            break;
                        }
                    }
                    lock (roleInfo)
                    {
                        int ret = DBWriter.UpdateHongDongAwardRecordForUser(dbMgr, roleInfo.UserID, activeid, huoDongKeyStr, (long)hasgettimes, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        if (ret < 0)
                        {
                            ret = DBWriter.AddHongDongAwardRecordForUser(dbMgr, roleInfo.UserID, activeid, huoDongKeyStr, (long)hasgettimes, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        }
                        if (ret < 0)
                        {
                            tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                            return(TCPProcessCmdResults.RESULT_FAILED);
                        }
                    }
                    strcmd       = string.Format("{0}:{1}:{2}", 1, activeid, hasgettimes);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                    result       = TCPProcessCmdResults.RESULT_DATA;
                }
            }
            return(result);
        }
        /// <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);
        }