Exemplo n.º 1
0
        public ActionResult ResetPassword(int id)
        {
            JsonModel jm = new JsonModel();

            IUserBLL userBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

            // 根据指定id值获取实体对象
            var user = userBll.GetEntity(u => u.Id == id && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            if (user != null)
            {
                Random r           = new Random();
                string newPassword = user.UserName + r.Next(100, 1000);
                user.Password = PropertyUtils.GetMD5Str(newPassword);

                // 恢复初始密码值
                userBll.Update(user);

                // 给用户发送邮件
                PropertyUtils.SendEmail(user.Email, user.UserName, "物业生活管理平台 APP用户密码重置", "您的用户密码已重置为:" + newPassword + ",请及时修改密码!");
                //操作日志
                jm.Content = "APP注册用户" + user.UserName + " 密码一键重置";
            }
            else
            {
                jm.Msg = "该用户不存在";
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public ActionResult UserResetPassword(UserPassResetModel model)
        {
            //判断提交模型数据是否正确
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            IUserBLL userBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

            var user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            if (user != null)
            {
                //如果重置密码激活码存在且未失效
                if (!string.IsNullOrEmpty(user.Activecode) && model.Activecode == user.Activecode &&
                    user.ActivecodeInvalidTime != null && DateTime.Now < user.ActivecodeInvalidTime.Value)
                {
                    user.Password = PropertyUtils.GetMD5Str(model.Password);
                    //密码重置链接失效
                    user.Activecode            = "";
                    user.ActivecodeInvalidTime = null;
                    //如果修改成功
                    if (userBll.Update(user))
                    {
                        return(RedirectToAction("ResetSuccess"));
                    }
                }
            }
            return(RedirectToAction("Error500"));
        }
Exemplo n.º 3
0
        public ApiPageResultModel GetAllTopicListByType([FromUri] AllTopicPagedSearchModel model)
        {
            ApiPageResultModel resultModel = new ApiPageResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    var collectedTopicIds = owner.UserPostBarTopics.Select(o => o.PostBarTopicId).ToList();

                    IPostBarTopicBLL topicBLL = BLLFactory <IPostBarTopicBLL> .GetBLL("PostBarTopicBLL");

                    // 获取小区某分类下的所有主题列表
                    var list = topicBLL.GetSetTopPageList(m => m.PropertyPlaceId == model.PropertyPlaceId && m.TopicTypeId == model.TopicTypeId, model.PageIndex, ConstantParam.PAGE_SIZE).Select(m => new
                    {
                        Id           = m.Id,
                        PostDate     = m.PostDate.ToString("yyyy-MM-dd HH:mm:ss"),
                        IsTop        = m.IsTop,
                        UserImage    = m.PostUser.HeadPath,
                        UserName     = m.PostUser.UserName,
                        Title        = m.Title,
                        Content      = m.Content,
                        PicList      = m.ImgPath,
                        CommentCount = m.PostBarTopicDiscusss.Count(),
                        IsCollected  = collectedTopicIds.Contains(m.Id) ? 1 : 0,
                        TopicType    = m.PostBarTopicType.Name,
                        PostUserId   = m.PostUserId
                    }).ToList();

                    resultModel.result = list;
                    resultModel.Total  = topicBLL.Count(m => m.PropertyPlaceId == model.PropertyPlaceId && m.TopicTypeId == model.TopicTypeId);
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(resultModel);
        }
Exemplo n.º 4
0
        public ApiResultModel EditLifeBill(EditLifeBillModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //通过用户Id查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }

                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    ILifeBillBLL lifeBillBll = BLLFactory <ILifeBillBLL> .GetBLL("LifeBillBLL");

                    T_LifeBill lifebill = lifeBillBll.GetEntity(u => u.Id == model.Id && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                    //如果该生活记账存在
                    if (lifebill != null)
                    {
                        lifebill.Id              = model.Id;
                        lifebill.BillTypeId      = model.CategoryId;
                        lifebill.PayTypeId       = model.PayId;
                        lifebill.Money           = model.Money;
                        lifebill.ConsumptionDate = Convert.ToDateTime(model.PayDate);
                        lifebill.CreateDate      = Convert.ToDateTime(model.DateStr);
                        lifebill.Memo            = model.Mark;

                        //更新
                        lifeBillBll.Update(lifebill);
                    }
                    else
                    {
                        resultModel.Msg = "生活记账不存在";
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 5
0
        public ApiPageResultModel DisposeFeedbackList([FromUri] PagedSearchModel model)
        {
            ApiPageResultModel resultModel = new ApiPageResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    //获取要公示的问题解决反馈 总个数和分页数据
                    IQuestionBLL questionBll = BLLFactory <IQuestionBLL> .GetBLL("QuestionBLL");

                    //条件已处理和要公示
                    var placeList = owner.UserPlaces.Select(m => m.PropertyPlaceId);
                    Expression <Func <T_Question, bool> > where = u => u.Status == ConstantParam.DISPOSED && u.IsPublish == ConstantParam.PUBLISHED_TRUE &&
                                                                  placeList.Contains(u.PropertyPlaceId);
                    resultModel.Total  = questionBll.Count(where);
                    resultModel.result = questionBll.GetPageList(where, "Id", false, model.PageIndex).ToList().Select(q => new
                    {
                        Id              = q.Id,
                        Title           = q.Title,
                        Desc            = string.IsNullOrEmpty(q.Desc) ? "" : q.Desc,
                        UploadUserName  = q.UploadUser.UserName,
                        UploadTime      = q.UploadTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        Imgs            = string.IsNullOrEmpty(q.Imgs) ? new string[] { } : q.Imgs.Split(';'),
                        AudioPath       = q.AudioPath,
                        VoiceDuration   = q.VoiceDuration,
                        PlaceName       = q.PropertyPlace.Name,
                        DisposeDesc     = q.QuestionDisposes.FirstOrDefault().DisposeDesc,
                        DisposeUserName = string.IsNullOrEmpty(q.QuestionDisposes.FirstOrDefault().DisposeUser.TrueName) ?
                                          q.QuestionDisposes.FirstOrDefault().DisposeUser.UserName : q.QuestionDisposes.FirstOrDefault().DisposeUser.TrueName,
                        DisposesTime = q.QuestionDisposes.FirstOrDefault().DisposeTime.ToString("yyyy-MM-dd HH:mm:ss")
                    });
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 6
0
        public ApiResultModel DeleteReply(DeleteReplyModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL userBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                if (user != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }

                    //更新最近登录时间和Token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));

                    userBll.Update(user);

                    //获取要删除的回复内容
                    IPostBarTopicDiscussBLL postBarTopicDiscussBll = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL");

                    T_PostBarTopicDiscuss reply = postBarTopicDiscussBll.GetEntity(u => u.Id == model.Id);

                    //如果该回复存在
                    if (reply == null)
                    {
                        resultModel.Msg = "该回复不存在";
                    }
                    else
                    {
                        if (reply.ParentId == null)
                        {
                            postBarTopicDiscussBll.DeleteLevelOneDiscuss(reply.Id);
                        }
                        else
                        {
                            postBarTopicDiscussBll.Delete(reply);
                        }
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(resultModel);
        }
Exemplo n.º 7
0
        public ActionResult UserResetPassword(PassResetActiveModel model)
        {
            if (model.Body == null)
            {
                return(RedirectToAction("ResetUrlInvalid"));
            }
            //将用户ID解密
            int      UserId  = Int32.Parse(PropertyUtils.DecodeBase64(model.Body));
            IUserBLL userBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

            var user = userBll.GetEntity(u => u.Id == UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            if (user != null)
            {
                //如果重置密码激活码存在且未失效
                if (!string.IsNullOrEmpty(user.Activecode) && model.Activecode == user.Activecode &&
                    user.ActivecodeInvalidTime != null && DateTime.Now <= user.ActivecodeInvalidTime.Value)
                {
                    UserPassResetModel m = new UserPassResetModel();
                    m.UserId     = user.Id;
                    m.UserName   = user.UserName;
                    m.Activecode = user.Activecode;
                    return(View(m));
                }
                else
                {
                    return(RedirectToAction("ResetUrlInvalid"));
                }
            }
            else
            {
                return(RedirectToAction("ResetUrlInvalid"));
            }
        }
Exemplo n.º 8
0
        public ApiPageResultModel GetSaleList([FromUri] GoodsSearchModel model)
        {
            ApiPageResultModel resultModel = new ApiPageResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    //该门店销售中的商品
                    Expression <Func <T_ShopSale, bool> > where = s => s.GoodsCategory.ShopId == model.ShopId && s.InSales == 1;
                    //如果选择了商品分类
                    if (model.GoodsCategoryId > 0)
                    {
                        where = PredicateBuilder.And(where, s => s.GoodsCategoryId == model.GoodsCategoryId);
                    }
                    //获取指定门店指定类别的商品列表
                    IShopSaleBLL SaleBll = BLLFactory <IShopSaleBLL> .GetBLL("ShopSaleBLL");

                    resultModel.Total  = SaleBll.Count(where);
                    resultModel.result = SaleBll.GetPageList(where, "Id", false, model.PageIndex).ToList().Select(s => new
                    {
                        GoodsId        = s.Id,
                        GoodsName      = s.Title,
                        GoodsDesc      = s.Content,
                        RemainingAmout = s.RemainingAmout,
                        SellAmout      = s.OrderDetails.Where(od => od.Order.OrderStatus == ConstantParam.OrderStatus_FINISH).Select(od => od.SaledAmount).ToArray().Sum(),
                        GoodsCoverImg  = string.IsNullOrEmpty(s.ImgThumbnail) ? "" : s.ImgThumbnail.Split(';')[0],
                        GoodsOtherImg  = string.IsNullOrEmpty(s.ImgPath) ? "" : s.ImgPath,
                        Price          = s.Price
                    });
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 9
0
        public string GetRepliedName(int replyId)
        {
            IUserBLL userBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

            var user        = userBll.GetEntity(m => m.Id == replyId);
            var repliedName = string.Format("回复{0}:", user.UserName);

            return(repliedName);
        }
Exemplo n.º 10
0
        public ApiPageResultModel GetMyLevel2RepliesList([FromUri] Level2RepliedListModel model)
        {
            ApiPageResultModel resultModel = new ApiPageResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);


                    IPostBarTopicDiscussBLL topicDiscussBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL");

                    var level1Disscuss = topicDiscussBLL.GetEntity(m => m.Id == model.Id);
                    // 获取我的二级回复列表
                    var list = topicDiscussBLL.GetPageList(m => m.ParentId == model.Id && m.TopicId == model.TopicId, "PostTime", true, model.PageIndex, ConstantParam.PAGE_SIZE).Select(m => new
                    {
                        Id              = m.Id,
                        PostDate        = m.PostTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        UserId          = m.PostUserId,
                        UserImage       = m.PostUser.HeadPath,
                        UserName        = m.PostUser.UserName,
                        Content         = m.Content,
                        PicList         = m.ImgPath,
                        RepliedUserName = m.ReplyUser.UserName,
                        Level2ParentId  = m.ParentId
                    }).ToList();

                    resultModel.result = list;
                    resultModel.Total  = topicDiscussBLL.Count(m => m.ParentId == model.Id && m.TopicId == model.TopicId);
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(resultModel);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 获取当前用户
        /// </summary>
        /// <returns></returns>
        public T_User GetCurrentUser()
        {
            string   Unionid  = (string)Session["Unionid"];
            IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

            T_User owner = ownerBll.GetEntity(o => o.WeixinUnionId == Unionid && o.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            return(owner);
        }
Exemplo n.º 12
0
        public ApiPageResultModel ShopList([FromUri] ShopSearchModel model)
        {
            ApiPageResultModel resultModel = new ApiPageResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

                    Expression <Func <T_Shop, bool> > where = u => u.Type.Contains(model.Type.ToString());
                    //如果是生活小卖店或五金店
                    if (model.Type == 2 || model.Type == 3)
                    {
                        var placeList = owner.UserPlaces.Select(m => m.PropertyPlaceId);
                        where = PredicateBuilder.And(where, u => u.ShopPlaces.Count(p => placeList.Contains(p.PropertyPlaceId)) > 0);
                    }
                    resultModel.Total  = shopBll.Count(where);
                    resultModel.result = shopBll.GetPageList(where, "Id", false, model.PageIndex).ToList().Select(s => new
                    {
                        Id       = s.Id,
                        ShopName = s.ShopName,
                        Content  = s.MainSale,
                        Phone    = string.IsNullOrEmpty(s.Phone) ? "" : s.Phone,
                        Img      = string.IsNullOrEmpty(s.ImgThumbnail) ? "" : s.ImgThumbnail.Split(';')[0]
                    });
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 13
0
        public ApiPageResultModel ExpensedRecordList([FromUri] PagedSearchModel model)
        {
            ApiPageResultModel resultModel = new ApiPageResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    //初始化查询条件
                    var DoorIds    = owner.PropertyIdentityVerification.Where(v => v.DoorId != null).Select(m => m.DoorId);
                    var CompanyIds = owner.PropertyIdentityVerification.Where(v => v.BuildCompanyId != null).Select(m => m.BuildCompanyId);
                    Expression <Func <T_HouseUserExpenseDetails, bool> > where = u => u.IsPayed == ConstantParam.PAYED_TRUE && (DoorIds.Contains(u.BuildDoorId) || CompanyIds.Contains(u.BuildCompanyId));
                    // 获取当前用户对应业主的缴费记录
                    IHouseUserExpenseDetailsBLL expenseDetailsBLL = BLLFactory <IHouseUserExpenseDetailsBLL> .GetBLL("HouseUserExpenseDetailsBLL");

                    var list = expenseDetailsBLL.GetPageList(where, "PayedDate", false, model.PageIndex).Select(e => new
                    {
                        RecordId        = e.Id,
                        ExpenseTypeName = e.PropertyExpenseType.Name,
                        ExpenseDateDes  = e.ExpenseDateDes,
                        PlaceName       = e.BuildCompanyId == null ? e.BuildDoor.BuildUnit.Build.PropertyPlace.Name : e.BuildCompany.PropertyPlace.Name,
                        Expense         = e.Expense,
                        PayedTime       = e.PayedDate.Value.ToString("yyyy-MM-dd HH:mm:ss")
                    }).ToList();
                    resultModel.result = list;
                    resultModel.Total  = expenseDetailsBLL.GetList(where).Count();
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 14
0
        public ApiResultModel QuestionDetail([FromUri] DetailSearchModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    //获取问题总个数和分页数据
                    IQuestionBLL questionBll = BLLFactory <IQuestionBLL> .GetBLL("QuestionBLL");

                    var question = questionBll.GetEntity(u => u.Id == model.Id);
                    resultModel.result = new
                    {
                        Id            = question.Id,
                        Title         = question.Title,
                        Desc          = string.IsNullOrEmpty(question.Desc) ? "" : question.Desc,
                        Status        = question.Status,
                        UploadTime    = question.UploadTime.ToString("yyyy-MM-dd HH:mm:ss"),
                        Imgs          = string.IsNullOrEmpty(question.Imgs) ? new string[] {} : question.Imgs.Split(';'),
                        AudioPath     = question.AudioPath,
                        VoiceDuration = question.VoiceDuration,
                        PlaceName     = question.PropertyPlace.Name,
                        DisposesTime  = question.Status == ConstantParam.NO_DISPOSE ? null : question.QuestionDisposes.FirstOrDefault().DisposeTime.ToString("yyyy-MM-dd HH:mm:ss")
                    };
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 15
0
        public ApiResultModel GetShopPayWay([FromUri] DetailSearchModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    //获取要查询的门店
                    IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

                    var shop = shopBll.GetEntity(s => s.Id == model.Id);
                    if (shop != null)
                    {
                        var PayWays = shop.ShopPaymentManagements.Select(p => p.PayTypeId).ToList();
                        if (PayWays.Count > 0)
                        {
                            resultModel.result = PayWays;
                        }
                        else
                        {
                            resultModel.result = new List <int>();
                        }
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 16
0
        public ApiResultModel NewsDetail([FromUri] NewsDetailModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    IPostBLL postBll = BLLFactory <IPostBLL> .GetBLL("PostBLL");

                    var post = postBll.GetEntity(p => p.Id == model.PostId && p.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && p.PublishedFlag == 1);
                    if (post != null)
                    {
                        // 返回详细页面url
                        resultModel.result = new
                        {
                            PlaceTel = post.PropertyPlace.Tel,
                            Url      = "MobilePage/NewsDetail?id=" + model.PostId
                        };
                    }
                    else
                    {
                        resultModel.Msg = "新闻公告不存在";
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 17
0
        public ApiResultModel ShopDetail2([FromUri] DetailSearchModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    //获取要查看详细的门店实体对象
                    IShopBLL ShopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

                    T_Shop Shop = ShopBll.GetEntity(s => s.Id == model.Id);
                    if (Shop != null)
                    {
                        resultModel.result = new
                        {
                            ShopImg      = Shop.ImgPath,
                            ShopInfoPath = "MobilePage/StoreDetail2?ShopId=" + model.Id,
                        };
                    }
                    else
                    {
                        resultModel.Msg = APIMessage.SHOP_NOEXIST;
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 18
0
        public ApiPageResultModel NewsList([FromUri] PagedSearchModel model)
        {
            ApiPageResultModel resultModel = new ApiPageResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    // 获取指定物业小区id的公告列表
                    IPostBLL postBll = BLLFactory <IPostBLL> .GetBLL("PostBLL");

                    var placeList = owner.UserPlaces.Select(m => m.PropertyPlaceId);
                    Expression <Func <T_Post, bool> > where = u => placeList.Contains(u.PropertyPlaceId) && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT && u.PublishedFlag == ConstantParam.PUBLISHED_TRUE;
                    // TODO:此处Content不需要全部返回,待优化
                    var list = postBll.GetPageList(where, "PublishedTime", false, model.PageIndex).Select(s => new
                    {
                        ID           = s.Id,
                        propertyName = s.PropertyPlace.Name,
                        propertyPic  = string.IsNullOrEmpty(s.PropertyPlace.ImgThumbnail) ? "/Images/news_item_default.png" : s.PropertyPlace.ImgThumbnail,
                        pubDate      = s.PublishedTime.ToString(),
                        title        = s.Title
                    }).ToList();
                    resultModel.result = list;
                    resultModel.Total  = postBll.GetList(where).Count();
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 19
0
        public ApiResultModel CollectTopic(CollectTopicModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL userBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                if (user != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }

                    //更新最近登录时间和Token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));

                    //如果没有收藏,则收藏主题
                    var check = user.UserPostBarTopics.FirstOrDefault(m => m.PostBarTopicId == model.TopicId && m.UserId == model.UserId);

                    if (check == null)
                    {
                        var userPostBarTopic = new R_UserPostBarTopic()
                        {
                            PostBarTopicId = model.TopicId,
                            UserId         = model.UserId
                        };

                        user.UserPostBarTopics.Add(userPostBarTopic);
                    }

                    userBll.Update(user);
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(resultModel);
        }
Exemplo n.º 20
0
        public ApiResultModel GetShopFreight([FromUri] ShopFreightSearchModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    //获取要查询的门店
                    IShopBLL shopBll = BLLFactory <IShopBLL> .GetBLL("ShopBLL");

                    var shop = shopBll.GetEntity(s => s.Id == model.Id);
                    if (shop != null)
                    {
                        var cost = shop.ShopShippingCosts.FirstOrDefault();
                        if (cost != null && cost.IsFree == 0 && (cost.OrderExpense == null || model.TotalPrice < cost.OrderExpense.Value))
                        {
                            resultModel.result = cost.Price.Value;
                        }
                        else
                        {
                            resultModel.result = 0;
                        }
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 21
0
        public ApiResultModel SetRecordToExpensed(DetailSearchModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    //设置缴费记录为已在线缴费
                    IHouseUserExpenseDetailsBLL expenseDetailsBLL = BLLFactory <IHouseUserExpenseDetailsBLL> .GetBLL("HouseUserExpenseDetailsBLL");

                    var record = expenseDetailsBLL.GetEntity(e => e.Id == model.Id);
                    if (record != null)
                    {
                        record.IsPayed     = ConstantParam.PAYED_TRUE;
                        record.PaymentType = 2;
                        record.PayedDate   = DateTime.Now;

                        expenseDetailsBLL.Update(record);
                    }
                    else
                    {
                        resultModel.Msg = APIMessage.EXPENSE_RECORD_NOEXIST;
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 22
0
        public ApiPageResultModel GetTopicSortList([FromUri] TopicSortSearchModel model)
        {
            ApiPageResultModel resultModel = new ApiPageResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != model.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }

                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    //获取小区所有主题分类列表
                    IPostBarTopicTypeBLL postBarTopicTypeBll = BLLFactory <IPostBarTopicTypeBLL> .GetBLL("PostBarTopicTypeBLL");

                    Expression <Func <T_PostBarTopicType, bool> > where = u => u.PropertyPlaceId == model.PropertyPlaceId;

                    var list = postBarTopicTypeBll.GetList(where, "Id", false).Select(s => new
                    {
                        ID   = s.Id,
                        Name = s.Name
                    }).ToList();

                    resultModel.result = list;
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 23
0
        public ApiResultModel GetLifePayType([FromUri] TokenModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //根据业主Id查询业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }

                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    //获取所有生活支付方式列表
                    ILifePayTypeBLL lifePayTypeBll = BLLFactory <ILifePayTypeBLL> .GetBLL("LifePayTypeBLL");

                    Expression <Func <T_LifePayType, bool> > where = u => u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT;

                    var list = lifePayTypeBll.GetList(where, "Id", true).ToList();
                    resultModel.result = list.Select(u => new
                    {
                        Id   = u.Id,
                        Img  = u.Img,
                        Name = u.Name
                    });
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 24
0
        public ApiResultModel GetExpressCompany([FromUri] TokenModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                ///查询用户Id查找业主
                IUserBLL userBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User user = userBll.GetEntity(m => m.Id == model.UserId && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                //如果业主不存在
                if (user != null)
                {
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }

                    //更新最近的登录时间和最新的token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    userBll.Update(user);

                    IExpressCompanyBLL expressCompanyBLL = BLLFactory <IExpressCompanyBLL> .GetBLL("ExpressCompanyBLL");

                    Expression <Func <T_ExpressCompany, bool> > where = o => o.DelFlag == ConstantParam.DEL_FLAG_DEFAULT;

                    var list = expressCompanyBLL.GetList(where, "Id", true).ToList();

                    resultModel.result = list.Select(u => new
                    {
                        Id    = u.Id,
                        Img   = u.Img,
                        Phone = u.Phone
                    });
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 25
0
        /// <summary>
        /// 楼层详细列表
        /// </summary>
        /// <param name="floorId">一级回复的主键Id</param>
        /// <param name="replyId">准备要回复对方的Id</param>
        /// <returns></returns>
        public ActionResult FloorDetailList(int floorId, int replyId)
        {
            int CurrentUserId = GetCurrentUser().Id;

            WeixinApiInit();

            //获取当前楼层(也就是一级回复的)信息
            IPostBarTopicDiscussBLL topicDiscussBLL = BLLFactory <IPostBarTopicDiscussBLL> .GetBLL("PostBarTopicDiscussBLL");

            var topicDiscuss = topicDiscussBLL.GetEntity(m => m.Id == floorId);
            //主题下面所有的一级Ids
            var level1Ids = topicDiscussBLL.GetList(m => m.TopicId == topicDiscuss.TopicId && m.ParentId == null).OrderBy(m => m.PostTime).Select(m => m.Id).ToList();
            //当前是第几楼
            int FloorNo = level1Ids.FindIndex(m => m == floorId) + 1;

            ViewBag.FloorNo = string.Format("{0}楼", FloorNo);

            IUserBLL userBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

            var replidUserName = "";

            var replyUser = userBll.GetEntity(m => m.Id == replyId);

            replidUserName = string.Format("回复{0}:", replyUser.UserName);

            var model = new TopicFloorDetailModel()
            {
                FloorId            = topicDiscuss.Id,
                FloorNo            = string.Format("第{0}楼", FloorNo),
                PostUserId         = topicDiscuss.PostUserId,
                PostUserName       = topicDiscuss.PostUser.UserName,
                PostUserHeadPath   = topicDiscuss.PostUser.HeadPath,
                ImgPath            = topicDiscuss.ImgPath,
                ImgThumbnail       = topicDiscuss.ImgThumbnail,
                PostDate           = string.Format("第{0}楼 {1}", FloorNo, TimeFormat(topicDiscuss.PostTime)),
                Content            = topicDiscuss.Content,
                PropertyPlaceId    = topicDiscuss.PostBarTopic.PropertyPlaceId,
                TopicId            = topicDiscuss.PostBarTopic.Id,
                LevelTwoReplyCount = topicDiscussBLL.Count(m => m.ParentId == topicDiscuss.Id && m.TopicId == topicDiscuss.TopicId),
                ReplyId            = replyId,
                ReplidUserName     = replidUserName,
                CurrentUserId      = CurrentUserId,
                CanDelete          = topicDiscuss.PostUserId == CurrentUserId
            };

            return(View(model));
        }
Exemplo n.º 26
0
        public ApiResultModel GetGoodsCategoryList([FromUri] DetailSearchModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User owner = ownerBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果业主存在
                if (owner != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > owner.TokenInvalidTime || model.Token != owner.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }
                    //更新最近登录时间和Token失效时间
                    owner.LatelyLoginTime  = DateTime.Now;
                    owner.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));
                    ownerBll.Update(owner);

                    //该门店的商品类别
                    Expression <Func <T_GoodsCategory, bool> > where = s => s.ShopId == model.Id;
                    //获取指定门店的类别列表
                    IGoodsCategoryBLL categoryBll = BLLFactory <IGoodsCategoryBLL> .GetBLL("GoodsCategoryBLL");

                    resultModel.result = categoryBll.GetList(where).Select(s => new
                    {
                        CategoryId   = s.Id,
                        CategoryName = s.Name
                    });
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(resultModel);
        }
Exemplo n.º 27
0
        public ApiResultModel CancelCollectedTopic(CollectTopicModel model)
        {
            ApiResultModel resultModel = new ApiResultModel();

            try
            {
                //根据用户ID查找业主
                IUserBLL userBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User user = userBll.GetEntity(u => u.Id == model.UserId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

                if (user != null)
                {
                    //如果验证Token不通过或已过期
                    if (DateTime.Now > user.TokenInvalidTime || model.Token != user.Token)
                    {
                        resultModel.Msg = APIMessage.TOKEN_INVALID;
                        return(resultModel);
                    }

                    //更新最近登录时间和Token失效时间
                    user.LatelyLoginTime  = DateTime.Now;
                    user.TokenInvalidTime = DateTime.Now.AddDays(Convert.ToInt32(PropertyUtils.GetConfigParamValue("TokenInvalid")));

                    userBll.Update(user);
                    //如果有收藏主题,取消收藏
                    var userPostBarTopic = user.UserPostBarTopics.FirstOrDefault(m => m.PostBarTopicId == model.TopicId && m.UserId == model.UserId);

                    if (userPostBarTopic != null)
                    {
                        userBll.ExecuteSql(string.Format("delete from R_UserPostBarTopic where userid={0} and postbartopicid={1}", model.UserId, model.TopicId));
                    }
                }
                else
                {
                    resultModel.Msg = APIMessage.NO_USER;
                }
            }
            catch
            {
                resultModel.Msg = APIMessage.REQUEST_EXCEPTION;
            }

            return(resultModel);
        }
Exemplo n.º 28
0
        /// <summary>
        /// 在某个action执行之前进行拦截
        /// </summary>
        /// <param name="filterContext"></param>
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

            //获取当前保存的Session
            HttpContextBase ctx     = filterContext.HttpContext;
            string          Unionid = (string)ctx.Session["Unionid"];
            string          Openid  = (string)ctx.Session["OpenId"];

            //获取请求地址
            string controller = filterContext.RouteData.Values["controller"].ToString();
            string action     = filterContext.RouteData.Values["action"].ToString();

            if (Openid == null || Unionid == null || !ownerBll.Exist(o => o.WeixinUnionId == Unionid && o.DelFlag == ConstantParam.DEL_FLAG_DEFAULT) ||
                !ownerBll.Exist(o => o.WeixinOpenId == Openid && o.DelFlag == ConstantParam.DEL_FLAG_DEFAULT))
            {
                string url = HttpContext.Current.Request.Url.ToString();
                ctx.Session["VisitUrl"] = url;
                string oAuthUrl = OAuthApi.GetAuthorizeUrl(ConstantParam.AppId, "http://v.homekeeper.com.cn/WeixinOAuth2/UserInfoCallback", "sarnath", OAuthScope.snsapi_userinfo);
                filterContext.Result = new RedirectResult(oAuthUrl);
            }
            else if (!"WeixinPersonalCenter".Equals(controller) && !"WeixinIdentityBind".Equals(controller) && !"WeixinHome".Equals(controller))
            {
                var owner      = ownerBll.GetEntity(o => o.WeixinUnionId == Unionid && o.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                var userPlaces = owner.UserPlaces.Where(p => p.PropertyPlace.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                if (userPlaces.Count() == 0)
                {
                    filterContext.Result = new RedirectResult("/WeixinIdentityBind/AddPlace");
                }
                else if (!"WeixinPropertyNotice".Equals(controller) && userPlaces.Select(p => IsVerified(p.PropertyPlace, p.User)).Count(i => i) == 0)
                {
                    filterContext.Result = new RedirectResult("/WeixinIdentityBind/Index");
                }
            }
            base.OnActionExecuting(filterContext);
        }
Exemplo n.º 29
0
        public JsonResult DeleteUser(int id)
        {
            JsonModel jm = new JsonModel();

            try
            {
                //获取要删除的业主
                IUserBLL userBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                T_User user = userBll.GetEntity(m => m.Id == id && m.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                //如果该业主存在
                if (user != null)
                {
                    //修改指定业主中的已删除标识
                    user.DelFlag = ConstantParam.DEL_FLAG_DELETE;
                    if (userBll.DeleteUser(user))
                    {
                        //操作日志
                        jm.Content = "删除APP注册用户" + user.UserName;
                    }
                    else
                    {
                        jm.Msg = "删除失败";
                    }
                }
                else
                {
                    jm.Msg = "该APP注册用户不存在";
                }
            }
            catch
            {
                jm.Msg = "删除失败";
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 30
0
        /// <summary>
        /// OAuthScope.snsapi_userinfo方式回调
        /// </summary>
        /// <param name="code"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public ActionResult UserInfoCallback(string code, string state)
        {
            if (string.IsNullOrEmpty(code))
            {
                return(Content("您拒绝了授权!"));
            }
            if (state != "sarnath")
            {
                //实际上可以存任何想传递的数据,比如用户ID,并且需要结合例如下面的Session["OAuthAccessToken"]进行验证
                return(Content("验证失败!请从正规途径进入!"));
            }
            OAuthAccessTokenResult result = null;

            //通过,用code换取access_token
            try
            {
                result = OAuthApi.GetAccessToken(ConstantParam.AppId, ConstantParam.AppSecret, code);
            }
            catch (Exception ex)
            {
                return(Content(ex.Message));
            }
            if (result.errcode != ReturnCode.请求成功)
            {
                return(Content("错误:" + result.errmsg));
            }
            //下面2个数据也可以自己封装成一个类,储存在数据库中(建议结合缓存)
            //如果可以确保安全,可以将access_token存入用户的cookie中,每一个人的access_token是不一样的
            Session["OAuthAccessTokenStartTime"] = DateTime.Now;
            Session["OAuthAccessToken"]          = result;

            //获取用户详细信息
            try
            {
                OAuthUserInfo userInfo = OAuthApi.GetUserInfo(result.access_token, result.openid);

                IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                //如果微信Unionid不存在
                if (!ownerBll.Exist(o => o.WeixinUnionId == userInfo.unionid && o.DelFlag == ConstantParam.DEL_FLAG_DEFAULT))
                {
                    //随机字符串
                    string str       = "1234567890abcdefghijklmnopqrstuvwxyz";
                    Random r         = new Random();
                    string RandomStr = "";
                    for (int i = 0; i < 16; i++)
                    {
                        RandomStr += str[r.Next(str.Length)].ToString();
                    }
                    T_User user = new T_User()
                    {
                        UserName      = RandomStr,
                        WeixinOpenId  = userInfo.openid,
                        WeixinUnionId = userInfo.unionid
                    };
                    if (userInfo.sex > 0)
                    {
                        user.Gender = userInfo.sex == 1 ? 0 : 1;
                    }
                    ownerBll.Save(user);
                }
                else if (!ownerBll.Exist(o => o.WeixinOpenId == userInfo.openid && o.DelFlag == ConstantParam.DEL_FLAG_DEFAULT))
                {
                    T_User user = ownerBll.GetEntity(o => o.WeixinUnionId == userInfo.unionid && o.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                    user.WeixinOpenId = userInfo.openid;
                    ownerBll.Update(user);
                }
                var owner = ownerBll.GetEntity(o => o.WeixinUnionId == userInfo.unionid && o.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);
                Session["OpenId"]  = owner.WeixinOpenId;
                Session["Unionid"] = owner.WeixinUnionId;
                return(Redirect((string)Session["VisitUrl"]));
            }
            catch (ErrorJsonResultException ex)
            {
                return(Content(ex.Message));
            }
        }