private void UserPayOrder()
 {
     if (this.Order.OrderStatus == OrderStatus.BuyerAlreadyPaid)
     {
         this.ResponseStatus(true, "success");
     }
     else
     {
         int num  = 0;
         int num2 = 0;
         int num3 = 0;
         if (this.Order.GroupBuyId > 0)
         {
             GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(this.Order.GroupBuyId);
             if (groupBuy == null || groupBuy.Status != GroupBuyStatus.UnderWay)
             {
                 this.ResponseStatus(false, "groupbuyalreadyfinished");
                 return;
             }
             num2 = TradeHelper.GetOrderCount(this.Order.GroupBuyId);
             num3 = this.Order.GetGroupBuyOerderNumber();
             num  = groupBuy.MaxCount;
             if (num < num2 + num3)
             {
                 this.ResponseStatus(false, "exceedordermax");
                 return;
             }
         }
         if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UserPayOrder(this.Order, false))
         {
             TradeHelper.SaveDebitNote(new DebitNote
             {
                 NoteId   = Globals.GetGenerateId(),
                 OrderId  = this.Order.OrderId,
                 Operator = this.Order.Username,
                 Remark   = "客户订单在线支付成功"
             });
             if (this.Order.GroupBuyId > 0 && num == num2 + num3)
             {
                 TradeHelper.SetGroupBuyEndUntreated(this.Order.GroupBuyId);
             }
             if (this.Order.UserId != 0 && this.Order.UserId != 1100)
             {
                 Hidistro.Membership.Core.IUser user = Hidistro.Membership.Context.Users.GetUser(this.Order.UserId);
                 if (user != null && (user.UserRole == Hidistro.Membership.Core.Enums.UserRole.Member || user.UserRole == Hidistro.Membership.Core.Enums.UserRole.Underling))
                 {
                     Messenger.OrderPayment(user, this.Order.OrderId, this.Order.GetTotal());
                 }
             }
             this.Order.OnPayment();
             this.ResponseStatus(true, "success");
         }
         else
         {
             this.ResponseStatus(false, "fail");
         }
     }
 }
示例#2
0
        private void UserPayOrder()
        {
            if (this.Order.OrderStatus == OrderStatus.BuyerAlreadyPaid)
            {
                base.Response.Write("OK");
                base.Response.End();
                return;
            }
            int num  = 0;
            int num2 = 0;
            int num3 = 0;

            if (this.Order.GroupBuyId > 0)
            {
                GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(this.Order.GroupBuyId);
                if (groupBuy == null || groupBuy.Status != GroupBuyStatus.UnderWay)
                {
                    base.Response.Write("<p style=\"font-size:16px;\">订单为团购订单,团购活动已结束,支付失败</p>");
                    return;
                }
                num2 = TradeHelper.GetOrderCount(this.Order.GroupBuyId);
                num3 = this.Order.GetGroupBuyOerderNumber();
                num  = groupBuy.MaxCount;
                if (num < num2 + num3)
                {
                    base.Response.Write("<p style=\"font-size:16px;\">订单为团购订单,订购数量超过订购总数,支付失败</p>");
                    return;
                }
            }
            if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UserPayOrder(this.Order, false))
            {
                TradeHelper.SaveDebitNote(new DebitNoteInfo
                {
                    NoteId   = Globals.GetGenerateId(),
                    OrderId  = this.Order.OrderId,
                    Operator = this.Order.Username,
                    Remark   = "客户订单在线支付成功"
                });
                if (this.Order.GroupBuyId > 0 && num == num2 + num3)
                {
                    TradeHelper.SetGroupBuyEndUntreated(this.Order.GroupBuyId);
                }
                if (this.Order.UserId != 0 && this.Order.UserId != 1100)
                {
                    IUser user = Users.GetUser(this.Order.UserId);
                    if (user != null && user.UserRole == UserRole.Member)
                    {
                        Messenger.OrderPayment(user, this.Order, this.Order.GetTotal());
                    }
                }
                this.Order.OnPayment();
                base.Response.Write("OK");
                base.Response.End();
                return;
            }
            base.Response.Write("OK");
            base.Response.End();
        }
示例#3
0
 private void UserPayOrder()
 {
     if (this.Order.OrderStatus == OrderStatus.BuyerAlreadyPaid)
     {
         this.ResponseStatus(true, "success");
     }
     else
     {
         int maxCount             = 0;
         int orderCount           = 0;
         int groupBuyOerderNumber = 0;
         if (this.Order.GroupBuyId > 0)
         {
             GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(this.Order.GroupBuyId);
             if ((groupBuy == null) || (groupBuy.Status != GroupBuyStatus.UnderWay))
             {
                 this.ResponseStatus(false, "groupbuyalreadyfinished");
                 return;
             }
             orderCount           = TradeHelper.GetOrderCount(this.Order.GroupBuyId);
             groupBuyOerderNumber = this.Order.GetGroupBuyOerderNumber();
             maxCount             = groupBuy.MaxCount;
             if (maxCount < (orderCount + groupBuyOerderNumber))
             {
                 this.ResponseStatus(false, "exceedordermax");
                 return;
             }
         }
         if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UserPayOrder(this.Order, false))
         {
             DebitNote note = new DebitNote();
             note.NoteId   = Globals.GetGenerateId();
             note.OrderId  = this.Order.OrderId;
             note.Operator = this.Order.Username;
             note.Remark   = "客户订单在线支付成功";
             TradeHelper.SaveDebitNote(note);
             if ((this.Order.GroupBuyId > 0) && (maxCount == (orderCount + groupBuyOerderNumber)))
             {
                 TradeHelper.SetGroupBuyEndUntreated(this.Order.GroupBuyId);
             }
             if ((this.Order.UserId != 0) && (this.Order.UserId != 0x44c))
             {
                 IUser user = Users.GetUser(this.Order.UserId);
                 if ((user != null) && ((user.UserRole == UserRole.Member) || (user.UserRole == UserRole.Underling)))
                 {
                     Messenger.OrderPayment(user, this.Order.OrderId, this.Order.GetTotal());
                 }
             }
             this.Order.OnPayment();
             this.ResponseStatus(true, "success");
         }
         else
         {
             this.ResponseStatus(false, "fail");
         }
     }
 }
