コード例 #1
0
ファイル: ShopHandler.cs プロジェクト: huaminglee/myyyyshop
 private void IsExistSkuCode(HttpContext context)
 {
     string str = context.Request.Params["SKUCode"];
     JsonObject obj2 = new JsonObject();
     if (!string.IsNullOrWhiteSpace(str))
     {
         Maticsoft.BLL.Shop.Products.SKUInfo info = new Maticsoft.BLL.Shop.Products.SKUInfo();
         if (info.Exists(str))
         {
             obj2.Put("STATUS", "FAILED");
         }
         else
         {
             obj2.Put("STATUS", "SUCCESS");
         }
     }
     else
     {
         obj2.Put("STATUS", "ERROR");
     }
     context.Response.Write(obj2.ToString());
 }
コード例 #2
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());
 }
コード例 #3
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;
 }
コード例 #4
0
 public ActionResult SubmitOrder(string sku, int count = 1, int shippingTypeId = -1, int c = -1, string viewName = "SubmitOrder")
 {
     ShoppingCartInfo cartInfo = new ShoppingCartInfo();
     if (string.IsNullOrWhiteSpace(sku))
     {
         int userId = (base.currentUser == null) ? -1 : base.currentUser.UserID;
         cartInfo = new ShoppingCartHelper(userId).GetShoppingCart();
     }
     else
     {
         Maticsoft.BLL.Shop.Products.SKUInfo info2 = new Maticsoft.BLL.Shop.Products.SKUInfo();
         Maticsoft.BLL.Shop.Products.ProductInfo info3 = new Maticsoft.BLL.Shop.Products.ProductInfo();
         Maticsoft.Model.Shop.Products.SKUInfo modelBySKU = info2.GetModelBySKU(sku);
         if (modelBySKU == null)
         {
             return new RedirectResult("/Error");
         }
         Maticsoft.Model.Shop.Products.ProductInfo productInfo = info3.GetModel(modelBySKU.ProductId);
         if (productInfo == null)
         {
             return new RedirectResult("/Error");
         }
         Maticsoft.Model.Shop.Products.ProductInfo proSaleInfo = null;
         if (c > 0)
         {
             proSaleInfo = info3.GetProSaleModel(c);
             if (proSaleInfo == null)
             {
                 return new RedirectResult("/Error");
             }
             if (DateTime.Now > proSaleInfo.ProSalesEndDate)
             {
                 return base.RedirectToAction("ProSaleDetail", "Product", new { area = "Shop", id = c });
             }
         }
         cartInfo = this.GetCartInfo4SKU(productInfo, modelBySKU, count, proSaleInfo);
     }
     if (cartInfo.Items.Count < 1)
     {
         return (ActionResult) this.Redirect(((dynamic) base.ViewBag).BasePath + "ShoppingCart/CartInfo");
     }
     try
     {
         cartInfo = new SalesRuleProduct().GetWholeSale(cartInfo);
     }
     catch (Exception exception)
     {
         throw exception;
     }
     Maticsoft.Model.Shop.Shipping.ShippingType model = this._shippingTypeManage.GetModel(shippingTypeId);
     ((dynamic) base.ViewBag).Freight = cartInfo.CalcFreight(model);
     ((dynamic) base.ViewBag).TotalQuantity = cartInfo.Quantity;
     ((dynamic) base.ViewBag).TotalAdjustedPrice = cartInfo.TotalAdjustedPrice;
     ((dynamic) base.ViewBag).ProductTotal = cartInfo.TotalSellPrice;
     ((dynamic) base.ViewBag).TotalPrice = cartInfo.TotalAdjustedPrice + ((dynamic) base.ViewBag).Freight;
     ((dynamic) base.ViewBag).TotalPromPrice = cartInfo.TotalSellPrice - cartInfo.TotalAdjustedPrice;
     ((dynamic) base.ViewBag).Title = "提交订单";
     return base.View(viewName, cartInfo);
 }
コード例 #5
0
 public ActionResult ShowPayAndShip(int payId = -1, int shipId = -1, string sku = new string(), int count = 1, int c = -1, string viewName = "_ShowPayAndShip")
 {
     ShoppingCartInfo shoppingCart;
     PayAndShip model = new PayAndShip {
         ListPaymentMode = PaymentModeManage.GetPaymentModes()
     };
     if (payId > 0)
     {
         model.CurrentPaymentMode = PaymentModeManage.GetPaymentModeById(payId);
     }
     else if ((model.ListPaymentMode != null) && (model.ListPaymentMode.Count > 0))
     {
         model.CurrentPaymentMode = model.ListPaymentMode[0];
         model.ListShippingType = this._shippingTypeManage.GetListByPay(model.CurrentPaymentMode.ModeId);
     }
     else
     {
         PaymentModeInfo info = new PaymentModeInfo {
             ModeId = -1,
             Name = "未选择支付方式"
         };
         model.CurrentPaymentMode = info;
     }
     if (shipId > 0)
     {
         model.CurrentShippingType = this._shippingTypeManage.GetModelByCache(shipId);
     }
     else if ((model.ListShippingType != null) && (model.ListShippingType.Count > 0))
     {
         model.CurrentShippingType = model.ListShippingType[0];
     }
     else
     {
         Maticsoft.Model.Shop.Shipping.ShippingType type = new Maticsoft.Model.Shop.Shipping.ShippingType {
             ModeId = -1,
             Name = "未选择配送方式"
         };
         model.CurrentShippingType = type;
     }
     if (string.IsNullOrWhiteSpace(sku))
     {
         int userId = (base.currentUser == null) ? -1 : base.currentUser.UserID;
         shoppingCart = new ShoppingCartHelper(userId).GetShoppingCart();
     }
     else
     {
         Maticsoft.BLL.Shop.Products.SKUInfo info3 = new Maticsoft.BLL.Shop.Products.SKUInfo();
         Maticsoft.BLL.Shop.Products.ProductInfo info4 = new Maticsoft.BLL.Shop.Products.ProductInfo();
         Maticsoft.Model.Shop.Products.SKUInfo modelBySKU = info3.GetModelBySKU(sku);
         if (modelBySKU == null)
         {
             ((dynamic) base.ViewBag).Freight = 0;
             return base.View(viewName, model);
         }
         Maticsoft.Model.Shop.Products.ProductInfo productInfo = info4.GetModel(modelBySKU.ProductId);
         if (productInfo == null)
         {
             ((dynamic) base.ViewBag).Freight = 0;
             return base.View(viewName, model);
         }
         Maticsoft.Model.Shop.Products.ProductInfo proSaleInfo = null;
         if (c > 0)
         {
             proSaleInfo = info4.GetProSaleModel(c);
             if (proSaleInfo == null)
             {
                 ((dynamic) base.ViewBag).Freight = 0;
                 return base.View(viewName, model);
             }
         }
         shoppingCart = this.GetCartInfo4SKU(productInfo, modelBySKU, count, proSaleInfo);
     }
     ((dynamic) base.ViewBag).Freight = shoppingCart.CalcFreight(model.CurrentShippingType);
     return base.View(viewName, model);
 }
