public void MyBind()
        {
            M_UserInfo mu = SnsHelper.GetLogin();

            CartDT = SelByCartID(B_Cart.GetCartID(), mu.UserID, ProClass, ids);
            if (CartDT.Rows.Count < 1)
            {
                function.WriteErrMsg("You have not yet chosen the goods");
            }
            //------核算费用
            allmoney = UpdateCartAllMoney(CartDT);
            //------费用统计
            itemnum_span.InnerText     = CartDT.Rows.Count.ToString();
            totalmoney_span1.InnerText = allmoney.ToString("f2");
            //------店铺
            Store_RPT.DataSource = orderCom.SelStoreDT(CartDT);
            Store_RPT.DataBind();
        }
    public void MyBind()
    {
        StringWriter sw = new StringWriter();
        M_UserInfo   mu = buser.GetLogin(false);

        CartDT = cartBll.SelByCartID(B_Cart.GetCartID(), mu.UserID, ProClass, ids);
        CartDT.DefaultView.RowFilter = "StoreID=" + StoreID;
        CartDT = CartDT.DefaultView.ToTable();
        if (CartDT.Rows.Count < 1)
        {
            function.WriteErrMsg("你尚未选择商品,<a href='/Extend/Mobile/UserOrder.aspx'>查看我的订单</a>");
        }
        //------核算费用
        allmoney = UpdateCartAllMoney(CartDT);
        //------费用统计
        itemnum_span.InnerText     = CartDT.Rows.Count.ToString();
        totalmoney_span1.InnerText = allmoney.ToString("f2");
        //------店铺
        Store_RPT.DataSource = orderCom.SelStoreDT(CartDT);
        Store_RPT.DataBind();
        //------发票绑定
        Server.Execute("/Cart/Comp/Invoice.aspx", sw);
        sw = new StringWriter();
        //------积分抵扣
        //{
        //    int usepoint = Point_CanBeUse(allmoney);
        //    if (usepoint > 0)
        //    {
        //        point_body.Visible = true;
        //        Point_L.Text = mu.UserExp.ToString();
        //        //int usepoint = (int)(allmoney * (SiteConfig.ShopConfig.PointRatiot * 0.01));
        //        function.Script(this, "SumByPoint(" + usepoint + ");");
        //        PointRate_Hid.Value = SiteConfig.ShopConfig.PointRate.ToString("F2");
        //    }
        //    else
        //    {
        //        point_tips.Visible = true;
        //    }
        //}
        //------优惠券
        Server.Execute("/Cart/Comp/ArriveList.aspx?allmoney=" + allmoney + "&ids=" + ids, sw);
        Arrive_Lit.Text = sw.ToString();
    }
