示例#1
0
 /// <summary>
 /// 获取代理商价格
 /// </summary>
 /// <returns></returns>
 public string GetPrice(string id, string price)
 {
     if (!Util.IsEmpty(this.ddlDisList.SelectedValue.Trim()))
     {
         List <Hi.Model.BD_GoodsPrice> l = new Hi.BLL.BD_GoodsPrice().GetList("", "isnull(dr,0)=0 and isenabled=1 and disid=" + this.ddlDisList.SelectedValue.Trim() + " and compid=" + this.CompID + " and goodsinfoid=" + id, "");
         if (l.Count > 0)
         {
             return(l[0].TinkerPrice.ToString());
         }
         else
         {
             Hi.Model.BD_GoodsInfo lll = new Hi.BLL.BD_GoodsInfo().GetModel(Convert.ToInt32(id));
             if (lll != null)
             {
                 return(lll.TinkerPrice.ToString());
             }
             else
             {
                 return(price);
             }
         }
     }
     else
     {
         return(price);
     }
 }
示例#2
0
    /// <summary>
    /// 新增
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        SqlTransaction Tran = null;

        try
        {
            Tran = DBUtility.SqlHelper.CreateStoreTranSaction();
            List <Hi.Model.BD_GoodsPrice> llll  = new List <Hi.Model.BD_GoodsPrice>(); //修改
            List <Hi.Model.BD_GoodsPrice> llll2 = new List <Hi.Model.BD_GoodsPrice>(); //新增
            string[] disIdList = Request["lblDisId"].Split(',');                       // this.hidDisId.Value.Trim();//代理商列表
            string[] priceList = Request["txtPrice"].Split(',');                       //价格
            for (int i = 0; i < disIdList.Length; i++)
            {
                List <Hi.Model.BD_GoodsPrice> lll = new Hi.BLL.BD_GoodsPrice().GetList("", "isnull(dr,0)=0 and isenabled=1 and disid = " + disIdList[i] + "and compid=" + this.CompID + " and  goodsinfoid=" + goodsInfoId, "", Tran);
                if (lll.Count > 0)
                {
                    foreach (Hi.Model.BD_GoodsPrice item2 in lll)
                    {
                        item2.IsEnabled  = false;
                        item2.modifyuser = this.UserID;
                        item2.ts         = DateTime.Now;
                        item2.CompID     = this.CompID;
                        llll.Add(item2);
                    }
                }
                //新增
                Hi.Model.BD_GoodsPrice model3 = new Hi.Model.BD_GoodsPrice();
                //model3.DisPriceID = 0;
                model3.DisID        = Convert.ToInt32(disIdList[i]);
                model3.CompID       = this.CompID;
                model3.GoodsInfoID  = goodsInfoId;
                model3.TinkerPrice  = Convert.ToDecimal(priceList[i]);
                model3.IsEnabled    = true;
                model3.CreateUserID = this.UserID;
                model3.CreateDate   = DateTime.Now;
                model3.ts           = DateTime.Now;
                model3.modifyuser   = this.UserID;
                llll2.Add(model3);
            }
            new Hi.BLL.BD_GoodsPrice().Update(llll, Tran);
            new Hi.BLL.BD_GoodsPrice().Add(llll2, Tran);
            Tran.Commit();
            ClientScript.RegisterStartupScript(this.GetType(), "msg2", "<script>$(function(){ window.parent.layerCommon.layerClose('hid_Alert');})</script>");
        }
        catch (Exception)
        {
            if (Tran != null)
            {
                if (Tran.Connection != null)
                {
                    Tran.Rollback();
                }
            }
            JScript.AlertMethod(this, "价格调整失败", JScript.IconOption.错误);
            return;
        }
    }