示例#4
0
        private void UserPayOrder(OrderInfo order)
        {
            ErrorLog.Write(string.Format("支付宝App支付回调,校验成功,开始更新订单{0}状态", this.Order.OrderId));

            if (order.OrderStatus == OrderStatus.BuyerAlreadyPaid)
            {
                base.Response.Write("success");
                return;
            }

            if (this.Order.OrderStatus == OrderStatus.BuyerAlreadyPaid)
            {
                base.Response.Write("success");
                return;
            }
            int num  = 0;
            int num2 = 0;
            int num3 = 0;

            if (this.Order.GroupBuyId > 0)
            {
                GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(this.Order.GroupBuyId);
                if (groupBuy == null || groupBuy.Status != GroupBuyStatus.UnderWay)
                {
                    base.Response.Write("groupbuyalreadyfinished");
                    return;
                }
                num2 = TradeHelper.GetOrderCount(this.Order.GroupBuyId);
                num3 = this.Order.GetGroupBuyOerderNumber();
                num  = groupBuy.MaxCount;
                if (num < num2 + num3)
                {
                    base.Response.Write("exceedordermax");
                    return;
                }
            }

            if (Order.OrderStatus == OrderStatus.WaitBuyerPay)
            {
                //如果需要拆单
                if (TradeHelper.CheckIsUnpack(this.Order.OrderId))
                {
                    ErrorLog.Write(string.Format("支付宝App支付,拆单,原订单{0}", this.Order.OrderId));
                    if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UserPayOrder(this.Order, false, 1))
                    {
                        //OrderHelper.SetOrderPayStatus(this.Order.OrderId, 2);
                        OrderHelper.SetOrderPayStatus(this.Order.OrderId, 2, Order.PaymentTypeId, Order.PaymentType, Order.Gateway, Order.GatewayOrderId);
                        if (this.Order.UserId != 0 && this.Order.UserId != 1100)
                        {
                            IUser user = Users.GetUser(this.Order.UserId);
                            if (user != null && user.UserRole == UserRole.Member)
                            {
                                Messenger.OrderPayment(user, this.Order, this.Order.GetTotal());
                            }
                        }
                        this.Order.OnPayment();
                        base.Response.Write("success");
                    }
                }
                else if (Order.OrderType == (int)OrderType.WillMerge)//合并单据
                {
                    bool b    = ShoppingProcessor.mergeOrder(this.Order);
                    int  flag = 0;
                    if (b)
                    {
                        flag = 2;
                    }
                    if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UserPayOrder(this.Order, false, flag))
                    {
                        //OrderHelper.SetOrderPayStatus(orderId, 2);
                        OrderHelper.SetOrderPayStatus(this.Order.OrderId, 2, Order.PaymentTypeId, Order.PaymentType, Order.Gateway, Order.GatewayOrderId);
                        if (this.Order.UserId != 0 && this.Order.UserId != 1100)
                        {
                            IUser user = Users.GetUser(this.Order.UserId);
                            if (user != null && user.UserRole == UserRole.Member)
                            {
                                Messenger.OrderPayment(user, this.Order, this.Order.GetTotal());
                            }
                        }
                        this.Order.OnPayment();
                        base.Response.Write("success");
                    }
                }
                else
                {
                    ErrorLog.Write(string.Format("支付宝App支付,正常单据,原订单{0}", this.Order.OrderId));
                    if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UserPayOrder(this.Order, false))
                    {
                        OrderHelper.SetOrderPayStatus(this.Order.OrderId, 2, Order.PaymentTypeId, Order.PaymentType, Order.Gateway, Order.GatewayOrderId);

                        TradeHelper.SaveDebitNote(new DebitNoteInfo
                        {
                            NoteId   = Globals.GetGenerateId(),
                            OrderId  = this.Order.OrderId,
                            Operator = this.Order.Username,
                            Remark   = "客户订单在线支付成功"
                        });
                        if (this.Order.GroupBuyId > 0 && num == num2 + num3)
                        {
                            TradeHelper.SetGroupBuyEndUntreated(this.Order.GroupBuyId);
                        }
                        OrderHelper.SetOrderPayStatus(this.Order.OrderId, 2, Order.PaymentTypeId, Order.PaymentType, Order.Gateway, Order.GatewayOrderId);
                        if (this.Order.UserId != 0 && this.Order.UserId != 1100)
                        {
                            IUser user = Users.GetUser(this.Order.UserId);
                            if (user != null && user.UserRole == UserRole.Member)
                            {
                                Messenger.OrderPayment(user, this.Order, this.Order.GetTotal());
                            }
                        }
                        this.Order.OnPayment();
                        base.Response.Write("success");
                    }
                }
            }
            else
            {
                ErrorLog.Write(string.Format("支付宝App支付,当前状态不支持付款,原订单{0},订单状态{1}", this.Order.OrderId, (int)this.Order.OrderStatus));
                base.Response.Write("fail");
            }

            //if (order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UserPayOrder(order, false))
            //{
            //    order.OnPayment();
            //    base.Response.Write("success");
            //}
        }
示例#5
0
 private void UserPayOrder()
 {
     if (this.Order.OrderStatus == OrderStatus.Closed)
     {
         OrderHelper.SetExceptionOrder(this.Order.OrderId, "支付异常,请联系买家退款");
         Messenger.OrderException(Users.GetUser(this.Order.UserId), this.Order, "订单支付异常,请联系卖家退款.订单号:" + this.Order.OrderId);
     }
     else if (this.Order.OrderStatus == OrderStatus.BuyerAlreadyPaid)
     {
         if (this.Order.FightGroupId > 0)
         {
             this.toFightGroupSuccess();
         }
         else
         {
             base.Response.Write(string.Format("<p style=\"font-size:16px;\">恭喜您,订单已成功完成支付:{0}</br>支付金额:{1}<br><a href=\"{2}\">查看订单</a></p>", this.OrderId, this.Amount.ToString("F"), this.GetReturnLink(this.Order.OrderSource)));
         }
     }
     else
     {
         int maxCount        = 0;
         int yetOrderNum     = 0;
         int currentOrderNum = 0;
         if (this.Order.GroupBuyId > 0)
         {
             GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(this.Order.GroupBuyId);
             if (groupBuy == null || groupBuy.Status != GroupBuyStatus.UnderWay)
             {
                 base.Response.Write($"<p style=\"font-size:16px;\">订单为团购订单,团购活动已结束,支付失败<br><a href=\"{this.GetReturnLink(this.Order.OrderSource)}\">查看订单</a></p>");
                 return;
             }
             yetOrderNum     = TradeHelper.GetOrderCount(this.Order.GroupBuyId);
             currentOrderNum = this.Order.GetGroupBuyOerderNumber();
             maxCount        = groupBuy.MaxCount;
             if (maxCount < yetOrderNum + currentOrderNum)
             {
                 base.Response.Write($"<p style=\"font-size:16px;\">订单为团购订单,订购数量超过订购总数,支付失败<br><a href=\"{this.GetReturnLink(this.Order.OrderSource)}\">查看订单</a></p>");
                 return;
             }
         }
         if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UpdateOrderStatus(this.Order))
         {
             Task.Factory.StartNew(delegate
             {
                 TradeHelper.UserPayOrder(this.Order, false, true);
                 try
                 {
                     if (this.Order.FightGroupId > 0)
                     {
                         VShopHelper.SetFightGroupSuccess(this.Order.FightGroupId);
                     }
                     if (this.Order.GroupBuyId > 0 && maxCount == yetOrderNum + currentOrderNum)
                     {
                         TradeHelper.SetGroupBuyEndUntreated(this.Order.GroupBuyId);
                     }
                     if (this.Order.ParentOrderId == "-1")
                     {
                         OrderQuery orderQuery           = new OrderQuery();
                         orderQuery.ParentOrderId        = this.Order.OrderId;
                         IList <OrderInfo> listUserOrder = MemberProcessor.GetListUserOrder(this.Order.UserId, orderQuery);
                         foreach (OrderInfo item in listUserOrder)
                         {
                             OrderHelper.OrderConfirmPaySendMessage(item);
                         }
                     }
                     else
                     {
                         OrderHelper.OrderConfirmPaySendMessage(this.Order);
                     }
                 }
                 catch (Exception ex)
                 {
                     IDictionary <string, string> dictionary = new Dictionary <string, string>();
                     dictionary.Add("ErrorMessage", ex.Message);
                     dictionary.Add("StackTrace", ex.StackTrace);
                     if (ex.InnerException != null)
                     {
                         dictionary.Add("InnerException", ex.InnerException.ToString());
                     }
                     if (ex.GetBaseException() != null)
                     {
                         dictionary.Add("BaseException", ex.GetBaseException().Message);
                     }
                     if (ex.TargetSite != (MethodBase)null)
                     {
                         dictionary.Add("TargetSite", ex.TargetSite.ToString());
                     }
                     dictionary.Add("ExSource", ex.Source);
                     Globals.AppendLog(dictionary, "支付更新订单收款记录或者消息通知时出错:" + ex.Message, "", "", "UserPay");
                 }
                 this.Order.OnPayment();
             });
             if (this.Order.FightGroupId > 0)
             {
                 this.toFightGroupSuccess();
             }
             else
             {
                 base.Response.Write(string.Format("<p style=\"font-size:16px;\">恭喜您,订单已成功完成支付:{0}</br>支付金额:{1}<br><a href=\"{2}\">查看订单</a></p>", this.OrderId, this.Amount.ToString("F"), this.GetReturnLink(this.Order.OrderSource)));
             }
         }
         else if (this.Order.GroupBuyId > 0)
         {
             this.toFightGroupSuccess();
         }
         else
         {
             base.Response.Write(string.Format("<p style=\"font-size:16px;\">恭喜您,订单已成功完成支付:{0}</br>支付金额:{1}<br><a href=\"{2}\">查看订单</a></p>", this.OrderId, this.Amount.ToString("F"), this.GetReturnLink(this.Order.OrderSource)));
         }
     }
 }
