Ejemplo n.º 1
0
        public static DataTable Report_SelByDay(Sale_Filter filter)
        {
            DateTime    STime    = Convert.ToDateTime(filter.stime);
            DateTime    ETime    = Convert.ToDateTime(filter.etime);
            B_OrderList orderBll = new B_OrderList();
            DataTable   saleDT   = orderBll.Report_SelByDate(STime, ETime);
            DataTable   dayDT    = new DataTable();

            dayDT.Columns.Add("date", typeof(string));
            dayDT.Columns.Add("total", typeof(double));
            for (DateTime s = STime; s <= ETime; s = s.AddDays(1))
            {
                DataRow day = dayDT.NewRow();
                //DateTime sdate = Convert.ToDateTime("{0}/{1}/{2} 00:00:00");
                string sdate = s.ToString("#yyyy/MM/dd 00:00:00#"), edate = s.ToString("#yyyy/MM/dd 23:59:59#");
                saleDT.DefaultView.RowFilter = "PayTime>= " + sdate + " AND PayTime<= " + edate;
                day["date"]  = s.ToString("yyyy-MM-dd");
                day["total"] = 0;
                foreach (DataRow dr in saleDT.DefaultView.ToTable().Rows)
                {
                    day["Total"] = DataConvert.CDouble(day["Total"]) + DataConvert.CDouble(dr["OrdersAmount"]);
                }
                dayDT.Rows.Add(day);
            }
            return(dayDT);
        }
Ejemplo n.º 2
0
        public static List <M_OrderList> OrdersCheck(M_Payment payMod)
        {
            B_OrderList val = new B_OrderList();

            if (payMod.Status != 1)
            {
                function.WriteErrMsg("Incorrect order payment condition");
                return(null);
            }
            if (payMod.IsDel == 1)
            {
                function.WriteErrMsg("The order has been deleted");
                return(null);
            }
            string[]           array = payMod.PaymentNum.Split(',');
            List <M_OrderList> list  = new List <M_OrderList>();

            for (int i = 0; i < array.Length; i++)
            {
                M_OrderList val2 = val.SelModelByOrderNo(array[i]);
                SnsHelper.CheckIsCanPay(val2);
                list.Add(val2);
            }
            return(list);
        }
Ejemplo n.º 3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //StringWriter sw = new StringWriter();
        //Server.Execute("/Common/MailTlp/Order_Payed.aspx?ID=79", sw);
        //Response.Write(sw.ToString());


        //EventDeal.SendOrderEmailByType(1144, "order");
        //throw new Exception("Email has send");
        B_Admin.CheckIsLogged(Request.RawUrl);
        int             oid      = 1144;
        M_Order_Contact conMod   = new B_Order_Contact().SelModelByOid(oid);
        M_OrderList     orderMod = new B_OrderList().SelReturnModel(oid);
        StringWriter    sw       = new StringWriter();

        HttpContext.Current.Server.Execute("/Common/MailTlp/Order_Payed.aspx?ID=" + oid, sw);
        string title2 = "We received your order!";
        string html2  = sw.ToString();

        //throw new Exception(conMod.Email);
        SendMail.MailState state = SendMail.MailState.None;
        string             exmsg = "";

        try
        {
            state = SendEmailFunc(conMod.Email, title2, html2, "");
        }
        catch (Exception ex) { exmsg = ex.Message; }
        //conMod.Email = "*****@*****.**";
        //conMod.Email = "*****@*****.**";
        //conMod.Email = "*****@*****.**";
        var cfg = SiteConfig.MailConfig;

        throw new Exception(conMod.Email + exmsg);
    }
Ejemplo n.º 4
0
    public void CreateOrder(M_FastOrder model)
    {
        M_UserInfo  mu    = buser.GetLogin(false);
        M_OrderList Odata = new M_OrderList();

        Odata.Ordertype       = 10;
        Odata.OrderNo         = B_OrderList.CreateOrderNo((M_OrderList.OrderEnum)Odata.Ordertype);
        Odata.StoreID         = 0;
        Odata.Rename          = mu.UserName;
        Odata.Outstock        = 0;  //缺货处理
        Odata.Ordermessage    = model.Proinfo;
        Odata.Merchandiser    = ""; //跟单员
        Odata.Internalrecords = ""; //内部记录
        Odata.IsCount         = false;
        //-----金额计算
        Odata.Balance_price     = model.Price;
        Odata.Freight           = 0;                                   //运费计算
        Odata.Ordersamount      = Odata.Balance_price + Odata.Freight; //订单金额
        Odata.AllMoney_Json     = "";
        Odata.Specifiedprice    = Odata.Ordersamount;                  //订单金额;
        Odata.Receivablesamount = 0;                                   //收款金额
        Odata.Developedvotes    = 0;
        Odata.OrderStatus       = 0;                                   //订单状态
        Odata.Paymentstatus     = 0;                                   //付款状态
        Odata.StateLogistics    = 0;                                   //物流状态
        Odata.Signed            = 0;                                   //签收
        Odata.Settle            = 0;                                   //结清
        Odata.Aside             = 0;                                   //作废
        Odata.Suspended         = 0;                                   //暂停
        Odata.AddTime           = DateTime.Now;
        Odata.AddUser           = mu.UserName;;
        Odata.Userid            = mu.UserID;
        Odata.Freight_remark    = " ";
        Odata.Balance_remark    = "";
        Odata.Promoter          = 0;
        Odata.id = orderBll.Adds(Odata);
        M_Payment payMod = new M_Payment();

        payMod.PaymentNum = Odata.OrderNo;
        payMod.MoneyPay   = Odata.Ordersamount;
        payMod.Remark     = model.ProName;
        payMod.PayNo      = payBll.CreatePayNo();
        payMod.UserID     = mu.UserID;
        payMod.Status     = 1;
        payMod.PaymentID  = payBll.Add(payMod);
        if (string.IsNullOrEmpty(Method))
        {
            string redirect_uri = HttpUtility.UrlEncode("http://x014.2013.hx008.com/PayOnline/wxpayonline.aspx?PayNo=" + payMod.PayNo);
            string url          = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx215c3a129d4f8fcc&redirect_uri=" + redirect_uri + "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
            Response.Redirect(url);
        }
        else
        {
            string redirect_uri = HttpUtility.UrlEncode("http://x014.2013.hx008.com/PayOnline/wxpayonline.aspx?PayNo=" + payMod.PayNo);
            string url          = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx215c3a129d4f8fcc&redirect_uri=" + redirect_uri + "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
            Response.Redirect(url);
        }
    }
Ejemplo n.º 5
0
 //------------------------
 public M_Order_OPLog NewLog(int orderID, string opname, string after = "")
 {
     B_OrderList orderBll = new B_OrderList();
     M_OrderList orderMod = orderBll.SelReturnModel(orderID);
     M_Order_OPLog logMod = new M_Order_OPLog();
     logMod.OPName = opname;
     logMod.OrderNo = orderMod.OrderNo;
     logMod.Before = GetOrderInfo(orderMod);
     logMod.After = after;
     return logMod;
 }
Ejemplo n.º 6
0
    public void CreateOrder(M_FastOrder model)
    {
        M_UserInfo  mu    = buser.GetLogin(false);
        M_OrderList Odata = new M_OrderList();

        Odata.Ordertype       = 10;
        Odata.OrderNo         = B_OrderList.CreateOrderNo((M_OrderList.OrderEnum)Odata.Ordertype);
        Odata.StoreID         = 0;
        Odata.Rename          = mu.UserName;
        Odata.Outstock        = 0;  //缺货处理
        Odata.Ordermessage    = model.Proinfo;
        Odata.Merchandiser    = ""; //跟单员
        Odata.Internalrecords = ""; //内部记录
        Odata.IsCount         = false;
        //-----金额计算
        Odata.Balance_price     = model.Price;
        Odata.Freight           = 0;                                   //运费计算
        Odata.Ordersamount      = Odata.Balance_price + Odata.Freight; //订单金额
        Odata.AllMoney_Json     = "";
        Odata.Specifiedprice    = Odata.Ordersamount;                  //订单金额;
        Odata.Receivablesamount = 0;                                   //收款金额
        Odata.Developedvotes    = 0;
        Odata.OrderStatus       = 0;                                   //订单状态
        Odata.Paymentstatus     = 0;                                   //付款状态
        Odata.StateLogistics    = 0;                                   //物流状态
        Odata.Signed            = 0;                                   //签收
        Odata.Settle            = 0;                                   //结清
        Odata.Aside             = 0;                                   //作废
        Odata.Suspended         = 0;                                   //暂停
        Odata.AddTime           = DateTime.Now;
        Odata.AddUser           = mu.UserName;;
        Odata.Userid            = mu.UserID;
        Odata.Freight_remark    = " ";
        Odata.Balance_remark    = "";
        Odata.Promoter          = 0;
        Odata.id = orderBll.Adds(Odata);
        M_Payment payMod = new M_Payment();

        payMod.PaymentNum = Odata.OrderNo;
        payMod.MoneyPay   = DataConverter.CDecimal(Odata.Ordersamount);
        payMod.Remark     = model.ProName;
        payMod.PayNo      = payBll.CreatePayNo();
        payMod.UserID     = mu.UserID;
        payMod.Status     = 1;
        payMod.PaymentID  = payBll.Add(payMod);
        if (string.IsNullOrEmpty(Method))
        {
            Response.Redirect("/PayOnline/Orderpay.aspx?PayNo=" + payMod.PayNo);
        }
        else
        {
            Response.Redirect("/PayOnline/PayOnline.aspx?Method=" + Method + "&PayNo=" + payMod.PayNo);
        }
    }
