public CallResult AddProduct(string SPUName, string SPUDesc, List <string> SKUSpecs, List <string> SKUUnits, List <decimal> SKUDealerPrices, List <string> SKUImageUrles, List <decimal> SKUPvs) { var productSPUId = Guid.NewGuid(); var productSKUs = new List <ProductSKU>(); for (int i = 0; i < SKUSpecs.Count; i++) { var productSKU = new ProductSKU().CreateProductSKU( SPUName, productSPUId, SKUImageUrles[i], SKUDealerPrices[i], SKUPvs[i], SKUUnits[i], SKUSpecs[i]); productSKUs.Add(productSKU); } var productSPU = new ProductSPU().CreateProductSPU(productSPUId, SPUName, SPUDesc, productSKUs); try { using (baseRepository) { productRepository.Add(productSPU); baseRepository.Commit(); } return(new CallResult(200, "产品创建成功")); } catch (Exception ex) { return(new CallResult(500, $"产品创建异常:{ex.Message}/r/n{ex.StackTrace}")); } }
public OperationDetails UpdateCart(string userId, List <ProductDTO> products) { foreach (var cartItem in products) { if (cartItem.Quantity == 0) { return(new OperationDetails(false, "لايمكن للكمية أن تكون معدومة", "")); } ProductSKU sku = unitOfWork.ProductSKURepository.Get(s => s.SKUId == cartItem.SKUId).FirstOrDefault(); if (sku == null) { return(new OperationDetails(false, "حدث خطأ أثناء تعديل السلة", "skuId")); } if (sku.Quentity < cartItem.Quantity) { return(new OperationDetails(false, "الكميات المطلوبة غير متوفرة", "")); } var realItem = unitOfWork.ShoppingCartRepository.Get(c => c.UserId == userId && c.SKUId == cartItem.SKUId && c.ProductId == cartItem.Id).FirstOrDefault(); if (realItem == null) { return(new OperationDetails(false, "حدث خطأ أثناء تعديل السلة", "skuId")); } realItem.Quantity = cartItem.Quantity; } unitOfWork.Save(); return(new OperationDetails(true, "تم تعدل السلة بنجاح", "")); }
public OperationDetails AddToCart(long skuId, long productId, String userId, int quantity) { ProductSKU sku = unitOfWork.ProductSKURepository.Get(s => s.SKUId == skuId).FirstOrDefault(); if (sku == null) { return(new OperationDetails(false, "المنتج غير موجود", "SkuId")); } if (sku.Quentity < quantity || quantity == 0) { return(new OperationDetails(false, "لايوجد هذه الكمية", "Qty")); } // sku.Quentity -= quantity; ShoppingCart userCart = unitOfWork.ShoppingCartRepository.Get(s => s.SKUId == skuId && s.UserId == userId).FirstOrDefault(); if (userCart == null) { unitOfWork.ShoppingCartRepository.Insert(new ShoppingCart() { ProductId = productId, SKUId = skuId, UserId = userId, Quantity = quantity }); } else { userCart.Quantity += quantity; } unitOfWork.Save(); return(new OperationDetails(true, "تم اضافة المنتج إلى السلة", "")); }
public string GetSKUList(string callType, string xmlMessage) { string result = ""; string logID = Guid.NewGuid().ToString(); try { FileLogger.WriteLog(logID + "|Start:" + xmlMessage, 1, "", callType); if (Helper.CheckAuthCode(callType, xmlMessage)) { ProductSKU sku = new ProductSKU(); result = sku.GetList(xmlMessage); } } catch (Exception err) { result = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<" + callType + ">" + "<Result>False</Result>" + "<Description>" + err.Message + "</Description></" + callType + ">"; } FileLogger.WriteLog(logID + "|End:" + result, 1, "", callType); return(result); }
public ResultEntity <bool> AddProduct(AddProductSPUDTO addproductspudto) { var productspuid = Guid.NewGuid(); var productskus = new List <ProductSKU>(); for (int i = 0; i < addproductspudto.SKUSpecs.Count; i++) { var productsku = new ProductSKU().CreateProductSKU(addproductspudto.SPUName, productspuid, addproductspudto.SKUImages[i], addproductspudto.SKUDealerPrices[i], addproductspudto.SKUPvs[i], addproductspudto.SKUUnits[i], addproductspudto.SKUSpecs[i]); productskus.Add(productsku); } var productspu = new ProductSPU().CreateProductSPU(productspuid, addproductspudto.SPUName, addproductspudto.SPUDesc, productskus); try { using (irepositorycontext) { iproductrepository.CreateProduct(productspu); irepositorycontext.Commit(); } return(GetResultEntity(true)); } catch (Exception error) { throw error; } }
public ActionResult DeleteConfirmed(int id) { ProductSKU productSKU = db.ProductSKU.Find(id); db.ProductSKU.Remove(productSKU); db.SaveChanges(); return(RedirectToAction("Index")); }
public ResultEntity <bool> CreateOrder(dynamic orderdto) { var orderid = Guid.NewGuid(); Orders order = new Orders(); var productskus = new List <ProductSKU>(); for (int i = 0; i < orderdto.ProductSPUNames.Count; i++) { var productsku = new ProductSKU(); productsku.ProductSPUName = orderdto.ProductSPUNames[i]; productsku.DealerPrice = orderdto.ProductDealerPrices[i]; productsku.PV = orderdto.ProductPVS[i]; productsku.Id = orderdto.ProductSKUIds[i]; productsku.Spec = orderdto.ProductSepcs[i]; productskus.Add(productsku); } var contact = new Contact(); contact.ContactName = orderdto.ContactName; contact.ContactTel = orderdto.ContactTel; contact.Province = orderdto.Privence; contact.City = orderdto.City; contact.Zero = orderdto.Zero; contact.Street = orderdto.Street; var orders = order.CreateOrders(orderid, orderdto.DealerId, productskus, orderdto.Counts, contact); try { //using (var tansaction = new TransactionScope()) //{ using (irepositories[1]) { idealerrepository.SubParentEleMoney(orderdto.DealerId, order.OrderTotalPrice.TotalPrice); idealerrepository.AddDealerPV(orderdto.DealerId, order.OrderTotalPV.TotalPV); irepositories[1].Commit(); } using (irepositories[0]) { iorderrepository.CreateOrder(orders); irepositories[0].Commit(); } return(GetResultEntity(true)); //tansaction.Complete(); //} } catch (Exception error) { throw error; } }
public ActionResult Edit([Bind(Include = "ID,SKU,ProductID,StoreID")] ProductSKU productSKU) { if (ModelState.IsValid) { db.Entry(productSKU).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ProductID = new SelectList(db.Products, "ID", "Name", productSKU.ProductID); ViewBag.StoreID = new SelectList(db.Stores, "ID", "Name", productSKU.StoreID); return(View(productSKU)); }
public void should_Success_Instantiate_ProductSKU() { ProductSKU productSKU = new ProductSKU() { Id = 1, Code = "Code", Name = "Name" }; Assert.Equal(1, productSKU.Id); Assert.Equal("Code", productSKU.Code); Assert.Equal("Name", productSKU.Name); }
// GET: ProductSKU/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProductSKU productSKU = db.ProductSKU.Find(id); if (productSKU == null) { return(HttpNotFound()); } return(View(productSKU)); }
public OperationDetails Remove(long skuId, long productId, string userId) { ShoppingCart cart = unitOfWork.ShoppingCartRepository.Get(s => s.SKUId == skuId && s.ProductId == productId && s.UserId == userId).FirstOrDefault(); if (cart == null) { return(new OperationDetails(false, "حدث خطأ أثناء الحذف", "")); } ProductSKU product = cart.ProductSKU; product.Quentity += (int)cart.Quantity; unitOfWork.ShoppingCartRepository.Delete(cart); unitOfWork.Save(); return(new OperationDetails(true, "تم الحذف بنجاح", "")); }
// GET: ProductSKU/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } ProductSKU productSKU = db.ProductSKU.Find(id); if (productSKU == null) { return(HttpNotFound()); } ViewBag.ProductID = new SelectList(db.Products, "ID", "Name", productSKU.ProductID); ViewBag.StoreID = new SelectList(db.Stores, "ID", "Name", productSKU.StoreID); return(View(productSKU)); }
/* * public int Insert(Product info, List<CharactorValue> colors, List<CharactorValue> sizes) * { * try * { * string commandText = string.Format("insert into Product(name, comment, parent) values('{0}', '{1}', 19)", info.Name, info.Comment); * DbHelperAccess.executeNonQuery(commandText); * int productID = DbHelperAccess.executeLastID("ID", "Product"); * foreach (CharactorValue color in colors) * { * commandText = string.Format("insert into ProductAttribute(productID, charactorID, charactorValueID) values({0},{1},{2})", productID, color.CharactorId, color.Id); * DbHelperAccess.executeNonQuery(commandText); * } * foreach (CharactorValue size in sizes) * { * commandText = string.Format("insert into ProductAttribute(productID, charactorID, charactorValueID) values({0},{1},{2})", productID, size.CharactorId, size.Id); * DbHelperAccess.executeNonQuery(commandText); * } * foreach (CharactorValue color in colors) * { * foreach (CharactorValue size in sizes) * { * string composeID = string.Format("{0}:{1};{2}:{3}", color.CharactorId, color.Id, size.CharactorId, size.Id); * commandText = string.Format("insert into ProductSKU(productID, composeID, price) values({0},'{1}',{2})", * productID, composeID, info.Price); * DbHelperAccess.executeNonQuery(commandText); * } * } * return productID; * } * catch (Exception ex) * { * throw ex; * } * * } * * public void Update(Product info, List<int> elementIDs) { * string commandText = string.Format("update Product set name='{0}', price='{1}', comment='{2}' where ID={3}", * info.Name, info.Price, info.Comment, info.ID); * * DbHelperAccess.executeNonQuery(commandText); * * commandText = string.Format("delete from ProductElement where productID={0}", info.ID); * DbHelperAccess.executeNonQuery(commandText); * * foreach (int elementID in elementIDs) * { * commandText = string.Format("insert into ProductElement(productID, elementID) values('{0}', '{1}')", info.ID, elementID); * DbHelperAccess.executeNonQuery(commandText); * } * } * * public DataTable FindList(Category parent) * { * string commandText = "select * from Product"; * if (parent != null) * commandText = string.Format("select * from Product, ProductCategory where Product.parent=ProductCategory.ID and ProductCategory.lft>={0} and ProductCategory.rgt<={1}", parent.Left, parent.Right); * return DbHelperAccess.executeQuery(commandText); * } * * */ public ProductSKU FindByComposeID(int productID, int colorID, int sizeID) { string composeID = string.Format("1:{0};2:{1}", colorID, sizeID); string commandText = string.Format("select * from ProductSKU where productID={0} and composeID='{1}'", productID, composeID); DataRow dr = DbHelperAccess.executeQueryGetOneRow(commandText); ProductSKU product = new ProductSKU(); if (dr != null) { product.ID = (int)dr["ID"]; product.Color = CharactorValueDao.getInstance().findById(colorID);// dr["name"] as string; product.Size = CharactorValueDao.getInstance().findById(sizeID); return(product); } return(null); }
protected void populateProducts(ProductInfo_V02 product, bool showAllInventory, Dictionary <string, SKU_V01> AllSKUS) { if (product != null) { ProductSKU.DataSource = from s in product.SKUs from a in AllSKUS.Keys where s.SKU == a && (showAllInventory || (showAllInventory == false && s.ProductAvailability != ProductAvailabilityType.Unavailable)) select AllSKUS[a]; ProductSKU.DataBind(); } }
public ProductSKU FindByID(int ID) { string commandText = string.Format("select * from ProductSKU where ID={0}", ID); DataRow dr = DbHelperAccess.executeQueryGetOneRow(commandText); ProductSKU product = new ProductSKU(); if (dr != null) { product.ID = (int)dr["ID"]; string composeIDs = dr["composeID"] as string; string [] composeIDstrs = composeIDs.Split(new char [] { ':', ';' }); int colorID = int.Parse(composeIDstrs[1]); int sizeID = int.Parse(composeIDstrs[3]); product.Color = CharactorValueDao.getInstance().findById(colorID);// dr["name"] as string; product.Size = CharactorValueDao.getInstance().findById(sizeID); return(product); } return(null); }
private bool IsSKuInDiscount(long skuId) { //bool result = false; ProductSKU sku = _uitOfWork.ProductSKURepository.Get(c => c.SKUId == skuId).FirstOrDefault(); if (sku.ProductSkuDiscounts != null && sku.ProductSkuDiscounts.Count > 0) { List <ProductDiscount> discounts = sku.ProductSkuDiscounts.ToList(); foreach (var discount in discounts) { if (discount.Discount.DateEnd > DateTime.Now) { return(true); } } } return(false); }
public Object PalletizeFulOrder(string trackingNumber, int palletId) { try { Guid TrackingNumber; if (!Guid.TryParse(trackingNumber, out TrackingNumber)) { return(new { status = false, message = _iconfiguration["INVALID_TRACKINGFORMAT"] }); } /*get FulOrder information based on given tracking number and palletId*/ Shipment shipmentObj = new Shipment(); shipmentObj = (from s in context.Shipment where s.TrackingNumber == TrackingNumber select s).FirstOrDefault(); if (shipmentObj == null) { return(new { status = false, message = _iconfiguration["TRACKINGNO_NOTFOUND"] }); } Pallet PalletObj = (from p in context.Pallet where p.PalletId == palletId select p).FirstOrDefault(); if (PalletObj == null) { return new { status = false, message = _iconfiguration["PALLETID_NOTFOUND"] } } ; int?CarrierServiceTypeId = (from cs in context.CarrierService where cs.CarrierServiceId == shipmentObj.CarrierServiceId && cs.CarrierId == shipmentObj.CarrierId select cs.CarrierServiceTypeId).FirstOrDefault(); if (PalletObj.CarrierId != shipmentObj.CarrierId || PalletObj.CarrierServiceTypeId != CarrierServiceTypeId) { return new { status = false, message = _iconfiguration["PALLET_SHIPMENT_CARRIER_NOT_MATCH"] } } ; if (shipmentObj.CarrierId == PalletObj.CarrierId && CarrierServiceTypeId != null && CarrierServiceTypeId == PalletObj.CarrierServiceTypeId) { FulOrder FulOrderObj = new FulOrder(); FulOrderObj = (from fo in context.FulOrder join fos in context.FulOrderStatus on fo.FulOrderStatusId equals fos.FulOrderStatusId where fo.FulOrderId == shipmentObj.FulOrderId && fos.Name == _iconfiguration["PACKAGED"] select fo).FirstOrDefault(); if (FulOrderObj == null) { return new { status = false, message = _iconfiguration["FULORDER_NOT_IN_PACKAGE"] } } ; FulOrderStatus FulOrderStatusObj = (from fos in context.FulOrderStatus where fos.Name.ToUpper() == _iconfiguration["PALLETIZED"] select fos).FirstOrDefault(); FulOrderObj.FulOrderStatusId = FulOrderStatusObj.FulOrderStatusId; FulOrderObj.PalletId = palletId; context.FulOrder.Update(FulOrderObj); context.SaveChanges(); Product ProductObj = new Product(); ProductObj = (from fi in context.FulItem join p in context.Product on fi.ProductId equals p.ProductId select p).FirstOrDefault(); ProductSKU productSKUObj = (from ps in context.ProductSKU where ps.ProductId == ProductObj.ProductId select ps).FirstOrDefault(); UpdateTrackingDTO response = new UpdateTrackingDTO(); response.fulOrderId = FulOrderObj.FulOrderId; response.fulOrderStatus = FulOrderStatusObj.Name; response.productName = ProductObj.Name; response.sku = productSKUObj.SKU; response.trackingNumber = shipmentObj.TrackingNumber.ToString(); return(new { status = true, data = response, message = string.Format(_iconfiguration["PALLETIZED_SUCCESS"], FulOrderObj.FulOrderId.ToString()) }); } return(new { status = false, message = _iconfiguration["ERROR_NOFULORDERPACKAGEFOUND"] }); } catch (Exception Ex) { LogServiceObj.LogException(Ex); MailServiceObj.SendMail(Ex.Message ?? "", (Ex.InnerException != null) ? Ex.InnerException.Message : "", Ex.StackTrace ?? ""); return(new { status = false, message = _iconfiguration["ERROR_CREATEPALLET"] }); } }
public object CreatePackage(int fulOrderId) { try { UpdateTrackingDTO response = new UpdateTrackingDTO(); FulOrder FulOrderObj = (from fo in context.FulOrder join fos in context.FulOrderStatus on fo.FulOrderStatusId equals fos.FulOrderStatusId where fo.FulOrderId == fulOrderId && fos.Name.ToUpper() == _iconfiguration["LABELCREATED"] select fo).FirstOrDefault(); if (FulOrderObj == null) { return new { status = false, message = _iconfiguration["FULORDER_NOT_LABELED"] } } ; FulOrderStatus FulOrderStatus = (from fos in context.FulOrderStatus where fos.Name.ToUpper() == _iconfiguration["PACKAGED"] select fos).FirstOrDefault(); Product productObj = (from fi in context.FulItem join p in context.Product on fi.ProductId equals p.ProductId where fi.FulOrderId == fulOrderId select p).FirstOrDefault(); ProductSKU productSKU = (from p in context.Product join ps in context.ProductSKU on p.ProductId equals ps.ProductId join pt in context.ProductSKUType on ps.SKUTypeId equals pt.ProductSKUTypeId where p.ProductId == productObj.ProductId && pt.Name.ToUpper() == _iconfiguration["SKU"] select ps).FirstOrDefault(); Shipment shipmentObj = (from s in context.Shipment where s.FulOrderId == fulOrderId select s).FirstOrDefault(); FulOrderObj.FulOrderStatusId = FulOrderStatus.FulOrderStatusId; context.FulOrder.Update(FulOrderObj); context.SaveChanges(); if (productObj != null && productSKU != null && shipmentObj != null) { response.fulOrderId = fulOrderId; response.fulOrderStatus = FulOrderStatus.Name; response.productName = productObj.Name; response.sku = productSKU.SKU; response.trackingNumber = shipmentObj.TrackingNumber.ToString(); } else if (productObj == null) { return(new { status = false, message = _iconfiguration["PRODUCTNOTFOUND"] }); } else if (productSKU == null) { return(new { status = false, message = _iconfiguration["PRODUCTSKUNOTFOUND"] }); } else if (shipmentObj == null) { return(new { status = false, message = _iconfiguration["SHIPMENTNOTFOUND"] }); } return(new { status = true, message = string.Format(_iconfiguration["PACKAGE_SUCCESS"], fulOrderId.ToString()), data = response }); } catch (Exception Ex) { LogServiceObj.LogException(Ex); MailServiceObj.SendMail(Ex.Message ?? "", (Ex.InnerException != null) ? Ex.InnerException.Message : "", Ex.StackTrace ?? ""); return(new { status = false, message = _iconfiguration["ERROR_PACKAGE"] }); } }
public ActionResult Detail(string id) { long valueId; ProductInfo[] array; int i; double num; string str = ""; ProductDetailModelForWeb productDetailModelForWeb = new ProductDetailModelForWeb() { HotAttentionProducts = new List <HotProductInfo>(), HotSaleProducts = new List <HotProductInfo>(), Product = new ProductInfo(), Shop = new ShopInfoModel(), ShopCategory = new List <CategoryJsonModel>(), Color = new CollectionSKU(), Size = new CollectionSKU(), Version = new CollectionSKU() }; ProductDetailModelForWeb maxSaleCount = productDetailModelForWeb; LimitTimeMarketInfo limitTimeMarketItem = null; ShopInfo shop = null; long productId = 0; long num1 = 0; long.TryParse(id, out num1); if (num1 == 0) { return(RedirectToAction("Error404", "Error", new { area = "Web" })); } limitTimeMarketItem = ServiceHelper.Create <ILimitTimeBuyService>().GetLimitTimeMarketItem(num1); if (limitTimeMarketItem == null || limitTimeMarketItem.AuditStatus != LimitTimeMarketInfo.LimitTimeMarketAuditStatus.Ongoing) { limitTimeMarketItem = (limitTimeMarketItem == null ? ServiceHelper.Create <ILimitTimeBuyService>().GetLimitTimeMarketItemByProductId(num1) : limitTimeMarketItem); if (limitTimeMarketItem == null || limitTimeMarketItem.AuditStatus != LimitTimeMarketInfo.LimitTimeMarketAuditStatus.Ongoing) { return(RedirectToAction("Error404", "Error", new { area = "Web" })); } } maxSaleCount.MaxSaleCount = limitTimeMarketItem.MaxSaleCount; maxSaleCount.Title = limitTimeMarketItem.Title; shop = ServiceHelper.Create <IShopService>().GetShop(limitTimeMarketItem.ShopId, false); if (limitTimeMarketItem == null || limitTimeMarketItem.Id == 0) { return(RedirectToAction("Error404", "Error", new { area = "Web" })); } ProductInfo product = ServiceHelper.Create <IProductService>().GetProduct(limitTimeMarketItem.ProductId); productId = limitTimeMarketItem.ProductId; product.MarketPrice = limitTimeMarketItem.Price; product.SaleCounts = limitTimeMarketItem.SaleCount; maxSaleCount.Product = product; maxSaleCount.ProductDescription = product.ProductDescriptionInfo.Description; if (product.ProductDescriptionInfo.DescriptionPrefixId != 0) { ProductDescriptionTemplateInfo template = ServiceHelper.Create <IProductDescriptionTemplateService>().GetTemplate(product.ProductDescriptionInfo.DescriptionPrefixId, product.ShopId); maxSaleCount.DescriptionPrefix = (template == null ? "" : template.Content); } if (product.ProductDescriptionInfo.DescriptiondSuffixId != 0) { ProductDescriptionTemplateInfo productDescriptionTemplateInfo = ServiceHelper.Create <IProductDescriptionTemplateService>().GetTemplate(product.ProductDescriptionInfo.DescriptiondSuffixId, product.ShopId); maxSaleCount.DescriptiondSuffix = (productDescriptionTemplateInfo == null ? "" : productDescriptionTemplateInfo.Content); } IQueryable <ShopCategoryInfo> shopCategory = ServiceHelper.Create <IShopCategoryService>().GetShopCategory(product.ShopId); List <ShopCategoryInfo> list = shopCategory.ToList(); foreach (ShopCategoryInfo shopCategoryInfo in from s in list where s.ParentCategoryId == 0 select s) { CategoryJsonModel categoryJsonModel = new CategoryJsonModel() { Name = shopCategoryInfo.Name }; valueId = shopCategoryInfo.Id; categoryJsonModel.Id = valueId.ToString(); categoryJsonModel.SubCategory = new List <SecondLevelCategory>(); CategoryJsonModel categoryJsonModel1 = categoryJsonModel; foreach (ShopCategoryInfo shopCategoryInfo1 in from s in list where s.ParentCategoryId == shopCategoryInfo.Id select s) { SecondLevelCategory secondLevelCategory = new SecondLevelCategory() { Name = shopCategoryInfo1.Name, Id = shopCategoryInfo1.Id.ToString() }; categoryJsonModel1.SubCategory.Add(secondLevelCategory); } maxSaleCount.ShopCategory.Add(categoryJsonModel1); } IQueryable <ProductInfo> hotSaleProduct = ServiceHelper.Create <IProductService>().GetHotSaleProduct(shop.Id, 5); if (hotSaleProduct != null) { array = hotSaleProduct.ToArray(); for (i = 0; i < array.Length; i++) { ProductInfo productInfo = array[i]; List <HotProductInfo> hotSaleProducts = maxSaleCount.HotSaleProducts; HotProductInfo hotProductInfo = new HotProductInfo() { ImgPath = productInfo.ImagePath, Name = productInfo.ProductName, Price = productInfo.MinSalePrice, Id = productInfo.Id, SaleCount = (int)productInfo.SaleCounts }; hotSaleProducts.Add(hotProductInfo); } } IQueryable <ProductInfo> hotConcernedProduct = ServiceHelper.Create <IProductService>().GetHotConcernedProduct(shop.Id, 5); if (hotConcernedProduct != null) { array = hotConcernedProduct.ToArray(); for (i = 0; i < array.Length; i++) { ProductInfo productInfo1 = array[i]; List <HotProductInfo> hotAttentionProducts = maxSaleCount.HotAttentionProducts; HotProductInfo hotProductInfo1 = new HotProductInfo() { ImgPath = productInfo1.ImagePath, Name = productInfo1.ProductName, Price = productInfo1.MinSalePrice, Id = productInfo1.Id, SaleCount = productInfo1.ConcernedCount }; hotAttentionProducts.Add(hotProductInfo1); } } if (product.SKUInfo != null && product.SKUInfo.Count() > 0) { long num2 = 0; long num3 = 0; long num4 = 0; foreach (SKUInfo sKUInfo in product.SKUInfo) { string[] strArrays = sKUInfo.Id.Split(new char[] { '\u005F' }); if (strArrays.Count() > 0) { long.TryParse(strArrays[1], out num2); if (num2 != 0) { if (!maxSaleCount.Color.Any((ProductSKU v) => v.Value.Equals(sKUInfo.Color))) { long num5 = ( from s in product.SKUInfo where s.Color.Equals(sKUInfo.Color) select s).Sum <SKUInfo>((SKUInfo s) => s.Stock); CollectionSKU color = maxSaleCount.Color; ProductSKU productSKU = new ProductSKU() { Name = "选择颜色", EnabledClass = (num5 != 0 ? "enabled" : "disabled"), SelectedClass = "", SKUId = num2, Value = sKUInfo.Color }; color.Add(productSKU); } } } if (strArrays.Count() > 1) { long.TryParse(strArrays[2], out num3); if (num3 != 0) { if (!maxSaleCount.Size.Any((ProductSKU v) => v.Value.Equals(sKUInfo.Size))) { long num6 = ( from s in product.SKUInfo where s.Size.Equals(sKUInfo.Size) select s).Sum <SKUInfo>((SKUInfo s1) => s1.Stock); CollectionSKU size = maxSaleCount.Size; ProductSKU productSKU1 = new ProductSKU() { Name = "选择尺码", EnabledClass = (num6 != 0 ? "enabled" : "disabled"), SelectedClass = "", SKUId = num3, Value = sKUInfo.Size }; size.Add(productSKU1); } } } if (strArrays.Count() <= 2) { continue; } long.TryParse(strArrays[3], out num4); if (num4 == 0) { continue; } if (maxSaleCount.Version.Any((ProductSKU v) => v.Value.Equals(sKUInfo.Version))) { continue; } long num7 = ( from s in product.SKUInfo where s.Version.Equals(sKUInfo.Version) select s).Sum <SKUInfo>((SKUInfo s) => s.Stock); CollectionSKU version = maxSaleCount.Version; ProductSKU productSKU2 = new ProductSKU() { Name = "选择版本", EnabledClass = (num7 != 0 ? "enabled" : "disabled"), SelectedClass = "", SKUId = num4, Value = sKUInfo.Version }; version.Add(productSKU2); } decimal num8 = new decimal(0); decimal num9 = new decimal(0); num8 = ( from s in product.SKUInfo where s.Stock >= 0 select s).Min <SKUInfo>((SKUInfo s) => s.SalePrice); num9 = ( from s in product.SKUInfo where s.Stock >= 0 select s).Max <SKUInfo>((SKUInfo s) => s.SalePrice); if (!(num8 == new decimal(0)) || !(num9 == new decimal(0))) { str = (num9 <= num8 ? string.Format("{0}", num8.ToString("f2")) : string.Format("{0}-{1}", num8.ToString("f2"), num9.ToString("f2"))); } else { str = product.MinSalePrice.ToString("f2"); } } base.ViewBag.Price = (string.IsNullOrWhiteSpace(str) ? product.MinSalePrice.ToString("f2") : str); List <TypeAttributesModel> typeAttributesModels = new List <TypeAttributesModel>(); List <ProductAttributeInfo> productAttributeInfos = ServiceHelper.Create <IProductService>().GetProductAttribute(product.Id).ToList(); foreach (ProductAttributeInfo productAttributeInfo in productAttributeInfos) { if (typeAttributesModels.Any((TypeAttributesModel p) => p.AttrId == productAttributeInfo.AttributeId)) { TypeAttributesModel typeAttributesModel = typeAttributesModels.FirstOrDefault((TypeAttributesModel p) => p.AttrId == productAttributeInfo.AttributeId); if (typeAttributesModel.AttrValues.Any((TypeAttrValue p) => p.Id == productAttributeInfo.ValueId.ToString())) { continue; } List <TypeAttrValue> attrValues = typeAttributesModel.AttrValues; TypeAttrValue typeAttrValue = new TypeAttrValue(); valueId = productAttributeInfo.ValueId; typeAttrValue.Id = valueId.ToString(); typeAttrValue.Name = productAttributeInfo.AttributesInfo.AttributeValueInfo.FirstOrDefault((AttributeValueInfo a) => a.Id == productAttributeInfo.ValueId).Value; attrValues.Add(typeAttrValue); } else { TypeAttributesModel typeAttributesModel1 = new TypeAttributesModel() { AttrId = productAttributeInfo.AttributeId, AttrValues = new List <TypeAttrValue>(), Name = productAttributeInfo.AttributesInfo.Name }; TypeAttributesModel typeAttributesModel2 = typeAttributesModel1; foreach (AttributeValueInfo attributeValueInfo in productAttributeInfo.AttributesInfo.AttributeValueInfo) { if (!productAttributeInfos.Any((ProductAttributeInfo p) => p.ValueId == attributeValueInfo.Id)) { continue; } List <TypeAttrValue> typeAttrValues = typeAttributesModel2.AttrValues; TypeAttrValue value = new TypeAttrValue(); valueId = attributeValueInfo.Id; value.Id = valueId.ToString(); value.Name = attributeValueInfo.Value; typeAttrValues.Add(value); } typeAttributesModels.Add(typeAttributesModel2); } } ViewBag.ProductAttrs = typeAttributesModels; ICommentService commentService = ServiceHelper.Create <ICommentService>(); CommentQuery commentQuery = new CommentQuery() { ProductID = product.Id, PageNo = 1, PageSize = 10000 }; PageModel <ProductCommentInfo> comments = commentService.GetComments(commentQuery); ViewBag.CommentCount = comments.Total; IQueryable <ProductConsultationInfo> consultations = ServiceHelper.Create <IConsultationService>().GetConsultations(productId); ViewBag.Consultations = consultations.Count(); if (base.CurrentUser == null) { BrowseHistrory.AddBrowsingProduct(product.Id, 0); } else { BrowseHistrory.AddBrowsingProduct(product.Id, base.CurrentUser.Id); } ServiceHelper.Create <IProductService>().LogProductVisti(productId); base.ViewBag.Logined = (base.CurrentUser != null ? 1 : 0); base.ViewBag.EnabledBuy = (product.AuditStatus != ProductInfo.ProductAuditStatus.Audited || !(limitTimeMarketItem.StartTime <= DateTime.Now) || !(limitTimeMarketItem.EndTime > DateTime.Now) ? false : product.SaleStatus == ProductInfo.ProductSaleStatus.OnSale); DateTime endTime = limitTimeMarketItem.EndTime; TimeSpan timeSpan = new TimeSpan(endTime.Ticks); endTime = DateTime.Now; TimeSpan timeSpan1 = timeSpan.Subtract(new TimeSpan(endTime.Ticks)); dynamic viewBag = base.ViewBag; num = (timeSpan1.TotalSeconds < 0 ? 0 : timeSpan1.TotalSeconds); viewBag.Second = num; return(View(maxSaleCount)); }
// creation of the produt && edit the produt public Object AddEditProduct(ProductDetailsDTO product) { try { bool isSuccess; string result = string.Empty; int? productId; bool isNew = product.ProductId != 0 ? false : true; var addProduct = isNew ? new Product { } : context.Product.Find(product.ProductId); addProduct.Name = product.Name == null ? null : product.Name; addProduct.Description = product.Description == null ? null : product.Description; addProduct.UPC = product.UPC == null ? null : product.UPC; addProduct.BoxId = product.BoxId == null ? null : product.BoxId; addProduct.StatusId = product.StatusId; addProduct.Length = product.Length; addProduct.Width = product.Width; addProduct.Height = product.Height; addProduct.Weight = product.Weight; addProduct.DimensionUnitId = product.DimensionUnitId; addProduct.WeightUnitId = product.WeightUnitId; addProduct.ShipsAlone_FLG = product.ShipsAlone_FLG; addProduct.ManufacturerId = product.ManufacturerId; addProduct.ConditionId = product.ConditionId; addProduct.CategoryId = product.CategoryId; addProduct.ColorId = product.ColorId; addProduct.Ref1 = product.Ref1; addProduct.Ref2 = product.Ref2; if (isNew) { //sku var addProductSku = new List <ProductSKU>(); foreach (var item in product.ProductSku) { ProductSKU addsku = new ProductSKU(); addsku.ProductId = item.ProductId; addsku.SKU = item.SKU == null ? null : item.SKU; addsku.StatusId = item.StatusId; addsku.Description = item.Description == null ? null : item.Description; addsku.SKUTypeId = item.SKUTypeId; addProductSku.Add(addsku); } addProduct.ProductSKUs = addProductSku; //inventory var addProductInven = new List <ProductInventory>(); foreach (var item in product.ProductInventory) { ProductInventory addInventory = new ProductInventory(); addInventory.ProductVersionId = item.ProductVersionId; addInventory.WarehouseId = item.WarehouseId; addInventory.Quantity = item.Quantity; addInventory.StatusId = item.StatusId; addProductInven.Add(addInventory); } //versions var addProductVersion = new List <ProductVersion>(); foreach (var item in product.ProductVersion) { ProductVersion addversion = new ProductVersion(); var matchedInventory = new List <ProductInventory>(); matchedInventory = addProductInven.FindAll(x => x.ProductVersionId == item.ProductVersionId); addversion.ProductInventories = matchedInventory; addversion.ProductId = item.ProductId; addversion.Description = item.Description; addversion.StatusId = item.StatusId; addProductVersion.Add(addversion); } addProduct.ProductVersions = addProductVersion; //tags var addProductTag = new List <ProductTag>(); if (product.ProductTag != null) { foreach (var item in product.ProductTag) { ProductTag addTag = new ProductTag(); addTag.ProductId = item.ProductId; addTag.TagId = item.TagId; addProductTag.Add(addTag); } addProduct.ProductTags = addProductTag; } context.Product.Add(addProduct); context.SaveChanges(); result = _iconfiguration["PRODUCT_ADDED_SUCCESSFUL"]; productId = addProduct.ProductId; isSuccess = true; } else { List <ProductSKU> existingProductSku = context.ProductSKU.Where(x => x.ProductId == product.ProductId).ToList(); List <ProductVersion> existingProductVersion = context.ProductVersion.Where(x => x.ProductId == product.ProductId).ToList(); List <ProductTag> existingProductTag = context.ProductTag.Where(x => x.ProductId == product.ProductId).ToList(); var existingInventory = new List <ProductInventory>(); foreach (var item in existingProductVersion) { var existingmatchedInventory = new List <ProductInventory>(); existingmatchedInventory = context.ProductInventory.Where(x => x.ProductVersionId == item.ProductVersionId).ToList(); if (existingmatchedInventory.Count > 0) { existingInventory.AddRange(existingmatchedInventory); } } //sku var newProductSku = new List <ProductSKU>(); foreach (var item in product.ProductSku) { ProductSKU addsku = new ProductSKU(); addsku.ProductId = item.ProductId; addsku.SKU = item.SKU == null ? null : item.SKU; addsku.StatusId = item.StatusId; addsku.Description = item.Description == null ? null : item.Description; addsku.SKUTypeId = item.SKUTypeId; newProductSku.Add(addsku); } //inventory var newProductInven = new List <ProductInventory>(); foreach (var item in product.ProductInventory) { ProductInventory addInventory = new ProductInventory(); addInventory.ProductVersionId = item.ProductVersionId; addInventory.WarehouseId = item.WarehouseId; addInventory.Quantity = item.Quantity; addInventory.StatusId = item.StatusId; newProductInven.Add(addInventory); } //versions var newProductVersion = new List <ProductVersion>(); foreach (var item in product.ProductVersion) { ProductVersion addversion = new ProductVersion(); var matchedInventory = new List <ProductInventory>(); matchedInventory = newProductInven.FindAll(x => x.ProductVersionId == item.ProductVersionId); addversion.ProductInventories = matchedInventory; addversion.ProductId = item.ProductId; addversion.Description = item.Description; addversion.StatusId = item.StatusId; newProductVersion.Add(addversion); } //tags var newProductTag = new List <ProductTag>(); if (product.ProductTag != null) { foreach (var item in product.ProductTag) { ProductTag addTag = new ProductTag(); addTag.ProductId = item.ProductId; addTag.TagId = item.TagId; newProductTag.Add(addTag); } } addProduct.ProductSKUs = new List <ProductSKU>(); addProduct.ProductVersions = new List <ProductVersion>(); addProduct.ProductTags = new List <ProductTag>(); if (existingProductSku.Count > 0) { context.ProductSKU.RemoveRange(existingProductSku); } if (existingInventory.Count > 0) { context.ProductInventory.RemoveRange(existingInventory); } if (existingProductVersion.Count > 0) { context.ProductVersion.RemoveRange(existingProductVersion); } if (existingProductTag.Count > 0) { context.ProductTag.RemoveRange(existingProductTag); } context.ProductSKU.AddRange(newProductSku); context.ProductVersion.AddRange(newProductVersion); if (newProductTag.Count > 0) { context.ProductTag.AddRange(newProductTag); } context.Product.Update(addProduct); context.SaveChanges(); context.Dispose(); result = _iconfiguration["PRODUCT_EDITED_SUCCESSFUL"]; productId = addProduct.ProductId; isSuccess = true; } return(new { status = isSuccess, productID = productId, message = result }); } catch (Exception ex) { if (ex.InnerException != null) { return(new { status = false, productID = product.ProductId, message = ex.InnerException.Message }); } else { return(new { status = false, productID = product.ProductId, message = ex.Message }); } throw ex; } }
public void Productsku(string id) { ProductSKU.EnterText(id); Console.WriteLine("Product sku Entered"); }
public ActionResult Detail(string id) { long valueId; ProductInfo[] array; int i; double num; decimal num1; decimal num2; string str = ""; ProductDetailModelForWeb productDetailModelForWeb = new ProductDetailModelForWeb() { HotAttentionProducts = new List <HotProductInfo>(), HotSaleProducts = new List <HotProductInfo>(), Product = new ProductInfo(), Shop = new ShopInfoModel(), ShopCategory = new List <CategoryJsonModel>(), Color = new CollectionSKU(), Size = new CollectionSKU(), Version = new CollectionSKU() }; ProductDetailModelForWeb maxSaleCount = productDetailModelForWeb; LimitTimeMarketInfo limitTimeMarketItem = null; ShopInfo shop = null; long productId = 0; long num3 = 0; long.TryParse(id, out num3); if (num3 == 0) { return(RedirectToAction("Error404", "Error", new { area = "Mobile" })); } limitTimeMarketItem = ServiceHelper.Create <ILimitTimeBuyService>().GetLimitTimeMarketItem(num3); if (limitTimeMarketItem == null || limitTimeMarketItem.AuditStatus != LimitTimeMarketInfo.LimitTimeMarketAuditStatus.Ongoing) { limitTimeMarketItem = (limitTimeMarketItem == null ? ServiceHelper.Create <ILimitTimeBuyService>().GetLimitTimeMarketItemByProductId(num3) : limitTimeMarketItem); if (limitTimeMarketItem == null || limitTimeMarketItem.AuditStatus != LimitTimeMarketInfo.LimitTimeMarketAuditStatus.Ongoing) { return(RedirectToAction("Error404", "Error", new { area = "Mobile" })); } } if (limitTimeMarketItem != null && (limitTimeMarketItem.AuditStatus != LimitTimeMarketInfo.LimitTimeMarketAuditStatus.Ongoing || limitTimeMarketItem.EndTime < DateTime.Now)) { return(RedirectToAction("Detail", "Product", new { id = limitTimeMarketItem.ProductId })); } maxSaleCount.MaxSaleCount = limitTimeMarketItem.MaxSaleCount; maxSaleCount.Title = limitTimeMarketItem.Title; shop = ServiceHelper.Create <IShopService>().GetShop(limitTimeMarketItem.ShopId, false); if (limitTimeMarketItem == null || limitTimeMarketItem.Id == 0) { return(RedirectToAction("Error404", "Error", new { area = "Web" })); } ProductInfo product = ServiceHelper.Create <IProductService>().GetProduct(limitTimeMarketItem.ProductId); productId = limitTimeMarketItem.ProductId; product.MarketPrice = limitTimeMarketItem.Price; product.SaleCounts = limitTimeMarketItem.SaleCount; maxSaleCount.Product = product; maxSaleCount.ProductDescription = product.ProductDescriptionInfo.Description; if (product.ProductDescriptionInfo.DescriptionPrefixId != 0) { ProductDescriptionTemplateInfo template = ServiceHelper.Create <IProductDescriptionTemplateService>().GetTemplate(product.ProductDescriptionInfo.DescriptionPrefixId, product.ShopId); maxSaleCount.DescriptionPrefix = (template == null ? "" : template.Content); } if (product.ProductDescriptionInfo.DescriptiondSuffixId != 0) { ProductDescriptionTemplateInfo productDescriptionTemplateInfo = ServiceHelper.Create <IProductDescriptionTemplateService>().GetTemplate(product.ProductDescriptionInfo.DescriptiondSuffixId, product.ShopId); maxSaleCount.DescriptiondSuffix = (productDescriptionTemplateInfo == null ? "" : productDescriptionTemplateInfo.Content); } ShopServiceMarkModel shopComprehensiveMark = ShopServiceMark.GetShopComprehensiveMark(shop.Id); maxSaleCount.Shop.PackMark = shopComprehensiveMark.PackMark; maxSaleCount.Shop.ServiceMark = shopComprehensiveMark.ServiceMark; maxSaleCount.Shop.ComprehensiveMark = shopComprehensiveMark.ComprehensiveMark; IQueryable <ProductCommentInfo> commentsByProductId = ServiceHelper.Create <ICommentService>().GetCommentsByProductId(productId); maxSaleCount.Shop.Name = shop.ShopName; maxSaleCount.Shop.ProductMark = (commentsByProductId == null || commentsByProductId.Count() == 0 ? new decimal(0) : commentsByProductId.Average <ProductCommentInfo>((ProductCommentInfo p) => (decimal)p.ReviewMark)); maxSaleCount.Shop.Id = product.ShopId; maxSaleCount.Shop.FreeFreight = shop.FreeFreight; ViewBag.ProductNum = ServiceHelper.Create <IProductService>().GetShopOnsaleProducts(product.ShopId); if (base.CurrentUser != null) { ViewBag.IsFavorite = ServiceHelper.Create <IProductService>().IsFavorite(product.Id, base.CurrentUser.Id); } else { ViewBag.IsFavorite = false; } IQueryable <ShopCategoryInfo> shopCategory = ServiceHelper.Create <IShopCategoryService>().GetShopCategory(product.ShopId); List <ShopCategoryInfo> list = shopCategory.ToList(); foreach (ShopCategoryInfo shopCategoryInfo in from s in list where s.ParentCategoryId == 0 select s) { CategoryJsonModel categoryJsonModel = new CategoryJsonModel() { Name = shopCategoryInfo.Name }; valueId = shopCategoryInfo.Id; categoryJsonModel.Id = valueId.ToString(); categoryJsonModel.SubCategory = new List <SecondLevelCategory>(); CategoryJsonModel categoryJsonModel1 = categoryJsonModel; foreach (ShopCategoryInfo shopCategoryInfo1 in from s in list where s.ParentCategoryId == shopCategoryInfo.Id select s) { SecondLevelCategory secondLevelCategory = new SecondLevelCategory() { Name = shopCategoryInfo1.Name, Id = shopCategoryInfo1.Id.ToString() }; categoryJsonModel1.SubCategory.Add(secondLevelCategory); } maxSaleCount.ShopCategory.Add(categoryJsonModel1); } IQueryable <ProductInfo> hotSaleProduct = ServiceHelper.Create <IProductService>().GetHotSaleProduct(shop.Id, 5); if (hotSaleProduct != null) { array = hotSaleProduct.ToArray(); for (i = 0; i < array.Length; i++) { ProductInfo productInfo = array[i]; List <HotProductInfo> hotSaleProducts = maxSaleCount.HotSaleProducts; HotProductInfo hotProductInfo = new HotProductInfo() { ImgPath = productInfo.ImagePath, Name = productInfo.ProductName, Price = productInfo.MinSalePrice, Id = productInfo.Id, SaleCount = (int)productInfo.SaleCounts }; hotSaleProducts.Add(hotProductInfo); } } IQueryable <ProductInfo> hotConcernedProduct = ServiceHelper.Create <IProductService>().GetHotConcernedProduct(shop.Id, 5); if (hotConcernedProduct != null) { array = hotConcernedProduct.ToArray(); for (i = 0; i < array.Length; i++) { ProductInfo productInfo1 = array[i]; List <HotProductInfo> hotAttentionProducts = maxSaleCount.HotAttentionProducts; HotProductInfo hotProductInfo1 = new HotProductInfo() { ImgPath = productInfo1.ImagePath, Name = productInfo1.ProductName, Price = productInfo1.MinSalePrice, Id = productInfo1.Id, SaleCount = productInfo1.ConcernedCount }; hotAttentionProducts.Add(hotProductInfo1); } } if (product.SKUInfo != null && product.SKUInfo.Count() > 0) { long num4 = 0; long num5 = 0; long num6 = 0; foreach (SKUInfo sKUInfo in product.SKUInfo) { string[] strArrays = sKUInfo.Id.Split(new char[] { '\u005F' }); if (strArrays.Count() > 0) { long.TryParse(strArrays[1], out num4); if (num4 != 0) { if (!maxSaleCount.Color.Any((ProductSKU v) => v.Value.Equals(sKUInfo.Color))) { long num7 = ( from s in product.SKUInfo where s.Color.Equals(sKUInfo.Color) select s).Sum <SKUInfo>((SKUInfo s) => s.Stock); CollectionSKU color = maxSaleCount.Color; ProductSKU productSKU = new ProductSKU() { Name = "选择颜色", EnabledClass = (num7 != 0 ? "enabled" : "disabled"), SelectedClass = "", SKUId = num4, Value = sKUInfo.Color }; color.Add(productSKU); } } } if (strArrays.Count() > 1) { long.TryParse(strArrays[2], out num5); if (num5 != 0) { if (!maxSaleCount.Size.Any((ProductSKU v) => v.Value.Equals(sKUInfo.Size))) { long num8 = ( from s in product.SKUInfo where s.Size.Equals(sKUInfo.Size) select s).Sum <SKUInfo>((SKUInfo s1) => s1.Stock); CollectionSKU size = maxSaleCount.Size; ProductSKU productSKU1 = new ProductSKU() { Name = "选择尺码", EnabledClass = (num8 != 0 ? "enabled" : "disabled"), SelectedClass = "", SKUId = num5, Value = sKUInfo.Size }; size.Add(productSKU1); } } } if (strArrays.Count() <= 2) { continue; } long.TryParse(strArrays[3], out num6); if (num6 == 0) { continue; } if (maxSaleCount.Version.Any((ProductSKU v) => v.Value.Equals(sKUInfo.Version))) { continue; } long num9 = ( from s in product.SKUInfo where s.Version.Equals(sKUInfo.Version) select s).Sum <SKUInfo>((SKUInfo s) => s.Stock); CollectionSKU version = maxSaleCount.Version; ProductSKU productSKU2 = new ProductSKU() { Name = "选择版本", EnabledClass = (num9 != 0 ? "enabled" : "disabled"), SelectedClass = "", SKUId = num6, Value = sKUInfo.Version }; version.Add(productSKU2); } decimal num10 = new decimal(0); decimal num11 = new decimal(0); num10 = ( from s in product.SKUInfo where s.Stock >= 0 select s).Min <SKUInfo>((SKUInfo s) => s.SalePrice); num11 = ( from s in product.SKUInfo where s.Stock >= 0 select s).Max <SKUInfo>((SKUInfo s) => s.SalePrice); if (!(num10 == new decimal(0)) || !(num11 == new decimal(0))) { str = (num11 <= num10 ? string.Format("{0}", num10.ToString("f2")) : string.Format("{0}-{1}", num10.ToString("f2"), num11.ToString("f2"))); } else { str = product.MinSalePrice.ToString("f2"); } } base.ViewBag.Price = (string.IsNullOrWhiteSpace(str) ? product.MinSalePrice.ToString("f2") : str); List <TypeAttributesModel> typeAttributesModels = new List <TypeAttributesModel>(); List <ProductAttributeInfo> productAttributeInfos = ServiceHelper.Create <IProductService>().GetProductAttribute(product.Id).ToList(); foreach (ProductAttributeInfo productAttributeInfo in productAttributeInfos) { if (typeAttributesModels.Any((TypeAttributesModel p) => p.AttrId == productAttributeInfo.AttributeId)) { TypeAttributesModel typeAttributesModel = typeAttributesModels.FirstOrDefault((TypeAttributesModel p) => p.AttrId == productAttributeInfo.AttributeId); if (typeAttributesModel.AttrValues.Any((TypeAttrValue p) => p.Id == productAttributeInfo.ValueId.ToString())) { continue; } List <TypeAttrValue> attrValues = typeAttributesModel.AttrValues; TypeAttrValue typeAttrValue = new TypeAttrValue(); valueId = productAttributeInfo.ValueId; typeAttrValue.Id = valueId.ToString(); typeAttrValue.Name = productAttributeInfo.AttributesInfo.AttributeValueInfo.FirstOrDefault((AttributeValueInfo a) => a.Id == productAttributeInfo.ValueId).Value; attrValues.Add(typeAttrValue); } else { TypeAttributesModel typeAttributesModel1 = new TypeAttributesModel() { AttrId = productAttributeInfo.AttributeId, AttrValues = new List <TypeAttrValue>(), Name = productAttributeInfo.AttributesInfo.Name }; TypeAttributesModel typeAttributesModel2 = typeAttributesModel1; foreach (AttributeValueInfo attributeValueInfo in productAttributeInfo.AttributesInfo.AttributeValueInfo) { if (!productAttributeInfos.Any((ProductAttributeInfo p) => p.ValueId == attributeValueInfo.Id)) { continue; } List <TypeAttrValue> typeAttrValues = typeAttributesModel2.AttrValues; TypeAttrValue value = new TypeAttrValue(); valueId = attributeValueInfo.Id; value.Id = valueId.ToString(); value.Name = attributeValueInfo.Value; typeAttrValues.Add(value); } typeAttributesModels.Add(typeAttributesModel2); } } ViewBag.ProductAttrs = typeAttributesModels; ICommentService commentService = ServiceHelper.Create <ICommentService>(); CommentQuery commentQuery = new CommentQuery() { ProductID = product.Id, PageNo = 1, PageSize = 10000 }; PageModel <ProductCommentInfo> comments = commentService.GetComments(commentQuery); ViewBag.CommentCount = comments.Total; IQueryable <ProductConsultationInfo> consultations = ServiceHelper.Create <IConsultationService>().GetConsultations(productId); ViewBag.Consultations = consultations.Count(); double num12 = product.Himall_ProductComments.Count(); double num13 = product.Himall_ProductComments.Count((ProductCommentInfo item) => item.ReviewMark >= 4); ViewBag.NicePercent = num13 / num12 * 100; ViewBag.Consultations = consultations.Count(); if (ServiceHelper.Create <IVShopService>().GetVShopByShopId(shop.Id) != null) { ViewBag.VShopId = ServiceHelper.Create <IVShopService>().GetVShopByShopId(shop.Id).Id; } else { ViewBag.VShopId = -1; } IQueryable <StatisticOrderCommentsInfo> shopStatisticOrderComments = ServiceHelper.Create <IShopService>().GetShopStatisticOrderComments(product.ShopId); StatisticOrderCommentsInfo statisticOrderCommentsInfo = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 1 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo1 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 9 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo2 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 5 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo3 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 2 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo4 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 10 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo5 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 6 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo6 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 3 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo7 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 4 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo8 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 11 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo9 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 12 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo10 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 7 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo11 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 8 select c).FirstOrDefault(); int num14 = 5; if (statisticOrderCommentsInfo == null || statisticOrderCommentsInfo3 == null) { ViewBag.ProductAndDescription = num14; ViewBag.ProductAndDescriptionPeer = num14; ViewBag.ProductAndDescriptionMin = num14; ViewBag.ProductAndDescriptionMax = num14; } else { ViewBag.ProductAndDescription = statisticOrderCommentsInfo.CommentValue; ViewBag.ProductAndDescriptionPeer = statisticOrderCommentsInfo3.CommentValue; ViewBag.ProductAndDescriptionMin = statisticOrderCommentsInfo7.CommentValue; ViewBag.ProductAndDescriptionMax = statisticOrderCommentsInfo6.CommentValue; } if (statisticOrderCommentsInfo1 == null || statisticOrderCommentsInfo4 == null) { ViewBag.SellerServiceAttitude = num14; ViewBag.SellerServiceAttitudePeer = num14; ViewBag.SellerServiceAttitudeMax = num14; ViewBag.SellerServiceAttitudeMin = num14; } else { ViewBag.SellerServiceAttitude = statisticOrderCommentsInfo1.CommentValue; ViewBag.SellerServiceAttitudePeer = statisticOrderCommentsInfo4.CommentValue; ViewBag.SellerServiceAttitudeMax = statisticOrderCommentsInfo8.CommentValue; ViewBag.SellerServiceAttitudeMin = statisticOrderCommentsInfo9.CommentValue; } if (statisticOrderCommentsInfo5 == null || statisticOrderCommentsInfo2 == null) { ViewBag.SellerDeliverySpeed = num14; ViewBag.SellerDeliverySpeedPeer = num14; ViewBag.SellerDeliverySpeedMax = num14; ViewBag.sellerDeliverySpeedMin = num14; } else { ViewBag.SellerDeliverySpeed = statisticOrderCommentsInfo2.CommentValue; ViewBag.SellerDeliverySpeedPeer = statisticOrderCommentsInfo5.CommentValue; dynamic viewBag = base.ViewBag; num1 = (statisticOrderCommentsInfo10 != null ? statisticOrderCommentsInfo10.CommentValue : new decimal(0)); viewBag.SellerDeliverySpeedMax = num1; dynamic obj = base.ViewBag; num2 = (statisticOrderCommentsInfo11 != null ? statisticOrderCommentsInfo11.CommentValue : new decimal(0)); obj.sellerDeliverySpeedMin = num2; } base.ViewBag.Logined = (base.CurrentUser != null ? 1 : 0); base.ViewBag.EnabledBuy = (product.AuditStatus != ProductInfo.ProductAuditStatus.Audited || !(limitTimeMarketItem.StartTime <= DateTime.Now) || !(limitTimeMarketItem.EndTime > DateTime.Now) ? false : product.SaleStatus == ProductInfo.ProductSaleStatus.OnSale); DateTime endTime = limitTimeMarketItem.EndTime; TimeSpan timeSpan = new TimeSpan(endTime.Ticks); endTime = DateTime.Now; TimeSpan timeSpan1 = timeSpan.Subtract(new TimeSpan(endTime.Ticks)); dynamic viewBag1 = base.ViewBag; num = (timeSpan1.TotalSeconds < 0 ? 0 : timeSpan1.TotalSeconds); viewBag1.Second = num; return(View(maxSaleCount)); }
public ActionResult ShowSkuInfo(FightGroupActiveModel data) { if (data == null) { throw new HimallException("错误的活动信息"); } ProductShowSkuInfoModel model = new ProductShowSkuInfoModel { MinSalePrice = data.MiniGroupPrice, ProductImagePath = data.ProductImgPath }; ProductTypeInfo typeByProductId = this._iTypeService.GetTypeByProductId(data.ProductId.Value); string str = ((typeByProductId == null) || string.IsNullOrEmpty(typeByProductId.ColorAlias)) ? SpecificationType.Color.ToDescription() : typeByProductId.ColorAlias; string str2 = ((typeByProductId == null) || string.IsNullOrEmpty(typeByProductId.SizeAlias)) ? SpecificationType.Size.ToDescription() : typeByProductId.SizeAlias; string str3 = ((typeByProductId == null) || string.IsNullOrEmpty(typeByProductId.VersionAlias)) ? SpecificationType.Version.ToDescription() : typeByProductId.VersionAlias; model.ColorAlias = str; model.SizeAlias = str2; model.VersionAlias = str3; if ((data.ActiveItems != null) && (data.ActiveItems.Count <FightGroupActiveItemModel>() > 0)) { long result = 0L; long num2 = 0L; long num3 = 0L; using (List <FightGroupActiveItemModel> .Enumerator enumerator = data.ActiveItems.GetEnumerator()) { while (enumerator.MoveNext()) { Func <ProductSKU, bool> predicate = null; Func <FightGroupActiveItemModel, bool> func2 = null; Func <ProductSKU, bool> func3 = null; Func <FightGroupActiveItemModel, bool> func4 = null; Func <ProductSKU, bool> func5 = null; Func <FightGroupActiveItemModel, bool> func6 = null; FightGroupActiveItemModel sku = enumerator.Current; string[] source = sku.SkuId.Split(new char[] { '_' }); if (source.Count <string>() > 0) { if (long.TryParse(source[1], out result)) { } if (result != 0L) { if (predicate == null) { predicate = v => v.Value.Equals(sku.Color); } if (!model.Color.Any <ProductSKU>(predicate)) { if (func2 == null) { func2 = s => s.Color.Equals(sku.Color); } long? nullable = data.ActiveItems.Where <FightGroupActiveItemModel>(func2).Sum <FightGroupActiveItemModel>((Func <FightGroupActiveItemModel, long?>)(s => s.ActiveStock)); ProductSKU item = new ProductSKU { Name = "选择" + str, EnabledClass = (nullable != 0L) ? "enabled" : "disabled", SelectedClass = "", SkuId = result, Value = sku.Color, Img = sku.ShowPic }; model.Color.Add(item); } } } if (source.Count <string>() > 1) { if (long.TryParse(source[2], out num2)) { } if (num2 != 0L) { if (func3 == null) { func3 = v => v.Value.Equals(sku.Size); } if (!model.Size.Any <ProductSKU>(func3)) { if (func4 == null) { func4 = s => s.Size.Equals(sku.Size); } long? nullable2 = data.ActiveItems.Where <FightGroupActiveItemModel>(func4).Sum <FightGroupActiveItemModel>((Func <FightGroupActiveItemModel, long?>)(s1 => s1.ActiveStock)); ProductSKU tsku2 = new ProductSKU { Name = "选择" + str2, EnabledClass = (nullable2 != 0L) ? "enabled" : "disabled", SelectedClass = "", SkuId = num2, Value = sku.Size }; model.Size.Add(tsku2); } } } if (source.Count <string>() > 2) { if (long.TryParse(source[3], out num3)) { } if (num3 != 0L) { if (func5 == null) { func5 = v => v.Value.Equals(sku.Version); } if (!model.Version.Any <ProductSKU>(func5)) { if (func6 == null) { func6 = s => s.Version.Equals(sku.Version); } long? nullable3 = data.ActiveItems.Where <FightGroupActiveItemModel>(func6).Sum <FightGroupActiveItemModel>((Func <FightGroupActiveItemModel, long?>)(s => s.ActiveStock)); ProductSKU tsku3 = new ProductSKU { Name = "选择" + str3, EnabledClass = (nullable3 != 0L) ? "enabled" : "disabled", SelectedClass = "", SkuId = num3, Value = sku.Version }; model.Version.Add(tsku3); } } } } } } return(base.View(model)); }
//....................... public ProductDTO GetProductSKU(long skuId, Langs l, Currency c) { ProductDTO productDTO = GetSKUInformation(skuId, l, c); productDTO.SizeAttributes = new List <SizeAttributeViewDTO>(); productDTO.Sizes = GetProductSizes(productDTO.Id, l); if (productDTO.Sizes.Count == 0) { productDTO.SelectedSize = -1; productDTO.Sizes = null; } else { var sizeOption = unitOfWork.ProductSKURepository.Get(s => s.SKUId == skuId).FirstOrDefault(). ProductSKUOptionValues.Select(op => op.OptionValue). Where(op => op.Option.IsColor == false).FirstOrDefault(); if (sizeOption != null) { long sizeId = sizeOption.ValueId; for (int i = 0; i < productDTO.Sizes.Count; i++) { if (productDTO.Sizes[i].ValueId == sizeId) { productDTO.SelectedSize = i; } } } else { long sizeId = unitOfWork.ProductSKURepository.Get(s => s.SKUId == skuId).FirstOrDefault().ProductSKUOptionValues.FirstOrDefault().ValueId; for (int i = 0; i < productDTO.Sizes.Count; i++) { if (productDTO.Sizes[i].ValueId == sizeId) { productDTO.SelectedSize = i; } } } } productDTO.Colors = GetProductColors(productDTO.Id, l); if (productDTO.Colors.Count == 0) { productDTO.SelectedColor = -1; productDTO.Colors = null; } else { long colorId = unitOfWork.ProductSKURepository.Get(op => op.SKUId == skuId).FirstOrDefault(). ProductSKUOptionValues.Select(op => op.OptionValue). Where(op => op.Option.IsColor == true).FirstOrDefault().ValueId; for (int i = 0; i < productDTO.Colors.Count; i++) { if (productDTO.Colors[i].ValueId == colorId) { productDTO.SelectedColor = i; } } var colorOptionId = productDTO.Colors[productDTO.SelectedColor].OptionId; var colorImages = unitOfWork.OptionValueRepository.Get(op => op.ProductId == productDTO.Id && op.OptionId == colorOptionId && op.ValueId == colorId) .FirstOrDefault().Images; if (colorImages.Count > 0) { productDTO.Images = colorImages.Select(img => img.ImageUrl).ToList(); } else { productDTO.Images.Add(DefaultImages.Product); } if (productDTO.SelectedSize >= 0) { for (int i = 0; i < productDTO.Sizes.Count; i++) { long curSize = productDTO.Sizes[i].ValueId, curColor = productDTO.Colors[productDTO.SelectedColor].ValueId, curProduct = productDTO.Id, curColorOption, curSizeOption; ProductSKU psku = unitOfWork.ProductSKURepository.Get(s => s.SKUId == productDTO.SKUId).FirstOrDefault(); //curColorOption=psku. // ProductSKUOptionValues.Select(op => op.OptionValue). // Where(op=>op.ValueId==curColor).FirstOrDefault().Option.OptionId; curColorOption = productDTO.Colors[productDTO.SelectedColor].OptionId; //curSizeOption = psku. // ProductSKUOptionValues.Select(op => op.OptionValue). // Where(op => op.ValueId == curSize).FirstOrDefault().Option.OptionId; curSizeOption = productDTO.Sizes[i].OptionId; var v1 = unitOfWork.ProductSKUOptionValueRepository.Get(op => op.ProductId == curProduct && op.ValueId == curColor && op.OptionId == curColorOption).Select(op => op.SKUId); var v2 = unitOfWork.ProductSKUOptionValueRepository.Get(op => op.ProductId == curProduct && op.ValueId == curSize && op.OptionId == curSizeOption).Select(op => op.SKUId); var v = v1.Intersect(v2); if (v != null && v.ToList().Count > 0) { productDTO.Sizes[i].Available = true; } else { productDTO.Sizes[i].Available = false; } } } if (productDTO.SelectedSize >= 0) { var sizeDto = productDTO.Sizes[productDTO.SelectedSize]; var sizAttributes = unitOfWork.ProductSizeAttributeRepository.Get(ps => ps.ValueId == sizeDto.ValueId && ps.ProductId == productDTO.Id).ToList(); foreach (var productSizeAttribute in sizAttributes) { SizeAttributeViewDTO dto = new SizeAttributeViewDTO(); var sizeAttribute = unitOfWork.SizeAttributeRepository.GetByID(productSizeAttribute.SizeAttributeId); var option = unitOfWork.SizeHelperRepository.Get(d => d.Id == sizeAttribute.Id).FirstOrDefault().OptionId; dto.SizeAttributeName = sizeAttribute.SizeAttributeDescriptions.Where(d => d.LanguageId == (long)l) .FirstOrDefault() .Name; dto.SizeAttributeValueCm = productSizeAttribute.Value; dto.SizeAttributeValueInch = productSizeAttribute.Value * 2.5; productDTO.SizeAttributes.Add(dto); } } } return(productDTO); }
private ProductDTO GetSKUInformation(long skuId, Langs l, Currency c) { long languageId = Utils.getLanguage(l); ProductDTO productDTO = new ProductDTO(); productDTO.SKUId = skuId; ProductSKU SKU = unitOfWork.ProductSKURepository.Get(s => s.SKUId == skuId).FirstOrDefault(); productDTO.Id = SKU.ProductId; Product product = unitOfWork.ProductRepository.GetByID(productDTO.Id); productDTO.Designer = new DesignerDTO(); productDTO.Designer.DesignerId = product.DesignerId; productDTO.Designer.DesignerName = product.Designer.Descriptions.FirstOrDefault(cc => cc.LanguageId == (long)l).Text; productDTO.Name = product.ProductDescriptions.Where(cc => cc.LanguageId == (long)l).FirstOrDefault().Name; productDTO.IsNew = (DateTime.Now.Year * 365 + DateTime.Now.Month * 30 + DateTime.Now.Day - product.DateAdded.Value.Year * 365 - product.DateAdded.Value.Month * 30 - product.DateAdded.Value.Day) <= 7; productDTO.Quantity = SKU.Quentity; productDTO.IsAvailable = (SKU.Quentity != 0); productDTO.CategoryId = product.CategoryId; productDTO.Price = Utils.getCurrency(c, l, product.Price).Item1; Tuple <double, String> tuple = Utils.getCurrency(c, l, SKU.Price); double SKUPrice = tuple.Item1; productDTO.CurrencyName = tuple.Item2; productDTO.rates = GetProductRates(productDTO.Id); if (productDTO.rates.Count != 0) { productDTO.TotalRate = (int)Math.Ceiling(productDTO.rates.Sum(cc => cc.Rate) / productDTO.rates.Count + 0.0); } else { productDTO.TotalRate = 0; } productDTO.DateAdded = product.DateAdded.Value; productDTO.OrginalPrice = (productDTO.Price + SKUPrice); productDTO.TotalPrice = productDTO.OrginalPrice; //if (SKU.Discounts.Count > 0) //{ // if (SKU.Discounts.FirstOrDefault().IsPercentage) // productDTO.TotalPrice = productDTO.OrginalPrice * (100 - SKU.Discounts.FirstOrDefault().Value) / 100; // else // productDTO.TotalPrice = productDTO.OrginalPrice - SKU.Discounts.FirstOrDefault().Value; // productDTO.IsDiscounted = (SKU.Discounts.FirstOrDefault().Value != 0); //} ProductDescription productDescription = product.ProductDescriptions.FirstOrDefault(op => op.LanguageId == languageId); productDTO.MetaDescriptions = productDescription.MetaDescriptions; productDTO.Text = productDescription.Text; var images = unitOfWork.ImageRepository.Get(img => img.ProductId == productDTO.Id) .Select(img => img.ImageUrl) .ToList(); if (images.Count > 0) { productDTO.Images = images; } else { productDTO.Images = new List <string>(); productDTO.Images.Add(DefaultImages.Product); } productDTO.Tags = GetProductTagsBySkuId(productDTO.SKUId, l); return(productDTO); }
public ActionResult Detail(string id = "") { decimal num; decimal num1; string str = ""; ProductDetailModelForWeb productDetailModelForWeb = new ProductDetailModelForWeb() { Product = new ProductInfo(), Shop = new ShopInfoModel(), Color = new CollectionSKU(), Size = new CollectionSKU(), Version = new CollectionSKU() }; ProductDetailModelForWeb showMobileDescription = productDetailModelForWeb; ProductInfo product = null; ShopInfo shop = null; long num2 = 0; long.TryParse(id, out num2); if (num2 == 0) { return(RedirectToAction("Error404", "Error", new { area = "Web" })); } product = ServiceHelper.Create <IProductService>().GetProduct(num2); showMobileDescription.ProductDescription = product.ProductDescriptionInfo.ShowMobileDescription; if (product == null) { return(RedirectToAction("Error404", "Error", new { area = "Web" })); } LimitTimeMarketInfo limitTimeMarketItemByProductId = ServiceHelper.Create <ILimitTimeBuyService>().GetLimitTimeMarketItemByProductId(product.Id); if (limitTimeMarketItemByProductId != null) { return(RedirectToAction("Detail", "LimitTimeBuy", new { id = limitTimeMarketItemByProductId.Id })); } shop = ServiceHelper.Create <IShopService>().GetShop(product.ShopId, false); ShopServiceMarkModel shopComprehensiveMark = ShopServiceMark.GetShopComprehensiveMark(shop.Id); showMobileDescription.Shop.PackMark = shopComprehensiveMark.PackMark; showMobileDescription.Shop.ServiceMark = shopComprehensiveMark.ServiceMark; showMobileDescription.Shop.ComprehensiveMark = shopComprehensiveMark.ComprehensiveMark; IQueryable <ProductCommentInfo> commentsByProductId = ServiceHelper.Create <ICommentService>().GetCommentsByProductId(num2); showMobileDescription.Shop.Name = shop.ShopName; showMobileDescription.Shop.ProductMark = (commentsByProductId == null || commentsByProductId.Count() == 0 ? new decimal(0) : commentsByProductId.Average <ProductCommentInfo>((ProductCommentInfo p) => (decimal)p.ReviewMark)); showMobileDescription.Shop.Id = product.ShopId; showMobileDescription.Shop.FreeFreight = shop.FreeFreight; ViewBag.ProductNum = ServiceHelper.Create <IProductService>().GetShopOnsaleProducts(product.ShopId); if (base.CurrentUser != null) { ViewBag.IsFavorite = ServiceHelper.Create <IProductService>().IsFavorite(product.Id, base.CurrentUser.Id); } else { ViewBag.IsFavorite = false; } if (product.SKUInfo != null && product.SKUInfo.Count() > 0) { long num3 = 0; long num4 = 0; long num5 = 0; foreach (SKUInfo sKUInfo in product.SKUInfo) { string[] strArrays = sKUInfo.Id.Split(new char[] { '\u005F' }); if (strArrays.Count() > 0) { long.TryParse(strArrays[1], out num3); if (num3 != 0) { if (!showMobileDescription.Color.Any((ProductSKU v) => v.Value.Equals(sKUInfo.Color))) { long num6 = ( from s in product.SKUInfo where s.Color.Equals(sKUInfo.Color) select s).Sum <SKUInfo>((SKUInfo s) => s.Stock); CollectionSKU color = showMobileDescription.Color; ProductSKU productSKU = new ProductSKU() { Name = "选择颜色", EnabledClass = (num6 != 0 ? "enabled" : "disabled"), SelectedClass = "", SKUId = num3, Value = sKUInfo.Color }; color.Add(productSKU); } } } if (strArrays.Count() > 1) { long.TryParse(strArrays[2], out num4); if (num4 != 0) { if (!showMobileDescription.Size.Any((ProductSKU v) => v.Value.Equals(sKUInfo.Size))) { long num7 = ( from s in product.SKUInfo where s.Size.Equals(sKUInfo.Size) select s).Sum <SKUInfo>((SKUInfo s1) => s1.Stock); CollectionSKU size = showMobileDescription.Size; ProductSKU productSKU1 = new ProductSKU() { Name = "选择尺码", EnabledClass = (num7 != 0 ? "enabled" : "disabled"), SelectedClass = "", SKUId = num4, Value = sKUInfo.Size }; size.Add(productSKU1); } } } if (strArrays.Count() <= 2) { continue; } long.TryParse(strArrays[3], out num5); if (num5 == 0) { continue; } if (showMobileDescription.Version.Any((ProductSKU v) => v.Value.Equals(sKUInfo.Version))) { continue; } long num8 = ( from s in product.SKUInfo where s.Version.Equals(sKUInfo.Version) select s).Sum <SKUInfo>((SKUInfo s) => s.Stock); CollectionSKU version = showMobileDescription.Version; ProductSKU productSKU2 = new ProductSKU() { Name = "选择版本", EnabledClass = (num8 != 0 ? "enabled" : "disabled"), SelectedClass = "", SKUId = num5, Value = sKUInfo.Version }; version.Add(productSKU2); } decimal num9 = new decimal(0); decimal num10 = new decimal(0); num9 = ( from s in product.SKUInfo where s.Stock >= 0 select s).Min <SKUInfo>((SKUInfo s) => s.SalePrice); num10 = ( from s in product.SKUInfo where s.Stock >= 0 select s).Max <SKUInfo>((SKUInfo s) => s.SalePrice); if (!(num9 == new decimal(0)) || !(num10 == new decimal(0))) { str = (num10 <= num9 ? string.Format("{0}", num9.ToString("f2")) : string.Format("{0}-{1}", num9.ToString("f2"), num10.ToString("f2"))); } else { str = product.MinSalePrice.ToString("f2"); } } base.ViewBag.Price = (string.IsNullOrWhiteSpace(str) ? product.MinSalePrice.ToString("f2") : str); IQueryable <StatisticOrderCommentsInfo> shopStatisticOrderComments = ServiceHelper.Create <IShopService>().GetShopStatisticOrderComments(product.ShopId); StatisticOrderCommentsInfo statisticOrderCommentsInfo = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 1 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo1 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 9 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo2 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 5 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo3 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 2 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo4 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 10 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo5 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 6 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo6 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 3 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo7 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 4 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo8 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 11 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo9 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 12 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo10 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 7 select c).FirstOrDefault(); StatisticOrderCommentsInfo statisticOrderCommentsInfo11 = ( from c in shopStatisticOrderComments where (int)c.CommentKey == 8 select c).FirstOrDefault(); int num11 = 5; if (statisticOrderCommentsInfo == null || statisticOrderCommentsInfo3 == null) { ViewBag.ProductAndDescription = num11; ViewBag.ProductAndDescriptionPeer = num11; ViewBag.ProductAndDescriptionMin = num11; ViewBag.ProductAndDescriptionMax = num11; } else { ViewBag.ProductAndDescription = statisticOrderCommentsInfo.CommentValue; ViewBag.ProductAndDescriptionPeer = statisticOrderCommentsInfo3.CommentValue; ViewBag.ProductAndDescriptionMin = statisticOrderCommentsInfo7.CommentValue; ViewBag.ProductAndDescriptionMax = statisticOrderCommentsInfo6.CommentValue; } if (statisticOrderCommentsInfo1 == null || statisticOrderCommentsInfo4 == null) { ViewBag.SellerServiceAttitude = num11; ViewBag.SellerServiceAttitudePeer = num11; ViewBag.SellerServiceAttitudeMax = num11; ViewBag.SellerServiceAttitudeMin = num11; } else { ViewBag.SellerServiceAttitude = statisticOrderCommentsInfo1.CommentValue; ViewBag.SellerServiceAttitudePeer = statisticOrderCommentsInfo4.CommentValue; ViewBag.SellerServiceAttitudeMax = statisticOrderCommentsInfo8.CommentValue; ViewBag.SellerServiceAttitudeMin = statisticOrderCommentsInfo9.CommentValue; } if (statisticOrderCommentsInfo5 == null || statisticOrderCommentsInfo2 == null) { ViewBag.SellerDeliverySpeed = num11; ViewBag.SellerDeliverySpeedPeer = num11; ViewBag.SellerDeliverySpeedMax = num11; ViewBag.sellerDeliverySpeedMin = num11; } else { ViewBag.SellerDeliverySpeed = statisticOrderCommentsInfo2.CommentValue; ViewBag.SellerDeliverySpeedPeer = statisticOrderCommentsInfo5.CommentValue; dynamic viewBag = base.ViewBag; num = (statisticOrderCommentsInfo10 != null ? statisticOrderCommentsInfo10.CommentValue : new decimal(0)); viewBag.SellerDeliverySpeedMax = num; dynamic obj = base.ViewBag; num1 = (statisticOrderCommentsInfo11 != null ? statisticOrderCommentsInfo11.CommentValue : new decimal(0)); obj.sellerDeliverySpeedMin = num1; } showMobileDescription.Product = product; ICommentService commentService = ServiceHelper.Create <ICommentService>(); CommentQuery commentQuery = new CommentQuery() { ProductID = product.Id, PageNo = 1, PageSize = 10000 }; PageModel <ProductCommentInfo> comments = commentService.GetComments(commentQuery); ViewBag.CommentCount = comments.Total; IQueryable <ProductConsultationInfo> consultations = ServiceHelper.Create <IConsultationService>().GetConsultations(num2); double num12 = product.ChemCloud_ProductComments.Count(); double num13 = product.ChemCloud_ProductComments.Count((ProductCommentInfo item) => item.ReviewMark >= 4); ViewBag.NicePercent = num13 / num12 * 100; ViewBag.Consultations = consultations.Count(); if (ServiceHelper.Create <IVShopService>().GetVShopByShopId(shop.Id) != null) { ViewBag.VShopId = ServiceHelper.Create <IVShopService>().GetVShopByShopId(shop.Id).Id; } else { ViewBag.VShopId = -1; } IEnumerable <CouponInfo> couponList = GetCouponList(shop.Id); if (couponList != null) { int num14 = couponList.Count(); ViewBag.CouponCount = num14; } ShopBonusInfo byShopId = ServiceHelper.Create <IShopBonusService>().GetByShopId(shop.Id); if (byShopId != null) { ViewBag.BonusCount = byShopId.Count; ViewBag.BonusGrantPrice = byShopId.GrantPrice; ViewBag.BonusRandomAmountStart = byShopId.RandomAmountStart; ViewBag.BonusRandomAmountEnd = byShopId.RandomAmountEnd; } ViewBag.CashDepositsObligation = Instance <ICashDepositsService> .Create.GetCashDepositsObligation(product.Id); showMobileDescription.CashDepositsServer = Instance <ICashDepositsService> .Create.GetCashDepositsObligation(product.Id); return(View(showMobileDescription)); }
public ActionResult Detail(string id) { ProductDescriptionTemplateInfo template; long num15; TimeSpan span; TimeSpan span2; TimeSpan span3; ParameterExpression expression; LimitTimeBuyDetailModel model = new LimitTimeBuyDetailModel(); string str = ""; LimitTimeProductDetailModel model2 = new LimitTimeProductDetailModel { MainId = long.Parse(id), HotAttentionProducts = new List <HotProductInfo>(), HotSaleProducts = new List <HotProductInfo>(), Product = new ProductInfo(), Shop = new ShopInfoModel(), ShopCategory = new List <CategoryJsonModel>(), Color = new CollectionSKU(), Size = new CollectionSKU(), Version = new CollectionSKU() }; FlashSaleModel model3 = null; ShopInfo shop = null; long productId = 0L; long result = 0L; if (long.TryParse(id, out result)) { } if (result == 0L) { return(base.RedirectToAction("Error404", "Error", new { area = "Mobile" })); } model3 = this._iLimitTimeBuyService.Get(result); switch (model3.Status) { case FlashSaleInfo.FlashSaleStatus.Ended: return(base.RedirectToAction("Detail", "Product", new { id = model3.ProductId })); case FlashSaleInfo.FlashSaleStatus.Cancelled: return(base.RedirectToAction("Detail", "Product", new { id = model3.ProductId })); } model2.FlashSale = model3; if ((model3 == null) || (model3.Status != FlashSaleInfo.FlashSaleStatus.Ongoing)) { model3 = (model3 == null) ? this._iLimitTimeBuyService.GetFlaseSaleByProductId(result) : model3; if (model3 == null) { return(base.RedirectToAction("Error404", "Error", new { area = "Mobile" })); } if (model3.Status != FlashSaleInfo.FlashSaleStatus.Ongoing) { return(base.RedirectToAction("Detail", "Product", new { id = model3.ProductId })); } } if ((model3 != null) && ((model3.Status != FlashSaleInfo.FlashSaleStatus.Ongoing) || (DateTime.Parse(model3.EndDate) < DateTime.Now))) { return(base.RedirectToAction("Detail", "Product", new { id = model3.ProductId })); } model2.MaxSaleCount = model3.LimitCountOfThePeople; model2.Title = model3.Title; shop = this._iShopService.GetShop(model3.ShopId, false); if ((model3 == null) || (model3.Id == 0L)) { return(base.RedirectToAction("Error404", "Error", new { area = "Web" })); } ProductInfo product = this._iProductService.GetProduct(model3.ProductId); productId = model3.ProductId; model2.Product = product; model2.ProductDescription = product.ProductDescriptionInfo.ShowMobileDescription; if (product.ProductDescriptionInfo.DescriptionPrefixId != 0L) { template = this._iProductDescriptionTemplateService.GetTemplate(product.ProductDescriptionInfo.DescriptionPrefixId, product.ShopId); model2.DescriptionPrefix = (template == null) ? "" : template.Content; } if (product.ProductDescriptionInfo.DescriptiondSuffixId != 0L) { template = this._iProductDescriptionTemplateService.GetTemplate(product.ProductDescriptionInfo.DescriptiondSuffixId, product.ShopId); model2.DescriptiondSuffix = (template == null) ? "" : template.Content; } ShopServiceMarkModel shopComprehensiveMark = ShopServiceMark.GetShopComprehensiveMark(shop.Id); model2.Shop.PackMark = shopComprehensiveMark.PackMark; model2.Shop.ServiceMark = shopComprehensiveMark.ServiceMark; model2.Shop.ComprehensiveMark = shopComprehensiveMark.ComprehensiveMark; IQueryable <ProductCommentInfo> commentsByProductId = this._iCommentService.GetCommentsByProductId(productId); model2.Shop.Name = shop.ShopName; Decimal num1; if (commentsByProductId != null && Queryable.Count <ProductCommentInfo>(commentsByProductId) != 0) { num1 = Queryable.Average <ProductCommentInfo>(commentsByProductId, (Expression <Func <ProductCommentInfo, Decimal> >)(p => (Decimal)p.ReviewMark)); } else { num1 = new Decimal(0); } model2.Shop.ProductMark = num1; model2.Shop.Id = product.ShopId; model2.Shop.FreeFreight = shop.FreeFreight; model.ProductNum = this._iProductService.GetShopOnsaleProducts(product.ShopId); model.FavoriteShopCount = this._iShopService.GetShopFavoritesCount(product.ShopId); if (base.CurrentUser == null) { model.IsFavorite = false; model.IsFavoriteShop = false; } else { model.IsFavorite = this._iProductService.IsFavorite(product.Id, base.CurrentUser.Id); model.IsFavoriteShop = (from item in this._iShopService.GetFavoriteShopInfos(base.CurrentUser.Id) select item.ShopId).ToArray <long>().Contains <long>(product.ShopId); } List <ShopCategoryInfo> source = this._iShopCategoryService.GetShopCategory(product.ShopId).ToList <ShopCategoryInfo>(); using (IEnumerator <ShopCategoryInfo> enumerator = (from s in source where s.ParentCategoryId == 0L select s).GetEnumerator()) { while (enumerator.MoveNext()) { Func <ShopCategoryInfo, bool> predicate = null; ShopCategoryInfo main = enumerator.Current; CategoryJsonModel model5 = new CategoryJsonModel { Name = main.Name, Id = main.Id.ToString(), SubCategory = new List <SecondLevelCategory>() }; if (predicate == null) { predicate = s => s.ParentCategoryId == main.Id; } foreach (ShopCategoryInfo info4 in source.Where <ShopCategoryInfo>(predicate)) { SecondLevelCategory category = new SecondLevelCategory { Name = info4.Name, Id = info4.Id.ToString() }; model5.SubCategory.Add(category); } model2.ShopCategory.Add(model5); } } IQueryable <ProductInfo> hotSaleProduct = this._iProductService.GetHotSaleProduct(shop.Id, 5); if (hotSaleProduct != null) { foreach (ProductInfo info5 in hotSaleProduct.ToArray <ProductInfo>()) { HotProductInfo info6 = new HotProductInfo { ImgPath = info5.ImagePath, Name = info5.ProductName, Price = info5.MinSalePrice, Id = info5.Id, SaleCount = (int)info5.SaleCounts }; model2.HotSaleProducts.Add(info6); } } IQueryable <ProductInfo> hotConcernedProduct = this._iProductService.GetHotConcernedProduct(shop.Id, 5); if (hotConcernedProduct != null) { foreach (ProductInfo info5 in hotConcernedProduct.ToArray <ProductInfo>()) { HotProductInfo info7 = new HotProductInfo { ImgPath = info5.ImagePath, Name = info5.ProductName, Price = info5.MinSalePrice, Id = info5.Id, SaleCount = info5.ConcernedCount }; model2.HotAttentionProducts.Add(info7); } } ProductTypeInfo type = this._iTypeService.GetType(product.TypeId); string str2 = ((type == null) || string.IsNullOrEmpty(type.ColorAlias)) ? SpecificationType.Color.ToDescription() : type.ColorAlias; string str3 = ((type == null) || string.IsNullOrEmpty(type.SizeAlias)) ? SpecificationType.Size.ToDescription() : type.SizeAlias; string str4 = ((type == null) || string.IsNullOrEmpty(type.VersionAlias)) ? SpecificationType.Version.ToDescription() : type.VersionAlias; model2.ColorAlias = str2; model2.SizeAlias = str3; model2.VersionAlias = str4; if ((product.SKUInfo != null) && (product.SKUInfo.Count <SKUInfo>() > 0)) { long num3 = 0L; long num4 = 0L; long num5 = 0L; using (IEnumerator <SKUInfo> enumerator3 = product.SKUInfo.GetEnumerator()) { while (enumerator3.MoveNext()) { Func <ProductSKU, bool> func2 = null; Func <SKUInfo, bool> func3 = null; Func <ProductSKU, bool> func4 = null; Func <SKUInfo, bool> func5 = null; Func <ProductSKU, bool> func6 = null; Func <SKUInfo, bool> func7 = null; SKUInfo sku = enumerator3.Current; string[] strArray = sku.Id.Split(new char[] { '_' }); if (strArray.Count <string>() > 0) { if (long.TryParse(strArray[1], out num3)) { } if (num3 != 0L) { if (func2 == null) { func2 = v => v.Value.Equals(sku.Color); } if (!model2.Color.Any <ProductSKU>(func2)) { if (func3 == null) { func3 = s => s.Color.Equals(sku.Color); } long num6 = product.SKUInfo.Where <SKUInfo>(func3).Sum <SKUInfo>((Func <SKUInfo, long>)(s => s.Stock)); ProductSKU tsku = new ProductSKU { Name = "选择" + str2, EnabledClass = (num6 != 0L) ? "enabled" : "disabled", SelectedClass = "", SkuId = num3, Value = sku.Color, Img = sku.ShowPic }; model2.Color.Add(tsku); } } } if (strArray.Count <string>() > 1) { if (long.TryParse(strArray[2], out num4)) { } if (num4 != 0L) { if (func4 == null) { func4 = v => v.Value.Equals(sku.Size); } if (!model2.Size.Any <ProductSKU>(func4)) { if (func5 == null) { func5 = s => s.Size.Equals(sku.Size); } long num7 = product.SKUInfo.Where <SKUInfo>(func5).Sum <SKUInfo>((Func <SKUInfo, long>)(s1 => s1.Stock)); ProductSKU tsku2 = new ProductSKU { Name = "选择" + str3, EnabledClass = (num7 != 0L) ? "enabled" : "disabled", SelectedClass = "", SkuId = num4, Value = sku.Size }; model2.Size.Add(tsku2); } } } if (strArray.Count <string>() > 2) { if (long.TryParse(strArray[3], out num5)) { } if (num5 != 0L) { if (func6 == null) { func6 = v => v.Value.Equals(sku.Version); } if (!model2.Version.Any <ProductSKU>(func6)) { if (func7 == null) { func7 = s => s.Version.Equals(sku.Version); } long num8 = product.SKUInfo.Where <SKUInfo>(func7).Sum <SKUInfo>((Func <SKUInfo, long>)(s => s.Stock)); ProductSKU tsku3 = new ProductSKU { Name = "选择" + str4, EnabledClass = (num8 != 0L) ? "enabled" : "disabled", SelectedClass = "", SkuId = num5, Value = sku.Version }; model2.Version.Add(tsku3); } } } } } decimal num9 = 0M; decimal num10 = 0M; num9 = (from s in product.SKUInfo where s.Stock >= 0L select s).Min <SKUInfo>((Func <SKUInfo, decimal>)(s => s.SalePrice)); num10 = (from s in product.SKUInfo where s.Stock >= 0L select s).Max <SKUInfo>((Func <SKUInfo, decimal>)(s => s.SalePrice)); if ((num9 == 0M) && (num10 == 0M)) { str = product.MinSalePrice.ToString("f2"); } else if (num10 > num9) { str = string.Format("{0}-{1}", num9.ToString("f2"), num10.ToString("f2")); } else { str = string.Format("{0}", num9.ToString("f2")); } } model.Price = string.IsNullOrWhiteSpace(str) ? product.MinSalePrice.ToString("f2") : str; List <TypeAttributesModel> list2 = new List <TypeAttributesModel>(); List <ProductAttributeInfo> list3 = this._iProductService.GetProductAttribute(product.Id).ToList <ProductAttributeInfo>(); using (List <ProductAttributeInfo> .Enumerator enumerator4 = list3.GetEnumerator()) { while (enumerator4.MoveNext()) { Func <TypeAttributesModel, bool> func9 = null; Func <TypeAttributesModel, bool> func10 = null; Func <TypeAttrValue, bool> func11 = null; Func <AttributeValueInfo, bool> func12 = null; ProductAttributeInfo attr = enumerator4.Current; if (func9 == null) { func9 = p => p.AttrId == attr.AttributeId; } if (!list2.Any <TypeAttributesModel>(func9)) { TypeAttributesModel model7 = new TypeAttributesModel { AttrId = attr.AttributeId, AttrValues = new List <TypeAttrValue>(), Name = attr.AttributesInfo.Name }; using (IEnumerator <AttributeValueInfo> enumerator5 = attr.AttributesInfo.AttributeValueInfo.GetEnumerator()) { while (enumerator5.MoveNext()) { Func <ProductAttributeInfo, bool> func8 = null; AttributeValueInfo attrV = enumerator5.Current; if (func8 == null) { func8 = p => p.ValueId == attrV.Id; } if (list3.Any <ProductAttributeInfo>(func8)) { TypeAttrValue value2 = new TypeAttrValue { Id = attrV.Id.ToString(), Name = attrV.Value }; model7.AttrValues.Add(value2); } } } list2.Add(model7); } else { if (func10 == null) { func10 = p => p.AttrId == attr.AttributeId; } TypeAttributesModel model9 = list2.FirstOrDefault <TypeAttributesModel>(func10); if (func11 == null) { func11 = p => p.Id == attr.ValueId.ToString(); } if (!model9.AttrValues.Any <TypeAttrValue>(func11)) { TypeAttrValue value3 = new TypeAttrValue { Id = attr.ValueId.ToString() }; if (func12 == null) { func12 = a => a.Id == attr.ValueId; } value3.Name = attr.AttributesInfo.AttributeValueInfo.FirstOrDefault <AttributeValueInfo>(func12).Value; model9.AttrValues.Add(value3); } } } } model.ProductAttrs = list2; IEnumerable <ProductCommentInfo> enumerable = Enumerable.Where <ProductCommentInfo>((IEnumerable <ProductCommentInfo>)product.Himall_ProductComments, (Func <ProductCommentInfo, bool>)(item => !item.IsHidden.HasValue || !item.IsHidden.Value)); int num11 = enumerable.Count <ProductCommentInfo>(); model.CommentCount = num11; IQueryable <ProductConsultationInfo> consultations = this._iConsultationService.GetConsultations(productId); model.Consultations = consultations.Count <ProductConsultationInfo>(); double num12 = num11; double num13 = enumerable.Count <ProductCommentInfo>(item => item.ReviewMark >= 4); model.NicePercent = (int)((num13 / num12) * 100.0); model.Consultations = consultations.Count <ProductConsultationInfo>(); if (this._iVShopService.GetVShopByShopId(shop.Id) == null) { model.VShopId = -1L; } else { model.VShopId = this._iVShopService.GetVShopByShopId(shop.Id).Id; } IQueryable <StatisticOrderCommentsInfo> shopStatisticOrderComments = this._iShopService.GetShopStatisticOrderComments(product.ShopId); StatisticOrderCommentsInfo info9 = (from c in shopStatisticOrderComments where ((int)c.CommentKey) == 1 select c).FirstOrDefault <StatisticOrderCommentsInfo>(); StatisticOrderCommentsInfo info10 = (from c in shopStatisticOrderComments where ((int)c.CommentKey) == 9 select c).FirstOrDefault <StatisticOrderCommentsInfo>(); StatisticOrderCommentsInfo info11 = (from c in shopStatisticOrderComments where ((int)c.CommentKey) == 5 select c).FirstOrDefault <StatisticOrderCommentsInfo>(); StatisticOrderCommentsInfo info12 = (from c in shopStatisticOrderComments where ((int)c.CommentKey) == 2 select c).FirstOrDefault <StatisticOrderCommentsInfo>(); StatisticOrderCommentsInfo info13 = (from c in shopStatisticOrderComments where ((int)c.CommentKey) == 10 select c).FirstOrDefault <StatisticOrderCommentsInfo>(); StatisticOrderCommentsInfo info14 = (from c in shopStatisticOrderComments where ((int)c.CommentKey) == 6 select c).FirstOrDefault <StatisticOrderCommentsInfo>(); StatisticOrderCommentsInfo info15 = (from c in shopStatisticOrderComments where ((int)c.CommentKey) == 3 select c).FirstOrDefault <StatisticOrderCommentsInfo>(); StatisticOrderCommentsInfo info16 = (from c in shopStatisticOrderComments where ((int)c.CommentKey) == 4 select c).FirstOrDefault <StatisticOrderCommentsInfo>(); StatisticOrderCommentsInfo info17 = (from c in shopStatisticOrderComments where ((int)c.CommentKey) == 11 select c).FirstOrDefault <StatisticOrderCommentsInfo>(); StatisticOrderCommentsInfo info18 = (from c in shopStatisticOrderComments where ((int)c.CommentKey) == 12 select c).FirstOrDefault <StatisticOrderCommentsInfo>(); StatisticOrderCommentsInfo info19 = (from c in shopStatisticOrderComments where ((int)c.CommentKey) == 7 select c).FirstOrDefault <StatisticOrderCommentsInfo>(); StatisticOrderCommentsInfo info20 = (from c in shopStatisticOrderComments where ((int)c.CommentKey) == 8 select c).FirstOrDefault <StatisticOrderCommentsInfo>(); decimal num14 = 5M; if (!(((info9 == null) || (info12 == null)) || shop.IsSelf)) { model.ProductAndDescription = info9.CommentValue; model.ProductAndDescriptionPeer = info12.CommentValue; model.ProductAndDescriptionMin = info16.CommentValue; model.ProductAndDescriptionMax = info15.CommentValue; } else { model.ProductAndDescription = num14; model.ProductAndDescriptionPeer = num14; model.ProductAndDescriptionMin = num14; model.ProductAndDescriptionMax = num14; } if (!(((info10 == null) || (info13 == null)) || shop.IsSelf)) { model.SellerServiceAttitude = info10.CommentValue; model.SellerServiceAttitudePeer = info13.CommentValue; model.SellerServiceAttitudeMax = info17.CommentValue; model.SellerServiceAttitudeMin = info18.CommentValue; } else { model.SellerServiceAttitude = num14; model.SellerServiceAttitudePeer = num14; model.SellerServiceAttitudeMax = num14; model.SellerServiceAttitudeMin = num14; } if (!(((info14 == null) || (info11 == null)) || shop.IsSelf)) { model.SellerDeliverySpeed = info11.CommentValue; model.SellerDeliverySpeedPeer = info14.CommentValue; model.SellerDeliverySpeedMax = (info19 != null) ? info19.CommentValue : 0M; model.sellerDeliverySpeedMin = (info20 != null) ? info20.CommentValue : 0M; } else { model.SellerDeliverySpeed = num14; model.SellerDeliverySpeedPeer = num14; model.SellerDeliverySpeedMax = num14; model.sellerDeliverySpeedMin = num14; } if ((base.CurrentUser != null) && (base.CurrentUser.Id > 0L)) { model2.IsFavorite = this._iProductService.IsFavorite(product.Id, base.CurrentUser.Id); } else { model2.IsFavorite = false; } VShopInfo vShopByShopId = this._iVShopService.GetVShopByShopId(shop.Id); if (vShopByShopId == null) { num15 = -1L; } else { num15 = vShopByShopId.Id; } model.VShopId = num15; model2.Shop.VShopId = num15; model2.VShopLog = this._iVShopService.GetVShopLog(model2.Shop.VShopId); if (string.IsNullOrWhiteSpace(model2.VShopLog)) { model2.VShopLog = base.CurrentSiteSetting.WXLogo; } model.Logined = (base.CurrentUser != null) ? 1 : 0; model2.EnabledBuy = (((product.AuditStatus == ProductInfo.ProductAuditStatus.Audited) && (DateTime.Parse(model3.BeginDate) <= DateTime.Now)) && (DateTime.Parse(model3.EndDate) > DateTime.Now)) && (product.SaleStatus == ProductInfo.ProductSaleStatus.OnSale); if (((model3.Status == FlashSaleInfo.FlashSaleStatus.Ongoing) && (DateTime.Parse(model3.BeginDate) < DateTime.Now)) && (DateTime.Parse(model3.EndDate) > DateTime.Now)) { span = new TimeSpan(DateTime.Parse(model3.EndDate).Ticks); span2 = new TimeSpan(DateTime.Now.Ticks); span3 = span.Subtract(span2); model.Second = (span3.TotalSeconds < 0.0) ? 0.0 : span3.TotalSeconds; } else if ((model3.Status == FlashSaleInfo.FlashSaleStatus.Ongoing) && (DateTime.Parse(model3.BeginDate) > DateTime.Now)) { span = new TimeSpan(DateTime.Parse(model3.BeginDate).Ticks); span2 = new TimeSpan(DateTime.Now.Ticks); span3 = span.Subtract(span2); model.Second = (span3.TotalSeconds < 0.0) ? 0.0 : span3.TotalSeconds; } ((dynamic)base.ViewBag).DetailModel = model; List <Himall.DTO.CustomerService> mobileCustomerService = CustomerServiceApplication.GetMobileCustomerService(model3.ShopId); Himall.DTO.CustomerService service = Enumerable.FirstOrDefault <Himall.DTO.CustomerService>((IEnumerable <Himall.DTO.CustomerService>)CustomerServiceApplication.GetPreSaleByShopId(model3.ShopId), (Func <Himall.DTO.CustomerService, bool>)(p => p.Tool == CustomerServiceInfo.ServiceTool.MeiQia)); if (service != null) { mobileCustomerService.Insert(0, service); } ((dynamic)base.ViewBag).CustomerServices = mobileCustomerService; StatisticApplication.StatisticVisitCount(product.Id, product.ShopId); return(base.View(model2)); }