示例#1
0
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int index = Convert.ToInt32(e.CommandArgument);

        MojoCube.Web.Order.List order = new MojoCube.Web.Order.List();
        order.GetData(int.Parse(((Label)GridView1.Rows[index].FindControl("lblID")).Text));

        //取消订单
        if (e.CommandName == "_cancel")
        {
            order.StatusID   = 4;
            order.CancelDate = DateTime.Now.ToString();
        }

        //确认收货
        if (e.CommandName == "_complete")
        {
            order.StatusID = 3;
            order.EndDate  = DateTime.Now.ToString();
        }

        //标记删除
        if (e.CommandName == "_delete")
        {
            order.IsDeleted = true;
        }

        order.UpdateData(order.pk_Order);
        Response.Redirect(MojoCube.Web.Site.Cache.GetUrlExtension("Order", MojoCube.Api.UI.Language.GetLanguage()));
    }
示例#2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["id"] == null)
            {
                Response.Redirect(MojoCube.Web.Site.Cache.GetUrlExtension("Order", strLanguage));
            }

            ViewState["pk_Order"] = MojoCube.Api.Text.Security.DecryptString(Request.QueryString["id"]);

            MojoCube.Web.Order.List order = new MojoCube.Web.Order.List();
            order.GetData(int.Parse(ViewState["pk_Order"].ToString()));

            if (order.IsComment || order.fk_Member.ToString() != Session["Member_UserID"].ToString())
            {
                Response.Redirect(MojoCube.Web.Site.Cache.GetUrlExtension("Order", strLanguage));
            }

            lblOrderNumber.Text = order.OrderNumber;
            lblDescription.Text = order.Description;
            lblAmount.Text      = MojoCube.Web.String.GetCurrency(order.Amount);

            GridBind();
            WUC_MemberMenu.CssFocus = "id=\"\"";
            BannerDiv.InnerHtml     = MojoCube.Web.Site.Cache.GetSiteBanner(strLanguage, 1);
            this.Title            = MojoCube.Web.String.GetTitle(hlTitle.Text, MojoCube.Web.Site.Cache.GetSiteTitle(strLanguage));
            hlProduct.NavigateUrl = MojoCube.Web.Site.Cache.GetUrlExtension("Product", strLanguage);
            hlOrder.NavigateUrl   = MojoCube.Web.Site.Cache.GetUrlExtension("Order", strLanguage);
        }
    }
示例#3
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        MojoCube.Web.Order.List order = new MojoCube.Web.Order.List();
        order.GetData(int.Parse(ViewState["pk_Order"].ToString()));

        order.IsComment = true;
        order.UpdateData(order.pk_Order);

        if (GridView1.Rows.Count > 0)
        {
            MojoCube.Web.Member.List member = new MojoCube.Web.Member.List();
            member.GetData(int.Parse(Session["Member_UserID"].ToString()));

            MojoCube.Web.Comment.List list = new MojoCube.Web.Comment.List();

            for (int i = 0; i < GridView1.Rows.Count; i++)
            {
                if (((TextBox)GridView1.Rows[i].FindControl("txtComment")).Text.Trim() != "")
                {
                    list.Title        = ((Label)GridView1.Rows[i].FindControl("lblTitle")).Text;
                    list.Subtitle     = string.Empty;
                    list.Description  = ((TextBox)GridView1.Rows[i].FindControl("txtComment")).Text.Trim();
                    list.Feedback     = string.Empty;
                    list.Visual       = string.Empty;
                    list.Author       = member.LastName + member.FirstName;
                    list.Email        = member.Email;
                    list.Phone        = member.Phone1;
                    list.Address      = member.Address;
                    list.Website      = string.Empty;
                    list.IPAddress    = MojoCube.Web.IP.Get();
                    list.Browser      = MojoCube.Web.String.GetBrowserInfo();
                    list.Issue        = true;
                    list.IsComment    = false;
                    list.IsRecommend  = false;
                    list.IsRead       = false;
                    list.ReadDate     = DateTime.Now.ToString();
                    list.Clicks       = 0;
                    list.fk_ID        = int.Parse(((Label)GridView1.Rows[i].FindControl("lblfkID")).Text);
                    list.SortID       = 0;
                    list.TypeID       = 1;
                    list.StatusID     = 0;
                    list.Score        = int.Parse(((DropDownList)GridView1.Rows[i].FindControl("ddlScore")).SelectedValue);
                    list.ScoreIn      = list.Score;
                    list.CreateDate   = DateTime.Now.ToString();
                    list.CreateUserID = member.pk_Member;
                    list.ModifyDate   = DateTime.Now.ToString();
                    list.ModifyUserID = 0;
                    list.Language     = MojoCube.Api.UI.Language.GetLanguage();
                    list.InsertData();
                }
            }
        }

        Response.Redirect(MojoCube.Web.Site.Cache.GetUrlExtension("OrderDetail", MojoCube.Api.UI.Language.GetLanguage()) + "?id=" + MojoCube.Api.Text.Security.EncryptString(ViewState["pk_Order"].ToString()));
    }
