public decimal GetNotCashCollectionTotal(string strWhere, string gateway)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(strWhere.ToString());
            stringBuilder.Append(" and GateWay = '" + gateway + "'");
            StoreCollectionInfo storeCollectionInfo = new StoreCollectionInfo();
            string    query            = "SELECT  SUM(ISNULL(PayAmount,0)) - SUM(ISNULL(RefundAmount,0)) FROM dbo.Hishop_StoreCollections where " + stringBuilder.ToString();
            DbCommand sqlStringCommand = base.database.GetSqlStringCommand(query);

            return(base.database.ExecuteScalar(sqlStringCommand).ToDecimal(0));
        }
        public StoreCollectionInfo GetStoreCollectionInfo(string serialNumber)
        {
            StoreCollectionInfo result = new StoreCollectionInfo();
            string    query            = "SELECT * FROM dbo.Hishop_StoreCollections WHERE SerialNumber= @SerialNumber";
            DbCommand sqlStringCommand = base.database.GetSqlStringCommand(query);

            base.database.AddInParameter(sqlStringCommand, "SerialNumber", DbType.String, serialNumber);
            using (IDataReader objReader = base.database.ExecuteReader(sqlStringCommand))
            {
                result = DataHelper.ReaderToModel <StoreCollectionInfo>(objReader);
            }
            return(result);
        }
        public StoreCollectionInfo GetStoreCollectionInfoByOrderId(string OrderId)
        {
            StoreCollectionInfo result = new StoreCollectionInfo();
            string    query            = "SELECT top 1 * FROM dbo.Hishop_StoreCollections where OrderId = @OrderId";
            DbCommand sqlStringCommand = base.database.GetSqlStringCommand(query);

            base.database.AddInParameter(sqlStringCommand, "OrderId", DbType.String, OrderId);
            using (IDataReader objReader = base.database.ExecuteReader(sqlStringCommand))
            {
                result = DataHelper.ReaderToModel <StoreCollectionInfo>(objReader);
            }
            return(result);
        }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.isOfflineOrder = (base.Request.QueryString["isOffline"].ToNullString().ToLower() == "true");
            bool   flag  = false;
            bool   flag2 = false;
            string text  = HttpContext.Current.Request.UserAgent;

            if (string.IsNullOrEmpty(text))
            {
                text = "";
            }
            bool flag3 = false;

            if (text.ToLower().IndexOf("micromessenger") > -1)
            {
                flag3 = true;
            }
            SiteSettings siteSettings = HiContext.Current.SiteSettings;

            if (!string.IsNullOrEmpty(siteSettings.WeixinAppId) && !string.IsNullOrEmpty(siteSettings.WeixinAppSecret) && !string.IsNullOrEmpty(siteSettings.WeixinPartnerID) && !string.IsNullOrEmpty(siteSettings.WeixinPartnerKey))
            {
                this.hasWxPayRight.Value = "1";
                flag = true;
            }
            else
            {
                this.hasWxPayRight.Value = "0";
            }
            PaymentModeInfo paymentMode = ShoppingProcessor.GetPaymentMode("hishop.plugins.payment.ws_wappay.wswappayrequest");

            if (paymentMode != null)
            {
                this.hasAliPayRight.Value = "1";
                flag2 = true;
            }
            else
            {
                this.hasAliPayRight.Value = "0";
            }
            this.sessionId = this.Page.Request["SessionId"].ToNullString();
            if (!string.IsNullOrEmpty(this.sessionId))
            {
                this.inputPanel.Visible = true;
            }
            else
            {
                this.inputPanel.Visible = false;
            }
            if (!this.isOfflineOrder)
            {
                OrderInfo orderInfo = OrderHelper.GetOrderInfo(base.Request.QueryString["OrderId"].ToNullString());
                if (orderInfo == null)
                {
                    this.hidErrMsg.Value = "错误的订单ID";
                }
                else if (orderInfo.OrderStatus != OrderStatus.WaitBuyerPay)
                {
                    this.hidErrMsg.Value = "错误的订单状态";
                }
                else
                {
                    EnumPaymentType enumPaymentType = flag3 ? EnumPaymentType.WXPay : EnumPaymentType.WapAliPay;
                    this.offlineOrder = StoresHelper.GetStoreCollectionInfo(this.OrderId);
                    if (this.offlineOrder == null)
                    {
                        StoreCollectionInfo storeCollectionInfo = new StoreCollectionInfo();
                        storeCollectionInfo.CreateTime      = orderInfo.OrderDate;
                        storeCollectionInfo.FinishTime      = DateTime.Now;
                        storeCollectionInfo.PayTime         = DateTime.Now;
                        storeCollectionInfo.PaymentTypeId   = (int)enumPaymentType;
                        storeCollectionInfo.PaymentTypeName = EnumDescription.GetEnumDescription((Enum)(object)enumPaymentType, 0);
                        storeCollectionInfo.GateWay         = EnumDescription.GetEnumDescription((Enum)(object)enumPaymentType, 1);
                        storeCollectionInfo.OrderId         = orderInfo.OrderId;
                        storeCollectionInfo.OrderType       = 1;
                        storeCollectionInfo.PayAmount       = orderInfo.GetTotal(false);
                        storeCollectionInfo.RefundAmount    = decimal.Zero;
                        storeCollectionInfo.Remark          = "上门自提订单确认提货:" + orderInfo.OrderId;
                        storeCollectionInfo.SerialNumber    = Globals.GetGenerateId();
                        storeCollectionInfo.Status          = 0;
                        storeCollectionInfo.StoreId         = orderInfo.StoreId;
                        storeCollectionInfo.UserId          = orderInfo.UserId;
                        StoresHelper.AddStoreCollectionInfo(storeCollectionInfo);
                    }
                    else
                    {
                        this.offlineOrder.PaymentTypeId   = (int)enumPaymentType;
                        this.offlineOrder.PaymentTypeName = EnumDescription.GetEnumDescription((Enum)(object)enumPaymentType, 0);
                        this.offlineOrder.GateWay         = EnumDescription.GetEnumDescription((Enum)(object)enumPaymentType, 1);
                        StoresHelper.UpdateStoreCollectionInfo(this.offlineOrder);
                    }
                }
            }
            if (flag3)
            {
                if (flag && !this.inputPanel.Visible)
                {
                    base.Response.Redirect("/Vshop/StoreOrderPay?OrderId=" + base.Request.QueryString["OrderId"].ToNullString() + "&IsOffline=" + base.Request.QueryString["isOffline"].ToNullString());
                }
            }
            else if (flag2 && !this.inputPanel.Visible)
            {
                base.Response.Redirect("/WapShop/StoreOrderPay?OrderId=" + base.Request.QueryString["OrderId"].ToNullString() + "&IsOffline=" + base.Request.QueryString["isOffline"].ToNullString());
            }
        }
