public async Task <H5ResponseViewModel <UserInfoView> > UserInfo([FromBody] H5RequestViewModel Parameters)
        {
            var          sysCode = _sys.CheckParameters(Parameters.data, "userverify");
            UserInfoView Result  = null;
            H5ResponseViewModel <UserInfoView> response = null;

            if (sysCode == SysCode.Ok)
            {
                string token = Parameters.data.token;
                //token是否有效
                bool isLog = _token.VerifyToken(token);
                if (isLog)
                {
                    UserLoginDto userLogin = JsonHelper.DeserializeJsonToObject <UserLoginDto>(RedisHelper.StringGet($"{CacheKey.Token}{token}", RedisFolderEnum.token, RedisEnum.Five));
                    long         userId    = long.Parse(userLogin.Userid.ToString());
                    UserInfoDto  userInfo  = await _user.SearchUserInfoAsync(userId);

                    UserBalanceDto UserBalance = null;
                    //关闭章鱼余额查询
                    // UserBalance = _biz.AcquireBalance(userId);
                    //从php获取用户余额
                    UserBalance = _accout.AcquireBalance_php(userId);

                    if (UserBalance == null)
                    {
                        UserBalance = new UserBalanceDto
                        {
                            PrizeBalance = 0.00,
                            Balance      = 0.00
                        };
                    }
                    //查询用户渠道并返回用户信息
                    var userchannel = await _routine.GetUserIdChannelIdAsync(userId);

                    Result = new UserInfoView
                    {
                        Balance      = UserBalance.Balance,
                        IdCard       = userInfo.Id_card,
                        Nickname     = userInfo.Nick_name,
                        Phone        = userLogin.Phone,
                        PrizeBalance = UserBalance.PrizeBalance,
                        RealName     = userInfo.Real_name,
                        channel      = userchannel
                    };
                }
                else
                {
                    /*短令牌失效*/
                    sysCode = SysCode.SessionTokenLose;
                }
            }
            response = new H5ResponseViewModel <UserInfoView>(sysCode, Result);
            return(response);
        }