示例#4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            hlBack.NavigateUrl = "List.aspx?active=" + Request.QueryString["active"];

            MojoCube.Web.Sql.DropDownListBind(ddlStatus, "Sys_StatusID", "StatusName_CHS", "ID", "TableName='Order_List'", "ID", "asc");

            MojoCube.Web.Sql.DropDownListBind(ddlExpress, "Sys_Express", "FullName", "ShortName", "Visible=1", "FullName", "asc", new ListItem("--请选择物流公司--", ""));

            if (Request.QueryString["id"] != null)
            {
                ViewState["pk_Order"] = MojoCube.Api.Text.Security.DecryptString(Request.QueryString["id"]);

                MojoCube.Web.Order.List list = new MojoCube.Web.Order.List();
                list.GetData(int.Parse(ViewState["pk_Order"].ToString()));

                lblTitle.Text       = "订单编号:" + list.OrderNumber;
                lblDate.Text        = "下单日期:" + list.CreateDate;
                lblDescription.Text = CreateOrderInfo(list);

                txtAmount.Text       = list.Amount.ToString("N2");
                txtLogisticCode.Text = list.LogisticCode;
                txtNumber.Text       = list.OrderNumber;
                txtNote.Text         = list.Note;

                MojoCube.Web.Sql.ddlFindByValue(ddlStatus, list.StatusID.ToString());
                MojoCube.Web.Sql.ddlFindByValue(ddlExpress, list.ShipperCode.ToString());

                lblHistory.Text = CreateHistory(list);

                if (list.Comments != "")
                {
                    lblComments.Text += "<hr/>" + list.Comments.Replace("\n", "<br/>");
                }

                this.Title = "订单编辑:" + lblTitle.Text;

                if (list.IsComment)
                {
                    lblTitle.Text += "(已评价)";
                }
            }
            else
            {
                this.Title = "订单编辑";
            }
        }
    }
示例#5
0
    //删除
    protected void lnbDelete_Click(object sender, EventArgs e)
    {
        MojoCube.Web.Order.List order = new MojoCube.Web.Order.List();

        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            if (((CheckBox)GridView1.Rows[i].FindControl("cbSelect")).Checked)
            {
                order.GetData(int.Parse(((Label)GridView1.Rows[i].FindControl("lblID")).Text));
                order.IsDeleted = true;
                order.UpdateData(order.pk_Order);
            }
        }

        Response.Redirect(MojoCube.Web.Site.Cache.GetUrlExtension("Order", MojoCube.Api.UI.Language.GetLanguage()));
    }
示例#6
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        if (txtAmount.Text.Trim() == "")
        {
            AlertDiv.InnerHtml = MojoCube.Web.String.ShowAlert("danger", "请填写金额");
            return;
        }

        MojoCube.Web.Order.List list = new MojoCube.Web.Order.List();

        //修改
        if (ViewState["pk_Order"] != null)
        {
            list.GetData(int.Parse(ViewState["pk_Order"].ToString()));

            if (list.StatusID != int.Parse(ddlStatus.SelectedValue))
            {
                string dateString = "<span style=\"font-size:8pt; color:#999; margin-left:3px;\">[" + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + "]</span>";
                list.StatusID  = int.Parse(ddlStatus.SelectedValue);
                list.Comments += Session["FullName"].ToString() + dateString + ":将状态改为【" + ddlStatus.SelectedItem.Text + "】\n";
            }
            if (list.ShipperCode != ddlExpress.SelectedValue)
            {
                list.ShipperCode  = ddlExpress.SelectedValue;
                list.ShipmentDate = DateTime.Now.ToString();
                list.LogisticCode = txtLogisticCode.Text.Trim();
            }
            if (list.StatusID == 3)
            {
                list.EndDate = DateTime.Now.ToString();
            }
            if (list.StatusID == 4)
            {
                list.CancelDate = DateTime.Now.ToString();
            }
            list.Amount      = MojoCube.Web.String.ToDecimal(txtAmount.Text.Trim());
            list.OrderNumber = txtNumber.Text.Trim();
            list.Note        = txtNote.Text.Trim();
            list.UpdateData(list.pk_Order);
        }

        AlertDiv.InnerHtml = MojoCube.Web.String.ShowAlert("success", "数据保存成功");
    }