Exemple #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            M_UserInfo mu       = buser.GetLogin();
            double     allmoney = DataConvert.CDouble(Request["allmoney"]);
            string     ids      = DataConvert.CStr(Request.QueryString["ids"]);
            //------用户有哪些未使用的优惠券
            DataTable avdt   = avBll.U_Sel(mu.UserID, -100, 1);
            DataTable cartdt = null;

            if (avdt.Rows.Count < 1)
            {
                arrive_empty_div.Visible = true; return;
            }
            else
            {
                arrive_div.Style.Add("display", "block");
                arrive_data_div.Visible = true;
                avdt.Columns.Add("enable", typeof(int)); //优惠券是否有效 1:有效
                avdt.Columns.Add("err", typeof(string)); //不能使用的原因
                cartdt = cartBll.SelByCartID(B_Cart.GetCartID(), mu.UserID, -100, ids);
            }
            //---------------------------------------Logical
            for (int i = 0; i < avdt.Rows.Count; i++)
            {
                DataRow         dr     = avdt.Rows[i];
                M_Arrive        avMod  = new M_Arrive().GetModelFromReader(dr);
                double          money  = allmoney;
                M_Arrive_Result retMod = avBll.U_CheckArrive(avMod, mu.UserID, cartdt, money);
                dr["enable"] = retMod.enabled ? 1 : 0;
                dr["err"]    = retMod.err;
            }
            avdt.DefaultView.RowFilter   = "enable='1'";
            Arrive_Active_RPT.DataSource = avdt.DefaultView.ToTable();
            Arrive_Active_RPT.DataBind();
            avdt.DefaultView.RowFilter    = "enable='0'";
            Arrive_Disable_RPT.DataSource = avdt.DefaultView.ToTable();
            Arrive_Disable_RPT.DataBind();
        }
        protected void AddOrder_Btn_Click(object sender, EventArgs e)
        {
            //1,生成订单,2,关联购物车中商品为已绑定订单
            M_UserInfo mu     = SnsHelper.GetLogin();
            DataTable  cartDT = SelByCartID(B_Cart.GetCartID(), mu.UserID, ProClass, ids);//需要购买的商品

            if (cartDT.Rows.Count < 1)
            {
                function.WriteErrMsg("You have not yet chosen the goods");
            }
            //------检测End
            //按店铺生成订单
            DataTable          storeDT   = cartDT.DefaultView.ToTable(true, "StoreID");
            List <M_OrderList> orderList = new List <M_OrderList>();//用于生成临时订单,统计计算(Disuse)

            foreach (DataRow dr in storeDT.Rows)
            {
                M_OrderList Odata = new M_OrderList();
                Odata.Ordertype = OrderHelper.GetOrderType(ProClass);

                Odata.OrderNo = GetOrderNo();
                Odata.StoreID = Convert.ToInt32(dr["StoreID"]);
                cartDT.DefaultView.RowFilter = "StoreID=" + Odata.StoreID;
                DataTable storeCartDT = cartDT.DefaultView.ToTable();


                Odata.Promoter     = TipID;
                Odata.Invoiceneeds = DataConverter.CLng(Request.Form["invoice_rad"]);//是否需开发票
                //Odata.Invoice = Odata.Invoiceneeds == 0 ? "" : InvoTitle_T.Text + "||" + Invoice_T.Text;
                Odata.Rename       = mu.UserName;
                Odata.AddUser      = mu.UserName;;
                Odata.Userid       = mu.UserID;
                Odata.Ordermessage = Server.HtmlEncode((Request.Form["orderMsg"] ?? ""));// 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;
                M_Grade countryMod = B_GradeOption.GetGradeOption(Convert.ToInt32(Request.Form["country"]));
                M_Grade stateMod   = B_GradeOption.GetGradeOption(Convert.ToInt32(Request.Form["state"]));
                Odata.Money_rate = 0;

                Odata.Receiver  = Request.Form["FullName"];
                Odata.Phone     = Request.Form["phone"];
                Odata.MobileNum = Request.Form["phone"];
                Odata.Email     = Request.Form["email"];
                Odata.Diqu      = countryMod.GradeName;
                Odata.Shengfen  = stateMod.GradeName;
                Odata.Chengshi  = Request.Form["city"];
                Odata.Jiedao    = Request.Form["address"];
                Odata.ZipCode   = Request.Form["zip"];



                Odata.id = orderBll.insert(Odata);
                CopyToCartPro(mu, storeCartDT, Odata.id);
                orderList.Add(Odata);
                //orderCom.SendMessage(Odata, null, "ordered");
                //-----联系人
                B_Order_Contact conBll = new B_Order_Contact();
                M_Order_Contact conMod = new M_Order_Contact();

                conMod.OrderID  = Odata.id;
                conMod.FullName = Request.Form["fullname"];
                conMod.Email    = Request.Form["email"];
                conMod.Address  = Request.Form["address"];
                conMod.City     = Request.Form["city"];
                conMod.State    = stateMod.GradeName;
                conMod.Country  = countryMod.GradeName;
                conMod.Zip      = Request.Form["zip"];
                conMod.Phone    = Request.Form["phone"];
                conMod.Remark   = "";
                conBll.Insert(conMod);
            }
            //cartBll.DelByids(ids);//客户希望保留购物车中信息
            //-----------------订单生成后处理
            M_Payment payMod = payBll.CreateByOrder(orderList);

            //优惠券,编号与密码
            if (!string.IsNullOrEmpty(Coupon_Num.Text))
            {
                B_Ex_Coupon cupBll = new B_Ex_Coupon();
                string      code   = Coupon_Num.Text.Trim();
                //string pwd = Coupon_Pwd.Text.Trim();
                //M_Arrive avMod = SnsHelper.AV_SelModel(code);
                //M_Arrive_Result retMod = SnsHelper.CheckArrive(code, pwd, payMod.MoneyPay);
                //if (retMod.enabled)
                //{
                //    payMod.MoneyPay = retMod.money;
                //    payMod.ArriveMoney = retMod.amount;
                //    payMod.ArriveDetail = "优惠券号:" + code + ",密码:" + pwd;
                //    SnsHelper.Use_Arrive(avMod, "支付单[" + payMod.PayNo + "]使用,优惠金额:" + retMod.amount.ToString("F2"));
                //}
                //else { function.WriteErrMsg(retMod.err); }
                M_Arrive_Result retMod = cupBll.CheckArrive(code, payMod.MoneyPay);
                if (retMod.enabled)
                {
                    payMod.MoneyPay     = retMod.money;
                    payMod.ArriveMoney  = retMod.amount;
                    payMod.ArriveDetail = "优惠券号:" + code;
                }
            }
            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);
            //取消下面注释激活下单立即发送邮件
            EventDeal.SendOrderEmailByType(orderList[0].id, "order", SiteConfig.SiteInfo.WebmasterEmail);
            Response.Cookies["agree_save"].Value   = Request.Form["agree_save_chk"];
            Response.Cookies["agree_save"].Expires = DateTime.Now.AddYears(1);
            Response.Redirect("/PayOnline/Orderpay.aspx?PayNo=" + payMod.PayNo);
        }
