public bool CheckShopGrade(long shopId, long newId) { IShopService shopService = ServiceHelper.Create <IShopService>(); int shopAllProducts = ServiceHelper.Create <IProductService>().GetShopAllProducts(shopId); long shopSpaceUsage = shopService.GetShopSpaceUsage(shopId); long num = (shopSpaceUsage > 0 ? shopSpaceUsage : 0); if (newId <= 0) { return(true); } ShopGradeInfo shopGrade = ServiceHelper.Create <IShopService>().GetShopGrade(newId); if (shopGrade == null) { return(true); } int productLimit = shopGrade.ProductLimit; if (productLimit >= shopAllProducts && shopGrade.ImageLimit >= num) { return(true); } return(false); }
public ShopGradeModel(ShopGradeInfo m) : this() { Id = m.Id; Name = m.Name; ImageLimit = m.ImageLimit; ProductLimit = m.ProductLimit; ChargeStandard = m.ChargeStandard; }
public void UpdateShopGrade(ShopGradeInfo shopGrade) { ShopGradeInfo name = context.ShopGradeInfo.FindById <ShopGradeInfo>(shopGrade.Id); name.Name = shopGrade.Name; name.ProductLimit = shopGrade.ProductLimit; name.ImageLimit = shopGrade.ImageLimit; name.ChargeStandard = shopGrade.ChargeStandard; context.SaveChanges(); }
public ShopModel(ShopInfo m) : this() { Id = m.Id; Account = m.ShopAccount; Name = m.ShopName; ShopGradeInfo shopGrade = ServiceHelper.Create <IShopService>().GetShopGrade(m.GradeId); ShopGrade = (shopGrade == null ? "" : shopGrade.Name); Status = m.ShopStatus.ToDescription(); EndDate = (m.EndDate.HasValue ? m.EndDate.Value.ToString("yyyy-MM-dd") : ""); IsSelf = m.IsSelf; CompanyName = m.CompanyName; NewCompanyRegionId = m.CompanyRegionId; CompanyRegion = ServiceHelper.Create <IRegionService>().GetRegionFullName(m.CompanyRegionId, " "); CompanyAddress = m.CompanyAddress; CompanyPhone = m.CompanyPhone; CompanyEmployeeCount = m.CompanyEmployeeCount; CompanyRegisteredCapital = m.CompanyRegisteredCapital; ContactsName = m.ContactsName; ContactsPhone = m.ContactsPhone; ContactsEmail = m.ContactsEmail; BusinessLicenseCert = m.BusinessLicenseCert; ProductCert = m.ProductCert; OtherCert = m.OtherCert; BusinessLicenceNumber = m.BusinessLicenceNumber; BusinessLicenceNumberPhoto = m.BusinessLicenceNumberPhoto; BusinessLicenceRegionId = ServiceHelper.Create <IRegionService>().GetRegionFullName(m.BusinessLicenceRegionId, " "); BusinessLicenceStart = m.BusinessLicenceStart; BusinessLicenceEnd = m.BusinessLicenceEnd; BusinessSphere = m.BusinessSphere; OrganizationCode = m.OrganizationCode; OrganizationCodePhoto = m.OrganizationCodePhoto; GeneralTaxpayerPhot = m.GeneralTaxpayerPhot; BankAccountName = m.BankAccountName; BankAccountNumber = m.BankAccountNumber; BankName = m.BankName; BankCode = m.BankCode; BankRegionId = ServiceHelper.Create <IRegionService>().GetRegionFullName(m.BankRegionId, " "); NewBankRegionId = m.BankRegionId; BankPhoto = m.BankPhoto; TaxRegistrationCertificate = m.TaxRegistrationCertificate; TaxpayerId = m.TaxpayerId; TaxRegistrationCertificatePhoto = m.TaxRegistrationCertificatePhoto; PayPhoto = m.PayPhoto; PayRemark = m.PayRemark; legalPerson = m.legalPerson; CompanyFoundingDate = new DateTime?((m.CompanyFoundingDate.HasValue ? m.CompanyFoundingDate.Value : DateTime.Now)); }
public ActionResult Console() { ChemCloud.Service.Order.Business.OrderBO _orderBO = new ChemCloud.Service.Order.Business.OrderBO(); ViewBag.sortpayid = _orderBO.GenerateOrderNumber(); HomeModel homeModel = new HomeModel() { SellerConsoleModel = ServiceHelper.Create <IShopService>().GetSellerConsoleModel(base.CurrentSellerManager.ShopId, base.CurrentUser.Id), Articles = ServiceHelper.Create <IArticleService>().GetTopNArticle <ArticleInfo>(6, 4, null, false) }; ShopInfo shop = ServiceHelper.Create <IShopService>().GetShop(base.CurrentSellerManager.ShopId, false); if (shop != null) { ViewBag.UserType = base.CurrentUser.UserType; ViewBag.SortType = shop.SortType; ViewBag.Logo = base.CurrentSiteSetting.MemberLogo; homeModel.ShopId = shop.Id; homeModel.ShopLogo = shop.Logo; homeModel.ShopName = shop.ShopName; homeModel.ShopEndDate = (shop.EndDate.HasValue ? shop.EndDate.Value.ToString("yyyy-MM-dd") : string.Empty); ShopGradeInfo shopGradeInfo = ( from c in ServiceHelper.Create <IShopService>().GetShopGrades() where c.Id == shop.GradeId select c).FirstOrDefault(); homeModel.ShopGradeName = (shopGradeInfo != null ? shopGradeInfo.Name : string.Empty); IQueryable <StatisticOrderCommentsInfo> shopStatisticOrderComments = ServiceHelper.Create <IShopService>().GetShopStatisticOrderComments(base.CurrentSellerManager.ShopId); StatisticOrderCommentsInfo statisticOrderCommentsInfo = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 13 select c).FirstOrDefault(); //质量与描述满意度 StatisticOrderCommentsInfo statisticOrderCommentsInfo1 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 14 select c).FirstOrDefault();//发货速度满意度 StatisticOrderCommentsInfo statisticOrderCommentsInfo2 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 15 select c).FirstOrDefault();//服务态度满意度 StatisticOrderCommentsInfo statisticOrderCommentsInfo3 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 16 //包装质量满意度 select c).FirstOrDefault(); string str = "5"; //如果无评价数据,默认为5分 homeModel.ProductAndDescription = (statisticOrderCommentsInfo != null ? string.Format("{0:F}", statisticOrderCommentsInfo.CommentValue) : str); homeModel.SellerServiceAttitude = (statisticOrderCommentsInfo1 != null ? string.Format("{0:F}", statisticOrderCommentsInfo1.CommentValue) : str); homeModel.SellerDeliverySpeed = (statisticOrderCommentsInfo2 != null ? string.Format("{0:F}", statisticOrderCommentsInfo2.CommentValue) : str); homeModel.PackingQuality = (statisticOrderCommentsInfo3 != null ? string.Format("{0:F}", statisticOrderCommentsInfo3.CommentValue) : str); homeModel.ProductsNumberIng = homeModel.SellerConsoleModel.ProductLimit.ToString(); homeModel.ProductsNumber = homeModel.SellerConsoleModel.ProductsCount.ToString(); homeModel.UseSpace = homeModel.SellerConsoleModel.ImageLimit.ToString(); homeModel.UseSpaceing = homeModel.SellerConsoleModel.ProductImages.ToString(); homeModel.OrderProductConsultation = homeModel.SellerConsoleModel.ProductConsultations.ToString(); homeModel.OrderCounts = homeModel.SellerConsoleModel.OrderCounts.ToString(); homeModel.OrderWaitPay = homeModel.SellerConsoleModel.WaitPayTrades.ToString(); homeModel.OrderWaitDelivery = homeModel.SellerConsoleModel.WaitDeliveryTrades.ToString(); ICommentService commentService = ServiceHelper.Create <ICommentService>(); CommentQuery commentQuery = new CommentQuery() { PageNo = 1, PageSize = 2147483647, IsReply = new bool?(false), ShopID = base.CurrentSellerManager.ShopId }; int total = commentService.GetComments(commentQuery).Total; homeModel.OrderReplyComments = total.ToString(); homeModel.OrderHandlingComplaints = homeModel.SellerConsoleModel.Complaints.ToString(); homeModel.OrderWithRefund = homeModel.SellerConsoleModel.RefundTrades.ToString(); homeModel.OrderWithRefundAndRGoods = homeModel.SellerConsoleModel.RefundAndRGoodsTrades.ToString(); homeModel.ProductsEvaluation = homeModel.SellerConsoleModel.ProductComments.ToString(); int num = ( from c in ServiceHelper.Create <IBrandService>().GetShopBrandApplys(base.CurrentSellerManager.ShopId) where c.AuditStatus == 1 select c).Count(); homeModel.ProductsBrands = num.ToString(); homeModel.ProductsOnSale = homeModel.SellerConsoleModel.OnSaleProducts.ToString(); IProductService productService = ServiceHelper.Create <IProductService>(); ProductQuery productQuery = new ProductQuery() { PageNo = 1, PageSize = 2147483647, ShopId = new long?(base.CurrentSellerManager.ShopId), SaleStatus = new ProductInfo.ProductSaleStatus?(ProductInfo.ProductSaleStatus.InDraft) }; int total1 = productService.GetProducts(productQuery).Total; homeModel.ProductsInDraft = total1.ToString(); homeModel.ProductsWaitForAuditing = homeModel.SellerConsoleModel.WaitForAuditingProducts.ToString(); homeModel.ProductsAuditFailed = homeModel.SellerConsoleModel.AuditFailureProducts.ToString(); homeModel.ProductsInfractionSaleOff = homeModel.SellerConsoleModel.InfractionSaleOffProducts.ToString(); homeModel.ProductsInStock = homeModel.SellerConsoleModel.InStockProducts.ToString(); DateTime date = DateTime.Now.AddDays(-1).Date; DateTime dateTime = date.AddDays(1).AddMilliseconds(-1); ShopInfo.ShopVistis shopVistiInfo = ServiceHelper.Create <IShopService>().GetShopVistiInfo(date, dateTime, base.CurrentSellerManager.ShopId); List <EchartsData> echartsDatas = new List <EchartsData>(); if (shopVistiInfo == null) { string str1 = (new decimal(0)).ToString(); ViewBag.VistiCounts = str1; ViewBag.OrderCounts = str1; ViewBag.SaleAmounts = str1; } else { ViewBag.VistiCounts = shopVistiInfo.VistiCounts; ViewBag.OrderCounts = shopVistiInfo.OrderCounts; ViewBag.SaleAmounts = shopVistiInfo.SaleAmounts; } } return(View(homeModel)); }
public void AddShopGrade(ShopGradeInfo shopGrade) { context.ShopGradeInfo.Add(shopGrade); context.SaveChanges(); }
public SellerConsoleModel GetSellerConsoleModel(long shopId) { ShopInfo shopInfo = ( from a in context.ShopInfo where a.Id == shopId select a).FirstOrDefault(); ShopGradeInfo shopGradeInfo = context.ShopGradeInfo.FindById <ShopGradeInfo>(shopInfo.GradeId); IQueryable <OrderInfo> orderInfo = from a in context.OrderInfo where a.ShopId == shopId select a; IQueryable <ProductInfo> productInfo = from a in context.ProductInfo where a.ShopId == shopId && (int)a.SaleStatus != 4 select a; IQueryable <ShopBrandApplysInfo> shopBrandApplysInfo = from a in context.ShopBrandApplysInfo where a.ShopId == shopId select a; IQueryable <OrderRefundInfo> orderRefundInfo = from a in context.OrderRefundInfo where a.ShopId == shopId && (int)a.RefundMode != 3 && ((int)a.SellerAuditStatus == 1 || (int)a.SellerAuditStatus == 3) select a; IQueryable <OrderRefundInfo> orderRefundInfos = from a in context.OrderRefundInfo where a.ShopId == shopId && (int)a.RefundMode == 3 && ((int)a.SellerAuditStatus == 1 || (int)a.SellerAuditStatus == 3) select a; IQueryable <ProductCommentInfo> productCommentInfo = from a in context.ProductCommentInfo where a.ShopId == shopId select a; IQueryable <ProductConsultationInfo> productConsultationInfo = from a in context.ProductConsultationInfo where a.ShopId == shopId select a; IQueryable <OrderComplaintInfo> orderComplaintInfo = from a in context.OrderComplaintInfo where a.ShopId == shopId && (int)a.Status == 1 select a; SellerConsoleModel sellerConsoleModel = new SellerConsoleModel() { ShopName = shopInfo.ShopName, ShopGrade = shopGradeInfo.Name, ShopEndDate = shopInfo.EndDate.Value, ShopFreight = shopInfo.Freight, ProductsCount = productInfo.Count(), OnSaleProducts = ( from a in productInfo where (int)a.SaleStatus == 1 && (int)a.AuditStatus == 2 select a).Count(), AuditFailureProducts = ( from a in productInfo where (int)a.AuditStatus == 3 select a).Count(), InfractionSaleOffProducts = ( from a in productInfo where (int)a.AuditStatus == 4 select a).Count(), InStockProducts = ( from a in productInfo where (int)a.SaleStatus == 2 select a).Count(), WaitForAuditingProducts = ( from a in productInfo where (int)a.AuditStatus == 1 && (int)a.SaleStatus == 1 select a).Count(), BrandApply = ( from a in shopBrandApplysInfo where a.AuditStatus == 0 select a).Count(), WaitPayTrades = ( from a in orderInfo where (int)a.OrderStatus == 1 select a).Count(), ProductComments = productCommentInfo.Count(), ProductConsultations = productConsultationInfo.Count(), ProductLimit = shopGradeInfo.ProductLimit }; long shopSpaceUsage2 = GetShopSpaceUsage2(shopId); sellerConsoleModel.ProductsCount = productInfo.Count(); sellerConsoleModel.ImageLimit = shopGradeInfo.ImageLimit; sellerConsoleModel.ProductImages = shopSpaceUsage2; sellerConsoleModel.WaitDeliveryTrades = ( from a in orderInfo where (int)a.OrderStatus == 2 select a).Count(); #region 账户动态 if ((from a in orderInfo where (int)a.AccountType == 1 select a).Count() > 0) { sellerConsoleModel.NoAccount = ( from a in orderInfo where (int)a.AccountType == 1 select a).Sum(a => a.ProductTotalAmount + a.Freight + a.RefundCommisAmount - a.RefundTotalAmount - a.CommisTotalAmount - a.DiscountAmount); } else { sellerConsoleModel.NoAccount = 0; } #endregion sellerConsoleModel.RefundTrades = orderRefundInfo.Count(); sellerConsoleModel.RefundAndRGoodsTrades = orderRefundInfos.Count(); sellerConsoleModel.Complaints = orderComplaintInfo.Count(); sellerConsoleModel.OrderCounts = orderInfo.Count(); return(sellerConsoleModel); }
public ShopModel(ShopInfo m) : this() { Id = m.Id; Account = m.ShopAccount; Name = m.ShopName; ShopGradeInfo shopGrade = ServiceHelper.Create <IShopService>().GetShopGrade(m.GradeId); ShopGrade = (shopGrade == null ? "" : shopGrade.Name); Status = m.ShopStatus.ToDescription(); EndDate = (m.EndDate.HasValue ? m.EndDate.Value.ToString("yyyy-MM-dd") : ""); IsSelf = m.IsSelf; CompanyName = m.CompanyName; NewCompanyRegionId = m.CompanyRegionId; CompanyRegion = ServiceHelper.Create <IRegionService>().GetRegionFullName(m.CompanyRegionId, " "); CompanyAddress = m.CompanyAddress; CompanyPhone = m.CompanyPhone; CompanyEmployeeCount = m.CompanyEmployeeCount; CompanyRegisteredCapital = m.CompanyRegisteredCapital; ContactsName = m.ContactsName; ContactsPhone = m.ContactsPhone; ContactsEmail = m.ContactsEmail; BusinessLicenseCert = m.BusinessLicenseCert; ProductCert = m.ProductCert; OtherCert = m.OtherCert; BusinessLicenceNumber = m.BusinessLicenceNumber; BusinessLicenceNumberPhoto = m.BusinessLicenceNumberPhoto; BusinessLicenceRegionId = ServiceHelper.Create <IRegionService>().GetRegionFullName(m.BusinessLicenceRegionId, " "); BusinessLicenceStart = m.BusinessLicenceStart; BusinessLicenceEnd = m.BusinessLicenceEnd; BusinessSphere = m.BusinessSphere; OrganizationCode = m.OrganizationCode; OrganizationCodePhoto = m.OrganizationCodePhoto; GeneralTaxpayerPhot = m.GeneralTaxpayerPhot; BankAccountName = m.BankAccountName; BankAccountNumber = m.BankAccountNumber; BankName = m.BankName; BankCode = m.BankCode; BankRegionId = ServiceHelper.Create <IRegionService>().GetRegionFullName(m.BankRegionId, " "); NewBankRegionId = m.BankRegionId; BankPhoto = m.BankPhoto; TaxRegistrationCertificate = m.TaxRegistrationCertificate; TaxpayerId = m.TaxpayerId; TaxRegistrationCertificatePhoto = m.TaxRegistrationCertificatePhoto; PayPhoto = m.PayPhoto; PayRemark = m.PayRemark; legalPerson = m.legalPerson; RefuseReason = m.RefuseReason; ECompanyName = m.ECompanyName; ECompanyAddress = m.ECompanyAddress; EContactsName = m.EContactsName; CompanyType = m.CompanyType; ZipCode = m.ZipCode; Fax = m.Fax; URL = m.URL; ChemicalsBusinessLicense = m.ChemicalsBusinessLicense; Logo = m.Logo; GMPPhoto = m.GMPPhoto; FDAPhoto = m.FDAPhoto; ISOPhoto = m.ISOPhoto; ChemNumber = m.ChemNumber; CompanyFoundingDate = new DateTime?((m.CompanyFoundingDate.HasValue ? m.CompanyFoundingDate.Value : DateTime.Now)); BeneficiaryBankName = m.BeneficiaryBankName; SWiftBic = m.SWiftBic; BeneficiaryName = m.BeneficiaryName; BeneficiaryAccountNum = m.BeneficiaryAccountNum; CompanysAddress = m.CompanysAddress; BeneficiaryBankBranchAddress = m.BeneficiaryBankBranchAddress; CertificatePhoto = m.CertificatePhoto; AbaRoutingNumber = m.AbaRoutingNumber; CreateDate = m.CreateDate; }
public JsonResult ImportProductsFromExcel(long shopCategoyId, string filename) { /*供应商产品批量导入*/ if (!string.IsNullOrWhiteSpace(filename)) { string serverFilepath = Server.MapPath("/temp/"); string fullFilePath = serverFilepath + filename; FileInfo file = new FileInfo(fullFilePath); /*计数统计*/ int ErrorCount = 0, SuccessCount = 0; if (file != null && file.Length > 0) { //_importManager.ImportProductsFromXlsx(file.InputStream); // ok, we can run the real code of the sample now using (var xlPackage = new ExcelPackage(file)) { // get the first worksheet in the workbook var worksheet = xlPackage.Workbook.Worksheets.FirstOrDefault(); if (worksheet == null) { return(Json(new { success = false, message = 6 }));//文件为空 } //the columns var properties = new[] { "CategoryId", "ProductName", "ProductCode", "ShortDescription", "Pictures", "MarketPrice", "MinSalePrice", "FreightTemplateId", "Weight", "Volume", "Quantity", "MeasureUnit", "Description", "Meta_Title", "Meta_Description", "Meta_Keywords" }; int iRow = 3;//从Excel第三行开始读取 while (true) { int errorTemp = 0; bool allColumnsAreEmpty = true; for (var i = 1; i <= properties.Length; i++) { if (worksheet.Cells[iRow, i].Value != null && !String.IsNullOrEmpty(worksheet.Cells[iRow, i].Value.ToString())) { allColumnsAreEmpty = false; break; } } if (allColumnsAreEmpty) { break; } long categoryId = Convert.ToInt64(worksheet.Cells[iRow, GetColumnIndex(properties, "CategoryId")].Value); string productName = ConvertColumnToString(worksheet.Cells[iRow, GetColumnIndex(properties, "ProductName")].Value); string productCode = ConvertColumnToString(worksheet.Cells[iRow, GetColumnIndex(properties, "ProductCode")].Value); string shortDescription = ConvertColumnToString(worksheet.Cells[iRow, GetColumnIndex(properties, "ShortDescription")].Value); string pictures = ConvertColumnToString(worksheet.Cells[iRow, GetColumnIndex(properties, "pictures")].Value); decimal marketPrice = Convert.ToDecimal(worksheet.Cells[iRow, GetColumnIndex(properties, "MarketPrice")].Value); decimal minSalePrice = Convert.ToDecimal(worksheet.Cells[iRow, GetColumnIndex(properties, "MinSalePrice")].Value); long freightTemplateId = Convert.ToInt64(worksheet.Cells[iRow, GetColumnIndex(properties, "FreightTemplateId")].Value); decimal weight = Convert.ToDecimal(worksheet.Cells[iRow, GetColumnIndex(properties, "Weight")].Value); decimal volume = Convert.ToDecimal(worksheet.Cells[iRow, GetColumnIndex(properties, "Volume")].Value); int quantity = Convert.ToInt32(worksheet.Cells[iRow, GetColumnIndex(properties, "Quantity")].Value); string measureUnit = ConvertColumnToString(worksheet.Cells[iRow, GetColumnIndex(properties, "MeasureUnit")].Value); string description = ConvertColumnToString(worksheet.Cells[iRow, GetColumnIndex(properties, "Description")].Value); string meta_Title = ConvertColumnToString(worksheet.Cells[iRow, GetColumnIndex(properties, "Meta_Title")].Value); string meta_Description = ConvertColumnToString(worksheet.Cells[iRow, GetColumnIndex(properties, "Meta_Description")].Value); string meta_Keywords = ConvertColumnToString(worksheet.Cells[iRow, GetColumnIndex(properties, "Meta_Keywords")].Value); ProductDetailModel productDetailModel = new ProductDetailModel(); productDetailModel.adWord = shortDescription; productDetailModel.saleStatus = 1; productDetailModel.brandId = 0; productDetailModel.productId = 0; productDetailModel.categoryId = categoryId; if (!string.IsNullOrWhiteSpace(description)) { productDetailModel.des = "<p>" + description + "</p>"; } productDetailModel.FreightTemplateId = freightTemplateId; productDetailModel.goodsName = productName; productDetailModel.mallPrce = minSalePrice.ToString(); productDetailModel.marketPrice = marketPrice.ToString(); productDetailModel.MeasureUnit = measureUnit; productDetailModel.productCode = productCode; productDetailModel.seoDes = meta_Description; productDetailModel.seoKey = meta_Keywords; productDetailModel.seoTitle = meta_Title; productDetailModel.stock = quantity; productDetailModel.Weight = weight; productDetailModel.Volume = volume; productDetailModel.styleTemplateId = new List <long> { 0, 0 }; productDetailModel.goodsCategory = new List <long> { shopCategoyId }; if (pictures != null && pictures.Length > 4) { string[] picArray = pictures.Split(new char[] { ',' }); productDetailModel.pic = new List <string>(picArray); } else { productDetailModel.pic = new List <string>(); } List <AttrSelectData> attrSelectDataList = new List <AttrSelectData> { new AttrSelectData { attrId = 10, valueId = "" }, new AttrSelectData { attrId = 11, valueId = "" } }; productDetailModel.attrSelectData = attrSelectDataList; productDetailModel.specifications = new List <Specifications>(); productDetailModel.specificationsValue = new List <SpecificationsValue>(); IProductService productService = ServiceHelper.Create <IProductService>(); ICategoryService categoryService = ServiceHelper.Create <ICategoryService>(); long num = productDetailModel.productId; ProductInfo productInfo = ProductDetailModel.GetProductInfo(productDetailModel, num); ShopInfo shop = ServiceHelper.Create <IShopService>().GetShop(base.CurrentSellerManager.ShopId, false); int shopAllProducts = productService.GetShopAllProducts(base.CurrentSellerManager.ShopId); ProductInfo.ProductEditStatus editStatus = productService.GetEditStatus(num, productInfo); foreach (string str in productDetailModel.pic) { if (str.IndexOf("Storage") >= 0) { continue; } editStatus = (editStatus <= ProductInfo.ProductEditStatus.EditedAndPending ? ProductInfo.ProductEditStatus.EditedAndPending : ProductInfo.ProductEditStatus.CompelPendingHasEdited); } productInfo.EditStatus = (short)editStatus; if (productDetailModel.productId != 0) { productInfo.ShopId = shopId; productInfo.ImagePath = string.Format("/Storage/Shop/{0}/Products/{1}", shopId, productInfo.Id); productInfo.CategoryPath = categoryService.GetCategory(productInfo.CategoryId).Path; productService.UpdateProduct(productInfo); } else { productInfo.ShopId = base.CurrentSellerManager.ShopId; if (productDetailModel.specificationsValue.Count > 0) { productInfo.MinSalePrice = decimal.Parse(productDetailModel.specificationsValue.Min <SpecificationsValue, string>((SpecificationsValue p) => p.mallPrice)); } productInfo.ImagePath = string.Format("/Storage/Shop/{0}/Products/{1}", shopId, productInfo.Id); productInfo.CategoryPath = categoryService.GetCategory(productInfo.CategoryId).Path; if (ServiceHelper.Create <IShopService>().GetShopSpaceUsage(base.CurrentSellerManager.ShopId) == -1) { return(Json(new { successful = false, msg = "数据提交失败。 原因:店铺存储图片空间不足,不能发布商品!" })); } ShopGradeInfo shopGrade = ServiceHelper.Create <IShopService>().GetShopGrade(shop.GradeId); if (shopGrade != null && shopAllProducts >= shopGrade.ProductLimit) { return(Json(new { successful = false, msg = string.Concat("数据提交失败。 原因:此店铺等级最多只能发布", shopGrade.ProductLimit, "件商品") })); } productService.AddProduct(productInfo); string str1 = string.Format("/Storage/Shop/{0}/Products/{1}", shopId, productInfo.Id); productService.UpdateProductImagePath(productInfo.Id, str1); } ProcessSKU(productDetailModel, productInfo); productService.AddSKU(productInfo); productService.GetSellerSpecifications(shopId, categoryService.GetCategory(productDetailModel.categoryId).TypeId); CategoryInfo category = categoryService.GetCategory(productDetailModel.categoryId); List <SellerSpecificationValueInfo> sellerSpecificationValueInfos = new List <SellerSpecificationValueInfo>(); foreach (Specifications specification in productDetailModel.specifications) { if (!specification.selected) { continue; } SellerSpecificationValueInfo sellerSpecificationValueInfo = new SellerSpecificationValueInfo() { ShopId = shopId, ValueId = specification.Id, Value = specification.newValue, TypeId = category.TypeId }; sellerSpecificationValueInfos.Add(sellerSpecificationValueInfo); } productService.SaveSellerSpecifications(sellerSpecificationValueInfos); int num1 = 1; #region 生成图片 foreach (string str2 in productDetailModel.pic) { //string str3 = Server.MapPath(string.Concat(@"/temp/", str2));//图片位置 string str3 = Server.MapPath(string.Format("/Storage/Original/Shop/{0}/{1}", shopId, str2)); string str4 = Server.MapPath(string.Format("/Storage/Shop/{0}/Products/{1}", shopId, productInfo.Id)); if (string.IsNullOrWhiteSpace(str2)) { string str5 = string.Format("{0}\\{1}.png", str4, num1); if (System.IO.File.Exists(str5)) { System.IO.File.Delete(str5); } IEnumerable <int> dictionary = from t in EnumHelper.ToDictionary <ProductInfo.ImageSize>() select t.Key; foreach (int num2 in dictionary) { string str6 = string.Format("{0}/{1}_{2}.png", str4, num1, num2); if (!System.IO.File.Exists(str6)) { continue; } System.IO.File.Delete(str6); } num1++; } else { try { if (!Directory.Exists(str4)) { Directory.CreateDirectory(str4); } string str7 = string.Format("{0}\\{1}.png", str4, num1);//生成图片的位置和名字 if (System.IO.File.Exists(str3)) { if (str3 != str7) { using (Image image = Image.FromFile(str3))//从temp位置把图片eg:/temp/201607201045475671970.jpg 生成到/Storage/Shop/shopid/Products/productId/ 文件夹下 { image.Save(str7, ImageFormat.Png); IEnumerable <int> nums = from t in EnumHelper.ToDictionary <ProductInfo.ImageSize>() select t.Key; foreach (int num3 in nums)//根据ProductInfo.ImageSize的枚举值生成五张小图 { string str8 = string.Format("{0}/{1}_{2}.png", str4, num1, num3); ImageHelper.CreateThumbnail(str7, str8, num3, num3); } } num1++; } else { num1++; } } } catch (FileNotFoundException fileNotFoundException1) { FileNotFoundException fileNotFoundException = fileNotFoundException1; num1++; ErrorCount++; errorTemp++; Log.Error("发布商品时候,没有找到文件", fileNotFoundException); } catch (ExternalException externalException1) { ExternalException externalException = externalException1; num1++; ErrorCount++; errorTemp++; Log.Error("发布商品时候,ExternalException异常", externalException); } catch (Exception exception1) { Exception exception = exception1; num1++; ErrorCount++; errorTemp++; Log.Error("发布商品时候,Exception异常", exception); } } } #endregion //next product iRow++; if (errorTemp == 0) { SuccessCount++; } } } return(Json(new { success = true, message = 1, ErrorCount = ErrorCount, SuccessCount = SuccessCount })); } else { return(Json(new { success = false, message = 6 }));//"文件为空" } } else { return(Json(new { success = false, message = 6 }));//"没有找到文件!" } }
/// <summary> /// /// </summary> /// <returns></returns> public ActionResult ShopStore(long shopId) { ShopStore homeModel = new ShopStore(); ShopInfo shop = ServiceHelper.Create <IShopService>().GetShop(shopId, false); if (shop != null) { ViewBag.SortType = shop.SortType; ViewBag.Logo = base.CurrentSiteSetting.MemberLogo; homeModel.ShopId = shop.Id; homeModel.ShopLogo = shop.Logo; homeModel.CompanyAddress = shop.CompanyAddress; // +"/" + shop.ECompanyAddress + "</span>"; homeModel.ShopName = shop.ShopName; // +"/" + shop.ECompanyName; homeModel.ContactsEmail = shop.ContactsEmail; homeModel.ContactsPhone = shop.ContactsPhone; homeModel.CompanyFoundingDate = shop.CompanyFoundingDate.HasValue ? shop.CompanyFoundingDate.Value.ToString("yyyy-MM-dd") : string.Empty; homeModel.URL = shop.URL; homeModel.CompanyFoundingDate = shop.CreateDate.ToShortDateString(); homeModel.GMPPhoto = shop.GMPPhoto; homeModel.ISOPhoto = shop.ISOPhoto; homeModel.FDAPhoto = shop.FDAPhoto; homeModel.Fax = shop.Fax; homeModel.OrganizationCodePhoto = shop.OrganizationCodePhoto; homeModel.TaxRegistrationCertificatePhoto = shop.TaxRegistrationCertificatePhoto; homeModel.BusinessLicenceNumberPhoto = shop.BusinessLicenceNumberPhoto; homeModel.ShopAccount = shop.ShopAccount; homeModel.ContactsName = shop.ContactsName;// +"/" + shop.EContactsName; homeModel.BankName = shop.BankName; homeModel.BankAccountNumber = shop.BankAccountNumber; // homeModel.Price= homeModel.ShopEndDate = (shop.EndDate.HasValue ? shop.EndDate.Value.ToString("yyyy-MM-dd") : string.Empty); ShopGradeInfo shopGradeInfo = ( from c in ServiceHelper.Create <IShopService>().GetShopGrades() where c.Id == shop.GradeId select c).FirstOrDefault(); homeModel.ShopGradeName = (shopGradeInfo != null ? shopGradeInfo.Name : string.Empty); IQueryable <StatisticOrderCommentsInfo> shopStatisticOrderComments = ServiceHelper.Create <IShopService>().GetShopStatisticOrderComments(shopId); StatisticOrderCommentsInfo statisticOrderCommentsInfo = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 13 select c).FirstOrDefault(); //质量与描述满意度 StatisticOrderCommentsInfo statisticOrderCommentsInfo1 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 14 select c).FirstOrDefault();//发货速度满意度 StatisticOrderCommentsInfo statisticOrderCommentsInfo2 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 15 select c).FirstOrDefault();//服务态度满意度 StatisticOrderCommentsInfo statisticOrderCommentsInfo3 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 16 //包装质量满意度 select c).FirstOrDefault(); string str = "5"; //如果无评价数据,默认为5分 homeModel.ProductAndDescription = (statisticOrderCommentsInfo != null ? string.Format("{0:F}", statisticOrderCommentsInfo.CommentValue) : str); homeModel.SellerServiceAttitude = (statisticOrderCommentsInfo1 != null ? string.Format("{0:F}", statisticOrderCommentsInfo1.CommentValue) : str); homeModel.SellerDeliverySpeed = (statisticOrderCommentsInfo2 != null ? string.Format("{0:F}", statisticOrderCommentsInfo2.CommentValue) : str); homeModel.PackingQuality = (statisticOrderCommentsInfo3 != null ? string.Format("{0:F}", statisticOrderCommentsInfo3.CommentValue) : str); DateTime date = DateTime.Now.AddDays(-1).Date; DateTime dateTime = date.AddDays(1).AddMilliseconds(-1); ShopInfo.ShopVistis shopVistiInfo = ServiceHelper.Create <IShopService>().GetShopVistiInfo(date, dateTime, shopId); List <EchartsData> echartsDatas = new List <EchartsData>(); if (shopVistiInfo == null) { string str1 = (new decimal(0)).ToString(); ViewBag.VistiCounts = str1; ViewBag.OrderCounts = str1; ViewBag.SaleAmounts = str1; } else { ViewBag.VistiCounts = shopVistiInfo.VistiCounts; ViewBag.OrderCounts = shopVistiInfo.OrderCounts; ViewBag.SaleAmounts = shopVistiInfo.SaleAmounts; } } return(View(homeModel)); }