示例#6
0
        private void UserPayOrder()
        {
            if (this.Order.OrderStatus == OrderStatus.Closed)
            {
                if (!this.hasNotify)
                {
                    OrderHelper.SetExceptionOrder(this.Order.OrderId, "支付异常,请联系买家退款");
                    Messenger.OrderException(Users.GetUser(this.Order.UserId), this.Order, "订单支付异常,请联系卖家退款.订单号:" + this.Order.OrderId);
                    TradeHelper.UpdateOrderGatewayOrderId(this.Order.OrderId, this.Order.GatewayOrderId);
                }
                this.ResponseReturn(true, "");
                return;
            }
            if (this.Order.OrderStatus == OrderStatus.BuyerAlreadyPaid)
            {
                this.ResponseReturn(true, "");
                return;
            }
            int maxCount        = 0;
            int yetOrderNum     = 0;
            int currentOrderNum = 0;

            if (this.Order.GroupBuyId > 0)
            {
                GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(this.Order.GroupBuyId);
                if (groupBuy != null && groupBuy.Status == GroupBuyStatus.UnderWay)
                {
                    yetOrderNum     = TradeHelper.GetOrderCount(this.Order.GroupBuyId);
                    currentOrderNum = this.Order.GetGroupBuyOerderNumber();
                    maxCount        = groupBuy.MaxCount;
                    if (maxCount < yetOrderNum + currentOrderNum)
                    {
                        this.ResponseReturn(true, "");
                        return;
                    }
                    goto IL_0197;
                }
                this.ResponseReturn(true, "");
                return;
            }
            goto IL_0197;
IL_0197:
            if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UpdateOrderStatus(this.Order))
            {
                Task.Factory.StartNew(delegate
                {
                    TradeHelper.UserPayOrder(this.Order, false, true);
                    try
                    {
                        if (this.Order.FightGroupId > 0)
                        {
                            VShopHelper.SetFightGroupSuccess(this.Order.FightGroupId);
                        }
                        if (this.Order.GroupBuyId > 0 && maxCount == yetOrderNum + currentOrderNum)
                        {
                            TradeHelper.SetGroupBuyEndUntreated(this.Order.GroupBuyId);
                        }
                        if (this.Order.ParentOrderId == "-1")
                        {
                            OrderQuery orderQuery           = new OrderQuery();
                            orderQuery.ParentOrderId        = this.Order.OrderId;
                            IList <OrderInfo> listUserOrder = MemberProcessor.GetListUserOrder(this.Order.UserId, orderQuery);
                            foreach (OrderInfo item in listUserOrder)
                            {
                                OrderHelper.OrderConfirmPaySendMessage(item);
                            }
                        }
                        else
                        {
                            OrderHelper.OrderConfirmPaySendMessage(this.Order);
                        }
                    }
                    catch (Exception ex)
                    {
                        IDictionary <string, string> dictionary = new Dictionary <string, string>();
                        dictionary.Add("ErrorMessage", ex.Message);
                        dictionary.Add("StackTrace", ex.StackTrace);
                        if (ex.InnerException != null)
                        {
                            dictionary.Add("InnerException", ex.InnerException.ToString());
                        }
                        if (ex.GetBaseException() != null)
                        {
                            dictionary.Add("BaseException", ex.GetBaseException().Message);
                        }
                        if (ex.TargetSite != (MethodBase)null)
                        {
                            dictionary.Add("TargetSite", ex.TargetSite.ToString());
                        }
                        dictionary.Add("ExSource", ex.Source);
                        Globals.AppendLog(dictionary, "支付更新订单收款记录或者消息通知时出错:" + ex.Message, "", "", "UserPay");
                    }
                    this.Order.OnPayment();
                });
                this.ResponseReturn(true, "");
            }
        }
示例#7
0
文件: Pay.cs 项目: uvbs/eshopSanQiang
        protected void btnPay_Click(object sender, System.EventArgs e)
        {
            OrderInfo orderInfo = TradeHelper.GetOrderInfo(this.orderId);
            int       num       = 0;
            int       num2      = 0;
            int       num3      = 0;

            if (orderInfo.CountDownBuyId > 0)
            {
                CountDownInfo countDownBuy = TradeHelper.GetCountDownBuy(orderInfo.CountDownBuyId);
                if (countDownBuy == null || countDownBuy.EndDate < System.DateTime.Now)
                {
                    this.ShowMessage("当前的订单为限时抢购订单,此活动已结束,所以不能支付", false);
                    return;
                }
            }
            if (orderInfo.GroupBuyId > 0)
            {
                GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(orderInfo.GroupBuyId);
                if (groupBuy == null || groupBuy.Status != GroupBuyStatus.UnderWay)
                {
                    this.ShowMessage("当前的订单为团购订单,此团购活动已结束,所以不能支付", false);
                    return;
                }
                num2 = TradeHelper.GetOrderCount(orderInfo.GroupBuyId);
                num3 = orderInfo.GetGroupBuyOerderNumber();
                num  = groupBuy.MaxCount;
                if (num < num2 + num3)
                {
                    this.ShowMessage("当前的订单为团购订单,订购数量已超过订购总数,所以不能支付", false);
                    return;
                }
            }
            if (!orderInfo.CheckAction(OrderActions.BUYER_PAY))
            {
                this.ShowMessage("当前的订单订单状态不是等待付款,所以不能支付", false);
            }
            else
            {
                if (HiContext.Current.User.UserId != orderInfo.UserId)
                {
                    this.ShowMessage("预付款只能为自己下的订单付款,查一查该订单是不是你的", false);
                }
                else
                {
                    if ((decimal)this.litUseableBalance.Money < orderInfo.GetTotal())
                    {
                        this.ShowMessage("预付款余额不足,支付失败", false);
                    }
                    else
                    {
                        Hidistro.Membership.Core.IUser user = HiContext.Current.User;
                        user.TradePassword = this.txtPassword.Text;
                        if (Users.ValidTradePassword(user))
                        {
                            System.Collections.Generic.Dictionary <string, LineItemInfo> lineItems = orderInfo.LineItems;
                            foreach (LineItemInfo current in lineItems.Values)
                            {
                                int stock = ShoppingProcessor.GetStock(current.ProductId, current.SkuId);
                                if (stock < current.ShipmentQuantity)
                                {
                                    this.ShowMessage("订单中商品库存不足,禁止支付!", false);
                                    return;
                                }
                            }
                            if (TradeHelper.UserPayOrder(orderInfo, true))
                            {
                                TradeHelper.SaveDebitNote(new DebitNote
                                {
                                    NoteId   = Globals.GetGenerateId(),
                                    OrderId  = this.orderId,
                                    Operator = HiContext.Current.User.Username,
                                    Remark   = "客户预付款订单支付成功"
                                });
                                if (orderInfo.GroupBuyId > 0 && num == num2 + num3)
                                {
                                    TradeHelper.SetGroupBuyEndUntreated(orderInfo.GroupBuyId);
                                }
                                Messenger.OrderPayment(user, orderInfo.OrderId, orderInfo.GetTotal());
                                orderInfo.OnPayment();
                                this.Page.Response.Redirect(Globals.ApplicationPath + "/user/PaySucceed.aspx?orderId=" + this.orderId);
                            }
                            else
                            {
                                this.ShowMessage(string.Format("对订单{0} 支付失败", orderInfo.OrderId), false);
                            }
                        }
                        else
                        {
                            this.ShowMessage("交易密码有误,请重试", false);
                        }
                    }
                }
            }
        }
