Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            openid = MyCommFun.RequestOpenid();
            int otid = MyCommFun.RequestInt("orderid");

            wid          = MyCommFun.RequestInt("wid");
            expireMinute = MyCommFun.RequestInt("expireminute");
            if (expireMinute == 0)
            {
                expireMinute = 30;
            }
            else if (expireMinute == -1)
            {  //如果为-1,则有限期间为1年
                expireMinute = 60 * 12 * 365;
            }
            if (openid == "" || otid == 0 || wid == 0)
            {
                return;
            }
            BLL.orders   otBll       = new BLL.orders();
            Model.orders orderEntity = otBll.GetModel(otid, wid);
            litout_trade_no.Text = orderEntity.order_no;
            litMoney.Text        = orderEntity.order_amount.ToString();
            litDate.Text         = orderEntity.add_time.ToString();
            WxPayData(orderEntity.order_amount, orderEntity.id.ToString(), orderEntity.order_no);
        }
Example #2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.orders model)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder str1   = new StringBuilder();

            //利用反射获得属性的所有公共属性
            PropertyInfo[]      pros  = model.GetType().GetProperties();
            List <SqlParameter> paras = new List <SqlParameter>();

            strSql.Append("update " + databaseprefix + "orders set ");
            foreach (PropertyInfo pi in pros)
            {
                //如果不是主键则追加sql字符串
                if (!pi.Name.Equals("id") && !typeof(System.Collections.IList).IsAssignableFrom(pi.PropertyType))
                {
                    //判断属性值是否为空
                    if (pi.GetValue(model, null) != null)
                    {
                        str1.Append(pi.Name + "=@" + pi.Name + ",");                          //声明参数
                        paras.Add(new SqlParameter("@" + pi.Name, pi.GetValue(model, null))); //对参数赋值
                    }
                }
            }
            strSql.Append(str1.ToString().Trim(','));
            strSql.Append(" where id=@id");
            paras.Add(new SqlParameter("@id", model.id));
            return(DbHelperSQL.ExecuteSql(strSql.ToString(), paras.ToArray()) > 0);
        }
Example #3
0
 /// <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();
     }
 }
Example #4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/json";
            string action = MXRequest.GetQueryString("myact");

            if (action == "upStock")
            {
                BLL.wx_shop_product spBll = new BLL.wx_shop_product();
                BLL.orders          oBll  = new BLL.orders();
                try
                {
                    string orderno = MyCommFun.QueryString("order_no");
                    //根据订单号得到订单
                    Model.orders oModel = oBll.GetModelByNo(orderno);
                    //得到所有订购商品
                    List <Model.order_goods> ogList = oModel.order_goods;

                    //根据订购商品的数量修改库存
                    foreach (Model.order_goods item in ogList)
                    {
                        Model.wx_shop_product spModel = spBll.GetModel(item.goods_id);
                        spModel.stock = spModel.stock - item.quantity;
                        spBll.Update(spModel);
                    }
                    context.Response.Write("{\"status\": 1, \"msg\": \"库存操作成功!\"}");
                    return;
                }
                catch (Exception)
                {
                    context.Response.Write("{\"status\": 0, \"msg\": \"库存操作失败!\"}");
                    return;
                }
            }
        }
Example #5
0
 //确认订单
 protected void lbtnConfirm_Click(object sender, EventArgs e)
 {
     ChkAdminLevel("orders", DTEnums.ActionEnum.Edit.ToString()); //检查权限
     BLL.orders   bll   = new BLL.orders();
     Model.orders model = bll.GetModel(this.id);
     //检查订单状态
     if (model == null || model.status > 1)
     {
         JscriptMsg("订单不符合要求,无法确认!", "", "Error");
         return;
     }
     //检查支付方式
     Model.payment payModel = new BLL.payment().GetModel(model.payment_id);
     if (payModel == null)
     {
         JscriptMsg("支付方式不存在,无法确认!", "", "Error");
         return;
     }
     //如果支付方式为线上支付,则检查付款状态
     if (payModel.type == 1)
     {
         if (model.payment_status != 2)
         {
             JscriptMsg("订单未付款,无法确认!", "", "Error");
             return;
         }
     }
     bll.UpdateField(this.id, "status=2,confirm_time='" + DateTime.Now + "'");
     JscriptMsg("订单确认成功!", "order_edit.aspx?id=" + this.id, "Success");
 }
        //确认设计
        protected void btnOK_Click(object sender, EventArgs e)
        {
            string orderNO = hiddNO.Value;

            if (orderNO == "")
            {
                JscriptMsg("传输参数不正确!", "back", "Error");
                return;
            }
            if (!new BLL.orders().Exists(orderNO))
            {
                JscriptMsg("订单不存在或已被删除!", "back", "Error");
                return;
            }
            model              = bll.GetModel(orderNO);
            model.status       = 3;
            model.confirm_time = DateTime.Now;
            if (bll.Update(model))
            {
                JscriptMsg("DIY设计确认成功!", "back", "success");
            }
            else
            {
                JscriptMsg("DIY设计确认失败!", "back", "Error");
            }
            //if (bll.Update(model))
            //{
            //    Response.Write("{\"status\":\"1\",\"msg\":\"DIY设计确认成功!\"}");
            //}
            //else
            //{
            //    Response.Write("{\"status\":\"0\",\"msg\":\"DIY设计确认失败!\"}");
            //}
        }
Example #7
0
        /// <summary>
        /// 根据订单号返回一个实体
        /// </summary>
        public Model.orders GetModel(string order_no)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder str1   = new StringBuilder();

            Model.orders model = new Model.orders();
            //利用反射获得属性的所有公共属性
            PropertyInfo[] pros = model.GetType().GetProperties();
            foreach (PropertyInfo p in pros)
            {
                //拼接字段,忽略List<T>
                if (!typeof(System.Collections.IList).IsAssignableFrom(p.PropertyType))
                {
                    str1.Append(p.Name + ",");//拼接字段
                }
            }
            strSql.Append("select top 1 " + str1.ToString().Trim(',') + " from " + databaseprefix + "orders");
            strSql.Append(" where order_no=@order_no");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@order_no", MySqlDbType.VarChar, 100)
            };
            parameters[0].Value = order_no;

            DataSet ds = DbHelperMySql.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #8
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.orders GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            StringBuilder str1   = new StringBuilder();

            Model.orders model = new Model.orders();
            //利用反射获得属性的所有公共属性
            PropertyInfo[] pros = model.GetType().GetProperties();
            foreach (PropertyInfo p in pros)
            {
                //拼接字段,忽略List<T>
                if (!typeof(System.Collections.IList).IsAssignableFrom(p.PropertyType))
                {
                    str1.Append(p.Name + ",");//拼接字段
                }
            }
            strSql.Append("select top 1 " + str1.ToString().Trim(','));
            strSql.Append(" from " + databaseprefix + "orders");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;
            DataTable dt = DbHelperSQL.Query(strSql.ToString(), parameters).Tables[0];

            if (dt.Rows.Count > 0)
            {
                return(DataRowToModel(dt.Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #9
0
 protected void lbtnConfirm_Click(object sender, EventArgs e)
 {
     ChkAdminLevel("orders", DTEnums.ActionEnum.Edit.ToString()); //檢查許可權
     BLL.orders   bll   = new BLL.orders();
     Model.orders model = bll.GetModel(this.id);
     //檢查訂單狀態
     if (model == null || model.status > 1)
     {
         JscriptMsg("訂單不符合要求,無法確認!", "", "Error");
         return;
     }
     //檢查付款方式
     Model.payment payModel = new BLL.payment().GetModel(model.payment_id);
     if (payModel == null)
     {
         JscriptMsg("付款方式不存在,無法確認!", "", "Error");
         return;
     }
     //如果付款方式為線上付款,則檢查付款狀態
     if (payModel.type == 1)
     {
         if (model.payment_status != 2)
         {
             JscriptMsg("訂單未付款,無法確認!", "", "Error");
             return;
         }
     }
     bll.UpdateField(this.id, "status=2,confirm_time='" + DateTime.Now + "'");
     JscriptMsg("訂單確認成功!", "order_edit.aspx?id=" + this.id, "Success");
 }
Example #10
0
 //完成订单
 protected void lbtnComplete_Click(object sender, EventArgs e)
 {
     ChkAdminLevel("orders", DTEnums.ActionEnum.Edit.ToString()); //检查权限
     BLL.orders   bll   = new BLL.orders();
     Model.orders model = bll.GetModel(this.id);
     //检查订单状态
     if (model == null || model.status != 2 || model.distribution_status != 2)
     {
         JscriptMsg("订单不符合要求,无法发货!", "", "Error");
         return;
     }
     //检查支付方式
     Model.payment payModel = new BLL.payment().GetModel(model.payment_id);
     if (payModel == null)
     {
         JscriptMsg("支付方式不存在,无法完成订单!", "", "Error");
         return;
     }
     //增加积分/经验值
     if (model.point > 0)
     {
         new BLL.point_log().Add(model.user_id, model.user_name, model.point, "购物获得积分,订单号:" + model.order_no);
     }
     //如果配送方式为先款后货,则检查付款状态
     if (payModel.type == 2)
     {
         bll.UpdateField(this.id, "status=3,complete_time='" + DateTime.Now + "'," + "payment_status=2,payment_time='" + DateTime.Now + "'");
     }
     else
     {
         bll.UpdateField(this.id, "status=3,complete_time='" + DateTime.Now + "'");
     }
     JscriptMsg("订单已经完成啦!", "order_edit.aspx?id=" + this.id, "Success");
 }
Example #11
0
 protected void lbtnComplete_Click(object sender, EventArgs e)
 {
     ChkAdminLevel("orders", DTEnums.ActionEnum.Edit.ToString()); //檢查許可權
     BLL.orders   bll   = new BLL.orders();
     Model.orders model = bll.GetModel(this.id);
     //檢查訂單狀態
     if (model == null || model.status != 2 || model.distribution_status != 2)
     {
         JscriptMsg("訂單不符合要求,無法發貨!", "", "Error");
         return;
     }
     //檢查付款方式
     Model.payment payModel = new BLL.payment().GetModel(model.payment_id);
     if (payModel == null)
     {
         JscriptMsg("付款方式不存在,無法完成訂單!", "", "Error");
         return;
     }
     //增加積分/經驗值
     if (model.point > 0)
     {
         new BLL.point_log().Add(model.user_id, model.user_name, model.point, "購物獲得積分,訂單號:" + model.order_no);
     }
     //如果配送方式為先款後貨,則檢查付款狀態
     if (payModel.type == 2)
     {
         bll.UpdateField(this.id, "status=3,complete_time='" + DateTime.Now + "'," + "payment_status=2,payment_time='" + DateTime.Now + "'");
     }
     else
     {
         bll.UpdateField(this.id, "status=3,complete_time='" + DateTime.Now + "'");
     }
     JscriptMsg("訂單已經完成!", "order_edit.aspx?id=" + this.id, "Success");
 }
Example #12
0
        /// <summary>
        /// 添加套餐站点可用数量表
        /// </summary>
        /// <param name="model"></param>
        public void Add(Model.orders model)
        {
            if (model == null)
            {
                return;
            }

            var dic = this.GetCallIndexNumMap(model);

            if (dic.Count == 0)
            {
                return;
            }

            var bi = new Model.buyersitebase()
            {
                user_id  = model.user_id,
                order_no = model.order_no,
                add_time = DateTime.Now,
                stat     = 1
            };

            var map = dic.Select(x => new Model.buyersiteext()
            {
                call_index = x.Key, subdomain_num = x.Value, subdomain_applied = 0
            }).ToList();

            new BLL.buyersite().AddList(bi, map);
        }
Example #13
0
 /// <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();
     }
 }
Example #14
0
 private void ShowInfo(string _order_no)
 {
     BLL.orders bll = new BLL.orders();
     model = bll.GetModel(_order_no);
     adminModel = GetAdminInfo();
     this.rptList.DataSource = model.order_goods;
     this.rptList.DataBind();
 }
Example #15
0
 private void ShowInfo(int _id)
 {
     BLL.orders bll = new BLL.orders();
     model                   = bll.GetModel(_id);
     managerModel            = GetAdminInfo();
     this.rptList.DataSource = model.order_goods;
     this.rptList.DataBind();
 }
Example #16
0
 private void ShowInfo(string _order_no)
 {
     BLL.orders bll = new BLL.orders();
     model      = bll.GetModel(_order_no);
     adminModel = GetAdminInfo();
     this.rptList.DataSource = model.order_goods;
     this.rptList.DataBind();
 }
Example #17
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.orders model)
        {
            int a = dal.Add(model);

            new Tea.BLL.users().JiSuan(model.user_id);

            return(a);
        }
 private void ShowInfo(int _id)
 {
     BLL.orders bll = new BLL.orders();
     model = bll.GetModel(_id);
     managerModel = GetAdminInfo();
     this.rptList.DataSource = model.order_goods;
     this.rptList.DataBind();
 }
Example #19
0
        private PayResult ValidateOrderNum(string ordernum)
        {
            var result = new PayResult();

            if (ordernum.StartsWith("R")) //充值订单
            {
                BLL.user_recharge   bll   = new BLL.user_recharge();
                Model.user_recharge model = bll.GetModel(ordernum);
                if (model == null)
                {
                    result.msg     = "该订单号不存在";
                    result.success = false;
                    result.status  = 201;
                    return(result);
                }
                if (model.status == 1)
                {
                    result.msg     = "该订单已经支付,请不要重复支付";
                    result.success = false;
                    result.status  = 202;
                    return(result);
                }
                result.msg     = "验证通过";
                result.success = true;
                result.status  = 200;
                return(result);
            }
            else if (ordernum.StartsWith("B"))
            {
                BLL.orders   bll   = new BLL.orders();
                Model.orders model = bll.GetModel(ordernum);
                if (model == null)
                {
                    result.msg     = "该订单号不存在";
                    result.success = false;
                    result.status  = 201;
                    return(result);
                }
                if (model.payment_status == 2) //已付款
                {
                    result.msg     = "该订单已经支付,请不要重复支付";
                    result.success = false;
                    result.status  = 202;
                    return(result);
                }
                result.msg     = "验证通过";
                result.success = true;
                result.status  = 200;
                return(result);
            }
            else
            {
                result.msg     = "订单号不正确";
                result.success = false;
                result.status  = 203;
                return(result);
            }
        }