示例#7
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["id"] == null)
            {
                Response.Redirect(MojoCube.Web.Site.Cache.GetUrlExtension("Order", strLanguage));
            }

            ViewState["pk_Order"] = MojoCube.Api.Text.Security.DecryptString(Request.QueryString["id"]);

            MojoCube.Web.Order.List order = new MojoCube.Web.Order.List();
            order.GetData(int.Parse(ViewState["pk_Order"].ToString()));

            if (order.pk_Order == 0 || order.StatusID > 0 || order.fk_Member.ToString() != Session["Member_UserID"].ToString())
            {
                Response.Redirect(MojoCube.Web.Site.Cache.GetUrlExtension("Order", strLanguage));
            }

            string siteUrl = MojoCube.Web.Site.Cache.GetDomain(strLanguage);  //获取网站的域名

            MojoCube.Web.Payment.List payment = new MojoCube.Web.Payment.List();
            payment.GetDataByType(1);

            strUrl         = payment.Gateway;
            ordersn        = order.OrderNumber;
            item_name      = HttpUtility.UrlEncode(order.Description, System.Text.Encoding.UTF8);
            amount         = (double)order.Amount * double.Parse(payment.Rate.ToString());
            amount         = double.Parse(amount.ToString("0.00"));
            currency_code  = "USD";
            username       = HttpUtility.UrlEncode(order.CustomerName, System.Text.Encoding.UTF8);
            business       = payment.Account;
            notify_url     = siteUrl + MojoCube.Web.Site.Cache.GetUrlExtension("Paypal_NotifyUrl", strLanguage);
            cancel_return  = siteUrl + MojoCube.Web.Site.Cache.GetUrlExtension("Paypal_Cancel", strLanguage) + "?username="******"&ordersn=" + ordersn;
            success_return = siteUrl + MojoCube.Web.Site.Cache.GetUrlExtension("Paypal_Success", strLanguage) + "?username="******"&ordersn=" + ordersn;
        }
    }
示例#8
0
    private void WxPayJS()
    {
        string siteUrl = MojoCube.Web.Site.Cache.GetDomain(strLanguage);  //获取网站的域名

        MojoCube.Web.Payment.List payment = new MojoCube.Web.Payment.List();
        payment.GetDataByType(2);

        MojoCube.Web.Order.List order = new MojoCube.Web.Order.List();
        order.GetData(int.Parse(ViewState["pk_Order"].ToString()));

        if (order.pk_Order == 0 || order.StatusID > 0 || order.fk_Member.ToString() != Session["Member_UserID"].ToString())
        {
            Response.Redirect(MojoCube.Web.Site.Cache.GetUrlExtension("Order", strLanguage));
        }

        appId = payment.AppID;
        string partnerId = payment.PartnerID;
        string key       = payment.KeyCode;
        string secret    = payment.Secret;
        int    price     = (int)(order.Amount * 100);
        string body      = order.Description;

        if (body.Length > 20)
        {
            body = body.Substring(0, 20);
        }

        //调用【网页授权获取用户信息】接口获取用户的openid和access_token
        GetOpenidAndAccessToken(appId, secret);

        UnifiedOrder order1 = new UnifiedOrder();

        order1.appid            = appId;
        order1.mch_id           = partnerId;
        order1.nonce_str        = TenpayUtil.getNoncestr();
        order1.body             = body;
        order1.out_trade_no     = order.OrderNumber;
        order1.total_fee        = price;
        order1.spbill_create_ip = Page.Request.UserHostAddress;
        order1.notify_url       = siteUrl + MojoCube.Web.Site.Cache.GetUrlExtension("WxPay_Notify", strLanguage);
        order1.trade_type       = "JSAPI";
        if (ViewState["OpenID"] != null)
        {
            order1.openid = ViewState["OpenID"].ToString();  //JSAPI必须传入openid
        }

        TenpayUtil tu = new TenpayUtil();

        prepayId  = tu.getPrepay_id(order1, key);
        nonceStr  = order1.nonce_str;
        timeStamp = TenpayUtil.getTimestamp();

        SortedDictionary <string, string> sParams = new SortedDictionary <string, string>();

        sParams.Add("appId", appId);
        sParams.Add("nonceStr", nonceStr);
        sParams.Add("package", "prepay_id=" + prepayId);
        sParams.Add("signType", "MD5");
        sParams.Add("timeStamp", timeStamp);
        sign = tu.getsign(sParams, key);
    }