Beispiel #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.param = new NameValueCollection
            {
                base.Request.QueryString,
                base.Request.Form
            };
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();
            NotifyClient notifyClient   = null;

            notifyClient = ((string.IsNullOrEmpty(masterSettings.Main_Mch_ID) || string.IsNullOrEmpty(masterSettings.Main_AppId)) ? new NotifyClient(masterSettings.WeixinAppId, masterSettings.WeixinAppSecret, masterSettings.WeixinPartnerID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey, "", "") : new NotifyClient(masterSettings.Main_AppId, masterSettings.WeixinAppSecret, masterSettings.Main_Mch_ID, masterSettings.WeixinPartnerKey, masterSettings.WeixinPaySignKey, masterSettings.WeixinAppId, masterSettings.WeixinPartnerID));
            NameValueCollection nameValueCollection = new NameValueCollection
            {
                base.Request.QueryString,
                base.Request.Form
            };
            string    sign      = "";
            PayNotify payNotify = notifyClient.GetPayNotify(base.Request.InputStream);

            if (payNotify == null)
            {
                Globals.AppendLog(this.param, "通知信息为空", sign, "", "AppStore_wxPay");
            }
            else
            {
                this.OrderId      = payNotify.PayInfo.OutTradeNo;
                this.Order        = ShoppingProcessor.GetOrderInfo(this.OrderId);
                this.offlineOrder = StoresHelper.GetStoreCollectionInfo(this.OrderId);
                if (this.Order == null)
                {
                    this.Order = ShoppingProcessor.GetOrderInfo(payNotify.PayInfo.OutTradeNo);
                }
                if (this.offlineOrder == null)
                {
                    this.offlineOrder = StoresHelper.GetStoreCollectionInfo(payNotify.PayInfo.OutTradeNo);
                }
                if (this.Order == null && this.offlineOrder == null)
                {
                    Globals.AppendLog(this.param, "订单信息为空", sign, "", "AppStore_wxPay");
                    base.Response.Write("success");
                }
                else
                {
                    EnumPaymentType enumPaymentType = EnumPaymentType.WXPay;
                    if (this.Order == null)
                    {
                        this.isOfflineOrder = true;
                    }
                    else
                    {
                        this.Order.PaymentTypeId  = (int)enumPaymentType;
                        this.Order.PaymentType    = EnumDescription.GetEnumDescription((Enum)(object)enumPaymentType, 0);
                        this.Order.Gateway        = EnumDescription.GetEnumDescription((Enum)(object)enumPaymentType, 1);
                        this.Order.GatewayOrderId = payNotify.PayInfo.TransactionId;
                        if (this.offlineOrder == null)
                        {
                            this.offlineOrder = StoresHelper.GetStoreCollectionInfoOfOrderId(this.Order.OrderId);
                        }
                    }
                    if (this.offlineOrder != null)
                    {
                        this.offlineOrder.GateWayOrderId  = payNotify.PayInfo.TransactionId;
                        this.offlineOrder.PaymentTypeId   = (int)enumPaymentType;
                        this.offlineOrder.PaymentTypeName = EnumDescription.GetEnumDescription((Enum)(object)enumPaymentType, 0);
                        this.offlineOrder.GateWay         = EnumDescription.GetEnumDescription((Enum)(object)enumPaymentType, 1);
                    }
                    this.UserPayOrder();
                    base.Response.Write("success");
                }
            }
        }
