public async Task <ResponseViewModel <AppGameListView> > GameSwitch([FromBody] RequestViewModel obj) { AppGameListView result = new AppGameListView(); result.GameList = new List <AppGameDto>(); obj = JsonHelper.DeserializeJsonToObject <RequestViewModel>(Content(User.Identity.Name).Content); ResponseViewModel <AppGameListView> response = null; var code = SysCode.Ok; int channelIdType = 3; //0 来源设备信息 1 来源注册渠道 string strChannels = string.Empty; dynamic ibcList = obj.Data.iBeaconsList; //蓝牙设备集合 if (!obj.HendInfo.UserOpenId.IsBlank()) { /*登陆后查询设计信息*/ foreach (var item in ibcList) { channelIdType = 0; //查找已经部署的ibc的渠道 strChannels = await _routine.GetDevicesChannelIdAsync(int.Parse((string)item.major), int.Parse((string)item.minor), (string)item.uuid); if (!strChannels.IsBlank()) { result.GameList = await _routine.GetGameListAsync(strChannels, channelIdType); break; } } if (result.GameList == null || result.GameList.Count == 0) { /*设备信息为空找注册渠道*/ channelIdType = 1; string strJson = RedisHelper.StringGet($"{CacheKey.Token}{obj.HendInfo.UserOpenId}", RedisFolderEnum.token, RedisEnum.Three); if (!strJson.IsBlank()) { UserLoginDto UserLog = JsonHelper.DeserializeJsonToObject <UserLoginDto>(strJson); RegisterDto Register = await _user.GetRegisterAsync(UserLog.Userid); result.GameList = await _routine.GetGameListAsync(Register.Channel, channelIdType); } } } if (result.GameList == null || result.GameList.Count == 0) { /*没有登陆直接返回原始渠道游戏列表*/ channelIdType = 2; result.GameList = await _routine.GetGameListAsync("000000000000000", channelIdType); } response = new ResponseViewModel <AppGameListView>(code, result, obj.Encrypt, _sys, obj.Secret); return(response); }