Ejemplo n.º 7
0
        /// <summary>
        /// 发送系统邮件
        /// </summary>
        public static void SendOrderEmailByType(int oid, string type, string email = "")
        {
            M_OrderList orderMod = new B_OrderList().SelReturnModel(oid);

            if (string.IsNullOrEmpty(email))
            {
                M_Order_Contact conMod = new B_Order_Contact().SelModelByOid(oid);
                email = conMod.Email;
            }
            switch (type)
            {
            case "order":    //下单后(暂只用于测试)
            {
                StringWriter sw = new StringWriter();
                HttpContext.Current.Server.Execute("/Common/MailTlp/Order_Payed.aspx?ID=" + oid, sw);
                string title2 = "We received your order!";
                string html2  = sw.ToString();
                //throw new Exception(conMod.Email);
                SendToEmail(email, title2, html2, "");
            }
            break;

            case "pay":    //付款后
            {
                OrderFinish(orderMod, null);
            }
            break;

            case "exp":
            {
                StringWriter sw = new StringWriter();
                HttpContext.Current.Server.Execute("/Common/MailTlp/Order_Send.aspx?ID=" + oid, sw);
                string title = "Order has been shipped";
                string html  = sw.ToString();
                SendToEmail(email, title, html, "");
                SnsHelper.UpdateOrderField(oid, "EMail_Exp", "1");
            }
            break;

            case "after":
            {
                DataTable orderDT = DBCenter.Sel("ZL_OrderInfo", "ID=" + oid);
                string    title   = "Order Notify";
                string    html    = Tlp_Read("订单后期调查");
                html = EventDeal.TlpDeal(html, orderDT);
                SendToEmail(email, title, html, "");
                SnsHelper.UpdateOrderField(orderMod.id, "EMail_After", "1");
                SendToEmail(SiteConfig.SiteInfo.WebmasterEmail, title, html, "");
            }
            break;
            }
        }
Ejemplo n.º 8
0
        public M_OrderList NewOrder(M_UserInfo mu, int sid)
        {
            M_OrderList orderMod = new M_OrderList();

            orderMod.Userid    = mu.UserID;
            orderMod.AddUser   = mu.UserName;
            orderMod.Rename    = mu.UserName;
            orderMod.Receiver  = mu.UserName;
            orderMod.StoreID   = sid;
            orderMod.Ordertype = (int)M_OrderList.OrderEnum.Other;
            orderMod.OrderNo   = B_OrderList.CreateOrderNo(M_OrderList.OrderEnum.Other);
            return(orderMod);
        }
Ejemplo n.º 9
0
    /*
     * http://kf.qq.com/faq/140225MveaUz150107jmeaMv.html  参数一些解释,公众号APPID
     *
     *
     * 问:输入的商户号有误
     * 资料:报这个错误提示,要注意上传的请求参数要按照文档的要求:APPID这个参数要正确填写为:mch_appid,请注意。如下图
     */
    protected void Transfer_Btn_Click(object sender, EventArgs e)
    {
        WxPayData inputObj = new WxPayData();

        inputObj.SetValue("partner_trade_no", B_OrderList.CreateOrderNo(M_OrderList.OrderEnum.Cloud));
        inputObj.SetValue("openid", "oaLxyt7ZTVnjPmqkTI-SY-Z9akzw");
        inputObj.SetValue("check_name", "OPTION_CHECK");
        inputObj.SetValue("re_user_name", "徐喜平");
        inputObj.SetValue("amount", "100");
        inputObj.SetValue("desc", "提现");
        inputObj.SetValue("spbill_create_ip", "58.215.65.54");
        Transfer(inputObj);
    }
Ejemplo n.º 10
0
        //设为成功
        protected void Button2_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Request.Form["idchk"]))
            {
                return;
            }
            B_OrderList orderBll = new B_OrderList();

            string[] idArr = Request.Form["idchk"].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < idArr.Length; i++)
            {
                orderBll.UpOrderinfo("OrderStatus=99", Convert.ToInt32(idArr[i]));
            }
            MyBind();
        }
Ejemplo n.º 11
0
        public void CreateOrder(M_FastOrder model)
        {
            M_UserInfo  mu    = buser.GetLogin(false);
            M_OrderList Odata = new M_OrderList();

            Odata.Ordertype    = 10;
            Odata.OrderNo      = B_OrderList.CreateOrderNo((M_OrderList.OrderEnum)Odata.Ordertype);
            Odata.Mobile       = DataConverter.CLng(model.Phone);
            Odata.Rename       = mu.UserName;
            Odata.Ordermessage = model.Jiedao;
            Odata.Jiedao       = model.Proinfo;
            //-----金额计算
            Odata.Balance_price  = model.Price;
            Odata.Ordersamount   = Odata.Balance_price + Odata.Freight; //订单金额
            Odata.Specifiedprice = Odata.Ordersamount;                  //订单金额;
            Odata.AddUser        = mu.UserName;;
            Odata.Userid         = mu.UserID;
            Odata.id             = orderBll.Adds(Odata);
            //-----购物车记录
            M_CartPro cartMod = new M_CartPro();

            cartMod.Orderlistid = Odata.id;
            cartMod.Username    = mu.UserName;
            cartMod.Proname     = model.ProName;
            cartMod.Pronum      = model.Pronum;
            cartMod.ProClass    = model.ProClass;
            cartMod.FarePrice   = model.Price.ToString("F2");
            cartBll.Add(cartMod);
            //-----支付单
            M_Payment payMod = new M_Payment();

            payMod.PaymentNum = Odata.OrderNo;
            payMod.MoneyPay   = Odata.Ordersamount;
            payMod.Remark     = model.ProName;
            payMod.PayNo      = payBll.CreatePayNo();
            payMod.UserID     = mu.UserID;
            payMod.Status     = 1;
            payMod.PaymentID  = payBll.Add(payMod);
            if (string.IsNullOrEmpty(Method))
            {
                Response.Redirect("/PayOnline/Orderpay.aspx?PayNo=" + payMod.PayNo);
            }
            else
            {
                Response.Redirect("/PayOnline/PayOnline.aspx?Method=" + Method + "&PayNo=" + payMod.PayNo);
            }
        }
Ejemplo n.º 12
0
        public DataTable GetSaleByDay(F_Shop_SaleReport filter)
        {
            B_OrderList orderBll = new B_OrderList();

            if (string.IsNullOrEmpty(filter.SDate))
            {
                filter.SDate = DateTime.Now.AddMonths(-2).ToString("yyyy/MM/dd");
            }
            if (string.IsNullOrEmpty(filter.EDate))
            {
                filter.EDate = DateTime.Now.ToString("yyyy/MM/dd");
            }
            DateTime  STime = DataConvert.CDate(filter.SDate), ETime = DataConvert.CDate(filter.EDate);
            DataTable saleDT = orderBll.Report_SelByDate(STime, ETime, filter.StoreID);
            DataTable dayDT  = new DataTable();

            dayDT.Columns.Add("date", typeof(string));
            dayDT.Columns.Add("total", typeof(double));
            dayDT.Columns.Add("pay_online", typeof(double));
            dayDT.Columns.Add("pay_purse", typeof(double));
            for (DateTime s = STime; s <= ETime; s = s.AddDays(1))
            {
                DataRow day = dayDT.NewRow();
                //DateTime sdate = Convert.ToDateTime("{0}/{1}/{2} 00:00:00");
                string sdate = s.ToString("#yyyy/MM/dd 00:00:00#"), edate = s.ToString("#yyyy/MM/dd 23:59:59#");
                saleDT.DefaultView.RowFilter = "PayTime>= " + sdate + " AND PayTime<= " + edate;
                day["date"]       = s.ToString("yyyy-MM-dd");
                day["total"]      = 0;
                day["pay_online"] = 0;
                day["pay_purse"]  = 0;
                foreach (DataRow dr in saleDT.DefaultView.ToTable().Rows)
                {
                    day["Total"] = DataConvert.CDouble(day["Total"]) + DataConvert.CDouble(dr["OrdersAmount"]);
                    if (Convert.ToInt32(dr["PayPlatID"]) == 0)
                    {
                        day["pay_purse"] = DataConvert.CDouble(day["pay_purse"]) + DataConvert.CDouble(dr["OrdersAmount"]);
                    }
                    else
                    {
                        day["pay_online"] = DataConvert.CDouble(day["pay_online"]) + DataConvert.CDouble(dr["OrdersAmount"]);
                    }
                }
                dayDT.Rows.Add(day);
            }
            return(dayDT);
        }
Ejemplo n.º 13
0
        public void fahuo(int id, String Email)
        {
            B_CartPro   cpl = new B_CartPro();
            B_OrderList oll = new B_OrderList();
            B_Product   pll = new B_Product();
            B_Stock     Sll = new B_Stock();

            //历遍清单所有商品数量,查找库存///////////////////
            DataTable   Unew   = cpl.GetCartProOrderID(id); //获得详细清单列表
            M_OrderList orlist = oll.GetOrderListByid(id);

            for (int s = 0; s < Unew.Rows.Count; s++)
            {
                int Onum = ZoomLa.Common.DataConverter.CLng(Unew.Rows[s]["Pronum"]);
                int Opid = ZoomLa.Common.DataConverter.CLng(Unew.Rows[s]["ProID"]);

                M_Product pdin = pll.GetproductByid(Opid);//获得商品信息

                if (pdin.JisuanFs == 0)
                {
                    int pstock = pdin.Stock - Onum;//库存结果,返回的商品数量
                    pll.ProUpStock(Opid, pstock);
                }
                M_Stock SData = new M_Stock();
                SData.id        = 0;
                SData.proid     = Opid;
                SData.stocktype = 1;
                SData.proname   = pdin.Proname;
                SData.danju     = "CK" + orlist.OrderNo.ToString();
                SData.adduser   = orlist.Reuser.ToString();
                SData.addtime   = DateTime.Now;
                SData.content   = "订单:" + orlist.Reuser.ToString() + "发货";
                SData.Pronum    = ZoomLa.Common.DataConverter.CLng(Unew.Rows[0]["Pronum"]);
                Sll.AddStock(SData);
            }

            string str = "StateLogistics=1";

            if (!string.IsNullOrEmpty(Email))
            {
                str += ",ExpressDelivery='" + Email + "'";
            }
            oll.UpOrderinfo(str, id);
            PromotionComfirm(orlist);
        }