Beispiel #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            NameValueCollection headers = base.Request.Headers;
            string text = "";

            if (headers.AllKeys.Contains("Forwarded"))
            {
                text = headers["Forwarded"].ToNullString();
            }
            OrderInfo    orderInfo      = null;
            PackageInfo  packageInfo    = new PackageInfo();
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();
            bool         flag           = this.Page.Request["IsOffline"].ToBool();
            string       a      = this.Page.Request["from"].ToNullString().ToLower();
            string       text2  = this.Page.Request.QueryString.Get("orderId");
            string       empty  = string.Empty;
            string       empty2 = string.Empty;
            decimal      d;

            if (a == "appstore")
            {
                this.isOfflineOrder = "true";
                if (string.IsNullOrEmpty(text2))
                {
                    this.litError.Text = "错误的订单号,不能进行支付!";
                    return;
                }
                empty = text2;
                d     = default(decimal);
                StoreCollectionInfo storeCollectionInfo = null;
                if (flag)
                {
                    this.isOfflineOrder = "true";
                    storeCollectionInfo = StoresHelper.GetStoreCollectionInfo(text2);
                    if (storeCollectionInfo == null)
                    {
                        this.litError.Text = "订单状态错误,不能进行支付!";
                    }
                    else if (storeCollectionInfo.Status == 0)
                    {
                        d = storeCollectionInfo.PayAmount;
                        goto IL_0309;
                    }
                    return;
                }
                orderInfo = ShoppingProcessor.GetOrderInfo(text2);
                if (orderInfo == null)
                {
                    this.litError.Text = "错误的订单信息,不能进行支付!";
                    return;
                }
                if (orderInfo.OrderStatus != OrderStatus.WaitBuyerPay)
                {
                    if (orderInfo.OrderSource == OrderSource.Alioh)
                    {
                        base.Response.Redirect("/AliOH/MemberOrderDetails?OrderId=" + orderInfo.OrderId);
                    }
                    else
                    {
                        base.Response.Redirect("/WapShop/MemberOrderDetails?OrderId=" + orderInfo.OrderId);
                    }
                    return;
                }
                this.IsServiceOrder = ((orderInfo.OrderType == OrderType.ServiceOrder) ? "true" : "false");
                if (orderInfo.PreSaleId > 0)
                {
                    if (!orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay)
                    {
                        empty = orderInfo.OrderId;
                        d     = orderInfo.Deposit - orderInfo.BalanceAmount;
                    }
                    if (orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay)
                    {
                        if (orderInfo.PayRandCode.ToInt(0) == 0)
                        {
                            int num = orderInfo.PayRandCode.ToInt(0);
                            num = ((num >= 100) ? (num + 1) : 100);
                            orderInfo.PayRandCode = num.ToString();
                            OrderHelper.UpdateOrderPaymentTypeOfAPI(orderInfo);
                        }
                        empty = orderInfo.PayOrderId;
                        d     = orderInfo.FinalPayment;
                    }
                }
                else
                {
                    empty = orderInfo.PayOrderId;
                    d     = orderInfo.GetTotal(true);
                }
                goto IL_0309;
            }
            if (string.IsNullOrEmpty(text2))
            {
                this.litError.Text = "订单状态错误,不能进行支付!";
                return;
            }
            orderInfo = OrderHelper.GetOrderInfo(text2);
            if (orderInfo == null)
            {
                this.litError.Text = "订单状态错误,不能进行支付!";
                return;
            }
            if (orderInfo.OrderStatus != OrderStatus.WaitBuyerPay)
            {
                if (orderInfo.OrderSource == OrderSource.Alioh)
                {
                    base.Response.Redirect("/AliOH/MemberOrderDetails?OrderId=" + orderInfo.OrderId);
                }
                else
                {
                    base.Response.Redirect("/WapShop/MemberOrderDetails?OrderId=" + orderInfo.OrderId);
                }
                return;
            }
            empty             = text2;
            this.isFightGroup = ((orderInfo.FightGroupId > 0) ? "true" : "false");
            decimal d2 = default(decimal);

            if (orderInfo.PreSaleId > 0)
            {
                if (!orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay)
                {
                    empty = orderInfo.OrderId;
                    d2    = ((orderInfo.Deposit - orderInfo.BalanceAmount > decimal.Zero) ? (orderInfo.Deposit - orderInfo.BalanceAmount) : decimal.Zero);
                }
                if (orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay)
                {
                    if (orderInfo.PayRandCode.ToInt(0) == 0)
                    {
                        int num2 = orderInfo.PayRandCode.ToInt(0);
                        num2 = ((num2 >= 100) ? (num2 + 1) : 100);
                        orderInfo.PayRandCode = num2.ToString();
                        OrderHelper.UpdateOrderPaymentTypeOfAPI(orderInfo);
                    }
                    empty = orderInfo.PayOrderId;
                    d2    = ((orderInfo.FinalPayment > decimal.Zero) ? orderInfo.FinalPayment : decimal.Zero);
                }
            }
            else
            {
                empty = orderInfo.PayOrderId;
                d2    = orderInfo.GetTotal(true);
            }
            packageInfo.Body      = orderInfo.OrderId;
            packageInfo.NotifyUrl = Globals.GetProtocal(HttpContext.Current) + "://" + $"{this.Page.Request.Url.Host}/pay/wx_Pay";
            if (orderInfo.OrderType != OrderType.ServiceOrder && orderInfo.OrderSource == OrderSource.Applet)
            {
                packageInfo.NotifyUrl = Globals.GetProtocal(HttpContext.Current) + "://" + $"{this.Page.Request.Url.Host}/pay/O2OApplet_Pay";
            }
            packageInfo.OutTradeNo = empty;
            packageInfo.Attach     = empty2;
            packageInfo.TotalFee   = (int)(d2 * 100m);
            if (packageInfo.TotalFee < decimal.One)
            {
                packageInfo.TotalFee = decimal.One;
            }
            goto IL_06db;