Exemple #5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     platMod = new B_PayPlat().SelModelByClass(M_PayPlat.Plat.PayPal);
     try
     {
         if (CheckSign())
         {
             string payno  = executedPayment.transactions[0].invoice_number;
             double amount = DataConvert.CDouble(executedPayment.transactions[0].related_resources[0].sale.amount.total);
             PaySuccess(payno, amount);
             //-----------------
             payMod   = payBll.SelModelByPayNo(payno);
             orderMod = orderBll.SelModelByOrderNo(payMod.PaymentNum.Trim(','));
             M_Order_Contact conMod = new B_Order_Contact().SelModelByOid(orderMod.id);
             PayNo_L.Text   = payMod.PayNo;
             OrderNo_L.Text = orderMod.OrderNo;
             Amount_L.Text  = payMod.MoneyPay.ToString("F2");
             Email_L.Text   = conMod.Email;
             DBCenter.DelByWhere("ZL_Cart", "CartId=@cartid", new List <SqlParameter>()
             {
                 new SqlParameter("cartid", B_Cart.GetCartID(Context))
             });
             EventDeal.SendOrderEmailByType(orderMod.id, "payed", SiteConfig.SiteInfo.WebmasterEmail);
             EventDeal.SendOrderEmailByType(orderMod.id, "payed");
         }
         else
         {
             ZLLog.L(ZLEnum.Log.pay, "[" + PayPlat + "]签名验证失败,返回:" + ServerReturn);
             function.WriteErrMsg("Validation failed, information mismatch");
         }
     }
     catch (Exception ex)
     {
         Log("[" + PayPlat + "]出错,原因:" + ex.Message + ",返回:" + ServerReturn);
         success_div.Visible = false;
         fail_div.Visible    = true;
         //------------------------------------
         payMod = payBll.SelModelByPayNo(Request["payno"]);
         if (payMod == null)
         {
             function.WriteErrMsg("order does not exist");
         }
         if (payMod.Status != (int)M_Payment.PayStatus.NoPay)
         {
             function.WriteErrMsg("The order has been paid and cannot be repeated");
         }
         orderMod            = orderBll.SelModelByOrderNo(payMod.PaymentNum.Trim(','));
         Fail_PayNo_L.Text   = payMod.PayNo;
         Fail_OrderNo_L.Text = orderMod.OrderNo;
         Fail_Amount_L.Text  = payMod.MoneyPay.ToString("F2");
         //------------------------------------
         //if (string.IsNullOrEmpty(payMod.code))
         //{
         //    string cartId = B_Cart.GetCartID(Context);
         //    B_Cart cartBll = new B_Cart();
         //    B_CartPro cpBll = new B_CartPro();
         //    DataTable cartDT = cpBll.SelByOrderID(orderMod.id);
         //    foreach (DataRow cartDR in cartDT.Rows)
         //    {
         //        M_Cart cartMod = new M_Cart().GetModelFromReader(cartDR);
         //        cartMod.userid = 10000;
         //        cartMod.Cartid = cartId;
         //        cartMod.ProAttr = DataConvert.CStr(cartDR["Attribute"]);
         //        cartBll.insert(cartMod);
         //    }
         //    DBCenter.UpdateSQL(payMod.TbName,"Code='1'", "PaymentID=" + payMod.PaymentID);
         //}
         //function.WriteErrMsg("Error:Unfinished payment");
     }
 }
    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);
    }
