/// <summary> /// 商品价格 /// </summary> public void ProducePrice() { int id = RequestTool.RequestInt("id"); int count = RequestTool.RequestInt("count", 1); Lebi_Product product = GetProduct(id); decimal price = EX_Product.ProductPrice(product, CurrentUserLevel, CurrentUser, count); Response.Write(FormatMoney(price)); }
/// <summary> /// 添加或修改 /// 收藏141或 /// 购物车142 /// 浏览历史143 /// </summary> public void UserProduct_Edit() { int t = RequestTool.RequestInt("type", 141); //默认收藏 int num = RequestTool.RequestInt("num", 1); //默认数量1 int pid = RequestTool.RequestInt("pid", 0); if (t != 142) { num = 1; } if (num <= 0) { num = 1; } string property = RequestTool.RequestSafeString("property"); string propertypriceids = RequestTool.RequestSafeString("propertypriceids"); int warndays = RequestTool.RequestInt("warndays", 0); string mes = ""; if (t != 141 && t != 142 && t != 143 && t != 144) { Response.Write("{\"msg\":\"OK\"}"); return; } if ((t == 141 || t == 144) && CurrentUser.id == 0) { Response.Write("{\"msg\":\"" + Tag("请先登陆") + "\",\"url\":\"" + URL("P_Login", "") + "\"}"); return; } //<-{ 判断是否上架状态 by lebi.kingdge 2015-02-10 Lebi_Product pro = B_Lebi_Product.GetModel("id = " + pid + ""); if (pro == null) { return; } if (t == 142) { int levelcount = ProductLevelCount(pro); if (num < levelcount) { num = levelcount; Response.Write("{\"msg\":\"" + Lang(pro.Name) + " " + Tag("起订量") + " " + levelcount + "\"}"); return; } } if (pro.Type_id_ProductStatus != 101) { Response.Write("{\"msg\":\"" + Lang(pro.Name) + " " + Tag("该商品已经下架") + "\"}"); return; } if (ProductStock(pro) < 1 && pro.Type_id_ProductType != 324 && SYS.IsNullStockSale != "1") { Response.Write("{\"msg\":\"" + Lang(pro.Name) + " " + Tag("该商品已经售罄") + "\"}"); return; } if ((pro.Type_id_ProductType == 321 || pro.Type_id_ProductType == 322) & (System.DateTime.Now < pro.Time_Start)) { Response.Write("{\"msg\":\"" + Lang(pro.Name) + " " + Tag("尚未开始") + "\"}"); return; } if ((pro.Type_id_ProductType == 321 || pro.Type_id_ProductType == 322) & (System.DateTime.Now > pro.Time_Expired)) { Response.Write("{\"msg\":\"" + Lang(pro.Name) + " " + Tag("已结束") + "\"}"); return; } if (CurrentUserLevel.BuyRight == 0 && t == 142) { Response.Write("{\"msg\":\"" + Lang(pro.Name) + " " + Tag("无权购买") + "\"}"); return; } if (EX_Product.ProductPrice(pro, CurrentUserLevel, CurrentUser) < 0 && t == 142) { Response.Write("{\"msg\":\"" + Lang(pro.Name) + " " + Tag("无权购买") + "\"}"); return; } //用户的商品权限 if (Shop.LebiAPI.Service.Instanse.Check("plugin_productlimit") && t == 142) { if (SYS.ProductLimitType == "1")//选择表允许 { int lc = B_Lebi_Product_Limit.Counts("(Product_id=" + pro.id + " or Product_id=" + pro.Product_id + ") and User_id=" + CurrentUser.id + " and IsShow=1 and IsPriceShow=1 and IsBuy=1"); if (lc == 0) { lc = B_Lebi_Product_Limit.Counts("(Product_id=" + pro.id + " or Product_id=" + pro.Product_id + ") and UserLevel_id=" + CurrentUserLevel.id + " and IsShow=1 and IsPriceShow=1 and IsBuy=1"); if (lc > 0) { Response.Write("{\"msg\":\"" + Lang(pro.Name) + " " + Tag("无权购买") + "\"}"); return; } } } else { int lc = B_Lebi_Product_Limit.Counts("(Product_id=" + pro.id + " or Product_id=" + pro.Product_id + ") and User_id=" + CurrentUser.id + " and IsShow=1 and IsPriceShow=1 and IsBuy=1"); if (lc == 0) { lc = B_Lebi_Product_Limit.Counts("(Product_id=" + pro.id + " or Product_id=" + pro.Product_id + ") and UserLevel_id=" + CurrentUserLevel.id + " and IsShow=1 and IsPriceShow=1 and IsBuy=1"); if (lc > 0) { Response.Write("{\"msg\":\"" + Lang(pro.Name) + " " + Tag("无权购买") + "\"}"); return; } } else { Response.Write("{\"msg\":\"" + Lang(pro.Name) + " " + Tag("无权购买") + "\"}"); return; } } } //if (!("," + pro.UserLevel_ids_buy + ",").Contains("," + CurrentUserLevel.id + ",") && pro.UserLevel_ids_buy != "" && t == 142) //{ // Response.Write("{\"msg\":\"" + Lang(pro.Name) + " " + Tag("无权购买") + "\"}"); // return; //} //}-> EX_User.UserProduct_Edit(CurrentUser, pid, num, t, property, warndays, propertypriceids); if (t == 141) { mes = Tag("商品已加入收藏夹"); } else if (t == 144) { mes = Tag("商品已加入常购清单"); } else { Basket basket = new Basket(0); mes = Tag("商品已加入购物车") + "<div>" + Tag("数量") + " <span>" + basket.Count + "</span> " + Tag("件") + " <span>" + FormatMoney(basket.Money_Product) + "</span></div><div><a href='" + URL("P_Basket", "") + "' class='btn btn-7'><s></s>" + Tag("查看购物车") + "</a> <a href='javascript:void(0)' onclick='cloesedialog();' class='btn btn-11'><s></s>" + Tag("关闭") + "</a></div>"; } Response.Write("{\"msg\":\"OK\",\"count\":\"" + Basket_Product_Count() + "\",\"amount\":\"" + FormatMoney(Basket_Product_Price()) + "\",\"mes\":\"" + mes + "\",\"url\":\"" + URL("P_AddToBasket", "") + "\"}"); }
public decimal Money_Tax = 0; //税金 /// <summary> /// sid=0,取得全部供应商的商品 /// </summary> /// <param name="type"></param> public Basket(int sid) { Products = Basket.UserProduct(CurrentUser, 142); PromotionTypes = new List <Lebi_Promotion_Type>(); FreeProducts = new List <Lebi_User_Product>(); Shops = new List <BasketShop>(); List <BasketShop> tempShops = new List <BasketShop>(); List <string> brandstring = new List <string>(); foreach (Lebi_User_Product pro in Products) { try { Lebi_Product product = B_Lebi_Product.GetModel(pro.Product_id); if (product == null) { continue; } bool ishavebrand = false; for (int i = 0; i < brandstring.Count(); i++) { if (brandstring[i].Contains(product.Brand_id.ToString() + ":")) { brandstring[i] += "," + pro.Product_id; ishavebrand = true; break; } } if (!ishavebrand) { brandstring.Add(product.Brand_id.ToString() + ":" + pro.Product_id); } if (product.Type_id_ProductType == 324) //预定商品 { pro.Product_Price = product.Price_reserve; //预定金额 } else { pro.Product_Price = EX_Product.ProductPrice(product, CurrentUserLevel, CurrentUser, pro.count);//单价 } //<-{计算品牌不含税商品总额 by lebi.kingdge 2015-08-22 Lebi_Brand brand = B_Lebi_Brand.GetModel(product.Brand_id); if (brand != null) { if (brand.IsVAT == 0) { Money_Product_NOVAT += pro.Product_Price * pro.count; } } //}-> Lebi_Supplier shop = B_Lebi_Supplier.GetModel(product.Supplier_id); if (shop == null) { product.Supplier_id = 0; //容错,商品供应商删除时,商城发货 shop = new Lebi_Supplier(); //自营商品 } else { if (shop.IsSupplierTransport == 0)//商城代发货的情况 { product.Supplier_id = 0; shop = new Lebi_Supplier();//自营商品 } } BasketShop bshop = (from m in tempShops where m.Shop.id == product.Supplier_id select m).ToList().FirstOrDefault(); if (bshop == null) { if (product.Supplier_id == 0) { //shop = new Lebi_Supplier();//自营商品 bshop = new BasketShop(); bshop.Shop = shop; bshop.Products = new List <Lebi_User_Product>(); tempShops.Add(bshop); } else { bshop = new BasketShop(); bshop.Shop = shop; bshop.Products = new List <Lebi_User_Product>(); tempShops.Add(bshop); } } (from m in tempShops where m.Shop.id == product.Supplier_id select m).ToList().FirstOrDefault().Products.Add(pro); } catch (System.NullReferenceException) { } } tempShops = tempShops.OrderBy(a => a.Shop.id).ToList(); if (SYS.IsSupplierCash == "1") { if (sid == 0) { sid = RequestTool.RequestInt("sid"); } if (sid == 0) { string tempid = CookieTool.GetCookieString("supplier"); int.TryParse(tempid, out sid); } cashsupplierid = sid; bool flag = false; foreach (BasketShop shop in tempShops) { if (shop.Shop.IsCash == 1) { IsMutiCash = true; } if (shop.Shop.id == cashsupplierid) { flag = true; } } if (!flag) { try { cashsupplierid = tempShops.FirstOrDefault().Shop.id; } catch { cashsupplierid = 0; } } if (sid > 0) { //只保留当前结算供应商的数据 List <int> ids = new List <int>(); for (int i = 0; i < tempShops.Count; i++) { if (tempShops[i].Shop.id == cashsupplierid) { Shops.Add(tempShops[i]); } } } else { Shops = tempShops; } } else { Shops = tempShops; } Products = new List <Lebi_User_Product>(); for (int i = 0; i < Shops.Count; i++) { Shops[i] = SetMoneyAndPoint(CurrentUser, CurrentUserLevel, Shops[i]); Weight += Shops[i].Weight; Volume += Shops[i].Volume; Money_Product += Shops[i].Money_Product; Money_Product_begin += Shops[i].Money_Product_begin; Money_Property += Shops[i].Money_Property; Money_Cut += Shops[i].Money_Cut; Money_Give += Shops[i].Money_Give; Money_Market += Shops[i].Money_Market; Count += Shops[i].Count; Point += Shops[i].Point; Point_Buy += Shops[i].Point_Buy; Point_Product += Shops[i].Point_Product; Point_Free += Shops[i].Point_Free; FreeProducts.AddRange(Shops[i].FreeProducts); PromotionTypes.AddRange(Shops[i].PromotionTypes); Products.AddRange(Shops[i].Products); } //<-{退税计算 by lebi.kingdge 2015-08-22 decimal Refund_MinMoney = 0; decimal Refund_VAT = 0; decimal.TryParse(SYS.Refund_MinMoney, out Refund_MinMoney); decimal.TryParse(SYS.Refund_VAT, out Refund_VAT); if (Refund_MinMoney > 0) { if ((Money_Product - Money_Product_NOVAT) > Refund_MinMoney) { Money_Refund_VAT = (Money_Product - Money_Product_NOVAT) * Refund_VAT / 100; Money_Refund_Fee = Refund_Fee(SYS.Refund_StepR, Money_Refund_VAT, Money_Product - Money_Product_NOVAT); Money_Refund = Money_Refund_VAT - Money_Refund_Fee; } else { Money_Refund = 0; Money_Refund_VAT = 0; Money_Refund_Fee = 0; } //循环品牌计算各品牌退税 if (Refund_VAT > 0) { foreach (string bran in brandstring) { string[] arr = bran.Split(':'); Lebi_Brand brand = B_Lebi_Brand.GetModel("id=" + arr[0] + " and IsVAT = 1"); if (brand != null) { decimal Brand_Money_Product = 0; decimal OtherSite_Money_Refund_VAT = 0; decimal OtherSite_Money_Refund_Fee = 0; List <Lebi_User_Product> user_products = (from m in Products where ("," + arr[1] + ",").Contains("," + m.Product_id + ",") select m).ToList(); foreach (Lebi_User_Product user_product in user_products) { Brand_Money_Product += user_product.Product_Price * user_product.count; } if (Brand_Money_Product >= Refund_MinMoney) { OtherSite_Money_Refund_VAT = Brand_Money_Product * Refund_VAT / 100; OtherSite_Money_Refund_Fee = Refund_Fee(SYS.Refund_StepR, OtherSite_Money_Refund_VAT, Brand_Money_Product); OtherSite_Money_Refund += OtherSite_Money_Refund_VAT - OtherSite_Money_Refund_Fee; } } } } } //}-> //<-{税金计算 by lebi.kingdge 2017-02-17 decimal TaxRate = 0; decimal.TryParse(SYS.TaxRate, out TaxRate); if (TaxRate > 0) { Money_Tax = Money_Product * TaxRate / 100; } //}-> }
public decimal ProductPrice(Lebi_Product pro) { return(EX_Product.ProductPrice(pro, CurrentUserLevel)); }