Exemplo n.º 1
0
 private void PayOrder(OrderInfo order)
 {
     if (order.OrderStatus == OrderStatus.BuyerAlreadyPaid)
     {
         return;
     }
     //如果需要拆单
     if (TradeHelper.CheckIsUnpack(order.OrderId) && order.OrderStatus == OrderStatus.WaitBuyerPay)
     {
         if (order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UserPayOrder(order, false, 1))
         {
             //if (order.UserId != 0 && order.UserId != 1100)
             //{
             //    IUser user = Users.GetUser(order.UserId);
             //    if (user != null && user.UserRole == UserRole.Member)
             //    {
             //        Messenger.OrderPayment(user, order, order.GetTotal());
             //    }
             //}
         }
     }
     else
     {
         if (order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UserPayOrder(order, false))
         {
             //if (order.UserId != 0 && order.UserId != 1100)
             //{
             //    IUser user = Users.GetUser(order.UserId);
             //    if (user != null && user.UserRole == UserRole.Member)
             //    {
             //        Messenger.OrderPayment(user, order, order.GetTotal());
             //    }
             //}
         }
     }
 }
Exemplo n.º 2
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");
            //}
        }
        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");
        }
Exemplo n.º 4
0
        private void UserPayOrder()
        {
            ErrorLog.Write("微信扫码回调原始数据(wx_PayQRcode_notify_url),开始处理订单状态...");

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

            string json = Newtonsoft.Json.JsonConvert.SerializeObject(payNotify);

            if (Order.OrderStatus == OrderStatus.WaitBuyerPay)
            {
                //如果需要拆单
                if (TradeHelper.CheckIsUnpack(OrderId))
                {
                    ErrorLog.Write(string.Format("微信扫码回调原始数据(wx_PayQRcode_notify_url)拆单,原订单{0},返回信息{1}", this.Order.OrderId, json));
                    if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UserPayOrder(this.Order, false, 1))
                    {
                        OrderHelper.SetOrderPayStatus(OrderId, 2);
                        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)//合并单据
                {
                    ErrorLog.Write(string.Format("微信扫码回调原始数据(wx_PayQRcode_notify_url)合并单据,原订单{0},返回信息{1}", this.Order.OrderId, json));
                    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);
                        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("微信扫码回调原始数据(wx_PayQRcode_notify_url)正常单据,原订单{0},返回信息{1}", this.Order.OrderId, json));
                    if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UserPayOrder(this.Order, false))
                    {
                        OrderHelper.SetOrderPayStatus(OrderId, 2);
                        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("微信扫码支付回调,当前状态不支持付款,订单号:{0},订单状态:{1}", this.Order.OrderId, this.Order.OrderStatus));
            }
        }
Exemplo n.º 5
0
        private void UserPayOrder()
        {
            if (this.Order.OrderStatus == OrderStatus.BuyerAlreadyPaid)
            {
                base.Response.Write("success");
                return;
            }
            string json = Newtonsoft.Json.JsonConvert.SerializeObject(payNotify);

            //如果需要拆单
            if (TradeHelper.CheckIsUnpack(OrderId) && Order.OrderStatus == OrderStatus.WaitBuyerPay)
            {
                ErrorLog.Write(string.Format("微信App支付拆单,原订单{0},返回信息{1}", this.Order.OrderId, json));
                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();
                    base.Response.Write("success");
                }
            }
            else if (Order.OrderType == (int)OrderType.WillMerge && Order.OrderStatus == OrderStatus.WaitBuyerPay)//合并单据
            {
                ErrorLog.Write(string.Format("微信App支付合并单据,原订单{0},返回信息{1}", this.Order.OrderId, json));
                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();
                    base.Response.Write("success");
                }
            }
            else
            {
                ErrorLog.Write(string.Format("微信App支付正常单据,原订单{0},返回信息{1}", this.Order.OrderId, json));
                if (this.Order.CheckAction(OrderActions.BUYER_PAY) && TradeHelper.UserPayOrder(this.Order, false))
                {
                    //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();
                    base.Response.Write("success");
                }
            }
        }