Ejemplo n.º 14
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (UserID < 1)
     {
         function.WriteErrMsg("未指定会员ID");
     }
     if (ExpType < 1)
     {
         function.WriteErrMsg("未指定虚拟币类型");
     }
     if (!IsPostBack)
     {
         //订单赠送积分,自动填写备注
         if (OrderID > 0)
         {
             B_OrderList orderBll = new B_OrderList();
             M_OrderList orderMod = orderBll.SelReturnModel(OrderID);
             if (orderMod == null)
             {
                 function.WriteErrMsg("指定的订单不存在");
             }
             TxtDetail.Text = "订单:[" + orderMod.OrderNo + "]";
         }
         if (EditID > 0)
         {
             UserPDiv.Visible  = false;
             EditMoney.Visible = true;
             M_UserExpHis expMod = hisBll.SelReturnModel((M_UserExpHis.SType)ExpType, EditID);
             UserExpDomPID.Text = expMod.ExpHisID.ToString();
             HisTime.Text       = expMod.HisTime.ToString();
             Score.Text         = expMod.score.ToString();
             Detail.Text        = expMod.detail;
             UserPH.Value       = expMod.ExpHisID.ToString();
             return;
         }
         else
         {
             MyBind();
         }
         Call.SetBreadCrumb(Master, "<li><a href='" + customPath2 + "Main.aspx'>工作台</a></li><li><a href='UserManage.aspx'>会员管理</a></li><li><a href='UserInfo.aspx?ID=" + UserID + "'>会员信息</a></li><li class='active'>会员" + GetTypeName() + "操作</li>");
     }
 }
Ejemplo n.º 15
0
        private CommonReturn SendMoney(M_WX_APPID appMod, string openid, double amount, string desc)
        {
            WxPayData wxdata = new WxPayData();

            wxdata.SetValue("partner_trade_no", B_OrderList.CreateOrderNo(M_OrderList.OrderEnum.Normal));
            wxdata.SetValue("openid", openid);
            wxdata.SetValue("check_name", "NO_CHECK");//OPTION_CHECK NO_CHECK
            //wxdata.SetValue("re_user_name", trueName.Trim());
            wxdata.SetValue("amount", (int)amount * 100);
            wxdata.SetValue("desc", desc);
            wxdata.SetValue("spbill_create_ip", Request.ServerVariables["LOCAl_ADDR"]);//必须填写
            WxPayData result = WxPayApi.Pay_Transfer(wxdata, appMod);

            if (result.GetValue("result_code").ToString().ToUpper().Equals("SUCCESS"))
            {
                return(CommonReturn.Success());
            }
            else
            {
                string err = result.GetValue("return_msg").ToString();
                return(CommonReturn.Failed(err));
            }
        }
Ejemplo n.º 16
0
        //确定购买
        protected void sureBtn_Click(object sender, EventArgs e)
        {
            M_UserInfo mu = buser.GetLogin();

            proModel = proBll.GetproductByid(Convert.ToInt32(dataField.Value));
            int num = Convert.ToInt32(proNum.Text.Trim());

            Odata.Ordersamount = Convert.ToDouble(num * proModel.LinPrice);
            Odata.OrderNo      = B_OrderList.CreateOrderNo(M_OrderList.OrderEnum.IDC);
            Odata.Ordertype    = (int)M_OrderList.OrderEnum.IDC;;//服务,主机等订单
            Odata.Receiver     = mu.UserName;
            Odata.Reuser       = mu.UserName;
            Odata.Userid       = mu.UserID;
            //Odata.AddUser = siteListDP.SelectedValue;//跟单员,此处记录对应ID
            //Odata.Internalrecords = siteListDP.SelectedItem.Text;//内部记录,此处用来存与主机的关联信息
            //添加订单,添加数据库购物车
            Odata.id = OCl.Adds(Odata);
            if (Odata.id > 0)
            {
                //写入购物车记录
                M_CartPro cartModel = new M_CartPro();
                cartModel.Orderlistid = Odata.id;
                cartModel.ProID       = proModel.ID;
                cartModel.Proname     = proModel.Proname;
                cartModel.Shijia      = proModel.LinPrice;
                cartModel.Pronum      = num;
                cartModel.AllMoney    = Odata.Ordersamount;
                cartModel.EndTime     = DateTime.Now;//支付时再更新日期, proBll.GetEndTime(proModel, num);
                cartModel.type        = (int)M_OrderList.OrderEnum.IDC;
                bcart.Add(cartModel);
                Response.Redirect("~/PayOnline/Orderpay.aspx?OrderCode=" + Odata.OrderNo);
            }
            else
            {
                function.WriteErrMsg("目标订单:" + Odata.OrderNo + "不存在!!!");
            }
        }
Ejemplo n.º 17
0
        protected void Submit_B_Click(object sender, EventArgs e)
        {
            M_OrderList Odata = new M_OrderList();

            //int uid = DataConvert.CLng(UserID_Hid.Value);
            M_UserInfo mu = buser.SelReturnModel(DataConvert.CLng(UserID_Hid.Value));

            if (mu.IsNull)
            {
                function.WriteErrMsg("订单所绑定的用户[" + UserID_T.Text + "]不存在");
            }
            Odata.Ordertype         = DataConvert.CLng(OrderType_DP.SelectedValue);
            Odata.OrderNo           = B_OrderList.CreateOrderNo((M_OrderList.OrderEnum)Odata.Ordertype);
            Odata.StoreID           = DataConvert.CLng(StoreID_T.Text);
            Odata.Receiver          = ReceUser_T.Text;
            Odata.Reuser            = ReceUser_T.Text;
            Odata.Phone             = Mobile_T.Text;
            Odata.MobileNum         = Mobile_T.Text;
            Odata.Shengfen          = Request.Form["province_dp"];
            Odata.Chengshi          = Request.Form["city_dp"];
            Odata.Diqu              = Request.Form["county_dp"];
            Odata.Jiedao            = Address_T.Text;
            Odata.ZipCode           = ZipCode_T.Text;
            Odata.Invoiceneeds      = Invoiceneeds.Checked ? 1 : 0;
            Odata.Rename            = mu.UserName;
            Odata.Outstock          = 0;                   //缺货处理
            Odata.Ordermessage      = Ordermessage_T.Text; //订货留言
            Odata.Balance_price     = DataConvert.CFloat(Price_T.Text);
            Odata.Freight           = DataConvert.CFloat(Freight_T.Text);
            Odata.Ordersamount      = Odata.Balance_price + Odata.Freight; //订单金额
            Odata.Specifiedprice    = Odata.Ordersamount;
            Odata.Receivablesamount = 0;                                   //收款金额
            Odata.Developedvotes    = 0;
            Odata.OrderStatus       = DataConvert.CLng(OrderStatus_DP.SelectedValue);
            Odata.PayType           = DataConvert.CLng(PayType_Rad.SelectedValue);
            Odata.Paymentstatus     = DataConvert.CLng(Pay_Rad.SelectedValue);
            Odata.StateLogistics    = DataConvert.CLng(Exp_Rad.SelectedValue);
            Odata.AddTime           = DateTime.Now;
            Odata.AddUser           = mu.UserName;;
            Odata.Userid            = mu.UserID;
            Odata.Merchandiser      = "";                //跟单员
            Odata.Internalrecords   = "";                //内部记录
            Odata.id             = orderBll.Adds(Odata); //添加到订单表
            Odata.IsCount        = false;
            Odata.Freight_remark = " ";
            Odata.Balance_remark = "";
            Odata.Promoter       = 0;
            //将数据添加至zl_cartpro永久保存
            CopyToCartPro(Odata);
            string rurl = "";

            if (OrderType == (int)M_OrderList.OrderEnum.IDC || OrderType == (int)M_OrderList.OrderEnum.IDCRen)
            {
                rurl = "OtherOrder/IDCOrder.aspx?OrderType=" + OrderType;
            }
            else
            {
                rurl = "OrderList.aspx?OrderType=" + OrderType;
            }
            function.WriteSuccessMsg("订单添加成功!", rurl);
        }
Ejemplo n.º 18
0
        //确定,生成信息写入ZL_Payment
        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            int         platid   = DataConverter.CLng(Request.Form["payplat_rad"]);
            M_UserInfo  mu       = buser.GetLogin(false);
            M_Payment   pinfo    = new M_Payment();
            M_OrderList orderMod = new M_OrderList();

            if (!string.IsNullOrEmpty(PayNo))//支付单付款
            {
                pinfo = payBll.SelModelByPayNo(PayNo);
                if (pinfo.Status != (int)M_Payment.PayStatus.NoPay)
                {
                    function.WriteErrMsg("该支付单已付款,请勿重复支付"); return;
                }
            }
            else
            {
                //传入订单,或直接充值
                if (Money > 0)//直接充值
                {
                    orderMod.OrderNo      = B_OrderList.CreateOrderNo(M_OrderList.OrderEnum.Purse);
                    orderMod.Ordertype    = (int)M_OrderList.OrderEnum.Purse;//Purse等充值
                    orderMod.Userid       = mu.UserID;
                    orderMod.Rename       = mu.UserName;
                    orderMod.AddUser      = mu.UserName;
                    orderMod.Ordersamount = Money;
                    if (orderMod.Ordersamount < 0.01)
                    {
                        function.WriteErrMsg("错误,金额过小");
                    }
                    orderBll.Add(orderMod);
                    pinfo.PaymentNum = orderMod.OrderNo;
                    pinfo.MoneyPay   = orderMod.Ordersamount;
                    pinfo.Remark     = "用户充值";
                }
                else
                {
                    DataTable orderDT = orderBll.GetOrderbyOrderNo(OrderNo);
                    GetTotal(orderDT, ref price, ref fare, ref allamount);
                    if (allamount < 0.01)
                    {
                        function.WriteErrMsg("每次划款金额不能低于0.01元");
                    }
                    if (orderDT != null && orderDT.Rows.Count > 0)
                    {
                        orderMod         = orderBll.GetOrderListByid(DataConverter.CLng(orderDT.Rows[0]["id"]));
                        orderMod.Payment = platid;
                        orderBll.Update(orderMod);
                    }
                    pinfo.PaymentNum = OrderNo;
                    pinfo.MoneyPay   = allamount;
                    DataTable cartDT = new DataTable();
                    //cartDT = bcart.GetSelectTableBySql("select * From ZL_CartPro Where OrderListID = " + orderMod.id, null);
                    //pinfo.Remark = cartDT.Rows.Count > 1 ? "[" + cartDT.Rows[0]["ProName"] as string + "]等" : cartDT.Rows[0]["ProName"] as string;
                }
            }
            pinfo.UserID    = mu.UserID;
            pinfo.PayPlatID = platid;
            pinfo.MoneyID   = 0;
            pinfo.MoneyReal = pinfo.MoneyPay;
            //用于支付宝网银
            pinfo.PlatformInfo = Request.Form["payplat_rad"];
            if (!string.IsNullOrEmpty(PayNo))
            {
                payBll.Update(pinfo);
            }
            else
            {
                pinfo.Status = (int)M_Payment.PayStatus.NoPay;
                pinfo.PayNo  = payBll.CreatePayNo();
                payBll.Add(pinfo);
            }
            string url = "PayOnline.aspx?PayNo=" + pinfo.PayNo;

            if (pinfo.PayPlatID == 0)
            {
                url += "&method=" + Request.Form["payplat_rad"];
            }
            Response.Redirect(url);
        }
