protected void BatDel_Click(object sender, EventArgs e)
        {
            string ids = Request.Form["idchk"];

            if (!string.IsNullOrEmpty(ids))
            {
                bll.DelByids(ids);
                function.WriteSuccessMsg("删除成功");
            }
            MyBind();
        }
Ejemplo n.º 2
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.º 3
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);
    }
Ejemplo n.º 4
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.º 5
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));
        }