示例#1
0
        private void ShowOrderInfo(string orderId)
        {
            NoName.NetShop.ShopFlow.CommOrderBll bll = new NoName.NetShop.ShopFlow.CommOrderBll();
            CommOrderModel order = bll.GetModel(orderId, CurrentUser.UserId);

            if (order != null)
            {
                gvProducts.DataSource = bll.GetOrderItems(orderId);
                gvProducts.DataBind();
                gvActionLog.DataSource = bll.GetChangeLogs(orderId);
                gvActionLog.DataBind();

                lblOrderId.Text     = order.OrderId;
                lblUserId.Text      = order.UserId;
                lblOrderStatus.Text = order.OrderStatus.ToString();
                lblPayStatus.Text   = order.PayStatus.ToString();
                lblCreateTime.Text  = order.CreateTime.ToString("yyyy-MM-dd HH:mm");
                lblPayTime.Text     = order.PayTime == null ? "" : (order.PayTime ?? default(DateTime)).ToString("yyyy-MM-dd HH:mm");
                lblPayMethod.Text   = order.PayMethod.ToString();
                lblShipMethod.Text  = order.ShipMethod.ToString();
                lblProductFee.Text  = order.ProductFee.ToString("F2");
                lblShipFee.Text     = order.ShipFee.ToString("F2");
                lblDerateFee.Text   = order.DerateFee.ToString("F2");
                lblPaySum.Text      = order.Paysum.ToString("F2");
                lblAddress.Text     = order.RecieverProvince + order.RecieverCity + order.RecieverCounty + " " + order.AddressDetial + " 邮编:" + order.Postalcode;
                lblInvoice.Text     = order.IsNeedInvoice ? "需要发票,抬头为:" + order.InvoiceTitle : "不需要发票";
                lblUserNotes.Text   = order.UserNotes;
                lblTelePhone.Text   = order.RecieverPhone;
                lblReceName.Text    = order.RecieverName;
                lblEmail.Text       = order.RecieverEmail;

                ShowActions(order);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CommOrderBll obll = new CommOrderBll();
            string orderId = Request.QueryString["orderId"];

            CommOrderModel model = obll.GetModel(orderId);
            List<CommOrderItemModel> items = obll.GetOrderItems(orderId);
            string subject = String.Join(",", (from s in items select s.ProductName).ToArray());
            int quantity = (from s in items select s.Quantity).Sum();
            string paymethod = (model.ShipMethod == ShipMethodType.EMS?"EMS":"Express");

            subject = String.IsNullOrEmpty(subject)?null:subject;
            string agent =null;
            string body = null;
            AliPay ap = new AliPay();
            StandardGoods bp = new StandardGoods(PayServiceType.trade_create_by_buyer.Key, AlipaySetting.Partner, AlipaySetting.NotifyUrl,AlipaySetting.ReturnUrl,
                agent,AlipaySetting.EncodeType,AlipaySetting.Key,AlipaySetting.SignType,subject,body,model.OrderId,
                model.Paysum, quantity, null,AlipaySetting.SellerEmail, null,null,null,null,
                "POST", model.ShipFee, LogisticsPayment.SELLER_PAY.Key, "1");

            bp.Notify_Url = AlipaySetting.NotifyUrl;
            bp.Return_Url = AlipaySetting.ReturnUrl;
            bp.Receive_Address = model.FullAddress;
            bp.Receive_Phone = model.RecieverPhone;
            bp.Receive_Zip = model.Postalcode;
            bp.Receive_Name = model.RecieverName;

            ap.CreateStandardTrade(AlipaySetting.PushUrl, bp, this);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            //可以在页面加载时设置页面的缓存为“SetNoStore()”,即无缓存
            Response.Cache.SetNoStore();

            if (CurrentShopCart == null)
            {
                Response.Write("购物车已清空,页面将<a href='../member/MyOrderList.aspx'>跳转</a>至账户中心!");
                Response.AddHeader("REFRESH", "3;URL='../member/MyOrderList.aspx'");
                Response.End();
            }

            if (!IsPostBack)
            {
                litSavedOrderId.Text = CurrentShopCart.RecentSavedOrderId.ToString();
                Context.Items.Remove("SavedOrderId");

                CommOrderBll cobll = new CommOrderBll();
                CommOrderModel model = cobll.GetModel(litSavedOrderId.Text);
                if (model != null && String.IsNullOrEmpty(model.PayorderId) && model.PayMethod == PayMethType.支付宝)
                {
                    string url = "../alipay/StandardPay.aspx?orderId=" + litSavedOrderId.Text;
                    Response.Write("订单已生成,页面将<a href='" + url + "'>跳转</a>支付页面!");
                    Response.AddHeader("REFRESH", "3;URL='" + url + "'");
                }

            }
        }
 /// <summary>
 /// 置为退款完成,前置条件:退款申请中订单,不包括货到付款订单
 /// 如果是线上支付订单,需要调用接口完成退款操作(目前暂无接口)
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnAskRefund_Click(object sender, EventArgs e)
 {
     CommOrderBll obll = new CommOrderBll();
     OrderChangeLogBll lbll = new OrderChangeLogBll();
     CommOrderModel order = obll.GetModel(lblOrderId.Text);
     if (order != null && order.PayMethod != PayMethType.货到付款 && order.PayStatus == PayStatus.支付成功)
     {
         obll.ChangePayStatus(order.OrderId, PayStatus.退款申请中);
         lbll.Add(order.OrderId, txtActionRemark.Text.Trim(), PayStatus.退款申请中.ToString(),
             Context.User.Identity.Name);
         ShowOrderInfo(lblOrderId.Text);
     }
 }
 /// <summary>
 /// 关闭订单,前置条件为:订单处于初始创建,且未支付
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnClose_Click(object sender, EventArgs e)
 {
     CommOrderBll obll = new CommOrderBll();
     OrderChangeLogBll lbll = new OrderChangeLogBll();
     CommOrderModel order = obll.GetModel(lblOrderId.Text);
     if (order != null && order.OrderStatus == OrderStatus.已创建 && order.PayStatus== PayStatus.等待付款)
     {
         obll.ChangeOrderStatus(order.OrderId, OrderStatus.交易关闭);
         lbll.Add(order.OrderId, txtActionRemark.Text.Trim(), OrderStatus.交易关闭.ToString(),
             Context.User.Identity.Name);
         ShowOrderInfo(lblOrderId.Text);
     }
 }
 /// <summary>
 /// 置为交易失败,前置条件为:货到付款订单,已发货;其他订单,已退款
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnFail_Click(object sender, EventArgs e)
 {
     CommOrderBll obll = new CommOrderBll();
     OrderChangeLogBll lbll = new OrderChangeLogBll();
     CommOrderModel order = obll.GetModel(lblOrderId.Text);
     if (order != null &&
         ((order.PayMethod== PayMethType.货到付款 && order.OrderStatus== OrderStatus.已发货)
         || (order.PayMethod!= PayMethType.货到付款 && order.PayStatus == PayStatus.退款完成)))
     {
         obll.ChangeOrderStatus(order.OrderId, OrderStatus.交易失败);
         lbll.Add(order.OrderId, txtActionRemark.Text.Trim(), OrderStatus.交易失败.ToString(),
             Context.User.Identity.Name);
         ShowOrderInfo(lblOrderId.Text);
     }
 }
        /// <summary>
        /// 置为买家签收(买家确认),隐含实现,如果为线上支付,则同时跳转至结算页面,前置条件:订单已发货
        /// 如果是货到付款订单,同时设置订单支付状态为已支付
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnCherrys_Click(object sender, EventArgs e)
        {
            CommOrderBll obll = new CommOrderBll();
            OrderChangeLogBll lbll = new OrderChangeLogBll();
            CommOrderModel order = obll.GetModel(lblOrderId.Text);
            if (order.OrderStatus == OrderStatus.已发货 || order.OrderStatus == OrderStatus.物流到货)
            {
                obll.ChangeOrderStatus(order.OrderId, OrderStatus.买家确认);
                lbll.Add(order.OrderId, txtActionRemark.Text.Trim(), OrderStatus.买家确认.ToString(),
                    Context.User.Identity.Name);

                if (order.PayMethod == PayMethType.支付宝)
                {
                    // 转向支付结算页面
                }
                ShowOrderInfo(lblOrderId.Text);

            }
        }
        private void ShowOrderInfo(string orderId)
        {
            NoName.NetShop.ShopFlow.CommOrderBll bll = new NoName.NetShop.ShopFlow.CommOrderBll();
            CommOrderModel order = bll.GetModel(orderId, CurrentUser.UserId);
            if (order != null)
            {
                gvProducts.DataSource = bll.GetOrderItems(orderId);
                gvProducts.DataBind();
                gvActionLog.DataSource = bll.GetChangeLogs(orderId);
                gvActionLog.DataBind();

                lblOrderId.Text = order.OrderId;
                lblUserId.Text = order.UserId;
                lblOrderStatus.Text = order.OrderStatus.ToString();
                lblPayStatus.Text = order.PayStatus.ToString();
                lblCreateTime.Text = order.CreateTime.ToString("yyyy-MM-dd HH:mm");
                lblPayTime.Text = order.PayTime == null ? "" : (order.PayTime ?? default(DateTime)).ToString("yyyy-MM-dd HH:mm");
                lblPayMethod.Text = order.PayMethod.ToString();
                lblShipMethod.Text = order.ShipMethod.ToString();
                lblProductFee.Text = order.ProductFee.ToString("F2");
                lblShipFee.Text = order.ShipFee.ToString("F2");
                lblDerateFee.Text = order.DerateFee.ToString("F2");
                lblPaySum.Text = order.Paysum.ToString("F2");
                lblAddress.Text = order.RecieverProvince + order.RecieverCity + order.RecieverCounty + " " + order.AddressDetial + " 邮编:" + order.Postalcode;
                lblInvoice.Text = order.IsNeedInvoice ? "需要发票,抬头为:" + order.InvoiceTitle : "不需要发票";
                lblUserNotes.Text = order.UserNotes;
                lblTelePhone.Text = order.RecieverPhone;
                lblReceName.Text = order.RecieverName;
                lblEmail.Text = order.RecieverEmail;

                ShowActions(order);
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            CommOrderBll obll = new CommOrderBll();
            string orderId = Request.QueryString["orderId"];

            CommOrderModel model = obll.GetModel(orderId);
            List<CommOrderItemModel> items = obll.GetOrderItems(orderId);
            string subject = "test product";
            int quantity = 1;
            string paymethod = (model.ShipMethod == ShipMethodType.EMS ? "EMS" : "EXPRESS");

            //        StandardGoods bp = new StandardGoods(PayServiceType.trade_create_by_buyer.Key, AlipaySetting.Partner,
            //AlipaySetting.Key,
            //AlipaySetting.SignType,
            //subject, model.OrderId, model.Paysum, quantity, AlipaySetting.SellerEmail, AlipaySetting.SellerId,
            //"POST", model.ShipFee, LogisticsPayment.BUYER_PAY.Key, "1");

            //string logistics_type = "POST";
            //string logistics_fee = TextBox2.Text;
            //string logistics_payment = "BUYER_PAY";
            //string logistics_type_1 = "EXPRESS";
            //string logistics_fee_1 = TextBox3.Text;
            //string logistics_payment_1 = "BUYER_PAY";

            //bp.Notify_Url = AlipaySetting.NotifyUrl;
            //bp.Return_Url = AlipaySetting.ReturnUrl;

            //��ʱ���충���ţ�

            string out_trade_no = model.OrderId;
            //ҵ�������ֵ��
            string gateway = AlipaySetting.PushUrl;	//'֧���ӿ�
            string service = PayServiceType.trade_create_by_buyer.Key;
            string partner = AlipaySetting.Partner;		//partner		�������ID			�����ֶ�
            string sign_type = AlipaySetting.SignType;
            string body = "test order";		//body			��Ʒ����
            string payment_type = "1";                  //֧������
            string price = model.Paysum.ToString("f2");
            string show_url = "http://dingding.uncc.cn/";
            string seller_email =AlipaySetting.SellerEmail;             //����˺�
            string key = AlipaySetting.Key;              //partner�˻���֧������ȫУ����
            string return_url = AlipaySetting.ReturnUrl; //������֪ͨ���ؽӿ�
            string notify_url = AlipaySetting.NotifyUrl; //������֪ͨ���ؽӿ�
            string _input_charset = AlipaySetting.EncodeType;
            string logistics_type = "POST";
            string logistics_fee = model.ShipFee.ToString("f2");
            string logistics_payment = LogisticsPayment.BUYER_PAY.Key;
            string logistics_type_1 =null;
            string logistics_fee_1 = null;
            string logistics_payment_1 = null;

            MyAliPay ap = new MyAliPay();
            string aliay_url = ap.CreatUrl(
                gateway,
                service,
                partner,
                sign_type,
                out_trade_no,
                subject,
                body,
                payment_type,
                price,
                show_url,
                seller_email,
                key,
                return_url,
                _input_charset,
                notify_url,
                logistics_type,
                logistics_fee,
                logistics_payment,
                logistics_type_1,
                logistics_fee_1,
                logistics_payment_1,
                quantity.ToString()
                );

            Response.Redirect(aliay_url);
        }
 /// <summary>
 /// 置为备货状态,前置条件为:订单为初始创建,如果是货到付款,不需要判断支付状态,其他的需要为已支付状态
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnPrepareGoods_Click(object sender, EventArgs e)
 {
     CommOrderBll obll = new CommOrderBll();
     OrderChangeLogBll lbll = new OrderChangeLogBll();
     CommOrderModel order = obll.GetModel(lblOrderId.Text);
     if (order != null && order.OrderStatus == OrderStatus.已创建 &&
         (order.PayMethod== PayMethType.货到付款 || order.PayStatus == PayStatus.支付成功))
     {
         obll.ChangeOrderStatus(order.OrderId, OrderStatus.备货中);
         lbll.Add(order.OrderId, txtActionRemark.Text.Trim(), OrderStatus.备货中.ToString(),
             Context.User.Identity.Name);
         ShowOrderInfo(lblOrderId.Text);
     }
 }