Beispiel #1
0
    /// <summary>
    /// 删除
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDel_Click(object sender, EventArgs e)
    {
        if (KeyID != 0)
        {
            Hi.Model.BD_Promotion proModel = new Hi.BLL.BD_Promotion().GetModel(KeyID);
            //促销公告
            List <Hi.Model.BD_CompNews> newsl = new Hi.BLL.BD_CompNews().GetList("", " PMID=" + KeyID, "");

            if (proModel != null)
            {
                proModel.IsEnabled = 1;
                proModel.dr        = 1;
                if (new Hi.BLL.BD_Promotion().Update(proModel))
                {
                    if (newsl != null && newsl.Count > 0)
                    {
                        Hi.Model.BD_CompNews newsModel = new Hi.Model.BD_CompNews();
                        foreach (Hi.Model.BD_CompNews item in newsl)
                        {
                            item.IsEnabled = 0;
                            item.dr        = 1;
                            newsModel      = item;
                        }
                        new Hi.BLL.BD_CompNews().Update(newsModel);
                    }
                    Response.Write("<script>window.location.href='PromotionList.aspx?type=" + Request["type"] + "';</script>");
                }
            }
        }
    }
Beispiel #2
0
    /// <summary>
    /// 禁用
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnNo_Click(object sender, EventArgs e)
    {
        if (KeyID != 0)
        {
            Hi.Model.BD_Promotion proModel = new Hi.BLL.BD_Promotion().GetModel(KeyID);

            //促销公告
            List <Hi.Model.BD_CompNews> newsl = new Hi.BLL.BD_CompNews().GetList("", " PMID=" + KeyID, "");

            if (proModel != null)
            {
                proModel.IsEnabled = 0;

                if (new Hi.BLL.BD_Promotion().Update(proModel))
                {
                    Hi.Model.BD_CompNews newsModel = new Hi.Model.BD_CompNews();
                    if (newsl != null && newsl.Count > 0)
                    {
                        foreach (Hi.Model.BD_CompNews item in newsl)
                        {
                            item.IsEnabled = 0;
                            newsModel      = item;
                        }
                        new Hi.BLL.BD_CompNews().Update(newsModel);
                    }

                    Response.Write("<script>window.location.href='PromotionInfo2.aspx?KeyId=" + Common.DesEncrypt(this.KeyID.ToString(), Common.EncryptKey) + "&type=" + Request["type"] + "';</script>");
                }
            }
        }
    }
Beispiel #3
0
    /// <summary>
    /// 查询商品使用的促销方式 by szj 2016-04-13
    /// </summary>
    /// <param name="proID">促销ID</param>
    public static string ProType(object proID)
    {
        string TheLabel = string.Empty;

        if (proID.ToString() != "")
        {
            DataTable dt = new Hi.BLL.BD_Promotion().ProType(proID.ToString());

            if (dt != null && dt.Rows.Count > 0)
            {
                TheLabel = "<div class=\"sale-box\"><i class=\"sale\">促销</i><div class=\"sale-txt\"><i class=\"arrow\"></i>";
                if (dt.Rows[0]["Type"].ToString() == "0")
                {
                    TheLabel += "特价商品";
                }
                else if (dt.Rows[0]["Type"].ToString() == "1")
                {
                    if (dt.Rows[0]["Protype"].ToString() == "3")
                    {
                        TheLabel += "满" + OrderInfoType.GetNum(dt.Rows[0]["DisCount"].ToString().ToDecimal(0)) + "件" + ",获赠商品(" + OrderInfoType.GetNum(dt.Rows[0]["GoodsPrice"].ToString().ToDecimal(0)) + ")个";
                    }
                    else
                    {
                        TheLabel += "在原订货价基础上已打(" + Convert.ToInt32(dt.Rows[0]["DisCount"]) + ")%折";
                    }
                }
                TheLabel += " </div></div>";
            }
        }

        return(TheLabel);
    }
Beispiel #4
0
    /// <summary>
    /// 促销信息
    /// </summary>
    /// <param name="ProID">促销ID</param>
    /// <param name="GoodInfoID">GoodsInfoID</param>
    /// <returns></returns>
    public BD_GoodsCategory.PromotionInfo GetProInfo(int ProID, int GoodInfoID)
    {
        Hi.Model.BD_Promotion pro = new Hi.BLL.BD_Promotion().GetModel(ProID);
        if (pro != null)
        {
            string proInfos = string.Empty;

            List <Hi.Model.BD_PromotionDetail> dList = new Hi.BLL.BD_PromotionDetail()
                                                       .GetList("", " ProID=" + pro.ID + " and GoodInfoID ='" + GoodInfoID + "' and dr=0",
                                                                "");
            if (dList != null && dList.Count > 0)
            {
                if (pro.Type == 0 && pro.ProType == 1)
                {
                    proInfos = "赠品";
                }
                else if (pro.Type == 0 && pro.ProType == 2)
                {
                    proInfos = "商品优惠价" + dList[0].GoodsPrice.ToString("0.00");
                }
                else if (pro.Type == 1 && pro.ProType == 3)
                {
                    proInfos = "商品数量满" + pro.Discount.ToString("0.00") + "赠" +
                               dList[0].GoodsPrice.ToString("0.00") + dList[0].GoodsUnit;
                }
                else if (pro.Type == 1 && pro.ProType == 4)
                {
                    proInfos = "商品打折" + pro.Discount.ToString("0.00") + "%";
                }
            }

            return(new BD_GoodsCategory.PromotionInfo()
            {
                ProID = ProID.ToString(),
                ProTitle = pro.ProTitle,
                ProInfos = proInfos,

                Tpye = pro.Type.ToString(),
                ProTpye = pro.ProType.ToString(),
                Discount = pro.Discount.ToString("0.00"),

                ProStartTime = pro.ProStartTime.ToString("yy-MM-dd"),
                ProEndTime = pro.ProEndTime.ToString("yy-MM-dd")
            });
        }
        else
        {
            return(null);
        }
    }
Beispiel #5
0
    public string IsEnd(int PMID)
    {
        string str = "";

        if (PMID > 0)
        {
            Hi.Model.BD_Promotion ProM = new Hi.BLL.BD_Promotion().GetModel(PMID);
            if (ProM != null)
            {
                if (ProM.ProEndTime.Date < DateTime.Now.Date.Date)
                {
                    str = "<i  style='margin-left:5px;color: #aaaaaa;font-style: normal;'>【已结束】</i>";
                }
            }
        }
        return(str);
    }
Beispiel #6
0
    public string IsEnd(int PMID)
    {
        string str = "";

        if (PMID > 0)
        {
            Hi.Model.BD_Promotion ProM = new Hi.BLL.BD_Promotion().GetModel(PMID);
            if (ProM != null)
            {
                if (ProM.ProEndTime.Date < DateTime.Now.Date.Date)
                {
                    str = "<i class='grayTxt' title='活动已结束' style='margin-left:5px;color: #aaaaaa;font-weight:bold;'>已结束</i>";
                }
            }
        }
        return(str);
    }