示例#9
0
    private string CreateHistory()
    {
        MojoCube.Web.Order.List list = new MojoCube.Web.Order.List();
        list.GetData(int.Parse(ViewState["pk_Order"].ToString()));

        if (list.fk_Member.ToString() != Session["Member_UserID"].ToString())
        {
            Response.Redirect(MojoCube.Web.Site.Cache.GetUrlExtension("Order", strLanguage));
        }

        lblContactName.Text  = list.CustomerName;
        lblAddress.Text      = list.CustomerAddress;
        lblContactPhone.Text = list.CustomerPhone1;
        lblRemark.Text       = list.Remark;

        StringBuilder sb = new StringBuilder();

        sb.Append("<span style=\"font-size:8pt; color:#999; margin-left:3px;\">[" + DateTime.Parse(list.CreateDate).ToString("yyyy-MM-dd HH:mm") + "]</span> 创建订单,订单编号【" + list.OrderNumber + "】<br/>");

        if (list.fk_Payment > 0)
        {
            MojoCube.Web.Payment.List payment = new MojoCube.Web.Payment.List();
            payment.GetData(list.fk_Payment);
            sb.Append("<span style=\"font-size:8pt; color:#999; margin-left:3px;\">[" + DateTime.Parse(list.PaymentDate).ToString("yyyy-MM-dd HH:mm") + "]</span> 付款成功,【" + payment.Title + "】<br/>");
        }

        if (list.ShipperCode != "")
        {
            MojoCube.Web.Sys.Express express = new MojoCube.Web.Sys.Express();
            express.GetData(list.ShipperCode);
            sb.Append("<span style=\"font-size:8pt; color:#999; margin-left:3px;\">[" + DateTime.Parse(list.ShipmentDate).ToString("yyyy-MM-dd HH:mm") + "]</span> 已发货," + express.FullName + ",运单号【" + list.LogisticCode + "】<br/>");

            DataTable dt = new DataTable();
            if (Session["LogisticCode_" + list.LogisticCode] != null)
            {
                dt = (DataTable)Session["LogisticCode_" + list.LogisticCode];
            }
            else
            {
                dt = MojoCube.Web.Express.Function.GetLogisticDT(list.ShipperCode, list.LogisticCode);
                Session["LogisticCode_" + list.LogisticCode] = dt;
            }
            if (dt.Rows.Count > 0)
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    sb.Append("<span style=\"font-size:8pt; color:#999; margin-left:3px;\">[" + DateTime.Parse(dt.Rows[i]["Time"].ToString()).ToString("yyyy-MM-dd HH:mm") + "]</span> " + dt.Rows[i]["Content"].ToString() + "<br/>");
                }
            }
        }

        if (list.StatusID == 3)
        {
            sb.Append("<span style=\"font-size:8pt; color:#999; margin-left:3px;\">[" + DateTime.Parse(list.EndDate).ToString("yyyy-MM-dd HH:mm") + "]</span> 交易成功<br/>");
        }

        if (list.StatusID == 4)
        {
            sb.Append("<span style=\"font-size:8pt; color:#999; margin-left:3px;\">[" + DateTime.Parse(list.CancelDate).ToString("yyyy-MM-dd HH:mm") + "]</span> 交易关闭<br/>");
        }

        return(sb.ToString());
    }
示例#10
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            string data = string.Empty;

            try
            {
                //接收并读取POST过来的XML文件流
                StreamReader reader  = new StreamReader(Request.InputStream);
                String       xmlData = reader.ReadToEnd();

                data = xmlData;
            }
            catch { }

            MojoCube.Web.Order.List order = new MojoCube.Web.Order.List();
            order.GetData(GetWxKeyValue(data, "out_trade_no"));

            if (order.pk_Order > 0)
            {
                ViewState["AppID"] = GetWxKeyValue(data, "appid");
                string responseTxt = GetWxKeyValue(data, "return_code");

                if (!IsAllow())
                {
                    return;
                }

                if (!MojoCube.Web.Sql.IsExist("Order_Log", "fk_Order", order.pk_Order, "TransStatus='" + responseTxt + "'"))
                {
                    bool isSuccess = false;

                    if (responseTxt == "SUCCESS")
                    {
                        isSuccess = true;
                    }

                    MojoCube.Web.Order.Log log = new MojoCube.Web.Order.Log();
                    log.Number      = MojoCube.Api.Text.Function.DateTimeString(true);
                    log.OrderNumber = order.OrderNumber;
                    log.fk_Order    = order.pk_Order;
                    log.fk_Member   = order.fk_Member;
                    log.TypeID      = 0;
                    log.StatusID    = 0;
                    log.Title       = string.Empty;
                    log.Description = order.Description;
                    log.Amount      = order.Amount;
                    log.AppID       = ViewState["AppID"].ToString();
                    log.TransStatus = responseTxt;
                    if (isSuccess)
                    {
                        log.TransName   = "支付成功";
                        log.ResponseMsg = "交易成功";
                    }
                    else
                    {
                        log.TransName   = "支付失败";
                        log.ResponseMsg = "交易失败";
                    }
                    log.ChannelType    = "微信支付";
                    log.ResponseCode   = responseTxt;
                    log.OrderStartTime = GetWxKeyValue(data, "time_end");
                    log.OrderAmt       = GetWxKeyValue(data, "total_fee");
                    log.OrderTimeOut   = "0";
                    log.OrderType      = "普通消费";
                    log.DeviceType     = GetWxKeyValue(data, "trade_type");
                    log.ResponseTime   = log.OrderStartTime;
                    log.CurrencyType   = GetWxKeyValue(data, "fee_type");
                    log.Result         = data;
                    log.CreateDate     = DateTime.Now.ToString();
                    log.InsertData();

                    //支付成功
                    if (isSuccess)
                    {
                        //修改订单状态
                        order.StatusID    = 1;
                        order.fk_Payment  = 3;
                        order.PaymentDate = DateTime.Now.ToString();
                        order.UpdateData(order.pk_Order);

                        //通知微信已收到通知
                        Response.Write(CreateMsg());
                    }
                }
            }
        }
    }