Example #20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.id        = Vincent._DTcms.DTRequest.GetQueryInt("id", 0);
            this.refund_id = Vincent._DTcms.DTRequest.GetQueryInt("refund_id", 0);

            //如果传过来的是退货id
            if (this.id == 0)
            {
                this.id = this.refund_id;
                if (this.id == 0)
                {
                    JscriptMsg("传输参数不正确!", "back", "Error");
                    return;
                }

                Model.refund refund = new BLL.refund().GetModel(this.id);

                if (!new BLL.orders().Exists(refund.order_no))
                {
                    JscriptMsg("记录不存在或已被删除!", "back", "Error");
                    return;
                }
                if (!Page.IsPostBack)
                {
                    ChkAdminLevel("order_edit", Vincent._DTcms.DTEnums.ActionEnum.View.ToString()); //检查权限
                    ShowInfos(refund.order_no);
                    orderStatus();
                }

                addressModel = new BuysingooShop.BLL.user_address().GetModels(refund.user_id);
            }
            else
            {
                if (this.id == 0)
                {
                    JscriptMsg("传输参数不正确!", "back", "Error");
                    return;
                }

                //Model.refund refund = new BLL.refund().GetModel(this.id);
                model = new BLL.orders().GetModel(this.id);

                if (model == null)
                {
                    JscriptMsg("记录不存在或已被删除!", "back", "Error");
                    return;
                }
                if (!Page.IsPostBack)
                {
                    ChkAdminLevel("order_list", Vincent._DTcms.DTEnums.ActionEnum.View.ToString()); //检查权限
                    ShowInfos(model.order_no);
                    orderStatus();
                }

                addressModel = new BuysingooShop.BLL.user_address().GetModels(model.user_id);
            }
        }
Example #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            wid = MyCommFun.RequestInt("wid");
            //授权
            BLL.wx_userweixin   bll     = new BLL.wx_userweixin();
            Model.wx_userweixin wxModel = bll.GetModel(wid);
            string code = MyCommFun.QueryString("code");

            if (code == null || code.Trim() == "")
            {
                string thisUrl = MyCommFun.getTotalUrl();
                string newUrl  = OAuthApi.GetAuthorizeUrl(wxModel.AppId, thisUrl, "fukuan", OAuthScope.snsapi_base);
                Response.Redirect(newUrl);
            }
            else
            {
                var result = OAuthApi.GetAccessToken(wxModel.AppId, wxModel.AppSecret, code);
                openid = result.openid;
            }
            //授权结束
            // logBll.AddLog("【微支付】微信预定", "paypage.aspx Page_Load", " 授权结束openid= " + openid, 1);

            try
            {
                int otid = MyCommFun.RequestInt("orderid");
                otid_str = otid.ToString();
                rpage    = "/api/payment/paypage.aspx?showwxpaytitle=1&paytype=shop&wid=" + wid + "&openid=" + openid + "&orderid=" + otid_str;
                if (code == null || code.Trim() == "" || openid == "" || otid == 0 || wid == 0)
                {
                    return;
                }
                //expireMinute = MyCommFun.RequestInt("expireminute");
                //if (expireMinute == 0)
                //{
                //    expireMinute = 30;
                //}
                //else if (expireMinute == -1)
                //{  //如果为-1,则有限期间为1年
                //    expireMinute = 60 * 12 * 365;
                //}

                BLL.orders   otBll       = new BLL.orders();
                Model.orders orderEntity = otBll.GetModel(otid, wid);
                WXLogs.AddLog("【微支付】微信预定", "paypage.aspx Page_Load", "orderEntity.order_no: " + orderEntity.order_no + "|orderEntity.order_amount:" + orderEntity.order_amount, 1);
                litout_trade_no.Text = orderEntity.order_no;
                litMoney.Text        = orderEntity.order_amount.ToString();
                litDate.Text         = orderEntity.add_time.ToString();
                //WxPayData(orderEntity.order_amount, orderEntity.id.ToString(), orderEntity.order_no, code);//老的接口
                WxPayDataV3(orderEntity.order_amount, orderEntity.id.ToString(), orderEntity.order_no, code);
            }
            catch (Exception ex)
            {
                WXLogs.AddLog("【微支付】微信预定", "paypage.aspx Page_Load", "ex: " + ex.Message, 1);
                //MessageBox.ShowAndRedirect(this, "支付有问题:" + ex.Message, "/shop/index.aspx?wid=" + wid);
            }
        }
Example #22
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.orders model)
        {
            //计算订单总金额:商品总金额+配送费用+支付手续费
            //model.order_amount = model.real_amount + model.express_fee + model.payment_fee + model.invoice_taxes;
            bool b = dal.Update(model);

            new Tea.BLL.users().JiSuan(model.user_id);

            return(b);
        }
Example #23
0
 private void ShowInfo(string _order_no)
 {
     Model.wx_userweixin weixin = GetWeiXinCode();
     zffs = new WeiXinPF.BLL.payment().GetTitle(weixin.id, model.payment_id);
     BLL.orders bll = new BLL.orders();
     model      = bll.GetModel(_order_no);
     adminModel = GetAdminInfo();
     this.rptList.DataSource = model.order_goods;
     this.rptList.DataBind();
 }
Example #24
0
        /// <summary>
        /// 将对象转换实体
        /// </summary>
        public Model.orders DataRowToModel(DataRow row)
        {
            Model.orders model = new Model.orders();
            if (row != null)
            {
                #region 主表信息======================
                //利用反射获得属性的所有公共属性
                Type modelType = model.GetType();
                for (int i = 0; i < row.Table.Columns.Count; i++)
                {
                    //查找实体是否存在列表相同的公共属性
                    PropertyInfo proInfo = modelType.GetProperty(row.Table.Columns[i].ColumnName);
                    if (proInfo != null && row[i] != DBNull.Value)
                    {
                        proInfo.SetValue(model, row[i], null);//用索引值设置属性值
                    }
                }
                #endregion

                #region 子表信息======================
                StringBuilder strSql1 = new StringBuilder();
                strSql1.Append("select * from " + databaseprefix + "order_goods");
                strSql1.Append(" where order_id=@id");
                SqlParameter[] parameters1 =
                {
                    new SqlParameter("@id", SqlDbType.Int, 4)
                };
                parameters1[0].Value = model.id;

                DataTable dt1 = DbHelperSQL.Query(strSql1.ToString(), parameters1).Tables[0];
                if (dt1.Rows.Count > 0)
                {
                    int rowsCount = dt1.Rows.Count;
                    List <Model.order_goods> models = new List <Model.order_goods>();
                    Model.order_goods        modelt;
                    for (int n = 0; n < rowsCount; n++)
                    {
                        modelt = new Model.order_goods();
                        Type modeltType = modelt.GetType();
                        for (int i = 0; i < dt1.Rows[n].Table.Columns.Count; i++)
                        {
                            PropertyInfo proInfo = modeltType.GetProperty(dt1.Rows[n].Table.Columns[i].ColumnName);
                            if (proInfo != null && dt1.Rows[n][i] != DBNull.Value)
                            {
                                proInfo.SetValue(modelt, dt1.Rows[n][i], null);
                            }
                        }
                        models.Add(modelt);
                    }
                    model.order_goods = models;
                }
                #endregion
            }
            return(model);
        }
Example #25
0
        //將excel的資料寫入資料庫
        private string InsertGoods(DataTable dt)
        {
            string result = "";

            BLL.orders   bll   = new BLL.orders();
            Model.orders model = null;

            //判斷列名是否規範
            string[] strColumn = { "訂單號", "發票號" };
            int      num       = 0;

            for (int i = 0; i < dt.Columns.Count; i++)
            {
                foreach (string str in strColumn)
                {
                    if (str == dt.Columns[i].ColumnName)
                    {
                        num++;
                    }
                }
            }

            if (num == strColumn.Length)
            {
                //遍歷主件

                foreach (DataRow dr in dt.Rows)
                {
                    if (dr[0].ToString().Trim() != "" && dr[1].ToString().Trim() != "")
                    {
                        bool update = true;
                        try
                        {
                            model = bll.GetModel(dr[0].ToString());
                        }
                        catch (Exception eee) { }
                        if (model != null)
                        {
                            model.trade_no = dr[1].ToString();

                            if (update)
                            {
                                bll.Update(model);
                            }
                        }
                    }
                }
            }
            else
            {
                result = "請檢查excel檔案格式!" + num + strColumn.Length;
            }
            return(result);
        }
Example #26
0
 protected void Page_Load(object sender, EventArgs e)
 {
     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);
 }
Example #27
0
        /// <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);
            }
        }
Example #28
0
        public string OrderQuery()
        {
            int    orderId = MyCommFun.RequestInt("orderid");
            int    wid     = MyCommFun.RequestInt("wid");
            string code    = MyCommFun.RequestParam("code");
            string state   = MyCommFun.RequestParam("state");

            BLL.wx_payment_wxpay   wxPayBll    = new BLL.wx_payment_wxpay();
            Model.wx_payment_wxpay paymentInfo = wxPayBll.GetModelByWid(wid);
            BLL.wx_userweixin      wx          = new BLL.wx_userweixin();
            Model.wx_userweixin    wxModel     = wx.GetModel(wid);
            BLL.orders             otBll       = new BLL.orders();
            Model.orders           orderEntity = otBll.GetModel(orderId, wid);
            litout_trade_no = orderEntity.order_no;
            string         nonceStr          = TenPayV3Util.GetNoncestr();
            RequestHandler packageReqHandler = new RequestHandler(null);

            //设置package订单参数
            packageReqHandler.SetParameter("appid", paymentInfo.appId);      //公众账号ID
            packageReqHandler.SetParameter("mch_id", paymentInfo.partnerId); //商户号
            packageReqHandler.SetParameter("transaction_id", "");            //填入微信订单号
            packageReqHandler.SetParameter("out_trade_no", litout_trade_no); //填入商家订单号
            packageReqHandler.SetParameter("nonce_str", nonceStr);           //随机字符串
            string sign = packageReqHandler.CreateMd5Sign("key", paymentInfo.paySignKey);

            packageReqHandler.SetParameter("sign", sign);                           //签名

            string data = packageReqHandler.ParseXML();

            var result = TenPayV3.OrderQuery(data);
            var res    = XDocument.Parse(result);

            openid = res.Element("xml").Element("sign").Value;
            string transaction_id = res.Element("xml").Element("sign").Value;

            openids   = res.Element("xml").Element("openid").Value;
            bank_type = res.Element("xml").Element("bank_type").Value;
            if (bank_type == "CNY")
            {
                bank_type = "钱包零钱";
            }
            if (bank_type == "CFT")
            {
                bank_type = "银行卡";
            }
            total_fee      = res.Element("xml").Element("total_fee").Value;
            time_end       = res.Element("xml").Element("time_end").Value;
            out_trade_no   = res.Element("xml").Element("out_trade_no").Value;
            transaction_id = res.Element("xml").Element("transaction_id").Value;
            result_code    = res.Element("xml").Element("result_code").Value;

            return(openid);
        }
Example #29
0
        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();
            }
        }
Example #30
0
 //作废订单
 protected void btnInvalid_Click(object sender, EventArgs e)
 {
     ChkAdminLevel("orders", DTEnums.ActionEnum.Invalid.ToString()); //检查权限
     BLL.orders   bll   = new BLL.orders();
     Model.orders model = bll.GetModel(this.id);
     if (model == null && model.status != 3)
     {
         JscriptMsg("订单未完成,无法作废!", "", "Error");
         return;
     }
     bll.UpdateField(this.id, "status=5");
     JscriptMsg("订单取消成功啦!", "order_edit.aspx?id=" + this.id, "Success");
 }
Example #31
0
        /// <summary>
        /// 确认支付
        /// </summary>
        /// <param name="ID"></param>
        /// <returns></returns>
        public static bool ConfirmPay(int ID, int PayType, int pay)
        {
            orders bll = new orders("dt_");

            Model.orders model = bll.GetModel(ID);

            user_coupon coubll = new user_coupon("dt_");

            Model.user_coupon coumodel = new Model.user_coupon();
            if (model.str_code != "")
            {
                coumodel = coubll.GetModel(" str_code='" + model.str_code + "'");
            }

            if (model.status > 1 || model.payment_status == 2)
            {
                return(false);
            }
            model.payment_status = 2;
            model.payment_time   = DateTime.Now;
            model.status         = PayType;
            model.payment_id     = pay;
            model.confirm_time   = DateTime.Now;
            if (bll.Update(model))
            {
                if (model.str_code != "")
                {
                    coumodel.status = 2;
                    coubll.Update(coumodel);

                    users       bll1     = new users("dt_");
                    Model.users userinfo = bll1.GetModel(model.user_id);
                    //优惠券使用记录
                    user_coupon_log       cbll   = new user_coupon_log("dt_");
                    Model.user_coupon_log cmodel = new Model.user_coupon_log();
                    cmodel.user_id   = userinfo.id;
                    cmodel.user_name = userinfo.user_name;
                    cmodel.coupon_id = coumodel.id;
                    cmodel.str_code  = model.str_code;
                    cmodel.order_id  = model.id;
                    cmodel.order_no  = model.order_no;
                    cmodel.add_time  = coumodel.add_time;
                    cmodel.use_time  = DateTime.Now;
                    cmodel.status    = 2;
                }

                return(true);
            }

            return(false);
        }
Example #32
0
        //确认生产
        protected void btnConfirm_Click(object sender, EventArgs e)
        {
            ChkAdminLevel("order_list", Vincent._DTcms.DTEnums.ActionEnum.Confirm.ToString()); //检查权限
            int sucCount   = 0;
            int errorCount = 0;

            BLL.orders bll = new BLL.orders();
            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)
                {
                    Model.orders model = bll.GetModel(id);
                    if (model != null)
                    {
                        //检查订单是否使用在线支付方式
                        //if (model.payment_status > 0)
                        //{
                        //在线支付方式
                        //model.payment_status = 2; //标志已付款
                        //model.payment_time = DateTime.Now; //支付时间
                        //model.status = 3; // 订单为确认状态
                        //model.confirm_time = DateTime.Now; //确认时间
                        //}
                        //else
                        //{
                        //线下支付方式
                        //    model.status = 3; // 订单为确认状态
                        //    model.confirm_time = DateTime.Now; //确认时间
                        //}
                        model.status      = 4; // 已确认生产
                        model.winery_time = DateTime.Now;
                        if (bll.Update(model))
                        {
                            sucCount++;
                        }
                        else
                        {
                            errorCount++;
                        }
                    }
                    else
                    {
                        errorCount++;
                    }
                }
            }
            AddAdminLog(Vincent._DTcms.DTEnums.ActionEnum.Confirm.ToString(), "确认订单成功" + sucCount + "条,失败" + errorCount + "条"); //记录日志
            JscriptMsg("确认成功" + sucCount + "条,失败" + errorCount + "条!", Vincent._DTcms.Utils.CombUrlTxt("order_confirm.aspx", "keywords={0}", this.keywords), "Success");
        }