Beispiel #7
0
    /// <summary>
    /// 促销
    /// </summary>
    /// <returns></returns>
    public string Cuxiao(string goodsInfoId)
    {
        string str = string.Empty;
        List <Hi.Model.BD_PromotionDetail> pd = new Hi.BLL.BD_PromotionDetail().GetList("", "isnull(dr,0)=0 and Goodinfoid=" + goodsInfoId, " id  desc");

        if (pd.Count > 0)
        {
            for (int i = 0; i < pd.Count; i++)
            {
                List <Hi.Model.BD_Promotion> pt = new Hi.BLL.BD_Promotion().GetList("", "isnull(IsEnabled,0)=1 and isnull(dr,0)=0 and ('" + DateTime.Now.Date + "' between  ProStartTime and ProEndTime ) and id=" + pd[i].ProID, "");
                if (pt.Count > 0)
                {
                    //if (pt[0].ProType.ToString() != "3")
                    //{
                    return(pt[0].ID.ToString());
                    // }
                }
            }
        }
        return(str);
    }
Beispiel #8
0
    /// <summary>
    /// 数据绑定
    /// </summary>
    private void Bind()
    {
        if (KeyID != 0)
        {
            Hi.Model.BD_Promotion ProModel = new Hi.BLL.BD_Promotion().GetModel(KeyID);
            if (ProModel != null)
            {
                this.lblProType.InnerText = Common.GetProType(ProModel.ProType.ToString());
                pro = ProModel.ProType.ToString();

                this.lblProIsEnabled.InnerText = Common.GetIsEnabled(ProModel.IsEnabled.ToString());
                this.lblProStartDate.InnerText = ProModel.ProStartTime == DateTime.MinValue ? "" : ProModel.ProStartTime.ToString("yyyy-MM-dd");
                this.lblProEndDate.InnerText   = ProModel.ProEndTime == DateTime.MinValue ? "" : ProModel.ProEndTime.ToString("yyyy-MM-dd");
                this.lblProInfos.InnerText     = ProModel.ProInfos;
                if (ProModel.ProStartTime <= DateTime.Now && ProModel.ProEndTime.AddDays(1) > DateTime.Now)
                {
                    //促销活动中
                    //判断是否禁用
                    if (ProModel.IsEnabled == 0)
                    {
                        //未禁用
                        this.liEdit.Visible = true;  //编辑
                        this.liDel.Visible  = true;  //删除
                        this.liNo.Visible   = false; //禁用
                        this.liOk.Visible   = true;  //启用
                    }
                    else
                    {
                        //已禁用
                        this.liEdit.Visible = false; //编辑
                        this.liDel.Visible  = false; //删除
                        this.liNo.Visible   = true;  //禁用
                        this.liOk.Visible   = false; //启用
                    }
                }
                else if (ProModel.ProStartTime > DateTime.Now)
                {
                    //判断是否禁用
                    if (ProModel.IsEnabled == 0)
                    {
                        //未禁用
                        this.liEdit.Visible = true;  //编辑
                        this.liDel.Visible  = true;  //删除
                        this.liNo.Visible   = false; //禁用
                        this.liOk.Visible   = true;  //启用
                    }
                    else
                    {
                        //已禁用
                        this.liEdit.Visible = false; //编辑
                        this.liDel.Visible  = false; //删除
                        this.liNo.Visible   = true;  //禁用
                        this.liOk.Visible   = false; //启用
                    }
                }
                else
                {
                    this.liEdit.Visible = true;  //编辑
                    this.liDel.Visible  = true;  //删除
                    this.liNo.Visible   = false; //禁用
                    this.liOk.Visible   = false; //启用
                }
                List <Hi.Model.BD_PromotionDetail2> ll = new Hi.BLL.BD_PromotionDetail2().GetList("", "isnull(dr,0)=0 and proId=" + ProModel.ID + " and compId=" + this.CompID, "");
                if (ll.Count > 1)
                {
                    this.lblProIsJieTi.InnerText = "是";
                }
                else
                {
                    this.lblProIsJieTi.InnerText = "否";
                }
                string html = "";
                if (ProModel.ProType == 5)
                {
                    foreach (Hi.Model.BD_PromotionDetail2 item in ll)
                    {
                        html += "<label>订单金额满¥<input type=\"text\" onkeyup='KeyInt2(this)' id=\"txtPrice1\" class=\"send txtPrice\" style=\"width: 50px;\" name=\"txtPrice\" value=\"" + item.OrderPrice.ToString("f2") + "\" />,立减¥<input type=\"text\" id=\"txtSendFull1\" onkeyup='KeyInt2(this)' class=\"send txtSendFull\" name=\"txtSendFull\" style=\"width: 50px;\" value=\"" + item.Discount.ToString("f2") + "\"/></label><br>";
                    }
                }
                else if (ProModel.ProType == 6)
                {
                    foreach (Hi.Model.BD_PromotionDetail2 item in ll)
                    {
                        html += "<label>订单金额满¥<input type=\"text\" onkeyup='KeyInt2(this)' id=\"txtPrices1\" class=\"send txtPrices\" style=\"width: 50px;\" name=\"txtPrices\"  value=\"" + item.OrderPrice.ToString("f2") + "\"/>,打折(<input type=\"text\" id=\"txtDiscount1\" onkeyup='KeyInt2(this)' class=\"send txtDiscount\" name=\"txtDiscount\" style=\"width: 20px;\"  value=\"" + Convert.ToInt32(item.Discount) + "\"/>)%</label><br>";
                    }
                }
                this.SendFull.InnerHtml = html;
            }
        }
    }
Beispiel #9
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 = "异常"
            });
        }
    }
