示例#1
0
        private void btnPay_Click(object sender, EventArgs e)
        {
            string value  = this.hdorderId.Value;
            int    modeId = 0;

            int.TryParse(this.dropPayType.SelectedValue, out modeId);
            PaymentModeInfo paymentMode = TradeHelper.GetPaymentMode(modeId);
            OrderInfo       orderInfo   = TradeHelper.GetOrderInfo(value);
            string          msg         = "";

            if (!TradeHelper.CheckOrderStock(orderInfo, out msg))
            {
                this.ShowMessage(msg, false, "", 1);
            }
            else
            {
                IList <string> list = new List <string>();
                list.Add("hishop.plugins.payment.podrequest");
                list.Add("hishop.plugins.payment.bankrequest");
                if (orderInfo.CountDownBuyId > 0)
                {
                    if (list.Contains(paymentMode.Gateway.ToLower().Trim()))
                    {
                        msg = "限购的订单不支持货到付款和线下支付";
                        this.ShowMessage(msg, false, "", 1);
                        return;
                    }
                    foreach (LineItemInfo value2 in orderInfo.LineItems.Values)
                    {
                        CountDownInfo countDownInfo = TradeHelper.CheckUserCountDown(value2.ProductId, orderInfo.CountDownBuyId, value2.SkuId, HiContext.Current.UserId, orderInfo.GetAllQuantity(true), orderInfo.OrderId, out msg, orderInfo.StoreId);
                        if (countDownInfo == null)
                        {
                            this.ShowMessage(msg, false, "", 1);
                            return;
                        }
                    }
                }
                if (orderInfo.FightGroupId > 0)
                {
                    if (paymentMode == null || (!TradeHelper.GatewayIsCanBackReturn(paymentMode.Gateway) && paymentMode.Gateway != EnumDescription.GetEnumDescription((Enum)(object)EnumPaymentType.AdvancePay, 1)))
                    {
                        this.ShowMessage("火拼团订单不支付该支付方式进行支付", false, "", 1);
                        return;
                    }
                    foreach (KeyValuePair <string, LineItemInfo> lineItem in orderInfo.LineItems)
                    {
                        FightGroupActivityInfo fightGroupActivityInfo = VShopHelper.CheckUserFightGroup(lineItem.Value.ProductId, orderInfo.FightGroupActivityId, orderInfo.FightGroupId, lineItem.Value.SkuId, HiContext.Current.UserId, orderInfo.GetAllQuantity(true), orderInfo.OrderId, lineItem.Value.Quantity, out msg);
                        if (fightGroupActivityInfo == null)
                        {
                            this.ShowMessage(msg, false, "", 1);
                            return;
                        }
                    }
                }
                if (orderInfo.GroupBuyId > 0 && list.Contains(paymentMode.Gateway.ToLower().Trim()))
                {
                    msg = "团购的订单不支持货到付款和线下支付";
                    this.ShowMessage(msg, false, "", 1);
                }
                else
                {
                    if (orderInfo.PreSaleId > 0)
                    {
                        if (paymentMode.Gateway.ToLower().Trim() == "hishop.plugins.payment.podrequest")
                        {
                            this.ShowMessage("预售订单不支持货到付款", false, "", 1);
                            return;
                        }
                        ProductPreSaleInfo productPreSaleInfo = ProductPreSaleHelper.GetProductPreSaleInfo(orderInfo.PreSaleId);
                        if (productPreSaleInfo == null)
                        {
                            this.ShowMessage("预售活动不存在,不能支付", false, "", 1);
                            return;
                        }
                        if (!orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay && productPreSaleInfo.PreSaleEndDate < DateTime.Now)
                        {
                            this.ShowMessage("您支付晚了,预售活动已经结束", false, "", 1);
                            return;
                        }
                        if (orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay)
                        {
                            if (productPreSaleInfo.PaymentStartDate > DateTime.Now)
                            {
                                this.ShowMessage("尾款支付尚未开始", false, "", 1);
                                return;
                            }
                            DateTime dateTime = productPreSaleInfo.PaymentEndDate;
                            DateTime date     = dateTime.Date;
                            dateTime = DateTime.Now;
                            if (date < dateTime.Date)
                            {
                                this.ShowMessage("尾款支付已结束", false, "", 1);
                                return;
                            }
                        }
                    }
                    if (paymentMode != null)
                    {
                        orderInfo.PaymentTypeId = paymentMode.ModeId;
                        orderInfo.PaymentType   = paymentMode.Name;
                        orderInfo.Gateway       = paymentMode.Gateway;
                        TradeHelper.UpdateOrderPaymentType(orderInfo);
                    }
                    this.Page.Response.Redirect(base.GetRouteUrl("sendPayment", new
                    {
                        orderId = value
                    }));
                }
            }
        }