示例#8
0
        protected void btnPay_Click(object sender, EventArgs e)
        {
            OrderInfo orderInfo            = TradeHelper.GetOrderInfo(this.orderId);
            int       maxCount             = 0;
            int       orderCount           = 0;
            int       groupBuyOerderNumber = 0;

            if (orderInfo.CountDownBuyId > 0)
            {
                CountDownInfo countDownBuy = TradeHelper.GetCountDownBuy(orderInfo.CountDownBuyId);
                if ((countDownBuy == null) || (countDownBuy.EndDate < DateTime.Now))
                {
                    this.ShowMessage("当前的订单为限时抢购订单,此活动已结束,所以不能支付", false);
                    return;
                }
            }
            if (orderInfo.GroupBuyId > 0)
            {
                GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(orderInfo.GroupBuyId);
                if ((groupBuy == null) || (groupBuy.Status != GroupBuyStatus.UnderWay))
                {
                    this.ShowMessage("当前的订单为团购订单,此团购活动已结束,所以不能支付", false);
                    return;
                }
                orderCount           = TradeHelper.GetOrderCount(orderInfo.GroupBuyId);
                groupBuyOerderNumber = orderInfo.GetGroupBuyOerderNumber();
                maxCount             = groupBuy.MaxCount;
                if (maxCount < (orderCount + groupBuyOerderNumber))
                {
                    this.ShowMessage("当前的订单为团购订单,订购数量已超过订购总数,所以不能支付", false);
                    return;
                }
            }
            if (!orderInfo.CheckAction(OrderActions.BUYER_PAY))
            {
                this.ShowMessage("当前的订单订单状态不是等待付款,所以不能支付", false);
            }
            else if (HiContext.Current.User.UserId != orderInfo.UserId)
            {
                this.ShowMessage("预付款只能为自己下的订单付款,查一查该订单是不是你的", false);
            }
            else if (((decimal)this.litUseableBalance.Money) < orderInfo.GetTotal())
            {
                this.ShowMessage("预付款余额不足,支付失败", false);
            }
            else
            {
                IUser user = HiContext.Current.User;
                user.TradePassword = this.txtPassword.Text;
                if (Users.ValidTradePassword(user))
                {
                    foreach (LineItemInfo info4 in orderInfo.LineItems.Values)
                    {
                        if (ShoppingProcessor.GetStock(info4.ProductId, info4.SkuId) < info4.ShipmentQuantity)
                        {
                            this.ShowMessage("订单中商品库存不足,禁止支付!", false);
                            return;
                        }
                    }
                    if (TradeHelper.UserPayOrder(orderInfo, true))
                    {
                        DebitNote note = new DebitNote();
                        note.NoteId   = Globals.GetGenerateId();
                        note.OrderId  = this.orderId;
                        note.Operator = HiContext.Current.User.Username;
                        note.Remark   = "客户预付款订单支付成功";
                        TradeHelper.SaveDebitNote(note);
                        if ((orderInfo.GroupBuyId > 0) && (maxCount == (orderCount + groupBuyOerderNumber)))
                        {
                            TradeHelper.SetGroupBuyEndUntreated(orderInfo.GroupBuyId);
                        }
                        Messenger.OrderPayment(user, orderInfo.OrderId, orderInfo.GetTotal());
                        orderInfo.OnPayment();
                        this.Page.Response.Redirect(Globals.ApplicationPath + "/user/PaySucceed.aspx?orderId=" + this.orderId);
                    }
                    else
                    {
                        this.ShowMessage(string.Format("对订单{0} 支付失败", orderInfo.OrderId), false);
                    }
                }
                else
                {
                    this.ShowMessage("交易密码有误,请重试", false);
                }
            }
        }
示例#9
0
        protected void btnPay_Click(object sender, EventArgs e)
        {
            OrderInfo orderInfo            = TradeHelper.GetOrderInfo(this.orderId);
            int       maxCount             = 0;
            int       orderCount           = 0;
            int       groupBuyOerderNumber = 0;

            if (orderInfo.GroupBuyId > 0)
            {
                GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(orderInfo.GroupBuyId);
                if ((groupBuy == null) || (groupBuy.Status != GroupBuyStatus.UnderWay))
                {
                    this.ShowMessage("当前的订单为团购订单,此团购活动已结束,所以不能支付", false);
                    return;
                }
                orderCount           = TradeHelper.GetOrderCount(orderInfo.GroupBuyId);
                groupBuyOerderNumber = orderInfo.GetGroupBuyOerderNumber();
                maxCount             = groupBuy.MaxCount;
                if (maxCount < (orderCount + groupBuyOerderNumber))
                {
                    this.ShowMessage("当前的订单为团购订单,订购数量已超过订购总数,所以不能支付", false);
                    return;
                }
            }
            if (!orderInfo.CheckAction(OrderActions.BUYER_PAY))
            {
                this.ShowMessage("当前的订单订单状态不是等待付款,所以不能支付", false);
            }
            else if (HiContext.Current.User.UserId != orderInfo.UserId)
            {
                this.ShowMessage("预付款只能为自己下的订单付款,查一查该订单是不是你的", false);
            }
            else if (((decimal)this.litUseableBalance.Money) < orderInfo.GetTotal())
            {
                this.ShowMessage("预付款余额不足,支付失败", false);
            }
            else
            {
                IUser user = HiContext.Current.User;
                user.TradePassword = this.txtPassword.Text;
                if (Users.ValidTradePassword(user))
                {
                    if (TradeHelper.UserPayOrder(orderInfo, true))
                    {
                        if ((orderInfo.GroupBuyId > 0) && (maxCount == (orderCount + groupBuyOerderNumber)))
                        {
                            TradeHelper.SetGroupBuyEndUntreated(orderInfo.GroupBuyId);
                        }
                        Messenger.OrderPayment(user, orderInfo.OrderId, orderInfo.GetTotal());
                        orderInfo.OnPayment();
                        this.Page.Response.Redirect(Globals.ApplicationPath + "/user/PaySucceed.aspx?orderId=" + this.orderId);
                    }
                    else
                    {
                        this.ShowMessage(string.Format("对订单{0} 支付失败", orderInfo.OrderId), false);
                    }
                }
                else
                {
                    this.ShowMessage("交易密码有误,请重试", false);
                }
            }
        }
