Beispiel #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
                    }));
                }
            }
        }
Beispiel #2
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);
            }
        }