Ejemplo n.º 19
0
    /// <summary>
    /// 异步回调后-->验证支付单状态-->如果正常,更新订单状态
    /// </summary>
    /// <param name="mod">订单模型</param>
    /// <param name="paylogMod">订单支付日志模型</param>
    public static void FinalStep(M_Payment pinfo, M_OrderList mod, M_Order_PayLog paylogMod)
    {
        B_OrderList    orderBll  = new B_OrderList();
        B_CartPro      cartBll   = new B_CartPro();
        B_Order_PayLog paylogBll = new B_Order_PayLog();
        B_User         buser     = new B_User();

        //订单已处理,避免重复(如已处理过,则继续处理下一张订单)
        if (mod.OrderStatus >= 99)
        {
            ZLLog.L(ZoomLa.Model.ZLEnum.Log.safe, new M_Log()
            {
                Action  = "支付回调异常,订单状态已为99",
                Message = "订单号:" + mod.OrderNo + ",支付单:" + pinfo.PayNo
            });
            return;
        }
        //已经收到钱了,所以先执行
        orderBll.UpOrderinfo("Paymentstatus=1,Receivablesamount=" + pinfo.MoneyTrue, mod.id);
        if (mod.Ordertype == (int)M_OrderList.OrderEnum.Domain)//域名订单
        {
            orderBll.UpOrderinfo("OrderStatus=1", mod.id);
            //Response.Redirect("~/Plugins/Domain/DomReg2.aspx?OrderNo=" + mod.OrderNo);
        }
        else if (mod.Ordertype == (int)M_OrderList.OrderEnum.IDC)//IDC服务
        {
            orderBll.UpOrderinfo("OrderStatus=99", mod.id);
            cartBll.IDC_UpdateEndTimeByOid(mod.id);
        }
        else if (mod.Ordertype == (int)M_OrderList.OrderEnum.Purse)//余额充值,不支持银币
        {
            buser.ChangeVirtualMoney(mod.Userid, new M_UserExpHis()
            {
                score     = (int)mod.Ordersamount,
                ScoreType = (int)M_UserExpHis.SType.Purse,
                detail    = "余额充值,订单号:" + mod.OrderNo
            });
            orderBll.UpOrderinfo("OrderStatus=99", mod.id);            //成功的订单
        }
        else if ((mod.Ordertype == (int)M_OrderList.OrderEnum.IDCRen)) //IDC服务续费
        {
            orderBll.UpOrderinfo("OrderStatus=99", mod.id);
            B_Product proBll = new B_Product();
            //更新旧订单的期限
            if (string.IsNullOrEmpty(mod.Ordermessage))//购物车ID
            {
                //function.WriteErrMsg("出错,无需续费订单信息,请联系管理员!!!");
                throw new Exception("出错,无续费订单信息,请联系管理员");
            }
            M_CartPro newCartMod = cartBll.SelModByOrderID(mod.id);//新购物车只是取其商品ID与数量等
            M_Product proMod     = proBll.GetproductByid(newCartMod.ProID);
            //更新延长旧服务的到期时间,旧服务是存在CartPro的EndTime当中
            M_CartPro oldCartMod = cartBll.SelReturnModel(Convert.ToInt32(mod.Ordermessage));
            if (oldCartMod.EndTime < DateTime.Now)
            {
                oldCartMod.EndTime = DateTime.Now;                                   //如已过期,则将时间更新至今日
            }
            oldCartMod.EndTime = proBll.GetEndTime(proMod, newCartMod.Pronum, oldCartMod.EndTime);
            cartBll.UpdateByID(oldCartMod);
            //paylogMod.Remind = "为" + mod.Ordermessage + "订单续费(购物车)";
        }
        else if (mod.Ordertype == (int)M_OrderList.OrderEnum.Cloud)//云购订单
        {
            //根据份数生成幸运码,写入表中,并减去库存 ZL_Order_LuckCode
        }
        else//其他旅游订单等,只更新状态
        {
            orderBll.UpOrderinfo("OrderStatus=99", mod.id);//成功的订单
        }
        //-------支付成功处理,并写入日志
        paylogMod.Remind   += "订单" + mod.OrderNo + "购买生效";
        paylogMod.OrderID   = mod.id;
        paylogMod.PayMoney  = mod.Ordersamount;
        paylogMod.PayMethod = (int)M_Order_PayLog.PayMethodEnum.Other;//外部指定
        paylogMod.PayPlatID = pinfo.PayPlatID;
        paylogBll.insert(paylogMod);
    }
Ejemplo n.º 20
0
        public void WeiXinPay()
        {
            M_Payment payMod = payBll.SelModelByPayNo(PayNo);

            if (string.IsNullOrEmpty(PayNo))
            {
                function.WriteErrMsg("0x53,支付单号或为空");
            }
            else if (payMod == null)
            {
                function.WriteErrMsg("支付单号不存在");
            }
            else if (payMod.Status != (int)M_Payment.PayStatus.NoPay)
            {
                function.WriteErrMsg("0x14,支付单已付过款,不能重复支付");
            }
            else if (payMod.MoneyReal <= 0)
            {
                function.WriteErrMsg("0x56,支付单金额异常");
            }
            //押金与转借订单
            //if (!string.IsNullOrEmpty(payMod.SysRemark))
            //{
            B_OrderList orderBll = new B_OrderList();
            M_OrderList orderMod = orderBll.SelModelByOrderNo(payMod.PaymentNum);

            if (orderMod.Ordertype == (int)M_OrderList.OrderEnum.Score)
            {
                Lend1.Visible = true;
            }
            if (orderMod.Ordertype == (int)M_OrderList.OrderEnum.Purse)
            {
                Lend2.Visible = true;
            }
            //}
            //function.WriteErrMsg(payMod.SysRemark.ToString());

            string  code      = Request.QueryString["code"];
            string  resultStr = APIHelper.GetWebResult("https://api.weixin.qq.com/sns/oauth2/access_token?appid=" + appMod.APPID + "&secret=" + appMod.Secret + "&code=" + code + "&grant_type=authorization_code");
            JObject obj       = (JObject)JsonConvert.DeserializeObject(resultStr);

            WxPayData wxdata = new WxPayData();

            wxdata.SetValue("out_trade_no", payMod.PayNo);
            wxdata.SetValue("body", string.IsNullOrEmpty(payMod.Remark) ? "微信支付" : payMod.Remark);
            wxdata.SetValue("total_fee", (int)(payMod.MoneyReal * 100));//            wxdata.SetValue("total_fee", (int)( * 100));

            wxdata.SetValue("trade_type", "JSAPI");
            wxdata.SetValue("notify_url", notifyUrl);
            wxdata.SetValue("product_id", "123");                //必填
            wxdata.SetValue("openid", obj["openid"].ToString()); //公众号支付必填
            wxdata.SetValue("nonce_str", WxAPI.nonce);

            //获取预支付单号
            WxPayData result = WxPayApi.UnifiedOrder(wxdata, appMod);

            if (result.GetValue("return_code").ToString().Equals("FAIL"))
            {
                function.WriteErrMsg("商户" + result.GetValue("return_msg"));
            }
            prepay_id = result.GetValue("prepay_id").ToString();
            payBll.UpdatePlat(payMod.PaymentID, M_PayPlat.Plat.WXPay, appMod.ID.ToString());
            LendInfo_Hid.Value = payMod.SysRemark;
        }
