コード例 #1
0
        private TCPProcessCmdResults ProcessRechargeData(TCPOutPacketPool pool, int nID, byte[] data, int count, out TCPOutPacket tcpOutPacket)
        {
            tcpOutPacket = null;
            RechargeData rechargeData = null;

            try
            {
                rechargeData = DataHelper.BytesToObject <RechargeData>(data, 0, count);
                if (null == rechargeData)
                {
                    throw new Exception();
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteLog(LogTypes.Error, string.Format("解析指令失败, CMD={0}", (TCPGameServerCmds)nID), null, true);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            try
            {
                string strMD5Key = string.Format("{0}{1}{2}{3}{4}{5}{6}", new object[]
                {
                    rechargeData.Amount,
                    rechargeData.UserID,
                    rechargeData.ZoneID,
                    rechargeData.order_no,
                    rechargeData.cporder_no,
                    rechargeData.Time,
                    GameDBManager.serverDBInfo.ChargeKey
                });
                string sign = MD5Helper.get_md5_string(strMD5Key);
                string strcmd;
                if (sign != rechargeData.Sign)
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("ProcessRechargeData Sign Faild : sign={0} recvsign={1} strMD5Key={2}", sign, rechargeData.Sign, strMD5Key), null, true);
                    strcmd       = string.Format("{0}:{1}", rechargeData.Id, -4);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                if (DBQuery.CheckOrderNo(DBManager.getInstance(), rechargeData.order_no) && (DBQuery.CheckInputLogOrderNo(DBManager.getInstance(), rechargeData.order_no) || DBQuery.CheckInputLog2OrderNo(DBManager.getInstance(), rechargeData.order_no)))
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("ProcessRechargeData Insert2OrderNo Faild : order_no={0}", rechargeData.order_no), null, true);
                    strcmd       = string.Format("{0}:{1}", rechargeData.Id, -5);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                if (!DBWriter.Insert2OrderNo(DBManager.getInstance(), rechargeData.order_no))
                {
                }
                if (!DBWriter.Insert2InputLog(DBManager.getInstance(), rechargeData))
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("ProcessRechargeData Insert2InputLog Faild : order_no={0}", rechargeData.order_no), null, true);
                    strcmd       = string.Format("{0}:{1}", rechargeData.Id, -2);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                TempMoneyInfo info = new TempMoneyInfo();
                info.userID       = rechargeData.UserID;
                info.chargeRoleID = rechargeData.RoleID;
                info.addUserMoney = rechargeData.Amount;
                info.addUserItem  = rechargeData.ItemId;
                info.chargeTm     = rechargeData.ChargeTime;
                info.cc           = rechargeData.cc;
                info.budanflag    = rechargeData.BudanFlag;
                if (!DBWriter.Insert2TempMoney(DBManager.getInstance(), info))
                {
                    LogManager.WriteLog(LogTypes.Error, string.Format("ProcessRechargeData Insert2TempMoney Faild : order_no={0} userid={1} rid={2} Amount={3} ItemID={4}", new object[]
                    {
                        rechargeData.order_no,
                        rechargeData.UserID,
                        rechargeData.RoleID,
                        rechargeData.Amount,
                        rechargeData.ItemId
                    }), null, true);
                    strcmd       = string.Format("{0}:{1}", rechargeData.Id, -3);
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                strcmd       = string.Format("{0}:{1}", rechargeData.Id, 1);
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, strcmd, nID);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception ex)
            {
                DataHelper.WriteFormatExceptionLog(ex, "", false, false);
            }
            return(TCPProcessCmdResults.RESULT_FAILED);
        }