コード例 #1
0
ファイル: Common.cs プロジェクト: kkwkk/ybyzt
        /// <summary>
        /// 获取商品最新价格
        /// </summary>
        /// <param name="CompID">核心企业ID</param>
        /// <param name="DisID">经销商ID</param>
        /// <param name="GoodsInfoID">商品ID</param>
        /// <returns></returns>
        public static List <gDprice> GetPrice(int CompID, int DisID, List <int> infoIDl)
        {
            List <gDprice> g  = new List <gDprice>();
            gDprice        gd = null;

            try
            {
                var disInfoID = string.Empty;

                //判断是否存在商品ID
                if (infoIDl != null && infoIDl.Count > 0)
                {
                    var    infoID = string.Join(",", infoIDl);
                    string sql    = "select * from dbo.GetGoodsInfoPrice(" + DisID + "," + CompID + ",'" + infoID + "')";

                    DataTable dt = SqlHelper.Query(SqlHelper.LocalSqlServer, sql.ToString()).Tables[0];

                    if (dt != null && dt.Rows.Count > 0)
                    {
                        foreach (DataRow item in dt.Rows)
                        {
                            gd             = new gDprice();
                            gd.goodsInfoId = int.Parse(item["GoodsInfoID"].ToString());
                            //经销商价格
                            gd.disPrice = decimal.Parse(item["disPrice"].ToString());
                            //经销商分类、区域价格
                            gd.typePrice = decimal.Parse(item["typePrice"].ToString());
                            //促销价格
                            gd.bpPrice = decimal.Parse(item["BpPrice"].ToString());
                            //最终价
                            gd.FinalPrice = decimal.Parse(item["finalPrice"].ToString());
                            g.Add(gd);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(g);
        }
コード例 #2
0
ファイル: Common.cs プロジェクト: kkwkk/ybyzt
        /// <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);
        }
コード例 #3
0
ファイル: Common.cs プロジェクト: kkwkk/ybyzt
        /// <summary>
        /// 获取商品最新价格
        /// </summary>
        /// <param name="CompID">核心企业ID</param>
        /// <param name="DisID">经销商ID</param>
        /// <param name="GoodsInfoID">商品ID</param>
        /// <returns></returns>
        public static List <gDprice> GetGoodsPrice(int CompID, int DisID, List <int> infoIDl)
        {
            //返回
            List <gDprice> g  = new List <gDprice>();
            gDprice        gd = null;

            try
            {
                //没有设置经销商商品价格的商品ID
                var disInfoID = string.Empty;

                //判断是否存在商品ID
                if (infoIDl != null && infoIDl.Count > 0)
                {
                    var infoID = string.Join(",", infoIDl);

                    //经销商品查询
                    Hi.Model.BD_Distributor disModel = new Hi.BLL.BD_Distributor().GetModel(DisID);

                    //判断经销商信息是否正确
                    if (disModel == null)
                    {
                        return(g);
                    }

                    //查询经销商品价格
                    List <Hi.Model.BD_GoodsPrice> disPrice = new Hi.BLL.BD_GoodsPrice().GetList("", " isnull(dr,0)=0 and isnull(IsEnabled,0)=1 and CompID=" + CompID + " and DisID=" + DisID + " and GoodsInfoID in (" + infoID + ")", "");

                    if (disPrice != null && disPrice.Count > 0)
                    {
                        //存在经销商品价格
                        foreach (var item in disPrice)
                        {
                            //删除已查询出商品价格的商品ID
                            if (infoIDl.Contains(item.GoodsInfoID))
                            {
                                infoIDl.Remove(item.GoodsInfoID);
                            }

                            gd             = new gDprice();
                            gd.goodsInfoId = item.GoodsInfoID;
                            gd.FinalPrice  = item.TinkerPrice;
                            g.Add(gd);
                        }
                    }
                    else
                    {
                        disInfoID = infoID;
                    }

                    //disInfoID为空时,将 List<int>转为字符串且infoIDl存在参数
                    if (infoIDl.Count > 0)
                    {
                        disInfoID = string.Join(",", infoIDl);
                    }
                    else
                    {
                        return(g);
                    }

                    //查询经销商分类、区域价格主表
                    List <Hi.Model.BD_DisPrice> ll = new List <Hi.Model.BD_DisPrice>();
                    List <Hi.Model.BD_DisPrice> l  = new Hi.BLL.BD_DisPrice().GetList("", "isnull(dr,0)=0 and isnull(Type,0)!=0 and isnull(IsEnabled,0)=1 and CompID=" + CompID, "");

                    if (l != null && l.Count > 0)
                    {
                        //1、分类  2、区域
                        int priceType = l[0].Type;
                        //查询BD_DisPrice条件
                        StringBuilder str = new StringBuilder();

                        if (priceType == 1)
                        {
                            #region 经销商分类
                            //经销商分类
                            string   typeId = string.Empty;
                            string[] typeT  = { };

                            //查询经销商分类
                            if (disModel.DisTypeID != 0)
                            {
                                typeId = DisTypeId(disModel.DisTypeID, CompID, "");
                            }
                            else
                            {
                                //没有经销商分类,查询商品基本价格
                                List <gDprice> ggl = GetgDprice(CompID, disInfoID);
                                if (ggl != null && ggl.Count > 0)
                                {
                                    foreach (var item in ggl)
                                    {
                                        g.Add(item);
                                    }
                                }
                                return(g);
                            }

                            if (typeId.Length > 0)
                            {
                                typeT = typeId.Split(new char[] { ',' });
                            }

                            //经销商分类
                            if (typeT.Length - 1 == 1)
                            {
                                str.Append("Type=" + priceType + " and (One=" + typeT[0] + " and Two=0 and Three=0)");
                            }
                            else if (typeT.Length - 1 == 2)
                            {
                                str.Append("Type=" + priceType + " and ((One=" + typeT[0] + " and Two=0 and Three=0) or (One=" + typeT[0] + " and Two=" + typeT[1] + " and Three=0))");
                            }
                            else if (typeT.Length - 1 == 3)
                            {
                                str.Append("Type=" + priceType + " and ((One=" + typeT[0] + " and Two=0 and Three=0) or (One=" + typeT[0] + " and Two=" + typeT[1] + " and Three=0) or (One=" + typeT[0] + " and Two=" + typeT[1] + " and Three=" + typeT[2] + "))");
                            }

                            #endregion
                        }
                        else if (priceType == 2)
                        {
                            #region 经销商区域

                            //经销商区域
                            string   areaId = string.Empty;
                            string[] areaA  = { };
                            //查询经销商区域
                            if (disModel.AreaID != 0)
                            {
                                areaId = DisAreaId(disModel.AreaID, CompID, "");
                            }
                            else
                            {
                                //没有经销商区域,查询商品基本价格
                                List <gDprice> ggl = GetgDprice(CompID, disInfoID);
                                if (ggl != null && ggl.Count > 0)
                                {
                                    foreach (var item in ggl)
                                    {
                                        g.Add(item);
                                    }
                                }
                                return(g);
                            }

                            if (areaId.Length > 0)
                            {
                                areaA = areaId.Split(new char[] { ',' });
                            }

                            //经销商区域
                            if (areaA.Length - 1 == 1)
                            {
                                str.Append("Type=" + priceType + " and One=" + areaA[0] + " and Two=0 and Three=0");
                            }
                            else if (areaA.Length - 1 == 2)
                            {
                                str.Append("Type=" + priceType + " and ((One=" + areaA[0] + " and Two=0 and Three=0) or (One=" + areaA[0] + " and Two=" + areaA[1] + " and Three=0))");
                            }
                            else if (areaA.Length - 1 == 3)
                            {
                                str.Append("Type=" + priceType + " and ((One=" + areaA[0] + " and Two=0 and Three=0) or (One=" + areaA[0] + " and Two=" + areaA[1] + " and Three=0) or (One=" + areaA[0] + " and Two=" + areaA[1] + " and Three=" + areaA[2] + "))");
                            }

                            #endregion
                        }

                        //查询设置的商品价格
                        ll = new Hi.BLL.BD_DisPrice().GetList("", "isnull(dr,0)=0 and isnull(IsEnabled,0)=1 and " + str.ToString() + " and CompID=" + CompID, "");
                        if (ll != null && ll.Count > 0)
                        {
                            //存在经销商分类、区域的商品价格,取出其价格
                            string pId = string.Empty;
                            foreach (var item in ll)
                            {
                                pId += item.ID + ",";
                            }

                            if (pId.Length > 0)
                            {
                                pId = pId.Substring(0, pId.Length - 1);
                            }

                            List <Hi.Model.BD_DisPriceInfo> pinfol = new Hi.BLL.BD_DisPriceInfo().GetList("", " CompID=" + CompID + " and GoodsInfoID in(" + disInfoID + ")", "");

                            if (pinfol != null && pinfol.Count > 0)
                            {
                                foreach (var item in pinfol)
                                {
                                    //删除已查询出商品价格的商品ID
                                    if (infoIDl.Contains(item.GoodsInfoID))
                                    {
                                        infoIDl.Remove(item.GoodsInfoID);
                                    }

                                    gd             = new gDprice();
                                    gd.goodsInfoId = item.GoodsInfoID;
                                    gd.FinalPrice  = item.TinkerPrice;
                                    g.Add(gd);
                                }

                                //disInfoID为空时,将 List<int>转为字符串且infoIDl存在参数
                                if (infoIDl.Count > 0)
                                {
                                    disInfoID = string.Join(",", infoIDl);
                                }
                                else
                                {
                                    return(g);
                                }

                                //不存在经销商分类、区域的商品价格,查询商品基本价格
                                List <gDprice> ggl = GetgDprice(CompID, disInfoID);
                                if (ggl != null && ggl.Count > 0)
                                {
                                    foreach (var item in ggl)
                                    {
                                        g.Add(item);
                                    }
                                }
                            }
                            else
                            {
                                //不存在经销商分类、区域的商品价格,查询商品基本价格
                                List <gDprice> ggl = GetgDprice(CompID, disInfoID);
                                if (ggl != null && ggl.Count > 0)
                                {
                                    foreach (var item in ggl)
                                    {
                                        g.Add(item);
                                    }
                                }
                            }
                        }
                        else
                        {
                            //不存在经销商分类、区域的商品价格,查询商品基本价格
                            List <gDprice> ggl = GetgDprice(CompID, disInfoID);
                            if (ggl != null && ggl.Count > 0)
                            {
                                foreach (var item in ggl)
                                {
                                    g.Add(item);
                                }
                            }
                        }
                    }
                    else
                    {
                        //不存在经销商分类、区域的商品价格,查询商品基本价格
                        List <gDprice> ggl = GetgDprice(CompID, disInfoID);
                        if (ggl != null && ggl.Count > 0)
                        {
                            foreach (var item in ggl)
                            {
                                g.Add(item);
                            }
                        }
                    }
                }
                else
                {
                    return(g);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(g);
        }