コード例 #1
0
ファイル: ShopHandler.cs プロジェクト: huaminglee/myyyyshop
 private void ProductSkuInfo(HttpContext context)
 {
     JsonObject obj2 = new JsonObject();
     string str = context.Request.Params["pid"];
     if (!string.IsNullOrWhiteSpace(str))
     {
         long productId = Globals.SafeLong(str, (long) (-1L));
         List<Maticsoft.Model.Shop.Products.SKUInfo> productSkuInfo = new Maticsoft.BLL.Shop.Products.SKUInfo().GetProductSkuInfo(productId);
         if ((productSkuInfo != null) && (productSkuInfo.Count > 0))
         {
             JsonArray data = new JsonArray();
             productSkuInfo.ForEach(delegate (Maticsoft.Model.Shop.Products.SKUInfo info) {
                 data.Add(new JsonObject(new string[] { "SkuId", "ProductId", "SKU", "Weight", "Stock", "AlertStock", "CostPrice", "SalePrice", "Upselling" }, new object[] { info.SkuId, info.ProductId, info.SKU, info.Weight, info.Stock, info.AlertStock, info.CostPrice, info.SalePrice, info.Upselling }));
             });
             obj2.Put("STATUS", "SUCCESS");
             obj2.Put("DATA", data);
         }
         else
         {
             obj2.Put("STATUS", "FAILED");
         }
     }
     else
     {
         obj2.Put("STATUS", "FAILED");
     }
     context.Response.Write(obj2.ToString());
 }
コード例 #2
0
 private ShoppingCartInfo GetCartInfo4SKU(Maticsoft.Model.Shop.Products.ProductInfo productInfo, Maticsoft.Model.Shop.Products.SKUInfo skuInfo, int quantity, Maticsoft.Model.Shop.Products.ProductInfo proSaleInfo)
 {
     ShoppingCartInfo info = new ShoppingCartInfo();
     ShoppingCartItem cartItem = new ShoppingCartItem {
         MarketPrice = productInfo.MarketPrice.HasValue ? productInfo.MarketPrice.Value : 0M,
         Name = productInfo.ProductName,
         Quantity = (quantity < 1) ? 1 : quantity,
         SellPrice = skuInfo.SalePrice,
         AdjustedPrice = skuInfo.SalePrice,
         SKU = skuInfo.SKU,
         ProductId = skuInfo.ProductId,
         UserId = base.currentUser.UserID
     };
     if (proSaleInfo != null)
     {
         cartItem.AdjustedPrice = proSaleInfo.ProSalesPrice;
     }
     if (productInfo.SupplierId > 0)
     {
         Maticsoft.Model.Shop.Supplier.SupplierInfo modelByCache = new Maticsoft.BLL.Shop.Supplier.SupplierInfo().GetModelByCache(productInfo.SupplierId);
         if (modelByCache != null)
         {
             cartItem.SupplierId = new int?(modelByCache.SupplierId);
             cartItem.SupplierName = modelByCache.Name;
         }
     }
     List<Maticsoft.Model.Shop.Products.SKUItem> sKUItemsBySkuId = new Maticsoft.BLL.Shop.Products.SKUInfo().GetSKUItemsBySkuId(skuInfo.SkuId);
     if ((sKUItemsBySkuId != null) && (sKUItemsBySkuId.Count > 0))
     {
         cartItem.SkuValues = new string[sKUItemsBySkuId.Count];
         int index = 0;
         sKUItemsBySkuId.ForEach(delegate (Maticsoft.Model.Shop.Products.SKUItem xx) {
             cartItem.SkuValues[index++] = xx.ValueStr;
             if (!string.IsNullOrWhiteSpace(xx.ImageUrl))
             {
                 cartItem.SkuImageUrl = xx.ImageUrl;
             }
         });
     }
     cartItem.ThumbnailsUrl = productInfo.ThumbnailUrl1;
     cartItem.CostPrice = skuInfo.CostPrice.HasValue ? skuInfo.CostPrice.Value : 0M;
     cartItem.Weight = skuInfo.Weight.HasValue ? skuInfo.Weight.Value : 0;
     info.Items.Add(cartItem);
     return info;
 }