示例#3
0
    /// <summary>
    /// 最新价格
    /// </summary>
    /// <returns></returns>
    public string GoodsTinkerPrice(int id, string disId, string saleprice, int type)
    {
        string price = string.Empty;

        if (type == 1)
        {
            price = decimal.Parse(string.Format("{0:N2}", Convert.ToDecimal(saleprice.ToString()).ToString())).ToString("#,##0.00");
        }
        else
        {
            price = decimal.Parse(string.Format("{0:N2}", Convert.ToDecimal(saleprice.ToString()).ToString())).ToString("0.00");
        }
        if (disId.Split(',').Length == 1)
        {
            //List<Hi.Model.BD_DisPrice> ll = new Hi.BLL.BD_DisPrice().GetList("", "isnull(dr,0)=0 and isenabled=1 and compid=" + CompID + " and disids   like '%" + disId + "%'", " id desc");
            //if (ll.Count > 0)
            //{
            //    string disIdlist = string.Empty;
            //    foreach (Hi.Model.BD_DisPrice item in ll)
            //    {
            //        disIdlist += item.ID + ",";
            //    }
            List <Hi.Model.BD_GoodsPrice> l = new Hi.BLL.BD_GoodsPrice().GetList("", "isnull(dr,0)=0 and goodsinfoid =" + id + " and compid=" + this.CompID + " and disId=" + disId + " and isenabled=1", "id desc");
            if (l.Count > 0)
            {
                foreach (Hi.Model.BD_GoodsPrice item in l)
                {
                    if (type == 1)
                    {
                        price = decimal.Parse(string.Format("{0:N2}", Convert.ToDecimal(item.TinkerPrice.ToString()).ToString())).ToString("#,##0.00");
                    }
                    else
                    {
                        price = decimal.Parse(string.Format("{0:N2}", Convert.ToDecimal(item.TinkerPrice.ToString()).ToString())).ToString("0.00");
                    }
                }
            }
            else
            {
                Hi.Model.BD_GoodsInfo lll = new Hi.BLL.BD_GoodsInfo().GetModel(id);
                if (lll != null)
                {
                    if (type == 1)
                    {
                        price = decimal.Parse(string.Format("{0:N2}", Convert.ToDecimal(lll.TinkerPrice.ToString()).ToString())).ToString("#,##0.00");
                    }
                    else
                    {
                        price = decimal.Parse(string.Format("{0:N2}", Convert.ToDecimal(lll.TinkerPrice.ToString()).ToString())).ToString("0.00");
                    }
                }
            }
            // }
        }
        return(price);
    }
示例#4
0
    /// <summary>
    /// 获取商品最新价格
    /// </summary>
    /// <param name="GoodsinfoID"></param>
    /// <param name="DisId"></param>
    /// <param name="CompId"></param>
    /// <returns></returns>
    public static decimal GoodsNewPrice(int GoodsinfoID, int DisId, int CompId)
    {
        decimal TinkerPrice = 0;

        //获取商品信息
        Hi.Model.BD_GoodsInfo goodsinfoModel = new Hi.BLL.BD_GoodsInfo().GetModel(GoodsinfoID);

        if (goodsinfoModel != null)
        {
            //判断商品是否上架
            if (goodsinfoModel.IsOffline != 1)
            {
                return(0);
            }

            //判断是否存在促销活动 优先取促销活动价
            if (Common.GetPro(goodsinfoModel.GoodsID.ToString(), goodsinfoModel.ID.ToString(), CompId.ToString()) == 0)
            {
                //判断是否启用代理商价格维护
                if (Common.IsDisPrice != "0")
                {
                    List <Hi.Model.BD_GoodsPrice> pl = new Hi.BLL.BD_GoodsPrice().GetList("top 1 *", "DisID=" + DisId + " and CompID=" + CompId + " and GoodsInfoID=" + GoodsinfoID + " and IsEnabled=1 and ISNULL(dr,0)=0", "");

                    if (pl != null && pl.Count > 0)
                    {
                        TinkerPrice = pl[0].TinkerPrice.ToString() == "" ? goodsinfoModel.TinkerPrice : pl[0].TinkerPrice;;
                    }
                    else
                    {
                        TinkerPrice = goodsinfoModel.TinkerPrice;
                    }
                }
                else
                {
                    TinkerPrice = goodsinfoModel.TinkerPrice;
                }
            }
            else
            {
                TinkerPrice = Common.GetProPrice(goodsinfoModel.GoodsID.ToString(), goodsinfoModel.ID.ToString(), CompId.ToString());
            }
            //判断是不是赠品
            //if (GoodsName(goodsinfoModel.GoodsID, "IsSale") == "1")
            //{
            //    TinkerPrice = 0;
            //}
        }
        return(TinkerPrice);
    }
示例#5
0
    /// <summary>
    /// 最新价格
    /// </summary>
    /// <returns></returns>
    public string GoodsTinkerPrice(int id, string disId, string tinkerprice)
    {
        Hi.Model.BD_GoodsInfo model = new Hi.BLL.BD_GoodsInfo().GetModel(id);
        if (model != null)
        {
            tinkerprice = model.TinkerPrice.ToString();
        }
        string price = tinkerprice.ToString();

        List <Hi.Model.BD_GoodsPrice> l = new Hi.BLL.BD_GoodsPrice().GetList("", "isnull(dr,0)=0 and isenabled=1 and goodsinfoid =" + id + " and disId=" + disId + " and compId=" + this.CompID, "id desc");

        if (l.Count > 0)
        {
            foreach (Hi.Model.BD_GoodsPrice item in l)
            {
                price = item.TinkerPrice.ToString();
            }
        }
        return(price);
    }