IL_06db:
            packageInfo.SpbillCreateIp = ((string.IsNullOrEmpty(text) || !Globals.IsIpAddress(text)) ? Globals.GetIPAddress(HttpContext.Current) : text);
            string text3      = masterSettings.WeixinAppId;
            string appSecret  = masterSettings.WeixinAppSecret;
            string text4      = masterSettings.WeixinPartnerID;
            string partnerKey = masterSettings.WeixinPartnerKey;
            string text5      = masterSettings.Main_Mch_ID;
            string text6      = masterSettings.Main_AppId;

            if (orderInfo.OrderType == OrderType.ServiceOrder)
            {
                text3      = masterSettings.O2OAppletAppId;
                appSecret  = masterSettings.O2OAppletAppSecrect;
                text4      = masterSettings.O2OAppletMchId;
                partnerKey = masterSettings.O2OAppletKey;
                text5      = "";
                text6      = "";
            }
            else if (orderInfo.OrderSource == OrderSource.Applet)
            {
                text3      = masterSettings.WxAppletAppId;
                appSecret  = masterSettings.WxAppletAppSecrect;
                text4      = masterSettings.WxApplectMchId;
                partnerKey = masterSettings.WxApplectKey;
                text5      = "";
                text6      = "";
            }
            string text7 = "";

            if (!string.IsNullOrEmpty(text6) && !string.IsNullOrEmpty(text5))
            {
                packageInfo.sub_openid = text7;
            }
            else
            {
                packageInfo.OpenId = text7;
            }
            PayClient payClient = null;

            payClient = ((string.IsNullOrEmpty(text6) || string.IsNullOrEmpty(text5)) ? new PayClient(text3, appSecret, text4, partnerKey, "", "", "", "") : new PayClient(text6, appSecret, text5, partnerKey, "", text4, text3, ""));
            Globals.AppendLog(JsonHelper.GetJson(packageInfo), "", "", "H5PaySubmit");
            PayRequestInfo payRequestInfo = payClient.BuildH5PayRequest(packageInfo);

            this.pay_uri = payRequestInfo.mweb_url;
            return;

IL_0309:
            packageInfo.Body       = text2;
            packageInfo.NotifyUrl  = Globals.GetProtocal(HttpContext.Current) + "://" + $"{this.Page.Request.Url.Host}/pay/AppStore_wxPay";
            packageInfo.OutTradeNo = empty;
            packageInfo.TotalFee   = (int)(d * 100m);
            if (orderInfo != null)
            {
                packageInfo.OutTradeNo = orderInfo.PayOrderId;
                packageInfo.Attach     = empty2;
            }
            else
            {
                packageInfo.OutTradeNo = empty;
                packageInfo.Attach     = empty2;
            }
            if (packageInfo.TotalFee < decimal.One)
            {
                packageInfo.TotalFee = decimal.One;
            }
            goto IL_06db;
        }
		protected void Page_Load(object sender, EventArgs e)
		{
			NameValueCollection nameValueCollection = new NameValueCollection
			{
				this.Page.Request.Form,
				this.Page.Request.QueryString
			};
			this.Gateway = "hishop.plugins.payment.ws_wappay.wswappayrequest";
			this.Notify = PaymentNotify.CreateInstance(this.Gateway, nameValueCollection);
			this.OrderId = this.Notify.GetOrderId();
			this.Order = ShoppingProcessor.GetOrderInfo(this.OrderId);
			this.offlineOrder = StoresHelper.GetStoreCollectionInfo(this.OrderId);
			if (this.Order == null && this.offlineOrder == null)
			{
				Globals.AppendLog(nameValueCollection, "通知信息为空", "", "", "AppStore_wxPay");
				base.Response.Write("success");
			}
			else
			{
				PaymentModeInfo paymentMode = ShoppingProcessor.GetPaymentMode("hishop.plugins.payment.ws_wappay.wswappayrequest");
				if (paymentMode == null)
				{
					Globals.WriteLog(nameValueCollection, "支付方式获取失败hishop.plugins.payment.ws_wappay.wswappayrequest", "", "", "alipay");
					base.Response.Write("success");
				}
				else
				{
					this.Amount = this.Notify.GetOrderAmount();
					if (this.Order == null)
					{
						this.isOfflineOrder = true;
					}
					else
					{
						if (this.Amount <= decimal.Zero)
						{
							this.Amount = this.Order.GetTotal(true);
						}
						this.offlineOrder = StoresHelper.GetStoreCollectionInfoOfOrderId(this.OrderId);
						this.Order.GatewayOrderId = this.Notify.GetGatewayOrderId();
						this.Order.PaymentType = paymentMode.Name;
						this.Order.PaymentTypeId = 2;
						this.Order.Gateway = paymentMode.Gateway;
						if (this.offlineOrder == null)
						{
							this.offlineOrder = StoresHelper.GetStoreCollectionInfoOfOrderId(this.Order.OrderId);
						}
					}
					if (this.offlineOrder != null)
					{
						if (this.Amount <= decimal.Zero)
						{
							this.Amount = this.offlineOrder.PayAmount;
						}
						this.offlineOrder.GateWayOrderId = this.Notify.GetGatewayOrderId();
						this.offlineOrder.PaymentTypeId = 2;
						this.offlineOrder.PaymentTypeName = paymentMode.Name;
						this.offlineOrder.GateWay = paymentMode.Gateway;
					}
					this.Notify.Finished += this.Notify_Finished;
					this.Notify.NotifyVerifyFaild += this.Notify_NotifyVerifyFaild;
					this.Notify.Payment += this.Notify_Payment;
					this.Notify.VerifyNotify(30000, HiCryptographer.Decrypt(paymentMode.Settings));
				}
			}
		}