Beispiel #2
0
        public async Task <ResponseViewModel <UserInfoView> > QcquireUserInfo([FromBody] RequestViewModel obj)
        {
            UserInfoView result = null;
            ResponseViewModel <UserInfoView> response = null;

            obj = JsonHelper.DeserializeJsonToObject <RequestViewModel>(Content(User.Identity.Name).Content);
            var  code  = SysCode.Ok;
            bool isLog = _token.VerifyToken(obj.HendInfo.UserOpenId, obj.HendInfo.SessionToken);

            if (isLog)
            {
                string      strJson  = RedisHelper.StringGet($"{CacheKey.Token}{obj.HendInfo.UserOpenId}", RedisFolderEnum.token, RedisEnum.Three);
                var         userLog  = JsonHelper.DeserializeJsonToObject <UserLoginDto>(strJson);
                UserInfoDto UserInfo = await _user.SearchUserInfoAsync(userLog.Userid);

                UserBalanceDto userBalance = null;
                //关闭章鱼余额查询
                //userBalance = _biz.AcquireBalance(userLog.Userid);
                //从php获取用户余额
                userBalance = _accout.AcquireBalance_php(userLog.Userid);
                _log.InfoFormat("从php获取用户余额:{0},用户信息{1}", JsonHelper.SerializeObject(userBalance), JsonHelper.SerializeObject(UserInfo));
                if (userBalance == null)
                {
                    userBalance = new UserBalanceDto
                    {
                        PrizeBalance = 0.00,
                        Balance      = 0.00
                    };
                }
                //查询用户渠道并返回用户信息
                var userchannel = await _routine.GetUserIdChannelIdAsync(userLog.Userid);

                result = new UserInfoView
                {
                    Balance      = userBalance.Balance,
                    IdCard       = UserInfo.Id_card,
                    Nickname     = UserInfo.Nick_name,
                    Phone        = userLog.Phone,
                    PrizeBalance = userBalance.PrizeBalance,
                    RealName     = UserInfo.Real_name,
                    channel      = userchannel
                };
            }
            else
            {
                /*短令牌失效*/
                code = SysCode.SessionTokenLose;
            }
            response = new ResponseViewModel <UserInfoView>(code, code == SysCode.Ok ? result : null, obj.Encrypt, _sys, obj.Secret);
            return(response);
        }
        public async Task <ResponseViewModel <object> > SubmitIbc([FromBody] RequestViewModel obj)
        {
            ResponseViewModel <object> response = null;

            obj = JsonHelper.DeserializeJsonToObject <RequestViewModel>(Content(User.Identity.Name).Content);
            var          sysCode      = SysCode.Ok;
            ibeaconlocus ibeaconlocus = new ibeaconlocus();
            var          channelId    = obj.Client.Channel;
            var          userOpenId   = obj.HendInfo.UserOpenId;
            var          sessionToken = obj.HendInfo.SessionToken;
            var          timesTamp    = obj.Data.timestamp;
            string       strJson      = RedisHelper.StringGet($"{CacheKey.Token}{obj.HendInfo.UserOpenId}", RedisFolderEnum.token, RedisEnum.Three);

            if (strJson != null)
            {
                var     userLog = JsonHelper.DeserializeJsonToObject <UserLoginDto>(strJson);
                dynamic ibcList = obj.Data.iBeacons;

                string strjson     = JsonHelper.SerializeObject(ibcList);
                string strChannels = string.Empty;
                bool   result      = false;

                foreach (var item in ibcList)
                {
                    /*查找已经部署的ibc的渠道*/
                    strChannels = await _routine.GetDevicesChannelIdAsync(int.Parse((string)item.major), int.Parse((string)item.minor), (string)item.uuid);

                    /*更新设备电量 */
                    // result = await _routine.UpdateIbcAsync(int.Parse((string)item.major), int.Parse((string)item.minor), (string)item.uuid, int.Parse((string)item.battery));
                }
                _log.InfoFormat("查询设备渠道结果:{0}更新设备电量结果:{1}", strChannels, result);
                try
                {
                    var resignChannel = await _routine.GetUserIdChannelIdAsync(userLog.Userid);

                    var downId    = obj.Data.downid;
                    var gps       = obj.Client.Gps;
                    var userPhone = userLog.Phone;
                    var PhoneType = obj.Data.phoneType;
                    var gameType  = obj.Data.gameType;
                    ibeaconlocus.downid     = downId;
                    ibeaconlocus.userId     = userLog.Userid;
                    ibeaconlocus.iBeacons   = JsonHelper.DeserializeJsonToObject <List <ibcinfoList> >(strjson);
                    ibeaconlocus.phone      = userPhone;
                    ibeaconlocus.gps        = gps;
                    ibeaconlocus.timestamp  = timesTamp;
                    ibeaconlocus.token      = sessionToken;
                    ibeaconlocus.userOpenid = userOpenId;
                    ibeaconlocus.phoneType  = PhoneType;
                    ibeaconlocus.gameType   = gameType;
                    ibeaconlocus.ibcChannel = strChannels;
                    ibeaconlocus.channelId  = resignChannel;
                    ibeaconlocus.createTime = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
                    /* 将ibc信息写入mongo数据库*/
                    _routine.WriteIbcInfo(ibeaconlocus);
                }
                catch (System.Exception ex)
                {
                    _log.ErrorFormat("提报ibc接口异常{0}", ex.Message);
                    sysCode = SysCode.Err;
                }
            }
            else
            {
                sysCode = SysCode.UserOpenIdisNo;
            }

            response = new ResponseViewModel <object>(sysCode, null, obj.Encrypt, _sys, obj.Secret);
            return(response);
        }