Пример #1
0
        public ResultRecommend GetRecommendInfo(QueryGetRecommend query)
        {
            var result = new ResultRecommend {
                Exception = new MyException(), RecommendList = new List <RecommendUser>()
            };

            try
            {
                var realSsid = new EncryDecry().Md5Decrypt(query.Ssid);
                var arr      = HelpTool.GetSession(realSsid);
                if (arr.Length < 3)
                {
                    result.Exception.Exmsg   = "not found";
                    result.Exception.Success = true;
                    return(result);
                }
                var user          = arr.GetValue(2).ToString();
                var recommendList = _userRecommend.GetAllRecommend(user);
                foreach (var rec in recommendList)
                {
                    result.RecommendList.Add(new RecommendUser {
                        User = rec.User
                    });
                }
                result.Exception.Success = true;
            }
            catch (Exception ex)
            {
                result.Exception.Success = false;
                AppLogger.Error($"{ex.Message} {ex.StackTrace}");
            }

            return(result);
        }
Пример #2
0
        public ResultModifyAddress IsReg(QueryUserExists query)
        {
            var result = new ResultModifyAddress {
                Exception = new MyException()
            };

            try
            {
                var realSsid = new EncryDecry().Md5Decrypt(query.Ssid);
                var arr      = GetSession(realSsid);
                if (arr.Length < 3)
                {
                    result.Exception.Exmsg   = "not found";
                    result.Exception.Success = true;
                    return(result);
                }
                var findIt = _user.SearchUser(arr.GetValue(2).ToString());
                if (findIt != null)
                {
                    result.Address = _userInfo.GeTbUserInfos($"{findIt.Id}")?[0].Address;
                }
                result.Exception.Success = true;
                return(result);
            }
            catch (Exception ex)
            {
                AppLogger.Error($"{ex.Message} {ex.StackTrace}");
                result.Exception.Success = false;
            }
            return(result);
        }
Пример #3
0
        public ResultAddPostInfo AddPostInfo(QueryAddPostInfo query)
        {
            var result = new ResultAddPostInfo {
                Exception = new MyException()
            };

            try
            {
                var realSsid = new EncryDecry().Md5Decrypt(query.Ssid);
                var arr      = GetSession(realSsid);
                if (arr.Length < 3 || ValidatePostInfo(query) != 0)
                {
                    result.Exception.Exmsg   = "not found 标题或内容超过规定";
                    result.Exception.Success = true;
                    return(result);
                }
                var postInfo = new Tb_PostInfo
                {
                    CreateTime = DateTime.Now,
                    UserId     = arr.GetValue(2).ToString(),
                    Title      = query.Title,
                    PostText   = query.PostText,
                    IsShow     = 1,
                    ViewCount  = 1
                };
                _postInfo.AddPostInfo(postInfo);
                result.Exception.Success = true;
            }
            catch (Exception ex)
            {
                result.Exception.Success = false;
                AppLogger.Error($"{ex.Message} {ex.StackTrace}");
            }
            return(result);
        }
Пример #4
0
        public ResultUserCartgo ShowUserCartgo(QueryUserCartGo query)
        {
            var result = new ResultUserCartgo {
                Exception = new MyException(), CartGoAll = new UserCartGoAll()
            };

            try
            {
                if (!ValidateUserSsid(query.Ssid))
                {
                    result.Exception.Success = false;
                    return(result);
                }
                //根据uid查找数据库表 连接货物信息表
                var realSsid   = new EncryDecry().Md5Decrypt(query.Ssid);
                var sessionArr = GetSession(realSsid);
                if (sessionArr.Length == 3)
                {
                    realSsid = sessionArr.GetValue(2).ToString();
                }
                var cartgoInfo = _userCartgo.GetUserCartgoInfo(realSsid);
                result.CartGoAll.AllGoodsInCartgo = cartgoInfo;
                foreach (var info in cartgoInfo)
                {
                    result.CartGoAll.TotalPayment += info.TotalPrice;
                }
                result.Exception.Success = true;
            }
            catch (Exception ex)
            {
                result.Exception.Success = false;
                result.Exception.Exmsg   = ex.Message;
            }
            return(result);
        }
Пример #5
0
        public ResultRmUserCartgo AddBuyCnt(QueryAddBuyCnt query)
        {
            var result = new ResultRmUserCartgo {
                Exception = new MyException()
            };

            try
            {
                if (!ValidateUserSsid(query.Ssid))
                {
                    result.Exception.Success = false;
                    return(result);
                }
                var realSsid   = new EncryDecry().Md5Decrypt(query.Ssid);
                var sessionArr = GetSession(realSsid);
                if (sessionArr.Length == 3)
                {
                    realSsid = sessionArr.GetValue(2).ToString();
                }
                _userCartgo.AddBuyCnt(realSsid, query.Code, query.Cnt);
                result.Exception.Success = true;
            }catch (Exception ex)
            {
                result.Exception.Success = false;
                AppLogger.Error($"{ex.Message} {ex.StackTrace}");
            }
            return(result);
        }