Ejemplo n.º 21
0
    //提交订单
    protected void AddOrder_Btn_Click(object sender, EventArgs e)
    {
        if (Address_Div.Visible && DataConvert.CLng(Request.Form["address_rad"]) < 1)
        {
            function.WriteErrMsg("尚未选定收货地址");
        }
        //1,生成订单,2,关联购物车中商品为已绑定订单
        M_UserInfo  mu      = buser.GetLogin(false);
        M_UserRecei receMod = receBll.GetSelect(Convert.ToInt32(Request.Form["address_rad"]), mu.UserID);
        DataTable   cartDT  = cartBll.SelByCookID(CartCookID, ProClass, ids);//需要购买的商品

        if (cartDT.Rows.Count < 1)
        {
            function.WriteErrMsg("你尚未选择商品,<a href='/User/Order/OrderList.aspx'>查看我的订单</a>");
        }
        //------生成订单前检测区
        foreach (DataRow dr in cartDT.Rows)
        {
            if (!HasStock(dr["Allowed"], DataConvert.CLng(dr["stock"]), Convert.ToInt32(dr["Pronum"])))
            {
                function.WriteErrMsg("购买失败," + dr["proname"] + "的库存数量不足");
            }
        }
        //------检测End
        //按店铺生成订单,统一存ZL_Orderinfo
        DataTable storeDT = cartDT.DefaultView.ToTable(true, "StoreID");
        M_Payment payMod  = new M_Payment();

        payMod.PayNo = payBll.CreatePayNo();
        List <M_OrderList> orderList = new List <M_OrderList>();//用于生成临时订单,统计计算(Disuse)

        foreach (DataRow dr in storeDT.Rows)
        {
            #region 暂不使用字段
            //Odata.province = this.DropDownList1.SelectedValue;
            //Odata.city = this.DropDownList2.SelectedValue;//将地址省份与市ID存入,XML数据源
            //Odata.Guojia = "";//国家
            //Odata.Chengshi = DropDownList2.SelectedItem.Text;//城市
            //Odata.Diqu = DropDownList3.SelectedItem.Text;//地区
            //Odata.Delivery = DataConverter.CLng(Request.Form["Delivery"]);
            //Odata.Deliverytime = DataConverter.CLng(this.Deliverytime.Text);
            //Odata.Mobile = receMod.MobileNum;
            #endregion
            M_OrderList Odata = new M_OrderList();
            Odata.Ordertype = OrderHelper.GetOrderType(ProClass);
            Odata.OrderNo   = B_OrderList.CreateOrderNo((M_OrderList.OrderEnum)Odata.Ordertype);
            Odata.StoreID   = Convert.ToInt32(dr["StoreID"]);
            cartDT.DefaultView.RowFilter = "StoreID=" + Odata.StoreID;
            DataTable storeCartDT = cartDT.DefaultView.ToTable();
            switch (ProClass)//旅游机票等,以联系人信息为地址
            {
            case 7:
            case 8:
                M_Cart_Travel   model = JsonConvert.DeserializeObject <M_Cart_Travel>(storeCartDT.Rows[0]["Additional"].ToString());
                M_Cart_Contract user  = model.Contract[0];
                Odata.Receiver  = user.Name;
                Odata.Reuser    = user.Name;
                Odata.Phone     = user.Mobile;
                Odata.MobileNum = user.Mobile;
                Odata.Email     = user.Email;
                break;

            default:    //普通订单
                Odata.Receiver  = receMod.ReceivName;
                Odata.Reuser    = receMod.ReceivName;
                Odata.Phone     = receMod.phone;
                Odata.MobileNum = receMod.MobileNum;
                Odata.Email     = receMod.Email;
                Odata.Shengfen  = receMod.Provinces;
                Odata.Jiedao    = receMod.Street;
                Odata.ZipCode   = receMod.Zipcode;
                break;
            }
            Odata.Invoiceneeds    = DataConverter.CLng(Request.Form["invoice_rad"]);//是否需开发票
            Odata.Invoice         = Odata.Invoiceneeds == 0 ? "" : InvoTitle_T.Text + "||" + Invoice_T.Text;
            Odata.Rename          = mu.UserName;
            Odata.Outstock        = 0;              //缺货处理
            Odata.Ordermessage    = ORemind_T.Text; //订货留言
            Odata.Merchandiser    = "";             //跟单员
            Odata.Internalrecords = "";             //内部记录
            Odata.IsCount         = false;
            //-----金额计算
            Odata.Balance_price     = GetTotalMoney(storeCartDT);
            Odata.Freight           = GetFarePrice(storeCartDT, Odata.StoreID); //运费计算
            Odata.Ordersamount      = Odata.Balance_price + Odata.Freight;      //订单金额
            Odata.AllMoney_Json     = orderCom.GetTotalJson(storeCartDT);       //附加需要的虚拟币
            Odata.Specifiedprice    = Odata.Ordersamount;                       //订单金额;
            Odata.Receivablesamount = 0;                                        //收款金额
            Odata.Developedvotes    = 0;
            Odata.OrderStatus       = (int)M_OrderList.StatusEnum.Normal;       //订单状态
            Odata.Paymentstatus     = (int)M_OrderList.PayEnum.NoPay;           //付款状态
            Odata.StateLogistics    = 0;                                        //物流状态
            Odata.Signed            = 0;                                        //签收
            Odata.Settle            = 0;                                        //结清
            Odata.Aside             = 0;                                        //作废
            Odata.Suspended         = 0;                                        //暂停
            Odata.AddTime           = DateTime.Now;
            Odata.AddUser           = mu.UserName;;
            Odata.Userid            = mu.UserID;
            Odata.Integral          = DataConverter.CLng(Request.QueryString["jifen"]);
            Odata.Freight_remark    = " ";
            Odata.Balance_remark    = "";
            Odata.Promoter          = 0;
            Odata.id = orderBll.Adds(Odata);
            cartProBll.CopyToCartPro(mu, storeCartDT, Odata.id);
            orderList.Add(Odata);
            orderCom.SendMessage(Odata, null, "ordered");
            userappMod = userappBll.SelModelByUid(buser.GetLogin().UserID, "wechat");
            if (userappMod != null)
            {
                //function.WriteErrMsg(Odata.AddTime.ToString("yyyy年MM月dd日 HH:mm:ss"));
                WxAPI  wxapi = WxAPI.Code_Get(1);
                string json  = "{ \"touser\":\"" + userappMod.OpenID + "\",\"template_id\":\"6kw4rUCX3IpE7k8_kn3ocmaaQBZF4blWq25ualnz1qw\",\"url\":\"http://www.wodian8.com/User/Order/OrderList1.aspx\",\"data\":{\"first\": {\"value\":\"订单提交成功!\",\"color\":\"#173177\"},\"keyword1\":{\"value\":\"" + Odata.AddTime.ToString("yyyy年MM月dd日 HH:mm:ss") + "\",\"color\":\"#173177\"},\"keyword2\": {\"value\":\"" + Odata.Ordersamount.ToString("0.00") + "元\",\"color\":\"#173177\"},\"keyword3\": {\"value\":\"" + GetProname(Odata.id) + "\",\"color\":\"#173177\"},\"keyword4\": {\"value\":\"" + Odata.Shengfen + Odata.Jiedao + "\",\"color\":\"#173177\"},\"remark\":{\"value\":\"您好,订单提交成功,请尽快付款!\",\"color\":\"#173177\"}}}";
                wxapi.SendTlpMsg(json);
                //wxapi.SendMsg(userappMod.OpenID, "你已下订单,订单号为:" + Odata.OrderNo);
            }
        }
        cartBll.DelByids(ids);
        //-----------------订单生成后处理
        //进行减库存等操作
        foreach (DataRow dr in cartDT.Rows)
        {
            M_Product model = proBll.GetproductByid(Convert.ToInt32(dr["Proid"]));
            model.Stock = model.Stock - DataConvert.CLng(dr["Pronum"]);
            SqlHelper.ExecuteSql("Update ZL_Commodities Set Stock=" + model.Stock + " Where ID=" + model.ID);
        }
        //生成支付单,处理优惠券,并进入付款步骤
        foreach (M_OrderList model in orderList)
        {
            payMod.PaymentNum += model.OrderNo + ",";
            payMod.MoneyPay   += model.Ordersamount;
        }
        //优惠券
        if (!string.IsNullOrEmpty(Arrive_T.Text))
        {
            double arriveAmount = arriveBll.UserArrive(Arrive_T.Text, Arrive_Pwd.Text);
            payMod.MoneyPay     = payMod.MoneyPay - arriveAmount;
            payMod.ArriveMoney  = arriveAmount;
            payMod.ArriveDetail = Arrive_T.Text + "|" + Arrive_Pwd.Text;
        }
        //积分处理
        if (point_body.Visible && DataConvert.CLng(Point_T.Text) > 0)
        {
            int point    = DataConvert.CLng(Point_T.Text);
            int maxPoint = (int)((SiteConfig.ShopConfig.PointRatiot * 0.01) * (double)payMod.MoneyPay / SiteConfig.ShopConfig.PointRate);
            //if (point <= 0) { function.WriteErrMsg("积分数值不正确"); }
            if (point > mu.UserExp)
            {
                function.WriteErrMsg("您的积分不足!");
            }
            if (point > maxPoint)
            {
                function.WriteErrMsg("积分不能大于可兑换金额!");
            }
            //生成支付单时扣除用户积分
            buser.ChangeVirtualMoney(mu.UserID, new M_UserExpHis()
            {
                ScoreType = (int)M_UserExpHis.SType.Point, score = -point, detail = "积分抵扣,支付单号:" + payMod.PayNo
            });
            payMod.MoneyPay = payMod.MoneyPay - (point * SiteConfig.ShopConfig.PointRate);
            payMod.UsePoint = point;
        }
        if (payMod.MoneyPay <= 0)
        {
            payMod.MoneyPay = 0.01;
        }
        payMod.PaymentNum = payMod.PaymentNum.TrimEnd(',');
        payMod.Remark     = cartDT.Rows.Count > 1 ? "[" + cartDT.Rows[0]["ProName"] as string + "]等" : cartDT.Rows[0]["ProName"] as string;
        payMod.UserID     = mu.UserID;
        payMod.Status     = 1;
        payMod.PaymentID  = payBll.Add(payMod);

        string redirect_uri = HttpUtility.UrlEncode("http://www.wodian8.com/Payonline/wxpayonline.aspx?PayNo=" + payMod.PayNo);
        string url          = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8c5c2dc7b10a36f3&redirect_uri=" + redirect_uri + "&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
        //Response.Redirect(url);
        Response.Redirect("/PayOnline/Orderpay.aspx?PayNo=" + payMod.PayNo);
    }