Beispiel #10
0
    public ResultOrderList GetBriefingList(string JSon)
    {
        try
        {
            string UserID          = string.Empty;
            string CompID          = string.Empty;
            string criticalOrderID = string.Empty; //当前列表最临界点产品ID:初始-1
            string getType         = string.Empty; //方向
            string rows            = string.Empty;
            string sortType        = string.Empty;
            string sort            = string.Empty;
            string datetype        = string.Empty;
            string ordertype       = string.Empty;
            #region//JSon取值
            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (JInfo.Count > 0 && JInfo["UserID"].ToString() != "" && JInfo["CompID"].ToString() != "" &&
                JInfo["CriticalOrderID"].ToString() != "" && JInfo["GetType"].ToString() != "" &&
                JInfo["Rows"].ToString() != "" && JInfo["SortType"].ToString() != "" &&
                JInfo["Sort"].ToString() != "" && JInfo["DateType"].ToString() != "" && JInfo["OrderType"].ToString() != "")
            {
                UserID          = JInfo["UserID"].ToString();
                CompID          = JInfo["CompID"].ToString();
                criticalOrderID = JInfo["CriticalOrderID"].ToString();
                getType         = JInfo["GetType"].ToString();
                rows            = JInfo["Rows"].ToString();
                sortType        = JInfo["SortType"].ToString();
                sort            = JInfo["Sort"].ToString();
                datetype        = JInfo["DateType"].ToString();
                ordertype       = JInfo["OrderType"].ToString();
            }
            else
            {
                return(new ResultOrderList()
                {
                    Result = "F", Description = "参数异常"
                });
            }
            #endregion
            //判断登录信息是否异常
            Hi.Model.SYS_Users one = new Hi.Model.SYS_Users();
            if (!new Common().IsLegitUser(int.Parse(UserID), out one, int.Parse(CompID == "" ? "0" : CompID)))
            {
                return new ResultOrderList()
                       {
                           Result = "F", Description = "登录信息异常"
                       }
            }
            ;
            //判断经销商信息是否异常
            Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(Convert.ToInt32(CompID));
            if (comp == null || comp.dr == 1 || comp.AuditState == 0 || comp.IsEnabled == 0)
            {
                return new ResultOrderList()
                       {
                           Result = "F", Description = "核心企业异常"
                       }
            }
            ;

            DateTime date       = DateTime.Now;
            DateTime date_start = new DateTime();
            DateTime date_end   = date.AddDays(1);
            //string strdate_start = string.Empty;
            // string strdate_end = date_end.ToString("yyyy-MM-dd");

            string strwhere = "";
            switch (datetype)
            {
            case "0":
                date_start = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0);

                //strdate_start = date_start.ToString("yyyy-MM-dd");
                break;

            case "1":
                DateTime startWeek = date.AddDays(1 - Convert.ToInt32(date.DayOfWeek.ToString("d")));
                date_start = new DateTime(startWeek.Year, startWeek.Month, startWeek.Day, 0, 0, 0);
                //strdate_start = date_start.ToString("yyyy-MM-dd");
                break;

            case "2":
                date_start = new DateTime(date.Year, date.Month, 1);
                //strdate_start = date_start.ToString("yyyy-MM-dd");
                break;

            default:
                return(new ResultOrderList()
                {
                    Result = "F", Description = "时间段类型异常"
                });

                break;
            }
            switch (ordertype)
            {
            case "0":
                strwhere = " and  isnull(dr,0)=0 and Otype!=9 and CompID=" + comp.ID + " and OState in (2,3,4,5,7) and CreateDate>='" + date_start + "' and CreateDate<='" + date_end + "'";
                break;

            case "1":
                strwhere = " and  isnull(dr,0)=0 and CompID=" + comp.ID + " and  CreateDate>='" + date_start + "' and CreateDate<='" + date_end + "' and ReturnState =3";
                break;

            case "2":
                string sql = "SELECT distinct orderID FROM [dbo].[CompCollection_view] where OrderID not in(select ID from Dis_Order where ISNULL(dr,0)=0 and (Otype=9 or OState not in(2,3,4,5,7)) and CompID=" + comp.ID + ")  and status!=3 and CompID=" + comp.ID +
                             " and Date>='" + date_start + "' and Date<'" + date_end + "'  AND vedf9=1 ";
                DataTable dt_pay = SqlHelper.Query(SqlHelper.LocalSqlServer, sql).Tables[0];
                string where = "";
                for (int i = 0; i < dt_pay.Rows.Count; i++)
                {
                    if (ClsSystem.gnvl(dt_pay.Rows[i]["orderID"], "") != "")
                    {
                        where += ",";
                        where += ClsSystem.gnvl(dt_pay.Rows[i]["orderID"], "");
                    }
                }
                where    = where.Substring(1, where.Length - 1);
                strwhere = " and id in (" + where + ")";
                break;

            default:
                return(new ResultOrderList()
                {
                    Result = "F", Description = "订单类型异常"
                });

                break;
            }

            if (sortType == "1") //价格排序
            {
                sortType = "CreateDate";
            }
            else if (sortType == "2") //价格排序
            {
                sortType = "TotalAmount";
            }
            else
            {
                sortType = "ID";
            }

            string strsql = new Common().PageSqlString(criticalOrderID, "ID", "DIS_Order", sortType,
                                                       sort, strwhere, getType, rows);


            if (strsql == "")
            {
                return new ResultOrderList()
                       {
                           Result = "F", Description = "基础数据异常"
                       }
            }
            ;


            #region 赋值


            List <Order> OrderList = new List <Order>();
            DataSet      ds        = SqlHelper.Query(SqlHelper.LocalSqlServer, strsql);
            if (ds.Tables.Count == 0)
            {
                return new ResultOrderList()
                       {
                           Result = "T", Description = "没有更多数据"
                       }
            }
            ;
            DataTable orderList = ds.Tables[0];
            if (orderList != null)
            {
                if (orderList.Rows.Count == 0)
                {
                    return new ResultOrderList()
                           {
                               Result = "T", Description = "没有更多数据"
                           }
                }
                ;

                foreach (DataRow row in orderList.Rows)
                {
                    Order order = new Order();

                    Hi.Model.DIS_Order orderModel = new Hi.BLL.DIS_Order().GetModel(int.Parse(row["ID"].ToString()));
                    if (orderModel == null || orderModel.dr == 1)
                    {
                        return new ResultOrderList()
                               {
                                   Result = "F", Description = "订单异常"
                               }
                    }
                    ;
                    order.OrderID  = orderModel.ID.ToString();
                    order.CompID   = orderModel.CompID.ToString();
                    order.CompName = comp.CompName;

                    order.State = Common.GetCompOrderType(orderModel.OState, orderModel.PayState, orderModel.Otype,
                                                          orderModel.ReturnState);
                    string IsEnSend, IsEnPay, IsEnReceive, IsEnReturn, IsEnAudit;
                    Common.GetEspecialType(orderModel.OState.ToString(), orderModel.PayState.ToString(), orderModel.Otype.ToString(),
                                           orderModel.ReturnState.ToString(), out IsEnSend, out IsEnPay, out IsEnAudit, out IsEnReceive, out IsEnReturn);
                    order.IsEnSend    = IsEnSend;
                    order.IsEnPay     = IsEnPay;
                    order.IsEnAudit   = IsEnAudit;
                    order.IsEnReceive = IsEnReceive;
                    order.IsEnReturn  = IsEnReturn;

                    order.Otype       = orderModel.Otype.ToString();
                    order.AddType     = orderModel.AddType.ToString();
                    order.OState      = orderModel.OState.ToString();
                    order.PayState    = orderModel.PayState.ToString();
                    order.ReturnState = orderModel.ReturnState.ToString();
                    order.DisID       = orderModel.DisID.ToString();
                    Hi.Model.BD_Distributor dis = new Hi.BLL.BD_Distributor().GetModel(orderModel.DisID);
                    if (dis == null || dis.AuditState == 0 || dis.dr == 1)
                    {
                        return new ResultOrderList()
                               {
                                   Result = "F", Description = "经销信息商异常"
                               }
                    }
                    ;
                    order.DisName   = dis.DisName;
                    order.DisUserID = orderModel.DisUserID.ToString();
                    Hi.Model.SYS_Users user = new Hi.BLL.SYS_Users().GetModel(int.Parse(order.DisUserID));
                    //if (user == null || user.IsEnabled == 0 || user.dr == 1)
                    //    return new ResultOrderList() { Result = "F", Description = "经销商用户信息异常" };
                    //order.DisUserName = orderModel.DisUserName;
                    if (user != null && user.IsEnabled == 1 && user.dr == 0)
                    {
                        order.DisUserName = user.TrueName;
                    }
                    else
                    {
                        order.DisUserName = "";
                    }
                    order.AddrID    = orderModel.AddrID.ToString();
                    order.ReceiptNo = orderModel.ReceiptNo;
                    if (ClsSystem.gnvl(orderModel.ArriveDate, "") != "0001/1/1 0:00:00" && ClsSystem.gnvl(orderModel.ArriveDate, "") != "")
                    {
                        order.ArriveDate = orderModel.ArriveDate.ToString("yyyy-MM-dd");
                    }
                    if (!string.IsNullOrEmpty(orderModel.AddrID.ToString()))
                    {
                        Hi.Model.BD_DisAddr addr = new Hi.BLL.BD_DisAddr().GetModel(orderModel.AddrID);
                        if (addr != null)
                        {
                            order.Zip = addr.Zip;
                        }
                    }
                    order.Address           = orderModel.Address;
                    order.Contact           = orderModel.Principal;
                    order.Phone             = orderModel.Phone;
                    order.TotalAmount       = orderModel.AuditAmount.ToString("0.00");
                    order.AuditTotalAmount  = orderModel.AuditAmount.ToString("0.00");
                    order.PayedAmount       = orderModel.PayedAmount.ToString("0.00");
                    order.CreateUserID      = orderModel.CreateUserID.ToString();
                    order.CreateDate        = orderModel.CreateDate.ToString("yyyy-MM-dd HH:mm");
                    order.ReturnMoneyDate   = orderModel.ReturnMoneyDate.ToString();
                    order.ReturnMoneyUser   = orderModel.ReturnMoneyUser;
                    order.ReturnMoneyUserId = orderModel.ReturnMoneyUserId.ToString();

                    List <Hi.Model.DIS_OrderOut> outList = new Hi.BLL.DIS_OrderOut().GetList("",
                                                                                             " OrderID='" + orderModel.ID + "' and CompID='" + orderModel.CompID + "' and DisID='" +
                                                                                             orderModel.DisID + "' and ISNULL(dr,0)=0", "");
                    if (outList.Count != 0)
                    {
                        Hi.Model.DIS_OrderOut orderOut = new Hi.Model.DIS_OrderOut();
                        foreach (Hi.Model.DIS_OrderOut Out in outList)
                        {
                            orderOut = Out;
                        }
                        order.SendID   = orderOut.ID.ToString();
                        order.SendDate = orderOut.SendDate.ToString();
                        ////order.Express = orderOut.Express;
                        ////order.ExpressNo = orderOut.ExpressNo;
                        ////order.ExpressPerson = orderOut.ExpressPerson;
                        ////order.ExpressTel = orderOut.ExpressTel;
                        ////order.ExpressBao = orderOut.ExpressBao;
                        ////order.PostFee = orderOut.PostFee.ToString("0.00");
                        order.ActionUser = orderOut.ActionUser;
                        List <Hi.Model.DIS_Logistics> exlist = Common.GetExpress(orderOut.ID.ToString());
                        if (exlist != null)
                        {
                            order.SendRemark = exlist[0].Context;
                        }
                        order.IsAudit     = orderOut.IsAudit.ToString();
                        order.AuditUserID = orderOut.AuditUserID.ToString();
                        order.AuditDate   = orderOut.AuditDate.ToString();
                        order.AuditRemark = orderOut.AuditRemark == null ? "" : orderOut.AuditRemark.ToString();
                        order.SignDate    = orderOut.SignDate.ToString();
                        order.IsSign      = orderOut.IsSign.ToString();
                        order.SignUserId  = orderOut.SignUserId.ToString();
                        order.SignUser    = orderOut.SignUser;
                        order.SignRemark  = orderOut.SignRemark;
                    }
                    //todo:不知道的排序
                    //order.SortIndex = orderModel.SortIndex.ToString();
                    order.IsDel = orderModel.dr.ToString();

                    //明细
                    List <OrderDetail> orderDetail             = new List <OrderDetail>();
                    List <Hi.Model.DIS_OrderDetail> detailList = new Hi.BLL.DIS_OrderDetail().GetList("",
                                                                                                      " OrderID='" + orderModel.ID + "' and DisID='" + orderModel.DisID + "' and ISNULL(dr,0)=0", "");
                    if (detailList == null) //|| detailList.Count==0
                    {
                        return new ResultOrderList()
                               {
                                   Result = "F", Description = "订单明细异常"
                               }
                    }
                    ;
                    List <Hi.Model.BD_GoodsAttrs> list_attrs = null;
                    foreach (Hi.Model.DIS_OrderDetail detail in detailList)
                    {
                        string SKUName = string.Empty;

                        OrderDetail ordetail = new OrderDetail();
                        ordetail.SKUID = detail.GoodsinfoID.ToString();
                        //通过GoodsInfoID找到GoodsID
                        Hi.Model.BD_GoodsInfo goodsInfo = new Hi.BLL.BD_GoodsInfo().GetModel(detail.GoodsinfoID);
                        if (goodsInfo == null)
                        {
                            //if (goodsInfo == null || goodsInfo.IsEnabled == false || goodsInfo.dr == 1)
                            return new ResultOrderList()
                                   {
                                       Result = "F", Description = "SKU信息异常"
                                   }
                        }
                        ;
                        ordetail.ProductID = goodsInfo.GoodsID.ToString();

                        //通过GoodsID找到GoodsName
                        Hi.Model.BD_Goods goods = new Hi.BLL.BD_Goods().GetModel(goodsInfo.GoodsID);
                        if (goods == null)
                        {
                            //if (goods == null || goods.IsEnabled == 0 | goods.dr == 1)
                            return new ResultOrderList()
                                   {
                                       Result = "F", Description = "商品异常"
                                   }
                        }
                        ;
                        ordetail.ProductName = goods.GoodsName;
                        SKUName += goods.GoodsName;

                        list_attrs = new Hi.BLL.BD_GoodsAttrs().GetList("AttrsName", "GoodsID = " + goodsInfo.GoodsID + " and CompID = " + comp.ID + " and ISNULL(dr,0) = 0", "");
                        if (list_attrs != null && list_attrs.Count != 0)
                        {
                            foreach (Hi.Model.BD_GoodsAttrs attr in list_attrs)
                            {
                                SKUName += attr.AttrsName;
                            }
                        }
                        ordetail.SKUName = SKUName;
                        //todo:描述是什么
                        ordetail.ValueInfo   = goodsInfo.ValueInfo;
                        ordetail.SalePrice   = detail.Price.ToString("0.00");
                        ordetail.TinkerPrice = detail.AuditAmount.ToString("0.00");
                        ordetail.Num         = detail.GoodsNum.ToString("0.00");
                        ordetail.Remark      = detail.Remark;
                        //ordetail.IsPro =  .Trim() == "0" || detail.vdef1.Trim() == "" ? "0" : "1"; //是否是促销商品
                        //是否是促销商品
                        ordetail.IsPro = ClsSystem.gnvl(detail.vdef1, "").Trim() == "0" || ClsSystem.gnvl(detail.vdef1, "").Trim() == "" ? "0" : "1";

                        if (ordetail.IsPro != "0")
                        {
                            ordetail.ProNum = detail.vdef5;

                            if (detail.vdef1 != "" && detail.vdef1.Length > 0)
                            {
                                Hi.Model.BD_Promotion pro =
                                    new Hi.BLL.BD_Promotion().GetModel(Convert.ToInt32(detail.vdef1));
                                if (pro != null)
                                {
                                    List <Hi.Model.BD_PromotionDetail> dList = new Hi.BLL.BD_PromotionDetail().GetList(
                                        "", " ProID=" + pro.ID + " and GoodInfoID ='" + ordetail.SKUID + "' and dr=0",
                                        "");
                                    string info = string.Empty;
                                    if (dList != null && dList.Count > 0)
                                    {
                                        if (pro.Type == 0 && pro.ProType == 1)
                                        {
                                            info = "赠品";
                                        }
                                        else if (pro.Type == 0 && pro.ProType == 2)
                                        {
                                            info = "商品优惠价" + dList[0].GoodsPrice.ToString("0.00");
                                        }
                                        else if (pro.Type == 1 && pro.ProType == 3)
                                        {
                                            info = "商品数量满" + pro.Discount.ToString("0.00") + "赠" + dList[0].GoodsPrice.ToString("0.00") + dList[0].GoodsUnit;
                                        }
                                        else if (pro.Type == 1 && pro.ProType == 4)
                                        {
                                            info = "商品打折" + pro.Discount.ToString("0.00") + "%";
                                        }
                                    }
                                    ordetail.proInfo = new PromotionInfo()
                                    {
                                        ProID        = detail.vdef1,
                                        ProTitle     = pro.ProTitle,
                                        ProInfos     = info,
                                        Type         = pro.Type.ToString(),
                                        ProTpye      = pro.ProType.ToString(),
                                        Discount     = pro.Discount.ToString("0.00"),
                                        ProStartTime = pro.ProStartTime.ToString("yy-MM-dd"),
                                        ProEndTime   = pro.ProEndTime.ToString("yy-MM-dd")
                                    };
                                }
                            }
                        }

                        List <Pic> Pic = new List <Pic>();
                        if (goods.Pic != "" && goods.Pic != "X")
                        {
                            Pic pic = new Pic();
                            pic.ProductID = goodsInfo.GoodsID.ToString();
                            pic.IsDeafult = "1";
                            pic.PicUrl    = ConfigurationManager.AppSettings["ImgViewPath"].ToString().Trim() + "GoodsImg/" +
                                            goods.Pic;
                            Pic.Add(pic);
                        }
                        ordetail.ProductPicUrlList = Pic;

                        orderDetail.Add(ordetail);
                    }
                    order.OrderDetailList = orderDetail;
                    OrderList.Add(order);
                }
            }
            else
            {
                return(new ResultOrderList()
                {
                    Result = "F", Description = "没有更多数据"
                });
            }

            #endregion

            return(new ResultOrderList()
            {
                Result = "T",
                Description = "获取成功",
                OrderList = OrderList
            });
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "GetBriefingList:" + JSon);
            return(new ResultOrderList()
            {
                Result = "F", Description = "参数异常"
            });
        }
    }
