Esempio n. 1
0
        /// <summary>
        /// 获得特价
        /// </summary>
        /// <returns></returns>
        public DataTable getSpecialOffer()
        {
            Tag tag = this.Document.CurrentRenderingTag;

            var attribute = tag.Attributes["rows"];
            int rows      = -1;//若为-1,则不做限制条件

            if (attribute != null && MyCommFun.isNumber(attribute.Value.GetValue()))
            {
                rows = MyCommFun.Obj2Int(attribute.Value.GetValue());
            }
            DAL.wx_shop_product artDal = new DAL.wx_shop_product();
            productlist = artDal.GetList(wid, rows, "specialOffer=" + 1);
            DataTable dt = productlist.Tables[0];

            if (productlist != null && productlist.Tables.Count > 0 && productlist.Tables[0].Rows.Count > 0)
            {
                DataRow dr;
                for (int i = 0; i < productlist.Tables[0].Rows.Count; i++)
                {
                    dr = productlist.Tables[0].Rows[i];
                    if (dr["link_url"] != null && dr["link_url"].ToString().Trim().Length > 0)
                    {
                        dr["link_url"] = MyCommFun.urlAddOpenid(dr["link_url"].ToString().Trim(), openid);
                    }
                    else
                    {
                        dr["link_url"] = MyCommFun.urlAddOpenid("detail.aspx?wid=" + wid + "&pid=" + dr["id"].ToString(), openid);
                    }
                    productlist.AcceptChanges();
                }
            }
            return(dt);
        }
Esempio n. 2
0
        /// <summary>
        /// 去除url的page的值,并且将page参数放到url的最后
        /// </summary>
        /// <returns></returns>
        private string removePageUrl()
        {
            string url     = Request.Url.ToString();
            int    pageNum = MyCommFun.RequestInt("page");

            if (url.Contains("?page="))
            {
                url = url.Replace("?page=" + pageNum, "?page=");
            }
            else if (url.Contains("&page="))
            {
                url  = url.Replace("&page=" + pageNum, "");
                url += "&page=";
            }
            else
            {
                if (url.Contains("?"))
                {
                    url = url + "&page=";
                }
                else
                {
                    url = url + "?page=";
                }
            }
            url = MyCommFun.urlAddOpenid(url, openid);
            return(url);
        }