Ejemplo n.º 22
0
        public IActionResult GetOrderInfo_Submit()
        {
            //1,生成订单,2,关联购物车中商品为已绑定订单
            string     ids    = GetParam("ids");
            M_UserInfo mu     = buser.GetLogin(false);
            DataTable  cartDT = cartBll.SelByCartID(B_Cart.GetCartID(HttpContext), mu.UserID, ProClass, ids);//需要购买的商品

            if (cartDT.Rows.Count < 1)
            {
                return(WriteErr("你尚未选择商品,<a href='/User/Order/OrderList'>查看我的订单</a>"));
            }
            VM_CartOrder vmMod = new VM_CartOrder();

            vmMod.IsShowAddress(DataConvert.CLng(cartDT.Rows[0]["ProClass"]));
            //------------------------------
            #region 检测缓存中的值与数据库中是否匹配
            //string refreshTip = ",请点击<a href='" + Request.RawUrl() + "'>刷新页面</a>";
            //if (VerifyDT == null || VerifyDT.Rows.Count < 1 || VerifyDT.Rows.Count != cartDT.Rows.Count)
            //{ return WriteErr("验证失效" + refreshTip, Request.RawUrl()); }
            //for (int i = 0; i < VerifyDT.Rows.Count; i++)
            //{
            //    //检测每一个商品,是否发生了ID/金额/数量/价格/总金额上面的差异或缺少
            //    DataRow verifyDR = VerifyDT.Rows[i];
            //    DataRow cartDR = GetDRFromDT(cartDT, Convert.ToInt32(verifyDR["ID"]));
            //    if (cartDR == null) { return WriteErr("购物车信息不匹配" + refreshTip, Request.RawUrl()); }
            //    foreach (string field in verifyFields)
            //    {
            //        double verifyVal = DataConvert.CDouble(verifyDR[field]);
            //        double cartVal = DataConvert.CDouble(cartDR[field]);
            //        if (verifyVal != cartVal) { return WriteErr("购物车的[" + field + "]不匹配" + refreshTip, Request.RawUrl()); }
            //    }
            //}
            #endregion
            //------生成订单前检测区
            foreach (DataRow dr in cartDT.Rows)
            {
                if (!HasStock(dr["Allowed"], DataConvert.CLng(dr["stock"]), Convert.ToInt32(dr["Pronum"])))
                {
                    return(WriteErr("购买失败," + dr["proname"] + "的库存数量不足"));
                }
            }
            //------检测End
            //按店铺生成订单
            DataTable          storeDT   = cartDT.DefaultView.ToTable(true, "StoreID");
            List <M_OrderList> orderList = new List <M_OrderList>();//用于生成临时订单,统计计算(Disuse)
            foreach (DataRow dr in storeDT.Rows)
            {
                #region 暂不使用字段
                //Odata.province = this.DropDownList1.SelectedValue;
                //Odata.city = this.DropDownList2.SelectedValue;//将地址省份与市ID存入,XML数据源
                //Odata.Guojia = "";//国家
                //Odata.Chengshi = DropDownList2.SelectedItem.Text;//城市
                //Odata.Diqu = DropDownList3.SelectedItem.Text;//地区
                //Odata.Delivery = DataConverter.CLng(Request.Form["Delivery"]);
                //Odata.Deliverytime = DataConverter.CLng(this.Deliverytime.Text);
                //Odata.Mobile = receMod.MobileNum;
                #endregion
                M_OrderList Odata = new M_OrderList();
                Odata.Ordertype = OrderHelper.GetOrderType(ProClass);
                Odata.OrderNo   = B_OrderList.CreateOrderNo((M_OrderList.OrderEnum)Odata.Ordertype);
                Odata.StoreID   = Convert.ToInt32(dr["StoreID"]);
                cartDT.DefaultView.RowFilter = "StoreID=" + Odata.StoreID;
                DataTable storeCartDT = cartDT.DefaultView.ToTable();
                switch (vmMod.ProClass)//旅游机票等,以联系人信息为地址
                {
                case 7:
                case 8:
                    M_Cart_Travel   model = JsonConvert.DeserializeObject <M_Cart_Travel>(storeCartDT.Rows[0]["Additional"].ToString());
                    M_Cart_Contract user  = model.Contract[0];
                    Odata.Receiver  = user.Name;
                    Odata.Phone     = user.Mobile;
                    Odata.MobileNum = user.Mobile;
                    Odata.Email     = user.Email;
                    break;

                default:
                    if (vmMod.ShowAddress)
                    {
                        int    arsID  = DataConvert.CLng(GetParam("address_rad"));
                        string arsChk = GetParam("ars_chk");
                        if (!string.IsNullOrEmpty(arsChk))
                        {
                            #region 自提或微信共享地址
                            switch (arsChk)
                            {
                            case "self":
                            {
                                Odata.Receiver  = "[用户自提]" + GetParam("arsInfo_name");           //用户上门购买,然后自提取商品
                                Odata.MobileNum = GetParam("arsInfo_mobile");
                            }
                            break;

                            case "wechat":
                            {
                                Odata.Receiver  = GetParam("wxad_name");
                                Odata.MobileNum = GetParam("wxad_mobile");
                                Odata.Shengfen  = GetParam("wxad_city");
                                Odata.Jiedao    = GetParam("address");
                            }
                            break;
                            }
                            #endregion
                        }
                        else
                        {
                            M_UserRecei receMod = receBll.GetSelect(arsID, mu.UserID);
                            if (receMod == null)
                            {
                                return(WriteErr("用户尚未选择送货地址,或地址不存在"));
                            }
                            Odata.Receiver  = receMod.ReceivName;
                            Odata.Phone     = receMod.phone;
                            Odata.MobileNum = receMod.MobileNum;
                            Odata.Email     = receMod.Email;
                            Odata.Shengfen  = receMod.Provinces;
                            Odata.Jiedao    = receMod.Street;
                            Odata.ZipCode   = receMod.Zipcode;
                        }
                    }
                    break;
                }
                Odata.Invoiceneeds = DataConverter.CLng(GetParam("invoice_rad"));//是否需开发票
                Odata.Rename       = mu.UserName;
                Odata.AddUser      = mu.UserName;;
                Odata.Userid       = mu.UserID;
                Odata.Ordermessage = GetParam("ORemind_T");//订货留言
                //-----金额计算
                Odata.Balance_price  = GetTotalMoney(storeCartDT);
                Odata.Freight        = GetFarePrice(storeCartDT, Odata.StoreID); //运费计算
                Odata.Ordersamount   = Odata.Balance_price + Odata.Freight;      //订单金额
                Odata.AllMoney_Json  = orderCom.GetTotalJson(storeCartDT);       //附加需要的虚拟币
                Odata.Specifiedprice = Odata.Ordersamount;                       //订单金额;
                Odata.OrderStatus    = (int)M_OrderList.StatusEnum.Normal;       //订单状态
                Odata.Paymentstatus  = (int)M_OrderList.PayEnum.NoPay;           //付款状态
                //Odata.Integral = DataConverter.CLng(Request.QueryString["jifen"]);
                Odata.ExpTime = GetParam("exptime_hid");
                Odata.id      = orderBll.insert(Odata);
                //是否需要开发票
                if (Odata.Invoiceneeds == 1)
                {
                    M_Order_Invoice invMod = new M_Order_Invoice();
                    invMod.OrderID    = Odata.id;
                    invMod.InvHead    = GetParam("InvoTitle_T").Trim(',');
                    invMod.UserCode   = GetParam("InvoUserCode_T").Trim(',');
                    invMod.InvClass   = GetParam("invUseType_rad");
                    invMod.InvContent = GetParam("Invoice_T").Trim(',');
                    invMod.UserID     = Odata.Userid;
                    invBll.Insert(invMod);
                    new B_Order_InvTlp().Sync(invMod);
                }
                cpBll.CopyToCartPro(mu, storeCartDT, Odata.id);
                orderList.Add(Odata);
                orderCom.SendMessage(Odata, null, "ordered");
            }
            cartBll.DelByids(ids);
            //-----------------订单生成后处理
            //进行减库存等操作
            foreach (DataRow dr in cartDT.Rows)
            {
                M_Product model = proBll.GetproductByid(Convert.ToInt32(dr["Proid"]));
                model.Stock = model.Stock - DataConvert.CLng(dr["Pronum"]);
                SqlHelper.ExecuteSql("Update ZL_Commodities Set Stock=" + model.Stock + " Where ID=" + model.ID);
            }
            //生成支付单,处理优惠券,并进入付款步骤
            M_Payment payMod = payBll.CreateByOrder(orderList);
            //优惠券
            if (!string.IsNullOrEmpty(GetParam("Arrive_Hid")))
            {
                M_Arrive        avMod  = avBll.SelModelByFlow(GetParam("Arrive_Hid"), mu.UserID);
                double          money  = payMod.MoneyPay;
                string          remind = "支付单抵扣[" + payMod.PayNo + "]";
                M_Arrive_Result retMod = avBll.U_UseArrive(avMod, mu.UserID, cartDT, money, remind);
                if (retMod.enabled)
                {
                    payMod.MoneyPay     = retMod.money;
                    payMod.ArriveMoney  = retMod.amount;
                    payMod.ArriveDetail = avMod.ID.ToString();
                }
                else
                {
                    payMod.ArriveDetail = "优惠券[" + avMod.ID + "]异常 :" + retMod.err;
                }
            }
            //积分处理
            int maxPoint = Point_CanBeUse(payMod.MoneyPay + payMod.ArriveMoney);
            if (maxPoint > 0 && DataConvert.CLng(GetParam("Point_T")) > 0)
            {
                int point = DataConvert.CLng(GetParam("Point_T"));
                //此处需咨询,上限额度是否要扣减掉优惠券
                //if (point <= 0) {  return WriteErr("积分数值不正确"); }
                if (point > mu.UserExp)
                {
                    return(WriteErr("您的积分不足!"));
                }
                if (point > maxPoint)
                {
                    return(WriteErr("积分不能大于可兑换金额[" + maxPoint + "]!"));
                }
                //生成支付单时扣除用户积分
                buser.ChangeVirtualMoney(mu.UserID, new M_UserExpHis()
                {
                    ScoreType = (int)M_UserExpHis.SType.Point, score = -point, detail = "积分抵扣,支付单号:" + payMod.PayNo
                });
                payMod.UsePoint       = point;
                payMod.UsePointArrive = Point_ToMoney(point);
                payMod.MoneyPay       = payMod.MoneyPay - payMod.UsePointArrive;
            }
            payMod.MoneyReal = payMod.MoneyPay;
            payMod.Remark    = cartDT.Rows.Count > 1 ? "[" + cartDT.Rows[0]["ProName"] as string + "]等" : cartDT.Rows[0]["ProName"] as string;
            payMod.PaymentID = payBll.Add(payMod);
            {
                string notify_url = CustomerPageAction.customPath2 + "Shop/Orderlistinfo?ID=" + orderList[0].id;
                ZoomLa.BLL.User.M_User_Notify notify = new ZoomLa.BLL.User.M_User_Notify();
                notify.Title   = "有新的订单了";
                notify.Content = "<a href='" + notify_url + "' target='main_right' style='font-size:12px;' title='查看详情'>新订单:" + orderList[0].OrderNo + "</a>";
                notify.NType   = 1;
                notify.Gid     = orderList[0].id.ToString();
                notify.AppendReceUser("admin");
                ZoomLa.BLL.User.B_User_Notify.Add(notify);
            }
            return(Redirect("/PayOnline/Orderpay?PayNo=" + payMod.PayNo));
        }
