public JsonResult EditApply(BrandApplyModel brand)
        {
            var shopId = CurrentSellerManager.ShopId;

            Entities.ShopBrandApplyInfo model = _iBrandService.GetBrandApply(brand.Id);
            if (model == null)
            {
                throw new Himall.Core.HimallException("该品牌审核不通过,请重新编辑");
            }
            if (model.ApplyMode == 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;
                model.BrandId     = brand.BrandId;
            }
            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)
            {
                model.AuditStatus = 0;
                _iBrandService.UpdateApplyBrand(model);
            }
            else
            {
                Entities.BrandInfo orderband = null;
                if (oldapply.BrandId > 0)
                {
                    orderband = _iBrandService.GetBrand(oldapply.BrandId);
                }
                if (orderband != null && orderband.IsDeleted)
                {
                    model.Id = oldapply.Id;
                }
                else
                {
                    if (oldapply.AuditStatus == (int)ShopBrandApplyInfo.BrandAuditStatus.Audited || oldapply.AuditStatus == (int)ShopBrandApplyInfo.BrandAuditStatus.UnAudit)
                    {
                        throw new Himall.Core.HimallException("该品牌申请已存在,请选择申请其他品牌");
                    }
                    model.AuditStatus = 0;
                    _iBrandService.UpdateApplyBrand(model);
                }
            }
            return(Json(new Result()
            {
                success = true, 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 = "申请成功!"
                }));
            }
        }