示例#11
0
    private string GetPostUrl()
    {
        string siteUrl = MojoCube.Web.Site.Cache.GetDomain(strLanguage);  //获取网站的域名

        MojoCube.Web.Payment.List payment = new MojoCube.Web.Payment.List();
        payment.GetDataByType(0);

        MojoCube.Web.Order.List order = new MojoCube.Web.Order.List();
        order.GetData(int.Parse(ViewState["pk_Order"].ToString()));

        if (order.pk_Order == 0 || order.StatusID > 0 || order.fk_Member.ToString() != Session["Member_UserID"].ToString())
        {
            Response.Redirect(MojoCube.Web.Site.Cache.GetUrlExtension("Order", strLanguage));
        }

        ///////////////////////以下参数是需要设置的相关配置参数,设置后不会更改的///////////////////////////
        string service       = payment.Service;                                                                 //服务类型:create_partner_trade_by_buyer(支付宝中介担保交易)或者trade_create_by_buyer(即时到账)
        string partner       = payment.PartnerID;                                                               //合作身份者ID
        string key           = payment.KeyCode;                                                                 //安全检验码
        string seller_email  = payment.Account;                                                                 //签约支付宝账号或卖家支付宝帐户
        string input_charset = payment.InputCharset;                                                            //字符编码格式 目前支持 gb2312 或 utf-8
        string notify_url    = siteUrl + MojoCube.Web.Site.Cache.GetUrlExtension("Alipay_Notify", strLanguage); //交易过程中服务器通知的页面 要用 http://格式的完整路径,不允许加?id=123这类自定义参数
        string return_url    = siteUrl + MojoCube.Web.Site.Cache.GetUrlExtension("Alipay_Return", strLanguage); //付完款后跳转的页面 要用 http://格式的完整路径,不允许加?id=123这类自定义参数
        string show_url      = siteUrl;                                                                         //网站商品的展示地址,不允许加?id=123这类自定义参数
        string sign_type     = payment.SignType;                                                                //加密方式 不需修改

        ////////////////////////////////////////////////////////////////////////////////////////////////////

        ///////////////////////以下参数是需要通过下单时的订单数据传入进来获得////////////////////////////////
        //必填参数
        string out_trade_no = order.OrderNumber;             //请与贵网站订单系统中的唯一订单号匹配
        string subject      = order.Description;             //订单名称,显示在支付宝收银台里的“商品名称”里,显示在支付宝的交易管理的“商品名称”的列表里。
        string body         = "订单描述:" + order.Description;   //订单描述、订单详细、订单备注,显示在支付宝收银台里的“商品描述”里
        string price        = order.Amount.ToString("0.00"); //订单总金额,显示在支付宝收银台里的“商品单价”里

        string logistics_fee     = "0.00";                   //物流费用,即运费。
        string logistics_type    = "EXPRESS";                //物流类型,三个值可选:EXPRESS(快递)、POST(平邮)、EMS(EMS)
        string logistics_payment = "SELLER_PAY";             //物流支付方式,两个值可选:SELLER_PAY(卖家承担运费)、BUYER_PAY(买家承担运费)

        string quantity = "1";                               //商品数量,建议默认为1,不改变值,把一次交易看成是一次下订单而非购买一件商品。

        //扩展参数——买家收货信息(推荐作为必填)
        //该功能作用在于买家已经在商户网站的下单流程中填过一次收货信息,而不需要买家在支付宝的付款流程中再次填写收货信息。
        //若要使用该功能,请至少保证receive_name、receive_address有值
        string receive_name    = order.CustomerName;                            //收货人姓名,如:张三
        string receive_address = order.CustomerAddress;                         //收货人地址,如:XX省XXX市XXX区XXX路XXX小区XXX栋XXX单元XXX号
        string receive_zip     = order.CustomerZip;                             //收货人邮编,如:123456
        string receive_phone   = order.CustomerPhone1;                          //收货人电话号码,如:0571-81234567
        string receive_mobile  = order.CustomerPhone1;                          //收货人手机号码,如:13312341234

        //扩展参数——第二组物流方式
        //物流方式是三个为一组成组出现。若要使用,三个参数都需要填上数据;若不使用,三个参数都需要为空
        //有了第一组物流方式,才能有第二组物流方式,且不能与第一个物流方式中的物流类型相同,
        //即logistics_type="EXPRESS",那么logistics_type_1就必须在剩下的两个值(POST、EMS)中选择
        string logistics_fee_1     = "";                                                //物流费用,即运费。
        string logistics_type_1    = "";                                                //物流类型,三个值可选:EXPRESS(快递)、POST(平邮)、EMS(EMS)
        string logistics_payment_1 = "";                                                //物流支付方式,两个值可选:SELLER_PAY(卖家承担运费)、BUYER_PAY(买家承担运费)

        //扩展参数——第三组物流方式
        //物流方式是三个为一组成组出现。若要使用,三个参数都需要填上数据;若不使用,三个参数都需要为空
        //有了第一组物流方式和第二组物流方式,才能有第三组物流方式,且不能与第一组物流方式和第二组物流方式中的物流类型相同,
        //即logistics_type="EXPRESS"、logistics_type_1="EMS",那么logistics_type_2就只能选择"POST"
        string logistics_fee_2     = "";                                                //物流费用,即运费。
        string logistics_type_2    = "";                                                //物流类型,三个值可选:EXPRESS(快递)、POST(平邮)、EMS(EMS)
        string logistics_payment_2 = "";                                                //物流支付方式,两个值可选:SELLER_PAY(卖家承担运费)、BUYER_PAY(买家承担运费)

        //扩展功能参数——其他
        string buyer_email = "";                                                        //默认买家支付宝账号
        string discount    = "";                                                        //折扣,是具体的金额,而不是百分比。若要使用打折,请使用负数,并保证小数点最多两位数

        /////////////////////////////////////////////////////////////////////////////////////////////////////

        //构造请求函数
        MojoCube.Web.Payment.Alipay.Service aliService = new MojoCube.Web.Payment.Alipay.Service(
            partner,
            seller_email,
            return_url,
            notify_url,
            show_url,
            out_trade_no,
            subject,
            body,
            price,
            logistics_fee,
            logistics_type,
            logistics_payment,
            quantity,
            receive_name,
            receive_address,
            receive_zip,
            receive_phone,
            receive_mobile,
            logistics_fee_1,
            logistics_type_1,
            logistics_payment_1,
            logistics_fee_2,
            logistics_type_2,
            logistics_payment_2,
            buyer_email,
            discount,
            key,
            input_charset,
            sign_type,
            service);

        //GET方式传递
        return(aliService.Create_url());
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        ///当不知道https的时候,请使用http
        //string alipayNotifyURL = "https://www.alipay.com/cooperate/gateway.do?";
        string alipayNotifyURL = "http://notify.alipay.com/trade/notify_query.do?";

        MojoCube.Web.Payment.List payment = new MojoCube.Web.Payment.List();
        payment.GetDataByType(0);

        string partner = payment.PartnerID; //partner
        string key     = payment.KeyCode;   //安全校验码

        //alipayNotifyURL = alipayNotifyURL + "service=notify_verify" + "&partner=" + partner + "&notify_id=" + Request.QueryString["notify_id"];
        alipayNotifyURL = alipayNotifyURL + "partner=" + partner + "&notify_id=" + Request.QueryString["notify_id"];

        string responseTxt = Get_Http(alipayNotifyURL, 120000);
        //*********************************************************************************************
        int i;
        NameValueCollection coll;

        //Load Form variables into NameValueCollection variable.
        coll = Request.QueryString;

        // Get names of all forms into a string array.
        String[] requestarr = coll.AllKeys;

        //进行排序;
        string[] Sortedstr = BubbleSort(requestarr);

        //构造待md5摘要字符串;

        StringBuilder prestr = new StringBuilder();

        for (i = 0; i < Sortedstr.Length; i++)
        {
            if (Sortedstr[i] != "sign" && Sortedstr[i] != "sign_type")
            {
                if (i == Sortedstr.Length - 1)
                {
                    prestr.Append(Sortedstr[i] + "=" + Request.QueryString[Sortedstr[i]]);
                }
                else
                {
                    prestr.Append(Sortedstr[i] + "=" + Request.QueryString[Sortedstr[i]] + "&");
                }
            }
        }
        prestr.Append(key);

        string mysign    = GetMD5(prestr.ToString());               //生成MD5摘要
        string sign      = Request.Form["sign"];                    //签名
        string business  = Request.Form["seller_email"].ToString(); //收款方帐号ok
        string item_name = Request.Form["subject"].ToString();      //商品名ok
        string ordersn   = Request.Form["out_trade_no"].ToString(); //订单号ok
        string username  = Request.Form["receive_name"].ToString();
        string ppPrice   = Request.Form["price"].ToString();        //金额ok

        MojoCube.Web.Order.List order = new MojoCube.Web.Order.List();
        order.GetData(ordersn);

        if (order.pk_Order > 0)
        {
            if (mysign != sign)
            {
                return;
            }

            if (!MojoCube.Web.Sql.IsExist("Order_Log", "fk_Order", order.pk_Order, "TransStatus='" + responseTxt + "'"))
            {
                bool isSuccess = false;

                if (responseTxt == "true")
                {
                    isSuccess = true;
                }

                MojoCube.Web.Order.Log log = new MojoCube.Web.Order.Log();
                log.Number      = MojoCube.Api.Text.Function.DateTimeString(true);
                log.OrderNumber = order.OrderNumber;
                log.fk_Order    = order.pk_Order;
                log.fk_Member   = order.fk_Member;
                log.TypeID      = 0;
                log.StatusID    = 0;
                log.Title       = string.Empty;
                log.Description = order.Description;
                log.Amount      = order.Amount;
                log.AppID       = string.Empty;
                log.TransStatus = responseTxt;
                if (isSuccess)
                {
                    log.TransName   = "支付成功";
                    log.ResponseMsg = "交易成功";
                }
                else
                {
                    log.TransName   = "支付失败";
                    log.ResponseMsg = "交易失败";
                }
                log.ChannelType    = "支付宝";
                log.ResponseCode   = responseTxt;
                log.OrderStartTime = DateTime.Now.ToString("yyyyMMddHHmmss");
                log.OrderAmt       = ppPrice;
                log.OrderTimeOut   = "0";
                log.OrderType      = "普通消费";
                log.DeviceType     = "Web";
                log.ResponseTime   = log.OrderStartTime;
                log.CurrencyType   = "RMB";
                log.Result         = sign + "|" + business + "|" + item_name + "|" + ordersn + "|" + username + "|" + ppPrice;
                log.CreateDate     = DateTime.Now.ToString();
                log.InsertData();

                //支付成功
                if (isSuccess)
                {
                    //修改订单状态
                    order.StatusID    = 1;
                    order.fk_Payment  = 1;
                    order.PaymentDate = DateTime.Now.ToString();
                    order.UpdateData(order.pk_Order);

                    Response.Write("支付成功!");     //返回给支付宝消息,成功
                    Response.Write("<br>------------------" + Request.Form["body"]);
                }
                else
                {
                    Response.Write("支付失败,请与商家联系!");
                    Response.Write("<br>------------------" + Request.Form["body"]);
                }
            }
        }
    }