Ejemplo n.º 23
0
        //提交订单
        protected void AddOrder_Btn_Click(object sender, EventArgs e)
        {
            if (Address_Div.Visible && DataConvert.CLng(Request.Form["address_rad"]) < 1)
            {
                function.WriteErrMsg("尚未选定收货地址");
            }
            //1,生成订单,2,关联购物车中商品为已绑定订单
            M_UserInfo  mu      = buser.GetLogin(false);
            M_UserRecei receMod = receBll.GetSelect(Convert.ToInt32(Request.Form["address_rad"]), mu.UserID);
            DataTable   cartDT  = cartBll.SelByCartID(B_Cart.GetCartID(), mu.UserID, ProClass, ids);//需要购买的商品

            if (cartDT.Rows.Count < 1)
            {
                function.WriteErrMsg("你尚未选择商品,<a href='/User/Order/OrderList'>查看我的订单</a>");
            }
            //------生成订单前检测区
            foreach (DataRow dr in cartDT.Rows)
            {
                if (!HasStock(dr["Allowed"], DataConvert.CLng(dr["stock"]), Convert.ToInt32(dr["Pronum"])))
                {
                    function.WriteErrMsg("购买失败," + dr["proname"] + "的库存数量不足");
                }
            }
            //------检测End
            //按店铺生成订单,统一存ZL_Orderinfo
            DataTable          storeDT   = cartDT.DefaultView.ToTable(true, "StoreID");
            List <M_OrderList> orderList = new List <M_OrderList>();//用于生成临时订单,统计计算(Disuse)

            foreach (DataRow dr in storeDT.Rows)
            {
                #region 暂不使用字段
                //Odata.province = this.DropDownList1.SelectedValue;
                //Odata.city = this.DropDownList2.SelectedValue;//将地址省份与市ID存入,XML数据源
                //Odata.Guojia = "";//国家
                //Odata.Chengshi = DropDownList2.SelectedItem.Text;//城市
                //Odata.Diqu = DropDownList3.SelectedItem.Text;//地区
                //Odata.Delivery = DataConverter.CLng(Request.Form["Delivery"]);
                //Odata.Deliverytime = DataConverter.CLng(this.Deliverytime.Text);
                //Odata.Mobile = receMod.MobileNum;
                #endregion
                M_OrderList Odata = new M_OrderList();
                Odata.Ordertype = OrderHelper.GetOrderType(ProClass);
                Odata.OrderNo   = B_OrderList.CreateOrderNo((M_OrderList.OrderEnum)Odata.Ordertype);
                Odata.StoreID   = Convert.ToInt32(dr["StoreID"]);
                cartDT.DefaultView.RowFilter = "StoreID=" + Odata.StoreID;
                DataTable storeCartDT = cartDT.DefaultView.ToTable();
                switch (ProClass)//旅游机票等,以联系人信息为地址
                {
                case 7:
                case 8:
                    M_Cart_Travel   model = JsonConvert.DeserializeObject <M_Cart_Travel>(storeCartDT.Rows[0]["Additional"].ToString());
                    M_Cart_Contract user  = model.Contract[0];
                    Odata.Receiver  = user.Name;
                    Odata.Reuser    = user.Name;
                    Odata.Phone     = user.Mobile;
                    Odata.MobileNum = user.Mobile;
                    Odata.Email     = user.Email;
                    break;

                default:
                    if (Address_Div.Visible)
                    {
                        Odata.Receiver  = receMod.ReceivName;
                        Odata.Reuser    = receMod.ReceivName;
                        Odata.Phone     = receMod.phone;
                        Odata.MobileNum = receMod.MobileNum;
                        Odata.Email     = receMod.Email;
                        Odata.Shengfen  = receMod.Provinces;
                        Odata.Jiedao    = receMod.Street;
                        Odata.ZipCode   = receMod.Zipcode;
                    }
                    break;
                }
                Odata.Invoiceneeds    = DataConverter.CLng(Request.Form["invoice_rad"]);//是否需开发票
                Odata.Invoice         = Odata.Invoiceneeds == 0 ? "" : InvoTitle_T.Text + "||" + Invoice_T.Text;
                Odata.Rename          = mu.UserName;
                Odata.Outstock        = 0;              //缺货处理
                Odata.Ordermessage    = ORemind_T.Text; //订货留言
                Odata.Merchandiser    = "";             //跟单员
                Odata.Internalrecords = "";             //内部记录
                Odata.IsCount         = false;
                //-----金额计算
                Odata.Balance_price     = GetTotalMoney(storeCartDT);
                Odata.Freight           = GetFarePrice(storeCartDT, Odata.StoreID); //运费计算
                Odata.Ordersamount      = Odata.Balance_price + Odata.Freight;      //订单金额
                Odata.AllMoney_Json     = orderCom.GetTotalJson(storeCartDT);       //附加需要的虚拟币
                Odata.Specifiedprice    = Odata.Ordersamount;                       //订单金额;
                Odata.Receivablesamount = 0;                                        //收款金额
                Odata.Developedvotes    = 0;
                Odata.OrderStatus       = (int)M_OrderList.StatusEnum.Normal;       //订单状态
                Odata.Paymentstatus     = (int)M_OrderList.PayEnum.NoPay;           //付款状态
                Odata.StateLogistics    = 0;                                        //物流状态
                Odata.Signed            = 0;                                        //签收
                Odata.Settle            = 0;                                        //结清
                Odata.Aside             = 0;                                        //作废
                Odata.Suspended         = 0;                                        //暂停
                Odata.AddUser           = mu.UserName;;
                Odata.Userid            = mu.UserID;
                Odata.Integral          = DataConverter.CLng(Request.QueryString["jifen"]);
                Odata.Freight_remark    = " ";
                Odata.Balance_remark    = "";
                Odata.Promoter          = 0;
                Odata.id = orderBll.Adds(Odata);
                cartProBll.CopyToCartPro(mu, storeCartDT, Odata.id);
                orderList.Add(Odata);
                orderCom.SendMessage(Odata, null, "ordered");
            }
            cartBll.DelByids(ids);
            //-----------------订单生成后处理
            //进行减库存等操作
            foreach (DataRow dr in cartDT.Rows)
            {
                M_Product model = proBll.GetproductByid(Convert.ToInt32(dr["Proid"]));
                model.Stock = model.Stock - DataConvert.CLng(dr["Pronum"]);
                SqlHelper.ExecuteSql("Update ZL_Commodities Set Stock=" + model.Stock + " Where ID=" + model.ID);
            }
            //生成支付单,处理优惠券,并进入付款步骤
            M_Payment payMod = payBll.CreateByOrder(orderList);
            //优惠券
            if (!string.IsNullOrEmpty(Arrive_Hid.Value))
            {
                M_Arrive avMod  = avBll.SelModelByFlow(Arrive_Hid.Value, mu.UserID);
                double   money  = payMod.MoneyPay;
                string   err    = "";
                string   remind = "支付单抵扣[" + payMod.PayNo + "]";
                if (avBll.U_UseArrive(avMod, mu.UserID, ref money, ref err, remind))
                {
                    payMod.MoneyPay     = money;
                    payMod.ArriveMoney  = avMod.Amount;
                    payMod.ArriveDetail = avMod.ID.ToString();
                }
                else
                {
                    payMod.ArriveDetail = "优惠券[" + avMod.ID + "]异常 :" + err;
                }
            }
            //积分处理
            if (point_body.Visible && DataConvert.CLng(Point_T.Text) > 0)
            {
                int point    = DataConvert.CLng(Point_T.Text);
                int maxPoint = (int)((SiteConfig.ShopConfig.PointRatiot * 0.01) * (double)payMod.MoneyPay / SiteConfig.ShopConfig.PointRate);
                //if (point <= 0) { function.WriteErrMsg("积分数值不正确"); }
                if (point > mu.UserExp)
                {
                    function.WriteErrMsg("您的积分不足!");
                }
                if (point > maxPoint)
                {
                    function.WriteErrMsg("积分不能大于可兑换金额!");
                }
                //生成支付单时扣除用户积分
                buser.ChangeVirtualMoney(mu.UserID, new M_UserExpHis()
                {
                    ScoreType = (int)M_UserExpHis.SType.Point, score = -point, detail = "积分抵扣,支付单号:" + payMod.PayNo
                });
                payMod.MoneyPay = payMod.MoneyPay - (point * SiteConfig.ShopConfig.PointRate);
                payMod.UsePoint = point;
            }
            if (payMod.MoneyPay <= 0)
            {
                payMod.MoneyPay = 0.01;
            }
            payMod.Remark    = cartDT.Rows.Count > 1 ? "[" + cartDT.Rows[0]["ProName"] as string + "]等" : cartDT.Rows[0]["ProName"] as string;
            payMod.PaymentID = payBll.Add(payMod);
            Response.Redirect("/PayOnline/Orderpay.aspx?PayNo=" + payMod.PayNo);
        }