Example #33
0
 private void ShowInfo(int _id)
 {
     BLL.orders bll = new BLL.orders();
     model = bll.GetModel(_id);
     payModel = new BLL.payment().GetModel(model.payment_id);
     userModel = new BLL.users().GetModel(model.user_id);
     if (userModel != null)
     {
         groupModel = new BLL.user_groups().GetModel(userModel.group_id);
     }
     if (payModel == null)
     {
         payModel = new Model.payment();
     }
     this.rptList.DataSource = model.order_goods;
     this.rptList.DataBind();
     //订单状态
     if (model.status == 1)
     {
         if (payModel != null && payModel.type == 1)
         {
             if (model.payment_status > 1)
             {
                 this.lbtnConfirm.Enabled = true;
             }
         }
         else
         {
             this.lbtnConfirm.Enabled = true;
         }
     }
     else if (model.status == 2 && model.distribution_status == 1)
     {
         this.lbtnSend.Enabled = true;
     }
     else if (model.status == 2 && model.distribution_status == 2)
     {
         this.lbtnComplete.Enabled = true;
     }
     if (model.status < 3)
     {
         this.btnCancel.Visible = true;
     }
     //如果订单为已完成时,不能取消订单
     if (model.status == 3)
     {
         this.btnInvalid.Visible = true;
     }
 }
Example #34
0
 private void ShowInfo(int _id)
 {
     BLL.orders bll = new BLL.orders();
     model     = bll.GetModel(_id);
     payModel  = new BLL.payment().GetModel(model.payment_id);
     userModel = new BLL.users().GetModel(model.user_id);
     if (userModel != null)
     {
         groupModel = new BLL.user_groups().GetModel(userModel.group_id);
     }
     if (payModel == null)
     {
         payModel = new Model.payment();
     }
     this.rptList.DataSource = model.order_goods;
     this.rptList.DataBind();
     //订单状态
     if (model.status == 1)
     {
         if (payModel != null && payModel.type == 1)
         {
             if (model.payment_status > 1)
             {
                 this.lbtnConfirm.Enabled = true;
             }
         }
         else
         {
             this.lbtnConfirm.Enabled = true;
         }
     }
     else if (model.status == 2 && model.distribution_status == 1)
     {
         this.lbtnSend.Enabled = true;
     }
     else if (model.status == 2 && model.distribution_status == 2)
     {
         this.lbtnComplete.Enabled = true;
     }
     if (model.status < 3)
     {
         this.btnCancel.Visible = true;
     }
     //如果订单为已完成时,不能取消订单
     if (model.status == 3)
     {
         this.btnInvalid.Visible = true;
     }
 }
 /// <summary>
 /// 重写虚方法,此方法在Init事件执行
 /// </summary>
 protected override void InitPage()
 {
     id = MXRequest.GetQueryInt("id");
     BLL.orders bll = new BLL.orders();
     if (!bll.Exists(id))
     {
         HttpContext.Current.Response.Redirect(linkurl("error", "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!")));
         return;
     }
     model = bll.GetModel(id);
     payModel = new BLL.payment().GetModel(model.payment_id);
     if (payModel == null)
     {
         payModel = new Model.payment();
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

                openid = MyCommFun.RequestOpenid();
                otid = MyCommFun.RequestInt("otid");
                int wid = MyCommFun.RequestWid();
                if (openid == "" || otid == 0 || wid == 0)
                {
                    return;
                }

                WeiXinCRMComm wxComm = new WeiXinCRMComm();
                string err = "";
                token = wxComm.getAccessToken(wid, out err);

                BLL.orders otBll = new BLL.orders();
                ordertmp = otBll.GetModel(otid, wid);

            }
        }
Example #37
0
 /// <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);
             }
         }
     }
 }
Example #38
0
        /// <summary>
        /// 将在Init事件执行
        /// </summary>
        protected void payment_Init(object sender, EventArgs e)
        {
            //取得处事类型
            action = DTRequest.GetString("action");
            order_type = DTRequest.GetString("order_type");
            order_no = DTRequest.GetString("order_no");
            
            switch (action)
            {
                case "confirm":
                    if (string.IsNullOrEmpty(action) || string.IsNullOrEmpty(order_type) || string.IsNullOrEmpty(order_no))
                    {
                        HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,URL传输参数有误!"));
                        return;
                    }
                    //检查用户是否登录
                    userModel = new Web.UI.BasePage().GetUserInfo();
                    if (userModel == null)
                    {
                        //用户未登录
                        HttpContext.Current.Response.Redirect(linkurl("payment", "login"));
                        return;
                    }
                    //检查订单的类型(充值或购物)
                    if (order_type == DTEnums.AmountTypeEnum.Recharge.ToString()) //充值
                    {
                        amountModel = new BLL.amount_log().GetModel(order_no);
                        if (amountModel == null)
                        {
                            HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,订单号不存在或已删除!"));
                            return;
                        }
                        //检查订单号是否已支付
                        if (amountModel.status == 1)
                        {
                            HttpContext.Current.Response.Redirect(linkurl("payment1", "succeed", order_type, amountModel.order_no));
                            return;
                        }
                        //检查支付方式
                        payModel = new BLL.payment().GetModel(amountModel.payment_id);
                        if (payModel == null)
                        {
                            HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,支付方式不存在或已删除!"));
                            return;
                        }
                        //检查是否线上支付
                        if (payModel.type == 2)
                        {
                            HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,账户充值不允许线下支付!"));
                            return;
                        }
                        order_amount = amountModel.value; //订单金额
                    }
                    else if (order_type == DTEnums.AmountTypeEnum.BuyGoods.ToString()) //购物
                    {
                        //检查订单是否存在
                        orderModel = new BLL.orders().GetModel(order_no);
                        if (orderModel == null)
                        {
                            HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,订单号不存在或已删除!"));
                            return;
                        }
                        //检查是否已支付过
                        if (orderModel.payment_status == 2)
                        {
                            HttpContext.Current.Response.Redirect(linkurl("payment1", "succeed", order_type, orderModel.order_no));
                            return;
                        }
                        //检查支付方式
                        payModel = new BLL.payment().GetModel(orderModel.payment_id);
                        if (payModel == null)
                        {
                            HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,支付方式不存在或已删除!"));
                            return;
                        }
                        //检查是否线下付款
                        if (payModel.type == 2)
                        {
                            HttpContext.Current.Response.Redirect(linkurl("payment1", "succeed", order_type, orderModel.order_no));
                            return;
                        }
                        //检查是否积分换购,直接跳转成功页面
                        if (orderModel.order_amount == 0)
                        {
                            //修改订单状态
                            bool result = new BLL.orders().UpdateField(orderModel.order_no, "payment_status=2,payment_time='" + DateTime.Now + "'");
                            if (!result)
                            {
                                HttpContext.Current.Response.Redirect(linkurl("payment", "error"));
                                return;
                            }
                            HttpContext.Current.Response.Redirect(linkurl("payment1", "succeed", order_type, orderModel.order_no));
                            return;
                        }
                        order_amount = orderModel.order_amount; //订单金额
                    }
                    else
                    {
                        HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,找不到您要提交的订单类型!"));
                        return;
                    }
                    break;
                case "succeed":
                    //检查订单的类型(充值或购物)
                    if (order_type == DTEnums.AmountTypeEnum.Recharge.ToString()) //充值
                    {
                        amountModel = new BLL.amount_log().GetModel(order_no);
                        if (amountModel == null)
                        {
                            HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,订单号不存在或已删除!"));
                            return;
                        }

                    }
                    else if (order_type == DTEnums.AmountTypeEnum.BuyGoods.ToString()) //购物
                    {
                        orderModel = new BLL.orders().GetModel(order_no);
                        if (orderModel == null)
                        {
                            HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,订单号不存在或已删除!"));
                            return;
                        }
                    }
                    else
                    {
                        HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,找不到您要提交的订单类型!"));
                        return;
                    }
                    break;
            }
        }
        public void OrderSave(string jsondata, string version, string equType, string equName)
        {
            string json_result = string.Empty;
            //解析jsondata
            if (string.IsNullOrEmpty(jsondata))
            {
                json_result = "{\"status\":\"false\",\"data\":\"参数不能为空!\"}";
                Context.Response.Write(json_result);
                HttpContext.Current.ApplicationInstance.CompleteRequest();
                return;
            }
            try
            {
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                Dictionary<string, object> json = (Dictionary<string, object>)serializer.DeserializeObject(jsondata);

                int user_id = 0;
                int.TryParse(json["userId"].ToString(), out user_id);
                string nick_name = json["name"].ToString();

                int payment_id = 0; //支付方式为支付宝 DTRequest.GetFormInt("payment_id");
                int distribution_id = 4; //配送方式为普通快运 DTRequest.GetFormInt("distribution_id");

                object[] shopcarts = ((object[])json["shop_cart"]);
                if (shopcarts.Length == 0)
                {
                    Context.Response.Write("{\"status\":\"false\",\"data\":\"对不起,订单为空,无法结算!\"}");
                    HttpContext.Current.ApplicationInstance.CompleteRequest();
                    return;
                }
                //检查用户是否登录
                Model.users userModel = bll_user.GetModel(user_id);
                if (userModel == null)
                {
                    Context.Response.Write("{\"status\":\"false\",\"data\":\"对不起,此用户不存在!\"}");
                    HttpContext.Current.ApplicationInstance.CompleteRequest();
                    return;
                }

                Model.orders model = new Model.orders();
                //商品详细列表
                List<Model.order_goods> gls = new List<Model.order_goods>();
                //添加商品数据
                int quantity = 0;//临时数量变量
                int menpiao_type = 0;
                int goods_id = 0; //商品ID
                decimal goods_price = 0;
                decimal pay_amount = 0;//总金额
                foreach (var _item in shopcarts)
                {
                    Dictionary<string, object> d = (Dictionary<string, object>)_item;
                    int.TryParse(d["quantity"].ToString(), out quantity);
                    int.TryParse(d["goods_id"].ToString(), out goods_id);

                    decimal.TryParse(d["goods_price"].ToString(), out goods_price);
                    int.TryParse(d["menpiao_type"].ToString(), out menpiao_type);
                    for (int i = 0; i < quantity; i++)
                    {
                        gls.Add(new Model.order_goods { goods_id = goods_id, goods_name = d["goods_name"].ToString(), goods_price = goods_price, real_price = goods_price, menpiao_type = menpiao_type, quantity = 1, point = 0, status = 0, unique_code = "S" + Utils.GetShopNumber() });
                        pay_amount += goods_price;
                    }
                }
                model.order_goods = gls;

                //添加订单数据
                //保存订单=======================================================================

                model.order_no = "B" + Utils.GetOrderNumber(); //订单号
                model.user_id = user_id;
                model.user_name = nick_name;
                model.payment_id = payment_id;
                model.distribution_id = distribution_id;
                model.accept_name = nick_name;
                model.post_code = "";// post_code;
                model.telphone = userModel.mobile;// telphone;
                model.mobile = userModel.mobile;
                model.address = userModel.address; ;
                model.message = "";
                model.payable_amount = pay_amount;// cartModel.payable_amount;
                model.real_amount = pay_amount;// cartModel.real_amount;
                model.payable_freight = 0;// disModel.amount; //应付运费
                model.real_freight = 0;// disModel.amount; //实付运费
                //如果是先款后货的话
                //if (payModel.type == 1)
                //{
                //    if (payModel.poundage_type == 1) //百分比
                //    {
                //        model.payment_fee = model.real_amount * payModel.poundage_amount / 100;
                //    }
                //    else //固定金额
                //    {
                //        model.payment_fee = payModel.poundage_amount;
                //    }
                //}
                model.payment_fee = 0;
                //订单总金额=实付商品金额+运费+支付手续费
                model.order_amount = model.real_amount + model.real_freight + model.payment_fee;
                //购物积分,可为负数
                model.point = 0;// cartModel.total_point;
                model.add_time = DateTime.Now;

                int result = new BLL.orders().Add(model);
                if (result < 1)
                {
                    Context.Response.Write("{\"status\":\"false\",\"data\":\"订单保存过程中发生错误,请重新提交!\"}");
                    HttpContext.Current.ApplicationInstance.CompleteRequest();
                    return;
                }
                //提交成功,返回URL
                WriteWebServiceLog(version, equType, equName, "OrderSave", "");
                Context.Response.Write("{\"status\":\"true\",\"order_no\":\"" + model.order_no + "\",\"real_amount\":\"" + pay_amount + "\",\"data\":\"恭喜您,订单已成功提交!\"}");
                //Context.Response.Write("{\"msg\":1, \"url\":\"" + new Web.UI.BasePage().linkurl("payment1", "confirm", DTEnums.AmountTypeEnum.BuyGoods.ToString(), model.order_no) + "\", \"msgbox\":\"恭喜您,订单已成功提交!\"}");
                HttpContext.Current.ApplicationInstance.CompleteRequest();
                return;

            }
            catch (Exception ex)
            {
                Context.Response.Write("{\"status\":\"false\",\"data\":\"" + ex.Message + "\"}");
                HttpContext.Current.ApplicationInstance.CompleteRequest();
                return;
            }

            #region 注释部分

            //string post_code = DTRequest.GetFormString("post_code");
            //string telphone = DTRequest.GetFormString("telphone");
            //string mobile = DTRequest.GetFormString("mobile");
            //string address = DTRequest.GetFormString("address");
            ///string message = DTRequest.GetFormString("message");
            //检查配送方式
            //if (distribution_id == 0)
            //{
            //    context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,请选择配送方式!\"}");
            //    return;
            //}
            //Model.distribution disModel = new BLL.distribution().GetModel(distribution_id);
            //if (disModel == null)
            //{
            //    context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,您选择的配送方式不存在或已删除!\"}");
            //    return;
            //}
            //检查支付方式
            //if (payment_id == 0)
            //{
            //    context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,请选择支付方式!\"}");
            //    return;
            //}
            //Model.payment payModel = new BLL.payment().GetModel(payment_id);
            //if (payModel == null)
            //{
            //    context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,您选择的支付方式不存在或已删除!\"}");
            //    return;
            //}
            //检查收货人
            //if (string.IsNullOrEmpty(accept_name))
            //{
            //    context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,请输入收货人姓名!\"}");
            //    return;
            //}
            //检查手机和电话
            //if (string.IsNullOrEmpty(telphone) && string.IsNullOrEmpty(mobile))
            //{
            //    context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,请输入收货人联系电话或手机!\"}");
            //    return;
            //}
            ////检查地址
            //if (string.IsNullOrEmpty(address))
            //{
            //    context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,请输入详细的收货地址!\"}");
            //    return;
            //}

            //if (userModel == null)
            //{
            //    context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,用户没有登录或登录超时啦!\"}");
            //    return;
            //}
            //检查购物车商品
            //IList<Model.cart_items> iList = TOURISM.Web.UI.ShopCart.GetList(2);//userModel.group_id
            //if (iList == null)
            //{
            //    Context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,购物车为空,无法结算!\"}");
            //    return;
            //}
            //统计购物车
            //Model.cart_total cartModel = TOURISM.Web.UI.ShopCart.GetTotal(2);//userModel.group_id

            ////检查用户是否登录
            //Model.users userModel = bll_user.GetModel(user_id);

            //扣除积分
            //if (model.point < 0)
            //{
            //    new BLL.point_log().Add(model.user_id, model.user_name, model.point, "积分换购,订单号:" + model.order_no);
            //}
            //清空购物车
            //TOURISM.Web.UI.ShopCart.Clear("0");
            #endregion
        }
