/// <summary> /// 判断商品库存是否满足 /// </summary> /// <param name="goodsInfoID">商品信息ID</param> /// <param name="OrderId">订单ID</param> /// <param name="num">下单商品库存数量</param> /// <returns>0、没有库存 1、返回商品库存数量,包括修改订单时,修改订单商品明细数量</returns> public static decimal GetInevntory(int goodsInfoID, int OrderId, decimal num) { decimal Inventory = 0; if (OrderId != 0) { //修改订单时,判断商品库存加上订单明细上的该商品数量 List <Hi.Model.DIS_OrderDetail> l = new Hi.BLL.DIS_OrderDetail().GetList("", " IsNull(dr,0)=0 and GoodsInfoID=" + goodsInfoID + " and OrderID=" + OrderId, ""); if (l != null && l.Count <= 0) { Inventory = 0; } else { Inventory = Convert.ToDecimal(l[0].GoodsNum.ToString()); } } Hi.Model.BD_GoodsInfo infoModel = new Hi.BLL.BD_GoodsInfo().GetModel(goodsInfoID); Inventory += infoModel.Inventory; if (num != 0 && Inventory < num) { return(0); } return(Inventory); }
/// <summary> /// 判断商品是否可下单成功 /// </summary> /// <param name="GoodsInfoID">下单商品ID</param> /// <param name="msg">提示信息</param> /// <returns>false:可以下单 true:不能下单</returns> public static bool GetGoodsInfo(int GoodsInfoID, out string msg) { msg = ""; Hi.Model.BD_GoodsInfo infoModel = new Hi.BLL.BD_GoodsInfo().GetModel(GoodsInfoID); if (infoModel != null) { if (infoModel.dr == 1) { msg = "商品已删除"; return(true); } else if (!infoModel.IsEnabled) { msg = "商品已禁用"; return(true); } else if (infoModel.IsOffline == 0) { msg = "商品已下架"; return(true); } return(false); } msg = "商品不存在"; return(true); }
/// <summary> /// 判断商品库存是否满足 /// </summary> /// <param name="goodsInfoID">商品信息ID</param> /// <param name="OrderId">订单ID</param> /// <param name="num">下单商品库存数量</param> /// <param name="Inventory">商品库存数量</param> /// <returns>false:可以下单 true:商品存库不足</returns> public static bool GetInevntory(int CompID, int goodsInfoID, int OrderId, decimal num, out string Inventory) { Inventory = "0"; int IsInve = Convert.ToInt32(rdoOrderAudit("商品是否启用库存", CompID)); if (IsInve == 0) { string Digits = rdoOrderAudit("订单下单数量是否取整", CompID); //启用库存 if (OrderId != 0) { //修改订单时,判断商品库存加上订单明细上的该商品数量 List <Hi.Model.DIS_OrderDetail> l = new Hi.BLL.DIS_OrderDetail().GetList("", " IsNull(dr,0)=0 and GoodsInfoID=" + goodsInfoID + " and OrderID=" + OrderId, ""); if (l != null && l.Count <= 0) { Inventory = "0"; } else { Inventory = (Convert.ToDecimal(l[0].GoodsNum.ToString()) + Convert.ToDecimal(l[0].ProNum.ToString())).ToString(); } } Hi.Model.BD_GoodsInfo infoModel = new Hi.BLL.BD_GoodsInfo().GetModel(goodsInfoID); Inventory = (Convert.ToDecimal(Inventory) + infoModel.Inventory).ToString(); Inventory = decimal.Parse(string.Format("{0:N2}", Inventory)).ToString(Digits); if (num != 0 && Convert.ToDecimal(Inventory) < num) { return(true); } return(false); } else { return(false); } }
/// <summary> /// 查询商品基本价格 /// </summary> /// <param name="CompID">核心企业ID</param> /// <param name="disInfoID">商品ID</param> /// <returns></returns> public static List <gDprice> GetgDprice(int CompID, string disInfoID) { List <gDprice> g = new List <gDprice>(); //不存在经销商分类、区域的商品价格,查询商品基本价格 List <Hi.Model.BD_GoodsInfo> infol = new Hi.BLL.BD_GoodsInfo().GetList("", "isnull(IsOffline,0)=1 and isnull(dr,0)=0 and isnull(IsEnabled,0)=1 and CompID=" + CompID + " and ID in(" + disInfoID + ")", ""); if (infol != null && infol.Count > 0) { foreach (var item in infol) { gDprice gd = new gDprice(); gd.goodsInfoId = item.ID; gd.FinalPrice = item.TinkerPrice; g.Add(gd); } } else { return(g); } return(g); }