Beispiel #8
0
        protected override void AttachChildControls()
        {
            this.isOffline      = this.Page.Request["IsOffline"].ToBool();
            this.orderId        = Globals.StripAllTags(this.Page.Request.QueryString["orderId"].ToNullString());
            this.litOrderId     = (Literal)this.FindControl("litOrderId");
            this.litOrderTotal  = (Literal)this.FindControl("litOrderTotal");
            this.litPaymentType = (HtmlInputHidden)this.FindControl("litPaymentType");
            this.litPaymentName = (Literal)this.FindControl("litPaymentName");
            this.linkToDetail   = (HtmlAnchor)this.FindControl("linkToDetail");
            this.litErrorMsg    = (Literal)this.FindControl("litErrorMsg");
            this.loadPanel      = (HtmlGenericControl)this.FindControl("loadPanel");
            this.errorPanel     = (HtmlGenericControl)this.FindControl("errorPanel");
            this.btnToPay       = (HtmlAnchor)this.FindControl("btnToPay");
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();
            string       text           = "";
            string       userAgent      = HttpContext.Current.Request.UserAgent;

            this.loadPanel.Visible = true;
            StoreCollectionInfo storeCollectionInfo = null;

            if (this.isOffline)
            {
                storeCollectionInfo = StoresHelper.GetStoreCollectionInfo(this.orderId);
                if (storeCollectionInfo == null)
                {
                    this.litErrorMsg.Text   = "错误的订单编号";
                    this.loadPanel.Visible  = false;
                    this.errorPanel.Visible = true;
                    return;
                }
                if (storeCollectionInfo.Status != 0)
                {
                    this.litErrorMsg.Text   = "订单状态不是待支付状态";
                    this.loadPanel.Visible  = false;
                    this.errorPanel.Visible = true;
                    return;
                }
                if (this.linkToDetail != null)
                {
                    this.linkToDetail.Visible = false;
                }
            }
            else
            {
                this.order = ShoppingProcessor.GetOrderInfo(this.orderId);
                if (this.order == null)
                {
                    this.litErrorMsg.Text   = "错误的订单编号";
                    this.loadPanel.Visible  = false;
                    this.errorPanel.Visible = true;
                    return;
                }
                if (this.order.OrderStatus != OrderStatus.WaitBuyerPay)
                {
                    this.litErrorMsg.Text   = "订单状态不是待支付状态";
                    this.loadPanel.Visible  = false;
                    this.errorPanel.Visible = true;
                    return;
                }
                storeCollectionInfo      = StoresHelper.GetStoreCollectionInfoOfOrderId(this.orderId);
                this.litPaymentName.Text = this.order.PaymentType;
                this.litPaymentType.SetWhenIsNotNull(this.order.PaymentTypeId.ToString());
                this.litOrderId.SetWhenIsNotNull(this.orderId);
                this.litOrderTotal.SetWhenIsNotNull(this.order.GetTotal(false).F2ToString("f2"));
                if (this.linkToDetail != null)
                {
                    this.linkToDetail.Visible = true;
                    this.linkToDetail.HRef    = "MemberOrderDetails?OrderId=" + this.orderId;
                }
            }
            if (base.ClientType == ClientType.VShop)
            {
                if (!string.IsNullOrEmpty(masterSettings.WeixinAppId) && !string.IsNullOrEmpty(masterSettings.WeixinAppSecret) && !string.IsNullOrEmpty(masterSettings.WeixinPartnerID) && !string.IsNullOrEmpty(masterSettings.WeixinPartnerKey))
                {
                    if (!this.isOffline)
                    {
                        this.order.Gateway       = "hishop.plugins.payment.weixinrequest";
                        this.order.PaymentTypeId = -2;
                        this.order.PaymentType   = "微信支付";
                        TradeHelper.UpdateOrderPaymentType(this.order);
                    }
                    if (storeCollectionInfo != null)
                    {
                        storeCollectionInfo.GateWay         = "hishop.plugins.payment.weixinrequest";
                        storeCollectionInfo.PaymentTypeName = "微信支付";
                        storeCollectionInfo.PaymentTypeId   = 1;
                        StoresHelper.UpdateStoreCollectionInfo(storeCollectionInfo);
                    }
                    HttpContext.Current.Response.Redirect("~/pay/wx_Submit?orderId=" + this.orderId + "&IsOffline=" + this.isOffline.ToString() + "&from=appstore");
                }
                else
                {
                    this.litErrorMsg.Text   = "未配置微信支付";
                    this.loadPanel.Visible  = false;
                    this.errorPanel.Visible = true;
                }
            }
            else
            {
                PaymentModeInfo paymentMode = ShoppingProcessor.GetPaymentMode("hishop.plugins.payment.ws_wappay.wswappayrequest");
                if (paymentMode != null)
                {
                    decimal  amount     = default(decimal);
                    string   subject    = "门店APP订单支付";
                    string   buyerEmail = "";
                    DateTime date       = DateTime.Now;
                    if (!this.isOffline)
                    {
                        subject                  = "门店APP线下支付";
                        text                     = paymentMode.Gateway;
                        this.order.Gateway       = paymentMode.Gateway;
                        this.order.PaymentTypeId = paymentMode.ModeId;
                        this.order.PaymentType   = paymentMode.Name;
                        TradeHelper.UpdateOrderPaymentType(this.order);
                        amount     = this.order.GetTotal(false);
                        buyerEmail = this.order.EmailAddress;
                        date       = this.order.OrderDate;
                    }
                    if (storeCollectionInfo != null)
                    {
                        amount = storeCollectionInfo.PayAmount;
                        storeCollectionInfo.GateWay         = paymentMode.Gateway;
                        storeCollectionInfo.PaymentTypeName = paymentMode.Name;
                        storeCollectionInfo.PaymentTypeId   = 2;
                        StoresHelper.UpdateStoreCollectionInfo(storeCollectionInfo);
                        date = storeCollectionInfo.CreateTime;
                    }
                    string         attach         = "";
                    string         showUrl        = string.Format("http://{0}/{1}/", HttpContext.Current.Request.Url.Host, "AliOH");
                    PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), this.orderId, amount, subject, "订单号-" + this.orderId, buyerEmail, date, showUrl, Globals.FullPath("/pay/appstore_wapalipay_return_url"), Globals.FullPath("/pay/appstore_wapalipay_notify_url"), attach);
                    paymentRequest.SendRequest();
                }
                else
                {
                    this.litErrorMsg.Text   = "未配置支付宝网页支付";
                    this.loadPanel.Visible  = false;
                    this.errorPanel.Visible = true;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            base.Response.Write("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no\"/>");
            NameValueCollection nameValueCollection = new NameValueCollection
            {
                this.Page.Request.Form,
                this.Page.Request.QueryString
            };

            nameValueCollection.Add("IsReturn", "true");
            this.Gateway      = "hishop.plugins.payment.ws_wappay.wswappayrequest";
            this.Notify       = PaymentNotify.CreateInstance(this.Gateway, nameValueCollection);
            this.OrderId      = this.Notify.GetOrderId();
            this.Order        = ShoppingProcessor.GetOrderInfo(this.OrderId);
            this.offlineOrder = StoresHelper.GetStoreCollectionInfo(this.OrderId);
            if (this.Order == null && this.offlineOrder == null)
            {
                base.Response.Write("success");
            }
            else
            {
                PaymentModeInfo paymentMode = ShoppingProcessor.GetPaymentMode("hishop.plugins.payment.ws_wappay.wswappayrequest");
                if (paymentMode == null)
                {
                    Globals.WriteLog(nameValueCollection, "支付方式获取失败hishop.plugins.payment.ws_wappay.wswappayrequest", "", "", "alipay");
                    base.Response.Write("success");
                }
                else
                {
                    this.Amount = this.Notify.GetOrderAmount();
                    if (this.Order == null)
                    {
                        this.isOfflineOrder = true;
                    }
                    else
                    {
                        if (this.Amount <= decimal.Zero)
                        {
                            this.Amount = this.Order.GetTotal(true);
                        }
                        this.offlineOrder         = StoresHelper.GetStoreCollectionInfoOfOrderId(this.OrderId);
                        this.Order.GatewayOrderId = this.Notify.GetGatewayOrderId();
                        this.Order.PaymentType    = paymentMode.Name;
                        this.Order.PaymentTypeId  = paymentMode.ModeId;
                        this.Order.Gateway        = paymentMode.Gateway;
                        if (this.offlineOrder == null)
                        {
                            this.offlineOrder = StoresHelper.GetStoreCollectionInfoOfOrderId(this.Order.OrderId);
                        }
                    }
                    if (this.offlineOrder != null)
                    {
                        if (this.Amount <= decimal.Zero)
                        {
                            this.Amount = this.offlineOrder.PayAmount;
                        }
                        this.offlineOrder.GateWayOrderId  = this.Notify.GetGatewayOrderId();
                        this.offlineOrder.PaymentTypeId   = paymentMode.ModeId;
                        this.offlineOrder.PaymentTypeName = paymentMode.Name;
                        this.offlineOrder.GateWay         = paymentMode.Gateway;
                    }
                    this.Notify.Finished          += this.Notify_Finished;
                    this.Notify.NotifyVerifyFaild += this.Notify_NotifyVerifyFaild;
                    this.Notify.Payment           += this.Notify_Payment;
                    this.Notify.VerifyNotify(30000, HiCryptographer.Decrypt(paymentMode.Settings));
                }
            }
        }