示例#10
0
 private void UserPayOrder()
 {
     if (this.Order != null && this.Order.OrderStatus == OrderStatus.Closed)
     {
         OrderHelper.SetExceptionOrder(this.Order.OrderId, "支付异常,请联系买家退款");
         Messenger.OrderException(Users.GetUser(this.Order.UserId), this.Order, "订单支付异常,请联系卖家退款.订单号:" + this.Order.OrderId);
         this.ResponseReturn(true, "");
     }
     else if ((this.Order != null && this.Order.OrderStatus == OrderStatus.BuyerAlreadyPaid) || (this.offlineOrder != null && this.offlineOrder.Status == 1))
     {
         this.ResponseReturn(true, "");
     }
     else
     {
         try
         {
             int maxCount        = 0;
             int yetOrderNum     = 0;
             int currentOrderNum = 0;
             if (this.Order != null)
             {
                 if (this.Order.GroupBuyId > 0)
                 {
                     GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(this.Order.GroupBuyId);
                     if (groupBuy == null || groupBuy.Status != GroupBuyStatus.UnderWay)
                     {
                         return;
                     }
                     yetOrderNum     = TradeHelper.GetOrderCount(this.Order.GroupBuyId);
                     currentOrderNum = this.Order.GetGroupBuyOerderNumber();
                     maxCount        = groupBuy.MaxCount;
                     if (maxCount < yetOrderNum + currentOrderNum)
                     {
                         return;
                     }
                 }
                 if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UpdateOrderStatus(this.Order))
                 {
                     Task.Factory.StartNew(delegate
                     {
                         TradeHelper.UserPayOrder(this.Order, false, true);
                         try
                         {
                             if (this.offlineOrder != null)
                             {
                                 OrderHelper.UpdateOrderPaymentTypeOfAPI(this.Order);
                                 OrderHelper.ConfirmTakeGoods(this.Order, true);
                             }
                             if (this.Order.GroupBuyId > 0 && maxCount == yetOrderNum + currentOrderNum)
                             {
                                 TradeHelper.SetGroupBuyEndUntreated(this.Order.GroupBuyId);
                             }
                             if (this.Order.UserId != 0 && this.Order.UserId != 1100)
                             {
                                 string verificationPasswords = "";
                                 if (this.Order.OrderType == OrderType.ServiceOrder)
                                 {
                                     verificationPasswords = OrderHelper.GetVerificationPasswordsOfOrderId(this.Order.OrderId);
                                 }
                                 Hidistro.Entities.Members.MemberInfo user = Users.GetUser(this.Order.UserId);
                                 if (user != null)
                                 {
                                     Messenger.OrderPayment(user, this.Order, this.Order.GetTotal(true), verificationPasswords);
                                 }
                             }
                             StoresInfo storesInfo2 = null;
                             if (this.Order.StoreId > 0)
                             {
                                 storesInfo2 = DepotHelper.GetStoreById(this.Order.StoreId);
                             }
                             if (storesInfo2 != null)
                             {
                                 VShopHelper.AppPsuhRecordForStore(storesInfo2.StoreId, this.Order.OrderId, "", EnumPushStoreAction.StoreOrderPayed);
                                 if (this.offlineOrder == null)
                                 {
                                     if (this.Order.ShippingModeId == -2)
                                     {
                                         VShopHelper.AppPsuhRecordForStore(storesInfo2.StoreId, this.Order.OrderId, "", EnumPushStoreAction.TakeOnStoreOrderWaitConfirm);
                                     }
                                     else
                                     {
                                         VShopHelper.AppPsuhRecordForStore(storesInfo2.StoreId, this.Order.OrderId, "", EnumPushStoreAction.StoreOrderWaitSendGoods);
                                     }
                                 }
                             }
                             if (this.offlineOrder == null)
                             {
                                 ShippersInfo defaultOrFirstShipper = SalesHelper.GetDefaultOrFirstShipper(0);
                                 Messenger.OrderPaymentToShipper(defaultOrFirstShipper, storesInfo2, null, this.Order, this.Order.GetTotal(true));
                             }
                             this.Order.OnPayment();
                         }
                         catch (Exception ex2)
                         {
                             IDictionary <string, string> dictionary2 = new Dictionary <string, string>();
                             dictionary2.Add("ErrorMessage", ex2.Message);
                             dictionary2.Add("StackTrace", ex2.StackTrace);
                             if (ex2.InnerException != null)
                             {
                                 dictionary2.Add("InnerException", ex2.InnerException.ToString());
                             }
                             if (ex2.GetBaseException() != null)
                             {
                                 dictionary2.Add("BaseException", ex2.GetBaseException().Message);
                             }
                             if (ex2.TargetSite != (MethodBase)null)
                             {
                                 dictionary2.Add("TargetSite", ex2.TargetSite.ToString());
                             }
                             dictionary2.Add("ExSource", ex2.Source);
                             Globals.AppendLog(dictionary2, "支付更新订单收款记录或者消息通知时出错:" + ex2.Message, "", "", "UserPay");
                         }
                         this.Order.OnPayment();
                         this.ResponseReturn(true, "");
                     });
                 }
                 if (this.Order.FightGroupId > 0)
                 {
                     VShopHelper.SetFightGroupSuccess(this.Order.FightGroupId);
                 }
             }
             if (this.offlineOrder != null && this.offlineOrder.Status == 0)
             {
                 this.offlineOrder.Status  = 1;
                 this.offlineOrder.PayTime = DateTime.Now;
                 if (StoresHelper.UpdateStoreCollectionInfo(this.offlineOrder) && this.isOfflineOrder)
                 {
                     string     text      = "";
                     StoresInfo storeById = DepotHelper.GetStoreById(this.offlineOrder.StoreId);
                     if (storeById != null)
                     {
                         text = storeById.StoreName;
                         StoreBalanceDetailInfo storeBalanceDetailInfo = new StoreBalanceDetailInfo();
                         storeBalanceDetailInfo.StoreId         = this.offlineOrder.StoreId;
                         storeBalanceDetailInfo.TradeDate       = DateTime.Now;
                         storeBalanceDetailInfo.TradeType       = StoreTradeTypes.OfflineCashier;
                         storeBalanceDetailInfo.Expenses        = default(decimal);
                         storeBalanceDetailInfo.Income          = this.offlineOrder.PayAmount;
                         storeBalanceDetailInfo.Balance         = storeById.Balance + this.offlineOrder.PayAmount;
                         storeBalanceDetailInfo.Remark          = "线下收银(" + this.offlineOrder.OrderId + ")";
                         storeBalanceDetailInfo.ManagerUserName = "";
                         storeBalanceDetailInfo.TradeNo         = this.offlineOrder.OrderId;
                         storeBalanceDetailInfo.CreateTime      = DateTime.Now;
                         storeBalanceDetailInfo.PlatCommission  = decimal.Zero;
                         if (StoreBalanceHelper.AddBalanceDetailInfo(storeBalanceDetailInfo))
                         {
                             StoresInfo storesInfo = storeById;
                             storesInfo.Balance += this.offlineOrder.PayAmount;
                             StoresHelper.UpdateStore(storeById);
                         }
                     }
                     if (storeById != null)
                     {
                         VShopHelper.AppPsuhRecordForStore(storeById.StoreId, this.offlineOrder.OrderId, "", EnumPushStoreAction.StoreOrderPayed);
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             IDictionary <string, string> dictionary = new Dictionary <string, string>();
             dictionary.Add("ErrorMessage", ex.Message);
             dictionary.Add("StackTrace", ex.StackTrace);
             if (ex.InnerException != null)
             {
                 dictionary.Add("InnerException", ex.InnerException.ToString());
             }
             if (ex.GetBaseException() != null)
             {
                 dictionary.Add("BaseException", ex.GetBaseException().Message);
             }
             if (ex.TargetSite != (MethodBase)null)
             {
                 dictionary.Add("TargetSite", ex.TargetSite.ToString());
             }
             dictionary.Add("ExSource", ex.Source);
             Globals.AppendLog(dictionary, "支付更新订单收款记录或者消息通知时出错:" + ex.Message, "", "", "UserPay1");
         }
         this.ResponseReturn(true, "");
     }
 }
        private void UserPayOrder()
        {
            ErrorLog.Write("标准支付回调,处理订单状态,订单号:" + this.OrderId);

            if (this.Order.OrderStatus == OrderStatus.BuyerAlreadyPaid)
            {
                this.ResponseStatus(true, "success");
                return;
            }
            int num  = 0;
            int num2 = 0;
            int num3 = 0;

            if (this.Order.GroupBuyId > 0)
            {
                GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(this.Order.GroupBuyId);
                if (groupBuy == null || groupBuy.Status != GroupBuyStatus.UnderWay)
                {
                    this.ResponseStatus(false, "groupbuyalreadyfinished");
                    return;
                }
                num2 = TradeHelper.GetOrderCount(this.Order.GroupBuyId);
                num3 = this.Order.GetGroupBuyOerderNumber();
                num  = groupBuy.MaxCount;
                if (num < num2 + num3)
                {
                    this.ResponseStatus(false, "exceedordermax");
                    return;
                }
            }

            //如果需要拆单
            if (TradeHelper.CheckIsUnpack(OrderId) && Order.OrderStatus == OrderStatus.WaitBuyerPay)
            {
                ErrorLog.Write(string.Format(this.Order.PaymentType + "支付,拆单,原订单{0}", this.Order.OrderId));
                if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UserPayOrder(this.Order, false, 1))
                {
                    //OrderHelper.SetOrderPayStatus(OrderId, 2);
                    OrderHelper.SetOrderPayStatus(OrderId, 2, Order.PaymentTypeId, Order.PaymentType, Order.Gateway, Order.GatewayOrderId);
                    if (this.Order.UserId != 0 && this.Order.UserId != 1100)
                    {
                        IUser user = Users.GetUser(this.Order.UserId);
                        if (user != null && user.UserRole == UserRole.Member)
                        {
                            Messenger.OrderPayment(user, this.Order, this.Order.GetTotal());
                        }
                    }
                    this.Order.OnPayment();
                    this.ResponseStatus(true, "success");
                    return;
                }
            }
            else if (Order.OrderType == (int)OrderType.WillMerge && Order.OrderStatus == OrderStatus.WaitBuyerPay)//合并单据
            {
                bool b    = ShoppingProcessor.mergeOrder(this.Order);
                int  flag = 0;
                if (b)
                {
                    flag = 2;
                }
                if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UserPayOrder(this.Order, false, flag))
                {
                    //OrderHelper.SetOrderPayStatus(OrderId, 2);
                    OrderHelper.SetOrderPayStatus(OrderId, 2, Order.PaymentTypeId, Order.PaymentType, Order.Gateway, Order.GatewayOrderId);
                    if (this.Order.UserId != 0 && this.Order.UserId != 1100)
                    {
                        IUser user = Users.GetUser(this.Order.UserId);
                        if (user != null && user.UserRole == UserRole.Member)
                        {
                            Messenger.OrderPayment(user, this.Order, this.Order.GetTotal());
                        }
                    }
                    this.Order.OnPayment();
                    this.ResponseStatus(true, "success");
                    return;
                }
            }
            else
            {
                ErrorLog.Write(string.Format(this.Order.PaymentType + "支付,正常单据,原订单{0}", this.Order.OrderId));

                if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UserPayOrder(this.Order, false))
                {
                    TradeHelper.SaveDebitNote(new DebitNoteInfo
                    {
                        NoteId   = Globals.GetGenerateId(),
                        OrderId  = this.Order.OrderId,
                        Operator = this.Order.Username,
                        Remark   = "客户订单在线支付成功"
                    });
                    if (this.Order.GroupBuyId > 0 && num == num2 + num3)
                    {
                        TradeHelper.SetGroupBuyEndUntreated(this.Order.GroupBuyId);
                    }

                    OrderHelper.SetOrderPayStatus(OrderId, 2, Order.PaymentTypeId, Order.PaymentType, Order.Gateway, Order.GatewayOrderId);
                    if (this.Order.UserId != 0 && this.Order.UserId != 1100)
                    {
                        IUser user = Users.GetUser(this.Order.UserId);
                        if (user != null && user.UserRole == UserRole.Member)
                        {
                            Messenger.OrderPayment(user, this.Order, this.Order.GetTotal());
                        }
                    }
                    this.Order.OnPayment();
                    this.ResponseStatus(true, "success");
                    return;
                }
            }



            /* 2015-08-17 修改
             * if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UserPayOrder(this.Order, false))
             * {
             *  TradeHelper.SaveDebitNote(new DebitNoteInfo
             *  {
             *      NoteId = Globals.GetGenerateId(),
             *      OrderId = this.Order.OrderId,
             *      Operator = this.Order.Username,
             *      Remark = "客户订单在线支付成功"
             *  });
             *  if (this.Order.GroupBuyId > 0 && num == num2 + num3)
             *  {
             *      TradeHelper.SetGroupBuyEndUntreated(this.Order.GroupBuyId);
             *  }
             *  if (this.Order.UserId != 0 && this.Order.UserId != 1100)
             *  {
             *      IUser user = Users.GetUser(this.Order.UserId);
             *      if (user != null && user.UserRole == UserRole.Member)
             *      {
             *          Messenger.OrderPayment(user, this.Order, this.Order.GetTotal());
             *      }
             *  }
             *  this.Order.OnPayment();
             *  this.ResponseStatus(true, "success");
             *  return;
             * }*/
            this.ResponseStatus(false, "fail");
        }
 private void UserPayOrder()
 {
     if (this.Order.OrderStatus == OrderStatus.Closed)
     {
         if (!this.hasNotify)
         {
             OrderHelper.SetExceptionOrder(this.Order.OrderId, "支付异常,请联系买家退款");
             Messenger.OrderException(Users.GetUser(this.Order.UserId), this.Order, "订单支付异常,请联系卖家退款.订单号:" + this.Order.OrderId);
             TradeHelper.UpdateOrderGatewayOrderId(this.Order.OrderId, this.Order.GatewayOrderId);
         }
         base.Response.Write("success");
     }
     else if (this.Order.OrderStatus == OrderStatus.BuyerAlreadyPaid)
     {
         Globals.WriteLog(new NameValueCollection
         {
             this.Page.Request.Form,
             this.Page.Request.QueryString
         }, "订单状态已支付", "", "", "wap_bankunion");
         base.Response.Write("success");
     }
     else
     {
         int maxCount        = 0;
         int yetOrderNum     = 0;
         int currentOrderNum = 0;
         if (this.Order.GroupBuyId > 0)
         {
             GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(this.Order.GroupBuyId);
             if (groupBuy == null || groupBuy.Status != GroupBuyStatus.UnderWay)
             {
                 Globals.WriteLog(new NameValueCollection
                 {
                     this.Page.Request.Form,
                     this.Page.Request.QueryString
                 }, "错误的团购信息或者状态", "", "", "wap_bankunion");
                 base.Response.Write("success");
                 return;
             }
             yetOrderNum     = TradeHelper.GetOrderCount(this.Order.GroupBuyId);
             currentOrderNum = this.Order.GetGroupBuyOerderNumber();
             maxCount        = groupBuy.MaxCount;
             if (maxCount < yetOrderNum + currentOrderNum)
             {
                 Globals.WriteLog(new NameValueCollection
                 {
                     this.Page.Request.Form,
                     this.Page.Request.QueryString
                 }, "团购数量已超过指定数量", "", "", "wap_bankunion");
                 base.Response.Write("success");
                 return;
             }
         }
         if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UpdateOrderStatus(this.Order))
         {
             Task.Factory.StartNew(delegate
             {
                 TradeHelper.UserPayOrder(this.Order, false, true);
                 try
                 {
                     if (this.Order.GroupBuyId > 0 && maxCount == yetOrderNum + currentOrderNum)
                     {
                         TradeHelper.SetGroupBuyEndUntreated(this.Order.GroupBuyId);
                     }
                     if (this.Order.ParentOrderId == "-1")
                     {
                         OrderQuery orderQuery           = new OrderQuery();
                         orderQuery.ParentOrderId        = this.Order.OrderId;
                         IList <OrderInfo> listUserOrder = MemberProcessor.GetListUserOrder(this.Order.UserId, orderQuery);
                         foreach (OrderInfo item in listUserOrder)
                         {
                             OrderHelper.OrderConfirmPaySendMessage(item);
                         }
                     }
                     else
                     {
                         OrderHelper.OrderConfirmPaySendMessage(this.Order);
                     }
                 }
                 catch (Exception ex)
                 {
                     Globals.AppendLog("支付更新订单收款记录或者消息通知时出错:" + ex.Message, "", "", "UserPay");
                 }
                 this.Order.OnPayment();
             });
             base.Response.Write("success");
         }
         else
         {
             base.Response.Write("success");
         }
     }
 }
		private void UserPayOrder()
		{
			if (this.Order != null && this.Order.OrderStatus == OrderStatus.Closed)
			{
				OrderHelper.SetExceptionOrder(this.Order.OrderId, "支付异常,请联系买家退款");
				Messenger.OrderException(Users.GetUser(this.Order.UserId), this.Order, "订单支付异常,请联系卖家退款.订单号:" + this.Order.OrderId);
				base.Response.Write("success");
			}
			else if (this.Order.OrderStatus == OrderStatus.BuyerAlreadyPaid)
			{
				Globals.WriteLog(new NameValueCollection
				{
					this.Page.Request.Form,
					this.Page.Request.QueryString
				}, "订单状态为已支付", "", "", "alipay");
				base.Response.Write("success");
			}
			else
			{
				int maxCount = 0;
				int yetOrderNum = 0;
				int currentOrderNum = 0;
				if (this.Order.GroupBuyId > 0)
				{
					GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(this.Order.GroupBuyId);
					if (groupBuy == null || groupBuy.Status != GroupBuyStatus.UnderWay)
					{
						Globals.WriteLog(new NameValueCollection
						{
							this.Page.Request.Form,
							this.Page.Request.QueryString
						}, "错误的团购信息或者状态", "", "", "alipay");
						base.Response.Write("success");
						return;
					}
					yetOrderNum = TradeHelper.GetOrderCount(this.Order.GroupBuyId);
					currentOrderNum = this.Order.GetGroupBuyOerderNumber();
					maxCount = groupBuy.MaxCount;
					if (maxCount < yetOrderNum + currentOrderNum)
					{
						Globals.WriteLog(new NameValueCollection
						{
							this.Page.Request.Form,
							this.Page.Request.QueryString
						}, "团购数量已超过指定数量错", "", "", "alipay");
						base.Response.Write("success");
						return;
					}
				}
				if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UpdateOrderStatus(this.Order))
				{
					Task.Factory.StartNew(delegate
					{
						TradeHelper.UserPayOrder(this.Order, false, true);
						try
						{
							if (this.offlineOrder != null)
							{
								OrderHelper.UpdateOrderPaymentTypeOfAPI(this.Order);
								OrderHelper.ConfirmTakeGoods(this.Order, true);
							}
							if (this.Order.GroupBuyId > 0 && maxCount == yetOrderNum + currentOrderNum)
							{
								TradeHelper.SetGroupBuyEndUntreated(this.Order.GroupBuyId);
							}
							if (this.Order.UserId != 0 && this.Order.UserId != 1100)
							{
								Hidistro.Entities.Members.MemberInfo user = Users.GetUser(this.Order.UserId);
								string verificationPasswords = "";
								if (this.Order.OrderType == OrderType.ServiceOrder)
								{
									verificationPasswords = OrderHelper.GetVerificationPasswordsOfOrderId(this.Order.OrderId);
								}
								if (user != null)
								{
									Messenger.OrderPayment(user, this.Order, this.Order.GetTotal(false), verificationPasswords);
								}
							}
							StoresInfo storesInfo = null;
							if (this.Order.StoreId > 0)
							{
								storesInfo = DepotHelper.GetStoreById(this.Order.StoreId);
							}
							if (storesInfo != null)
							{
								VShopHelper.AppPsuhRecordForStore(storesInfo.StoreId, this.Order.OrderId, "", EnumPushStoreAction.StoreOrderPayed);
								if (this.offlineOrder == null)
								{
									if (this.Order.ShippingModeId == -2)
									{
										VShopHelper.AppPsuhRecordForStore(storesInfo.StoreId, this.Order.OrderId, "", EnumPushStoreAction.TakeOnStoreOrderWaitConfirm);
									}
									else
									{
										VShopHelper.AppPsuhRecordForStore(storesInfo.StoreId, this.Order.OrderId, "", EnumPushStoreAction.StoreOrderWaitSendGoods);
									}
								}
							}
							if (this.offlineOrder == null)
							{
								ShippersInfo defaultOrFirstShipper = SalesHelper.GetDefaultOrFirstShipper(0);
								Messenger.OrderPaymentToShipper(defaultOrFirstShipper, storesInfo, null, this.Order, this.Order.GetTotal(false));
							}
							this.Order.OnPayment();
						}
						catch (Exception ex)
						{
							IDictionary<string, string> dictionary = new Dictionary<string, string>();
							dictionary.Add("ErrorMessage", ex.Message);
							dictionary.Add("StackTrace", ex.StackTrace);
							if (ex.InnerException != null)
							{
								dictionary.Add("InnerException", ex.InnerException.ToString());
							}
							if (ex.GetBaseException() != null)
							{
								dictionary.Add("BaseException", ex.GetBaseException().Message);
							}
							if (ex.TargetSite != (MethodBase)null)
							{
								dictionary.Add("TargetSite", ex.TargetSite.ToString());
							}
							dictionary.Add("ExSource", ex.Source);
							Globals.AppendLog(dictionary, "支付更新订单收款记录或者消息通知时出错:" + ex.Message, "", "", "UserPay");
						}
					});
					base.Response.Write("success");
				}
				else
				{
					Globals.WriteLog(new NameValueCollection
					{
						this.Page.Request.Form,
						this.Page.Request.QueryString
					}, "订单不是待支付状态,或者更新订单状态失败", "", "", "alipay");
					base.Response.Write("success");
				}
			}
		}
 private void UserPayOrder()
 {
     if (this.Order.OrderStatus == OrderStatus.Closed)
     {
         OrderHelper.SetExceptionOrder(this.Order.OrderId, "支付异常,请联系买家退款");
         Messenger.OrderException(Users.GetUser(this.Order.UserId), this.Order, "订单支付异常,请联系卖家退款.订单号:" + this.Order.OrderId);
     }
     else if (this.Order.OrderStatus == OrderStatus.BuyerAlreadyPaid)
     {
         base.Response.Write(string.Format("<p style=\"font-size:16px;\">恭喜您,订单已成功完成支付:{0}</br>支付金额:{1}<br><a href=\"{2}\">查看订单</a></p>", this.OrderId, this.Amount.ToString("F"), this.GetReturnLink(this.Order.OrderSource)));
     }
     else
     {
         int maxCount        = 0;
         int yetOrderNum     = 0;
         int currentOrderNum = 0;
         if (this.Order.GroupBuyId > 0)
         {
             GroupBuyInfo groupBuy = TradeHelper.GetGroupBuy(this.Order.GroupBuyId);
             if (groupBuy == null || groupBuy.Status != GroupBuyStatus.UnderWay)
             {
                 base.Response.Write($"<p style=\"font-size:16px;\">订单为团购订单,团购活动已结束,支付失败<br><a href=\"{this.GetReturnLink(this.Order.OrderSource)}\">查看订单</a></p>");
                 return;
             }
             yetOrderNum     = TradeHelper.GetOrderCount(this.Order.GroupBuyId);
             currentOrderNum = this.Order.GetGroupBuyOerderNumber();
             maxCount        = groupBuy.MaxCount;
             if (maxCount < yetOrderNum + currentOrderNum)
             {
                 base.Response.Write($"<p style=\"font-size:16px;\">订单为团购订单,订购数量超过订购总数,支付失败<br><a href=\"{this.GetReturnLink(this.Order.OrderSource)}\">查看订单</a></p>");
                 return;
             }
         }
         if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UpdateOrderStatus(this.Order))
         {
             Task.Factory.StartNew(delegate
             {
                 TradeHelper.UserPayOrder(this.Order, false, true);
                 try
                 {
                     if (this.offlineOrder != null)
                     {
                         OrderHelper.UpdateOrderPaymentTypeOfAPI(this.Order);
                         OrderHelper.ConfirmTakeGoods(this.Order, true);
                     }
                     if (this.Order.GroupBuyId > 0 && maxCount == yetOrderNum + currentOrderNum)
                     {
                         TradeHelper.SetGroupBuyEndUntreated(this.Order.GroupBuyId);
                     }
                     if (this.Order.UserId != 0 && this.Order.UserId != 1100)
                     {
                         Hidistro.Entities.Members.MemberInfo user = Users.GetUser(this.Order.UserId);
                         string verificationPasswords = "";
                         if (this.Order.OrderType == OrderType.ServiceOrder)
                         {
                             verificationPasswords = OrderHelper.GetVerificationPasswordsOfOrderId(this.Order.OrderId);
                         }
                         if (user != null)
                         {
                             Messenger.OrderPayment(user, this.Order, this.Order.GetTotal(false), verificationPasswords);
                         }
                     }
                     StoresInfo storesInfo = null;
                     if (this.Order.StoreId > 0)
                     {
                         storesInfo = DepotHelper.GetStoreById(this.Order.StoreId);
                     }
                     if (storesInfo != null)
                     {
                         VShopHelper.AppPsuhRecordForStore(storesInfo.StoreId, this.Order.OrderId, "", EnumPushStoreAction.StoreOrderPayed);
                         if (this.offlineOrder == null)
                         {
                             if (this.Order.ShippingModeId == -2)
                             {
                                 VShopHelper.AppPsuhRecordForStore(storesInfo.StoreId, this.Order.OrderId, "", EnumPushStoreAction.TakeOnStoreOrderWaitConfirm);
                             }
                             else
                             {
                                 VShopHelper.AppPsuhRecordForStore(storesInfo.StoreId, this.Order.OrderId, "", EnumPushStoreAction.StoreOrderWaitSendGoods);
                             }
                         }
                     }
                     if (this.offlineOrder == null)
                     {
                         ShippersInfo defaultOrFirstShipper = SalesHelper.GetDefaultOrFirstShipper(0);
                         Messenger.OrderPaymentToShipper(defaultOrFirstShipper, storesInfo, null, this.Order, this.Order.GetTotal(false));
                     }
                     this.Order.OnPayment();
                 }
                 catch (Exception ex)
                 {
                     IDictionary <string, string> dictionary = new Dictionary <string, string>();
                     dictionary.Add("ErrorMessage", ex.Message);
                     dictionary.Add("StackTrace", ex.StackTrace);
                     if (ex.InnerException != null)
                     {
                         dictionary.Add("InnerException", ex.InnerException.ToString());
                     }
                     if (ex.GetBaseException() != null)
                     {
                         dictionary.Add("BaseException", ex.GetBaseException().Message);
                     }
                     if (ex.TargetSite != (MethodBase)null)
                     {
                         dictionary.Add("TargetSite", ex.TargetSite.ToString());
                     }
                     dictionary.Add("ExSource", ex.Source);
                     Globals.AppendLog(dictionary, "支付更新订单收款记录或者消息通知时出错:" + ex.Message, "", "", "UserPay");
                 }
                 this.Order.OnPayment();
             });
             base.Response.Write(string.Format("<p style=\"font-size:16px;\">恭喜您,订单已成功完成支付:{0}</br>支付金额:{1}<br><a href=\"{2}\">查看订单</a></p>", this.OrderId, this.Amount.ToString("F"), this.GetReturnLink(this.Order.OrderSource)));
         }
         else
         {
             base.Response.Write(string.Format("<p style=\"font-size:16px;\">恭喜您,订单已成功完成支付:{0}</br>支付金额:{1}<br><a href=\"{2}\">查看订单</a></p>", this.OrderId, this.Amount.ToString("F"), this.GetReturnLink(this.Order.OrderSource)));
         }
     }
 }
示例#15
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);
            }
        }