示例#2
0
        public void ConfirmPay(HttpContext context)
        {
            string text = context.Request["id"];

            if (string.IsNullOrWhiteSpace(text))
            {
                throw new HidistroAshxException("错误的编号");
            }
            OrderInfo orderInfo = new OrderDao().GetOrderInfo(text);

            if (orderInfo == null)
            {
                throw new HidistroAshxException("错误的编号");
            }
            if (!orderInfo.CheckAction(OrderActions.SELLER_CONFIRM_PAY))
            {
                throw new HidistroAshxException("权限不足");
            }
            PaymentModeInfo paymentMode = SalesHelper.GetPaymentMode("hishop.plugins.payment.bankrequest");

            if (paymentMode != null)
            {
                orderInfo.Gateway       = paymentMode.Gateway;
                orderInfo.PaymentType   = paymentMode.Name;
                orderInfo.PaymentTypeId = paymentMode.ModeId;
            }
            else
            {
                orderInfo.Gateway       = "hishop.plugins.payment.bankrequest";
                orderInfo.PaymentType   = "线下支付";
                orderInfo.PaymentTypeId = 0;
            }
            int num  = 0;
            int num2 = 0;
            int num3 = 0;

            if (orderInfo.CountDownBuyId > 0)
            {
                string empty = string.Empty;
                foreach (KeyValuePair <string, LineItemInfo> lineItem in orderInfo.LineItems)
                {
                    CountDownInfo countDownInfo = TradeHelper.CheckUserCountDown(lineItem.Value.ProductId, orderInfo.CountDownBuyId, lineItem.Value.SkuId, orderInfo.UserId, orderInfo.GetAllQuantity(true), orderInfo.OrderId, out empty, orderInfo.StoreId);
                    if (countDownInfo == null)
                    {
                        throw new HidistroAshxException(empty);
                    }
                }
            }
            if (orderInfo.FightGroupId > 0)
            {
                string empty2 = string.Empty;
                foreach (KeyValuePair <string, LineItemInfo> lineItem2 in orderInfo.LineItems)
                {
                    FightGroupActivityInfo fightGroupActivityInfo = VShopHelper.CheckUserFightGroup(lineItem2.Value.ProductId, orderInfo.FightGroupActivityId, orderInfo.FightGroupId, lineItem2.Value.SkuId, orderInfo.UserId, orderInfo.GetAllQuantity(true), orderInfo.OrderId, lineItem2.Value.Quantity, out empty2);
                    if (fightGroupActivityInfo == null)
                    {
                        throw new HidistroAshxException(empty2);
                    }
                }
            }
            if (orderInfo.GroupBuyId > 0)
            {
                GroupBuyInfo groupBuy = PromoteHelper.GetGroupBuy(orderInfo.GroupBuyId);
                if (groupBuy == null || groupBuy.Status != GroupBuyStatus.UnderWay)
                {
                    throw new HidistroAshxException("当前的订单为团购订单,此团购活动已结束,所以不能支付");
                }
                num2 = PromoteHelper.GetOrderCount(orderInfo.GroupBuyId);
                num  = groupBuy.MaxCount;
                num3 = orderInfo.GetGroupBuyOerderNumber();
                if (num < num2 + num3)
                {
                    throw new HidistroAshxException("当前的订单为团购订单,订购数量已超过订购总数,所以不能支付");
                }
            }
            if (orderInfo.PreSaleId > 0)
            {
                ProductPreSaleInfo productPreSaleInfo = ProductPreSaleHelper.GetProductPreSaleInfo(orderInfo.PreSaleId);
                if (productPreSaleInfo == null)
                {
                    throw new HidistroAshxException("预售活动不存在");
                }
                if (!orderInfo.DepositDate.HasValue && productPreSaleInfo.PreSaleEndDate < DateTime.Now)
                {
                    throw new HidistroAshxException("预售活动已结束不能支付定金,所以不能确认收款");
                }
            }
            string empty3 = string.Empty;

            switch (TradeHelper.CheckOrderBeforePay(orderInfo, out empty3))
            {
            case 1:
                throw new HidistroAshxException($"当前有商品{empty3}下架或者被删除,不能确认收款");

            case 2:
                if ((orderInfo.PreSaleId <= 0 || orderInfo.DepositDate.HasValue) && orderInfo.PreSaleId > 0)
                {
                    break;
                }
                throw new HidistroAshxException($"当前有商品{empty3}库存不足,不能确认收款");
            }
            if (OrderHelper.ConfirmPay(orderInfo))
            {
                if (orderInfo.GroupBuyId > 0 && num == num2 + num3)
                {
                    PromoteHelper.SetGroupBuyEndUntreated(orderInfo.GroupBuyId);
                }
                if (orderInfo.ParentOrderId == "-1")
                {
                    OrderQuery orderQuery = new OrderQuery();
                    orderQuery.ParentOrderId = orderInfo.OrderId;
                    IList <OrderInfo> listUserOrder = MemberProcessor.GetListUserOrder(orderInfo.UserId, orderQuery);
                    foreach (OrderInfo item in listUserOrder)
                    {
                        OrderHelper.OrderConfirmPaySendMessage(item);
                    }
                }
                else
                {
                    OrderHelper.OrderConfirmPaySendMessage(orderInfo);
                }
                base.ReturnSuccessResult(context, "成功的确认了订单收款", 0, true);
                return;
            }
            throw new HidistroAshxException("确认订单收款失败");
        }