Ejemplo n.º 24
0
        public static void OrderFinish(M_OrderList mod, M_Payment pinfo)
        {
            B_OrderList orderBll = new B_OrderList();
            B_CartPro   cpBll    = new B_CartPro();
            B_User      buser    = new B_User();

            //B_User_Card cdBll = new B_User_Card();
            //B_User_StoreUser suBll = new B_User_StoreUser();
            switch (mod.Ordertype)
            {
            case (int)M_OrderList.OrderEnum.Domain:
            {
                B_Shop_MoneyRegular regBll = new B_Shop_MoneyRegular();
                //M_User_StoreUser suMod = suBll.SelReturnModel(Convert.ToInt32(mod.Receiver));
                //M_User_Card cdMod = cdBll.SelModelByUid(suMod.ID);
                //cdMod.CardPurse += mod.Ordersamount;
                //cdBll.UpdateByID(cdMod);
                int regular = DataConvert.CLng(mod.Money_code);
                M_Shop_MoneyRegular regMod = null;
                if (regular > 0)
                {
                    regMod = regBll.SelReturnModel(regular);
                }
                else
                {
                    regMod     = new M_Shop_MoneyRegular();
                    regMod.Min = mod.Ordersamount;
                }
                buser.AddMoney(DataConvert.CLng(mod.Receiver), regMod.Min + regMod.Purse, M_UserExpHis.SType.Purse, "充值,订单号:" + mod.OrderNo + ",充值:" + regMod.Min + ",赠送:" + regMod.Purse);
                if (regMod.Point > 0)
                {
                    buser.AddMoney(DataConvert.CLng(mod.Receiver), regMod.Point, M_UserExpHis.SType.Point, "充值赠送积分,订单号:" + mod.OrderNo);
                }
            }
            break;

            case (int)M_OrderList.OrderEnum.Cloud:    //通过微信下的预约订单
            {
                //付款后增加预约记录,由收银员完成开单
                //{ id: 0, proid: 0, proname: "", empid: 0, empname: "" };
                DataTable cpDT = cpBll.SelByOrderID(mod.id);
                List <M_Ex_PreOrder_Item> itemList = new List <M_Ex_PreOrder_Item>();
                foreach (DataRow dr in cpDT.Rows)
                {
                    M_Ex_PreOrder_Item model = new M_Ex_PreOrder_Item();
                    model.proid   = Convert.ToInt32(dr["ProID"]);
                    model.proname = DataConvert.CStr(dr["Proname"]);
                    model.empid   = DataConvert.CLng(dr["code"]);
                    model.empname = DataConvert.CStr(dr["Proinfo"]);
                    itemList.Add(model);
                }
                B_Ex_PreOrder poBll = new B_Ex_PreOrder();
                M_Ex_PreOrder poMod = new M_Ex_PreOrder();
                poMod.ClientMobile = mod.Mobile.ToString();
                poMod.ClientName   = mod.Rename;
                poMod.ClientDate   = DataConvert.CDate(mod.ExpTime);
                poMod.ClientNeed   = JsonConvert.SerializeObject(itemList);
                poMod.Remark       = mod.Ordermessage;
                poMod.Source       = "微信";
                poMod.OrderID      = mod.id;
                poMod.ID           = poBll.Insert(poMod);
            }
            break;

            default:    //普通订单,计算提成,赠送积分
            {
                B_Shop_Bonus bnBll = new B_Shop_Bonus();
                DataTable    cpDT  = cpBll.SelByOrderID(mod.id);
                foreach (DataRow dr in cpDT.Rows)
                {
                    int    code     = DataConvert.CLng(dr["code"]);
                    int    proid    = DataConvert.CLng(dr["Proid"]);
                    double allMoney = DataConvert.CDouble(dr["AllMoney"]);
                    if (code < 1)
                    {
                        continue;
                    }
                    #region 技师计算提成
                    //技师绑定了何种分成方案,
                    M_UserInfo   jsMod = buser.SelReturnModel(code);
                    M_Shop_Bonus bnMod = null;
                    if (jsMod.VIP < 1)
                    {
                        bnMod = bnBll.SelModelByDefault();
                    }
                    else
                    {
                        bnMod = bnBll.SelReturnModel(jsMod.VIP);
                    }
                    //无提成方案则不计算
                    if (bnMod != null)
                    {
                        //根据商品ID,看有无匹配的子数据类型
                        M_Shop_Bonus bnMod2 = bnBll.SelModelByProID(bnMod.ID, proid);
                        if (bnMod2 != null)
                        {
                            bnMod = bnMod2;
                        }
                        //-------计算提成,写入CartPro中
                        double bonus = 0;
                        switch (bnMod.BonusType)
                        {
                        case 0:
                            bonus = allMoney * (DataConvert.CDouble(bnMod.BonusValue1) * 0.01);
                            break;

                        case 1:
                            bonus = DataConvert.CDouble(bnMod.BonusValue1);
                            break;
                        }
                        DBCenter.UpdateSQL("ZL_CartPro", "AllMoney_Json='" + bonus.ToString("F2") + "'", "ID=" + dr["ID"]);
                    }
                    #endregion
                }
                //-------赠送积分,默认每一元送一分
                buser.AddMoney(DataConvert.CLng(mod.Receiver), mod.Receivablesamount, M_UserExpHis.SType.Point, "订单[" + mod.id + "]赠送积分");
            }
            break;
            }
        }
Ejemplo n.º 25
0
    protected void AddOrder_Btn_Click(object sender, EventArgs e)
    {
        //1,生成订单,2,关联购物车中商品为已绑定订单
        M_UserInfo mu = buser.GetLogin(false);

        CartDT = cartBll.SelByCartID(B_Cart.GetCartID(), mu.UserID, ProClass, ids);//需要购买的商品
        if (CartDT.Rows.Count < 1)
        {
            function.WriteErrMsg("你尚未选择商品,<a href='/Extend/Mobile/UserOrder.aspx'>查看我的订单</a>");
        }
        CartDT.DefaultView.RowFilter = "StoreID=" + StoreID;
        CartDT = CartDT.DefaultView.ToTable();
        //------生成订单前检测区
        foreach (DataRow dr in CartDT.Rows)
        {
            if (!HasStock(dr["Allowed"], DataConvert.CLng(dr["stock"]), Convert.ToInt32(dr["Pronum"])))
            {
                function.WriteErrMsg("购买失败," + dr["proname"] + "的库存数量不足");
            }
        }
        //------检测End
        //按店铺生成订单
        DataTable          storeDT   = CartDT.DefaultView.ToTable(true, "StoreID");
        List <M_OrderList> orderList = new List <M_OrderList>();//用于生成临时订单,统计计算(Disuse)

        foreach (DataRow dr in storeDT.Rows)
        {
            #region 暂不使用字段
            //Odata.province = this.DropDownList1.SelectedValue;
            //Odata.city = this.DropDownList2.SelectedValue;//将地址省份与市ID存入,XML数据源
            //Odata.Guojia = "";//国家
            //Odata.Chengshi = DropDownList2.SelectedItem.Text;//城市
            //Odata.Diqu = DropDownList3.SelectedItem.Text;//地区
            //Odata.Delivery = DataConverter.CLng(Request.Form["Delivery"]);
            //Odata.Deliverytime = DataConverter.CLng(this.Deliverytime.Text);
            //Odata.Mobile = receMod.MobileNum;
            #endregion
            M_OrderList Odata = new M_OrderList();
            //通过微信支付的预购订单[special]
            Odata.Ordertype = (int)M_OrderList.OrderEnum.Cloud;
            Odata.OrderNo   = B_OrderList.CreateOrderNo((M_OrderList.OrderEnum)Odata.Ordertype);
            Odata.StoreID   = Convert.ToInt32(dr["StoreID"]);
            CartDT.DefaultView.RowFilter = "StoreID=" + Odata.StoreID;
            DataTable storeCartDT = CartDT.DefaultView.ToTable();
            //M_UserRecei receMod = receBll.GetSelect(arsID, mu.UserID);
            //if (receMod == null) { function.WriteErrMsg("用户尚未选择送货地址,或地址不存在"); }

            //直接使用微信获取的用户信息填充
            Odata.Receiver = mu.UserID.ToString();
            Odata.Rename   = mu.HoneyName;
            Odata.AddUser  = mu.UserName;;
            Odata.Userid   = mu.UserID;
            //Odata.Phone = receMod.phone;
            //Odata.MobileNum = receMod.MobileNum;
            //Odata.Email = receMod.Email;
            //Odata.Shengfen = receMod.Provinces;
            //Odata.Jiedao = receMod.Street;
            //Odata.ZipCode = receMod.Zipcode;


            Odata.Invoiceneeds = DataConverter.CLng(Request.Form["invoice_rad"]); //是否需开发票

            Odata.Ordermessage = ORemind_T.Text;                                  //订货留言
                                                                                  //-----金额计算
            Odata.Balance_price  = GetTotalMoney(storeCartDT);
            Odata.Freight        = 0;
            Odata.Ordersamount   = Odata.Balance_price + Odata.Freight; //订单金额
            Odata.AllMoney_Json  = orderCom.GetTotalJson(storeCartDT);  //附加需要的虚拟币
            Odata.Specifiedprice = Odata.Ordersamount;                  //订单金额;
            Odata.OrderStatus    = (int)M_OrderList.StatusEnum.Normal;  //订单状态
            Odata.Paymentstatus  = (int)M_OrderList.PayEnum.NoPay;      //付款状态
                                                                        //Odata.Integral = DataConverter.CLng(Request.QueryString["jifen"]);
            //Odata.ExpTime = exptime_hid.Value;
            Odata.id = orderBll.insert(Odata);
            cartProBll.CopyToCartPro(mu, storeCartDT, Odata.id);
            orderList.Add(Odata);
            orderCom.SendMessage(Odata, null, "ordered");
        }
        cartBll.DelByids(ids);
        //-----------------订单生成后处理
        //进行减库存等操作
        foreach (DataRow dr in CartDT.Rows)
        {
            M_Product model = proBll.GetproductByid(Convert.ToInt32(dr["Proid"]));
            model.Stock = model.Stock - DataConvert.CLng(dr["Pronum"]);
            SqlHelper.ExecuteSql("Update ZL_Commodities Set Stock=" + model.Stock + " Where ID=" + model.ID);
        }
        //生成支付单,处理优惠券,并进入付款步骤
        M_Payment payMod = payBll.CreateByOrder(orderList);
        //优惠券
        //if (!string.IsNullOrEmpty(Request.Form["Arrive_Hid"]))
        //{
        //    M_Arrive avMod = avBll.SelModelByFlow(Request.Form["Arrive_Hid"], mu.UserID);
        //    double money = payMod.MoneyPay;
        //    string remind = "支付单抵扣[" + payMod.PayNo + "]";
        //    M_Arrive_Result retMod = avBll.U_UseArrive(avMod, mu.UserID, cartDT, money, remind);
        //    if (retMod.enabled)
        //    {
        //        payMod.MoneyPay = retMod.money;
        //        payMod.ArriveMoney = retMod.amount;
        //        payMod.ArriveDetail = avMod.ID.ToString();
        //    }
        //    else { payMod.ArriveDetail = "优惠券[" + avMod.ID + "]异常 :" + retMod.err; }
        //}
        //积分处理
        //if (point_body.Visible && DataConvert.CLng(Point_T.Text) > 0)
        //{
        //    int point = DataConvert.CLng(Point_T.Text);
        //    //此处需咨询,上限额度是否要扣减掉优惠券

        //    int maxPoint = Point_CanBeUse(payMod.MoneyPay + payMod.ArriveMoney);
        //    //if (point <= 0) { function.WriteErrMsg("积分数值不正确"); }
        //    if (point > mu.UserExp) { function.WriteErrMsg("您的积分不足!"); }
        //    if (point > maxPoint) { function.WriteErrMsg("积分不能大于可兑换金额[" + maxPoint + "]!"); }
        //    //生成支付单时扣除用户积分
        //    buser.ChangeVirtualMoney(mu.UserID, new M_UserExpHis() { ScoreType = (int)M_UserExpHis.SType.Point, score = -point, detail = "积分抵扣,支付单号:" + payMod.PayNo });
        //    payMod.UsePoint = point;
        //    payMod.UsePointArrive = Point_ToMoney(point);
        //    payMod.MoneyPay = payMod.MoneyPay - payMod.UsePointArrive;
        //}
        payMod.MoneyReal = payMod.MoneyPay;
        payMod.Remark    = CartDT.Rows.Count > 1 ? "[" + CartDT.Rows[0]["ProName"] as string + "]等" : CartDT.Rows[0]["ProName"] as string;
        payMod.PaymentID = payBll.Add(payMod);
        Response.Redirect("/PayOnline/wxpay_mp.aspx?PayNo=" + payMod.PayNo);
        //Response.Redirect("/PayOnline/Orderpay.aspx?PayNo=" + payMod.PayNo);
    }