//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("order_express", DTEnums.ActionEnum.Delete.ToString()); //检查权限 int sucCount = 0; int errorCount = 0; BLL.express bll = new BLL.express(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { if (bll.Delete(id)) { sucCount += 1; } else { errorCount += 1; } } } AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), "删除配送方式成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("express_list.aspx", "keywords={0}", this.keywords), "Success"); }
private bool DoAdd() { Model.express model = new Model.express(); BLL.express bll = new BLL.express(); model.title = txtTitle.Text.Trim(); model.express_code = txtExpressCode.Text.Trim(); model.express_fee = Vincent._DTcms.Utils.StrToDecimal(txtExpressFee.Text.Trim(), 0); model.img_url = txtImgUrl.Text; model.website = txtWebSite.Text.Trim(); model.remark = Vincent._DTcms.Utils.ToHtml(txtRemark.Text); if (cbIsLock.Checked == true) { model.is_lock = 0; } else { model.is_lock = 1; } model.sort_id = Vincent._DTcms.Utils.StrToInt(txtSortId.Text.Trim(), 99); if (bll.Add(model) > 0) { AddAdminLog(Vincent._DTcms.DTEnums.ActionEnum.Add.ToString(), "添加配送方式:" + model.title); //记录日志 return(true); } return(false); }
protected void Page_Load(object sender, EventArgs e) { this.id = TWRequest.GetQueryInt("id"); if (this.id == 0) { JscriptMsg("傳輸參數不正確!", "back"); return; } if (!new BLL.orders().Exists(this.id)) { JscriptMsg("記錄不存在或已被刪除!", "back"); return; } if (!Page.IsPostBack) { BLL.express bll2 = new BLL.express(); DataTable dt = bll2.GetList("").Tables[0]; ddlExpressId.Items.Clear(); ddlExpressId.Items.Add(new ListItem("請選擇配送方式", "")); foreach (DataRow dr in dt.Rows) { ddlExpressId.Items.Add(new ListItem(dr["title"].ToString(), dr["id"].ToString())); } //ChkAdminLevel("order_list", TWEnums.ActionEnum.View.ToString()); //檢查許可權 ShowInfo(this.id); } }
//批量删除 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel("order_express", AXEnums.ActionEnum.Delete.ToString()); //检查权限 int sucCount = 0; int errorCount = 0; BLL.express bll = new BLL.express(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { if (bll.Delete(id)) { sucCount += 1; } else { errorCount += 1; } } } AddAdminLog(AXEnums.ActionEnum.Delete.ToString(), "删除配送小区成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志 JscriptMsg("删除成功" + sucCount + "条,失败" + errorCount + "条!", Utils.CombUrlTxt("express_list.aspx", "keywords={0}", this.keywords), "Success"); }
private bool DoEdit(int _id) { bool result = false; BLL.express bll = new BLL.express(); Model.express model = bll.GetModel(_id); model.title = txtTitle.Text.Trim(); model.express_code = txtExpressCode.Text.Trim(); model.express_fee = Utils.StrToDecimal(txtExpressFee.Text.Trim(), 0); model.website = txtWebSite.Text.Trim(); model.remark = Utils.ToHtml(txtRemark.Text); if (cbIsLock.Checked == true) { model.is_lock = 0; } else { model.is_lock = 1; } model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); if (bll.Update(model)) { AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "修改配送方式:" + model.title); //记录日志 result = true; } return(result); }
private bool DoAdd() { Model.express model = new Model.express(); BLL.express bll = new BLL.express(); Model.wx_userweixin weixin = GetWeiXinCode(); model.title = txtTitle.Text.Trim(); model.express_code = txtExpressCode.Text.Trim(); model.express_fee = Utils.StrToDecimal(txtExpressFee.Text.Trim(), 0); model.website = txtWebSite.Text.Trim(); model.remark = Utils.ToHtml(txtRemark.Text); model.wid = weixin.id; if (cbIsLock.Checked == true) { model.is_lock = 0; } else { model.is_lock = 1; } model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); if (bll.Add(model) > 0) { AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "添加配送方式:" + model.title); //记录日志 return(true); } return(false); }
/// <summary> /// 重写虚方法,此方法在Init事件执行 /// </summary> protected override void InitPage() { id = DTRequest.GetQueryInt("id"); BLL.orders bll = new BLL.orders(); if (!bll.Exists(id)) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错了,您要浏览的页面不存在或已删除!"))); return; } model = bll.GetModel(id); if (model.user_id != userModel.id) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错了,您所查看的并非自己的订单信息!"))); return; } payModel = new BLL.payment().GetModel(model.payment_id); if (payModel == null) { payModel = new Model.payment(); } //根据订单状态和物流单号跟踪物流信息 if (model.status > 1 && model.status < 4 && model.express_status == 2 && model.express_no.Trim().Length > 0) { Model.express modelt = new BLL.express().GetModel(model.express_id); Model.orderconfig orderConfig = new BLL.orderconfig().loadConfig(); } }
private bool DoAdd() { Model.express model = new Model.express(); BLL.express bll = new BLL.express(); Model.wx_userweixin weixin = GetWeiXinCode(); model.title = txtTitle.Text.Trim(); model.express_code = txtExpressCode.Text.Trim(); model.express_fee = Utils.StrToDecimal(txtExpressFee.Text.Trim(), 0); model.website = txtWebSite.Text.Trim(); model.remark = Utils.ToHtml(txtRemark.Text); model.wid = weixin.id; if (cbIsLock.Checked == true) { model.is_lock = 0; } else { model.is_lock = 1; } model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); if (bll.Add(model) > 0) { AddAdminLog(MXEnums.ActionEnum.Add.ToString(), "添加配送方式:" + model.title); //记录日志 return true; } return false; }
public string GetExpress() { BLL.express art = new BLL.express(); var info = art.GetList("1=1"); // Vincent._Json json = new _Json(); return(CreateJsonParameters(info.Tables[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> /// <param name="top">显示条数</param> /// <param name="strwhere">查询条件</param> /// <returns>DataTable</returns> protected DataTable get_express_list(int top, string strwhere) { DataTable dt = new DataTable(); string _where = "is_lock=0"; if (!string.IsNullOrEmpty(strwhere)) { _where += " and " + strwhere; } dt = new BLL.express().GetList(top, _where, "sort_id asc,id desc").Tables[0]; return dt; }
private void ExpBind(string strWhere) { BLL.express bll = new BLL.express(); DataTable dt = bll.GetList(0, strWhere, "sort_id asc,id asc").Tables[0]; this.ddlExpressId.Items.Clear(); this.ddlExpressId.Items.Add(new ListItem("请选择配送小区...", "")); foreach (DataRow dr in dt.Rows) { this.ddlExpressId.Items.Add(new ListItem(dr["title"].ToString(), dr["id"].ToString())); } }
/// <summary> /// 返回配送列表 /// </summary> /// <param name="top">显示条数</param> /// <param name="strwhere">查询条件</param> /// <returns>DataTable</returns> public List <Model.express> get_express_list(int top, string strwhere) { List <Model.express> list = new List <Model.express>(); string _where = "is_lock=0"; if (!string.IsNullOrEmpty(strwhere)) { _where += " and " + strwhere; } list = new BLL.express().GetModelList(top, _where, "*", "sort_id asc,id desc"); return(list); }
/// <summary> /// 返回配送列表 /// </summary> /// <param name="top">显示条数</param> /// <param name="strwhere">查询条件</param> /// <returns>DataTable</returns> protected DataTable get_express_list(int top, string strwhere) { DataTable dt = new DataTable(); string _where = "is_lock=0"; if (!string.IsNullOrEmpty(strwhere)) { _where += " and " + strwhere; } dt = new BLL.express().GetList(top, _where, "sort_id asc,id desc").Tables[0]; return(dt); }
private void ShowInfo(int _id) { BLL.orders bll = new BLL.orders(); model = bll.GetModel(_id); //绑定商品列表 this.rptList.DataSource = model.order_goods; this.rptList.DataBind(); //根据订单状态,显示各类操作按钮 switch (model.status) { case 1: //如果是线下支付,支付状态为0,如果是线上支付,支付成功后会自动改变订单状态为已确认 if (model.payment_status > 0) { //确认付款、取消订单、修改收货按钮显示 btnPayment.Visible = btnCancel.Visible = btnEditAcceptInfo.Visible = true; } else { //确认订单、取消订单、修改收货按钮显示 btnConfirm.Visible = btnCancel.Visible = btnEditAcceptInfo.Visible = true; } //修改订单备注、修改商品总金额、修改配送费用、修改支付手续费、修改发票税金按钮显示 btnEditRemark.Visible = btnEditRealAmount.Visible = btnEditExpressFee.Visible = btnEditPaymentFee.Visible = btnEditInvoiceTaxes.Visible = true; break; case 2: //如果订单为已确认状态,则进入发货状态 if (model.express_status == 1) { //确认发货、取消订单、修改收货信息按钮显示 btnExpress.Visible = btnCancel.Visible = btnEditAcceptInfo.Visible = true; } else if (model.express_status == 2) { //完成订单、取消订单按钮可见 btnComplete.Visible = btnCancel.Visible = true; } //修改订单备注按钮可见 btnEditRemark.Visible = true; break; case 3: //作废订单、修改订单备注按钮可见 btnInvalid.Visible = btnEditRemark.Visible = true; break; } //根据订单状态和物流单号跟踪物流信息 if (model.express_status == 2 && model.express_no.Trim().Length > 0) { Model.express modelt = new BLL.express().GetModel(model.express_id); Model.orderconfig orderConfig = new BLL.orderconfig().loadConfig(); } }
private void RptBind(string _strWhere, string _orderby) { this.page = DTRequest.GetQueryInt("page", 1); txtKeywords.Text = this.keywords; BLL.express bll = new BLL.express(); this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount); this.rptList.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("express_list.aspx", "keywords={0}&page={1}", this.keywords, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
private void RptBind(string _strWhere, string _orderby) { this.page = MXRequest.GetQueryInt("page", 1); txtKeywords.Text = this.keywords; BLL.express bll = new BLL.express(); this.rptList.DataSource = bll.GetListshop(this.pageSize, this.page, "min_attrid", _strWhere, _orderby, out this.totalCount); this.rptList.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("attr.aspx", "keywords={0}&page={1}", this.keywords, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
private void RptBind(string _strWhere, string _orderby) { Model.wx_userweixin weixin = GetWeiXinCode(); _strWhere = "wid=" + weixin.id + " " + _strWhere; this.page = MXRequest.GetQueryInt("page", 1); txtKeywords.Text = this.keywords; BLL.express bll = new BLL.express(); this.rptList.DataSource = bll.GetList(this.pageSize, this.page, _strWhere, _orderby, out this.totalCount); this.rptList.DataBind(); //绑定页码 txtPageNum.Text = this.pageSize.ToString(); string pageUrl = Utils.CombUrlTxt("express_list.aspx", "keywords={0}&page={1}", this.keywords, "__id__"); PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8); }
private void ShowInfo(string _order_no) { BLL.orders bll = new BLL.orders(); Model.orders model = bll.GetModel(_order_no); BLL.express bll2 = new BLL.express(); DataTable dt = bll2.GetList(0, string.Empty, "sort_id asc,id desc").Tables[0]; ddlExpressId.Items.Clear(); ddlExpressId.Items.Add(new ListItem("请选择配送方式", "")); foreach (DataRow dr in dt.Rows) { ddlExpressId.Items.Add(new ListItem(dr["title"].ToString(), dr["id"].ToString())); } txtExpressNo.Text = model.express_no; ddlExpressId.SelectedValue = model.express_id.ToString(); }
private void ShowInfo(string _order_no) { BLL.orders bll = new BLL.orders(); Model.orders model = bll.GetModel(_order_no); BLL.express bll2 = new BLL.express(); DataTable dt = bll2.GetList("").Tables[0]; ddlExpressId.Items.Clear(); ddlExpressId.Items.Add(new ListItem("请选择配送方式", "")); foreach (DataRow dr in dt.Rows) { ddlExpressId.Items.Add(new ListItem(dr["title"].ToString(), dr["id"].ToString())); } txtExpressNo.Text = model.express_no; ddlExpressId.SelectedValue = model.express_id.ToString(); }
//保存排序 protected void btnSave_Click(object sender, EventArgs e) { ChkAdminLevel("order_express", DTEnums.ActionEnum.Edit.ToString()); //检查权限 BLL.express bll = new BLL.express(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); int sortId; if (!int.TryParse(((TextBox)rptList.Items[i].FindControl("txtSortId")).Text.Trim(), out sortId)) { sortId = 99; } bll.UpdateField(id, "sort_id=" + sortId.ToString()); } AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "保存配送方式排序"); //记录日志 JscriptMsg("保存排序成功!", Utils.CombUrlTxt("express_list.aspx", "keywords={0}", this.keywords), "Success"); }
//保存排序 protected void btnSave_Click(object sender, EventArgs e) { ChkAdminLevel("order_express", AXEnums.ActionEnum.Edit.ToString()); //检查权限 BLL.express bll = new BLL.express(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); int sortId; if (!int.TryParse(((TextBox)rptList.Items[i].FindControl("txtSortId")).Text.Trim(), out sortId)) { sortId = 99; } bll.UpdateField(id, "sort_id=" + sortId.ToString()); } AddAdminLog(AXEnums.ActionEnum.Edit.ToString(), "保存配送小区排序"); //记录日志 JscriptMsg("保存排序成功!", Utils.CombUrlTxt("express_list.aspx", "keywords={0}", this.keywords), "Success"); }
private void ShowInfo(string _order_no) { BLL.orders bll = new BLL.orders(); Model.orders model = bll.GetModel(_order_no); BLL.express bll2 = new BLL.express(); DataTable dt = bll2.GetList("").Tables[0]; //ddlExpressId.Items.Clear(); //ddlExpressId.Items.Add(new ListItem("请选择配送小区", "")); //foreach (DataRow dr in dt.Rows) //{ // ddlExpressId.Items.Add(new ListItem(dr["title"].ToString(), dr["id"].ToString())); //} txtExpressNo.Text = model.express_no; // ddlExpressId.SelectedValue = model.express_id.ToString(); }
private void ShowInfo(int _id) { BLL.express bll = new BLL.express(); Model.express model = bll.GetModel(_id); txtTitle.Text = model.title; txtExpressCode.Text = model.express_code; txtExpressFee.Text = model.express_fee.ToString(); txtWebSite.Text = model.website; txtRemark.Text = Utils.ToTxt(model.remark); if (model.is_lock == 0) { cbIsLock.Checked = true; } else { cbIsLock.Checked = false; } txtSortId.Text = model.sort_id.ToString(); }
/// <summary> /// 重写虚方法,此方法在Init事件执行 /// </summary> protected override void InitPage() { id = DTRequest.GetQueryInt("id"); BLL.orders bll = new BLL.orders(); if (!bll.Exists(id)) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错了,您要浏览的页面不存在或已删除!"))); return; } model = bll.GetModel(id); if (model.user_id != userModel.id) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错了,您所查看的并非自己的订单信息!"))); return; } payModel = new BLL.site_payment().GetPaymentModel(model.payment_id); if (payModel == null) { payModel = new Model.payment(); } //根据订单状态和物流单号跟踪物流信息 if (model.status > 1 && model.status < 4 && model.express_status == 2 && model.express_no.Trim().Length > 0) { Model.express modelt = new BLL.express().GetModel(model.express_id); Model.orderconfig orderConfig = new BLL.orderconfig().loadConfig(); if (modelt != null && modelt.express_code.Trim().Length > 0 && orderConfig.kuaidiapi != "") { string apiurl = orderConfig.kuaidiapi + "?id=" + orderConfig.kuaidikey + "&com=" + modelt.express_code + "&nu=" + model.express_no + "&show=" + orderConfig.kuaidishow + "&muti=" + orderConfig.kuaidimuti + "&order=" + orderConfig.kuaidiorder; string detail = Utils.HttpGet(@apiurl); if (detail != null) { expressdetail = Utils.ToHtml(detail); } } } }
/// <summary> /// 重写虚方法,此方法在Init事件执行 /// </summary> protected override void InitPage() { id = DTRequest.GetQueryInt("id"); BLL.orders bll = new BLL.orders(); if (!bll.Exists(id)) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错了,您要浏览的页面不存在或已删除!"))); return; } model = bll.GetModel(id); if (model.user_id != userModel.id) { HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错了,您所查看的并非自己的订单信息!"))); return; } payModel = new BLL.payment().GetModel(model.payment_id); if (payModel == null) { payModel = new Model.payment(); } //根据订单状态和物流单号跟踪物流信息 if (model.status > 1 && model.status < 4 && model.express_status == 2 && model.express_no.Trim().Length > 0) { Model.express modelt = new BLL.express().GetModel(model.express_id); Model.orderconfig orderConfig = new BLL.orderconfig().loadConfig(); if (modelt != null && modelt.express_code.Trim().Length > 0 && orderConfig.kuaidiapi != "") { string apiurl = orderConfig.kuaidiapi + "?id=" + orderConfig.kuaidikey + "&com=" + modelt.express_code + "&nu=" + model.express_no + "&show=" + orderConfig.kuaidishow + "&muti=" + orderConfig.kuaidimuti + "&order=" + orderConfig.kuaidiorder; string detail = Utils.HttpGet(@apiurl); if (detail != null) { expressdetail = Utils.ToHtml(detail); } } } }
private bool DoEdit(int _id) { bool result = false; BLL.express bll = new BLL.express(); Model.express model = bll.GetModel(_id); model.title = txtTitle.Text.Trim(); model.express_code = txtExpressCode.Text.Trim(); model.express_fee = Utils.StrToDecimal(txtExpressFee.Text.Trim(), 0); model.website = txtWebSite.Text.Trim(); model.remark = Utils.ToHtml(txtRemark.Text); if (cbIsLock.Checked == true) { model.is_lock = 0; } else { model.is_lock = 1; } model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); if (bll.Update(model)) { AddAdminLog(MXEnums.ActionEnum.Edit.ToString(), "修改配送方式:" + model.title); //记录日志 result = true; } return result; }
private void ShowInfo(int _id) { BLL.orders bll = new BLL.orders(); model = bll.GetModel(_id); //绑定商品列表 this.rptList.DataSource = model.order_goods; this.rptList.DataBind(); //获得会员信息 if (model.user_id > 0) { Model.users user_info = new BLL.users().GetModel(model.user_id); if (user_info != null) { Model.user_groups group_info = new BLL.user_groups().GetModel(user_info.group_id); if (group_info != null) { dlUserInfo.Visible = true; lbUserName.Text = user_info.user_name; lbUserGroup.Text = group_info.title; lbUserDiscount.Text = group_info.discount.ToString() + " %"; lbUserAmount.Text = user_info.amount.ToString(); lbUserPoint.Text = user_info.point.ToString(); } } } //根据订单状态,显示各类操作按钮 switch (model.status) { case 1: //如果是线下支付,支付状态为0,如果是线上支付,支付成功后会自动改变订单状态为已确认 if (model.payment_status > 0) { //确认付款、取消订单、修改收货按钮显示 btnPayment.Visible = btnCancel.Visible = btnEditAcceptInfo.Visible = true; } else { //确认订单、取消订单、修改收货按钮显示 btnConfirm.Visible = btnCancel.Visible = btnEditAcceptInfo.Visible = true; } //修改订单备注、修改商品总金额、修改配送费用、修改支付手续费、修改发票税金按钮显示 btnEditRemark.Visible = btnEditRealAmount.Visible = btnEditExpressFee.Visible = btnEditPaymentFee.Visible = btnEditInvoiceTaxes.Visible = true; break; case 2: //如果订单为已确认状态,则进入发货状态 if (model.express_status == 1) { //确认发货、取消订单、修改收货信息按钮显示 btnExpress.Visible = btnCancel.Visible = btnEditAcceptInfo.Visible = true; } else if (model.express_status == 2) { //完成订单、取消订单按钮可见 btnComplete.Visible = btnCancel.Visible = true; } //修改订单备注按钮可见 btnEditRemark.Visible = true; break; case 3: //作废订单、修改订单备注按钮可见 btnInvalid.Visible = btnEditRemark.Visible = true; break; } //根据订单状态和物流单号跟踪物流信息 if (model.express_status == 2 && model.express_no.Trim().Length > 0) { Model.express modelt = new BLL.express().GetModel(model.express_id); Model.orderconfig orderConfig = new BLL.orderconfig().loadConfig(); if (modelt != null && modelt.express_code.Trim().Length > 0 && orderConfig.kuaidiapi != "") { string apiurl = orderConfig.kuaidiapi + "?id=" + orderConfig.kuaidikey + "&com=" + modelt.express_code + "&nu=" + model.express_no + "&show=" + orderConfig.kuaidishow + "&muti=" + orderConfig.kuaidimuti + "&order=" + orderConfig.kuaidiorder; string detail = Utils.HttpGet(@apiurl); if (detail != null) { litExpressDetail.Text = Utils.ToHtml(detail); } } } }
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"); int skuId = MyCommFun.RequestInt("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); 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"); } else { jsonDict.Add("errCode", "true"); } } 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"); } else { jsonDict.Add("errCode", "true"); } } } catch (Exception ex) { jsonDict.Add("errCode", "true"); } 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"); 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.avgPrice, real_price = item.avgPrice, 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; } //清空购物车,此步骤移到确认支付页面 // //提交成功,返回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 == "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=3"); } context.Response.Write("{\"errCode\":true, \"msg\":\"确认收货!\"}"); #endregion } else if (_action == "clearMyOrder") { #region 清空我的购物车订单,在支付页面,支付成功后执行此功能 int wid = MyCommFun.RequestInt("wid"); cartBll.RemoveCartInfo(wid, openid); #endregion } }
/// <summary> /// /// </summary> 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); if (product != null) { string skuStr = "{\"attr\":["; string availSkuStr = "{"; if (product.skulist != null && product.skulist.Count > 0) { //////////////////生成新的list对数据进行分类 List <int?> arrlist = new List <int?>(); for (int i = 0; i < product.skulist.Count; i++) { arrlist.Add(product.skulist[i].attributeId); } IList <int?> nlist = arrlist.Distinct().ToList();//去除重复值 ////////////////////// for (int j = 0; j < nlist.Count; j++) { ////////////////////////////////////// List <Model.wx_shop_sku> newskulist = new List <Model.wx_shop_sku>(); for (int i = 0; i < product.skulist.Count; i++) { if (product.skulist[i].attributeId == nlist[j].Value) { newskulist.Add(product.skulist[i]); } } ///////////////////////////////////// string dh = ""; if (j == (nlist.Count - 1)) { dh = ""; } else { dh = ","; } skuStr += "{\"attrname\":\"" + newskulist[j].attrName + "\",\"attrlist\": ["; string skuname = ""; for (int i = 0; i < newskulist.Count; i++) { string addprice = newskulist[i].price.ToString(); newskulist[i].price += product.salePrice; // newskulist[i].price *= 100; string dhi = "", dhk = ","; if (i != (newskulist.Count - 1)) { dhi = ","; } else { dhi = ""; //availSkuStr } if (j == (nlist.Count - 1) && i == (newskulist.Count - 1)) { dhk = ""; } skuStr += "{ \"pid\": " + newskulist[i].id + ", \"aname\": \"" + newskulist[i].attributeValue + "\", \"addprice\": \"" + addprice + "\", \"stockPrice\": \"" + newskulist[i].price + "\", \"maketPrice\": \"" + product.marketPrice + "\" }" + dhi + " "; // skuStr += "{ \"attrname\": \"" + newskulist[i].attributeValue + "\", \"stockPrice\": \"" + newskulist[i].price + "\", \"maketPrice\": \"" + product.marketPrice * 100 + "\" }" + dhi + ""; availSkuStr += "\"" + newskulist[i].attrName + ":" + newskulist[i].attributeValue + "\": { \"pid\": " + newskulist[i].id + ", \"stockCount\": \"\", \"stockPrice\": \"" + newskulist[i].price + "\", \"maketPrice\": \"" + product.marketPrice * 100 + "\" }" + dhk + " "; skuname = newskulist[i].attrName; } skuStr += "]}" + dh; } skuStr += "]}"; availSkuStr += "}"; //XCWeiXin.DAL.ShopSKUDal skuDal = new DAL.ShopSKUDal(); //IList<Model.ShopSKU> skulist = skuDal.SKUConvert(product.skulist); //this.Document.SetValue("skulist", skulist[0]); } else { skuStr += "]}"; } if (availSkuStr == "{}") { availSkuStr = "{ \"\": { \"pid\": 0, \"stockCount\": \"\", \"stockPrice\": \"" + product.salePrice + "\", \"maketPrice\": \"" + product.marketPrice * 100 + "\" } }"; } this.Document.SetValue("skuStr", skuStr); this.Document.SetValue("availSkuStr", availSkuStr); this.Document.SetValue("model", product); //快递信息列表 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); } }
private void add_order(HttpContext context) { int address_id = DTRequest.GetQueryInt("address"); int freight_id = DTRequest.GetQueryInt("freight"); string car_ids = DTRequest.GetQueryString("car_ids"); Model.users model = new BasePage().GetUserInfo(); if (model == null) { context.Response.Write("{\"status\":\"0\", \"msg\":\"对不起,请重新登录!\"}"); return; } //统计购物车 BLL.express bll_express = new BLL.express(); Model.express model_express = bll_express.GetModel(freight_id); if (model_express == null) { context.Response.Write("{\"status\":\"0\", \"msg\":\"对不起,该配送方式不存在或已删除!\"}"); return; } BLL.address bll_address = new BLL.address(); Model.address model_address = bll_address.GetModel(address_id); if (model_address == null) { context.Response.Write("{\"status\":\"0\", \"msg\":\"对不起,该收货信息不存在或已删除!\"}"); return; } IList<Model.cart_items> iList = DTcms.Web.UI.ShopCart.GetList(model.group_id); if (iList == null) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,购物车为空,无法结算!\"}"); return; } //保存订单======================================================================= Model.orders model_order = new Model.orders(); model_order.order_no = "B" + Utils.GetOrderNumber(); //订单号B开头为商品订单 model_order.user_id = model.id; model_order.user_name = model.user_name; model_order.payment_id = 0; model_order.express_id = model_express.id; model_order.accept_name = model_address.consignee; model_order.post_code = model_address.zipcode; model_order.telphone = model_address.consignee_phone; model_order.mobile = model_address.consignee_mobile; model_order.address = new BLL.province().GetModel(model_address.province).ProvinceName + "|" + new BLL.city().GetModel(model_address.city).CityName + "|" + new BLL.district().GetModel(model_address.distract).DistrictName + "|" + model_address.content; model_order.message = ""; model_order.express_status = 1; model_order.express_fee = model_express.express_fee; //物流费用 //如果是先款后货的话 //购物积分,可为负数 model_order.add_time = DateTime.Now; //商品详细列表 decimal real_amount = 0; decimal payable_amount = 0; int total_point = 0; List<Model.order_goods> gls = new List<Model.order_goods>(); BLL.standard bll_standard = new BLL.standard(); foreach (Model.cart_items item in iList) { string[] arr_car_id = car_ids.Split('_'); foreach (string str in arr_car_id) { if ((item.id + "-" + item.standard + "-" + item.unit_id).Trim() == str) { //{ //40-1|红色,2|黑色_10-1|红色,2|黑色 商品ID-规格ID|规格值ID,规格ID|规格值ID-单位ID // string[] arr_good_standard=str.Split('-'); // string str_standard = ""; // foreach (string str1 in arr_good_standard) // { // BLL.standard bll_standard = new BLL.standard(); // Model.standard model_standard = bll_standard.GetModel(Convert.ToInt32(str1.Split('|')[0])); // if (model_standard != null) // { // str_standard += model_standard.title + ":" + str1.Split('|')[1]; // } // } string str_standard = ""; //190-14|41-4650 string standard_title_id = ""; string standard_value_id = ""; Model.article model_good = new BLL.article().GetModel(item.id); if (model_good == null) { return; } string good_no = model_good.fields["goods_no"]; //规格 if (!string.IsNullOrEmpty(item.standard)) { string[] arr_standard = item.standard.Split(','); for (int i = 0; i < arr_standard.Length; i++) { Model.standard model_standard = bll_standard.GetModel(Convert.ToInt32(arr_standard[i].Split('|')[0])); Model.standard_value model_standard_value = new BLL.standard_value().GetModel(Convert.ToInt32(arr_standard[i].Split('|')[1])); if (model_standard != null && model_standard_value != null) { str_standard += model_standard.title + ":" + arr_standard[i].Split('|')[1] + ","; standard_title_id += model_standard.id + ","; standard_value_id += model_standard_value.id + ","; } } } if (!string.IsNullOrEmpty(standard_title_id) && !string.IsNullOrEmpty(standard_value_id)) { DataTable dt_standard_value = new BLL.standard_price().GetList("good_id='" + item.id + "' and standard_ids='" + standard_title_id.Substring(0, standard_title_id.Length - 1) + "' and standard_value_ids='" + standard_value_id.Substring(0, standard_value_id.Length - 1) + "'").Tables[0]; if (dt_standard_value != null && dt_standard_value.Rows.Count == 1) { good_no = dt_standard_value.Rows[0]["good_no"].ToString(); } } real_amount += item.user_price * item.quantity; payable_amount += item.price * item.quantity; total_point += item.point * item.quantity; BLL.unit bll_unit = new BLL.unit(); Model.unit model_unit = bll_unit.GetModel(item.unit_id); string str_unit = ""; if (model_unit != null) { str_unit = model_unit.title; if (!string.IsNullOrEmpty(model_unit.content)) { str_unit += "(" + model_unit.content + ")"; } } gls.Add(new Model.order_goods { goods_id = item.id, good_no = good_no, goods_title = item.title, goods_price = item.price, real_price = item.user_price, quantity = item.quantity, point = item.point, standard = (string.IsNullOrEmpty(str_standard) ? "" : str_standard.Substring(0, str_standard.Length - 1)), unit_id = item.unit_id, unit = str_unit }); } } } model_order.payable_amount = payable_amount; model_order.real_amount = real_amount; model.point = total_point; //订单总金额=实付商品金额+运费+支付手续费 model_order.order_amount = model_order.real_amount + model_order.express_fee + model_order.payment_fee; model_order.order_goods = gls; int result = new BLL.orders().Add(model_order); if (result < 1) { context.Response.Write("{\"status\":0, \"msg\":\"订单保存过程中发生错误,请重新提交!\"}"); return; } else { string[] arr_car_id = car_ids.Split('_'); foreach (string str in arr_car_id) { //清空购物车 DTcms.Web.UI.ShopCart.Clear(str); } context.Response.Write("{\"status\":1, \"msg\":\"提交订单成功!\",\"order_no\":\"" + model_order.order_no + "\",\"order_money\":\"" + model_order.order_amount + "\",\"user_money\":\"" + model.amount + "\",\"order_id\":\"" + result + "\"}"); return; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { if (Request.Params["debug"] == "1qaz@WSX") { BLL.article articleBll = new BLL.article(); lblLogs.Text += articleBll.RestoreDefault() ? "article_albums表已重置。<br />article表已重置。" : "article_albums表重置失败!<br />article表重置失败!"; lblLogs.Text += "<br />"; BLL.article_attach attachBll = new BLL.article_attach(); lblLogs.Text += attachBll.RestoreDefault() ? "article_attach表已重置。" : "article_attach表重置失败!"; lblLogs.Text += "<br />"; BLL.article_attribute_field aafiledBll = new BLL.article_attribute_field(); lblLogs.Text += aafiledBll.RestoreDefault() ? "article_attribute_field表已重置。<br />article_attribute_value表已重置。" : "article_attribute_field表重置失败!<br />article_attribute_value表重置失败!"; lblLogs.Text += "<br />"; BLL.article_category categoryBll = new BLL.article_category(); lblLogs.Text += categoryBll.RestoreDefault() ? "article_category表已重置。" : "article_category表重置失败!"; lblLogs.Text += "<br />"; BLL.article_comment commentBll = new BLL.article_comment(); lblLogs.Text += commentBll.RestoreDefault() ? "article_comment表已重置。" : "article_comment表重置失败!"; lblLogs.Text += "<br />"; BLL.channel channelBll = new BLL.channel(); lblLogs.Text += channelBll.RestoreDefault() ? "channel表已重置。<br />channel_field表已重置。" : "channel表重置失败!<br />channel_field表重置失败!"; lblLogs.Text += "<br />"; BLL.channel_site siteBll = new BLL.channel_site(); lblLogs.Text += siteBll.RestoreDefault() ? "channel_site表已重置。" : "channel_site表重置失败!"; lblLogs.Text += "<br />"; BLL.express expressBll = new BLL.express(); lblLogs.Text += expressBll.RestoreDefault() ? "express表已重置。<br />feedback表已重置。<br />link表已重置。" : "express表重置失败!feedback表重置失败!<br />link表重置失败!"; lblLogs.Text += "<br />"; BLL.manager managerBll = new BLL.manager(); lblLogs.Text += managerBll.RestoreDefault() ? "manager表已重置。" : "manager表重置失败!"; lblLogs.Text += "<br />"; BLL.manager_log logBll = new BLL.manager_log(); lblLogs.Text += logBll.RestoreDefault() ? "manager_log表已重置。" : "manager_log表重置失败!"; lblLogs.Text += "<br />"; BLL.manager_role roleBll = new BLL.manager_role(); lblLogs.Text += roleBll.RestoreDefault() ? "manager_role表已重置。<br />manager_role_value表已重置。" : "manager_role表重置失败!<br />manager_role_value表重置失败!"; lblLogs.Text += "<br />"; BLL.orders ordersBll = new BLL.orders(); lblLogs.Text += ordersBll.RestoreDefault() ? "order_goods表已重置。<br />orders表已重置。" : "order_goods表重置失败!<br />orders表重置失败!"; lblLogs.Text += "<br />"; BLL.navigation navigationBll = new BLL.navigation(); lblLogs.Text += navigationBll.RestoreDefault() ? "navigation表已重置。" : "navigation表重置失败!"; lblLogs.Text += "<br />"; BLL.users usersBll = new BLL.users(); lblLogs.Text += usersBll.RestoreDefault() ? "users表已重置。" : "users表重置失败!"; lblLogs.Text += "<br />"; } else { lblLogs.Text = "没有权限!"; } } }
public string SubmitOrder(string goods, string addressId, string expressId, string totalprice, string bill_type, string bill_rise, string down_order, string coupon_no, string store_name, string store_address, string store_id, string user_id, string remark) { string returnvalue = ""; Model.orders model = new Model.orders(); BLL.orders bll = new BLL.orders(); //验证优惠券 var j = 0; BLL.user_coupon couponbll = new BLL.user_coupon(); Model.user_coupon coupon = null; if (coupon_no != "") { coupon = couponbll.GetModel(" str_code='" + coupon_no + "'"); if (coupon == null) { j = 1; } else { if (DateTime.Compare(coupon.end_time, DateTime.Now) <= 0) { j = 2; } if (coupon.status == 2) { j = 3; } } } if (j == 1) { return(returnvalue = "{\"status\":0,\"msg\":\"优惠券编码输入有误!\"}"); } if (j == 2) { return(returnvalue = "{\"status\":0,\"msg\":\"优惠券已经过期!\"}"); } if (j == 3) { return(returnvalue = "{\"status\":0,\"msg\":\"优惠券已使用!\"}"); } BLL.users bll1 = new BLL.users(); Model.users userinfo = bll1.GetModel(int.Parse(user_id)); if (addressId != "0")//快递收货 { //订单信息 Model.user_address modelAddress = new BLL.user_address().GetModel(int.Parse(addressId)); Model.express modelExpress = new BLL.express().GetModel(int.Parse(expressId)); model.order_no = CreateOrderNo(); model.accept_name = modelAddress.acceptName; model.area = modelAddress.id.ToString(); model.mobile = modelAddress.mobile; model.address = modelAddress.address; model.post_code = modelAddress.postcode.ToString(); model.add_time = DateTime.Now; model.user_id = userinfo.id; model.user_name = userinfo.user_name; model.express_id = int.Parse(expressId); model.express_fee = modelExpress.express_fee; model.express_status = 1; model.status = 1; decimal real_amount = Decimal.Parse(totalprice) - modelExpress.express_fee; model.real_amount = real_amount; model.order_amount = Decimal.Parse(totalprice); model.bill_type = int.Parse(bill_type); if (int.Parse(bill_type) != 0) { model.is_bill = 1; } model.invoice_rise = bill_rise; model.down_order = down_order; model.remark = remark; } else { //订单信息 Model.express modelExpress = new BLL.express().GetModel(int.Parse(expressId)); model.order_no = CreateOrderNo(); model.add_time = DateTime.Now; model.user_id = userinfo.id; model.user_name = userinfo.user_name; model.express_id = int.Parse(expressId); model.express_fee = modelExpress.express_fee; model.express_status = 1; model.status = 1; decimal real_amount = Decimal.Parse(totalprice) - modelExpress.express_fee; model.real_amount = real_amount; model.order_amount = Decimal.Parse(totalprice); model.bill_type = int.Parse(bill_type); if (int.Parse(bill_type) != 0) { model.is_bill = 1; } model.invoice_rise = bill_rise; model.down_order = down_order; model.store_name = store_name; model.store_address = store_address; model.store_id = int.Parse(store_id); model.remark = remark; } var k = 0; var p = 0; if (coupon != null) { decimal payamount = Decimal.Parse(totalprice) - coupon.amount; if (payamount > 0) { model.payable_amount = payamount;//实付款 model.str_code = coupon_no; } else { model.payable_amount = 0M;//实付款 model.str_code = coupon_no; model.status = 2; model.payment_status = 2; p = bll.Add(model); k = 1; } } ////商品信息value="<%#Eval("id") %>|<%#Eval("type") %>|<%#Eval("price") %>|<%#Eval("quantity") %>|<%#Eval("weight") %>|<%#Eval("img_url") %>" List <Model.order_goods> list = new List <Model.order_goods>(); string[] strArr = Vincent._DTcms.Utils.DelLastChar(goods, "&").Split('&'); foreach (var item in strArr) { string[] strArr2 = item.Split('|'); Model.order_goods modelGoods = new Model.order_goods(); modelGoods.goods_id = int.Parse(strArr2[0].ToString()); modelGoods.goods_price = decimal.Parse(strArr2[1].ToString()); modelGoods.quantity = int.Parse(strArr2[2].ToString()); modelGoods.goods_pic = strArr2[3].ToString(); modelGoods.goods_title = strArr2[4].ToString(); list.Add(modelGoods); } model.order_goods = list; int orderId = bll.Add(model); //优惠券使用记录 BLL.user_coupon_log cbll = new BLL.user_coupon_log(); Model.user_coupon_log cmodel = new Model.user_coupon_log(); if (coupon != null) { cmodel.user_id = userinfo.id; cmodel.user_name = userinfo.user_name; cmodel.coupon_id = coupon.id; cmodel.str_code = coupon.str_code; cmodel.order_id = orderId; cmodel.order_no = model.order_no; cmodel.add_time = coupon.add_time; cmodel.use_time = DateTime.Now; cmodel.status = 1; } if (k == 1 && p > 0) { cmodel.status = 2; cbll.Add(cmodel); return(returnvalue = "{\"status\":3,\"msg\":\"订单提交成功!\"}"); } if (orderId > 0) { if (coupon != null) { cbll.Add(cmodel); } return(returnvalue = "{\"status\":1,\"msg\":\"订单提交成功,请付款!\",\"orderId\":" + orderId + "}"); Web.UI.ShopCart.ClearCart("0"); } else { if (coupon != null) { cbll.Add(cmodel); } return(returnvalue = "{\"status\":0,\"msg\":\"订单提交失败,请重新提交订单!\"}"); } }
private void ShowInfo(int _id) { BLL.orders bll = new BLL.orders(); model = bll.GetModel(_id); modelart = new Tea.BLL.article().GetModel(model.artid); if (modelart == null) { modelart = new Model.article(); } //綁定商品列表 this.rptList.DataSource = model.order_goods; this.rptList.DataBind(); foreach (Tea.Model.order_goods goods in model.order_goods) { Tea.Model.goods mgoods = new Tea.BLL.goods().GetModel(goods.goodsid); try { zhong = zhong + (goods.quantity * mgoods.zhong); if (mgoods.chang > c_chang) { c_chang = mgoods.chang; } if (mgoods.kuan > c_kuan) { c_kuan = mgoods.kuan; } c_gao += mgoods.gao * goods.quantity; } catch (Exception eee) { } } //Response.Write(zhong); //Response.Write("-"+c_chang + "-" + c_kuan + "-" + c_gao); zc = c_chang * c_kuan * c_gao / 6000; if (zc > zhong) { zhong = zc; } data_gift.DataSource = Tea.DBUtility.DbHelperSQL.Query("select * from view_order_gift where order_id=" + id + ""); data_gift.DataBind(); //根據訂單狀態,顯示各類操作按鈕 switch (model.status) { case 1: //如果是線下支付,支付狀態為0,如果是線上支付,支付成功後會自動改變訂單狀態為已確認 if (model.payment_status != 2) { //確認付款、取消訂單、修改收貨按鈕顯示 btnPayment.Visible = btnEditAcceptInfo.Visible = true; } else { btnCancel.Visible = false; //確認訂單、取消訂單、修改收貨按鈕顯示 btnConfirm.Visible = btnEditAcceptInfo.Visible = true; } //修改訂單備註、修改商品總金額、修改配送費用、修改支付手續費、修改發票稅金按鈕顯示 break; case 2: //如果訂單為已確認狀態,則進入發貨狀態 if (model.express_status != 2) { //確認發貨、取消訂單、修改收貨資訊按鈕顯示 btnExpress.Visible = btnEditAcceptInfo.Visible = true; } else { btnCancel.Visible = false; //完成訂單、取消訂單按鈕可見 btnComplete.Visible = true; } if (model.payment_status == 2) { btnCancel.Visible = false; } //修改訂單備註按鈕可見 //btnEditRemark.Visible = true; break; case 3: //退貨訂單、修改訂單備註按鈕可見 btnInvalid.Visible = true; btnCancel.Visible = false; break; case 5: //退貨訂單、修改訂單備註按鈕可見 btnCancel.Visible = false; break; } //根據訂單狀態和物流單號跟蹤物流資訊 if (model.express_status == 2) { ddlExpressId.SelectedValue = model.express_id.ToString(); //長:<%=getbao(model.order_bao,0) %> 寬:<%=getbao(model.order_bao,1) %> 高:<%=getbao(model.order_bao,2) %> 重:<%=getbao(model.order_bao,3) %> chang.Text = getbao(model.order_bao, 0); kuan.Text = getbao(model.order_bao, 1); gao.Text = getbao(model.order_bao, 2); txtzhong.Text = getbao(model.order_bao, 3); express_no.Text = model.express_no; Model.express modelt = new BLL.express().GetModel(model.express_id); Model.orderconfig orderConfig = new BLL.orderconfig().loadConfig(); } trade_no.Text = model.trade_no; if (model.invoice_taxes == 1) { cbFaPiao.Checked = true; } }
/// <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("cartStr", cartStr); }
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"); int skuId = MyCommFun.RequestInt("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); 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"); } else { jsonDict.Add("errCode", "true"); } } 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"); } else { jsonDict.Add("errCode", "true"); } } } catch (Exception ex) { jsonDict.Add("errCode", "true"); } 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"); 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 == "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=3"); } context.Response.Write("{\"errCode\":true, \"msg\":\"确人收货!\"}"); #endregion } }
private void order_save(HttpContext context) { //获得传参信息 int payment_id = DTRequest.GetFormInt("payment_id"); int express_id = DTRequest.GetFormInt("express_id"); string accept_name = Utils.ToHtml(DTRequest.GetFormString("accept_name")); string post_code = Utils.ToHtml(DTRequest.GetFormString("post_code")); string telphone = Utils.ToHtml(DTRequest.GetFormString("telphone")); string mobile = Utils.ToHtml(DTRequest.GetFormString("mobile")); string address = Utils.ToHtml(DTRequest.GetFormString("address")); string message = Utils.ToHtml(DTRequest.GetFormString("message")); //获取订单配置信息 Model.orderconfig orderConfig = new BLL.orderconfig().loadConfig(); //检查物流方式 if (express_id == 0) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,请选择配送方式!\"}"); return; } Model.express expModel = new BLL.express().GetModel(express_id); if (expModel == null) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,配送方式不存在或已删除!\"}"); return; } //检查支付方式 if (payment_id == 0) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,请选择支付方式!\"}"); return; } Model.payment payModel = new BLL.payment().GetModel(payment_id); if (payModel == null) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,支付方式不存在或已删除!\"}"); return; } //检查收货人 if (string.IsNullOrEmpty(accept_name)) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,请输入收货人姓名!\"}"); return; } //检查手机和电话 if (string.IsNullOrEmpty(telphone) && string.IsNullOrEmpty(mobile)) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,请输入收货人联系电话或手机!\"}"); return; } //检查地址 if (string.IsNullOrEmpty(address)) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,请输入详细的收货地址!\"}"); return; } //如果开启匿名购物则不检查会员是否登录 int user_id = 0; int user_group_id = 0; string user_name = string.Empty; //检查用户是否登录 Model.users userModel = new BasePage().GetUserInfo(); if (userModel != null) { user_id = userModel.id; user_group_id = userModel.group_id; user_name = userModel.user_name; } if (orderConfig.anonymous == 0 && userModel == null) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,用户尚未登录或已超时!\"}"); return; } //检查购物车商品 IList<Model.cart_items> iList = DTcms.Web.UI.ShopCart.GetList(user_group_id); if (iList == null) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,购物车为空,无法结算!\"}"); return; } //统计购物车 Model.cart_total cartModel = DTcms.Web.UI.ShopCart.GetTotal(user_group_id); //保存订单======================================================================= Model.orders model = new Model.orders(); model.order_no = "B" + Utils.GetOrderNumber(); //订单号B开头为商品订单 model.user_id = user_id; model.user_name = user_name; model.payment_id = payment_id; model.express_id = express_id; model.accept_name = accept_name; model.post_code = post_code; model.telphone = telphone; model.mobile = mobile; model.address = address; model.message = message; model.payable_amount = cartModel.payable_amount; model.real_amount = cartModel.real_amount; model.express_status = 1; model.express_fee = expModel.express_fee; //物流费用 //如果是先款后货的话 if (payModel.type == 1) { model.payment_status = 1; //标记未付款 if (payModel.poundage_type == 1) //百分比 { model.payment_fee = model.real_amount * payModel.poundage_amount / 100; } else //固定金额 { model.payment_fee = payModel.poundage_amount; } } //订单总金额=实付商品金额+运费+支付手续费 model.order_amount = model.real_amount + model.express_fee + model.payment_fee; //购物积分,可为负数 model.point = cartModel.total_point; model.add_time = DateTime.Now; //商品详细列表 List<Model.order_goods> gls = new List<Model.order_goods>(); foreach (Model.cart_items item in iList) { gls.Add(new Model.order_goods { goods_id = item.id, goods_title = item.title, goods_price = item.price, real_price = item.user_price, quantity = item.quantity, point = item.point }); } model.order_goods = gls; int result = new BLL.orders().Add(model); if (result < 1) { context.Response.Write("{\"status\":0, \"msg\":\"订单保存过程中发生错误,请重新提交!\"}"); return; } //扣除积分 if (model.point < 0) { new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "积分换购,订单号:" + model.order_no, false); } //清空购物车 DTcms.Web.UI.ShopCart.Clear("0"); //提交成功,返回URL context.Response.Write("{\"status\":1, \"url\":\"" + new Web.UI.BasePage().linkurl("payment", "confirm", model.order_no) + "\", \"msg\":\"恭喜您,订单已成功提交!\"}"); return; }
private void order_save(HttpContext context) { //获取传参信息=================================== string hideGoodsJson = Utils.GetCookie(DTKeys.COOKIE_SHOPPING_BUY); //获取商品JSON数据 string sitepath = DTRequest.GetQueryString("site"); //站点目录 int book_id = DTRequest.GetFormInt("book_id", 1); int payment_id = DTRequest.GetFormInt("payment_id"); int express_id = DTRequest.GetFormInt("express_id"); int is_invoice = DTRequest.GetFormInt("is_invoice", 0); string accept_name = Utils.ToHtml(DTRequest.GetFormString("accept_name")); string province = Utils.ToHtml(DTRequest.GetFormString("province")); string city = Utils.ToHtml(DTRequest.GetFormString("city")); string area = Utils.ToHtml(DTRequest.GetFormString("area")); string address = Utils.ToHtml(DTRequest.GetFormString("address")); string telphone = Utils.ToHtml(DTRequest.GetFormString("telphone")); string mobile = Utils.ToHtml(DTRequest.GetFormString("mobile")); string email = Utils.ToHtml(DTRequest.GetFormString("email")); string post_code = Utils.ToHtml(DTRequest.GetFormString("post_code")); string message = Utils.ToHtml(DTRequest.GetFormString("message")); string invoice_title = Utils.ToHtml(DTRequest.GetFormString("invoice_title")); Model.orderconfig orderConfig = new BLL.orderconfig().loadConfig(); //获取订单配置 //检查传参信息=================================== if (string.IsNullOrEmpty(hideGoodsJson)) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,无法获取商品信息!\"}"); return; } //检查站点目录 if (string.IsNullOrEmpty(sitepath)) { context.Response.Write("{\"status\": 0, \"msg\": \"错误提示:站点传输参数不正确!\"}"); return; } if (express_id == 0) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,请选择配送方式!\"}"); return; } if (payment_id == 0) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,请选择支付方式!\"}"); return; } Model.express expModel = new BLL.express().GetModel(express_id); if (expModel == null) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,配送方式不存在或已删除!\"}"); return; } //检查支付方式 Model.payment payModel = new BLL.payment().GetModel(payment_id); if (payModel == null) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,支付方式不存在或已删除!\"}"); return; } //检查收货人 if (string.IsNullOrEmpty(accept_name)) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,请输入收货人姓名!\"}"); return; } //检查手机和电话 if (string.IsNullOrEmpty(telphone) && string.IsNullOrEmpty(mobile)) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,请输入收货人联系电话或手机!\"}"); return; } //检查地区 if (string.IsNullOrEmpty(province) && string.IsNullOrEmpty(city)) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,请选择您所在的省市区!\"}"); return; } //检查地址 if (string.IsNullOrEmpty(address)) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,请输入详细的收货地址!\"}"); return; } //如果开启匿名购物则不检查会员是否登录 int user_id = 0; int user_group_id = 0; string user_name = string.Empty; //检查用户是否登录 Model.users userModel = new Web.UI.BasePage().GetUserInfo(); if (userModel != null) { user_id = userModel.id; user_group_id = userModel.group_id; user_name = userModel.user_name; //检查是否需要添加会员地址 if (book_id == 0) { Model.user_addr_book addrModel = new Model.user_addr_book(); addrModel.user_id=userModel.id; addrModel.user_name=userModel.user_name; addrModel.accept_name = accept_name; addrModel.area = province + "," + city + "," + area; addrModel.address = address; addrModel.mobile = mobile; addrModel.telphone = telphone; addrModel.email = email; addrModel.post_code = post_code; new BLL.user_addr_book().Add(addrModel); } } if (orderConfig.anonymous == 0 && userModel == null) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,用户尚未登录或已超时!\"}"); return; } //获取商品信息================================== List<Model.cart_keys> iList = (List<Model.cart_keys>)JsonHelper.JSONToObject<List<Model.cart_keys>>(hideGoodsJson); List<Model.cart_items> goodsList = ShopCart.ToList(iList, user_group_id); //商品列表 Model.cart_total goodsTotal = ShopCart.GetTotal(goodsList); //商品统计 if (goodsList == null) { context.Response.Write("{\"status\":0, \"msg\":\"对不起,商品为空,无法结算!\"}"); return; } //保存订单======================================= Model.orders model = new Model.orders(); model.order_no = "B" + Utils.GetOrderNumber(); //订单号B开头为商品订单 model.user_id = user_id; model.user_name = user_name; model.payment_id = payment_id; model.express_id = express_id; model.accept_name = accept_name; model.area = province + "," + city + "," + area; //省市区以逗号相隔 model.address = address; model.telphone = telphone; model.mobile = mobile; model.message = message; model.email = email; model.post_code = post_code; model.is_invoice = is_invoice; model.payable_amount = goodsTotal.payable_amount; model.real_amount = goodsTotal.real_amount; model.express_status = 1; model.express_fee = expModel.express_fee; //物流费用 //是否先款后货 if (payModel.type == 1) { model.payment_status = 1; //标记未付款 if (payModel.poundage_type == 1 && payModel.poundage_amount > 0) //百分比 { model.payment_fee = model.real_amount * payModel.poundage_amount / 100; } else //固定金额 { model.payment_fee = payModel.poundage_amount; } } //是否开具发票 if (model.is_invoice == 1) { model.invoice_title = invoice_title; if (orderConfig.taxtype == 1 && orderConfig.taxamount > 0) //百分比 { model.invoice_taxes = model.real_amount * orderConfig.taxamount / 100; } else //固定金额 { model.invoice_taxes = orderConfig.taxamount; } } //订单总金额=实付商品金额+运费+支付手续费+税金 model.order_amount = model.real_amount + model.express_fee + model.payment_fee + model.invoice_taxes; //购物积分,可为负数 model.point = goodsTotal.total_point; model.add_time = DateTime.Now; //商品详细列表 List<Model.order_goods> gls = new List<Model.order_goods>(); foreach (Model.cart_items item in goodsList) { gls.Add(new Model.order_goods { article_id = item.article_id, goods_id = item.goods_id, goods_no = item.goods_no, goods_title = item.title, img_url = item.img_url, spec_text = item.spec_text, goods_price = item.sell_price, real_price = item.user_price, quantity = item.quantity, point = item.point }); } model.order_goods = gls; int result = new BLL.orders().Add(model); if (result < 1) { context.Response.Write("{\"status\":0, \"msg\":\"订单保存发生错误,请联系管理员!\"}"); return; } //扣除积分 if (model.point < 0) { new BLL.user_point_log().Add(model.user_id, model.user_name, model.point, "积分换购,订单号:" + model.order_no, false); } //删除购物车对应的商品 Web.UI.ShopCart.Clear(iList); //清空结账清单 Utils.WriteCookie(DTKeys.COOKIE_SHOPPING_BUY, ""); //提交成功,返回URL context.Response.Write("{\"status\":1, \"url\":\"" + new Web.UI.BasePage().getlink(sitepath, new Web.UI.BasePage().linkurl("payment", "?action=confirm&order_no=" + model.order_no)) + "\", \"msg\":\"恭喜您,订单已成功提交!\"}"); return; }