Beispiel #11
0
    /// <summary>
    /// 数据绑定
    /// </summary>
    private void Bind()
    {
        if (KeyID != 0)
        {
            Hi.Model.BD_Promotion ProModel = new Hi.BLL.BD_Promotion().GetModel(KeyID);
            //促销公告
            List <Hi.Model.BD_CompNews> newsl = new Hi.BLL.BD_CompNews().GetList("", " PMID=" + KeyID + "and isnull(IsEnabled,0)=1", "");

            if (ProModel != null)
            {
                if (newsl != null && newsl.Count > 0)
                {
                    this.isOkComNews.Checked = true;
                    this.isNoComNews.Checked = false;
                }
                else
                {
                    this.isOkComNews.Checked = false;
                    this.isNoComNews.Checked = true;
                }
                this.txtPromotionDate.Value  = ProModel.ProStartTime == DateTime.MinValue ? "" : ProModel.ProStartTime.ToString("yyyy-MM-dd");
                this.txtPromotionDate1.Value = ProModel.ProEndTime == DateTime.MinValue ? "" : ProModel.ProEndTime.ToString("yyyy-MM-dd");
                this.txtProInfos.Value       = ProModel.ProInfos;
                //促销禁用
                if (ProModel.IsEnabled == 0)
                {
                    this.IsEnabled0.Checked = true;
                    this.IsEnabled1.Checked = false;
                }
                else
                {
                    this.IsEnabled0.Checked = false;
                    this.IsEnabled1.Checked = true;
                }
                List <Hi.Model.BD_PromotionDetail2> ll = new Hi.BLL.BD_PromotionDetail2().GetList("", "isnull(dr,0)=0 and proId=" + KeyID + " and compId=" + this.CompID, "");
                if (ll.Count > 1)
                {
                    this.Radio1.Checked = true;
                    this.Radio2.Checked = false;
                }
                else
                {
                    this.Radio2.Checked = true;
                    this.Radio1.Checked = false;
                }
                string html = "";
                if (ProModel.ProType == 5)
                {
                    this.promotionType3.Checked = true;
                    this.promotionType4.Checked = false;
                    int z = 0;
                    foreach (Hi.Model.BD_PromotionDetail2 item in ll)
                    {
                        z++;

                        html += "<label>订单金额满¥<input type=\"text\" onkeyup='KeyInt2(this)' id=\"txtPrice" + z + "\" class=\"send txtPrice\" style=\"width: 50px;\" name=\"txtPrice\" value=\"" + item.OrderPrice.ToString("f2") + "\" />,立减¥<input type=\"text\" id=\"txtSendFull" + z + "\" onkeyup='KeyInt2(this)' class=\"send txtSendFull\" name=\"txtSendFull\" style=\"width: 50px;\" value=\"" + item.Discount.ToString("f2") + "\"/>";
                        if (z > 1)
                        {
                            html += "<a class=\"theme-color ml20 deleteItem\" href=\"javascript:;\">删除</a>";
                        }
                        html += "</label><br>";
                    }
                    this.SendFull.InnerHtml = html.Substring(0, html.LastIndexOf("<"));
                }
                else if (ProModel.ProType == 6)
                {
                    this.promotionType4.Checked = true;
                    this.promotionType3.Checked = false;
                    int x = 0;
                    foreach (Hi.Model.BD_PromotionDetail2 item in ll)
                    {
                        x++;
                        html += "<label>订单金额满¥<input type=\"text\" onkeyup='KeyInt2(this)' id=\"txtPrices" + x + "\" class=\"send txtPrices\" style=\"width: 50px;\" name=\"txtPrices\"  value=\"" + item.OrderPrice.ToString("f2") + "\"/>,打折(<input type=\"text\" id=\"txtDiscount" + x + "\" onkeyup='KeyInt2(this)' class=\"send txtDiscount\" name=\"txtDiscount\" style=\"width: 20px;\"  value=\"" + Convert.ToInt32(item.Discount) + "\"/>)%";
                        if (x > 1)
                        {
                            html += "<a class=\"theme-color ml20 deleteItem\" href=\"javascript:;\">删除</a>";
                        }
                        html += "</label><br>";
                    }
                    this.Discount.InnerHtml = html.Substring(0, html.LastIndexOf("<"));
                }
            }
        }
    }
