Пример #1
0
    //用于后台确认支付
    public static void FinalStep(M_OrderList mod)
    {
        if (mod.id < 1)
        {
            throw new Exception("未指定订单ID");
        }
        if (mod.Ordertype < 1)
        {
            throw new Exception("未指定订单类型");
        }
        if (string.IsNullOrEmpty(mod.OrderNo))
        {
            throw new Exception("未指定订单号");
        }
        M_AdminInfo adminMod = B_Admin.GetLogin();
        B_Payment   payBll   = new B_Payment();
        M_Payment   pinfo    = new M_Payment();

        pinfo.PaymentNum   = mod.OrderNo;
        pinfo.UserID       = mod.Userid;
        pinfo.PayNo        = payBll.CreatePayNo();
        pinfo.MoneyPay     = (decimal)mod.Ordersamount;
        pinfo.MoneyTrue    = pinfo.MoneyPay;//看是否需要支持手输
        pinfo.Status       = (int)M_Payment.PayStatus.HasPayed;
        pinfo.CStatus      = true;
        pinfo.Remark       = "管理员确认支付,ID:" + adminMod.AdminId + ",登录名:" + adminMod.AdminName + ",真实姓名:" + adminMod.AdminTrueName;
        pinfo.PaymentID    = payBll.Add(pinfo);
        pinfo.SuccessTime  = DateTime.Now;
        pinfo.PayPlatID    = (int)M_PayPlat.Plat.CashOnDelivery;//默认为线下支付
        pinfo.PlatformInfo = "";
        M_Order_PayLog paylogMod = new M_Order_PayLog();

        FinalStep(pinfo, mod, paylogMod);
    }
Пример #2
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);
        }
Пример #3
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);
    }
Пример #4
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
            {
                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"]));
                    orderBll.Update(orderMod);
                }
                pinfo.PaymentNum = OrderNo;
                pinfo.MoneyPay   = allamount;
                DataTable cartDT = new DataTable();
                if (orderMod.id > 0)
                {
                    cartDT       = bcart.GetCartProOrderID(orderMod.id);
                    pinfo.Remark = cartDT.Rows.Count > 1 ? "[" + cartDT.Rows[0]["ProName"] as string + "]等" : cartDT.Rows[0]["ProName"] as string;
                }
                else
                {
                    pinfo.Remark = "没有对应订单";
                }
            }
            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 + "&StoreID=" + StoreID;

            if (pinfo.PayPlatID == 0)
            {
                url += "&method=" + Request.Form["payplat_rad"];
            }
            Response.Redirect(url);
        }