Esempio n. 1
0
        public ActionResult ApplyForDistributor(Model.PromoterModel model)
        {
            var promoter = _iDistributionService.GetPromoterByUserId(curUserId);


            if (promoter != null && (promoter.Status == PromoterInfo.PromoterStatus.NotAvailable || promoter.Status == PromoterInfo.PromoterStatus.Audited))
            {
                return(Json(new Result()
                {
                    success = false, msg = "你已经是使用员了!"
                }));
            }
            var setting = _iDistributionService.GetRecruitmentSetting();

            if (setting == null)
            {
                return(Json(new Result()
                {
                    success = false, msg = "平台未设置招募审核!"
                }));
            }
            if (setting.MustRealName && string.IsNullOrWhiteSpace(model.RealName))
            {
                return(Json(new Result()
                {
                    success = false, msg = "真实姓名必须填写!"
                }));
            }

            if (setting.MustMobile && string.IsNullOrEmpty(model.Mobile))
            {
                var mobile = _iMessageService.GetDestination(curUserId, SMSPLUGIN, Himall.Model.MemberContactsInfo.UserTypes.General);
                if (string.IsNullOrEmpty(mobile))
                {
                    return(Json(new Result()
                    {
                        success = false, msg = "手机必须必须填写!"
                    }));
                }
                model.Mobile = mobile;
            }
            if (setting.MustAddress)
            {
                if (model.RegionId == 0)
                {
                    return(Json(new Result()
                    {
                        success = false, msg = "地址必须填写!"
                    }));
                }
                model.TopRegionId = Himall.Application.RegionApplication.GetRegion(model.RegionId, CommonModel.Region.RegionLevel.Province).Id;
            }
            model.UserId = curUserId;
            _iDistributionService.ApplyForDistributor(model);
            var result = new Result()
            {
                success = true, msg = "提交成功!", status = 1
            };

            promoter = _iDistributionService.GetPromoterByUserId(curUserId);
            if (promoter != null)
            {
                if (promoter.Status == PromoterInfo.PromoterStatus.UnAudit)
                {
                    result = new Result()
                    {
                        success = true, msg = "提交成功!", status = 2
                    };
                }
            }
            return(Json(result));
        }