/*************************************** * author:李朴* company:上海沐雪网络科技有限公司* website:http://uweixin.cn* createDate:2013-11-1* update:2014-12-30* remark:本代码为微商城模板的核心处理逻辑;* html模板页面上的所有的方法,属性都在这个类里处理。* ***********************************/using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using MxWeiXinPF.Common;
using VTemplate.Engine;
using MxWeiXinPF.Model;namespace MxWeiXinPF.Templates
{/**************************************** author:李朴* company:上海沐雪网络科技有限公司* qq:23002807* website:http://uweixin.cn* taobao:http://uweixin.cn/portalpage/weixin_news_detail.aspx?id=2102* createDate:2013-11-1* update:2014-12-30* ***********************************/public class ShopTemplateMgr{MxWeiXinPF.DAL.templatesDal tDal = new DAL.templatesDal();#region 属性protected internal string ccRight = "(c)2014 沐雪 技术提供";/// <summary>/// 当前页面的模板文档对象/// </summary>protected TemplateDocument Document{get;private set;}/// <summary>/// 当前页面的模板文档的配置参数/// </summary>protected virtual TemplateDocumentConfig DocumentConfig{get{return TemplateDocumentConfig.Default;}}/// <summary>/// 微帐号/// </summary>public int wid { get; set; }/// <summary>/// 微信用户openid/// </summary>public string openid { get; set; }/// <summary>/// 模版类型/// </summary>public TemplateType tType { get; set; }/// <summary>/// 模版文件名称/// </summary>public string templateFileName { get; set; }/// <summary>/// 模版文件的文件夹名称/// </summary>public string templateDictoryName { get; set; }/// <summary>/// 模版的物理路径(全完)/// </summary>public string serverPath { get; set; }/// <summary>/// 模版的虚拟路径,比如/shop/templates/default/// </summary>public string tPath { get; set; }#endregion#region 构造函数/// <summary>/// 模版初始化/// </summary>/// <param name="tPath">模版文件的虚拟路径</param>/// <param name="serverPath">模版文件的完全路径</param>/// <param name="wid"></param>public ShopTemplateMgr(string tPath, string serverPath, int wid){this.serverPath = serverPath;this.tPath = tPath;this.Document = new TemplateDocument(serverPath, Encoding.UTF8, this.DocumentConfig);this.wid = wid;}/// <summary>/// 模版初始化/// </summary>/// <param name="templateDictoryName">模版文件的文件夹名称</param>/// <param name="tPath">模版文件的虚拟路径</param>/// <param name="serverPath">模版文件的完全路径</param>/// <param name="wid"></param>public ShopTemplateMgr(string templateDictoryName, string tPath, string serverPath, int wid){this.templateDictoryName = templateDictoryName;this.serverPath = serverPath;this.tPath = tPath;this.Document = new TemplateDocument(serverPath, Encoding.UTF8, this.DocumentConfig);this.wid = wid;}/// <summary>/// 模版初始化/// </summary>/// <param name="templateFileName">模版文件的名称</param>/// <param name="templateDictoryName">模版文件的文件夹名称</param>/// <param name="tPath">模版文件的虚拟路径</param>/// <param name="serverPath">模版文件的完全路径</param>/// <param name="wid"></param>public ShopTemplateMgr(string templateFileName, string templateDictoryName, string tPath, string serverPath, int wid){this.templateFileName = templateFileName;this.templateDictoryName = templateDictoryName;this.serverPath = serverPath;this.tPath = tPath;this.Document = new TemplateDocument(serverPath, Encoding.UTF8, this.DocumentConfig);this.wid = wid;}#endregion/// <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", MyCommFun.urlAddOpenid("/shop/cart.aspx?wid=" + wid, openid));//updthis.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);}#region 方法集合:注册到模版或者供模版调用public void ProductClassPage(){int category_id = MyCommFun.RequestInt("cid");//--=====begin: 将这个列表(文章类别)的基本信息展示出来 ====--DAL.wx_shop_category cateBll = new DAL.wx_shop_category();Model.wx_shop_category category = cateBll.GetCategoryByWid(wid, category_id);this.Document.SetValue("category", category);this.Document.SetValue("wid", wid);this.Document.SetValue("cid", category_id);//--=====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 productlist = new DataSet();//category_id = 3;//wid = 5;if (category_id != 0)//根据类别查询
            {DAL.wx_shop_product artDal = new DAL.wx_shop_product();productlist = artDal.GetList(wid, category_id, 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];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();}totPage = recordCount / pageSize;int yushu = recordCount % pageSize;if (yushu > 0){totPage += 1;}if (totPage < 1){totPage = 1;}}if (currPage > totPage){currPage = totPage;}}else if (MyCommFun.QueryString("type") == "new")//得到最新产品
            {DAL.wx_shop_product artDal = new DAL.wx_shop_product();productlist = artDal.GetList(wid, pageSize, "upselling=1 order by addDate desc," + 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];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();}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("productlist", productlist);//文章列表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);//下一页灰色的样式
}public void ShopDetailPage(){BLL.wx_shop_product artDal = new BLL.wx_shop_product();int pid = MyCommFun.RequestInt("pid");Model.wx_shop_product product = artDal.GetModel(pid, wid);if (product != null){string skuStr = "[";string availSkuStr = "{";if (product.skulist != null && product.skulist.Count > 0){// string skuStr = "[{ \"pList\": [\"H\", \"H/VVS/32分/14号\"], \"pName\": \"戒指手寸\" }]";// string   availSku = "{ \"戒指手寸:F-G/VVS/33分/12号\": { \"pid\": 12700, \"stockCount\": \"\", \"stockPrice\": \"1000\", \"maketPrice\": \"0\" },  }";
skuStr += "{ \"pList\": [";//暂时只支持一种配件for (int i = 0; i < product.skulist.Count; i++){product.skulist[i].price += product.salePrice;product.skulist[i].price *= 100;if (i != (product.skulist.Count - 1)){skuStr += "\"" + product.skulist[i].attributeValue + "\",";availSkuStr += "\"" + product.skulist[0].attrName + ":" + product.skulist[i].attributeValue + "\": { \"pid\": " + product.skulist[i].id + ", \"stockCount\": \"\", \"stockPrice\": \"" + product.skulist[i].price + "\", \"maketPrice\": \"" + product.marketPrice + "\" }, ";}else{skuStr += "\"" + product.skulist[i].attributeValue + "\"";availSkuStr += "\"" + product.skulist[0].attrName + ":" + product.skulist[i].attributeValue + "\": { \"pid\": " + product.skulist[i].id + ", \"stockCount\": \"\", \"stockPrice\": \"" + product.skulist[i].price + "\", \"maketPrice\": \"" + product.marketPrice + "\" }";}}skuStr += "], \"pName\": \"" + product.skulist[0].attrName + "\" }";//MxWeiXinPF.DAL.ShopSKUDal skuDal = new DAL.ShopSKUDal();//IList<Model.ShopSKU> skulist = skuDal.SKUConvert(product.skulist);//this.Document.SetValue("skulist", skulist[0]);
                }skuStr += "]";availSkuStr += "}";if (availSkuStr == "{}"){availSkuStr = "{ \"\": { \"pid\": 0, \"stockCount\": \"\", \"stockPrice\": \"" + product.salePrice + "\", \"maketPrice\": \"" + product.marketPrice + "\" } }";}this.Document.SetValue("skuStr", skuStr);this.Document.SetValue("availSkuStr", availSkuStr);this.Document.SetValue("model", product);}}/// <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;}/// <summary>/// 获得最新/// </summary>/// <returns></returns>public DataTable getLatest(){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, "latest=" + 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;}/// <summary>/// 获得热卖/// </summary>/// <returns></returns>public DataTable getHotsalet(){Tag tag = this.Document.CurrentRenderingTag;var attribute = tag.Attributes["rows"];int cid = MyCommFun.RequestInt("cid");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();if (cid != 0){productlist = artDal.GetList(wid, rows, "   categoryId=" + cid + " order by hotsale desc");}else{productlist = artDal.GetList(wid, rows, " 1=1 order by hotsale desc");}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;}/// <summary>/// 获得推荐/// </summary>/// <returns></returns>public DataTable getRecommended(){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, "recommended=" + 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;}/// <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;}/// <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;}/// <summary>/// 购物车页面/// </summary>public void CartDetailPage(){BLL.wx_shop_cart cartBll = new BLL.wx_shop_cart();IList<Model.cartProduct> cartList = cartBll.GetCartList(openid, wid);int jiage = 0;string cartStr = "{";if (cartList.Count > 0){for (int i = cartList.Count - 1; i >= 0; i--){if (i != 0){cartStr += "\"" + i + "\": { \"ic\": \"" + cartList[i].id + "\", \"attr\": \"\", \"bc\": \"" + cartList[i].productNum + "\", \"mid\": " + cartList[i].skuId + " },";}else{cartStr += "\"" + i + "\": { \"ic\": \"" + cartList[i].id + "\", \"attr\": \"\", \"bc\": \"" + cartList[i].productNum + "\", \"mid\": " + cartList[i].skuId + " }";}}}cartStr += "}";decimal alltotPrice = cartList.Sum(item => item.totPrice);this.Document.SetValue("cartlist", cartList);this.Document.SetValue("alltot", alltotPrice);this.Document.SetValue("cartStr", cartStr);this.Document.SetValue("zongjia", jiage);}/// <summary>/// 修改地址的页面/// </summary>public void editAddrPage(){string frompage = MyCommFun.QueryString("frompage");this.Document.SetValue("frompage", frompage);BLL.wx_shop_user_addr uAddrBll = new BLL.wx_shop_user_addr();IList<Model.wx_shop_user_addr> uaddrList = uAddrBll.GetOpenidAddr(openid, wid);if (uaddrList == null || uaddrList.Count <= 0 || uaddrList[0].id <= 0){}else{this.Document.SetValue("addrinfo", uaddrList[0]);}}/// <summary>/// 确认订单页面/// </summary>public void confirmOrder(){//1用户的地址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){ }else{this.Document.SetValue("addrinfo", uaddrList[0]);}//快递信息列表BLL.express expressBll = new BLL.express();DataSet dsExpress = expressBll.GetExpressList100(wid);this.Document.SetValue("express", dsExpress);//支付信息列表BLL.payment pbll = new BLL.payment();DataSet dsPay = pbll.GetList(0, "  is_lock=0 and wid=" + wid, "  sort_id asc");this.Document.SetValue("payment", dsPay);//购物车里的商品BLL.wx_shop_cart cartBll = new BLL.wx_shop_cart();IList<Model.cartProduct> cartList = cartBll.GetCartList(openid, wid);this.Document.SetValue("cartlist", cartList);string cartStr = "[";if (cartList.Count > 0){for (int i = cartList.Count - 1; i >= 0; i--){if (i != 0){cartStr += "{ \"ic\": \"" + cartList[i].id + "\", \"attr\": \"\", \"bc\": \"" + cartList[i].productNum + "\", \"mid\": " + cartList[i].skuId + " },";}else{cartStr += "{ \"ic\": \"" + cartList[i].id + "\", \"attr\": \"\", \"bc\": \"" + cartList[i].productNum + "\", \"mid\": " + cartList[i].skuId + " }";}}}cartStr += "]";decimal alltotPrice = cartList.Sum(item => item.totPrice);this.Document.SetValue("alltot", alltotPrice * 100);this.Document.SetValue("alltot_y", alltotPrice);this.Document.SetValue("cartStr", cartStr);}/// <summary>/// 下单成功页面/// </summary>public void OrderSuccessPage(){BLL.orders oBll = new BLL.orders();int orderid = MyCommFun.RequestInt("orderid");Model.orders order = oBll.GetModel(orderid);if (order != null){this.Document.SetValue("order", order);}}/// <summary>/// 用户中心/// </summary>public void userinfoPage(){BLL.orders oBll = new BLL.orders();//待付款的int wid = MyCommFun.RequestInt("wid");IList<Model.orders> orderlist_dfu = oBll.GetModelList(" wid=" + wid + " and openid='" + openid + "' and payment_id in (2,3) and   payment_status=1 and status=1 order by id desc");if (orderlist_dfu != null){for (int i = 0; i < orderlist_dfu.Count; i++){orderlist_dfu[i].status = GetOrderStatus_int(orderlist_dfu[i].status, orderlist_dfu[i].payment_status, orderlist_dfu[i].express_status);}this.Document.SetValue("o_dfu", orderlist_dfu);this.Document.SetValue("dfk_num", orderlist_dfu.Count);}//待收货的IList<Model.orders> orderlist_dsh = oBll.GetModelList(" wid=" + wid + " and openid='" + openid + "' and  (payment_status=2 or payment_id=1) and status not in(3,4,5) order by id desc");if (orderlist_dsh != null){for (int i = 0; i < orderlist_dsh.Count; i++){orderlist_dsh[i].status = GetOrderStatus_int(orderlist_dsh[i].status, orderlist_dsh[i].payment_status, orderlist_dsh[i].express_status);}this.Document.SetValue("o_dsh", orderlist_dsh);this.Document.SetValue("dsh_num", orderlist_dsh.Count);}//已结束的IList<Model.orders> orderlist_yjs = oBll.GetModelList(" wid=" + wid + " and openid='" + openid + "' and  payment_status=2 and status in (3,4,5) order by id desc");if (orderlist_yjs != null){for (int i = 0; i < orderlist_yjs.Count; i++){orderlist_yjs[i].status = GetOrderStatus_int(orderlist_yjs[i].status, orderlist_yjs[i].payment_status, orderlist_yjs[i].express_status);}this.Document.SetValue("o_yjs", orderlist_yjs);this.Document.SetValue("yjs_num", orderlist_yjs.Count);}}/// <summary>/// 订单详情页面/// </summary>public void orderDetail(){int wid = MyCommFun.RequestInt("wid");int orderId = MyCommFun.RequestInt("orderid");BLL.orders oBll = new BLL.orders();//Model.orders order = oBll.GetModel(orderId);IList<Model.orders> orderlist_detail = oBll.GetModelList(" id=" + orderId);if (orderlist_detail != null){Model.orders order = orderlist_detail[0];this.Document.SetValue("order", order);string statusName = GetOrderStatus(order.status, order.payment_status, order.express_status);this.Document.SetValue("statusName", statusName);string paymentName = new MxWeiXinPF.BLL.payment().GetTitle(wid, order.payment_id);this.Document.SetValue("paymentName", paymentName);string expressName = new MxWeiXinPF.BLL.express().GetTitle(order.express_id);this.Document.SetValue("expressName", expressName);}}#region 返回订单状态=============================protected string GetOrderStatus(int status, int payment_status, int express_status){string _title = string.Empty;// Model.orders model = new BLL.orders().GetModel(_id);switch (status){case 1: //如果是线下支付,支付状态为0,如果是线上支付,支付成功后会自动改变订单状态为已确认if (payment_status > 0){_title = "待付款";}else{_title = "待确认";}break;case 2: //如果订单为已确认状态,则进入发货状态if (express_status > 1){_title = "已发货";}else{_title = "待发货";}break;case 3:_title = "交易完成";break;case 4:_title = "已取消";break;case 5:_title = "已作废";break;}return _title;}/// <summary>/// 订单状态,转化成与zepto.min.js里一致的/// </summary>/// <param name="status"></param>/// <param name="payment_status"></param>/// <param name="express_status"></param>/// <returns></returns>protected int GetOrderStatus_int(int status, int payment_status, int express_status){int ret = 0;switch (status){case 1: //如果是线下支付,支付状态为0,如果是线上支付,支付成功后会自动改变订单状态为已确认if (payment_status > 0){ret = 1;}else{ret = 14;}break;case 2: //如果订单为已确认状态,则进入发货状态if (express_status > 1){ret = 25;}else{ret = 2;}break;case 3:ret = 6;break;case 4:ret = 4;break;case 5:ret = 26;break;}return ret;}#endregion/// <summary>/// 单位 元*100/// </summary>/// <param name="news"></param>/// <returns></returns>private object ComputeMoney(object[] news){if (news.Length > 0 && news[0] != null){decimal yuan = MyCommFun.Str2Decimal(news[0].ToString());yuan *= 100;return yuan;}else{return string.Empty;}}/// <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;}#endregionpublic DataSet productlist { get; set; }}
}