Beispiel #12
0
    /// <summary>
    /// 保存
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string str              = string.Empty;
        string ProType          = string.Empty; //促销方式
        string ProIsEnabled     = string.Empty; //是否启用
        string ProInfos         = string.Empty; //促销描述
        string ProIsJieTi       = string.Empty; //是否启用阶梯
        string PromotionDate    = string.Empty; //促销开始日期
        string PromotionEndDate = string.Empty; //促销结束日期
        int    isComNew         = 0;            //是否发布促销公告

        #region 判断值是否为空,取值
        //促销方式
        ProType = Request["promotionType"].ToString();
        //是否启用
        ProIsEnabled = Request["IsEnabled"].ToString();
        //是否启用阶梯
        ProIsJieTi = Request["IsEnabled2"].ToString();
        //促销开始日期
        if (this.txtPromotionDate.Value.Trim() == "")
        {
            str += " -- 促销开始日期不能为空。</br>";
        }
        else
        {
            PromotionDate = this.txtPromotionDate.Value.Trim();
        }
        //促销结束日期
        if (this.txtPromotionDate1.Value.Trim() == "")
        {
            str += " -- 促销结束日期不能为空。</br>";
        }
        else
        {
            PromotionEndDate = this.txtPromotionDate1.Value.Trim();
        }
        ProInfos = Common.NoHTML(this.txtProInfos.Value.Trim().ToString());
        if (str != "")
        {
            JScript.AlertMsgOne(this, str, JScript.IconOption.错误, 2500);
            return;
        }

        #endregion

        //是否发布促销公告
        isComNew = this.isOkComNews.Checked ? 1 : 0;
        string NewsContents = string.Empty;
        NewsContents = "<font size=\"3\" style=\"line-height:30px;\">";
        SqlTransaction Tran = null;
        try
        {
            Hi.Model.BD_Promotion proModel = null;
            int ProId = 0;
            Tran = DBUtility.SqlHelper.CreateStoreTranSaction();
            if (KeyID != 0)//修改
            {
                ProId = KeyID;
                List <Hi.Model.BD_PromotionDetail2> l = new Hi.BLL.BD_PromotionDetail2().GetList("", "isnull(dr,0)=0 and proId=" + KeyID + " and compId=" + this.CompID, "", Tran);
                if (l.Count > 0)
                {
                    foreach (Hi.Model.BD_PromotionDetail2 item in l)
                    {
                        new Hi.BLL.BD_PromotionDetail2().Delete(item.ID, Tran);
                    }
                }
                proModel = new Hi.BLL.BD_Promotion().GetModel(KeyID, Tran);
            }
            else
            {
                proModel = new Hi.Model.BD_Promotion();
            }
            //else
            //{
            proModel.Type    = Type.ToInt(0);
            proModel.CompID  = this.CompID;
            proModel.ProType = ProType.ToInt(0);
            if (ProType == "5")
            {
                proModel.ProTitle = "订单满减促销";
            }
            else if (ProType == "6")
            {
                proModel.ProTitle = "订单满折促销";
            }
            proModel.IsEnabled    = ProIsEnabled.ToInt(0);
            proModel.Discount     = 0;
            proModel.ProStartTime = PromotionDate.ToDateTime();
            proModel.ProEndTime   = PromotionEndDate.ToDateTime();
            proModel.ProInfos     = ProInfos;
            proModel.CreateUserID = this.UserID;
            proModel.CreateDate   = DateTime.Now;
            proModel.modifyuser   = this.UserID;
            proModel.ts           = DateTime.Now.ToString();
            if (KeyID != 0)//修改
            {
                ProId       = KeyID;
                proModel.ID = KeyID;
                new Hi.BLL.BD_Promotion().Update(proModel, Tran);
            }
            else
            {
                ProId = new Hi.BLL.BD_Promotion().Add(proModel, Tran);
            }
            if (ProType == "5")
            {
                string[] price  = Request["txtPrice"].ToString().Split(',');    //需要满金额
                string[] price2 = Request["txtSendFull"].ToString().Split(','); //满后需要减得金额
                for (int i = 0; i < price.Length; i++)
                {
                    if (price[i] != "")
                    {
                        Hi.Model.BD_PromotionDetail2 modelDeta = new Hi.Model.BD_PromotionDetail2();
                        modelDeta.CompID       = this.CompID;
                        modelDeta.ProID        = ProId;
                        modelDeta.OrderPrice   = Convert.ToDecimal(price[i]);
                        modelDeta.Discount     = Convert.ToDecimal(price2[i]);
                        modelDeta.modifyuser   = this.UserID;
                        modelDeta.ts           = DateTime.Now;
                        modelDeta.CreateUserID = this.UserID;
                        modelDeta.CreateDate   = DateTime.Now;
                        new Hi.BLL.BD_PromotionDetail2().Add(modelDeta, Tran);
                        NewsContents += "订单金额满¥" + price[i] + ",立减¥" + price2[i] + "<br>";
                    }
                }
            }
            else if (ProType == "6")
            {
                string[] prices  = Request["txtPrices"].ToString().Split(',');   //需要满金额
                string[] prices2 = Request["txtDiscount"].ToString().Split(','); //满后折扣
                for (int i = 0; i < prices.Length; i++)
                {
                    if (prices[i] != "")
                    {
                        Hi.Model.BD_PromotionDetail2 modelDeta = new Hi.Model.BD_PromotionDetail2();
                        modelDeta.CompID       = this.CompID;
                        modelDeta.ProID        = ProId;
                        modelDeta.OrderPrice   = Convert.ToDecimal(prices[i]);
                        modelDeta.Discount     = Convert.ToDecimal(prices2[i]);
                        modelDeta.modifyuser   = this.UserID;
                        modelDeta.ts           = DateTime.Now;
                        modelDeta.CreateUserID = this.UserID;
                        modelDeta.CreateDate   = DateTime.Now;
                        new Hi.BLL.BD_PromotionDetail2().Add(modelDeta, Tran);
                        NewsContents += "订单金额满¥" + prices[i] + ",打折(" + prices2[i] + ")%<br>";
                    }
                }
            }
            //}
            Hi.Model.BD_CompNews news = new Hi.Model.BD_CompNews();

            news.CompID       = CompID;
            news.CreateDate   = DateTime.Now;
            news.CreateUserID = UserID;
            news.dr           = 0;
            news.ts           = DateTime.Now;
            news.IsTop        = 1;
            news.IsEnabled    = 0;
            news.NewsType     = 4;
            news.ShowType     = "2";
            if (ProType == "5")
            {
                news.NewsTitle = "订单满减促销";
            }
            else if (ProType == "6")
            {
                news.NewsTitle = "订单满折促销";
            }

            NewsContents += "先到先得!";
            ProInfos      = ProInfos == "" ? "" : "(" + ProInfos + ")";
            NewsContents += ProInfos;

            NewsContents += " </br> 活动时间:" + PromotionDate.ToDateTime().ToString("yyyy-MM-dd") + "至" + PromotionEndDate.ToDateTime().ToString("yyyy-MM-dd");

            NewsContents     += "</font>";
            news.NewsContents = NewsContents;
            news.modifyuser   = UserID;
            news.PmID         = ProId;
            if (isComNew == 1)
            {
                new Hi.BLL.BD_CompNews().Add(news, Tran);
            }
            Tran.Commit();
            Response.Write("<script>window.location.href='PromotionInfo2.aspx?KeyId=" + Common.DesEncrypt(ProId.ToString(), Common.EncryptKey) + "&type=" + Type + "';</script>");
        }
        catch (Exception ex)
        {
            if (Tran != null)
            {
                if (Tran.Connection != null)
                {
                    Tran.Rollback();
                }
            }
            JScript.AlertMsgOne(this, "保存失败了", JScript.IconOption.错误, 2500);
            return;
        }
        finally
        {
            DBUtility.SqlHelper.ConnectionClose();
        }
    }