Beispiel #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            OrderInfo    orderInfo      = null;
            PackageInfo  packageInfo    = new PackageInfo();
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();
            bool         flag           = this.Page.Request["IsOffline"].ToBool();
            string       a         = this.Page.Request["from"].ToNullString().ToLower();
            string       text      = this.Page.Request.QueryString.Get("orderId");
            string       empty     = string.Empty;
            string       empty2    = string.Empty;
            string       userAgent = base.Request.UserAgent;

            if (userAgent.ToLower().IndexOf("micromessenger") > -1)
            {
                this.isWeiXin = true;
            }
            if (a == "appstore")
            {
                this.isOfflineOrder = "true";
                if (string.IsNullOrEmpty(text))
                {
                    this.Page.Response.Write("<h2 style=\"color:red;width:100%; text-align:center;\">错误的订单号,不能进行支付!<h2>");
                    this.Page.Response.End();
                }
                empty = text;
                decimal             d = default(decimal);
                StoreCollectionInfo storeCollectionInfo = null;
                if (flag)
                {
                    this.isOfflineOrder = "true";
                    storeCollectionInfo = StoresHelper.GetStoreCollectionInfo(text);
                    if (storeCollectionInfo == null)
                    {
                        this.Page.Response.Write("<h2 style=\"color:red;width:100%; text-align:center;\">订单状态错误,不能进行支付!<h2>");
                        this.Page.Response.End();
                    }
                    if (storeCollectionInfo.Status != 0)
                    {
                        this.Page.Response.Write("<h2 style=\"color:red;width:100%; text-align:center;\">订单状态错误,不能进行支付!<h2>");
                        this.Page.Response.End();
                    }
                    d = storeCollectionInfo.PayAmount;
                }
                else
                {
                    orderInfo = ShoppingProcessor.GetOrderInfo(text);
                    if (orderInfo == null)
                    {
                        this.Page.Response.Write("<h2 style=\"color:red;width:100%; text-align:center;\">订单状态错误,不能进行支付!<h2>");
                        this.Page.Response.End();
                    }
                    if (orderInfo.OrderStatus != OrderStatus.WaitBuyerPay)
                    {
                        this.Page.Response.Write("<h2 style=\"color:red;width:100%; text-align:center;\">订单状态错误,不能进行支付!<h2>");
                        this.Page.Response.End();
                    }
                    this.IsServiceOrder = ((orderInfo.OrderType == OrderType.ServiceOrder) ? "true" : "false");
                    if (orderInfo.PreSaleId > 0)
                    {
                        if (!orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay)
                        {
                            empty = orderInfo.OrderId;
                            d     = orderInfo.Deposit - orderInfo.BalanceAmount;
                        }
                        if (orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay)
                        {
                            if (orderInfo.PayRandCode.ToInt(0) == 0)
                            {
                                int num = orderInfo.PayRandCode.ToInt(0);
                                num = ((num >= 100) ? (num + 1) : 100);
                                orderInfo.PayRandCode = num.ToString();
                                OrderHelper.UpdateOrderPaymentTypeOfAPI(orderInfo);
                            }
                            empty = orderInfo.PayOrderId;
                            d     = orderInfo.FinalPayment;
                        }
                    }
                    else
                    {
                        empty = orderInfo.PayOrderId;
                        d     = orderInfo.GetTotal(true);
                    }
                }
                packageInfo.Body       = text;
                packageInfo.NotifyUrl  = Globals.GetProtocal(HttpContext.Current) + "://" + $"{this.Page.Request.Url.Host}/pay/AppStore_wxPay";
                packageInfo.OutTradeNo = empty;
                packageInfo.TotalFee   = (int)(d * 100m);
                if (orderInfo != null)
                {
                    packageInfo.OutTradeNo = orderInfo.PayOrderId;
                    packageInfo.Attach     = empty2;
                }
                else
                {
                    packageInfo.OutTradeNo = empty;
                    packageInfo.Attach     = empty2;
                }
                if (packageInfo.TotalFee < decimal.One)
                {
                    packageInfo.TotalFee = decimal.One;
                }
            }
            else
            {
                if (string.IsNullOrEmpty(text))
                {
                    this.Page.Response.Write("<h2 style=\"color:red;width:100%; text-align:center;\">订单状态错误,不能进行支付!<h2>");
                    this.Page.Response.End();
                }
                orderInfo = OrderHelper.GetOrderInfo(text);
                if (orderInfo == null)
                {
                    this.Page.Response.Write("<h2 style=\"color:red;width:100%; text-align:center;\">订单状态错误,不能进行支付!<h2>");
                    this.Page.Response.End();
                }
                if (orderInfo.OrderStatus != OrderStatus.WaitBuyerPay)
                {
                    this.Page.Response.Write("<h2 style=\"color:red;width:100%; text-align:center;\">订单状态错误,不能进行支付!<h2>");
                    this.Page.Response.End();
                }
                this.IsServiceOrder = ((orderInfo.OrderType == OrderType.ServiceOrder) ? "true" : "false");
                empty             = text;
                this.isFightGroup = ((orderInfo.FightGroupId > 0) ? "true" : "false");
                decimal d2 = default(decimal);
                if (orderInfo.PreSaleId > 0)
                {
                    if (!orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay)
                    {
                        empty = orderInfo.OrderId;
                        d2    = ((orderInfo.Deposit - orderInfo.BalanceAmount > decimal.Zero) ? (orderInfo.Deposit - orderInfo.BalanceAmount) : decimal.Zero);
                    }
                    if (orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay)
                    {
                        if (orderInfo.PayRandCode.ToInt(0) == 0)
                        {
                            int num2 = orderInfo.PayRandCode.ToInt(0);
                            num2 = ((num2 >= 100) ? (num2 + 1) : 100);
                            orderInfo.PayRandCode = num2.ToString();
                            OrderHelper.UpdateOrderPaymentTypeOfAPI(orderInfo);
                        }
                        empty = orderInfo.PayOrderId;
                        d2    = ((orderInfo.FinalPayment > decimal.Zero) ? orderInfo.FinalPayment : decimal.Zero);
                    }
                }
                else
                {
                    empty = orderInfo.OrderId;
                    d2    = orderInfo.GetTotal(true);
                }
                packageInfo.Body      = orderInfo.OrderId + orderInfo.PayRandCode;
                packageInfo.NotifyUrl = Globals.GetProtocal(HttpContext.Current) + "://" + $"{this.Page.Request.Url.Host}/pay/wx_Pay";
                if (orderInfo.OrderType != OrderType.ServiceOrder && orderInfo.OrderSource == OrderSource.Applet)
                {
                    packageInfo.NotifyUrl = Globals.GetProtocal(HttpContext.Current) + "://" + $"{this.Page.Request.Url.Host}/pay/O2OApplet_Pay";
                }
                packageInfo.OutTradeNo = orderInfo.PayOrderId;
                packageInfo.Attach     = empty2;
                packageInfo.TotalFee   = (int)(d2 * 100m);
                if (packageInfo.TotalFee < decimal.One)
                {
                    packageInfo.TotalFee = decimal.One;
                }
            }
            string text2     = masterSettings.WeixinAppId;
            string appSecret = masterSettings.WeixinAppSecret;
            string text3     = masterSettings.WeixinPartnerID;
            string text4     = masterSettings.WeixinPartnerKey;
            string text5     = masterSettings.Main_Mch_ID;
            string text6     = masterSettings.Main_AppId;

            if (a != "appstore")
            {
                if (orderInfo.OrderType == OrderType.ServiceOrder && orderInfo.OrderSource != OrderSource.WeiXin)
                {
                    text2     = masterSettings.O2OAppletAppId;
                    appSecret = masterSettings.O2OAppletAppSecrect;
                    text3     = masterSettings.O2OAppletMchId;
                    text4     = masterSettings.O2OAppletKey;
                    text5     = "";
                    text6     = "";
                }
                else if (orderInfo.OrderSource == OrderSource.Applet)
                {
                    text2     = masterSettings.WxAppletAppId;
                    appSecret = masterSettings.WxAppletAppSecrect;
                    text3     = masterSettings.WxApplectMchId;
                    text4     = masterSettings.WxApplectKey;
                    text5     = "";
                    text6     = "";
                }
            }
            string     text7 = "";
            MemberInfo user  = HiContext.Current.User;

            if (user.UserId > 0 && a != "appstore")
            {
                MemberOpenIdInfo memberOpenIdInfo = null;
                if (orderInfo.OrderType == OrderType.ServiceOrder && orderInfo.OrderSource != OrderSource.WeiXin)
                {
                    memberOpenIdInfo = user.MemberOpenIds.FirstOrDefault((MemberOpenIdInfo item) => item.OpenIdType.ToLower() == "hishop.plugins.openid.o2owxapplet");
                    if (memberOpenIdInfo != null)
                    {
                        text7 = memberOpenIdInfo.OpenId;
                    }
                }
                else if (orderInfo.OrderSource == OrderSource.Applet)
                {
                    memberOpenIdInfo = user.MemberOpenIds.FirstOrDefault((MemberOpenIdInfo item) => item.OpenIdType.ToLower() == "hishop.plugins.openid.wxapplet");
                    if (memberOpenIdInfo != null)
                    {
                        text7 = memberOpenIdInfo.OpenId;
                    }
                }
                else
                {
                    memberOpenIdInfo = user.MemberOpenIds.FirstOrDefault((MemberOpenIdInfo item) => item.OpenIdType.ToLower() == "hishop.plugins.openid.weixin");
                    if (memberOpenIdInfo != null && user.IsDefaultDevice)
                    {
                        text7 = memberOpenIdInfo.OpenId;
                    }
                }
            }
            if (string.IsNullOrEmpty(text7))
            {
                PayConfig payConfig = new PayConfig();
                payConfig.AppId     = text2;
                payConfig.Key       = text4;
                payConfig.MchID     = text3;
                payConfig.AppSecret = appSecret;
                JsApiPay jsApiPay = new JsApiPay();
                try
                {
                    NameValueCollection openidAndAccessToken = JsApiPay.GetOpenidAndAccessToken(this.Page, payConfig.AppId, payConfig.AppSecret, false);
                    if (openidAndAccessToken.HasKeys())
                    {
                        text7 = openidAndAccessToken["openId"];
                    }
                }
                catch (Exception ex)
                {
                    if (!(ex is ThreadAbortException))
                    {
                        IDictionary <string, string> dictionary = new Dictionary <string, string>();
                        dictionary.Add("AppId", payConfig.AppId);
                        dictionary.Add("Key", payConfig.Key);
                        dictionary.Add("MchID", payConfig.MchID);
                        dictionary.Add("AppSecret", payConfig.AppSecret);
                        dictionary.Add("Exception", ex.Message);
                        dictionary.Add("StackTrace", ex.StackTrace);
                        dictionary.Add("TargetSite", ex.TargetSite.ToString());
                        Globals.WriteLog(dictionary, "获取用户OpenId失败", "", "", "GetOpenId");
                    }
                }
            }
            if (!string.IsNullOrEmpty(text6) && !string.IsNullOrEmpty(text5))
            {
                packageInfo.sub_openid = text7;
            }
            else
            {
                packageInfo.OpenId = text7;
            }
            PayClient payClient = null;

            payClient = ((string.IsNullOrEmpty(text6) || string.IsNullOrEmpty(text5)) ? new PayClient(text2, appSecret, text3, text4, "", "", "", "") : new PayClient(text6, appSecret, text5, text4, "", text3, text2, ""));
            PayRequestInfo req = payClient.BuildPayRequest(packageInfo);

            this.pay_json = this.ConvertPayJson(req);
            this.pay_uri  = this.ConvertPayUri(req);
            if (!this.isWeiXin)
            {
                base.Response.Redirect(this.pay_uri);
            }
        }