Exemple #7
0
        public void MyBind()
        {
            M_UserInfo mu = buser.GetLogin();

            CartDT = cartBll.SelByCartID(B_Cart.GetCartID(), mu.UserID, ProClass, ids);
            if (CartDT.Rows.Count < 1)
            {
                function.WriteErrMsg("你尚未选择商品,<a href='/User/Order/OrderList'>查看我的订单</a>");
            }
            //旅游,酒店等不需要检测地址栏
            switch (DataConvert.CLng(CartDT.Rows[0]["ProClass"]))
            {
            case (int)M_Product.ClassType.LY:
            {
                userli.Visible = true;
                M_Cart_Travel model = JsonConvert.DeserializeObject <M_Cart_Travel>(CartDT.Rows[0]["Additional"].ToString());
                model.Guest.AddRange(model.Contract);
                UserRPT.DataSource = model.Guest;
                UserRPT.DataBind();
            }
            break;

            case (int)M_Product.ClassType.JD:
            {
                userli.Visible = true;
                M_Cart_Hotel model = JsonConvert.DeserializeObject <M_Cart_Hotel>(CartDT.Rows[0]["Additional"].ToString());
                model.Guest.AddRange(model.Contract);
                UserRPT.DataSource = model.Guest;
                UserRPT.DataBind();
            }
            break;

            default:     //------地址
                DataTable addressDT = receBll.SelByUID(buser.GetLogin().UserID);
                AddressRPT.DataSource = addressDT;
                AddressRPT.DataBind();
                EmptyDiv.Visible = addressDT.Rows.Count < 1;    //地址为空提醒
                break;
            }
            //------核算费用
            allmoney = UpdateCartAllMoney(CartDT);
            //------费用统计
            itemnum_span.InnerText     = CartDT.Rows.Count.ToString();
            totalmoney_span1.InnerText = allmoney.ToString("f2");
            //------店铺
            Store_RPT.DataSource = orderCom.SelStoreDT(CartDT);
            Store_RPT.DataBind();
            //------发票绑定
            DataTable invoceDT = new DataTable();//orderBll.SelInvoByUser(buser.GetLogin().UserID);

            if (invoceDT.Rows.Count > 0)
            {
                Invoice_RPT.DataSource = invoceDT;
                Invoice_RPT.DataBind();
            }
            else
            {
                Invoice_RPT.Visible = false;
            }
            //------积分抵扣
            if (SiteConfig.ShopConfig.PointRatiot > 0 && SiteConfig.ShopConfig.PointRatiot < 100 && SiteConfig.ShopConfig.PointRate > 0)
            {
                point_body.Visible = true;
                M_UserInfo usermod = buser.GetLogin();
                Point_L.Text = usermod.UserExp.ToString();
                int usepoint = (int)(allmoney * (SiteConfig.ShopConfig.PointRatiot * 0.01) / SiteConfig.ShopConfig.PointRate);
                function.Script(this, "SumByPoint(" + usepoint + ");");
                PointRate_Hid.Value = SiteConfig.ShopConfig.PointRate.ToString();
            }
            else
            {
                point_tips.Visible = true;
            }
            //------用户有哪些优惠券
            DataTable avdt = avBll.U_Sel(mu.UserID, -100, 1);

            if (avdt.Rows.Count > 0)
            {
                arrive_div.Style.Add("display", "block");
                arrive_data_div.Visible = true;
                avdt.Columns.Add("enable", typeof(int));
                avdt.Columns.Add("err", typeof(string));
                for (int i = 0; i < avdt.Rows.Count; i++)
                {
                    DataRow dr    = avdt.Rows[i];
                    double  money = allmoney;
                    string  err   = "";
                    dr["enable"] = avBll.U_CheckArrive(new M_Arrive().GetModelFromReader(dr), mu.UserID, ref money, ref err) ? 1 : 0;
                    dr["err"]    = err;
                }
                avdt.DefaultView.RowFilter = "enable='1'";
                //function.WriteErrMsg(avdt.DefaultView.ToTable().Rows.Count.ToString());
                Arrive_Active_RPT.DataSource = avdt.DefaultView.ToTable();
                Arrive_Active_RPT.DataBind();
                avdt.DefaultView.RowFilter    = "enable='0'";
                Arrive_Disable_RPT.DataSource = avdt.DefaultView.ToTable();
                Arrive_Disable_RPT.DataBind();
            }
            else
            {
                arrive_empty_div.Visible = true;
            }
        }
