Exemple #1
0
        public JsonResult PhoneInfo(PhoneInfoModel model)
        {
            JsonModel jm = new JsonModel();

            var owner = GetCurrentUser();

            if (owner != null)
            {
                //判断验证码是否正确
                IPhoneValidateBLL phoneValidateBll = BLLFactory <IPhoneValidateBLL> .GetBLL("PhoneValidateBLL");

                var val = phoneValidateBll.GetEntity(v => v.PhoneNum == model.Phone && v.ActionCode == 0);


                //如果验证码不准确
                if (val == null && model.VerityCode != val.ValidateCode)
                {
                    jm.Msg = APIMessage.VALIDATE_ERROR;
                    return(Json(jm, JsonRequestBehavior.AllowGet));
                }

                //验证码已失效
                if (val.InvalidTime < DateTime.Now)
                {
                    jm.Msg = APIMessage.VALIDATE_INVALID;
                    return(Json(jm, JsonRequestBehavior.AllowGet));
                }
                owner.Phone = model.Phone;

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

                ownerBll.Update(owner);
            }
            else
            {
                jm.Msg = "该用户不存在";
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
        public JsonResult GetValidateCode(string phoneNum, int actionCode)
        {
            JsonModel jm = new JsonModel();

            try
            {
                //如果是注册(设置手机号)操作获取验证码
                if (actionCode == 0)
                {
                    IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                    //如果手机号已存在
                    if (ownerBll.Exist(o => o.Phone == phoneNum && o.DelFlag == ConstantParam.DEL_FLAG_DEFAULT))
                    {
                        jm.Msg = APIMessage.PHONE_EXIST;
                        return(Json(jm, JsonRequestBehavior.AllowGet));
                    }
                }
                else if (actionCode == 1)
                {
                    IUserBLL ownerBll = BLLFactory <IUserBLL> .GetBLL("UserBLL");

                    //如果手机号对应用户不存在
                    if (!ownerBll.Exist(o => o.Phone == phoneNum && o.DelFlag == ConstantParam.DEL_FLAG_DEFAULT))
                    {
                        jm.Msg = APIMessage.PHONE_NO_EXIST;
                        return(Json(jm, JsonRequestBehavior.AllowGet));
                    }
                }
                string code = PropertyUtils.CreateValidateCode(6);
                string msg  = "感谢使用【Ai我家】微信公众号,验证码为:" + code + ",请在页面输入完成验证,如非本人操作请忽略";
                //如果短信发送成功
                if (PropertyUtils.SendSMS(phoneNum, msg, null))
                {
                    IPhoneValidateBLL phoneValidateBll = BLLFactory <IPhoneValidateBLL> .GetBLL("PhoneValidateBLL");

                    var phoneValidate = phoneValidateBll.GetEntity(v => v.PhoneNum == phoneNum && v.ActionCode == actionCode);
                    //如果该手机号在相同操作中不存在
                    if (phoneValidate == null)
                    {
                        T_PhoneValidate v = new T_PhoneValidate()
                        {
                            PhoneNum     = phoneNum,
                            ValidateCode = code,
                            InvalidTime  = DateTime.Now.AddMinutes(Convert.ToInt32(PropertyUtils.GetConfigParamValue("ValidateCodeInvalid"))),
                            ActionCode   = actionCode
                        };
                        phoneValidateBll.Save(v);
                    }
                    else
                    {
                        phoneValidate.ValidateCode = code;
                        phoneValidate.InvalidTime  = DateTime.Now.AddMinutes(Convert.ToInt32(PropertyUtils.GetConfigParamValue("ValidateCodeInvalid")));
                        phoneValidateBll.Update(phoneValidate);
                    }
                }
                else
                {
                    jm.Msg = APIMessage.VALDATE_GET_FAIL;
                }
            }
            catch
            {
                jm.Msg = APIMessage.REQUEST_EXCEPTION;
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }
Exemple #3
0
        public JsonResult IdentityVerification(PlaceIdentityVerifyModel model)
        {
            JsonModel jm    = new JsonModel();
            var       owner = GetCurrentUser();

            //获取要绑定验证的小区
            IPropertyPlaceBLL propertyPlaceBll = BLLFactory <IPropertyPlaceBLL> .GetBLL("PropertyPlaceBLL");

            var place = propertyPlaceBll.GetEntity(u => u.Id == model.PlaceId && u.DelFlag == ConstantParam.DEL_FLAG_DEFAULT);

            if (place == null)
            {
                jm.Msg = "小区已不存在";
                return(Json(jm, JsonRequestBehavior.AllowGet));
            }

            IPropertyIdentityVerificationBLL identityVerificationBll = BLLFactory <IPropertyIdentityVerificationBLL> .GetBLL("PropertyIdentityVerificationBLL");

            //如果小区类型为住宅小区
            if (place.PlaceType == ConstantParam.PLACE_TYPE_HOUSE)
            {
                //判断验证码是否正确
                IPhoneValidateBLL phoneValidateBll = BLLFactory <IPhoneValidateBLL> .GetBLL("PhoneValidateBLL");

                var val = phoneValidateBll.GetEntity(v => v.PhoneNum == model.Phone && v.ActionCode == 2);
                //判断验证码不准确
                if (val == null || model.VerityCode != val.ValidateCode)
                {
                    jm.Msg = APIMessage.VALIDATE_ERROR;
                    return(Json(jm, JsonRequestBehavior.AllowGet));
                }
                //验证码已失效
                if (val.InvalidTime < DateTime.Now)
                {
                    jm.Msg = APIMessage.VALIDATE_INVALID;
                    return(Json(jm, JsonRequestBehavior.AllowGet));
                }

                var identityVerification = identityVerificationBll.GetEntity(i => i.AppUserId == owner.Id && i.BuildDoor.BuildUnit.Build.PropertyPlaceId == place.Id);
                if (identityVerification != null)
                {
                    //如果存在审核中或已通过的验证信息
                    if (identityVerification.IsVerified != 2)
                    {
                        jm.Msg = APIMessage.VerifingOrYES;
                        return(Json(jm, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        identityVerification.DoorId = model.DoorId;
                        identityVerification.Name   = model.OwnerName;
                        identityVerification.Phone  = model.Phone;
                        //如果该小区不需要审批身份
                        if (place.IsValidate == 1)
                        {
                            identityVerification.IsVerified = ConstantParam.IsVerified_YES;
                        }
                        else
                        {
                            identityVerification.IsVerified = ConstantParam.IsVerified_DEFAULT;
                        }
                        //更新验证申请
                        identityVerificationBll.Update(identityVerification);
                    }
                }
                else
                {
                    identityVerification = new R_PropertyIdentityVerification()
                    {
                        AppUserId = owner.Id,
                        Name      = model.OwnerName,
                        Phone     = model.Phone,
                        DoorId    = model.DoorId,
                    };
                    //如果该小区不需要审批身份
                    if (place.IsValidate == 1)
                    {
                        identityVerification.IsVerified = ConstantParam.IsVerified_YES;
                    }
                    else
                    {
                        identityVerification.IsVerified = ConstantParam.IsVerified_DEFAULT;
                    }
                    //保存验证申请
                    identityVerificationBll.Save(identityVerification);
                }
            }
            //如果小区是办公楼小区
            else
            {
                var identityVerification = identityVerificationBll.GetEntity(i => i.AppUserId == owner.Id && i.BuildCompany.PropertyPlaceId == place.Id);
                if (identityVerification != null)
                {
                    //如果存在审核中或已通过的验证信息
                    if (identityVerification.IsVerified != 2)
                    {
                        jm.Msg = APIMessage.VerifingOrYES;
                        return(Json(jm, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        identityVerification.BuildCompanyId = model.DoorId;
                        identityVerification.Phone          = model.Phone;
                        //如果该小区不需要审批身份
                        if (place.IsValidate == 1)
                        {
                            identityVerification.IsVerified = ConstantParam.IsVerified_YES;
                        }
                        else
                        {
                            identityVerification.IsVerified = ConstantParam.IsVerified_DEFAULT;
                        }
                        //更新验证申请
                        identityVerificationBll.Update(identityVerification);
                    }
                }
                else
                {
                    identityVerification = new R_PropertyIdentityVerification()
                    {
                        AppUserId      = owner.Id,
                        Phone          = model.Phone,
                        BuildCompanyId = model.DoorId,
                    };
                    //如果该小区不需要审批身份
                    if (place.IsValidate == 1)
                    {
                        identityVerification.IsVerified = ConstantParam.IsVerified_YES;
                    }
                    else
                    {
                        identityVerification.IsVerified = ConstantParam.IsVerified_DEFAULT;
                    }
                    //保存验证申请
                    identityVerificationBll.Save(identityVerification);
                }
            }
            return(Json(jm, JsonRequestBehavior.AllowGet));
        }