/// <summary> /// 保存设置 /// </summary> /// <returns></returns> public JsonResult <Result <bool> > PostSaveShopConfig(PostSaveShopConfigModel model) { CheckUserLogin(); DistributorInfo currentDistributor = DistributionApplication.GetDistributor(CurrentUser.Id); if (string.IsNullOrWhiteSpace(currentDistributor.ShopLogo) && string.IsNullOrWhiteSpace(model.logoUrl)) { return(Json(ErrorResult <bool>("请上传小店logo!"))); } if (string.IsNullOrWhiteSpace(model.shopName)) { return(Json(ErrorResult <bool>("请填写小店名称!"))); } if (model.shopName.Length > 10) { return(Json(ErrorResult <bool>("小店名称不能超过10个字符!"))); } string shoplogo = currentDistributor.ShopLogo; if (!string.IsNullOrWhiteSpace(model.logoUrl)) { //shoplogo = DownloadWxImage(model.logoWXmediaId); shoplogo = model.logoUrl; } if (string.IsNullOrWhiteSpace(shoplogo)) { return(Json(ErrorResult <bool>("请上传小店logo!"))); } var oldname = Path.GetFileName(shoplogo); string ImageDir = string.Empty; if (!string.IsNullOrWhiteSpace(shoplogo)) { //转移图片 string relativeDir = DISTRIBUTOR_LOGO_PATH; Random ra = new Random(); string fileName = DateTime.Now.ToString("yyyyMMddHHmmssffffff") + ra.Next(4) + ".jpg"; if (shoplogo.Replace("\\", "/").Contains("/temp/"))//只有在临时目录中的图片才需要复制 { var de = shoplogo.Substring(shoplogo.LastIndexOf("/temp/")); Core.HimallIO.CopyFile(de, relativeDir + fileName, true); shoplogo = relativeDir + fileName; } //目标地址 else if (shoplogo.Contains("/Storage")) { shoplogo = shoplogo.Substring(shoplogo.LastIndexOf("/Storage")); } } DistributionApplication.UpdateDistributorConfig(currentDistributor.MemberId, shoplogo, model.shopName, model.isShowLogo); return(JsonResult(true)); }
/// <summary> /// 提交申请销售员 /// </summary> /// <returns></returns> public JsonResult <Result <bool> > PostApplyDistributor(PostSaveShopConfigModel model) { CheckUserLogin(); var sitesettings = SiteSettingApplication.SiteSettings; DistributorInfo currentDistributor = DistributionApplication.GetDistributor(CurrentUser.Id); if (sitesettings.DistributorApplyNeedQuota > 0) { var _u = MemberApplication.GetMember(CurrentUser.Id); if (_u.NetAmount < sitesettings.DistributorApplyNeedQuota) { return(Json(ErrorResult <bool>("需要累计消费金额达到" + sitesettings.DistributorApplyNeedQuota + "元才可申请哦!"))); } } if (currentDistributor == null) { currentDistributor = new DistributorInfo { MemberId = CurrentUser.Id }; } if (string.IsNullOrWhiteSpace(currentDistributor.ShopLogo)) { currentDistributor.ShopLogo = CurrentUser.Photo; } if (string.IsNullOrWhiteSpace(model.logoUrl)) { if (currentDistributor == null || string.IsNullOrWhiteSpace(currentDistributor.ShopLogo)) { return(Json(ErrorResult <bool>("请上传小店logo!"))); } } if (string.IsNullOrWhiteSpace(model.shopName)) { return(Json(ErrorResult <bool>("请填写小店名称!"))); } if (model.shopName.Length > 10) { return(Json(ErrorResult <bool>("小店名称不能超过10个字符!"))); } if (currentDistributor != null) { if (currentDistributor.DistributionStatus == (int)DistributorStatus.NotAvailable) { return(Json(ErrorResult <bool>("您己经被清退,不可以申请!"))); } if (currentDistributor.DistributionStatus == (int)DistributorStatus.Audited) { return(Json(ErrorResult <bool>("您己经是销售员,不可以重复申请!"))); } if (currentDistributor.DistributionStatus == (int)DistributorStatus.UnAudit) { return(Json(ErrorResult <bool>("您己经提交销售员申请,请耐心等待!"))); } } string shoplogo = currentDistributor != null ? currentDistributor.ShopLogo : ""; if (!string.IsNullOrWhiteSpace(model.logoUrl)) { //shoplogo = DownloadWxImage(model.logoWXmediaId); shoplogo = model.logoUrl; } if (string.IsNullOrWhiteSpace(shoplogo)) { return(Json(ErrorResult <bool>("请上传小店logo!"))); } var oldname = Path.GetFileName(shoplogo); string ImageDir = string.Empty; if (!string.IsNullOrWhiteSpace(shoplogo)) { //转移图片 string relativeDir = DISTRIBUTOR_LOGO_PATH; Random ra = new Random(); string fileName = DateTime.Now.ToString("yyyyMMddHHmmssffffff") + ra.Next(4) + ".jpg"; if (shoplogo.Replace("\\", "/").Contains("/temp/"))//只有在临时目录中的图片才需要复制 { var de = shoplogo.Substring(shoplogo.LastIndexOf("/temp/")); Core.HimallIO.CopyFile(de, relativeDir + fileName, true); shoplogo = relativeDir + fileName; } //目标地址 else if (shoplogo.Contains("/Storage")) { shoplogo = shoplogo.Substring(shoplogo.LastIndexOf("/Storage")); } } var d = DistributionApplication.ApplyDistributor(CurrentUser.Id, shoplogo, model.shopName); if (d == null) { return(Json(ErrorResult <bool>("申请失败,系统异常!"))); } if (d.DistributionStatus == (int)DistributorStatus.Audited) { return(JsonResult(true, "申请销售员成功!")); } return(JsonResult(true, "提交销售员申请成功!")); }