Exemple #8
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);
        }
Exemple #9
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));
        }
Exemple #10
0
        public void MyBind()
        {
            StringWriter sw = new StringWriter();
            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='/User/Order/OrderList'>查看我的订单</a>");
            }
            #region 旅游,酒店等不需要检测地址栏
            switch (DataConvert.CLng(CartDT.Rows[0]["ProClass"]))
            {
            case (int)M_Product.ClassType.LY:
            {
                userli.Visible = true;
                M_Cart_Travel model = JsonConvert.DeserializeObject <M_Cart_Travel>(CartDT.Rows[0]["Additional"].ToString());
                model.Guest.AddRange(model.Contract);
                UserRPT.DataSource = model.Guest;
                UserRPT.DataBind();
            }
            break;

            case (int)M_Product.ClassType.JD:
            {
                userli.Visible = true;
                M_Cart_Hotel model = JsonConvert.DeserializeObject <M_Cart_Hotel>(CartDT.Rows[0]["Additional"].ToString());
                model.Guest.AddRange(model.Contract);
                UserRPT.DataSource = model.Guest;
                UserRPT.DataBind();
            }
            break;

            default:     //------地址
                break;
            }
            #endregion
            //------核算费用
            allmoney = UpdateCartAllMoney(CartDT);
            //------费用统计
            itemnum_span.InnerText     = CartDT.Rows.Count.ToString();
            totalmoney_span1.InnerText = allmoney.ToString("f2");
            //------店铺
            Store_RPT.DataSource = orderCom.SelStoreDT(CartDT);
            Store_RPT.DataBind();
            //------发票绑定
            Server.Execute("/Cart/Comp/Invoice.aspx", sw);
            Invoice_Lit.Text = sw.ToString();
            sw = new StringWriter();
            //------积分抵扣
            {
                int usepoint = Point_CanBeUse(allmoney);
                if (usepoint > 0)
                {
                    point_body.Visible = true;
                    Point_L.Text       = mu.UserExp.ToString();
                    //int usepoint = (int)(allmoney * (SiteConfig.ShopConfig.PointRatiot * 0.01));
                    function.Script(this, "SumByPoint(" + usepoint + ");");
                    PointRate_Hid.Value = SiteConfig.ShopConfig.PointRate.ToString("F2");
                }
                else
                {
                    point_tips.Visible = true;
                }
            }
            //------优惠券
            Server.Execute("/Cart/Comp/ArriveList.aspx?allmoney=" + allmoney + "&ids=" + ids, sw);
            Arrive_Lit.Text = sw.ToString();
        }