示例#3
0
        protected override void AttachChildControls()
        {
            this.orderId = base.GetParameter("orderId", false);
            if (base.GetParameter("isCallback", false).ToBool())
            {
                HiContext.Current.Context.Response.Clear();
                HiContext.Current.Context.Response.ContentType = "application/json";
                string parameter = base.GetParameter("action", false);
                if (parameter.Equals("ToPay"))
                {
                    string    empty     = string.Empty;
                    OrderInfo orderInfo = ShoppingProcessor.GetOrderInfo(this.orderId);
                    if (orderInfo != null || orderInfo.UserId != HiContext.Current.UserId)
                    {
                        if (orderInfo.OrderStatus != OrderStatus.WaitBuyerPay)
                        {
                            HiContext.Current.Context.Response.Write("{\"Status\":0,\"Msg\":\"当前订单不是等待付款状态\"}");
                            return;
                        }
                        if (orderInfo.CountDownBuyId > 0)
                        {
                            foreach (KeyValuePair <string, LineItemInfo> lineItem in orderInfo.LineItems)
                            {
                                CountDownInfo countDownInfo = TradeHelper.CheckUserCountDown(lineItem.Value.ProductId, orderInfo.CountDownBuyId, lineItem.Value.SkuId, HiContext.Current.UserId, orderInfo.GetAllQuantity(true), orderInfo.OrderId, out empty, orderInfo.StoreId);
                                if (countDownInfo == null)
                                {
                                    HiContext.Current.Context.Response.Write("{\"Status\":0,\"Msg\":\"" + empty + "\"}");
                                    return;
                                }
                            }
                        }
                        if (orderInfo.FightGroupId > 0)
                        {
                            foreach (KeyValuePair <string, LineItemInfo> lineItem2 in orderInfo.LineItems)
                            {
                                FightGroupActivityInfo fightGroupActivityInfo = VShopHelper.CheckUserFightGroup(lineItem2.Value.ProductId, orderInfo.FightGroupActivityId, orderInfo.FightGroupId, lineItem2.Value.SkuId, HiContext.Current.UserId, orderInfo.GetAllQuantity(true), orderInfo.OrderId, lineItem2.Value.Quantity, out empty);
                                if (fightGroupActivityInfo == null)
                                {
                                    HiContext.Current.Context.Response.Write("{\"Status\":0,\"Msg\":\"" + empty + "\"}");
                                    return;
                                }
                            }
                        }
                        if (orderInfo.PreSaleId > 0)
                        {
                            ProductPreSaleInfo productPreSaleInfo = ProductPreSaleHelper.GetProductPreSaleInfo(orderInfo.PreSaleId);
                            if (productPreSaleInfo == null)
                            {
                                HiContext.Current.Context.Response.Write("{\"Status\":0,\"Msg\":\"预售活动不存在不能支付\"}");
                                return;
                            }
                            if (!orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay && productPreSaleInfo.PreSaleEndDate < DateTime.Now)
                            {
                                HiContext.Current.Context.Response.Write("{\"Status\":0,\"Msg\":\"您支付晚了,预售活动已经结束\"}");
                                return;
                            }
                            if (orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay)
                            {
                                if (productPreSaleInfo.PaymentStartDate > DateTime.Now)
                                {
                                    HiContext.Current.Context.Response.Write("{\"Status\":0,\"Msg\":\"尾款支付尚未开始\"}");
                                    return;
                                }
                                DateTime dateTime = productPreSaleInfo.PaymentEndDate;
                                DateTime date     = dateTime.Date;
                                dateTime = DateTime.Now;
                                if (date < dateTime.Date)
                                {
                                    HiContext.Current.Context.Response.Write("{\"Status\":0,\"Msg\":\"尾款支付已结束\"}");
                                    return;
                                }
                            }
                        }
                        int             modeId      = base.GetParameter("paymentModeId", false).ToInt(0);
                        PaymentModeInfo paymentMode = ShoppingProcessor.GetPaymentMode(modeId);
                        if (paymentMode == null)
                        {
                            HiContext.Current.Context.Response.Write("{\"Status\":0,\"Msg\":\"请选择支付方式\"}");
                            return;
                        }
                        orderInfo.PaymentTypeId = paymentMode.ModeId;
                        orderInfo.Gateway       = paymentMode.Gateway;
                        orderInfo.PaymentType   = paymentMode.Name;
                        if (TradeHelper.UpdateOrderPaymentType(orderInfo))
                        {
                            string empty2 = string.Empty;
                            empty2 = ((!(orderInfo.Gateway.ToLower() != "hishop.plugins.payment.advancerequest")) ? ("{\"Status\":1,\"Msg\":\"" + $"/user/pay.aspx?OrderId={this.orderId}" + "\"}") : ((!(orderInfo.Gateway.ToLower() == "hishop.plugins.payment.bankrequest")) ? ("{\"Status\":1,\"Msg\":\"" + base.GetRouteUrl("sendPayment", new
                            {
                                this.orderId
                            }) + "\"}") : ("{\"Status\":1,\"Msg\":\"" + Globals.FullPath(base.GetRouteUrl("bank_pay", new
                            {
                                orderInfo.OrderId
                            })) + "\"}")));
                            HttpContext.Current.Response.Write(empty2);
                            HttpContext.Current.Response.End();
                            return;
                        }
                        goto IL_058f;
                    }
                    HiContext.Current.Context.Response.Write("{\"Status\":0,\"Msg\":\"错误的订单信息\"}");
                    HttpContext.Current.Response.End();
                    return;
                }
            }
            goto IL_058f;
IL_058f:
            if (string.IsNullOrEmpty(this.orderId))
            {
                base.GotoResourceNotFound();
            }
            this.litOrderId           = (Literal)this.FindControl("litOrderId");
            this.litOrderPrice        = (FormatedMoneyLabel)this.FindControl("litOrderPrice");
            this.promptMsg            = (HtmlGenericControl)this.FindControl("promptMsg");
            this.onlinePayPanel       = (HtmlGenericControl)this.FindControl("onlinePayPanel");
            this.btnOrderPay          = ButtonManager.Create(this.FindControl("btnOrderPay"));
            this.paymentModeList      = (Common_PaymentModeList)this.FindControl("grd_Common_PaymentModeList");
            this.paymentModeId        = (HtmlInputHidden)this.FindControl("paymentModeId");
            this.AdvanceId            = (HtmlInputHidden)this.FindControl("AdvanceId");
            this.hidOrderid           = (HtmlInputHidden)this.FindControl("hidOrderid");
            this.msgTitle             = (HtmlGenericControl)this.FindControl("msgTitle");
            this.hidIspop             = (HiddenField)this.FindControl("hidIspop");
            this.userLink             = (HtmlAnchor)this.FindControl("userLink");
            this.orderLink            = (HtmlAnchor)this.FindControl("orderLink");
            this.divfinish            = (HtmlGenericControl)this.FindControl("divfinish");
            this.userLink.HRef        = "/User/UserDefault";
            this.divOrderPayInfo      = (HtmlGenericControl)this.FindControl("divOrderPayInfo");
            this.imgPayResult         = (HtmlImage)this.FindControl("imgPayResult");
            this.hidIsPreSale         = (HiddenField)this.FindControl("hidIsPreSale");
            this.litDeposit           = (FormatedMoneyLabel)this.FindControl("litDeposit");
            this.litDeposittxt        = (Literal)this.FindControl("litDeposittxt");
            this.demodiv              = (HtmlGenericControl)this.FindControl("demodiv");
            this.demodiv.Visible      = SettingsManager.GetMasterSettings().IsDemoSite;
            this.hidHasTradePassword  = (HtmlInputHidden)this.FindControl("hidHasTradePassword");
            this.litOfflinePayContent = (Literal)this.FindControl("litOfflinePayContent");
            this.offlinePayPanel      = (HtmlGenericControl)this.FindControl("offlinePayPanel");
            if (!this.Page.IsPostBack)
            {
                this.LoadOrderInfo();
            }
        }
