public JsonResult Apply(BrandApplyModel brand)
        {
            var shopId = CurrentSellerManager.ShopId;
            ShopBrandApplysInfo model = new ShopBrandApplysInfo();

            model.BrandId   = brand.BrandId;
            model.ApplyMode = brand.BrandMode == 1 ? (int)Himall.Model.ShopBrandApplysInfo.BrandApplyMode.Exist : (int)Himall.Model.ShopBrandApplysInfo.BrandApplyMode.New;
            if (brand.BrandMode == 1)
            {
                var m = _iBrandService.GetBrand(brand.BrandId);
                if (m == null)
                {
                    throw new Himall.Core.HimallException("品牌不存在,请刷新页面重新申请");
                }
                model.BrandName   = m.Name;
                model.Logo        = m.Logo;
                model.Description = m.Description;
            }
            else
            {
                if (brand.BrandDesc.Length > 200)
                {
                    return(Json(new Result()
                    {
                        success = false, msg = "简介过长!"
                    }));
                }
                model.BrandId     = null;
                model.BrandName   = brand.BrandName.Trim();
                model.Logo        = brand.BrandLogo;
                model.Description = brand.BrandDesc;
            }

            model.Remark          = brand.Remark;
            model.AuthCertificate = brand.BrandAuthPic;
            model.ShopId          = shopId;
            model.ApplyTime       = DateTime.Now;

            bool flag = _iBrandService.IsExistApply(shopId, model.BrandName);

            if (flag == false)
            {
                _iBrandService.ApplyBrand(model);
                return(Json(new Result()
                {
                    success = true, msg = "申请成功!"
                }));
            }
            else
            {
                return(Json(new Result()
                {
                    success = false, msg = "您已经申请了该品牌!"
                }));
            }
        }
        public JsonResult Apply(BrandApplyModel brand)
        {
            var shopId = CurrentSellerManager.ShopId;
            var model  = new Entities.ShopBrandApplyInfo();

            model.BrandId   = brand.BrandId;
            model.ApplyMode = brand.BrandMode == 1 ? (int)Himall.Entities.ShopBrandApplyInfo.BrandApplyMode.Exist : (int)Himall.Entities.ShopBrandApplyInfo.BrandApplyMode.New;
            if (brand.BrandMode == 1)
            {
                var m = _iBrandService.GetBrand(brand.BrandId);
                if (m == null)
                {
                    throw new Himall.Core.HimallException("品牌不存在,请刷新页面重新申请");
                }
                model.BrandName   = m.Name;
                model.Logo        = m.Logo;
                model.Description = m.Description;
            }
            else
            {
                if (brand.BrandDesc.Length > 200)
                {
                    return(Json(new Result()
                    {
                        success = false, msg = "简介过长!"
                    }));
                }
                model.BrandId     = 0;
                model.BrandName   = brand.BrandName.Trim();
                model.Logo        = brand.BrandLogo;
                model.Description = brand.BrandDesc;
            }

            model.Remark          = brand.Remark;
            model.AuthCertificate = brand.BrandAuthPic;
            model.ShopId          = shopId;
            model.ApplyTime       = DateTime.Now;

            var oldapply = _iBrandService.GetExistApply(shopId, model.BrandName);

            if (oldapply == null)
            {
                _iBrandService.ApplyBrand(model);
                return(Json(new Result()
                {
                    success = true, msg = "申请成功!"
                }));
            }
            else
            {
                var oBrand = BrandApplication.GetBrand(oldapply.BrandId);
                if (oBrand != null && oBrand.IsDeleted)
                {
                    model.Id = oldapply.Id;
                }
                else
                {
                    if (oldapply.AuditStatus == (int)Entities.ShopBrandApplyInfo.BrandAuditStatus.UnAudit)
                    {
                        return(Json(new Result()
                        {
                            success = false, msg = "该品牌正在审核中!"
                        }));
                    }
                    else if (oldapply.AuditStatus == (int)Entities.ShopBrandApplyInfo.BrandAuditStatus.Audited)
                    {
                        return(Json(new Result()
                        {
                            success = false, msg = "该品牌已存在,请选择申请已有品牌!"
                        }));
                    }
                }
                model.AuditStatus = 0;
                _iBrandService.UpdateApplyBrand(model);
                return(Json(new Result()
                {
                    success = true, msg = "申请成功!"
                }));
            }
        }
Exemple #3
0
 /// <summary>
 /// 申请一个品牌
 /// </summary>
 /// <param name="model"></param>
 public static void ApplyBrand(DTO.ShopBrandApply model)
 {
     _brandService.ApplyBrand(model.Map <Model.ShopBrandApplysInfo>());
 }