Пример #1
0
        public bool ClientCompleteServiceOrder(CompleteServiceOrder order, out string msg)
        {
            LogHelper.Logger.Debug("订单信息:" + order.ToJson());
            var orderId   = order.OrderID;
            var orderInfo = _userPayOrdeRepository.FirstOrDefault(p => p.Id == orderId);

            if (orderInfo == null)
            {
                msg = "没有查询到相关的订单";
                return(false);
            }

            LogHelper.Logger.Debug("查询到的订单信息为:" + orderInfo.ToJson());

            if (orderInfo.State == 2)
            {
                msg = "充值成功,您可以登陆代理系统查看您的充值金额";
                return(true);
            }


            var query = _orderPolicy.Orderquery(string.Format("{0}{1}", WxPayConfig.MCHID, order.OrderID), OrderType.OutTradeNo);

            if (query == null)
            {
                LogHelper.Logger.Error("没有查询到相关的订单信息");

                orderInfo.State      = 3;
                orderInfo.PayState   = "FAIL";
                orderInfo.UpdateTime = DateTime.Now;
                _userPayOrdeRepository.Update(orderInfo);
                msg = "没有查询到相关的订单信息";
                return(false);
            }
            else
            {
                LogHelper.Logger.Debug(query.ToJson());
                if (query.IsSet("trade_state") && query.GetValue("trade_state").ToString() == "SUCCESS")
                {
                    //    var orderState = _purchaseServiceRepository.CompleteServiceOrder(new CompleteServiceOrder()
                    //    {
                    //        OrderID = orderId,
                    //        Cost = (double)Convert.ToInt32(query.GetValue("total_fee")) / 100,
                    //        NewID = OrderHelper.GenerateNewId(),
                    //        PayState = query.GetValue("trade_state").ToString(),
                    //        PayExtendInfo = query.ToXml(),
                    //        PayOrderID = query.GetValue("transaction_id").ToString(),
                    //        Remarks = "微信公众号支付"
                    //    });
                    var orderState = CompleteRechargeOrder(query, out msg);

                    return(orderState);
                }
                else
                {
                    msg = "支付失败";
                    return(false);
                }
            }
        }
Пример #2
0
        public int ClientCompleteServiceOrder(CompleteServiceOrder order)
        {
            LogHelper.Logger.Debug("订单信息:" + order.ToJson());
            var orderId   = order.OrderID;
            var orderInfo = _userPayOrdeRepository.FirstOrDefault(p => p.Id == orderId);

            if (orderInfo == null)
            {
                return(-2);
            }

            LogHelper.Logger.Debug("查询到的订单信息为:" + orderInfo.ToJson());

            if (orderInfo.State == 2)
            {
                return(0);
            }


            var query = _orderPolicy.Orderquery(string.Format("{0}{1}", WxPayConfig.MCHID, order.OrderID), OrderType.OutTradeNo);

            if (query == null)
            {
                LogHelper.Logger.Error("没有查询到相关的订单信息");
                _purchaseServiceRepository.UpdateServiceOrder(new UpdateServiceOrder()
                {
                    ID       = orderId,
                    State    = 3,
                    PayState = "FAIL",
                });
                return(-1);
            }
            else
            {
                LogHelper.Logger.Debug(query.ToJson());
                if (query.IsSet("trade_state") && query.GetValue("trade_state").ToString() == "SUCCESS")
                {
                    var orderState = _purchaseServiceRepository.CompleteServiceOrder(new CompleteServiceOrder()
                    {
                        OrderID       = orderId,
                        Cost          = (double)Convert.ToInt32(query.GetValue("total_fee")) / 100,
                        NewID         = OrderHelper.GenerateNewId(),
                        PayState      = query.GetValue("trade_state").ToString(),
                        PayExtendInfo = query.ToXml(),
                        PayOrderID    = query.GetValue("transaction_id").ToString(),
                        Remarks       = "微信公众号支付"
                    });

                    return(orderState);
                }
                else
                {
                    return(-1);
                }
            }
        }