示例#6
0
    /// <summary>
    /// 确定并生效按钮
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnInsert_Click(object sender, EventArgs e)
    {
        SqlTransaction Tran = null;
        object         obj  = Session["GoodsPrice"];

        if (obj != null)
        {
            try
            {
                Tran = DBUtility.SqlHelper.CreateStoreTranSaction();
                string title       = Common.NoHTML(this.txtDisTitle.Value.Trim());   //调价标题
                string disNameList = Common.NoHTML(this.txtDisID1.Name.ToString());  //选择的代理商名称列表
                string disIdList   = Common.NoHTML(this.txtDisID1.Disid.ToString()); //选择的代理商Id列表
                string remark      = Common.NoHTML(this.txtRemark.Value.Trim());     //备注
                if (Util.IsEmpty(title))
                {
                    JScript.AlertMethod(this.Page, "调价标题不能为空", JScript.IconOption.错误);
                    return;
                }
                if (Util.IsEmpty(disNameList))
                {
                    JScript.AlertMethod(this.Page, "请选择代理商", JScript.IconOption.错误);
                    return;
                }
                Hi.Model.BD_DisPrice model2 = new Hi.Model.BD_DisPrice();
                //model2.Title = title;
                model2.CompID = this.CompID;
                model2.DisIDs = disIdList;
                //model2.DisNames = disNameList;
                //model2.Remark = remark;
                //model2.State = 0;
                model2.IsEnabled    = true;
                model2.CreateUserID = this.UserID;
                model2.CreateDate   = DateTime.Now;
                model2.dr           = 0;
                model2.ts           = DateTime.Now;
                model2.modifyuser   = this.UserID;
                int disPriceId = new Hi.BLL.BD_DisPrice().Add(model2, Tran);
                int z          = 0;
                List <Hi.Model.BD_GoodsPrice>   llll  = new List <Hi.Model.BD_GoodsPrice>();   //修改
                List <Hi.Model.BD_GoodsPrice>   llll2 = new List <Hi.Model.BD_GoodsPrice>();   //新增
                List <Hi.Model.BD_DisPriceInfo> llll3 = new List <Hi.Model.BD_DisPriceInfo>(); //新增
                // string disIdList = this.hidDisId.Value.Trim();//隐藏的选择代理商列表
                List <Hi.Model.BD_GoodsInfo> ll = obj as List <Hi.Model.BD_GoodsInfo>;
                foreach (Hi.Model.BD_GoodsInfo item in ll)
                {
                    List <Hi.Model.BD_GoodsPrice> lll = new Hi.BLL.BD_GoodsPrice().GetList("", "isnull(dr,0)=0 and isenabled=1 and disid in(" + disIdList + ") and compid=" + this.CompID + " and  goodsinfoid=" + item.ID, "", Tran);
                    if (lll.Count > 0)
                    {
                        foreach (Hi.Model.BD_GoodsPrice item2 in lll)
                        {
                            item2.IsEnabled  = false;
                            item2.modifyuser = this.UserID;
                            item2.ts         = DateTime.Now;
                            item2.CompID     = this.CompID;
                            llll.Add(item2);
                            //new Hi.BLL.BD_GoodsPrice().Update(llll);
                        }
                    }
                    for (int i = 0; i < disIdList.Split(',').Length; i++)
                    {
                        Hi.Model.BD_GoodsPrice   model  = new Hi.Model.BD_GoodsPrice();
                        Hi.Model.BD_DisPriceInfo model3 = new Hi.Model.BD_DisPriceInfo();

                        //model.DisPriceID = 0;
                        model.DisID       = Convert.ToInt32(disIdList.Split(',')[i]);
                        model.CompID      = this.CompID;
                        model.GoodsInfoID = item.ID;
                        if (Request["txtPrice"] != null)
                        {
                            model.TinkerPrice = Convert.ToDecimal(Request["txtPrice"].Split(',')[z]);
                        }
                        model.IsEnabled    = true;
                        model.CreateUserID = this.UserID;
                        model.CreateDate   = DateTime.Now;
                        model.ts           = DateTime.Now;
                        model.modifyuser   = this.UserID;
                        llll2.Add(model);

                        model3.DisPriceID = disPriceId;
                        //model3.DisID = Convert.ToInt32(disIdList.Split(',')[i]);
                        model3.CompID      = this.CompID;
                        model3.GoodsInfoID = item.ID;
                        if (Request["txtPrice"] != null)
                        {
                            model3.TinkerPrice = Convert.ToDecimal(Request["txtPrice"].Split(',')[z]);
                        }
                        model3.IsEnabled    = true;
                        model3.CreateUserID = this.UserID;
                        model3.CreateDate   = DateTime.Now;
                        model3.ts           = DateTime.Now;
                        model3.modifyuser   = this.UserID;
                        llll3.Add(model3);
                    }
                    z++;
                }
                new Hi.BLL.BD_GoodsPrice().Update(llll, Tran);
                new Hi.BLL.BD_GoodsPrice().Add(llll2, Tran);
                new Hi.BLL.BD_DisPriceInfo().Add(llll3, Tran);
                Tran.Commit();
                Response.Redirect("DispriceList.aspx");
                //  JScript.AlertMsg(this, "价格调整成功",);
            }
            catch (Exception)
            {
                if (Tran != null)
                {
                    if (Tran.Connection != null)
                    {
                        Tran.Rollback();
                    }
                }
                JScript.AlertMethod(this, "价格调整失败", JScript.IconOption.错误, "function(){location.href='DispriceList.aspx';}");
                return;
            }
        }
        else
        {
            JScript.AlertMethod(this.Page, "选择的商品数据有误", JScript.IconOption.错误);
            return;
        }
    }