Esempio n. 3
0
        /// <summary>
        /// 绑定活动类别的方法
        /// </summary>
        public void BindTypeData()
        {
            BLL.wx_product_type           sbll     = new BLL.wx_product_type();
            IList <Model.wx_product_type> typelist = sbll.GetModelList("wid=" + wid + " and store_id=" + pid + " order by sort_id asc");

            if (typelist != null && typelist.Count > 0)
            {
                StringBuilder sb = new StringBuilder("");
                for (int i = 0; i < typelist.Count; i++)
                {
                    string url = "";
                    if (typelist[i].tUrl != null && typelist[i].tUrl.Trim().Length > 0)
                    {
                        url = MyCommFun.urlAddOpenid(typelist[i].tUrl, openid);
                    }
                    else
                    {
                        url = MyCommFun.urlAddOpenid("index.aspx?tid=" + typelist[i].id + "&wid=" + wid + "&pid=" + pid, openid);
                    }
                    sb.Append(" <li>");
                    sb.Append("<a href=\"" + url + "\">" + typelist[i].tName);
                    sb.Append("</a></li>");
                }
                litTypeInfo.Text = sb.ToString();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 获得幻灯片列表二:优点:(1)使用function标签与foreach结合,可以从模版页面控制记录数量;(2)不需要实现注册到模版里
        /// </summary>
        /// <returns></returns>
        public IList <Model.wx_shop_indexbanner> getHdp()
        {
            Tag tag = this.Document.CurrentRenderingTag;

            var attribute = tag.Attributes["rows"];
            IList <Model.wx_shop_indexbanner> artlist = new List <Model.wx_shop_indexbanner>();

            int rows = -1;//若为-1,则不做限制条件

            if (attribute != null && MyCommFun.isNumber(attribute.Value.GetValue()))
            {
                rows = MyCommFun.Obj2Int(attribute.Value.GetValue());
            }
            MxWeiXinPF.DAL.wx_shop_indexbanner sibDal = new DAL.wx_shop_indexbanner();
            artlist = sibDal.GetHDPByWid(wid, rows);

            if (artlist != null && artlist.Count > 0)
            {
                Model.wx_shop_indexbanner cat = new Model.wx_shop_indexbanner();
                for (int i = 0; i < artlist.Count; i++)
                {
                    cat = artlist[i];

                    if (cat.bannerLinkUrl == null || cat.bannerLinkUrl.Trim() == "")
                    {  //如果link_url为空,则直接调用本系统的信息
                        cat.bannerLinkUrl = "javascript:;";
                    }
                    else
                    {
                        cat.bannerLinkUrl = MyCommFun.urlAddOpenid(cat.bannerLinkUrl, openid);
                    }
                }
            }
            return(artlist);
        }
Esempio n. 5
0
        /// <summary>
        /// 获得单页文章列表:优点:(1)使用function标签与foreach结合,可以从模版页面控制记录数量;(2)不需要实现注册到模版里
        /// </summary>
        /// <returns></returns>
        public IList <Model.article> getDanyeList()
        {
            Tag tag = this.Document.CurrentRenderingTag;

            var attribute = tag.Attributes["rows"];
            IList <Model.article> artlist = new List <Model.article>();

            int rows = -1;//若为-1,则不做限制条件

            if (attribute != null && MyCommFun.isNumber(attribute.Value.GetValue()))
            {
                rows = MyCommFun.Obj2Int(attribute.Value.GetValue());
            }

            artlist = tDal.GetDanYeByWid(wid, rows);

            if (artlist != null && artlist.Count > 0)
            {
                Model.article cat = new Model.article();
                for (int i = 0; i < artlist.Count; i++)
                {
                    cat = artlist[i];

                    if (cat.link_url == null || cat.link_url.Trim() == "")
                    {                                                                                                           //如果link_url为空,则直接调用本系统的信息
                        cat.link_url = MyCommFun.urlAddOpenid("content.aspx?wid=" + wid + "&aid=" + cat.id.ToString(), openid); //"http://localhost:820/content.aspx?wid=5&aid=112";
                    }
                    else
                    {
                        cat.link_url = MyCommFun.urlAddOpenid(cat.link_url, openid);
                    }
                }
            }
            return(artlist);
        }
Esempio n. 6
0
        /// <summary>
        /// 商城首页的url
        /// </summary>
        /// <returns></returns>
        private string indexUrl()
        {
            string url = "";

            // url = MyCommFun.getWebSite() + "/shop/index.aspx?wid=" + wid;
            url = MyCommFun.urlAddOpenid("/shop/index.aspx?wid=" + wid, openid);
            return(url);
        }
Esempio n. 7
0
        /// <summary>
        /// 获得wid的用户分类信息
        /// </summary>
        /// <returns></returns>
        public IList <Model.wx_shop_category> getCategory()
        {
            Tag tag = this.Document.CurrentRenderingTag;

            ///classlayer表示取类别深度,如果为-1,则取所有分类的深度,如果为1,则取第一层目录,如果为2,则去第2层目录
            var classlayer  = tag.Attributes["classlayer"];
            var parentidObj = tag.Attributes["parentid"];
            var attribute   = tag.Attributes["rows"];
            int rows        = -1;//若为-1,则不做限制条件
            IList <Model.wx_shop_category> categorylist = null;
            int parentid = -1;

            if (parentidObj != null && MyCommFun.isNumber(parentidObj.Value.GetValue()))
            {
                parentid = MyCommFun.Obj2Int(parentidObj.Value.GetValue());
            }
            int class_layer = -1;

            if (classlayer != null && MyCommFun.isNumber(classlayer.Value.GetValue()))
            {
                class_layer = MyCommFun.Obj2Int(classlayer.Value.GetValue());
            }
            DAL.wx_shop_category cateBll = new DAL.wx_shop_category();
            if (attribute != null && MyCommFun.isNumber(attribute.Value.GetValue()))
            {
                rows         = MyCommFun.Obj2Int(attribute.Value.GetValue());
                categorylist = cateBll.GetCategoryListByWid(wid, rows, parentid, class_layer);
            }
            else
            {
                categorylist = cateBll.GetCategoryListByWid(wid, -1, parentid, class_layer);
            }
            if (categorylist != null && categorylist.Count > 0)
            {
                Model.wx_shop_category cat = new Model.wx_shop_category();

                for (int i = 0; i < categorylist.Count; i++)
                {
                    cat = categorylist[i];
                    if (cat.link_url == null || cat.link_url.Trim() == "")
                    {  //如果link_url为空,则直接调用本系统的信息
                        cat.link_url = MyCommFun.urlAddOpenid("/shop/list.aspx?wid=" + wid + "&cid=" + cat.id + "", openid);
                    }
                    else
                    {
                        cat.link_url = MyCommFun.urlAddOpenid(cat.link_url, openid);
                    }
                }
            }

            return(categorylist);
        }
Esempio n. 8
0
        /// <summary>
        /// 获得wid的用户分类信息
        /// </summary>
        /// <returns></returns>
        public IList <Model.article_category> getCategory()
        {
            Tag tag = this.Document.CurrentRenderingTag;

            ///classlayer表示取类别深度,如果为-1,则取所有分类的深度,如果为1,则取第一层目录,如果为2,则去第2层目录
            var classlayer  = tag.Attributes["classlayer"];
            var parentidObj = tag.Attributes["parentid"];

            int parentid = -1;

            if (parentidObj != null && MyCommFun.isNumber(parentidObj.Value.GetValue()))
            {
                parentid = MyCommFun.Obj2Int(parentidObj.Value.GetValue());
            }
            int class_layer = -1;

            if (classlayer != null && MyCommFun.isNumber(classlayer.Value.GetValue()))
            {
                class_layer = MyCommFun.Obj2Int(classlayer.Value.GetValue());
            }

            IList <Model.article_category> categorylist = tDal.GetCategoryListByWid(wid, -1, parentid, class_layer);

            if (categorylist != null && categorylist.Count > 0)
            {
                Model.article_category cat = new Model.article_category();
                for (int i = 0; i < categorylist.Count; i++)
                {
                    cat = categorylist[i];
                    if (cat.hasSun)
                    {  //有子分类
                        cat.link_url = MyCommFun.urlAddOpenid("/category.aspx?wid=" + wid + "&cid=" + cat.id, openid);
                    }
                    else
                    {
                        if (cat.link_url == null || cat.link_url.Trim() == "")
                        {  //如果link_url为空,则直接调用本系统的信息
                            cat.link_url = MyCommFun.urlAddOpenid("/list.aspx?wid=" + wid + "&cid=" + cat.id, openid);
                        }
                        else if (!isContainsNoOpenid_hz(cat.link_url))
                        {
                            cat.link_url = MyCommFun.urlAddOpenid(cat.link_url, openid);
                        }
                    }
                }
            }

            return(categorylist);
        }
Esempio n. 9
0
        /// <summary>
        /// 频道,即二级分类
        /// </summary>
        public void CategoryPage()
        {
            int parentId = MyCommFun.RequestInt("cid");

            this.Document.SetValue("parentid", parentId);//父级id
            BLL.article_category   cateBll   = new BLL.article_category();
            Model.article_category pCategory = cateBll.GetModel(parentId);
            if (pCategory == null)
            {
                return;
            }
            this.Document.SetValue("pcategory", pCategory);//父级分类基本信息

            this.Document.SetValue("fxTitle", pCategory.title);
            this.Document.SetValue("fxDesc", pCategory.content);
            this.Document.SetValue("fxPic", MyCommFun.ImgAddHttp(pCategory.img_url));


            //去二级分类
            IList <Model.article_category> categorylist = tDal.GetCategoryListByWid(wid, -1, parentId, 2);

            if (categorylist != null && categorylist.Count > 0)
            {
                Model.article_category cat = new Model.article_category();
                for (int i = 0; i < categorylist.Count; i++)
                {
                    cat = categorylist[i];
                    if (cat.hasSun)
                    {  //有子分类
                        cat.link_url = MyCommFun.urlAddOpenid("/category.aspx?wid=" + wid + "&cid=" + cat.id, openid);
                    }
                    else
                    {
                        if (cat.link_url == null || cat.link_url.Trim() == "")
                        {  //如果link_url为空,则直接调用本系统的信息
                            cat.link_url = MyCommFun.urlAddOpenid("/list.aspx?wid=" + wid + "&cid=" + cat.id, openid);
                        }
                        else
                        {
                            cat.link_url = MyCommFun.urlAddOpenid(cat.link_url, openid);
                        }
                    }
                }

                this.Document.SetValue("clist", categorylist);//二级分类列表
            }
        }
Esempio n. 10
0
        /// <summary>
        /// 取商品列表,混合调用
        /// </summary>
        public DataTable ProductIndexPage()
        {
            Tag tag = this.Document.CurrentRenderingTag;
            //数据条数
            var topTag = tag.Attributes["top"];
            int top    = MyCommFun.Obj2Int(topTag.Value.GetValue());
            //取类ID
            var classlayer = tag.Attributes["cid"];
            int classid    = MyCommFun.Obj2Int(classlayer.Value.GetValue());
            //自定义where
            var    whereTag = tag.Attributes["where"];
            string mywhere  = MyCommFun.ObjToStr(whereTag.Value.GetValue());

            var    orderByTag = tag.Attributes["orderby"];
            string orderby    = MyCommFun.ObjToStr(orderByTag.Value.GetValue());

            string where = where = " wid=" + wid;
            if (classid != 0)
            {
                where += " and categoryId=" + classid;
            }

            where += mywhere;

            DataSet productlist = new DataSet();


            DAL.wx_shop_product artDal = new DAL.wx_shop_product();
            productlist = artDal.GetList(top, where, orderby);
            if (productlist != null && productlist.Tables.Count > 0 && productlist.Tables[0].Rows.Count > 0)
            {
                DataRow dr;

                for (int i = 0; i < productlist.Tables[0].Rows.Count; i++)
                {
                    dr             = productlist.Tables[0].Rows[i];
                    dr["link_url"] = MyCommFun.urlAddOpenid("detail.aspx?wid=" + wid + "&pid=" + dr["id"].ToString(), openid);
                    productlist.AcceptChanges();
                }
            }

            DataTable ds = new DataTable();

            ds = productlist.Tables[0].Copy();
            return(ds);
        }
Esempio n. 11
0
        public string DetailUrl(int wid, int id, float x, float y, string wUrl)
        {
            string openid = MyCommFun.RequestOpenid();
            string newurl = "";

            if (wUrl == null || wUrl.ToString().Trim().Length <= 0)
            {
                //到detailAddr.aspx
                newurl = "detailAddr.aspx?shopid=" + id.ToString() + "&x=" + x.ToString() + "&y=" + y.ToString() + "&wid=" + wid.ToString() + "&openid=" + openid;
            }
            else
            {
                newurl = MyCommFun.urlAddOpenid(wUrl.ToString(), openid);
            }

            return(newurl);
        }
Esempio n. 12
0
        /// <summary>
        /// 获得所有分类+底部菜单(排除url为空的)
        /// </summary>
        /// <returns></returns>
        public IList <Model.article_category> getAllCateMenu()
        {
            IList <Model.article_category> category  = getCategory();
            IList <Model.article_category> bmenulist = tDal.GetBottomMenuByWid(wid, -1, -1, -1);

            if (bmenulist != null && bmenulist.Count > 0)
            {
                Model.article_category cat = new Model.article_category();
                for (int i = 0; i < bmenulist.Count; i++)
                {
                    cat = bmenulist[i];
                    if (cat.link_url != null && cat.link_url.Trim() != "")
                    {
                        cat.link_url = MyCommFun.urlAddOpenid(cat.link_url, openid);
                        category.Add(cat);
                    }
                }
            }
            return(category);
        }
Esempio n. 13
0
        /// <summary>
        /// 获得底部菜单
        /// </summary>
        /// <returns></returns>
        public IList <Model.article_category> getBottomMenu()
        {
            string openid = MyCommFun.RequestOpenid();

            Tag tag         = this.Document.CurrentRenderingTag;
            var classlayer  = tag.Attributes["classlayer"];
            var parentidObj = tag.Attributes["parentid"];
            int parentid    = -1;

            if (parentidObj != null && MyCommFun.isNumber(parentidObj.Value.GetValue()))
            {
                parentid = MyCommFun.Obj2Int(parentidObj.Value.GetValue());
            }
            int class_layer = -1;

            if (classlayer != null && MyCommFun.isNumber(classlayer.Value.GetValue()))
            {
                class_layer = MyCommFun.Obj2Int(classlayer.Value.GetValue());
            }

            IList <Model.article_category> bmenulist = tDal.GetBottomMenuByWid(wid, -1, parentid, class_layer);

            if (bmenulist != null && bmenulist.Count > 0)
            {
                Model.article_category cat = new Model.article_category();
                for (int i = 0; i < bmenulist.Count; i++)
                {
                    cat = bmenulist[i];
                    if (cat.link_url == null || cat.link_url.Trim() == "" || isContainsNoOpenid_hz(cat.link_url))
                    {
                    }
                    else
                    {
                        cat.link_url = MyCommFun.urlAddOpenid(cat.link_url, openid);
                    }
                }
            }


            return(bmenulist);
        }
Esempio n. 14
0
        /// <summary>
        /// 绑定页面的repeater活动列表
        /// </summary>
        /// <param name="currentPage"></param>
        public void BindRepeater(int currentPage)
        {
            int RecordCount = 0;

            // currentPage -= 1;
            DataSet hdDt = hdBll.GetPageList(" typeId  in (select id from  wx_product_type where wid=" + wid + "  and store_id=" + pid + ")", pageSize, currentPage, out RecordCount, " extInt asc,createdate desc");

            string showinfoStr = "";

            if (hdDt != null && hdDt.Tables.Count > 0 && hdDt.Tables[0].Rows.Count > 0)
            {
                DataRow dr;
                for (int i = 0; i < hdDt.Tables[0].Rows.Count; i++)
                {
                    dr          = hdDt.Tables[0].Rows[i];
                    showinfoStr = "";
                    if (dr["showDate"].ToString().ToLower() == "true")
                    {
                        showinfoStr += " <span class=\"list_span\">" + dateStr(dr["createDate"]) + "</span>";
                    }
                    if (dr["showPrice"].ToString().ToLower() == "true")
                    {
                        showinfoStr += "<span class=\"list_span span_money\">¥" + MyCommFun.ObjToStr(dr["price"]) + "</span>";
                    }
                    if (dr["showYuDing"].ToString().ToLower() == "true")
                    {
                        showinfoStr += " <a href='" + MyCommFun.urlAddOpenid(MyCommFun.ObjToStr(dr["url"]), openid) + "' class=\"a_yuding\">" + (MyCommFun.ObjToStr(dr["btnName"]) == null ? "预定" : MyCommFun.ObjToStr(dr["btnName"])) + "</a>";
                    }
                    if (showinfoStr != "")
                    {
                        dr["showInfo"] = " <div class=\"list_div\">" + showinfoStr + " </div>  ";
                    }
                }
            }

            rpAction.DataSource = hdDt;
            rpAction.DataBind();
            litCurrentPage.Text = currentPage.ToString();
        }
Esempio n. 15
0
        /// <summary>
        /// 根据pageNum设置新的带有页码的url地址
        /// </summary>
        /// <param name="page"></param>
        /// <returns></returns>
        private string GetNewUrl(int page)
        {
            string url     = Request.Url.ToString();
            int    pageNum = MyCommFun.RequestInt("page");

            if (url.Contains("page="))
            {
                url = url.Replace("page=" + pageNum, "page=" + page);
            }
            else
            {
                if (url.Contains("?"))
                {
                    url = url + "&page=" + page;
                }
                else
                {
                    url = url + "?page=" + page;
                }
            }
            url = MyCommFun.urlAddOpenid(url, openid);
            return(url);
        }
Esempio n. 16
0
        /// <summary>
        /// 列表页面独有的数据
        /// </summary>
        public void ArticleClassPage()
        {
            int category_id = MyCommFun.RequestInt("cid");

            //--=====begin: 将这个列表(文章类别)的基本信息展示出来 ====--
            Model.article_category category = tDal.GetCategoryByWid(wid, category_id);
            this.Document.SetValue("category", category);
            //--=====end: 将这个列表(文章类别)的基本信息展示出来 ====--

            Tag    orderByTag = this.Document.GetChildTagById("norderby");
            string orderby    = orderByTag.Attributes["value"].Value.ToString();

            Tag    pagesizeTag = this.Document.GetChildTagById("npagesize");
            string pagesizeStr = pagesizeTag.Attributes["value"].Value.ToString();

            int currPage    = 1;                              //当前页面
            int recordCount = 0;                              //总记录数
            int totPage     = 1;                              //总页数
            int pageSize    = MyCommFun.Str2Int(pagesizeStr); //每页的记录数

            if (pageSize <= 0)
            {
                pageSize = 10;
            }
            if (MyCommFun.RequestInt("page") > 0)
            {
                currPage = MyCommFun.RequestInt("page");
            }

            DataSet artlist = new DataSet();

            if (category_id != 0)
            {
                DAL.article artDal = new DAL.article();
                artlist = artDal.GetList("news", category_id, pageSize, currPage, "wid=" + wid, orderby, out recordCount);
                if (artlist != null && artlist.Tables.Count > 0 && artlist.Tables[0].Rows.Count > 0)
                {
                    DataRow dr;
                    for (int i = 0; i < artlist.Tables[0].Rows.Count; i++)
                    {
                        dr = artlist.Tables[0].Rows[i];
                        if (dr["link_url"] != null && dr["link_url"].ToString().Trim().Length > 0)
                        {
                            dr["link_url"] = MyCommFun.urlAddOpenid(dr["link_url"].ToString().Trim(), openid);
                        }
                        else
                        {
                            dr["link_url"] = MyCommFun.urlAddOpenid("detail.aspx?wid=" + wid + "&aid=" + dr["id"].ToString(), openid);
                        }
                        artlist.AcceptChanges();
                    }

                    totPage = recordCount / pageSize;
                    int yushu = recordCount % pageSize;
                    if (yushu > 0)
                    {
                        totPage += 1;
                    }
                    if (totPage < 1)
                    {
                        totPage = 1;
                    }
                }
                if (currPage > totPage)
                {
                    currPage = totPage;
                }
            }
            else
            {
                currPage    = 1;
                recordCount = 0;
                totPage     = 1;
            }
            this.Document.SetValue("totPage", totPage);   //总页数
            this.Document.SetValue("currPage", currPage); //当前页
            this.Document.SetValue("newslist", artlist);  //文章列表

            string beforePageStr = "";                    //上一页
            string nextPageStr   = "";                    //下一页
            string bgrey         = "c-p-grey";
            string ngrey         = "c-p-grey";

            if (currPage <= 1)
            {
                beforePageStr = "";
                bgrey         = "c-p-grey";
            }
            else
            {
                beforePageStr = MyCommFun.ChangePageNum(MyCommFun.getTotalUrl(), (currPage - 1));
                beforePageStr = "href=\"" + beforePageStr + "\"";
                bgrey         = "";
            }

            if (currPage >= totPage)
            {
                nextPageStr = "";
                ngrey       = " c-p-grey";
            }
            else
            {
                nextPageStr = MyCommFun.ChangePageNum(MyCommFun.getTotalUrl(), (currPage + 1));
                nextPageStr = "href=\"" + nextPageStr + "\"";
                ngrey       = "";
            }
            this.Document.SetValue("bpage", beforePageStr); //上一页
            this.Document.SetValue("npage", nextPageStr);   //下一页
            this.Document.SetValue("bgrey", bgrey);         //上一页灰色的样式
            this.Document.SetValue("ngrey", ngrey);         //下一页灰色的样式
        }
Esempio n. 17
0
        /// <summary>
        /// 输出最终的html
        /// </summary>
        /// <param name="templateFileName"></param>
        /// <param name="tPath"></param>
        /// <param name="wid"></param>
        public void OutPutHtml(int wid)
        {
            //注册一个自定义函数
            this.Document.RegisterGlobalFunction(this.ComputeMoney);

            //对VT模板里的config变量赋值
            Model.wxcodeconfig wxconfig = tDal.GetModelByWid(wid, tPath);
            if (wxconfig.wxstatus == 0)
            {
                HttpContext.Current.Response.Write("帐号已过期!请及时充值!");
            }
            this.Document.Variables.SetValue("config", wxconfig);

            BLL.wx_shop_setting setBll = new BLL.wx_shop_setting();
            if (!setBll.ExistsWid(wid))
            {
                HttpContext.Current.Response.Write("请先选择模版!");
                HttpContext.Current.Response.End();
            }
            Model.wx_shop_setting setting = setBll.GetModelList("wid=" + wid)[0];

            this.Document.Variables.SetValue("shopconfig", setting);

            this.Document.SetValue("wid", wid);
            this.Document.SetValue("ccright", ccRight);
            this.Document.SetValue("yuming", MyCommFun.getWebSite());
            this.Document.SetValue("thisurl", MyCommFun.getTotalUrl());
            this.Document.SetValue("indexurl", indexUrl());
            this.Document.SetValue("categoryurl", MyCommFun.urlAddOpenid("/shop/category.aspx?wid=" + wid, openid));
            this.Document.SetValue("carturl", "/shop/cart.aspx?wid=" + wid);
            this.Document.SetValue("userurl", "/shop/userinfo.aspx?wid=" + wid);
            this.Document.SetValue("openid", openid);
            this.Document.Variables.SetValue("this", this);
            if (tType == TemplateType.Class)
            {
                ProductClassPage();
            }
            else if (tType == TemplateType.News)
            {
                ShopDetailPage();
            }
            else if (tType == TemplateType.Cart)
            {
                CartDetailPage();
            }
            else if (tType == TemplateType.confirmOrder)
            {
                confirmOrder();
            }
            else if (tType == TemplateType.editaddr)
            {
                editAddrPage();
            }
            else if (tType == TemplateType.orderSuccess)
            {
                OrderSuccessPage();
            }
            else if (tType == TemplateType.userinfo)
            {
                userinfoPage();
            }
            else if (tType == TemplateType.orderDetail)
            {  //订单详情页面
                orderDetail();
            }

            //输出最终呈现的数据
            this.Document.Render(HttpContext.Current.Response.Output);
        }
Esempio n. 18
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/json";
            BLL.wx_shop_cart            cartBll  = new BLL.wx_shop_cart();
            string                      _action  = MyCommFun.QueryString("myact");
            string                      openid   = MyCommFun.RequestOpenid(); //得到微信用户的openid
            Dictionary <string, string> jsonDict = new Dictionary <string, string>();

            if (_action == "addCart")
            {
                #region 添加购物车
                try
                {
                    int     wid        = MyCommFun.RequestInt("wid");
                    int     productId  = MyCommFun.RequestInt("productid");
                    string  skuId      = MyCommFun.QueryString("mid");
                    string  skuInfo    = MyCommFun.QueryString("attr");
                    int     productNum = MyCommFun.RequestInt("bc");
                    decimal totalPrice = (decimal)MyCommFun.RequestFloat("totprice", 0);

                    Model.wx_shop_cart cart = new Model.wx_shop_cart();

                    IList <Model.wx_shop_cart> cartList = cartBll.GetModelList("productId=" + productId + " and openid='" + openid + "' and skuId='" + skuId + "'");
                    int  getCartCount = cartBll.GetRecordCount("wid=" + wid + " and openid='" + openid + "'");
                    bool isAdd        = true;
                    if (cartList != null && cartList.Count > 0)
                    {
                        isAdd = false;
                        cart  = cartList[0];
                    }
                    if (isAdd)
                    {
                        cart.createDate = DateTime.Now;
                        cart.openid     = openid;
                        cart.productId  = productId;
                        cart.productNum = productNum;
                        cart.skuId      = skuId;
                        cart.skuInfo    = skuInfo;
                        cart.totPrice   = totalPrice * productNum;
                        cart.wid        = wid;
                        int ret = cartBll.Add(cart);
                        if (ret > 0)
                        {
                            jsonDict.Add("errCode", "false");
                            jsonDict.Add("recontent", "添加购物车成功!");
                            jsonDict.Add("cartcount", (getCartCount + 1).ToString());
                        }
                        else
                        {
                            jsonDict.Add("errCode", "true");
                            jsonDict.Add("recontent", "添加购物车失败!");
                            jsonDict.Add("cartcount", getCartCount.ToString());
                        }
                    }
                    else
                    {
                        cart.openid = openid;

                        cart.productNum += productNum;
                        cart.skuId       = skuId;
                        cart.skuInfo     = skuInfo;
                        cart.totPrice   += totalPrice * productNum;
                        cart.wid         = wid;
                        bool ret = cartBll.Update(cart);
                        if (ret)
                        {
                            jsonDict.Add("errCode", "false");
                            jsonDict.Add("recontent", "更新购物车成功!");
                            jsonDict.Add("cartcount", getCartCount.ToString());
                        }
                        else
                        {
                            jsonDict.Add("errCode", "true");
                            jsonDict.Add("recontent", "更新购物车失败!");
                            jsonDict.Add("cartcount", getCartCount.ToString());
                        }
                    }
                }
                catch (Exception ex)
                {
                    jsonDict.Add("errCode", "true");
                    jsonDict.Add("recontent", "添加购物车失败!");
                }
                finally
                {
                    context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                }
                #endregion
            }
            else if (_action == "pcount")
            {
                #region 购物车商品数量
                jsonDict = new Dictionary <string, string>();
                int wid   = MyCommFun.RequestInt("wid");
                int count = cartBll.GetRecordCount("wid=" + wid + " and openid='" + openid + "'");
                jsonDict.Add("data", count.ToString());
                context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                #endregion
            }
            else if (_action == "remove")
            {
                #region 移除购物车商品
                jsonDict = new Dictionary <string, string>();
                int cartId = MyCommFun.RequestInt("id");
                cartBll.Delete(cartId);
                jsonDict.Add("errCode", "false");
                context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                #endregion
            }
            else if (_action == "modifyNum")
            {
                #region 修改购物车商品数量
                jsonDict = new Dictionary <string, string>();
                int cartId = MyCommFun.RequestInt("ic");
                int newNum = MyCommFun.RequestInt("bc");
                cartBll.UpdateNum(cartId, newNum);
                jsonDict.Add("errCode", "false");
                jsonDict.Add("recontent", "更新成功!");
                context.Response.Write(MyCommFun.getJsonStr(jsonDict));
                #endregion
            }
            else if (_action == "getCity")
            {
                #region  择省份,改变城市列表
                int privice = MyCommFun.RequestInt("pvid");
                BLL.pre_common_district           areaBll = new BLL.pre_common_district();
                IList <Model.pre_common_district> disList = areaBll.GetModelList("upid=" + privice + " and level=2");
                Model.pre_common_district         dis;
                StringBuilder jsonStr = new StringBuilder("{\"errCode\":0,\"retCode\":0,\"msgType\":0,\"errMsg\":\"\",\"data\":[");
                for (int i = 0; i < disList.Count; i++)
                {
                    dis = new Model.pre_common_district();
                    if (i != disList.Count - 1)
                    {
                        jsonStr.Append("{\"id\":" + disList[i].id + ",\"name\":\"" + disList[i].name + "\"},");
                    }
                    else
                    {
                        jsonStr.Append("{\"id\":" + disList[i].id + ",\"name\":\"" + disList[i].name + "\"}");
                    }
                }
                jsonStr.Append("]}");
                context.Response.Write(jsonStr);
                #endregion
            }
            else if (_action == "getArea")
            {
                #region  择城市,改变区域列表
                int ctid = MyCommFun.RequestInt("ctid");
                BLL.pre_common_district           areaBll = new BLL.pre_common_district();
                IList <Model.pre_common_district> disList = areaBll.GetModelList("upid=" + ctid + " and level=3");
                Model.pre_common_district         dis;
                StringBuilder jsonStr = new StringBuilder("{\"errCode\":0,\"retCode\":0,\"msgType\":0,\"errMsg\":\"\",\"data\":[");
                for (int i = 0; i < disList.Count; i++)
                {
                    dis = new Model.pre_common_district();
                    if (i != disList.Count - 1)
                    {
                        jsonStr.Append("{\"id\":" + disList[i].id + ",\"name\":\"" + disList[i].name + "\"},");
                    }
                    else
                    {
                        jsonStr.Append("{\"id\":" + disList[i].id + ",\"name\":\"" + disList[i].name + "\"}");
                    }
                }
                jsonStr.Append("]}");
                context.Response.Write(jsonStr);
                #endregion
            }
            else if (_action == "order_save")
            {
                #region 保存订单信息
                //获得传参信息
                int wid = MyCommFun.RequestInt("wid");

                int payment_id = MyCommFun.RequestInt("pc");    //支付方式:1货到付款;3微支付
                int express_id = MyCommFun.RequestInt("mtype"); //物流方式
                // string orderStrList = MyCommFun.QueryString("orderStrList");

                //检查物流方式
                if (express_id == 0)
                {
                    context.Response.Write("{\"errCode\":3, \"msg\":\"对不起,请选择配送方式!\"}");
                    return;
                }

                BLL.wx_shop_user_addr           uAddrBll  = new BLL.wx_shop_user_addr();
                IList <Model.wx_shop_user_addr> uaddrList = uAddrBll.GetOpenidAddrName(openid, wid);
                if (uaddrList == null || uaddrList.Count <= 0 || uaddrList[0].id <= 0)
                {
                    context.Response.Write("{\"errCode\":3, \"msg\":\"收货地址不存在,无法结算!\"}");
                    return;
                }


                //检查购物车商品
                IList <Model.cartProduct> cartList = cartBll.GetCartList(openid, wid);
                if (cartList == null)
                {
                    context.Response.Write("{\"errCode\":3, \"msg\":\"对不起,购物车为空,无法结算!\"}");
                    return;
                }
                //统计购物车
                decimal payable_amount = cartList.Sum(c => c.totPrice);
                //物流费用
                BLL.express   expressBll = new BLL.express();
                Model.express expModel   = expressBll.GetModel(express_id);
                //支付方式
                BLL.payment   pbll     = new BLL.payment();
                Model.payment payModel = pbll.GetModelBypTypeId(payment_id);
                //保存订单=======================================================================
                Model.orders model = new Model.orders();
                model.order_no = "b" + Utils.GetOrderNumber(); //订单号B开头为商品订单

                model.wid             = wid;
                model.openid          = openid;
                model.modelName       = "微商城";
                model.modelCode       = "shop";
                model.modelActionName = "";
                model.modelActionId   = 0;
                model.user_id         = 0;
                model.user_name       = "";
                model.payment_id      = payment_id;
                model.express_id      = express_id;
                model.accept_name     = uaddrList[0].contractPerson;
                model.post_code       = "";
                model.telphone        = uaddrList[0].tel;
                model.mobile          = uaddrList[0].tel;
                model.area            = uaddrList[0].province;
                model.city            = uaddrList[0].city;
                model.district        = uaddrList[0].area;
                model.address         = uaddrList[0].province + " " + uaddrList[0].city + " " + uaddrList[0].area + " " + uaddrList[0].addrDetail;
                model.message         = "";
                model.payable_amount  = payable_amount; //应付商品总金额
                model.real_amount     = payable_amount; //实际商品总金额,
                model.status          = 1;
                model.express_status  = 1;
                model.express_fee     = expModel.express_fee; //物流费用

                if (payment_id == 1)
                {                             //货到付款,需要确认订单
                    model.payment_status = 0; //标记未付款
                }
                else
                {                             //先款后货
                    model.payment_status = 1; //标记未付款
                }
                bool quicklyFH = false;
                //如果是先款后货的话
                if (payment_id == 3)
                {
                    if (payModel.poundage_type == 1) //百分比
                    {
                        model.payment_fee = model.real_amount * payModel.poundage_amount / 100;
                    }
                    else //固定金额
                    {
                        model.payment_fee = payModel.poundage_amount;
                    }
                    BLL.wx_payment_wxpay   wxBll = new BLL.wx_payment_wxpay();
                    Model.wx_payment_wxpay wxpay = wxBll.GetModelByWid(wid);
                    quicklyFH = wxpay.quicklyFH;
                }
                if (quicklyFH)
                {
                    model.express_status = 0;
                }
                //订单总金额=实付商品金额+运费+支付手续费
                model.order_amount = model.real_amount + model.express_fee + model.payment_fee;
                //购物积分,可为负数
                model.point    = 0;
                model.add_time = DateTime.Now;
                //商品详细列表
                List <Model.order_goods> gls = new List <Model.order_goods>();
                foreach (Model.cartProduct item in cartList)
                {
                    gls.Add(new Model.order_goods {
                        goods_id = item.productId, goods_title = item.productName, goods_price = item.totPrice, real_price = item.totPrice, quantity = item.productNum, point = 0
                    });
                }
                model.order_goods = gls;
                int result = new BLL.orders().Add(model);
                if (result < 1)
                {
                    context.Response.Write("{\"errCode\":3, \"msg\":\"订单保存过程中发生错误,请重新提交!\"}");
                    return;
                }

                //清空购物车
                cartBll.RemoveCartInfo(wid, openid);
                //提交成功,返回URL  order_no
                context.Response.Write("{\"errCode\":true, \"payType\":\"" + payment_id + "\", \"order_no\":\"" + model.order_no + "\",\"orderid\":\"" + result + "\",\"wid\":\"" + wid + "\",\"openid\":\"" + openid + "\",\"payable_amount\":\"" + payable_amount + "\", \"msg\":\"恭喜您,订单已成功提交!\"}");
                return;

                #endregion
            }
            else if (_action == "order_canel")
            {
                #region  //取消订单
                int        orderid = MyCommFun.RequestInt("order_id");
                BLL.orders oBll    = new BLL.orders();
                oBll.UpdateField(orderid, "status=4");
                context.Response.Write("{\"errCode\":true, \"msg\":\"订单已取消!\"}");
                #endregion
            }
            else if (_action == "fukuan")
            {
                #region  //在线支付
                int          orderid = MyCommFun.RequestInt("order_id");
                BLL.orders   oBll    = new BLL.orders();
                Model.orders order   = oBll.GetModel(orderid);
                oBll.UpdateField(orderid, "express_status=1,payment_status=2 , status=2");
                context.Response.Write("{\"errCode\":true, \"msg\":\"付款成功!\"}");
                #endregion
            }
            else if (_action == "shouhuo")
            {
                #region  //确认收货
                int          orderid = MyCommFun.RequestInt("order_id");
                BLL.orders   oBll    = new BLL.orders();
                Model.orders order   = oBll.GetModel(orderid);

                //if (order.payment_id == 1)
                //{
                //货到付款
                //    oBll.UpdateField(orderid, "express_status=2,payment_status=2 , status=3");
                // }
                // else
                //{
                //在线支付
                oBll.UpdateField(orderid, "express_status=2,payment_status=2 , status=6");
                // }

                context.Response.Write("{\"errCode\":true, \"msg\":\"交易完成!\"}");
                #endregion
            }
            else if (_action == "so")
            {
                #region  //产品搜索,主要字段名称,分类,简介

                int    wid         = MyCommFun.RequestInt("wid");
                string pagesizeStr = MyCommFun.RequestParam("pagesize");
                string orderby     = " id desc";
                int    currPage    = MyCommFun.RequestInt("currPage");; //当前页面
                int    recordCount = 0;                                 //总记录数
                int    totPage     = 1;                                 //总页数
                int    pageSize    = MyCommFun.Str2Int(pagesizeStr);    //每页的记录数
                if (pageSize <= 0)
                {
                    pageSize = 10;
                }
                if (MyCommFun.RequestInt("page") > 0)
                {
                    currPage = 1;
                }

                string key = MyCommFun.RequestParam("key");

                DataSet productlist = new DataSet();


                DAL.wx_shop_product artDal = new DAL.wx_shop_product();
                productlist = artDal.SoGetList(wid, key, pageSize, currPage, "upselling=1", orderby, out recordCount);
                if (productlist != null && productlist.Tables.Count > 0 && productlist.Tables[0].Rows.Count > 0)
                {
                    DataRow dr;
                    for (int i = 0; i < productlist.Tables[0].Rows.Count; i++)
                    {
                        dr            = productlist.Tables[0].Rows[i];
                        dr["p_count"] = recordCount;
                        if (dr["link_url"] != null && dr["link_url"].ToString().Trim().Length > 0)
                        {
                            dr["link_url"] = MyCommFun.urlAddOpenid(dr["link_url"].ToString().Trim(), openid);
                        }
                        else
                        {
                            dr["link_url"] = MyCommFun.urlAddOpenid("detail.aspx?wid=" + wid + "&pid=" + dr["id"].ToString(), openid);
                        }
                        productlist.AcceptChanges();
                    }

                    context.Response.Write(MyCommFun.GetJsonByDataset(productlist));
                }



                #endregion
            }
        }