示例#4
0
        private void GotoPay()
        {
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();
            OrderInfo    orderInfo      = ShoppingProcessor.GetOrderInfo(this.orderId);
            string       str            = "";

            if (orderInfo == null)
            {
                this.litErrorMsg.Text = "数据错误!";
            }
            else
            {
                if (orderInfo.PreSaleId > 0)
                {
                    ProductPreSaleInfo productPreSaleInfo = ProductPreSaleHelper.GetProductPreSaleInfo(orderInfo.PreSaleId);
                    if (productPreSaleInfo == null)
                    {
                        this.litErrorMsg.Text = "预售活动不存在不能支付";
                        return;
                    }
                    if (!orderInfo.DepositDate.HasValue)
                    {
                        if (productPreSaleInfo.PreSaleEndDate < DateTime.Now)
                        {
                            this.litErrorMsg.Text = "您支付晚了,预售活动已经结束";
                            return;
                        }
                        if (!TradeHelper.CheckOrderStockBeforePay(orderInfo, out str))
                        {
                            this.litErrorMsg.Text = str + ",库存不足,不能进行支付";
                            return;
                        }
                    }
                    if (orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay)
                    {
                        if (productPreSaleInfo.PaymentStartDate > DateTime.Now)
                        {
                            this.litErrorMsg.Text = "尾款支付尚未开始";
                            return;
                        }
                        DateTime t = productPreSaleInfo.PaymentEndDate.AddDays(1.0);
                        if (t <= DateTime.Now)
                        {
                            this.litErrorMsg.Text = "尾款支付已结束,不能支付!";
                            return;
                        }
                    }
                }
                else if (!TradeHelper.CheckOrderStockBeforePay(orderInfo, out str))
                {
                    this.litErrorMsg.Text = str + ",库存不足,不能进行支付";
                    return;
                }
                if (orderInfo.CountDownBuyId > 0)
                {
                    string empty = string.Empty;
                    foreach (KeyValuePair <string, LineItemInfo> lineItem in orderInfo.LineItems)
                    {
                        CountDownInfo countDownInfo = TradeHelper.CheckUserCountDown(lineItem.Value.ProductId, orderInfo.CountDownBuyId, lineItem.Value.SkuId, HiContext.Current.UserId, orderInfo.GetAllQuantity(true), orderInfo.OrderId, out empty, orderInfo.StoreId);
                        if (countDownInfo == null)
                        {
                            this.litErrorMsg.Text = empty;
                            return;
                        }
                    }
                }
                if (orderInfo.FightGroupId > 0)
                {
                    string empty2 = string.Empty;
                    foreach (KeyValuePair <string, LineItemInfo> lineItem2 in orderInfo.LineItems)
                    {
                        FightGroupActivityInfo fightGroupActivityInfo = VShopHelper.CheckUserFightGroup(lineItem2.Value.ProductId, orderInfo.FightGroupActivityId, orderInfo.FightGroupId, lineItem2.Value.SkuId, HiContext.Current.UserId, orderInfo.GetAllQuantity(true), orderInfo.OrderId, lineItem2.Value.Quantity, out empty2);
                        if (fightGroupActivityInfo == null)
                        {
                            this.litErrorMsg.Text = empty2;
                            return;
                        }
                    }
                }
                string  text   = orderInfo.OrderId;
                decimal amount = orderInfo.GetTotal(true);
                text = orderInfo.PayOrderId;
                if (orderInfo.PreSaleId > 0)
                {
                    if (!orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay)
                    {
                        amount = orderInfo.Deposit;
                    }
                    if (orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay)
                    {
                        amount = orderInfo.FinalPayment;
                    }
                }
                this.litErrorMsg.Text = "";
                if (orderInfo.Gateway == "hishop.plugins.payment.advancerequest")
                {
                    this.Page.Response.Redirect("TransactionPwd?orderId=" + this.Page.Request.QueryString["orderId"] + "&totalAmount=" + orderInfo.GetTotal(false).F2ToString("f2"));
                }
                if (orderInfo.Gateway == "hishop.plugins.payment.ws_apppay.wswappayrequest")
                {
                    HttpContext.Current.Response.Redirect("~/pay/app_alipay_Submit?orderId=" + orderInfo.OrderId);
                }
                PaymentModeInfo paymentMode = ShoppingProcessor.GetPaymentMode(orderInfo.Gateway);
                if (orderInfo.Gateway == "hishop.plugins.payment.ws_wappay.wswappayrequest")
                {
                    if (!masterSettings.EnableAppWapAliPay)
                    {
                        this.litErrorMsg.Text = "未开启支付宝网页支付";
                    }
                    else
                    {
                        string         attach         = "";
                        string         showUrl        = $"http://{HttpContext.Current.Request.Url.Host}/AppShop/MemberOrderDetails?orderId={orderInfo.OrderId}";
                        PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), text, amount, "订单支付", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, showUrl, Globals.FullPath("/pay/wap_alipay_return_url"), Globals.FullPath("/pay/wap_alipay_notify_url"), attach);
                        paymentRequest.SendRequest();
                    }
                }
                else if (orderInfo.Gateway == "Hishop.Plugins.Payment.ShengPayMobile.ShengPayMobileRequest")
                {
                    if (!masterSettings.EnableAppShengPay)
                    {
                        this.litErrorMsg.Text = "未开启盛付通手机网页支付";
                    }
                    else
                    {
                        string         attach2         = "";
                        string         text2           = $"http://{HttpContext.Current.Request.Url.Host}/AppShop/";
                        PaymentRequest paymentRequest2 = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), text, amount, "订单支付", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, text2, text2 + "MemberOrderDetails?orderId=" + orderInfo.OrderId, Globals.FullPath("/pay/wap_sheng_return_url"), attach2);
                        paymentRequest2.SendRequest();
                    }
                }
                else if (orderInfo.Gateway == "hishop.plugins.payment.bankuniongateway.bankuniongetwayrequest")
                {
                    if (!masterSettings.EnableAPPBankUnionPay)
                    {
                        this.litErrorMsg.Text = "未开启银联全渠道支付";
                    }
                    else
                    {
                        string         attach3         = "";
                        string         showUrl2        = $"http://{HttpContext.Current.Request.Url.Host}/AppShop/";
                        PaymentRequest paymentRequest3 = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), text, amount, "订单支付", "订单号-" + orderInfo.OrderId, orderInfo.EmailAddress, orderInfo.OrderDate, showUrl2, Globals.FullPath("/pay/wap_bankunion_return_url"), Globals.FullPath("/pay/wap_bankunion_notify_url"), attach3);
                        paymentRequest3.SendRequest();
                    }
                }
                else
                {
                    if (orderInfo.Gateway == "hishop.plugins.payment.weixinrequest" || orderInfo.Gateway == "hishop.plugins.payment.appwxrequest")
                    {
                        if (!masterSettings.OpenAppWxPay || string.IsNullOrEmpty(masterSettings.AppWxAppId) || string.IsNullOrEmpty(masterSettings.AppWxAppSecret) || string.IsNullOrEmpty(masterSettings.AppWxMchId) || string.IsNullOrEmpty(masterSettings.AppWxPartnerKey))
                        {
                            this.litErrorMsg.Text = "APP未开通微信支付";
                            return;
                        }
                        HttpContext.Current.Response.Redirect("~/pay/H5WxPay_Submit?orderId=" + orderInfo.OrderId);
                    }
                    if (paymentMode == null)
                    {
                        this.litErrorMsg.Text = "错误的支付方式";
                    }
                    else
                    {
                        this.litErrorMsg.Text = "APP不支持使用" + paymentMode.Name + "进行支付";
                    }
                }
            }
        }