示例#7
0
    /// <summary>
    /// 获取某一分类产品信息,兼容了无属性的值,分类传-1
    /// </summary>
    /// <param name="JSon"></param>
    /// <returns></returns>
    public BD_GoodsCategory.ResultProductList GetProductsList(string JSon)
    {
        try
        {
            #region JSon取值

            string userID            = string.Empty;
            string disID             = string.Empty;
            string categoryID        = string.Empty; //分类ID
            string criticalProductID = string.Empty; //当前列表最临界点产品ID:初始-1
            string getType           = string.Empty; //方向
            string rows     = string.Empty;
            string sortType = string.Empty;
            string sort     = string.Empty;

            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (JInfo.Count > 0 && JInfo["UserID"].ToString() != "" && JInfo["ResellerID"].ToString() != "" &&
                JInfo["CriticalProductID"].ToString() != "" &&
                JInfo["GetType"].ToString() != "" && JInfo["Rows"].ToString() != "" &&
                JInfo["SortType"].ToString() != "" && JInfo["Sort"].ToString() != "")
            {
                userID            = JInfo["UserID"].ToString();
                disID             = JInfo["ResellerID"].ToString();
                categoryID        = JInfo["ClassifyID"].ToString();
                criticalProductID = JInfo["CriticalProductID"].ToString();
                getType           = JInfo["GetType"].ToString();
                rows     = JInfo["Rows"].ToString();
                sortType = JInfo["SortType"].ToString();
                sort     = JInfo["Sort"].ToString();
            }
            else
            {
                return(new BD_GoodsCategory.ResultProductList()
                {
                    Result = "F", Description = "参数异常"
                });
            }

            Hi.Model.SYS_Users user = new Hi.Model.SYS_Users();
            if (!new Common().IsLegitUser(int.Parse(userID), out user, 0, int.Parse(disID == "" ? "0" : disID)))
            {
                return new BD_GoodsCategory.ResultProductList()
                       {
                           Result = "F", Description = "参数异常"
                       }
            }
            ;

            #endregion

            #region 模拟分页

            string strsql = string.Empty; //搜索sql
            Hi.Model.BD_Distributor dis = new Hi.BLL.BD_Distributor().GetModel(int.Parse(disID));
            if (dis == null || dis.dr == 1 || dis.IsEnabled == 0)
            {
                return new BD_GoodsCategory.ResultProductList()
                       {
                           Result = "F", Description = "未找到经销商"
                       }
            }
            ;
            const string tabName = " [dbo].[BD_Goods]";      //表名
            sortType = sortType == "2" ? "SalePrice" : "ID"; //价格排序
            string strWhere = string.Empty;

            switch (categoryID)
            {
            case "-2":     //促销列表
            {
                List <Hi.Model.BD_Promotion> promotionList = new Hi.BLL.BD_Promotion().GetList("",
                                                                                               " compID='" + dis.CompID + "' and ProStartTime<='" + DateTime.Now + "' and ProEndTime >='" +
                                                                                               DateTime.Now + "' and IsEnabled=1", "");
                List <Hi.Model.BD_PromotionDetail> detailList = new List <BD_PromotionDetail>();
                if (promotionList != null && promotionList.Count > 0)
                {
                    detailList = new Hi.BLL.BD_PromotionDetail().GetList("",
                                                                         " ProID in(" + string.Join(",", promotionList.Select(p => p.ID)) + ")", "");
                }
                if (promotionList == null)
                {
                    return new BD_GoodsCategory.ResultProductList()
                           {
                               Result = "F", Description = "今天无促销"
                           }
                }
                ;
                if (detailList == null)
                {
                    return new BD_GoodsCategory.ResultProductList()
                           {
                               Result = "F", Description = "今天无促销"
                           }
                }
                ;
                var ienum = detailList.Select(p => p.GoodsID);
                if (ienum.Count() > 0)
                {
                    strWhere += " and ID in ( " + string.Join(",", ienum) + ")";
                }
            }
            break;

            case "-3":     //收藏列表
            {
                List <Hi.Model.BD_DisCollect> collects = new Hi.BLL.BD_DisCollect().GetList("",
                                                                                            "disID='" + disID + "' and dr=0", "");
                if (collects != null)
                {
                    strWhere += " and ID not in ( -1 ";
                    strWhere  = collects.Aggregate(strWhere, (current, goods) => current + ("," + goods.GoodsID)) +
                                ")";
                }
            }
            break;

            default:
                if (categoryID != "-1")     //全部
                {
                    strWhere += " and CategoryID in (" + Common.AllCategory(int.Parse(categoryID)) + ")";
                }
                break;
            }

            //商品可售区域判断
            List <Common.GoodsID> list = Common.DisEnAreaGoodsID(disID, dis.CompID.ToString());
            if (list != null)
            {
                strWhere += " and ID not in ( -1 ";
                strWhere  = list.Aggregate(strWhere, (current, goods) => current + ("," + goods.goodsID)) + ")";
            }
            strWhere += " and ISNULL(dr,0)=0 and isoffline=1 and IsEnabled = 1 and compid=" + dis.CompID;

            strsql = new Common().PageSqlString(criticalProductID, "ID", tabName, sortType,
                                                sort, strWhere, getType, rows);

            #endregion

            List <Hi.Model.BD_DisCollect> Colist = Common.GetDataSource <BD_DisCollect>("",
                                                                                        " and disID='" + disID + "' and compID='" + dis.CompID + "' and IsEnabled =1");
            List <Hi.Model.BD_GoodsInfo> infoAllList = new Hi.BLL.BD_GoodsInfo().GetList("",
                                                                                         " CompID='" + dis.CompID + "' and ISNULL(dr,0)=0 and IsEnabled=1 and isoffline=1", "");

            #region 赋值

            int CategoryID = 0;

            List <BD_GoodsCategory.Product> ProductList = new List <BD_GoodsCategory.Product>();
            DataTable dsList = SqlHelper.Query(SqlHelper.LocalSqlServer, strsql).Tables[0];
            if (dsList != null)
            {
                if (dsList.Rows.Count == 0)
                {
                    return new BD_GoodsCategory.ResultProductList()
                           {
                               Result = "F", Description = "未找到数据"
                           }
                }
                ;
                foreach (DataRow row in dsList.Rows)
                {
                    string SKUName = string.Empty;

                    BD_GoodsCategory.Product product = new BD_GoodsCategory.Product();
                    product.ProductID   = row["ID"].ToString(); //商品ID
                    product.ProductName = row["GoodsName"].ToString();
                    SKUName            += product.ProductName;
                    product.SalePrice   = decimal.Parse(row["SalePrice"].ToString()).ToString("0.00");
                    product.IsSale      = row["IsSale"].ToString();

                    List <Hi.Model.BD_DisCollect> alist = Colist != null && Colist.Count > 0
                        ? Colist.Where(p => p.GoodsID.ToString() == product.ProductID).ToList()
                        : null;
                    product.IsCollect = alist != null && alist.Count > 0 ? "1" : "0";
                    product.Title     = row["Title"].ToString();
                    //product.Details = row["Details"].ToString();
                    product.Title      = row["Title"].ToString();
                    product.Unit       = row["Unit"].ToString();
                    product.ClassifyID = row["CategoryID"].ToString();
                    CategoryID         = int.Parse(row["CategoryID"].ToString()); //类别ID

                    List <BD_GoodsCategory.Pic> Pic = new List <BD_GoodsCategory.Pic>();

                    #region List<Pic> Pic

                    if (row["Pic"].ToString() != "" && row["Pic"].ToString() != "X")
                    {
                        BD_GoodsCategory.Pic pic = new BD_GoodsCategory.Pic();
                        pic.ProductID = row["ID"].ToString();
                        pic.IsDeafult = "1";
                        pic.PicUrl    = ConfigurationManager.AppSettings["ImgViewPath"].ToString().Trim() + "GoodsImg/" +
                                        row["Pic"].ToString();
                        Pic.Add(pic);
                    }

                    Pic.AddRange(GetPicList(row["ID"].ToString()));

                    #endregion

                    product.ProductPicUrlList = Pic;

                    List <BD_GoodsCategory.SKU> SKUList = new List <BD_GoodsCategory.SKU>();
                    string strID = "0";

                    #region 通过 商品ID和属性值ID关联表,找到属性值

                    List <Hi.Model.BD_GoodsInfo> goodsInfoList = infoAllList != null && infoAllList.Count > 0
                        ? infoAllList.Where(p => p.GoodsID.ToString() == row["ID"].ToString()).ToList()
                        : null;
                    foreach (Hi.Model.BD_GoodsInfo goodsInfo in goodsInfoList)
                    {
                        if (!Common.IsOffline(goodsInfo.ID))
                        {
                            continue;
                        }

                        BD_GoodsCategory.SKU SKU = new BD_GoodsCategory.SKU();
                        //SKUID是GoodsInfoID,SKUName是GoodsName+各种属性值
                        SKU.SKUID     = goodsInfo.ID.ToString();
                        SKU.ProductID = goodsInfo.GoodsID.ToString();
                        SKU.BarCode   = goodsInfo.BarCode;
                        //SKUName = GoodsName + ValueInfo
                        SKU.SKUName = SKUName + " " + goodsInfo.ValueInfo;

                        SKU.ValueInfo = goodsInfo.ValueInfo;
                        SKU.SalePrice = goodsInfo.SalePrice.ToString("0.00");

                        int ProID = 0;   //暂时未用到 促销ID
                        SKU.IsPro = "0"; //默认不是促销价
                        decimal price = Common.GetProPrice(goodsInfo.GoodsID.ToString(), goodsInfo.ID.ToString(),
                                                           goodsInfo.CompID.ToString(), out ProID);
                        if (price == 0)
                        {
                            List <Hi.Model.BD_GoodsPrice> goodsPrice = new Hi.BLL.BD_GoodsPrice().GetList("",
                                                                                                          " GoodsInfoID='" + goodsInfo.ID + "' and ISNULL(dr,0)=0 and compid='" + goodsInfo.CompID +
                                                                                                          "' and IsEnabled=1", "");
                            SKU.TinkerPrice = goodsPrice.Count != 0
                                ? goodsPrice[0].TinkerPrice.ToString("0.00")
                                : goodsInfo.TinkerPrice.ToString("0.00");
                        }
                        else
                        {
                            SKU.IsPro       = "1"; //是促销价
                            SKU.ProInfo     = GetProInfo(ProID, goodsInfo.ID);
                            SKU.TinkerPrice = price.ToString("0.00");
                        }


                        List <BD_GoodsCategory.ProductAttValueID> ProductAttValueIDList = new List <BD_GoodsCategory.ProductAttValueID>();

                        List <Hi.Model.BD_GoodsAttrsInfo> attrList = new Hi.BLL.BD_GoodsAttrsInfo().GetList("", " GoodsID='" + goodsInfo.GoodsID + "' and ISNULL(dr,0)=0", "");
                        if (attrList == null)
                        {
                            return new BD_GoodsCategory.ResultProductList()
                                   {
                                       Result = "F", Description = "未找到商品属性名字"
                                   }
                        }
                        ;
                        List <Hi.Model.BD_GoodsAttrs> attrValList = new Hi.BLL.BD_GoodsAttrs().GetList("*", " CompID ='" + dis.CompID + "'", "");
                        foreach (Hi.Model.BD_GoodsAttrsInfo attribute in attrList)
                        {
                            strID += "," + attribute.AttrsID;

                            string[] args  = new[] { goodsInfo.ValueInfo };
                            string[] items = args[0].Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                            foreach (string item in items)
                            {
                                string[] strs = item.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);

                                if (strs[1] == attribute.AttrsInfoName)
                                {
                                    BD_GoodsCategory.ProductAttValueID productAttValueID = new BD_GoodsCategory.ProductAttValueID()
                                    {
                                        ProductAttributeValueID = attribute.ID.ToString()//
                                    };
                                    ProductAttValueIDList.Add(productAttValueID);
                                }
                            }
                        }

                        SKU.ProductAttValueIDList = ProductAttValueIDList;
                        SKUList.Add(SKU);
                    }

                    #endregion

                    product.SKUList = SKUList;

                    List <BD_GoodsCategory.ProductAttribute> ProductAttributeList = new List <BD_GoodsCategory.ProductAttribute>();

                    #region 通过商品类别ID和属性ID关联表,找到属性ID

                    List <Hi.Model.BD_GoodsAttrs> val = new Hi.BLL.BD_GoodsAttrs().GetList("", " ID in (" + strID + ") and CompID='" + dis.CompID + "' and ISNULL(dr,0)=0", "");
                    if (val == null)
                    {
                        return new BD_GoodsCategory.ResultProductList()
                               {
                                   Result = "F", Description = "未找到商品属性"
                               }
                    }
                    ;

                    foreach (Hi.Model.BD_GoodsAttrs goodsAttr in val)
                    {
                        BD_GoodsCategory.ProductAttribute proAttr = new BD_GoodsCategory.ProductAttribute();

                        proAttr.ProductID            = row["ID"].ToString();
                        proAttr.ProductAttributeID   = goodsAttr.ID.ToString(); //属性ID
                        proAttr.ProductAttributeName = goodsAttr.AttrsName;     //属性名称

                        List <BD_GoodsCategory.ProductAttValue> ProductAttValueList = new List <BD_GoodsCategory.ProductAttValue>();

                        List <Hi.Model.BD_GoodsAttrsInfo> attrList = new Hi.BLL.BD_GoodsAttrsInfo().GetList("",
                                                                                                            " AttrsID='" + goodsAttr.ID + "' and CompID='" + dis.CompID + "' and ISNULL(dr,0)=0" +
                                                                                                            " and AttrsID in (" + strID + ")", "ID"); //todo:商品属性表修改咨询商品结构
                        if (attrList == null)
                        {
                            return new BD_GoodsCategory.ResultProductList()
                                   {
                                       Result = "F", Description = "未找到商品属性名字"
                                   }
                        }
                        ;
                        foreach (Hi.Model.BD_GoodsAttrsInfo attribute in attrList)
                        {
                            BD_GoodsCategory.ProductAttValue productAttValue = new BD_GoodsCategory.ProductAttValue();

                            productAttValue.ProductID           = row["ID"].ToString();
                            productAttValue.ProductAttributeID  = goodsAttr.ID.ToString();
                            productAttValue.ProductAttValueID   = attribute.ID.ToString();
                            productAttValue.ProductAttValueName = attribute.AttrsInfoName;

                            ProductAttValueList.Add(productAttValue);
                        }
                        proAttr.ProductAttValueList = ProductAttValueList;
                        ProductAttributeList.Add(proAttr);
                    }

                    #endregion

                    product.ProductAttributeList = ProductAttributeList;

                    ProductList.Add(product);
                }
            }

            #endregion

            return(new BD_GoodsCategory.ResultProductList()
            {
                Result = "T",
                Description = "获取成功",
                ClassifyID = categoryID,
                ProductList = ProductList
            });
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "GetResellerProductList :" + JSon);
            return(new BD_GoodsCategory.ResultProductList()
            {
                Result = "F", Description = "异常"
            });
        }
    }