示例#13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        MojoCube.Web.Payment.List payment = new MojoCube.Web.Payment.List();
        payment.GetDataByType(1);

        string         strUrl = payment.Gateway;
        HttpWebRequest req    = (HttpWebRequest)WebRequest.Create(strUrl);

        // Set values for the request back
        req.Method      = "POST";
        req.ContentType = "application/x-www-form-urlencoded";
        byte[] param      = Request.BinaryRead(HttpContext.Current.Request.ContentLength);
        string strRequest = Encoding.ASCII.GetString(param);

        strRequest       += "&cmd=_notify-validate";
        req.ContentLength = strRequest.Length;

        //for proxy
        //WebProxy proxy = new WebProxy(new Uri("http://url:port#"));
        //req.Proxy = proxy;

        //Send the request to PayPal and get the response
        StreamWriter streamOut = new StreamWriter(req.GetRequestStream(), System.Text.Encoding.ASCII);

        streamOut.Write(strRequest);
        streamOut.Close();
        StreamReader streamIn    = new StreamReader(req.GetResponse().GetResponseStream());
        string       responseTxt = streamIn.ReadToEnd();

        streamIn.Close();

        string business  = GetString("business");                  //收款方帐号ok
        string item_name = GetString("item_name");                 //商品名ok
        string ordersn   = GetString("item_number");               //订单号ok
        string username  = GetString("username");
        string txnid     = GetString("txn_id").ToString();         //ok
        string ppStatus  = GetString("payment_status").ToString(); //状态 ok//成功返回:Completed
        string ppDate    = GetString("payment_date").ToString();   //paypal服务器支付时间ok
        string ppPrice   = GetString("mc_gross").ToString();       //金额ok

        MojoCube.Web.Order.List order = new MojoCube.Web.Order.List();
        order.GetData(ordersn);

        if (order.pk_Order > 0)
        {
            if (responseTxt != "VERIFIED")
            {
                return;
            }

            if (!MojoCube.Web.Sql.IsExist("Order_Log", "fk_Order", order.pk_Order, "TransStatus='" + ppStatus + "'"))
            {
                bool isSuccess = false;

                if (ppStatus == "Completed")
                {
                    isSuccess = true;
                }

                MojoCube.Web.Order.Log log = new MojoCube.Web.Order.Log();
                log.Number      = MojoCube.Api.Text.Function.DateTimeString(true);
                log.OrderNumber = order.OrderNumber;
                log.fk_Order    = order.pk_Order;
                log.fk_Member   = order.fk_Member;
                log.TypeID      = 0;
                log.StatusID    = 0;
                log.Title       = string.Empty;
                log.Description = order.Description;
                log.Amount      = order.Amount;
                log.AppID       = string.Empty;
                log.TransStatus = ppStatus;
                if (isSuccess)
                {
                    log.TransName   = "支付成功";
                    log.ResponseMsg = "交易成功";
                }
                else
                {
                    log.TransName   = "支付失败";
                    log.ResponseMsg = "交易失败";
                }
                log.ChannelType    = "Paypal";
                log.ResponseCode   = responseTxt;
                log.OrderStartTime = ppDate;
                log.OrderAmt       = ppPrice;
                log.OrderTimeOut   = "0";
                log.OrderType      = "普通消费";
                log.DeviceType     = "Web";
                log.ResponseTime   = log.OrderStartTime;
                log.CurrencyType   = "RMB";
                log.Result         = business + "|" + item_name + "|" + ordersn + "|" + username + "|" + txnid + "|" + ppStatus + "|" + ppDate + "|" + ppPrice;
                log.CreateDate     = DateTime.Now.ToString();
                log.InsertData();

                //支付成功
                if (isSuccess)
                {
                    //修改订单状态
                    order.StatusID    = 1;
                    order.fk_Payment  = 2;
                    order.PaymentDate = DateTime.Now.ToString();
                    order.UpdateData(order.pk_Order);
                }
            }
        }
    }