示例#5
0
        private void GotoPay()
        {
            SiteSettings masterSettings = SettingsManager.GetMasterSettings();
            string       text           = "";
            string       text2          = HttpContext.Current.Request.UserAgent;

            if (string.IsNullOrEmpty(text2))
            {
                text2 = "";
            }
            text2 = text2.ToLower();
            string str = "";

            if (this.order == null)
            {
                this.litErrorMsg.Text = "订单数据错误";
            }
            else
            {
                DateTime dateTime;
                if (this.order.PreSaleId > 0)
                {
                    ProductPreSaleInfo productPreSaleInfo = ProductPreSaleHelper.GetProductPreSaleInfo(this.order.PreSaleId);
                    if (productPreSaleInfo == null)
                    {
                        this.litErrorMsg.Text = "预售活动不存在不能支付";
                        return;
                    }
                    if (!this.order.DepositDate.HasValue)
                    {
                        if (productPreSaleInfo.PreSaleEndDate < DateTime.Now)
                        {
                            this.litErrorMsg.Text = "您支付晚了,预售活动已经结束";
                            return;
                        }
                        if (!TradeHelper.CheckOrderStockBeforePay(this.order, out str))
                        {
                            this.litErrorMsg.Text = str + ",库存不足,不能进行支付";
                            return;
                        }
                    }
                    if (this.order.DepositDate.HasValue && this.order.OrderStatus == OrderStatus.WaitBuyerPay)
                    {
                        if (productPreSaleInfo.PaymentStartDate > DateTime.Now)
                        {
                            this.litErrorMsg.Text = "尾款支付尚未开始";
                            return;
                        }
                        dateTime = productPreSaleInfo.PaymentEndDate;
                        DateTime t = dateTime.AddDays(1.0);
                        if (t <= DateTime.Now)
                        {
                            this.litErrorMsg.Text = "尾款支付已结束,不能支付!";
                            return;
                        }
                    }
                }
                else if (!TradeHelper.CheckOrderStockBeforePay(this.order, out str))
                {
                    this.litErrorMsg.Text = str + ",库存不足,不能进行支付";
                    return;
                }
                string getClientPath = HiContext.Current.GetClientPath;
                this.litErrorMsg.Text = "";
                PaymentModeInfo paymentMode = ShoppingProcessor.GetPaymentMode(this.order.Gateway);
                if (string.IsNullOrEmpty(text))
                {
                    text = this.order.Gateway;
                }
                if (this.order.CountDownBuyId > 0)
                {
                    string empty = string.Empty;
                    foreach (KeyValuePair <string, LineItemInfo> lineItem in this.order.LineItems)
                    {
                        CountDownInfo countDownInfo = TradeHelper.CheckUserCountDown(lineItem.Value.ProductId, this.order.CountDownBuyId, lineItem.Value.SkuId, HiContext.Current.UserId, this.order.GetAllQuantity(true), this.order.OrderId, out empty, this.order.StoreId);
                        if (countDownInfo == null)
                        {
                            this.litErrorMsg.Text = empty;
                            return;
                        }
                    }
                }
                if (this.order.FightGroupId > 0)
                {
                    string empty2 = string.Empty;
                    foreach (KeyValuePair <string, LineItemInfo> lineItem2 in this.order.LineItems)
                    {
                        FightGroupActivityInfo fightGroupActivityInfo = VShopHelper.CheckUserFightGroup(lineItem2.Value.ProductId, this.order.FightGroupActivityId, this.order.FightGroupId, lineItem2.Value.SkuId, HiContext.Current.UserId, this.order.GetAllQuantity(true), this.order.OrderId, lineItem2.Value.Quantity, out empty2);
                        if (fightGroupActivityInfo == null)
                        {
                            this.litErrorMsg.Text = empty2;
                            return;
                        }
                    }
                }
                if (!string.IsNullOrEmpty(text))
                {
                    text = text.ToLower();
                }
                string  text3 = this.order.OrderId;
                decimal num   = this.order.GetTotal(true);
                text3 = this.order.PayOrderId;
                if (this.order.PreSaleId > 0)
                {
                    if (!this.order.DepositDate.HasValue && this.order.OrderStatus == OrderStatus.WaitBuyerPay)
                    {
                        num = this.order.Deposit - this.order.BalanceAmount;
                    }
                    if (this.order.DepositDate.HasValue && this.order.OrderStatus == OrderStatus.WaitBuyerPay)
                    {
                        num = this.order.FinalPayment;
                    }
                }
                if (this.order.Gateway == "hishop.plugins.payment.advancerequest")
                {
                    this.Page.Response.Redirect("TransactionPwd?orderId=" + this.Page.Request.QueryString["orderId"] + "&totalAmount=" + num.F2ToString("f2"));
                }
                if (text == "hishop.plugins.payment.shengpaymobile.shengpaymobilerequest")
                {
                    if (!masterSettings.EnableWapShengPay)
                    {
                        this.litErrorMsg.Text = "未开启盛付通手机网页支付";
                    }
                    else
                    {
                        string     text4  = "\"outMemberId\":\"{0}\",\"outMemberRegisterTime\":\"{1}\",\"outMemberRegisterIP\":\"{2}\",\"outMemberVerifyStatus\":{3},\"outMemberName\":\"{4}\",\"outMemberMobile\":\"{5}\",\"attach\":\"{6}\"";
                        MemberInfo user   = HiContext.Current.User;
                        string     format = text4;
                        object[]   obj    = new object[7]
                        {
                            user.UserId,
                            null,
                            null,
                            null,
                            null,
                            null,
                            null
                        };
                        dateTime = user.CreateDate;
                        obj[1]   = dateTime.ToString("yyyyMMddHHmmss");
                        obj[2]   = "";
                        obj[3]   = 0;
                        obj[4]   = (string.IsNullOrEmpty(user.NickName) ? user.UserName : user.NickName);
                        obj[5]   = (string.IsNullOrEmpty(user.CellPhone) ? "13566778899" : user.CellPhone);
                        obj[6]   = "";
                        string         attach         = "{" + string.Format(format, obj) + "}";
                        string         text5          = $"http://{HttpContext.Current.Request.Url.Host}/{getClientPath}/default";
                        PaymentRequest paymentRequest = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), text3, num, "订单支付", "订单号-" + this.order.OrderId, this.order.EmailAddress, this.order.OrderDate, text5, text5, Globals.FullPath("/pay/wap_sheng_return_url"), attach);
                        paymentRequest.SendRequest();
                    }
                }
                else if (text == "hishop.plugins.payment.ws_wappay.wswappayrequest")
                {
                    if ((!masterSettings.EnableWeixinWapAliPay && base.ClientType == ClientType.VShop) || (!masterSettings.EnableWapAliPay && (base.ClientType == ClientType.WAP || base.ClientType == ClientType.AliOH)))
                    {
                        this.litErrorMsg.Text = "未开启支付宝网页支付";
                    }
                    else if (text2.IndexOf("micromessenger") > -1)
                    {
                        this.loadPanel.Visible  = false;
                        this.sharePanel.Visible = true;
                    }
                    else
                    {
                        this.loadPanel.Visible  = true;
                        this.sharePanel.Visible = false;
                        string         attach2         = "";
                        string         showUrl         = $"http://{HttpContext.Current.Request.Url.Host}/{getClientPath}/";
                        PaymentRequest paymentRequest2 = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), text3, num, "订单支付", "订单号-" + this.order.OrderId, this.order.EmailAddress, this.order.OrderDate, showUrl, Globals.FullPath("/pay/wap_alipay_return_url"), Globals.FullPath("/pay/wap_alipay_notify_url"), attach2);
                        paymentRequest2.SendRequest();
                    }
                }
                else if (this.order.Gateway == "hishop.plugins.payment.alipaycrossbordermobilepayment.alipaycrossbordermobilepaymentrequest")
                {
                    if (!masterSettings.EnableWapAliPayCrossBorder || base.ClientType != ClientType.WAP)
                    {
                        this.litErrorMsg.Text = "未开启支付宝跨境网页支付";
                    }
                    else
                    {
                        string attach3  = "";
                        string showUrl2 = $"http://{HttpContext.Current.Request.Url.Host}/{getClientPath}/";
                        text3 = this.order.OrderId;
                        text3 = this.order.PayOrderId;
                        PaymentRequest paymentRequest3 = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), text3, num, "OrderPay", "Order_No-" + this.order.OrderId, this.order.EmailAddress, this.order.OrderDate, showUrl2, Globals.FullPath("/pay/wap_alipay_cross_border_return_url"), Globals.FullPath("/pay/wap_alipay_cross_border_notify_url"), attach3);
                        paymentRequest3.SendRequest();
                    }
                }
                else if (base.ClientType == ClientType.VShop)
                {
                    if (text == "hishop.plugins.payment.weixinrequest")
                    {
                        if (!masterSettings.EnableWeiXinRequest && this.order.OrderType == OrderType.ServiceOrder && !masterSettings.OpenWxAppletWxPay)
                        {
                            this.litErrorMsg.Text = "未开启支微信支付";
                            return;
                        }
                        HttpContext.Current.Response.Redirect("~/pay/wx_Submit?orderId=" + this.order.OrderId);
                    }
                    if (text == "hishop.plugins.payment.bankuniongateway.bankuniongetwayrequest")
                    {
                        if (!masterSettings.EnableBankUnionPay)
                        {
                            this.litErrorMsg.Text = "未开启银联全渠道支付";
                        }
                        else
                        {
                            string         attach4         = "";
                            string         showUrl3        = $"http://{HttpContext.Current.Request.Url.Host}/vshop/";
                            PaymentRequest paymentRequest4 = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), text3, num, "订单支付", "订单号-" + this.order.OrderId, this.order.EmailAddress, this.order.OrderDate, showUrl3, Globals.FullPath("/pay/wap_bankunion_return_url"), Globals.FullPath("/pay/wap_bankunion_notify_url"), attach4);
                            paymentRequest4.SendRequest();
                        }
                    }
                    else
                    {
                        if (text == "hishop.plugins.payment.alipaywx.alipaywxrequest")
                        {
                            if (!masterSettings.EnableWeixinWapAliPay)
                            {
                                this.litErrorMsg.Text = "未开启微信端支付宝支付";
                                return;
                            }
                            HttpContext.Current.Response.Redirect("~/vshop/WXAliPay?orderId=" + this.order.OrderId);
                        }
                        if (paymentMode == null)
                        {
                            this.litErrorMsg.Text = "错误的支付方式";
                        }
                        else
                        {
                            this.litErrorMsg.Text = "微信商城不支持使用" + paymentMode.Name + "进行支付";
                        }
                    }
                }
                else if (base.ClientType == ClientType.AliOH)
                {
                    if (text == "hishop.plugins.payment.bankuniongateway.bankuniongetwayrequest")
                    {
                        this.litErrorMsg.Text = "生活号不支持银联全渠道支付";
                    }
                    else
                    {
                        if (text == "hishop.plugins.payment.weixinrequest")
                        {
                            if (!masterSettings.EnableWapWeiXinPay)
                            {
                                this.litErrorMsg.Text = "未开启支微信支付";
                                return;
                            }
                            HttpContext.Current.Response.Redirect("~/pay/H5WxPay_Submit.aspx?orderId=" + this.order.OrderId);
                        }
                        if (paymentMode == null)
                        {
                            this.litErrorMsg.Text = "错误的支付方式";
                        }
                        else
                        {
                            this.litErrorMsg.Text = "生活号不支持使用" + paymentMode.Name + "进行支付";
                        }
                    }
                }
                else if (text == "hishop.plugins.payment.bankuniongateway.bankuniongetwayrequest")
                {
                    if (!masterSettings.EnableBankUnionPay)
                    {
                        this.litErrorMsg.Text = "未开启银联全渠道支付";
                    }
                    else
                    {
                        string         attach5         = "";
                        string         showUrl4        = $"http://{HttpContext.Current.Request.Url.Host}/{getClientPath}/";
                        PaymentRequest paymentRequest5 = PaymentRequest.CreateInstance(paymentMode.Gateway, HiCryptographer.Decrypt(paymentMode.Settings), text3, num, "订单支付", "订单号-" + this.order.OrderId, this.order.EmailAddress, this.order.OrderDate, showUrl4, Globals.FullPath("/pay/wap_bankunion_return_url"), Globals.FullPath("/pay/wap_bankunion_notify_url"), attach5);
                        paymentRequest5.SendRequest();
                    }
                }
                else
                {
                    if (text == "hishop.plugins.payment.weixinrequest")
                    {
                        if (!masterSettings.EnableWapWeiXinPay)
                        {
                            this.litErrorMsg.Text = "未开启支微信支付";
                            return;
                        }
                        HttpContext.Current.Response.Redirect("~/pay/H5WxPay_Submit.aspx?orderId=" + this.order.OrderId);
                    }
                    if (paymentMode == null)
                    {
                        this.litErrorMsg.Text = "错误的支付方式";
                    }
                    else
                    {
                        this.litErrorMsg.Text = "触屏版不支持使用" + paymentMode.Name + "进行支付";
                    }
                }
            }
        }