Пример #6
0
        private bool ValidateClient(string key, ref string realKey)
        {
            realKey = new EncryDecry().Md5Decrypt(key);
            var vale = _redisOper.Get(realKey);

            return(vale != null);
        }
Пример #7
0
        private bool ValidateUserSsid(string ssid)
        {
            if (string.IsNullOrEmpty(ssid))
            {
                return(false);
            }
            var res = new EncryDecry().Md5Decrypt(ssid);

            if (_redisOper.Get(res) == null)
            {
                return(false);
            }
            return(true);
        }
Пример #8
0
        public ResultRecommend AddRecommend(QueryRecommendUser query)
        {
            var result = new ResultRecommend {
                Exception = new MyException()
            };

            try
            {
                var realSsid = new EncryDecry().Md5Decrypt(query.Ssid);
                var arr      = HelpTool.GetSession(realSsid);
                var errNo    = string.Empty;
                if (arr.Length < 3 || !CheckRecommenUser(query.User, new EncryDecryPhone().Md5Decrypt(query.Phone), ref errNo))
                {
                    result.Exception.Exmsg   = errNo;
                    result.Exception.Success = false;
                    return(result);
                }
                var user = arr.GetValue(2).ToString();
                if (user.Equals(query.User))
                {
                    result.Exception.Exmsg   = "4";
                    result.Exception.Success = false;
                    return(result);
                }
                var userRecommend = new Tb_Recommend
                {
                    RecommendUser = user,
                    User          = query.User,
                    CDT           = DateTime.Now
                };
                _userRecommend.AddRecommend(userRecommend);
                result.Exception.Success = true;
            }
            catch (Exception ex)
            {
                result.Exception.Success = false;
                AppLogger.Error($"{ex.Message} {ex.StackTrace}");
            }
            return(result);
        }
Пример #9
0
        public ResultLogin ModifyPass(QueryUserModify query)
        {
            var result = new ResultLogin {
                Exception = new MyException()
            };

            try
            {
                var realSsid = new EncryDecry().Md5Decrypt(query.Ssid);
                var arr      = GetSession(realSsid);
                if (arr.Length < 3)
                {
                    result.Exception.Exmsg   = "not found";
                    result.Exception.Success = true;
                    return(result);
                }
                var findIt = _user.SearchUser(arr.GetValue(2).ToString());
                if (findIt == null)
                {
                    throw new NullReferenceException();
                }
                if (!findIt.Pwd.Equals(new EncryDecryUser().Md5Encrypt(query.OldPass)))
                {
                    result.Exception.Success = false;
                    result.Exception.Exmsg   = "旧密码输入错误";
                    return(result);
                }
                findIt.Pwd = new EncryDecryUser().Md5Encrypt(query.Paw);
                _user.UpdateUser(findIt);
                result.Exception.Success = true;
            }
            catch (Exception ex)
            {
                result.Exception.Success = false;
                AppLogger.Error($"{ex.Message} {ex.StackTrace}");
            }

            return(result);
        }
Пример #10
0
        public ResultLogin Login(QueryUserLogin query)
        {
            var result = new ResultLogin {
                Exception = new MyException()
            };

            try
            {
                if (Validate(query.UserName, query.Password) == false)
                {
                    result.Exception.Success = false;
                    result.Exception.Exmsg   = "用户名或密码错误";
                    return(result);
                }
                var findIt = _user.SearchUser(query.UserName);
                if (findIt == null)
                {
                    result.Exception.Success = false;
                    result.Exception.Exmsg   = "用户名或密码错误";
                    return(result);
                }
                var pwd = new EncryDecryUser().Md5Encrypt(query.Password);
                result.Exception.Success = findIt.Pwd.Equals(pwd);
                if (result.Exception.Success)
                {
                    var realSsid = new EncryDecry().Md5Decrypt(query.Ssid);
                    var arr      = GetSession(realSsid);
                    _redisOper.Set(realSsid, $"1999_{DateTime.Now}_{findIt.Name}");//1999代表session
                    UpdateCartOrderInfo(query.UserName, realSsid);
                }
            }
            catch (Exception ex)
            {
                result.Exception.Success = false;
                result.Exception.Exmsg   = ex.Message;
            }
            return(result);
        }
Пример #11
0
        public ResultModifyAddress SaveAddress(QueryAdress query)
        {
            var result = new ResultModifyAddress {
                Exception = new MyException()
            };

            try
            {
                var realSsid = new EncryDecry().Md5Decrypt(query.Ssid);
                var arr      = GetSession(realSsid);
                if (arr.Length < 3)
                {
                    result.Exception.Exmsg   = "not found";
                    result.Exception.Success = true;
                    return(result);
                }
                var findIt = _user.SearchUser(arr.GetValue(2).ToString());
                if (findIt == null)
                {
                    throw new NullReferenceException();
                }
                var info = _userInfo.GeTbUserInfos($"{findIt.Name}")?[0];
                if (info != null)
                {
                    info.Address = query.Address;
                    _userInfo.UpdateUserInfo(info);
                }
                result.Exception.Success = true;
            }
            catch (Exception ex)
            {
                AppLogger.Error($"{ex.Message} {ex.StackTrace}");
                result.Exception.Success = false;
            }
            return(result);
        }