示例#14
0
    private string CreateInfo()
    {
        StringBuilder sb = new StringBuilder();

        MojoCube.Web.Order.List order = new MojoCube.Web.Order.List();
        order.GetData(int.Parse(ViewState["pk_Order"].ToString()));

        if (order.pk_Order == 0 || order.StatusID > 0 || order.fk_Member.ToString() != Session["Member_UserID"].ToString())
        {
            Response.Redirect(MojoCube.Web.Site.Cache.GetUrlExtension("Order", strLanguage));
        }

        sb.Append("<div class=\"pay-wrap\">");
        sb.Append("<table>");
        sb.Append("<tr>");
        sb.Append("<td class=\"pay-td\">订单编号:</td>");
        sb.Append("<td>" + order.OrderNumber + "</td>");
        sb.Append("</tr>");
        sb.Append("<tr>");
        sb.Append("<td class=\"pay-td\">订单描述:</td>");
        sb.Append("<td>" + order.Description + "</td>");
        sb.Append("</tr>");
        sb.Append("<tr>");
        sb.Append("<td class=\"pay-td\">订单金额:</td>");
        sb.Append("<td><span class=\"price\">" + MojoCube.Web.String.GetCurrency(order.Amount) + "</span></td>");
        sb.Append("</tr>");
        sb.Append("</table>");
        sb.Append("</div>");
        sb.Append("<div class=\"pay-title\">");
        sb.Append("<b>请选择支付方式:</b>");
        sb.Append("</div>");
        sb.Append("<div class=\"pay-item-wrap\">");
        sb.Append("<div class=\"pay-item-div\">");

        DataTable dt = MojoCube.Web.Sql.SqlQueryDS("select TypeID,ImagePath,Title from Payment_List where Visible=1 order by SortID asc").Tables[0];

        if (dt.Rows.Count > 0)
        {
            string url = "";

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                switch (dt.Rows[i]["TypeID"].ToString())
                {
                case "0":
                    url = MojoCube.Web.Site.Cache.GetUrlExtension("Alipay_Post", strLanguage);
                    break;

                case "1":
                    url = MojoCube.Web.Site.Cache.GetUrlExtension("Paypal_Post", strLanguage);
                    break;

                case "2":
                    url = MojoCube.Web.Site.Cache.GetUrlExtension("WxPay", strLanguage);
                    break;
                }
                sb.Append("<div class=\"pay-item\"><a href=\"" + url + "?id=" + Request.QueryString["id"] + "\" target=\"_blank\" onclick=\"openDialog();\"><img src=\"Files.aspx?image=" + MojoCube.Api.Text.Security.EncryptString(dt.Rows[i]["ImagePath"].ToString()) + "\" alt=\"" + dt.Rows[i]["Title"].ToString() + "\" /><br />" + dt.Rows[i]["Title"].ToString() + "</a></div>");
            }
        }

        sb.Append("</div>");
        sb.Append("</div>");

        //提示框信息
        sb.Append("<script type=\"text/javascript\">");
        sb.Append("function openDialog() {");
        sb.Append("BootstrapDialog.show({");
        sb.Append("title: '支付情况',");
        sb.Append("message: '如果您已经付款成功,请返回订单查看订单状态;如果付款过程中出现问题,请重试一次。',");
        sb.Append("buttons: [{");
        sb.Append("label: '支付成功,返回订单',");
        sb.Append("cssClass: 'btn-primary',");
        sb.Append("action: function () {");
        sb.Append("window.location.href = '" + MojoCube.Web.Site.Cache.GetUrlExtension("Order", strLanguage) + "';");
        sb.Append("}");
        sb.Append("}, {");
        sb.Append("label: '再试一次',");
        sb.Append("cssClass: 'btn-warning',");
        sb.Append("action: function (dialogItself) {");
        sb.Append("dialogItself.close();");
        sb.Append("}");
        sb.Append("}]");
        sb.Append("});");
        sb.Append("}");
        sb.Append("</script>");

        return(sb.ToString());
    }