示例#6
0
        protected void btnPay_Click(object sender, EventArgs e)
        {
            MemberInfo user = HiContext.Current.User;

            if (string.IsNullOrEmpty(user.TradePassword))
            {
                this.Page.Response.Redirect("/user/OpenBalance.aspx");
            }
            string    empty     = string.Empty;
            OrderInfo orderInfo = TradeHelper.GetOrderInfo(this.orderId);
            int       num       = 0;
            int       num2      = 0;
            int       num3      = 0;

            if (orderInfo.CountDownBuyId > 0)
            {
                foreach (KeyValuePair <string, LineItemInfo> lineItem in orderInfo.LineItems)
                {
                    CountDownInfo countDownInfo = TradeHelper.CheckUserCountDown(lineItem.Value.ProductId, orderInfo.CountDownBuyId, lineItem.Value.SkuId, HiContext.Current.UserId, orderInfo.GetAllQuantity(true), orderInfo.OrderId, out empty, orderInfo.StoreId);
                    if (countDownInfo == null)
                    {
                        this.ShowMessage(empty, false, "", 1);
                        return;
                    }
                }
            }
            if (orderInfo.FightGroupId > 0)
            {
                foreach (KeyValuePair <string, LineItemInfo> lineItem2 in orderInfo.LineItems)
                {
                    FightGroupActivityInfo fightGroupActivityInfo = VShopHelper.CheckUserFightGroup(lineItem2.Value.ProductId, orderInfo.FightGroupActivityId, orderInfo.FightGroupId, lineItem2.Value.SkuId, HiContext.Current.UserId, orderInfo.GetAllQuantity(true), orderInfo.OrderId, lineItem2.Value.Quantity, out empty);
                    if (fightGroupActivityInfo == null)
                    {
                        this.ShowMessage(empty, false, "", 1);
                        return;
                    }
                }
            }
            if (orderInfo.GroupBuyId > 0)
            {
                GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(orderInfo.GroupBuyId);
                if (groupBuy == null || groupBuy.Status != GroupBuyStatus.UnderWay)
                {
                    this.ShowMessage("当前的订单为团购订单,此团购活动已结束,所以不能支付", false, "", 1);
                    return;
                }
                num2 = TradeHelper.GetOrderCount(orderInfo.GroupBuyId);
                num3 = orderInfo.GetGroupBuyOerderNumber();
                num  = groupBuy.MaxCount;
                if (num < num2 + num3)
                {
                    this.ShowMessage("当前的订单为团购订单,订购数量已超过订购总数,所以不能支付", false, "", 1);
                    return;
                }
            }
            if (orderInfo.PreSaleId > 0)
            {
                ProductPreSaleInfo productPreSaleInfo = ProductPreSaleHelper.GetProductPreSaleInfo(orderInfo.PreSaleId);
                if (productPreSaleInfo == null)
                {
                    this.ShowMessage("预售活动不存在不能支付", false, "", 1);
                    return;
                }
                if (!orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay && productPreSaleInfo.PreSaleEndDate < DateTime.Now)
                {
                    this.ShowMessage("您支付晚了,预售活动已经结束", false, "", 1);
                    return;
                }
                if (orderInfo.DepositDate.HasValue && orderInfo.OrderStatus == OrderStatus.WaitBuyerPay)
                {
                    if (productPreSaleInfo.PaymentStartDate > DateTime.Now)
                    {
                        this.ShowMessage("尾款支付尚未开始", false, "", 1);
                        return;
                    }
                    DateTime dateTime = productPreSaleInfo.PaymentEndDate;
                    DateTime date     = dateTime.Date;
                    dateTime = DateTime.Now;
                    if (date < dateTime.Date)
                    {
                        this.ShowMessage("尾款支付已结束", false, "", 1);
                        return;
                    }
                }
            }
            if (!orderInfo.CheckAction(OrderActions.BUYER_PAY))
            {
                this.ShowMessage("当前的订单订单状态不是等待付款,所以不能支付", false, "", 1);
            }
            else if (HiContext.Current.UserId != orderInfo.UserId)
            {
                this.ShowMessage("预付款只能为自己下的订单付款,查一查该订单是不是你的", false, "", 1);
            }
            else if ((decimal)this.litUseableBalance.Money < orderInfo.GetTotal(false))
            {
                this.ShowMessage("预付款余额不足,支付失败", false, "", 1);
            }
            else if (MemberProcessor.ValidTradePassword(this.txtPassword.Text))
            {
                string str = "";
                if (!TradeHelper.CheckOrderStock(orderInfo, out str))
                {
                    this.ShowMessage("订单中有商品(" + str + ")库存不足", false, "", 1);
                }
                else
                {
                    Dictionary <string, LineItemInfo> lineItems = orderInfo.LineItems;
                    foreach (LineItemInfo value in lineItems.Values)
                    {
                        int skuStock = ShoppingCartProcessor.GetSkuStock(value.SkuId, 0);
                        if (skuStock < value.ShipmentQuantity)
                        {
                            this.ShowMessage("订单中商品库存不足,禁止支付!", false, "", 1);
                            return;
                        }
                    }
                    if (TradeHelper.UserPayOrder(orderInfo, true, false))
                    {
                        if (orderInfo.GroupBuyId > 0 && num == num2 + num3)
                        {
                            TradeHelper.SetGroupBuyEndUntreated(orderInfo.GroupBuyId);
                        }
                        if (orderInfo.ParentOrderId == "-1")
                        {
                            OrderQuery orderQuery = new OrderQuery();
                            orderQuery.ParentOrderId = orderInfo.OrderId;
                            IList <OrderInfo> listUserOrder = MemberProcessor.GetListUserOrder(orderInfo.UserId, orderQuery);
                            foreach (OrderInfo item in listUserOrder)
                            {
                                OrderHelper.OrderConfirmPaySendMessage(item);
                            }
                        }
                        else
                        {
                            OrderHelper.OrderConfirmPaySendMessage(orderInfo);
                        }
                        this.Page.Response.Redirect("/user/PaySucceed.aspx?orderId=" + this.orderId);
                    }
                    else
                    {
                        this.ShowMessage($"对订单{orderInfo.OrderId} 支付失败", false, "", 1);
                    }
                }
            }
            else
            {
                this.ShowMessage("交易密码有误,请重试", false, "", 1);
            }
        }