コード例 #6
0
 public ActionResult SubmitOrder(string sku, int count = 1, string viewName = "SubmitOrder")
 {
     if (!string.IsNullOrWhiteSpace(sku))
     {
         base.Session["SubmitOrder_SKU"] = sku;
         base.Session["SubmitOrder_COUNT"] = count;
     }
     else if (!string.IsNullOrWhiteSpace(base.Session["SubmitOrder_SKU"] as string))
     {
         sku = base.Session["SubmitOrder_SKU"] as string;
         count = Globals.SafeInt(base.Session["SubmitOrder_COUNT"], 1);
     }
     ((dynamic) base.ViewBag).SkuInfo = sku;
     ((dynamic) base.ViewBag).SkuCount = count;
     ShoppingCartInfo cartInfo = new ShoppingCartInfo();
     if (string.IsNullOrWhiteSpace(sku))
     {
         int userId = (base.currentUser == null) ? -1 : base.currentUser.UserID;
         cartInfo = new ShoppingCartHelper(userId).GetShoppingCart();
     }
     else
     {
         Maticsoft.BLL.Shop.Products.SKUInfo info2 = new Maticsoft.BLL.Shop.Products.SKUInfo();
         Maticsoft.BLL.Shop.Products.ProductInfo info3 = new Maticsoft.BLL.Shop.Products.ProductInfo();
         Maticsoft.Model.Shop.Products.SKUInfo modelBySKU = info2.GetModelBySKU(sku);
         if (modelBySKU == null)
         {
             return new RedirectResult("/Error");
         }
         Maticsoft.Model.Shop.Products.ProductInfo info5 = info3.GetModel(modelBySKU.ProductId);
         if (info5 == null)
         {
             return new RedirectResult("/Error");
         }
         ShoppingCartItem cartItem = new ShoppingCartItem {
             MarketPrice = info5.MarketPrice.HasValue ? info5.MarketPrice.Value : 0M,
             Name = info5.ProductName,
             Quantity = count,
             SellPrice = modelBySKU.SalePrice,
             AdjustedPrice = modelBySKU.SalePrice,
             SKU = modelBySKU.SKU,
             ProductId = modelBySKU.ProductId,
             UserId = base.currentUser.UserID
         };
         if (info5.SupplierId > 0)
         {
             Maticsoft.Model.Shop.Supplier.SupplierInfo modelByCache = new Maticsoft.BLL.Shop.Supplier.SupplierInfo().GetModelByCache(info5.SupplierId);
             if (modelByCache != null)
             {
                 cartItem.SupplierId = new int?(modelByCache.SupplierId);
                 cartItem.SupplierName = modelByCache.Name;
             }
         }
         List<Maticsoft.Model.Shop.Products.SKUItem> sKUItemsBySkuId = info2.GetSKUItemsBySkuId(modelBySKU.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 = info5.ThumbnailUrl1;
         cartItem.CostPrice = modelBySKU.CostPrice.HasValue ? modelBySKU.CostPrice.Value : 0M;
         cartItem.Weight = modelBySKU.Weight.HasValue ? modelBySKU.Weight.Value : 0;
         cartInfo.Items.Add(cartItem);
     }
     if (cartInfo.Items.Count < 1)
     {
         return (ActionResult) this.Redirect(((dynamic) base.ViewBag).BasePath + "ShoppingCart/CartInfo");
     }
     try
     {
         cartInfo = new SalesRuleProduct().GetWholeSale(cartInfo);
     }
     catch (Exception exception)
     {
         throw exception;
     }
     int modeId = Globals.SafeInt(base.Request.QueryString["shipId"], 0);
     Maticsoft.Model.Shop.Shipping.ShippingType model = this._shippingTypeManage.GetModel(modeId);
     ((dynamic) base.ViewBag).Freight = cartInfo.CalcFreight(model);
     ((dynamic) base.ViewBag).TotalQuantity = cartInfo.Quantity;
     ((dynamic) base.ViewBag).TotalAdjustedPrice = cartInfo.TotalAdjustedPrice;
     ((dynamic) base.ViewBag).TotalPrice = cartInfo.TotalAdjustedPrice + ((dynamic) base.ViewBag).Freight;
     ((dynamic) base.ViewBag).Title = "提交订单";
     return base.View(viewName, cartInfo);
 }