Exemplo n.º 1
0
        public static TCPProcessCmdResults ProcessDelChargeItemData(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 != 3)
                {
                    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 SerialID                = Convert.ToInt32(fields[0]);
                int ChargeMoney             = Convert.ToInt32(fields[1]);
                int ReturnUserMoney         = Convert.ToInt32(fields[2]);
                SingleChargeData chargeData = CFirstChargeMgr.ChargeData;
                if (chargeData == null)
                {
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                List <TempItemChargeInfo> tempItemInfoList = DBQuery.QueryTempItemChargeInfo(dbMgr, 0, SerialID, 0);
                if (tempItemInfoList.Count == 0)
                {
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                string     userID       = tempItemInfoList[0].userID;
                int        chargeRoleID = tempItemInfoList[0].chargeRoleID;
                int        addUserMoney = tempItemInfoList[0].addUserMoney;
                int        zhigouID     = tempItemInfoList[0].zhigouID;
                DBUserInfo dbUserInfo   = dbMgr.GetDBUserInfo(userID);
                if (dbUserInfo == null)
                {
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                byte DelState = (byte)((ChargeMoney == 1) ? 2 : 1);
                if (!DBWriter.DeleteChargeItemInfo(dbMgr, SerialID, DelState))
                {
                    tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
                    return(TCPProcessCmdResults.RESULT_DATA);
                }
                if (ChargeMoney == 1)
                {
                    UserMoneyMgr._ProcessCharge(dbMgr, dbUserInfo, chargeRoleID, addUserMoney, 0, "", chargeData, true);
                }
                else if (ReturnUserMoney > 0)
                {
                    UserMoneyMgr._ProcessCharge(dbMgr, dbUserInfo, chargeRoleID, ReturnUserMoney, 0, "", chargeData, true);
                }
                tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", nID);
                return(TCPProcessCmdResults.RESULT_DATA);
            }
            catch (Exception e)
            {
                LogManager.WriteException("ProcessDelChargeItemData:" + e.ToString());
            }
            tcpOutPacket = TCPOutPacket.MakeTCPOutPacket(pool, "0", 30767);
            return(TCPProcessCmdResults.RESULT_DATA);
        }