转载于:https://www.cnblogs.com/Jeely/p/11349787.html

微商城模板的核心处理逻辑相关推荐

  1. 用python搭建微商城_怎么搭建微商城?用什么系统好?

    微信目前拥有10亿用户,是我们每个人每天都使用的app,给商家带来了大量的机会,很多公司和商家都纷纷开始搭建微商城系统平台,实现在微信公众号内销售商品. 很多人还不知道怎么去搭建一个微商城,我会在这篇 ...

  2. 制作一个微商城要多少钱

    如何开通一个微商城?制作一个微商城要多少钱? 开通微商城其实很简单,只需要找一个第三方微商城制作平台就能开通微商城. 同时还能装修自己的微商城,设计出自己的微商城等. 普通企业员工,个体户经营者也能轻 ...

  3. 搭建公众号微商城+小程序微商城 企业商城系统一条龙 拖拽可视化装修模板

    搭建公众号微商城+小程序微商城 企业商城系统一条龙 拖拽可视化装修模板 来源:廖万里的博客  www.kkkliao.cn 本程序需有认证服务号!或者认证小程序 微信支付走官方接口! 没有的话 自己准 ...

  4. 微信小程序srt_微信小程序微商城(八):缓存实现商品购物车功能

    看效果web 购物车.gif小程序 开发计划微信小程序 一.商品详情页将商品信息放入缓存 二.购物车页面读取缓存获取商品信息 三.购物车商品计算和删除缓存商品 1.商品详情页将商品信息放入缓存数组 d ...

  5. 开源微商城 特惠端午节

    WeMall微商城是您微信生鲜水果超市外卖社区o2o的必选系统 1.快速创建微信商城.一杯茶的时间创建您的微信商城. 2.丰富的界面.简洁美观的界面,美轮美奂. 3.功能强大的系统.商品,订单,微信等 ...

  6. 微商城搭建教程,手把手教你开通自己的线上/定制微商城!

    微商城应该如何开通和搭建?这个问题一直困扰着很多商家,今天就为大家整理一份关于微商城从开通到搭建的具体教程,手把手教商家搭建自己的线上微商城. 微商城搭建教程,手把手教你开通自己的线上微商城! (一) ...

  7. 微商城分销系统开发方式需求与价格开发周期评估

    移动互联网电商的市场份额不壮大,网上购物热潮不断,网上销售动力成了各商家与企业关注热点,随着市场的不断快速增大,企业或商家发现微商城分销系统可以大大助力销售道路,很多企业或商家朋友们都想要了解这样一个 ...

  8. 二次开发手册——百家CMS微商城说明文档(5)

    系统目录结构 百家cms微商城最新版本可以在官方网站(http://bbs.baijiacms.com 官网目前已无法访问). 把下载后的压缩文件解压到你的WEB目录(或者任何目录都可以),框架的目录 ...

  9. 微信小程序微商城(五):动态API实现商品详情页(下)

    IT实战联盟博客:http://blog.100boot.cn 上一篇:微信小程序微商城(四):动态API实现商品详情页(上) 看效果 加入购物车.gif 开发计划 1.加入购物车悬浮框.商品数量.价 ...

最新文章

  1. Java学习总结:44(文件复制案例)
  2. [TJOI2013]循环格
  3. 9、MySQL系统变量(查看和修改)
  4. 笔记本电源适配器的选择方法
  5. Gym - 100941G
  6. mysql 表数据diff,mysqldiff使用笔记
  7. 2018-2019-2 20175328 《Java程序设计》第十一周学习总结
  8. 再看数据库——(2)视图
  9. Linux实操篇——实用指令学习笔记(详解)
  10. Android平台屏幕/摄像头或外部数据采集及RTMP推送接口设计描述
  11. 应用程序池 应用池即应用程序池:
  12. 利用Python发送短信,用处多多
  13. linux文件删除恢复
  14. WinForm程序利用sqlhelp连接SQLserver数据库
  15. word柱状图垂直轴数值设定_EXCEL中的图表坐标轴数值 如何设置
  16. 码绘与手绘——表达动态
  17. Android混淆发布依赖
  18. 马云说:“未来是大数据的时代”
  19. specCPU 2006 备忘
  20. Deep Attention Network:基于深层注意力网络的高光谱与多光谱图像融合

热门文章

  1. 【lua/aviutl】小型倒计时
  2. DolphinDB Database丨交易回测系列一:技术信号回测
  3. 计算机显示器怎么调左右,电脑屏幕内容左右看不到边怎么调
  4. docker学习之docker镜像加速器
  5. 机器学习中的Encoder和Decoder到底是什么
  6. c语言点亮共阴极数码管,课程设计-基于单片机的共阴极数码管显示电路.doc
  7. AVL树【图示详解+代码实现】
  8. 20155110王一帆 《远程安防监控系统》课程设计个人报告
  9. PyQT5打包后报错:Could not find QtWebEngineProcess.exe
  10. 死锁的处理策略—预防死锁、避免死锁、检测和解除死锁