Beispiel #13
0
    public ResultNewsList CompNewsList(string JSon)
    {
        try
        {
            StringBuilder str = new StringBuilder();

            #region JSon取值

            string userID          = string.Empty;
            string compID          = string.Empty;
            string criticalOrderID = string.Empty; //当前列表最临界点产品ID:初始-1
            string getType         = string.Empty; //方向
            string rows            = string.Empty;
            string sortType        = string.Empty;
            string sort            = string.Empty;
            string orderType       = string.Empty;
            string DisID           = string.Empty;

            JsonData JInfo = JsonMapper.ToObject(JSon);
            if (JInfo.Count > 0 && JInfo["UserID"].ToString() != "" && JInfo["CompanyID"].ToString() != "" &&
                JInfo["Search"].ToString() != "" && JInfo["CriticalOrderID"].ToString() != "" &&
                JInfo["GetType"].ToString() != "" && JInfo["Rows"].ToString() != "" &&
                JInfo["SortType"].ToString() != "" && JInfo["Sort"].ToString() != "" &&
                JInfo["OrderType"].ToString() != "")
            {
                userID = JInfo["UserID"].ToString().Trim();
                compID = JInfo["CompanyID"].ToString().Trim();
                str.Append(" AND CompID='" + compID + "' AND IsEnabled=1 and dr=0");
                criticalOrderID = JInfo["CriticalOrderID"].ToString();
                getType         = JInfo["GetType"].ToString();
                rows            = JInfo["Rows"].ToString();
                sortType        = JInfo["SortType"].ToString();
                sort            = JInfo["Sort"].ToString();
                orderType       = JInfo["OrderType"].ToString();//0:只按时间 1:置顶优先,再按时间排序
                //DisID = JInfo["ResellerID"].ToString();//经销商登录时需要传入经销商ID用于对登录信息进行判断
            }
            else
            {
                return(new ResultNewsList()
                {
                    Result = "F", Description = "参数异常"
                });
            }

            Hi.Model.SYS_Users user = new Hi.Model.SYS_Users();
            //if (DisID == "")
            //{
            //    if (!new Common().IsLegitUser(int.Parse(userID), out user, int.Parse(compID)))
            //        return new ResultNewsList() { Result = "F", Description = "登录信息异常" };
            //    Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(Convert.ToInt32(compID));
            //    if (comp == null || comp.dr == 1 || comp.AuditState == 0 || comp.IsEnabled == 0)
            //        return new ResultNewsList() { Result = "F", Description = "核心企业异常" };
            //}
            //else
            //{
            //    if (!new Common().IsLegitUser(int.Parse(userID), out user, 0, int.Parse(DisID)))
            //        return new ResultNewsList() { Result = "F", Description = "登录信息异常" };
            //    //判断经销商信息是否异常
            //    Hi.Model.BD_Distributor dis = new Hi.BLL.BD_Distributor().GetModel(Convert.ToInt32(DisID));
            //    if (dis == null || dis.dr == 1 || dis.IsEnabled == 0 || dis.AuditState == 0)
            //        return new ResultNewsList() { Result = "F", Description = "经销商信息异常" };
            //    //判断经销商对应的核心企业信息是否异常
            //    Hi.Model.BD_Company comp = new Hi.BLL.BD_Company().GetModel(dis.CompID);
            //    if (comp == null || comp.dr == 1 || comp.AuditState == 0 || comp.IsEnabled == 0)
            //        return new ResultNewsList() { Result = "F", Description = "核心企业异常" };
            //}

            JsonData JMsg = JInfo["Search"];
            if (JMsg.Count > 0)
            {
                string NewsID    = JMsg["NewsID"].ToString().Trim();
                string Title     = JMsg["Title"].ToString().Trim();
                string IsEnabled = JMsg["IsEnable"].ToString().Trim();
                string IsTop     = JMsg["IsTop"].ToString().Trim();
                string NewsType  = JMsg["NewsType"].ToString().Trim();

                string ShowType = JMsg["ShowType"].ToString().Trim();

                if (NewsID != "-1")
                {
                    str.Append(" and ID ='" + NewsID + "' ");
                }
                if (Title != "-1")
                {
                    str.Append(" and NewsTitle like '%" + Title + "%' ");
                }
                if (IsEnabled != "-1")
                {
                    str.Append(" and IsEnable = '" + IsEnabled + "' ");
                }
                if (IsTop != "-1")
                {
                    str.Append(" and IsTop = '" + IsTop + "' ");
                }
                if (NewsType != "-1")
                {
                    str.Append(" and NewsType = '" + NewsType + "' ");
                }
                if (ShowType != "-1")
                {
                    str.Append(ShowType == "3" ? " and ShowType = '1,2' " : " and ShowType = '" + ShowType + "' ");
                }
            }

            #endregion

            List <NewsInfo> NewsList = new List <NewsInfo>();

            if (orderType == "1")
            {
                #region 取当前置顶的新闻公告

                List <Hi.Model.BD_CompNews> newsList = new Hi.BLL.BD_CompNews().GetList("",
                                                                                        " IsEnabled =1 and IsTop =1 and CompID='" + compID + "' and dr=0", "createDate desc");
                if (newsList != null && newsList.Count != 0)
                {
                    str.Append(" and ID not in (-1");  //通用列表中去除置顶公告
                    if (criticalOrderID.Trim() == "-1")
                    {
                        //    List<NewsInfo> NewsList_select = newsList.Select(newsInfo => new NewsInfo()
                        //       {
                        //           NewsID = newsInfo.ID.ToString(),
                        //           Title = newsInfo.NewsTitle,
                        //           IsEnabled = newsInfo.IsEnabled.ToString(),
                        //           IsTop = newsInfo.IsTop.ToString(),
                        //           NewsType = newsInfo.NewsType.ToString(),

                        //           ShowType =
                        //               newsInfo.ShowType != "1" && newsInfo.ShowType != "2" && ClsSystem.gnvl(newsInfo.ShowType,"").Trim() != ""
                        //               ? "3" : newsInfo.ShowType,
                        //           CreateTime = newsInfo.CreateDate.ToString()
                        //       }
                        //   ).ToList();
                        foreach (
                            NewsInfo news in newsList.Select(newsInfo => new NewsInfo()
                        {
                            NewsID = newsInfo.ID.ToString(),
                            Title = newsInfo.NewsTitle,
                            IsEnabled = newsInfo.IsEnabled.ToString(),
                            IsTop = newsInfo.IsTop.ToString(),
                            NewsType = newsInfo.NewsType.ToString(),

                            ShowType =
                                newsInfo.ShowType != "1" && newsInfo.ShowType != "2" && ClsSystem.gnvl(newsInfo.ShowType, "").Trim() != ""
                                    ? "3" : newsInfo.ShowType,
                            CreateTime = newsInfo.CreateDate.ToString()
                        }
                                                             ))
                        //foreach (NewsInfo news in NewsList_select)
                        {
                            NewsList.Add(news);
                            str.Append("," + news.NewsID);
                        }
                    }
                    str.Append(")");
                }

                #endregion

                int dtRow = Convert.ToInt32(rows) - NewsList.Count;
                if (dtRow > 1)
                {
                    rows = dtRow.ToString();
                }
            }

            #region 模拟分页

            string tabName = " [dbo].[BD_CompNews]"; //表名
            string strsql  = string.Empty;           //搜索sql
            sortType = "CreateDate";
            sort     = "0";
            strsql   = new Common().PageSqlString(criticalOrderID, "ID", tabName, sortType, sort, str.ToString(), getType, rows);
            if (strsql == "")
            {
                return new ResultNewsList()
                       {
                           Result = "F", Description = "基础数据异常"
                       }
            }
            ;

            #endregion

            #region 赋值

            DataSet ds = SqlHelper.Query(SqlHelper.LocalSqlServer, strsql);
            if (ds.Tables.Count == 0)
            {
                if (NewsList.Count == 0)
                {
                    return new ResultNewsList()
                           {
                               Result = "T", Description = "没有更多数据"
                           }
                }
                ;
                else
                {
                    return(new ResultNewsList()
                    {
                        Result = "T", Description = "", NewsList = NewsList
                    });
                }
            }
            DataTable dtList = ds.Tables[0];
            if (dtList != null)
            {
                if (dtList.Rows.Count == 0)
                {
                    if (NewsList.Count != 0)
                    {
                        return new ResultNewsList()
                               {
                                   Result = "T", Description = "", NewsList = NewsList
                               }
                    }
                    ;
                    else
                    {
                        return(new ResultNewsList()
                        {
                            Result = "F", Description = "没有更多数据"
                        });
                    }
                }
                foreach (DataRow newsInfo in dtList.Rows)
                {
                    NewsInfo news = new NewsInfo();

                    news.NewsID    = newsInfo["ID"].ToString();
                    news.Title     = newsInfo["NewsTitle"].ToString();
                    news.IsOverdue = "0";
                    if (newsInfo["NewsType"].ToString() == "4")
                    {
                        if (newsInfo["PmID"] != null && Convert.ToInt32(newsInfo["PmID"]) != 0)
                        {
                            Hi.Model.BD_Promotion pro = new Hi.BLL.BD_Promotion().GetModel(Convert.ToInt32(newsInfo["PmID"].ToString()));
                            if (pro.ProEndTime < DateTime.Now)
                            {
                                news.IsOverdue = "1";
                            }
                        }
                    }
                    news.IsEnabled = newsInfo["IsEnabled"].ToString();
                    news.IsTop     = newsInfo["IsTop"].ToString();
                    news.NewsType  = newsInfo["NewsType"].ToString();
                    news.ShowType  = newsInfo["ShowType"].ToString() != "1" && newsInfo["ShowType"].ToString() != "2" &&
                                     newsInfo["ShowType"].ToString().Trim() != "" ? "3" : newsInfo["ShowType"].ToString();
                    news.CreateTime = newsInfo["CreateDate"].ToString();

                    NewsList.Add(news);
                }
            }

            #endregion

            return(new ResultNewsList()
            {
                Result = "T", Description = "获取成功", NewsList = NewsList
            });
        }
        catch (Exception ex)
        {
            Common.CatchInfo(ex.Message + ":" + ex.StackTrace, "CompNewsList :" + JSon);
            return(new ResultNewsList()
            {
                Result = "F", Description = "异常"
            });
        }
    }