Example #40
0
        /// <summary>
        /// 根据定单号返回订单列表
        /// </summary>
        /// <param name="user_id">用户ID</param>
        /// <returns>订单列表</returns>
        public List<Model.orders> GetOrderList(string order_no)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select   id,order_no,user_id,user_name,payment_id,distribution_id,status,payment_status,distribution_status,delivery_name,delivery_no,accept_name,post_code,telphone,mobile,address,message,payable_amount,real_amount,payable_freight,real_freight,payment_fee,order_amount,point,add_time,payment_time,confirm_time,distribution_time,complete_time from dt_orders ");
            strSql.Append(" where order_no=@order_no and status!=5 order by add_time desc");
            SqlParameter[] parameters = { new SqlParameter("@order_no", SqlDbType.NVarChar, 50) };
            parameters[0].Value = order_no;

            List<Model.orders> list_orders = new List<Model.orders>();
            Model.orders model = null;
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                model = new Model.orders();

                #region  父表信息
                if (ds.Tables[0].Rows[i]["id"] != null && ds.Tables[0].Rows[i]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[i]["id"].ToString());
                }
                if (ds.Tables[0].Rows[i]["order_no"] != null && ds.Tables[0].Rows[i]["order_no"].ToString() != "")
                {
                    model.order_no = ds.Tables[0].Rows[i]["order_no"].ToString();
                }
                if (ds.Tables[0].Rows[i]["user_id"] != null && ds.Tables[0].Rows[i]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[i]["user_id"].ToString());
                }
                if (ds.Tables[0].Rows[i]["user_name"] != null && ds.Tables[0].Rows[i]["user_name"].ToString() != "")
                {
                    model.user_name = ds.Tables[0].Rows[i]["user_name"].ToString();
                }
                if (ds.Tables[0].Rows[i]["payment_id"] != null && ds.Tables[0].Rows[i]["payment_id"].ToString() != "")
                {
                    model.payment_id = int.Parse(ds.Tables[0].Rows[i]["payment_id"].ToString());
                }
                if (ds.Tables[0].Rows[i]["distribution_id"] != null && ds.Tables[0].Rows[i]["distribution_id"].ToString() != "")
                {
                    model.distribution_id = int.Parse(ds.Tables[0].Rows[i]["distribution_id"].ToString());
                }
                if (ds.Tables[0].Rows[i]["status"] != null && ds.Tables[0].Rows[i]["status"].ToString() != "")
                {
                    model.status = int.Parse(ds.Tables[0].Rows[i]["status"].ToString());
                }
                if (ds.Tables[0].Rows[i]["payment_status"] != null && ds.Tables[0].Rows[i]["payment_status"].ToString() != "")
                {
                    model.payment_status = int.Parse(ds.Tables[0].Rows[i]["payment_status"].ToString());
                }
                if (ds.Tables[0].Rows[i]["distribution_status"] != null && ds.Tables[0].Rows[i]["distribution_status"].ToString() != "")
                {
                    model.distribution_status = int.Parse(ds.Tables[0].Rows[i]["distribution_status"].ToString());
                }
                if (ds.Tables[0].Rows[i]["delivery_name"] != null && ds.Tables[0].Rows[i]["delivery_name"].ToString() != "")
                {
                    model.delivery_name = ds.Tables[0].Rows[i]["delivery_name"].ToString();
                }
                if (ds.Tables[0].Rows[i]["delivery_no"] != null && ds.Tables[0].Rows[i]["delivery_no"].ToString() != "")
                {
                    model.delivery_no = ds.Tables[0].Rows[i]["delivery_no"].ToString();
                }
                if (ds.Tables[0].Rows[i]["accept_name"] != null && ds.Tables[0].Rows[i]["accept_name"].ToString() != "")
                {
                    model.accept_name = ds.Tables[0].Rows[i]["accept_name"].ToString();
                }
                if (ds.Tables[0].Rows[i]["post_code"] != null && ds.Tables[0].Rows[i]["post_code"].ToString() != "")
                {
                    model.post_code = ds.Tables[0].Rows[i]["post_code"].ToString();
                }
                if (ds.Tables[0].Rows[i]["telphone"] != null && ds.Tables[0].Rows[i]["telphone"].ToString() != "")
                {
                    model.telphone = ds.Tables[0].Rows[i]["telphone"].ToString();
                }
                if (ds.Tables[0].Rows[i]["mobile"] != null && ds.Tables[0].Rows[i]["mobile"].ToString() != "")
                {
                    model.mobile = ds.Tables[0].Rows[i]["mobile"].ToString();
                }
                if (ds.Tables[0].Rows[i]["address"] != null && ds.Tables[0].Rows[i]["address"].ToString() != "")
                {
                    model.address = ds.Tables[0].Rows[i]["address"].ToString();
                }
                if (ds.Tables[0].Rows[i]["message"] != null && ds.Tables[0].Rows[i]["message"].ToString() != "")
                {
                    model.message = ds.Tables[0].Rows[i]["message"].ToString();
                }
                if (ds.Tables[0].Rows[i]["payable_amount"] != null && ds.Tables[0].Rows[i]["payable_amount"].ToString() != "")
                {
                    model.payable_amount = decimal.Parse(ds.Tables[0].Rows[i]["payable_amount"].ToString());
                }
                if (ds.Tables[0].Rows[i]["real_amount"] != null && ds.Tables[0].Rows[i]["real_amount"].ToString() != "")
                {
                    model.real_amount = decimal.Parse(ds.Tables[0].Rows[i]["real_amount"].ToString());
                }
                if (ds.Tables[0].Rows[i]["payable_freight"] != null && ds.Tables[0].Rows[i]["payable_freight"].ToString() != "")
                {
                    model.payable_freight = decimal.Parse(ds.Tables[0].Rows[i]["payable_freight"].ToString());
                }
                if (ds.Tables[0].Rows[i]["real_freight"] != null && ds.Tables[0].Rows[i]["real_freight"].ToString() != "")
                {
                    model.real_freight = decimal.Parse(ds.Tables[0].Rows[i]["real_freight"].ToString());
                }
                if (ds.Tables[0].Rows[i]["payment_fee"] != null && ds.Tables[0].Rows[i]["payment_fee"].ToString() != "")
                {
                    model.payment_fee = decimal.Parse(ds.Tables[0].Rows[i]["payment_fee"].ToString());
                }
                if (ds.Tables[0].Rows[i]["order_amount"] != null && ds.Tables[0].Rows[i]["order_amount"].ToString() != "")
                {
                    model.order_amount = decimal.Parse(ds.Tables[0].Rows[i]["order_amount"].ToString());
                }
                if (ds.Tables[0].Rows[i]["point"] != null && ds.Tables[0].Rows[i]["point"].ToString() != "")
                {
                    model.point = int.Parse(ds.Tables[0].Rows[i]["point"].ToString());
                }
                if (ds.Tables[0].Rows[i]["add_time"] != null && ds.Tables[0].Rows[i]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[i]["add_time"].ToString());
                }
                if (ds.Tables[0].Rows[i]["payment_time"] != null && ds.Tables[0].Rows[i]["payment_time"].ToString() != "")
                {
                    model.payment_time = DateTime.Parse(ds.Tables[0].Rows[i]["payment_time"].ToString());
                }
                if (ds.Tables[0].Rows[i]["confirm_time"] != null && ds.Tables[0].Rows[i]["confirm_time"].ToString() != "")
                {
                    model.confirm_time = DateTime.Parse(ds.Tables[0].Rows[i]["confirm_time"].ToString());
                }
                if (ds.Tables[0].Rows[i]["distribution_time"] != null && ds.Tables[0].Rows[i]["distribution_time"].ToString() != "")
                {
                    model.distribution_time = DateTime.Parse(ds.Tables[0].Rows[i]["distribution_time"].ToString());
                }
                if (ds.Tables[0].Rows[i]["complete_time"] != null && ds.Tables[0].Rows[i]["complete_time"].ToString() != "")
                {
                    model.complete_time = DateTime.Parse(ds.Tables[0].Rows[i]["complete_time"].ToString());
                }
                #endregion

                #region  子表信息
                StringBuilder strSql2 = new StringBuilder();
                strSql2.Append("select id,order_id,goods_id,goods_name,goods_price,real_price,quantity,point,status,unique_code,menpiao_type from dt_order_goods ");
                strSql2.Append(" where order_id=@id ");
                SqlParameter[] parameters2 = { new SqlParameter("@id", SqlDbType.Int, 4) };
                parameters2[0].Value = model.id;

                DataSet ds2 = DbHelperSQL.Query(strSql2.ToString(), parameters2);
                if (ds2.Tables[0].Rows.Count > 0)
                {
                    #region  子表字段信息
                    int y = ds2.Tables[0].Rows.Count;
                    List<Model.order_goods> models = new List<Model.order_goods>();
                    Model.order_goods modelt;
                    for (int n = 0; n < y; n++)
                    {
                        modelt = new Model.order_goods();
                        if (ds2.Tables[0].Rows[n]["id"] != null && ds2.Tables[0].Rows[n]["id"].ToString() != "")
                        {
                            modelt.id = int.Parse(ds2.Tables[0].Rows[n]["id"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["order_id"] != null && ds2.Tables[0].Rows[n]["order_id"].ToString() != "")
                        {
                            modelt.order_id = int.Parse(ds2.Tables[0].Rows[n]["order_id"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["goods_id"] != null && ds2.Tables[0].Rows[n]["goods_id"].ToString() != "")
                        {
                            modelt.goods_id = int.Parse(ds2.Tables[0].Rows[n]["goods_id"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["goods_name"] != null && ds2.Tables[0].Rows[n]["goods_name"].ToString() != "")
                        {
                            modelt.goods_name = ds2.Tables[0].Rows[n]["goods_name"].ToString();
                        }
                        if (ds2.Tables[0].Rows[n]["goods_price"] != null && ds2.Tables[0].Rows[n]["goods_price"].ToString() != "")
                        {
                            modelt.goods_price = decimal.Parse(ds2.Tables[0].Rows[n]["goods_price"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["real_price"] != null && ds2.Tables[0].Rows[n]["real_price"].ToString() != "")
                        {
                            modelt.real_price = decimal.Parse(ds2.Tables[0].Rows[n]["real_price"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["quantity"] != null && ds2.Tables[0].Rows[n]["quantity"].ToString() != "")
                        {
                            modelt.quantity = int.Parse(ds2.Tables[0].Rows[n]["quantity"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["menpiao_type"] != null && ds2.Tables[0].Rows[n]["menpiao_type"].ToString() != "")
                        {
                            modelt.menpiao_type = int.Parse(ds2.Tables[0].Rows[n]["menpiao_type"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["point"] != null && ds2.Tables[0].Rows[n]["point"].ToString() != "")
                        {
                            modelt.point = int.Parse(ds2.Tables[0].Rows[n]["point"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["status"] != null && ds2.Tables[0].Rows[n]["status"].ToString() != "")
                        {
                            modelt.status = int.Parse(ds2.Tables[0].Rows[n]["status"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["unique_code"] != null && ds2.Tables[0].Rows[n]["unique_code"].ToString() != "")
                        {
                            modelt.unique_code = ds2.Tables[0].Rows[n]["unique_code"].ToString();
                        }
                        models.Add(modelt);
                    }
                    model.order_goods = models;
                    #endregion
                }
                #endregion

                list_orders.Add(model);

            }

            if (list_orders.Count == 0)
            { return null; }

            return list_orders; ;
        }
Example #41
0
        /// <summary>
        /// ������ת��Ϊʵ��
        /// </summary>
        public Model.orders DataRowToModel(DataRow row)
        {
            Model.orders model = new Model.orders();
            if (row != null)
            {
                #region ������Ϣ
                if (row["id"] != null && row["id"].ToString() != "")
                {
                    model.id = int.Parse(row["id"].ToString());
                }
                if (row["order_no"] != null)
                {
                    model.order_no = row["order_no"].ToString();
                }
                if (row["trade_no"] != null)
                {
                    model.trade_no = row["trade_no"].ToString();
                }
                if (row["user_id"] != null && row["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(row["user_id"].ToString());
                }
                if (row["user_name"] != null)
                {
                    model.user_name = row["user_name"].ToString();
                }
                if (row["payment_id"] != null && row["payment_id"].ToString() != "")
                {
                    model.payment_id = int.Parse(row["payment_id"].ToString());
                }
                if (row["payment_fee"] != null && row["payment_fee"].ToString() != "")
                {
                    model.payment_fee = decimal.Parse(row["payment_fee"].ToString());
                }
                if (row["payment_status"] != null && row["payment_status"].ToString() != "")
                {
                    model.payment_status = int.Parse(row["payment_status"].ToString());
                }
                if (row["payment_time"] != null && row["payment_time"].ToString() != "")
                {
                    model.payment_time = DateTime.Parse(row["payment_time"].ToString());
                }
                if (row["express_id"] != null && row["express_id"].ToString() != "")
                {
                    model.express_id = int.Parse(row["express_id"].ToString());
                }
                if (row["express_no"] != null)
                {
                    model.express_no = row["express_no"].ToString();
                }
                if (row["express_fee"] != null && row["express_fee"].ToString() != "")
                {
                    model.express_fee = decimal.Parse(row["express_fee"].ToString());
                }
                if (row["express_status"] != null && row["express_status"].ToString() != "")
                {
                    model.express_status = int.Parse(row["express_status"].ToString());
                }
                if (row["express_time"] != null && row["express_time"].ToString() != "")
                {
                    model.express_time = DateTime.Parse(row["express_time"].ToString());
                }
                if (row["accept_name"] != null)
                {
                    model.accept_name = row["accept_name"].ToString();
                }
                if (row["post_code"] != null)
                {
                    model.post_code = row["post_code"].ToString();
                }
                if (row["telphone"] != null)
                {
                    model.telphone = row["telphone"].ToString();
                }
                if (row["mobile"] != null)
                {
                    model.mobile = row["mobile"].ToString();
                }
                if (row["email"] != null)
                {
                    model.email = row["email"].ToString();
                }
                if (row["area"] != null)
                {
                    model.area = row["area"].ToString();
                }
                if (row["address"] != null)
                {
                    model.address = row["address"].ToString();
                }
                if (row["message"] != null)
                {
                    model.message = row["message"].ToString();
                }
                if (row["remark"] != null)
                {
                    model.remark = row["remark"].ToString();
                }
                if (row["is_invoice"] != null && row["is_invoice"].ToString() != "")
                {
                    model.is_invoice = int.Parse(row["is_invoice"].ToString());
                }
                if (row["invoice_title"] != null)
                {
                    model.invoice_title = row["invoice_title"].ToString();
                }
                if (row["invoice_taxes"] != null && row["invoice_taxes"].ToString() != "")
                {
                    model.invoice_taxes = decimal.Parse(row["invoice_taxes"].ToString());
                }
                if (row["payable_amount"] != null && row["payable_amount"].ToString() != "")
                {
                    model.payable_amount = decimal.Parse(row["payable_amount"].ToString());
                }
                if (row["real_amount"] != null && row["real_amount"].ToString() != "")
                {
                    model.real_amount = decimal.Parse(row["real_amount"].ToString());
                }
                if (row["order_amount"] != null && row["order_amount"].ToString() != "")
                {
                    model.order_amount = decimal.Parse(row["order_amount"].ToString());
                }
                if (row["point"] != null && row["point"].ToString() != "")
                {
                    model.point = int.Parse(row["point"].ToString());
                }
                if (row["status"] != null && row["status"].ToString() != "")
                {
                    model.status = int.Parse(row["status"].ToString());
                }
                if (row["add_time"] != null && row["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(row["add_time"].ToString());
                }
                if (row["confirm_time"] != null && row["confirm_time"].ToString() != "")
                {
                    model.confirm_time = DateTime.Parse(row["confirm_time"].ToString());
                }
                if (row["complete_time"] != null && row["complete_time"].ToString() != "")
                {
                    model.complete_time = DateTime.Parse(row["complete_time"].ToString());
                }
                #endregion

                #region �ӱ���Ϣ
                StringBuilder strSql2 = new StringBuilder();
                strSql2.Append("select id,article_id,order_id,goods_id,goods_no,goods_title,img_url,spec_text,goods_price,real_price,quantity,point");
                strSql2.Append(" from " + databaseprefix + "order_goods ");
                strSql2.Append(" where order_id=@id ");
                SqlParameter[] parameters2 = {
                        new SqlParameter("@id", SqlDbType.Int,4)};
                parameters2[0].Value = model.id;
                DataSet ds2 = DbHelperSQL.Query(strSql2.ToString(), parameters2);

                if (ds2.Tables[0].Rows.Count > 0)
                {
                    List<Model.order_goods> ls = new List<Model.order_goods>();
                    for (int n = 0; n < ds2.Tables[0].Rows.Count; n++)
                    {
                        Model.order_goods modelt = new Model.order_goods();
                        if (ds2.Tables[0].Rows[n]["id"] != null && ds2.Tables[0].Rows[n]["id"].ToString() != "")
                        {
                            modelt.id = int.Parse(ds2.Tables[0].Rows[n]["id"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["article_id"] != null && ds2.Tables[0].Rows[n]["article_id"].ToString() != "")
                        {
                            modelt.article_id = int.Parse(ds2.Tables[0].Rows[n]["article_id"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["order_id"] != null && ds2.Tables[0].Rows[n]["order_id"].ToString() != "")
                        {
                            modelt.order_id = int.Parse(ds2.Tables[0].Rows[n]["order_id"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["goods_id"] != null && ds2.Tables[0].Rows[n]["goods_id"].ToString() != "")
                        {
                            modelt.goods_id = int.Parse(ds2.Tables[0].Rows[n]["goods_id"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["goods_no"] != null)
                        {
                            modelt.goods_no = ds2.Tables[0].Rows[n]["goods_no"].ToString();
                        }
                        if (ds2.Tables[0].Rows[n]["goods_title"] != null)
                        {
                            modelt.goods_title = ds2.Tables[0].Rows[n]["goods_title"].ToString();
                        }
                        if (ds2.Tables[0].Rows[n]["img_url"] != null)
                        {
                            modelt.img_url = ds2.Tables[0].Rows[n]["img_url"].ToString();
                        }
                        if (ds2.Tables[0].Rows[n]["spec_text"] != null)
                        {
                            modelt.spec_text = ds2.Tables[0].Rows[n]["spec_text"].ToString();
                        }
                        if (ds2.Tables[0].Rows[n]["goods_price"] != null && ds2.Tables[0].Rows[n]["goods_price"].ToString() != "")
                        {
                            modelt.goods_price = decimal.Parse(ds2.Tables[0].Rows[n]["goods_price"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["real_price"] != null && ds2.Tables[0].Rows[n]["real_price"].ToString() != "")
                        {
                            modelt.real_price = decimal.Parse(ds2.Tables[0].Rows[n]["real_price"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["quantity"] != null && ds2.Tables[0].Rows[n]["quantity"].ToString() != "")
                        {
                            modelt.quantity = int.Parse(ds2.Tables[0].Rows[n]["quantity"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["point"] != null && ds2.Tables[0].Rows[n]["point"].ToString() != "")
                        {
                            modelt.point = int.Parse(ds2.Tables[0].Rows[n]["point"].ToString());
                        }
                        ls.Add(modelt);
                    }
                    model.order_goods = ls;
                }
                #endregion
            }
            return model;
        }
Example #42
0
        /// <summary>
        /// 将在Init事件执行
        /// </summary>
        protected void payment_Init(object sender, EventArgs e)
        {
            //取得处事类型
            action = DTRequest.GetString("action");
            order_no = DTRequest.GetString("order_no");
            if (order_no.ToUpper().StartsWith("R")) //充值订单
            {
                order_type = DTEnums.AmountTypeEnum.Recharge.ToString().ToLower();
            }
            else if (order_no.ToUpper().StartsWith("B")) //商品订单
            {
                order_type = DTEnums.AmountTypeEnum.BuyGoods.ToString().ToLower();
            }
            
            switch (action)
            {
                case "confirm":
                    if (string.IsNullOrEmpty(action) || string.IsNullOrEmpty(order_no))
                    {
                        HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,URL传输参数有误!")));
                        return;
                    }
                    //是否需要支持匿名购物
                    userModel = new Web.UI.BasePage().GetUserInfo(); //取得用户登录信息
                    if (orderConfig.anonymous == 0 || order_no.ToUpper().StartsWith("R"))
                    {
                        if (userModel == null)
                        {
                            //用户未登录
                            HttpContext.Current.Response.Redirect(linkurl("payment", "?action=login"));
                            return;
                        }
                    }
                    else if (userModel == null)
                    {
                        userModel = new Model.users();
                    }
                    //检查订单的类型(充值或购物)
                    if (order_no.ToUpper().StartsWith("R")) //充值订单
                    {
                        rechargeModel = new BLL.user_recharge().GetModel(order_no);
                        if (rechargeModel == null)
                        {
                            HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,订单号不存在或已删除!")));
                            return;
                        }
                        //检查订单号是否已支付
                        if (rechargeModel.status == 1)
                        {
                            HttpContext.Current.Response.Redirect(linkurl("payment", "?action=succeed&order_no=" + rechargeModel.recharge_no));
                            return;
                        }
                        //检查支付方式
                        payModel = new BLL.payment().GetModel(rechargeModel.payment_id);
                        if (payModel == null)
                        {
                            HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,支付方式不存在或已删除!")));
                            return;
                        }
                        //检查是否线上支付
                        if (payModel.type == 2)
                        {
                            HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,账户充值不允许线下支付!")));
                            return;
                        }
                        order_amount = rechargeModel.amount; //订单金额
                    }
                    else if (order_no.ToUpper().StartsWith("B")) //商品订单
                    {
                        //检查订单是否存在
                        orderModel = new BLL.orders().GetModel(order_no);
                        if (orderModel == null)
                        {
                            HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,订单号不存在或已删除!")));
                            return;
                        }
                        //检查是否已支付过
                        if (orderModel.payment_status == 2)
                        {
                            HttpContext.Current.Response.Redirect(linkurl("payment", "?action=succeed&order_no=" + orderModel.order_no));
                            return;
                        }
                        //检查支付方式
                        payModel = new BLL.payment().GetModel(orderModel.payment_id);
                        if (payModel == null)
                        {
                            HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,支付方式不存在或已删除!")));
                            return;
                        }
                        //检查是否线下付款
                        if (orderModel.payment_status == 0)
                        {
                            HttpContext.Current.Response.Redirect(linkurl("payment", "?action=succeed&order_no=" + orderModel.order_no));
                            return;
                        }
                        //检查是否积分换购,直接跳转成功页面
                        if (orderModel.order_amount == 0)
                        {
                            //修改订单状态
                            bool result = new BLL.orders().UpdateField(orderModel.order_no, "status=2,payment_status=2,payment_time='" + DateTime.Now + "'");
                            if (!result)
                            {
                                HttpContext.Current.Response.Redirect(linkurl("payment", "?action=error"));
                                return;
                            }
                            HttpContext.Current.Response.Redirect(linkurl("payment", "?action=succeed&order_no=" + orderModel.order_no));
                            return;
                        }
                        order_amount = orderModel.order_amount; //订单金额
                    }
                    else
                    {
                        HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,找不到您要提交的订单类型!")));
                        return;
                    }
                    break;
                case "succeed":
                    //检查订单的类型(充值或购物)
                    if (order_no.ToUpper().StartsWith("R")) //充值订单
                    {
                        rechargeModel = new BLL.user_recharge().GetModel(order_no);
                        if (rechargeModel == null)
                        {
                            HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,订单号不存在或已删除!")));
                            return;
                        }

                    }
                    else if (order_no.ToUpper().StartsWith("B")) //商品订单
                    {
                        orderModel = new BLL.orders().GetModel(order_no);
                        if (orderModel == null)
                        {
                            HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,订单号不存在或已删除!")));
                            return;
                        }
                    }
                    else
                    {
                        HttpContext.Current.Response.Redirect(linkurl("error", "?msg=" + Utils.UrlEncode("出错啦,找不到您要提交的订单类型!")));
                        return;
                    }
                    break;
            }
        }
Example #43
0
 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 = 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;
     }
 }
Example #44
0
        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;
            }
        }
Example #45
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public Model.orders GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,order_no,trade_no,user_id,user_name,payment_id,payment_fee,payment_status,payment_time,express_id,express_no,express_fee,express_status,express_time,accept_name,post_code,telphone,mobile,area,address,message,remark,payable_amount,real_amount,order_amount,point,status,add_time,confirm_time,complete_time,is_up,up_status");
            strSql.Append(" from " + databaseprefix + "orders ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;

            Model.orders model = new Model.orders();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                #region ������Ϣ
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                model.order_no = ds.Tables[0].Rows[0]["order_no"].ToString();
                model.trade_no = ds.Tables[0].Rows[0]["trade_no"].ToString();
                if (ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString();
                if (ds.Tables[0].Rows[0]["payment_id"].ToString() != "")
                {
                    model.payment_id = int.Parse(ds.Tables[0].Rows[0]["payment_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["payment_fee"].ToString() != "")
                {
                    model.payment_fee = decimal.Parse(ds.Tables[0].Rows[0]["payment_fee"].ToString());
                }
                if (ds.Tables[0].Rows[0]["payment_status"].ToString() != "")
                {
                    model.payment_status = int.Parse(ds.Tables[0].Rows[0]["payment_status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["payment_time"].ToString() != "")
                {
                    model.payment_time = DateTime.Parse(ds.Tables[0].Rows[0]["payment_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["express_id"].ToString() != "")
                {
                    model.express_id = int.Parse(ds.Tables[0].Rows[0]["express_id"].ToString());
                }
                model.express_no = ds.Tables[0].Rows[0]["express_no"].ToString();
                if (ds.Tables[0].Rows[0]["express_fee"].ToString() != "")
                {
                    model.express_fee = decimal.Parse(ds.Tables[0].Rows[0]["express_fee"].ToString());
                }
                if (ds.Tables[0].Rows[0]["express_status"].ToString() != "")
                {
                    model.express_status = int.Parse(ds.Tables[0].Rows[0]["express_status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["express_time"].ToString() != "")
                {
                    model.express_time = DateTime.Parse(ds.Tables[0].Rows[0]["express_time"].ToString());
                }
                model.accept_name = ds.Tables[0].Rows[0]["accept_name"].ToString();
                model.post_code = ds.Tables[0].Rows[0]["post_code"].ToString();
                model.telphone = ds.Tables[0].Rows[0]["telphone"].ToString();
                model.mobile = ds.Tables[0].Rows[0]["mobile"].ToString();
                model.area = ds.Tables[0].Rows[0]["area"].ToString();
                model.address = ds.Tables[0].Rows[0]["address"].ToString();
                model.message = ds.Tables[0].Rows[0]["message"].ToString();
                model.remark = ds.Tables[0].Rows[0]["remark"].ToString();
                if (ds.Tables[0].Rows[0]["payable_amount"].ToString() != "")
                {
                    model.payable_amount = decimal.Parse(ds.Tables[0].Rows[0]["payable_amount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["real_amount"].ToString() != "")
                {
                    model.real_amount = decimal.Parse(ds.Tables[0].Rows[0]["real_amount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["order_amount"].ToString() != "")
                {
                    model.order_amount = decimal.Parse(ds.Tables[0].Rows[0]["order_amount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["point"].ToString() != "")
                {
                    model.point = int.Parse(ds.Tables[0].Rows[0]["point"].ToString());
                }
                if (ds.Tables[0].Rows[0]["status"].ToString() != "")
                {
                    model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["confirm_time"].ToString() != "")
                {
                    model.confirm_time = DateTime.Parse(ds.Tables[0].Rows[0]["confirm_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["complete_time"].ToString() != "")
                {
                    model.complete_time = DateTime.Parse(ds.Tables[0].Rows[0]["complete_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_up"].ToString() != "")
                {
                    model.is_up = int.Parse(ds.Tables[0].Rows[0]["is_up"].ToString());
                }
                if (ds.Tables[0].Rows[0]["up_status"].ToString() != "")
                {
                    model.up_status = int.Parse(ds.Tables[0].Rows[0]["up_status"].ToString());
                }
                #endregion

                #region �ӱ���Ϣ
                StringBuilder strSql2 = new StringBuilder();
                strSql2.Append("select id,order_id,goods_id,goods_title,goods_price,real_price,quantity,point,standard,unit,unit_id,good_no from " + databaseprefix + "order_goods ");
                strSql2.Append(" where order_id=@id ");
                SqlParameter[] parameters2 = {
                        new SqlParameter("@id", SqlDbType.Int,4)};
                parameters2[0].Value = id;

                DataSet ds2 = DbHelperSQL.Query(strSql2.ToString(), parameters2);
                if (ds2.Tables[0].Rows.Count > 0)
                {
                    int i = ds2.Tables[0].Rows.Count;
                    List<Model.order_goods> models = new List<Model.order_goods>();
                    Model.order_goods modelt;
                    for (int n = 0; n < i; n++)
                    {
                        modelt = new Model.order_goods();
                        if (ds2.Tables[0].Rows[n]["id"] != null && ds2.Tables[0].Rows[n]["id"].ToString() != "")
                        {
                            modelt.id = int.Parse(ds2.Tables[0].Rows[n]["id"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["order_id"] != null && ds2.Tables[0].Rows[n]["order_id"].ToString() != "")
                        {
                            modelt.order_id = int.Parse(ds2.Tables[0].Rows[n]["order_id"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["goods_id"] != null && ds2.Tables[0].Rows[n]["goods_id"].ToString() != "")
                        {
                            modelt.goods_id = int.Parse(ds2.Tables[0].Rows[n]["goods_id"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["goods_title"] != null && ds2.Tables[0].Rows[n]["goods_title"].ToString() != "")
                        {
                            modelt.goods_title = ds2.Tables[0].Rows[n]["goods_title"].ToString();
                        }
                        if (ds2.Tables[0].Rows[n]["goods_price"] != null && ds2.Tables[0].Rows[n]["goods_price"].ToString() != "")
                        {
                            modelt.goods_price = decimal.Parse(ds2.Tables[0].Rows[n]["goods_price"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["real_price"] != null && ds2.Tables[0].Rows[n]["real_price"].ToString() != "")
                        {
                            modelt.real_price = decimal.Parse(ds2.Tables[0].Rows[n]["real_price"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["quantity"] != null && ds2.Tables[0].Rows[n]["quantity"].ToString() != "")
                        {
                            modelt.quantity = int.Parse(ds2.Tables[0].Rows[n]["quantity"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["point"] != null && ds2.Tables[0].Rows[n]["point"].ToString() != "")
                        {
                            modelt.point = int.Parse(ds2.Tables[0].Rows[n]["point"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["unit"] != null && ds2.Tables[0].Rows[n]["unit"].ToString() != "")
                        {
                            modelt.unit = ds2.Tables[0].Rows[n]["unit"].ToString();
                        }
                        if (ds2.Tables[0].Rows[n]["unit_id"] != null && ds2.Tables[0].Rows[n]["unit_id"].ToString() != "")
                        {
                            modelt.unit_id = decimal.Parse(ds2.Tables[0].Rows[n]["unit_id"].ToString());
                        }
                        modelt.standard = ds2.Tables[0].Rows[n]["standard"].ToString();
                        modelt.good_no = ds2.Tables[0].Rows[n]["good_no"].ToString();
                        models.Add(modelt);
                    }
                    model.order_goods = models;
                }
                #endregion

                return model;
            }
            else
            {
                return null;
            }
        }
Example #46
0
        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;
        }
Example #47
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/json";
            BLL.wx_shop_cart cartBll = new BLL.wx_shop_cart();
            string _action = MyCommFun.QueryString("myact");
            string openid = MyCommFun.RequestOpenid();  //得到微信用户的openid
            Dictionary<string, string> jsonDict = new Dictionary<string, string>();
            if (_action == "addCart")
            {
                #region 添加购物车
                try
                {
                    int wid = MyCommFun.RequestInt("wid");
                    int productId = MyCommFun.RequestInt("productid");
                    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

            }
        }
Example #48
0
        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);
                    }
                }
            }

        }
Example #49
0
 private void order_save(HttpContext context)
 {
     int payment_id = DTRequest.GetFormInt("payment_id");
     int distribution_id = DTRequest.GetFormInt("distribution_id");
     string accept_name = DTRequest.GetFormString("accept_name");
     string post_code = DTRequest.GetFormString("post_code");
     string telphone = DTRequest.GetFormString("telphone");
     string mobile = DTRequest.GetFormString("mobile");
     string address = DTRequest.GetFormString("address");
     string message = DTRequest.GetFormString("message");
     //检查配送方式
     if (distribution_id == 0)
     {
         context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,请选择配送方式!\"}");
         return;
     }
     Model.distribution disModel = new BLL.distribution().GetModel(distribution_id);
     if (disModel == null)
     {
         context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,您选择的配送方式不存在或已删除!\"}");
         return;
     }
     //检查支付方式
     if (payment_id == 0)
     {
         context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,请选择支付方式!\"}");
         return;
     }
     Model.payment payModel = new BLL.payment().GetModel(payment_id);
     if (payModel == null)
     {
         context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,您选择的支付方式不存在或已删除!\"}");
         return;
     }
     //检查收货人
     if (string.IsNullOrEmpty(accept_name))
     {
         context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,请输入收货人姓名!\"}");
         return;
     }
     //检查手机和电话
     if (string.IsNullOrEmpty(telphone) && string.IsNullOrEmpty(mobile))
     {
         context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,请输入收货人联系电话或手机!\"}");
         return;
     }
     //检查地址
     if (string.IsNullOrEmpty(address))
     {
         context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,请输入详细的收货地址!\"}");
         return;
     }
     //检查用户是否登录
     Model.users userModel = new BasePage().GetUserInfo();
     if (userModel == null)
     {
         context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,用户没有登录或登录超时啦!\"}");
         return;
     }
     //检查购物车商品
     IList<Model.cart_items> iList = DTcms.Web.UI.ShopCart.GetList(userModel.group_id);
     if (iList == null)
     {
         context.Response.Write("{\"msg\":0, \"msgbox\":\"对不起,购物车为空,无法结算!\"}");
         return;
     }
     //统计购物车
     Model.cart_total cartModel = DTcms.Web.UI.ShopCart.GetTotal(userModel.group_id);
     //保存订单=======================================================================
     Model.orders model = new Model.orders();
     model.order_no = Utils.GetOrderNumber(); //订单号
     model.user_id = userModel.id;
     model.user_name = userModel.user_name;
     model.payment_id = payment_id;
     model.distribution_id = distribution_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.payable_freight = disModel.amount; //应付运费
     model.real_freight = disModel.amount; //实付运费
     //如果是先款后货的话
     if (payModel.type == 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.real_freight + 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_name = 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("{\"msg\":0, \"msgbox\":\"订单保存过程中发生错误,请重新提交!\"}");
         return;
     }
     //扣除积分
     if (model.point < 0)
     {
         new BLL.point_log().Add(model.user_id, model.user_name, model.point, "积分换购,订单号:" + model.order_no);
     }
     //清空购物车
     DTcms.Web.UI.ShopCart.Clear("0");
     //提交成功,返回URL
     context.Response.Write("{\"msg\":1, \"url\":\"" + new Web.UI.BasePage().linkurl("payment1", "confirm", DTEnums.AmountTypeEnum.BuyGoods.ToString(), model.order_no) + "\", \"msgbox\":\"恭喜您,订单已成功提交!\"}");
     return;
 }
Example #50
0
        /// <summary>
        /// �õ�һ������ʵ���б�
        /// </summary>
        public IList<Model.orders> GetModelList(string sqlWhere)
        {
            IList<Model.orders> retlist = new List<Model.orders>();
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select   id,order_no,trade_no,user_id,user_name,payment_id,payment_fee,payment_status,payment_time,express_id,express_no,express_fee,express_status,express_time,accept_name,post_code,telphone,mobile,area,address,message,remark,payable_amount,real_amount,order_amount,point,status,add_time,confirm_time,complete_time,wid,openid,modelName,modelCode,modelActionName,modelActionId,orderSubject,city,district,notify_id,pay_info,isSubscribe,fahuoCode,fahuoMsg ");
            strSql.Append(" from " + databaseprefix + "orders ");
            if (sqlWhere.Trim() != "") {
                strSql.Append(" where "+sqlWhere);
            }

            Model.orders model = new Model.orders();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());
            DataSet ds2 = new DataSet();
            List<Model.wx_shop_product> models = new List<Model.wx_shop_product>();
            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow dr;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    model = new Model.orders();
                    dr = ds.Tables[0].Rows[i];
                    #region ������Ϣ
                    if (dr["id"].ToString() != "")
                    {
                        model.id = int.Parse(dr["id"].ToString());
                    }
                    model.order_no = dr["order_no"].ToString();
                    model.trade_no = dr["trade_no"].ToString();
                    if (dr["user_id"].ToString() != "")
                    {
                        model.user_id = int.Parse(dr["user_id"].ToString());
                    }
                    model.user_name = dr["user_name"].ToString();
                    if (dr["payment_id"].ToString() != "")
                    {
                        model.payment_id = int.Parse(dr["payment_id"].ToString());
                    }
                    if (dr["payment_fee"].ToString() != "")
                    {
                        model.payment_fee = decimal.Parse(dr["payment_fee"].ToString());
                    }
                    if (dr["payment_status"].ToString() != "")
                    {
                        model.payment_status = int.Parse(dr["payment_status"].ToString());
                    }
                    if (dr["payment_time"].ToString() != "")
                    {
                        model.payment_time = DateTime.Parse(dr["payment_time"].ToString());
                    }
                    if (dr["express_id"].ToString() != "")
                    {
                        model.express_id = int.Parse(dr["express_id"].ToString());
                    }
                    model.express_no = dr["express_no"].ToString();
                    if (dr["express_fee"].ToString() != "")
                    {
                        model.express_fee = decimal.Parse(dr["express_fee"].ToString());
                    }
                    if (dr["express_status"].ToString() != "")
                    {
                        model.express_status = int.Parse(dr["express_status"].ToString());
                    }
                    if (dr["express_time"].ToString() != "")
                    {
                        model.express_time = DateTime.Parse(dr["express_time"].ToString());
                    }
                    model.accept_name = dr["accept_name"].ToString();
                    model.post_code = dr["post_code"].ToString();
                    model.telphone = dr["telphone"].ToString();
                    model.mobile = dr["mobile"].ToString();
                    model.area = dr["area"].ToString();
                    model.address = dr["address"].ToString();
                    model.message = dr["message"].ToString();
                    model.remark = dr["remark"].ToString();
                    if (dr["payable_amount"].ToString() != "")
                    {
                        model.payable_amount = decimal.Parse(dr["payable_amount"].ToString());
                    }
                    if (dr["real_amount"].ToString() != "")
                    {
                        model.real_amount = decimal.Parse(dr["real_amount"].ToString());
                    }
                    if (dr["order_amount"].ToString() != "")
                    {
                        model.order_amount = decimal.Parse(dr["order_amount"].ToString());
                    }
                    if (dr["point"].ToString() != "")
                    {
                        model.point = int.Parse(dr["point"].ToString());
                    }
                    if (ds.Tables[0].Rows[0]["status"].ToString() != "")
                    {
                        model.status = int.Parse(dr["status"].ToString());
                    }
                    if (dr["add_time"].ToString() != "")
                    {
                        model.add_time = DateTime.Parse(dr["add_time"].ToString());
                    }
                    if (dr["confirm_time"].ToString() != "")
                    {
                        model.confirm_time = DateTime.Parse(dr["confirm_time"].ToString());
                    }
                    if (dr["complete_time"].ToString() != "")
                    {
                        model.complete_time = DateTime.Parse(dr["complete_time"].ToString());
                    }
                    if (dr["wid"] != null && dr["wid"].ToString() != "")
                    {
                        model.wid = int.Parse(dr["wid"].ToString());
                    }
                    if (dr["openid"] != null)
                    {
                        model.openid = dr["openid"].ToString();
                    }
                    if (ds.Tables[0].Rows[0]["modelName"] != null)
                    {
                        model.modelName = ds.Tables[0].Rows[0]["modelName"].ToString();
                    }
                    if (ds.Tables[0].Rows[0]["modelCode"] != null)
                    {
                        model.modelCode = ds.Tables[0].Rows[0]["modelCode"].ToString();
                    }
                    if (ds.Tables[0].Rows[0]["modelActionName"] != null)
                    {
                        model.modelActionName = ds.Tables[0].Rows[0]["modelActionName"].ToString();
                    }
                    if (ds.Tables[0].Rows[0]["modelActionId"] != null && ds.Tables[0].Rows[0]["modelActionId"].ToString() != "")
                    {
                        model.modelActionId = int.Parse(ds.Tables[0].Rows[0]["modelActionId"].ToString());
                    }
                    if (ds.Tables[0].Rows[0]["orderSubject"] != null)
                    {
                        model.orderSubject = ds.Tables[0].Rows[0]["orderSubject"].ToString();
                    }
                    if (ds.Tables[0].Rows[0]["city"] != null)
                    {
                        model.city = ds.Tables[0].Rows[0]["city"].ToString();
                    }
                    if (ds.Tables[0].Rows[0]["district"] != null)
                    {
                        model.district = ds.Tables[0].Rows[0]["district"].ToString();
                    }
                    if (ds.Tables[0].Rows[0]["notify_id"] != null)
                    {
                        model.notify_id = ds.Tables[0].Rows[0]["notify_id"].ToString();
                    }
                    if (ds.Tables[0].Rows[0]["pay_info"] != null)
                    {
                        model.pay_info = ds.Tables[0].Rows[0]["pay_info"].ToString();
                    }
                    if (ds.Tables[0].Rows[0]["isSubscribe"] != null && ds.Tables[0].Rows[0]["isSubscribe"].ToString() != "")
                    {
                        if ((ds.Tables[0].Rows[0]["isSubscribe"].ToString() == "1") || (ds.Tables[0].Rows[0]["isSubscribe"].ToString().ToLower() == "true"))
                        {
                            model.isSubscribe = true;
                        }
                        else
                        {
                            model.isSubscribe = false;
                        }
                    }
                    if (ds.Tables[0].Rows[0]["fahuoCode"] != null)
                    {
                        model.fahuoCode = ds.Tables[0].Rows[0]["fahuoCode"].ToString();
                    }
                    if (ds.Tables[0].Rows[0]["fahuoMsg"] != null)
                    {
                        model.fahuoMsg = ds.Tables[0].Rows[0]["fahuoMsg"].ToString();
                    }

                    #endregion

                    #region �ӱ���Ϣ
                    StringBuilder strSql2 = new StringBuilder();
                    strSql2.Append("select  (select top 1 original_path from  wx_shop_albums where  productId=p.id) as productpic,p.*,og.quantity,og.real_price from wx_shop_product p right join  dt_order_goods og on p.id=og.goods_id where og.order_id=@id");

                    SqlParameter[] parameters2 = {
                        new SqlParameter("@id", SqlDbType.Int,4)};
                    parameters2[0].Value = model.id;

                    ds2 = DbHelperSQL.Query(strSql2.ToString(), parameters2);
                    if (ds2.Tables[0].Rows.Count > 0)
                    {
                        int count = ds2.Tables[0].Rows.Count;
                        models = new List<Model.wx_shop_product>();
                        Model.wx_shop_product modelt;
                        for (int n = 0; n < count; n++)
                        {
                            modelt = new Model.wx_shop_product();
                            #region �ӱ��forѭ��

                            if (ds2.Tables[0].Rows[n]["id"] != null && ds2.Tables[0].Rows[n]["id"].ToString() != "")
                            {
                                modelt.id = int.Parse(ds2.Tables[0].Rows[n]["id"].ToString());
                            }

                            if (ds2.Tables[0].Rows[n]["quantity"] != null && ds2.Tables[0].Rows[n]["quantity"].ToString() != "")
                            {
                                modelt.stock = int.Parse(ds2.Tables[0].Rows[n]["quantity"].ToString());
                            }

                            if (ds2.Tables[0].Rows[n]["wid"] != null && ds2.Tables[0].Rows[n]["wid"].ToString() != "")
                            {
                                modelt.wid = int.Parse(ds2.Tables[0].Rows[n]["wid"].ToString());
                            }
                            if (ds2.Tables[0].Rows[n]["categoryId"] != null && ds2.Tables[0].Rows[n]["categoryId"].ToString() != "")
                            {
                                modelt.categoryId = int.Parse(ds2.Tables[0].Rows[n]["categoryId"].ToString());
                            }
                            if (ds2.Tables[0].Rows[n]["brandId"] != null && ds2.Tables[0].Rows[n]["brandId"].ToString() != "")
                            {
                                modelt.brandId = int.Parse(ds2.Tables[0].Rows[n]["brandId"].ToString());
                            }
                            if (ds2.Tables[0].Rows[n]["sku"] != null)
                            {
                                modelt.sku = ds2.Tables[0].Rows[n]["sku"].ToString();
                            }
                            if (ds2.Tables[0].Rows[n]["productName"] != null)
                            {
                                modelt.productName = ds2.Tables[0].Rows[n]["productName"].ToString();
                            }
                            if (ds2.Tables[0].Rows[n]["shortDesc"] != null)
                            {
                                modelt.shortDesc = ds2.Tables[0].Rows[n]["shortDesc"].ToString();
                            }
                            if (ds2.Tables[0].Rows[n]["unit"] != null)
                            {
                                modelt.unit = ds2.Tables[0].Rows[n]["unit"].ToString();
                            }
                            if (ds2.Tables[0].Rows[n]["weight"] != null && ds2.Tables[0].Rows[n]["weight"].ToString() != "")
                            {
                                modelt.weight = decimal.Parse(ds2.Tables[0].Rows[n]["weight"].ToString());
                            }
                            if (ds2.Tables[0].Rows[n]["description"] != null)
                            {
                                modelt.description = ds2.Tables[0].Rows[n]["description"].ToString();
                            }
                            if (ds2.Tables[0].Rows[n]["seo_title"] != null)
                            {
                                modelt.seo_title = ds2.Tables[0].Rows[n]["seo_title"].ToString();
                            }
                            if (ds2.Tables[0].Rows[n]["seo_keywords"] != null)
                            {
                                modelt.seo_keywords = ds2.Tables[0].Rows[n]["seo_keywords"].ToString();
                            }
                            if (ds2.Tables[0].Rows[n]["seo_description"] != null)
                            {
                                modelt.seo_description = ds2.Tables[0].Rows[n]["seo_description"].ToString();
                            }
                            if (ds2.Tables[0].Rows[n]["focusImgUrl"] != null)
                            {
                                modelt.focusImgUrl = ds2.Tables[0].Rows[n]["productpic"].ToString();
                            }
                            if (ds2.Tables[0].Rows[n]["thumbnailsUrll"] != null)
                            {
                                modelt.thumbnailsUrll = ds2.Tables[0].Rows[n]["thumbnailsUrll"].ToString();
                            }
                            if (ds2.Tables[0].Rows[n]["recommended"] != null && ds2.Tables[0].Rows[n]["recommended"].ToString() != "")
                            {
                                if ((ds2.Tables[0].Rows[n]["recommended"].ToString() == "1") || (ds2.Tables[0].Rows[n]["recommended"].ToString().ToLower() == "true"))
                                {
                                    modelt.recommended = true;
                                }
                                else
                                {
                                    modelt.recommended = false;
                                }
                            }
                            if (ds2.Tables[0].Rows[n]["latest"] != null && ds2.Tables[0].Rows[n]["latest"].ToString() != "")
                            {
                                if ((ds2.Tables[0].Rows[n]["latest"].ToString() == "1") || (ds2.Tables[0].Rows[n]["latest"].ToString().ToLower() == "true"))
                                {
                                    modelt.latest = true;
                                }
                                else
                                {
                                    modelt.latest = false;
                                }
                            }
                            if (ds2.Tables[0].Rows[n]["hotsale"] != null && ds2.Tables[0].Rows[n]["hotsale"].ToString() != "")
                            {
                                if ((ds2.Tables[0].Rows[n]["hotsale"].ToString() == "1") || (ds2.Tables[0].Rows[n]["hotsale"].ToString().ToLower() == "true"))
                                {
                                    modelt.hotsale = true;
                                }
                                else
                                {
                                    modelt.hotsale = false;
                                }
                            }
                            if (ds2.Tables[0].Rows[n]["specialOffer"] != null && ds2.Tables[0].Rows[n]["specialOffer"].ToString() != "")
                            {
                                if ((ds2.Tables[0].Rows[n]["specialOffer"].ToString() == "1") || (ds2.Tables[0].Rows[n]["specialOffer"].ToString().ToLower() == "true"))
                                {
                                    modelt.specialOffer = true;
                                }
                                else
                                {
                                    modelt.specialOffer = false;
                                }
                            }
                            if (ds2.Tables[0].Rows[n]["costPrice"] != null && ds2.Tables[0].Rows[n]["costPrice"].ToString() != "")
                            {
                                modelt.costPrice = decimal.Parse(ds2.Tables[0].Rows[n]["costPrice"].ToString());
                            }
                            if (ds2.Tables[0].Rows[n]["marketPrice"] != null && ds2.Tables[0].Rows[n]["marketPrice"].ToString() != "")
                            {
                                modelt.marketPrice = decimal.Parse(ds2.Tables[0].Rows[n]["marketPrice"].ToString());
                            }
                            if (ds2.Tables[0].Rows[n]["salePrice"] != null && ds2.Tables[0].Rows[n]["salePrice"].ToString() != "")
                            {
                                modelt.salePrice = decimal.Parse(ds2.Tables[0].Rows[n]["salePrice"].ToString());
                            }
                            if (ds2.Tables[0].Rows[n]["upselling"] != null && ds2.Tables[0].Rows[n]["upselling"].ToString() != "")
                            {
                                if ((ds2.Tables[0].Rows[n]["upselling"].ToString() == "1") || (ds2.Tables[0].Rows[n]["upselling"].ToString().ToLower() == "true"))
                                {
                                    modelt.upselling = true;
                                }
                                else
                                {
                                    modelt.upselling = false;
                                }
                            }

                            if (ds2.Tables[0].Rows[n]["addDate"] != null && ds2.Tables[0].Rows[n]["addDate"].ToString() != "")
                            {
                                modelt.addDate = DateTime.Parse(ds2.Tables[0].Rows[n]["addDate"].ToString());
                            }
                            if (ds2.Tables[0].Rows[n]["vistiCounts"] != null && ds2.Tables[0].Rows[n]["vistiCounts"].ToString() != "")
                            {
                                modelt.vistiCounts = int.Parse(ds2.Tables[0].Rows[n]["vistiCounts"].ToString());
                            }
                            if (ds2.Tables[0].Rows[n]["sort_id"] != null && ds2.Tables[0].Rows[n]["sort_id"].ToString() != "")
                            {
                                modelt.sort_id = int.Parse(ds2.Tables[0].Rows[n]["sort_id"].ToString());
                            }
                            if (ds2.Tables[0].Rows[n]["productionDate"] != null && ds2.Tables[0].Rows[n]["productionDate"].ToString() != "")
                            {
                                modelt.productionDate = DateTime.Parse(ds2.Tables[0].Rows[n]["productionDate"].ToString());
                            }
                            if (ds2.Tables[0].Rows[n]["ExpiryEndDate"] != null && ds2.Tables[0].Rows[n]["ExpiryEndDate"].ToString() != "")
                            {
                                modelt.ExpiryEndDate = DateTime.Parse(ds2.Tables[0].Rows[n]["ExpiryEndDate"].ToString());
                            }
                            if (ds2.Tables[0].Rows[n]["updateDate"] != null && ds2.Tables[0].Rows[n]["updateDate"].ToString() != "")
                            {
                                modelt.updateDate = DateTime.Parse(ds2.Tables[0].Rows[n]["updateDate"].ToString());
                            }

                            if (ds2.Tables[0].Rows[n]["catalogId"] != null && ds2.Tables[0].Rows[n]["catalogId"].ToString() != "")
                            {
                                modelt.catalogId = int.Parse(ds2.Tables[0].Rows[n]["catalogId"].ToString());
                            }

                            #endregion
                            models.Add(modelt);

                        }
                        model.order_product = models;
                    }
                    #endregion
                    retlist.Add(model);
                }

                return retlist;
            }
            else
            {
                return null;
            }
        }
Example #51
0
        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;
        }
Example #52
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public Model.orders GetModel(int id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 id,order_no,user_id,user_name,payment_id,distribution_id,status,payment_status,distribution_status,delivery_name,delivery_no,accept_name,post_code,telphone,mobile,address,message,payable_amount,real_amount,payable_freight,real_freight,payment_fee,order_amount,point,add_time,payment_time,confirm_time,distribution_time,complete_time from dt_orders ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;

            Model.orders model=new Model.orders();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                #region  ������Ϣ
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["order_no"] != null && ds.Tables[0].Rows[0]["order_no"].ToString() != "")
                {
                    model.order_no = ds.Tables[0].Rows[0]["order_no"].ToString();
                }
                if (ds.Tables[0].Rows[0]["user_id"] != null && ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["user_name"] != null && ds.Tables[0].Rows[0]["user_name"].ToString() != "")
                {
                    model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["payment_id"] != null && ds.Tables[0].Rows[0]["payment_id"].ToString() != "")
                {
                    model.payment_id = int.Parse(ds.Tables[0].Rows[0]["payment_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["distribution_id"] != null && ds.Tables[0].Rows[0]["distribution_id"].ToString() != "")
                {
                    model.distribution_id = int.Parse(ds.Tables[0].Rows[0]["distribution_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["status"] != null && ds.Tables[0].Rows[0]["status"].ToString() != "")
                {
                    model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["payment_status"] != null && ds.Tables[0].Rows[0]["payment_status"].ToString() != "")
                {
                    model.payment_status = int.Parse(ds.Tables[0].Rows[0]["payment_status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["distribution_status"] != null && ds.Tables[0].Rows[0]["distribution_status"].ToString() != "")
                {
                    model.distribution_status = int.Parse(ds.Tables[0].Rows[0]["distribution_status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["delivery_name"] != null && ds.Tables[0].Rows[0]["delivery_name"].ToString() != "")
                {
                    model.delivery_name = ds.Tables[0].Rows[0]["delivery_name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["delivery_no"] != null && ds.Tables[0].Rows[0]["delivery_no"].ToString() != "")
                {
                    model.delivery_no = ds.Tables[0].Rows[0]["delivery_no"].ToString();
                }
                if (ds.Tables[0].Rows[0]["accept_name"] != null && ds.Tables[0].Rows[0]["accept_name"].ToString() != "")
                {
                    model.accept_name = ds.Tables[0].Rows[0]["accept_name"].ToString();
                }
                if (ds.Tables[0].Rows[0]["post_code"] != null && ds.Tables[0].Rows[0]["post_code"].ToString() != "")
                {
                    model.post_code = ds.Tables[0].Rows[0]["post_code"].ToString();
                }
                if (ds.Tables[0].Rows[0]["telphone"] != null && ds.Tables[0].Rows[0]["telphone"].ToString() != "")
                {
                    model.telphone = ds.Tables[0].Rows[0]["telphone"].ToString();
                }
                if (ds.Tables[0].Rows[0]["mobile"] != null && ds.Tables[0].Rows[0]["mobile"].ToString() != "")
                {
                    model.mobile = ds.Tables[0].Rows[0]["mobile"].ToString();
                }
                if (ds.Tables[0].Rows[0]["address"] != null && ds.Tables[0].Rows[0]["address"].ToString() != "")
                {
                    model.address = ds.Tables[0].Rows[0]["address"].ToString();
                }
                if (ds.Tables[0].Rows[0]["message"] != null && ds.Tables[0].Rows[0]["message"].ToString() != "")
                {
                    model.message = ds.Tables[0].Rows[0]["message"].ToString();
                }
                if (ds.Tables[0].Rows[0]["payable_amount"] != null && ds.Tables[0].Rows[0]["payable_amount"].ToString() != "")
                {
                    model.payable_amount = decimal.Parse(ds.Tables[0].Rows[0]["payable_amount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["real_amount"] != null && ds.Tables[0].Rows[0]["real_amount"].ToString() != "")
                {
                    model.real_amount = decimal.Parse(ds.Tables[0].Rows[0]["real_amount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["payable_freight"] != null && ds.Tables[0].Rows[0]["payable_freight"].ToString() != "")
                {
                    model.payable_freight = decimal.Parse(ds.Tables[0].Rows[0]["payable_freight"].ToString());
                }
                if (ds.Tables[0].Rows[0]["real_freight"] != null && ds.Tables[0].Rows[0]["real_freight"].ToString() != "")
                {
                    model.real_freight = decimal.Parse(ds.Tables[0].Rows[0]["real_freight"].ToString());
                }
                if (ds.Tables[0].Rows[0]["payment_fee"] != null && ds.Tables[0].Rows[0]["payment_fee"].ToString() != "")
                {
                    model.payment_fee = decimal.Parse(ds.Tables[0].Rows[0]["payment_fee"].ToString());
                }
                if (ds.Tables[0].Rows[0]["order_amount"] != null && ds.Tables[0].Rows[0]["order_amount"].ToString() != "")
                {
                    model.order_amount = decimal.Parse(ds.Tables[0].Rows[0]["order_amount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["point"] != null && ds.Tables[0].Rows[0]["point"].ToString() != "")
                {
                    model.point = int.Parse(ds.Tables[0].Rows[0]["point"].ToString());
                }
                if (ds.Tables[0].Rows[0]["add_time"] != null && ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["payment_time"] != null && ds.Tables[0].Rows[0]["payment_time"].ToString() != "")
                {
                    model.payment_time = DateTime.Parse(ds.Tables[0].Rows[0]["payment_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["confirm_time"] != null && ds.Tables[0].Rows[0]["confirm_time"].ToString() != "")
                {
                    model.confirm_time = DateTime.Parse(ds.Tables[0].Rows[0]["confirm_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["distribution_time"] != null && ds.Tables[0].Rows[0]["distribution_time"].ToString() != "")
                {
                    model.distribution_time = DateTime.Parse(ds.Tables[0].Rows[0]["distribution_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["complete_time"] != null && ds.Tables[0].Rows[0]["complete_time"].ToString() != "")
                {
                    model.complete_time = DateTime.Parse(ds.Tables[0].Rows[0]["complete_time"].ToString());
                }
                #endregion  ������Ϣend

                #region  �ӱ���Ϣ
                StringBuilder strSql2=new StringBuilder();
                strSql2.Append("select id,order_id,goods_id,goods_name,goods_price,real_price,quantity,point from dt_order_goods ");
                strSql2.Append(" where order_id=@id ");
                SqlParameter[] parameters2 = {
                        new SqlParameter("@id", SqlDbType.Int,4)};
                parameters2[0].Value = id;

                DataSet ds2=DbHelperSQL.Query(strSql2.ToString(),parameters2);
                if(ds2.Tables[0].Rows.Count>0)
                {
                    #region  �ӱ��ֶ���Ϣ
                    int i = ds2.Tables[0].Rows.Count;
                    List<Model.order_goods> models = new List<Model.order_goods>();
                    Model.order_goods modelt;
                    for (int n = 0; n < i; n++)
                    {
                        modelt = new Model.order_goods();
                        if(ds2.Tables[0].Rows[n]["id"]!=null && ds2.Tables[0].Rows[n]["id"].ToString()!="")
                        {
                            modelt.id=int.Parse(ds2.Tables[0].Rows[n]["id"].ToString());
                        }
                        if(ds2.Tables[0].Rows[n]["order_id"]!=null && ds2.Tables[0].Rows[n]["order_id"].ToString()!="")
                        {
                            modelt.order_id=int.Parse(ds2.Tables[0].Rows[n]["order_id"].ToString());
                        }
                        if(ds2.Tables[0].Rows[n]["goods_id"]!=null && ds2.Tables[0].Rows[n]["goods_id"].ToString()!="")
                        {
                            modelt.goods_id=int.Parse(ds2.Tables[0].Rows[n]["goods_id"].ToString());
                        }
                        if(ds2.Tables[0].Rows[n]["goods_name"]!=null && ds2.Tables[0].Rows[n]["goods_name"].ToString()!="")
                        {
                            modelt.goods_name=ds2.Tables[0].Rows[n]["goods_name"].ToString();
                        }
                        if(ds2.Tables[0].Rows[n]["goods_price"]!=null && ds2.Tables[0].Rows[n]["goods_price"].ToString()!="")
                        {
                            modelt.goods_price=decimal.Parse(ds2.Tables[0].Rows[n]["goods_price"].ToString());
                        }
                        if(ds2.Tables[0].Rows[n]["real_price"]!=null && ds2.Tables[0].Rows[n]["real_price"].ToString()!="")
                        {
                            modelt.real_price=decimal.Parse(ds2.Tables[0].Rows[n]["real_price"].ToString());
                        }
                        if(ds2.Tables[0].Rows[n]["quantity"]!=null && ds2.Tables[0].Rows[n]["quantity"].ToString()!="")
                        {
                            modelt.quantity=int.Parse(ds2.Tables[0].Rows[n]["quantity"].ToString());
                        }
                        if(ds2.Tables[0].Rows[n]["point"]!=null && ds2.Tables[0].Rows[n]["point"].ToString()!="")
                        {
                            modelt.point=int.Parse(ds2.Tables[0].Rows[n]["point"].ToString());
                        }
                        models.Add(modelt);
                    }
                    model.order_goods = models;
                    #endregion  �ӱ��ֶ���Ϣend
                }
                #endregion  �ӱ���Ϣend

                return model;
            }
            else
            {
                return null;
            }
        }
Example #53
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public Model.orders GetModel(int id,int wid)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,order_no,trade_no,user_id,user_name,payment_id,payment_fee,payment_status,payment_time,express_id,express_no,express_fee,express_status,express_time,accept_name,post_code,telphone,mobile,area,address,message,remark,payable_amount,real_amount,order_amount,point,status,add_time,confirm_time,complete_time,wid,openid,modelName,modelCode,modelActionName,modelActionId,orderSubject,city,district,notify_id,pay_info,isSubscribe,fahuoCode,fahuoMsg ");
            strSql.Append(" from " + databaseprefix + "orders ");
            strSql.Append(" where id=@id and wid=@wid");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4),
                    new SqlParameter("@wid", SqlDbType.Int,4)};
            parameters[0].Value = id;
            parameters[1].Value = wid;
            Model.orders model = new Model.orders();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                #region ������Ϣ
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                model.order_no = ds.Tables[0].Rows[0]["order_no"].ToString();
                model.trade_no = ds.Tables[0].Rows[0]["trade_no"].ToString();
                if (ds.Tables[0].Rows[0]["user_id"].ToString() != "")
                {
                    model.user_id = int.Parse(ds.Tables[0].Rows[0]["user_id"].ToString());
                }
                model.user_name = ds.Tables[0].Rows[0]["user_name"].ToString();
                if (ds.Tables[0].Rows[0]["payment_id"].ToString() != "")
                {
                    model.payment_id = int.Parse(ds.Tables[0].Rows[0]["payment_id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["payment_fee"].ToString() != "")
                {
                    model.payment_fee = decimal.Parse(ds.Tables[0].Rows[0]["payment_fee"].ToString());
                }
                if (ds.Tables[0].Rows[0]["payment_status"].ToString() != "")
                {
                    model.payment_status = int.Parse(ds.Tables[0].Rows[0]["payment_status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["payment_time"].ToString() != "")
                {
                    model.payment_time = DateTime.Parse(ds.Tables[0].Rows[0]["payment_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["express_id"].ToString() != "")
                {
                    model.express_id = int.Parse(ds.Tables[0].Rows[0]["express_id"].ToString());
                }
                model.express_no = ds.Tables[0].Rows[0]["express_no"].ToString();
                if (ds.Tables[0].Rows[0]["express_fee"].ToString() != "")
                {
                    model.express_fee = decimal.Parse(ds.Tables[0].Rows[0]["express_fee"].ToString());
                }
                if (ds.Tables[0].Rows[0]["express_status"].ToString() != "")
                {
                    model.express_status = int.Parse(ds.Tables[0].Rows[0]["express_status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["express_time"].ToString() != "")
                {
                    model.express_time = DateTime.Parse(ds.Tables[0].Rows[0]["express_time"].ToString());
                }
                model.accept_name = ds.Tables[0].Rows[0]["accept_name"].ToString();
                model.post_code = ds.Tables[0].Rows[0]["post_code"].ToString();
                model.telphone = ds.Tables[0].Rows[0]["telphone"].ToString();
                model.mobile = ds.Tables[0].Rows[0]["mobile"].ToString();
                model.area = ds.Tables[0].Rows[0]["area"].ToString();
                model.address = ds.Tables[0].Rows[0]["address"].ToString();
                model.message = ds.Tables[0].Rows[0]["message"].ToString();
                model.remark = ds.Tables[0].Rows[0]["remark"].ToString();
                if (ds.Tables[0].Rows[0]["payable_amount"].ToString() != "")
                {
                    model.payable_amount = decimal.Parse(ds.Tables[0].Rows[0]["payable_amount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["real_amount"].ToString() != "")
                {
                    model.real_amount = decimal.Parse(ds.Tables[0].Rows[0]["real_amount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["order_amount"].ToString() != "")
                {
                    model.order_amount = decimal.Parse(ds.Tables[0].Rows[0]["order_amount"].ToString());
                }
                if (ds.Tables[0].Rows[0]["point"].ToString() != "")
                {
                    model.point = int.Parse(ds.Tables[0].Rows[0]["point"].ToString());
                }
                if (ds.Tables[0].Rows[0]["status"].ToString() != "")
                {
                    model.status = int.Parse(ds.Tables[0].Rows[0]["status"].ToString());
                }
                if (ds.Tables[0].Rows[0]["add_time"].ToString() != "")
                {
                    model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["confirm_time"].ToString() != "")
                {
                    model.confirm_time = DateTime.Parse(ds.Tables[0].Rows[0]["confirm_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["complete_time"].ToString() != "")
                {
                    model.complete_time = DateTime.Parse(ds.Tables[0].Rows[0]["complete_time"].ToString());
                }
                if (ds.Tables[0].Rows[0]["wid"] != null && ds.Tables[0].Rows[0]["wid"].ToString() != "")
                {
                    model.wid = int.Parse(ds.Tables[0].Rows[0]["wid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["openid"] != null)
                {
                    model.openid = ds.Tables[0].Rows[0]["openid"].ToString();
                }
                if (ds.Tables[0].Rows[0]["modelName"] != null)
                {
                    model.modelName = ds.Tables[0].Rows[0]["modelName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["modelCode"] != null)
                {
                    model.modelCode = ds.Tables[0].Rows[0]["modelCode"].ToString();
                }
                if (ds.Tables[0].Rows[0]["modelActionName"] != null)
                {
                    model.modelActionName = ds.Tables[0].Rows[0]["modelActionName"].ToString();
                }
                if (ds.Tables[0].Rows[0]["modelActionId"] != null && ds.Tables[0].Rows[0]["modelActionId"].ToString() != "")
                {
                    model.modelActionId = int.Parse(ds.Tables[0].Rows[0]["modelActionId"].ToString());
                }
                if (ds.Tables[0].Rows[0]["orderSubject"] != null)
                {
                    model.orderSubject = ds.Tables[0].Rows[0]["orderSubject"].ToString();
                }
                if (ds.Tables[0].Rows[0]["city"] != null)
                {
                    model.city = ds.Tables[0].Rows[0]["city"].ToString();
                }
                if (ds.Tables[0].Rows[0]["district"] != null)
                {
                    model.district = ds.Tables[0].Rows[0]["district"].ToString();
                }
                if (ds.Tables[0].Rows[0]["notify_id"] != null)
                {
                    model.notify_id = ds.Tables[0].Rows[0]["notify_id"].ToString();
                }
                if (ds.Tables[0].Rows[0]["pay_info"] != null)
                {
                    model.pay_info = ds.Tables[0].Rows[0]["pay_info"].ToString();
                }
                if (ds.Tables[0].Rows[0]["isSubscribe"] != null && ds.Tables[0].Rows[0]["isSubscribe"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["isSubscribe"].ToString() == "1") || (ds.Tables[0].Rows[0]["isSubscribe"].ToString().ToLower() == "true"))
                    {
                        model.isSubscribe = true;
                    }
                    else
                    {
                        model.isSubscribe = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["fahuoCode"] != null)
                {
                    model.fahuoCode = ds.Tables[0].Rows[0]["fahuoCode"].ToString();
                }
                if (ds.Tables[0].Rows[0]["fahuoMsg"] != null)
                {
                    model.fahuoMsg = ds.Tables[0].Rows[0]["fahuoMsg"].ToString();
                }

                #endregion

                #region �ӱ���Ϣ
                StringBuilder strSql2 = new StringBuilder();
                strSql2.Append("select id,order_id,goods_id,goods_title,goods_price,real_price,quantity,point from " + databaseprefix + "order_goods ");
                strSql2.Append(" where order_id=@id ");
                SqlParameter[] parameters2 = {
                        new SqlParameter("@id", SqlDbType.Int,4)};
                parameters2[0].Value = id;

                DataSet ds2 = DbHelperSQL.Query(strSql2.ToString(), parameters2);
                if (ds2.Tables[0].Rows.Count > 0)
                {
                    int i = ds2.Tables[0].Rows.Count;
                    List<Model.order_goods> models = new List<Model.order_goods>();
                    Model.order_goods modelt;
                    for (int n = 0; n < i; n++)
                    {
                        modelt = new Model.order_goods();
                        if (ds2.Tables[0].Rows[n]["id"] != null && ds2.Tables[0].Rows[n]["id"].ToString() != "")
                        {
                            modelt.id = int.Parse(ds2.Tables[0].Rows[n]["id"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["order_id"] != null && ds2.Tables[0].Rows[n]["order_id"].ToString() != "")
                        {
                            modelt.order_id = int.Parse(ds2.Tables[0].Rows[n]["order_id"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["goods_id"] != null && ds2.Tables[0].Rows[n]["goods_id"].ToString() != "")
                        {
                            modelt.goods_id = int.Parse(ds2.Tables[0].Rows[n]["goods_id"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["goods_title"] != null && ds2.Tables[0].Rows[n]["goods_title"].ToString() != "")
                        {
                            modelt.goods_title = ds2.Tables[0].Rows[n]["goods_title"].ToString();
                        }
                        if (ds2.Tables[0].Rows[n]["goods_price"] != null && ds2.Tables[0].Rows[n]["goods_price"].ToString() != "")
                        {
                            modelt.goods_price = decimal.Parse(ds2.Tables[0].Rows[n]["goods_price"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["real_price"] != null && ds2.Tables[0].Rows[n]["real_price"].ToString() != "")
                        {
                            modelt.real_price = decimal.Parse(ds2.Tables[0].Rows[n]["real_price"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["quantity"] != null && ds2.Tables[0].Rows[n]["quantity"].ToString() != "")
                        {
                            modelt.quantity = int.Parse(ds2.Tables[0].Rows[n]["quantity"].ToString());
                        }
                        if (ds2.Tables[0].Rows[n]["point"] != null && ds2.Tables[0].Rows[n]["point"].ToString() != "")
                        {
                            modelt.point = int.Parse(ds2.Tables[0].Rows[n]["point"].ToString());
                        }
                        models.Add(modelt);
                    }
                    model.order_goods = models;
                }
                #endregion

                return model;
            }
            else
            {
                return null;
            }
        }