Exemplo n.º 1
0
        /// <summary>
        /// 确认金钱逻辑
        /// </summary>
        /// <param name="user"></param>
        /// <param name="_targetUser"></param>
        /// <param name="data"></param>
        public static void EnsureMoneyLogic(tb_User user, tb_User _targetUser, cs_ensuremoneytrading data)
        {
            sc_ensuremoneytrading_n pushMsg = new sc_ensuremoneytrading_n {
                fn = "sc_ensuremoneytrading_n"
            };

            if (data.YesOrNo && _targetUser != null)
            {
                if (_targetUser.UserMoney >= (decimal)data.Money)
                {
                    _targetUser.UserMoney -= (decimal)data.Money;
                    user.UserMoney        += (decimal)data.Money;
                    tb_UserEx.UpdateData(user);
                    tb_UserEx.UpdateData(_targetUser);
                    var rLog = new tb_UserRechangeLog();
                    rLog.cointype   = 1;
                    rLog.createtime = DateTime.Now;
                    rLog.fromtype   = 2;
                    rLog.money      = (decimal)data.Money;
                    rLog.oldmoney   = user.UserMoney;
                    rLog.remarks    = "转账";
                    rLog.userid     = user.UserID;
                    rLog.fromuserid = _targetUser.UserID;
                    BLL_UserRechangeLog.Add(rLog);
                    if (user.AgentId <= 0 && user.isagent == 0)
                    {
                        user.AgentId = _targetUser.UserID;
                        tb_UserEx.UpdateData(user);
                    }
                    pushMsg.result      = 1;
                    pushMsg.Money       = data.Money;
                    pushMsg.objuserid   = user.UserID;
                    pushMsg.objusername = user.wechatName;
                    BullFight100Lobby.instance.SendMoneyTradinMsg(_targetUser.UserID, pushMsg);
                }
            }
            else
            {
                pushMsg.Money       = data.Money;
                pushMsg.objuserid   = user.UserID;
                pushMsg.objusername = user.wechatName;
                pushMsg.result      = -4;
                BullFight100Lobby.instance.SendMoneyTradinMsg(_targetUser.UserID, pushMsg);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 确认赠送金币
        /// </summary>
        /// <param name="user"></param>
        /// <param name="data"></param>
        /// <returns></returns>
        private string EnsureMoneyTrading(tb_User user, cs_ensuremoneytrading data)
        {
            // result 1:可以扣款,2 余额不足不能扣款,-1 用户账号不合法或者钱小于等于0,-2用户未在线或者给自己赠送钱,-3操作失败账号状态异常,-4用户拒绝
            sc_ensuremoneytrading sendData = new sc_ensuremoneytrading {
                fn = "sc_ensuremoneytrading", result = 1, Msg = "赠送成功"
            };
            tb_User _targetUser = tb_UserEx.GetFromCachebyUserID(data.objuserid);// userCache.FindKey(data.objuserid.ToString());

            if (_targetUser == null)
            {
                ErrorRecord.Record(" fetal error ...data.objuserid:" + data.objuserid);
                sendData.result = -1;
                sendData.Msg    = "赠送用户不存在";
                return(JsonUtils.Serialize(sendData));
            }
            CreateHandleGoldFactory.EnsureMoneyLogic(user, _targetUser, data);
            return(JsonUtils.Serialize(sendData));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 处理消息
        /// </summary>
        /// <param name="clientcommand"></param>
        /// <returns></returns>
        public bool DealDataEx(string _data, string _ipport, int SessionUserID, out string senddata)
        {
            senddata = "";
            if (SessionUserID == 0)
            {
                sc_exit_rebindsession_n _rebind = new sc_exit_rebindsession_n()
                {
                    result = 1, fn = "sc_exit_rebindsession_n"
                };
                senddata = JsonUtils.Serialize(_rebind);
                return(true);
            }
            _strIPandPort = _ipport;
            cs_base _basedata = JsonUtils.Deserialize <cs_base>(_data);
            var     cacheSet  = new PersonalCacheStruct <tb_User>();
            tb_User _tempuser = cacheSet.FindKey(SessionUserID.ToString());

            if (cacheSet.Count == 0 || _tempuser == null)
            {
                SchemaTable    schema   = EntitySchemaSet.Get <tb_User>();
                DbBaseProvider provider = DbConnectionProvider.CreateDbProvider(schema);
                DbDataFilter   filter   = new DbDataFilter(0);
                filter.Condition = provider.FormatFilterParam("UserId");
                filter.Parameters.Add("UserId", SessionUserID);
                cacheSet.TryRecoverFromDb(filter);                      //从数据库中恢复数据
                ////cacheSet.TryRecoverFromDb(new DbDataFilter(0));//all
                _tempuser = cacheSet.FindKey(SessionUserID.ToString()); //
            }
            if (_tempuser == null)
            {
                ErrorRecord.Record("CommonLogic 201611051736 User数据找不到SessionUserID:" + SessionUserID);
                return(false);
            }
            lock (_lockObj)
            {
                try
                {
                    switch (_basedata.fn)
                    {
                    case "cs_base": break;

                    case "cs_login":    //登录
                        cs_login _login = JsonUtils.Deserialize <cs_login>(_data);
                        senddata = Login(_tempuser, _login.accountId);
                        break;

                    case "cs_getgamelist":     //获取游戏列表
                        cs_getgamelist _gamelist = JsonUtils.Deserialize <cs_getgamelist>(_data);
                        senddata = GetGameList(_tempuser);
                        break;

                    case "cs_getgamelevel":     //获取游戏列表   也是房间列表
                        cs_getgamelevel _levellist = JsonUtils.Deserialize <cs_getgamelevel>(_data);
                        senddata = GetLevelList(_tempuser, _levellist.gameid);
                        break;

                    case "cs_freshplayerInfoSD":     //获取玩家信息
                        senddata = GetCurrentPlayerInfoSD(_tempuser);
                        break;

                    case "cs_enterroom":     //进入指定房间
                        cs_enterroom _enterroom = JsonUtils.Deserialize <cs_enterroom>(_data);
                        senddata = EnterRoom(_tempuser, _enterroom);
                        break;

                    case "cs_enterroomtable":     //进入指定房间
                        cs_enterroomtable _enterroomtable = JsonUtils.Deserialize <cs_enterroomtable>(_data);
                        senddata = EnterRoomTable(_tempuser, _enterroomtable);
                        break;

                    case "cs_exitroom":     //退出指定房间
                        cs_exitroom _exitroom = JsonUtils.Deserialize <cs_exitroom>(_data);
                        senddata = ExitRoom(_tempuser, _exitroom);
                        break;

                    case "cs_applyexittable":
                        cs_applyexittable _exittable = JsonUtils.Deserialize <cs_applyexittable>(_data);
                        senddata = ApplyExitTable(_tempuser, _exittable);
                        break;

                    case "cs_dealexittable":
                        cs_dealexittable _dealexittable = JsonUtils.Deserialize <cs_dealexittable>(_data);
                        senddata = DealExitTable(_tempuser, _dealexittable);
                        break;

                    case "cs_getnotice":    // 请求当前公告
                        cs_getnotice _notice = JsonUtils.Deserialize <cs_getnotice>(_data);
                        senddata = GetNotice("");
                        break;

                    case "cs_chat":    // 发送聊天信息
                        cs_chat _chat = JsonUtils.Deserialize <cs_chat>(_data);
                        senddata = NotifyChat(_tempuser, _chat);
                        break;

                    case "cs_gm_chesscard":        //GM 操作
                        break;

                    case "cs_reenterroom":     //断线重连第一版
                        cs_reenterroom _reroom = JsonUtils.Deserialize <cs_reenterroom>(_data);
                        senddata = ReEnterRoom(_tempuser, _reroom);
                        break;

                    case "cs_ping":    //GetPing  //给请求方发送服务器时间
                        senddata = GetPing();
                        break;

                    case "cs_getranklist":     //获取排行榜列表
                        cs_getranklist _getrank = JsonUtils.Deserialize <cs_getranklist>(_data);
                        senddata = GetRankList(_tempuser, _getrank);
                        break;

                    case "cs_getcombatgainlist":     //获取排行榜列表
                        cs_getcombatgainlist _getcombatgain = JsonUtils.Deserialize <cs_getcombatgainlist>(_data);
                        senddata = GetCombatGainList(_tempuser, _getcombatgain);
                        break;

                    case "cs_feedback":
                        cs_feedback _feedback = JsonUtils.Deserialize <cs_feedback>(_data);
                        senddata = PostFeedback(_tempuser, _feedback);
                        break;

                    case "cs_askmoneytrading":    //索要赠送请求
                        cs_askmoneytrading data = JsonUtils.Deserialize <cs_askmoneytrading>(_data);
                        //如果是作弊账号则走单独处理流程
                        HandelType type;
                        type = _tempuser.winpercent > 0 ? HandelType.abnormal : HandelType.normal;
                        var handleGoldOper = CreateHandleGoldFactory.CreateHandleGoldOperation(type);
                        handleGoldOper.model = data;
                        handleGoldOper.user  = _tempuser;
                        senddata             = handleGoldOper.Operation();
                        break;

                    case "cs_ensuremoneytrading":    //确认接收赠送金币
                        cs_ensuremoneytrading data1 = JsonUtils.Deserialize <cs_ensuremoneytrading>(_data);
                        senddata = EnsureMoneyTrading(_tempuser, data1);
                        break;

                    default:
                        if (_basedata.fn.EndsWith("_bf100"))
                        {
                            senddata = _bf100logic.DealDataEx(_data, _ipport, _tempuser);
                        }
                        else if (_basedata.fn.EndsWith("_bfc"))
                        {
                            senddata = _tclogic.DealDataEx(_data, _ipport, _tempuser);
                        }
                        //else if (_basedata.fn.EndsWith("_tc"))
                        //{ senddata = _tclogic.DealDataEx(_data, _ipport, _tempuser); }
                        break;
                    }
                    return(true);
                }
                catch (Exception ex)
                {
                    ErrorRecord.Record(ex, " 201206091508 ");
                    return(false);
                }
            }
        }