示例#8
0
    /// <summary>
    /// 选择商品
    /// </summary>
    /// <param name="Id">商品Id</param>
    public static void Goods(int Id, int DisId, int CompId)
    {
        DataTable dt    = null;
        int       ProID = 0;

        //获取商品信息
        Hi.Model.BD_GoodsInfo goodsinfoModel = new Hi.BLL.BD_GoodsInfo().GetModel(Id);
        string Digits = OrderInfoType.rdoOrderAudit("订单下单数量是否取整", CompId);

        if (goodsinfoModel != null)
        {
            int IsInve = OrderInfoType.rdoOrderAudit("商品是否启用库存", CompId).ToInt(0);
            if (IsInve == 0)
            {
                if (goodsinfoModel.Inventory <= 0)
                {
                    return;
                }
            }

            decimal TinkerPrice = 0;
            decimal Price       = goodsinfoModel.TinkerPrice;
            if (goodsinfoModel.IsOffline == 1)
            {
                //判断是否存在促销活动 优先取促销活动价
                ProID = Common.GetPro(goodsinfoModel.GoodsID.ToString(), goodsinfoModel.ID.ToString(), CompId.ToString());
                if (ProID == 0)
                {
                    //判断是否启用代理商价格维护
                    if (Common.IsDisPrice != "0")
                    {
                        //获取商品价格
                        List <Hi.Model.BD_GoodsPrice> pl = new Hi.BLL.BD_GoodsPrice().GetList("top 1 *", "DisID=" + DisId + " and CompID=" + CompId + " and GoodsInfoID=" + Id + " and isnull(IsEnabled,0)=1 and ISNULL(dr,0)=0", "");

                        if (pl != null && pl.Count > 0)
                        {
                            TinkerPrice = pl[0].TinkerPrice.ToString() == "" ? goodsinfoModel.TinkerPrice : pl[0].TinkerPrice;
                            Price       = pl[0].TinkerPrice.ToString() == "" ? goodsinfoModel.TinkerPrice : pl[0].TinkerPrice;
                        }
                        else
                        {
                            TinkerPrice = goodsinfoModel.TinkerPrice.ToString() == "" ? 0 : goodsinfoModel.TinkerPrice;
                            Price       = goodsinfoModel.TinkerPrice.ToString() == "" ? 0 : goodsinfoModel.TinkerPrice;
                        }
                    }
                    else
                    {
                        TinkerPrice = goodsinfoModel.TinkerPrice.ToString() == "" ? 0 : goodsinfoModel.TinkerPrice;
                        Price       = goodsinfoModel.TinkerPrice.ToString() == "" ? 0 : goodsinfoModel.TinkerPrice;
                    }
                }
                else
                {
                    TinkerPrice = Common.GetProPrice(goodsinfoModel.GoodsID.ToString(), goodsinfoModel.ID.ToString(), CompId.ToString());
                }
            }
            else
            {
                Price       = 0;
                TinkerPrice = 0;
            }

            //判断是不是赠品
            //if (GoodsName(goodsinfoModel.GoodsID, "IsSale") == "1")
            //{
            //    TinkerPrice = 0;
            //}

            if (HttpContext.Current.Session["GoodsInfo"] == null)
            {
                dt = new DataTable();
                dt.Columns.Add("Id", typeof(string));           //订单明细Id
                dt.Columns.Add("DisId", typeof(string));        //代理商Id
                dt.Columns.Add("CompId", typeof(string));       //企业Id
                dt.Columns.Add("GoodsID", typeof(Int64));       //商品基本档案ID
                dt.Columns.Add("GoodsinfoID", typeof(Int64));   //商品ID
                dt.Columns.Add("BarCode", typeof(string));      //商品编码
                dt.Columns.Add("GoodsName", typeof(string));    //商品名称
                dt.Columns.Add("GoodsInfos", typeof(string));   //商品属性信息
                dt.Columns.Add("Inventory", typeof(decimal));   //商品库存
                dt.Columns.Add("Price", typeof(decimal));       //商品价格
                dt.Columns.Add("AuditAmount", typeof(decimal)); //审核后价格
                dt.Columns.Add("Unit", typeof(string));         //商品计量单位
                dt.Columns.Add("Pic", typeof(string));          //商品图片
                //dt.Columns.Add("StockNum", typeof(int)); //数据类型为 文本
                dt.Columns.Add("GoodsNum", typeof(decimal));    //商品数量
                dt.Columns.Add("Remark", typeof(string));       //备注
                dt.Columns.Add("vdef1", typeof(string));        //是否促销商品
                dt.Columns.Add("vdef2", typeof(string));        //促销商品数量
                dt.Columns.Add("vdef3", typeof(string));        //促销Protype
                dt.Columns.Add("Total", typeof(decimal));       //小计

                DataRow dr1 = dt.NewRow();

                dr1["Id"]          = 0;
                dr1["DisId"]       = DisId;
                dr1["CompId"]      = CompId;
                dr1["GoodsID"]     = goodsinfoModel.GoodsID;
                dr1["GoodsinfoID"] = Id;
                dr1["BarCode"]     = goodsinfoModel.BarCode;
                dr1["GoodsName"]   = GoodsName(goodsinfoModel.GoodsID, "GoodsName");
                dr1["GoodsInfos"]  = goodsinfoModel.ValueInfo == "" ?  Util.GetSubString(Common.GetGoodsMemo(goodsinfoModel.GoodsID), 30) : goodsinfoModel.ValueInfo;
                dr1["Price"]       = Price;
                dr1["Inventory"]   = goodsinfoModel.Inventory;
                dr1["Pic"]         = GoodsName(goodsinfoModel.GoodsID, "Pic");
                dr1["AuditAmount"] = TinkerPrice;
                dr1["Unit"]        = GoodsName(goodsinfoModel.GoodsID, "Unit");
                dr1["GoodsNum"]    = decimal.Parse(string.Format("{0:N4}", (1).ToString("#,####" + Digits)));
                dr1["Remark"]      = "";
                dr1["vdef1"]       = ProID; //Common.GetPro(goodsinfoModel.GoodsID, Id.ToString(), CompId.ToString());
                dr1["vdef2"]       = "0";
                dr1["vdef3"]       = "";
                dr1["Total"]       = TinkerPrice * 1;

                dt.Rows.Add(dr1);
            }
            else
            {
                dt = HttpContext.Current.Session["GoodsInfo"] as DataTable;
                DataRow dr2 = dt.NewRow();

                dr2["Id"]          = 0;
                dr2["DisId"]       = DisId;
                dr2["CompId"]      = CompId;
                dr2["GoodsID"]     = goodsinfoModel.GoodsID;
                dr2["GoodsinfoID"] = Id;
                dr2["BarCode"]     = goodsinfoModel.BarCode;
                dr2["GoodsName"]   = GoodsName(goodsinfoModel.GoodsID, "GoodsName");
                dr2["GoodsInfos"]  = goodsinfoModel.ValueInfo == "" ? Util.GetSubString(Common.GetGoodsMemo(goodsinfoModel.GoodsID), 30) : goodsinfoModel.ValueInfo;
                dr2["Inventory"]   = goodsinfoModel.Inventory;
                dr2["Price"]       = Price;
                dr2["Pic"]         = GoodsName(goodsinfoModel.GoodsID, "Pic");
                dr2["AuditAmount"] = TinkerPrice;
                dr2["Unit"]        = GoodsName(goodsinfoModel.GoodsID, "Unit");
                dr2["GoodsNum"]    = decimal.Parse(string.Format("{0:N4}", (1).ToString("#,####" + Digits)));
                dr2["Remark"]      = "";
                dr2["vdef1"]       = ProID;// Common.GetPro(goodsinfoModel.GoodsID, Id.ToString(), CompId.ToString());
                dr2["vdef2"]       = "0";
                dr2["vdef3"]       = "";
                dr2["Total"]       = TinkerPrice * 1;
                dt.Rows.Add(dr2);
            }
            dt.DefaultView.Sort = "id desc";
            HttpContext.Current.Session["GoodsInfo"] = dt;
        }
    }