コード例 #1
0
        /// <summary>
        /// 2-付款成功 1-未付款 3-异常
        /// </summary>
        /// <param name="out_trade_no"></param>
        /// <returns></returns>
        public static int OrderQuery(string out_trade_no)
        {
            var exist_payment = Foresight.DataAccess.Payment.GetPaymentByTradeNo(out_trade_no);

            if (exist_payment == null)
            {
                return(1);
            }
            if (string.IsNullOrEmpty(exist_payment.PaymentType))
            {
                return(1);
            }
            if (exist_payment.PaymentType.Equals(Utility.EnumModel.PaymentTypeDefine.wx.ToString()))
            {
                if (exist_payment.Status == 2)
                {
                    Web.APPCode.PaymentHelper.SaveRoomFee(out_trade_no, "微信公众号微信支付", "微信支付");
                    return(2);
                }
                WxPayData data = new WxPayData();
                data.SetValue("out_trade_no", out_trade_no);
                WxPayData result      = WxPayApi.OrderQuery(data);//提交订单查询请求给API,接收返回数据
                var       sort_list   = data.FromXml(result.ToXml());
                var       trade_state = result.GetValue("trade_state");
                if (trade_state != null && trade_state.ToString() == "SUCCESS")
                {
                    Web.APPCode.PaymentHelper.SaveRoomFee(out_trade_no, "微信公众号微信支付", "微信支付");
                    return(2);
                }
                return(1);
            }
            if (exist_payment.PaymentType.Equals(Utility.EnumModel.PaymentTypeDefine.alipay.ToString()))
            {
                if (exist_payment.Status == 2)
                {
                    Web.APPCode.PaymentHelper.SaveRoomFee(out_trade_no, "微信公众号支付宝支付", "支付宝");
                    return(2);
                }
                return(AlipayOrderQuery(out_trade_no));
            }
            if (exist_payment.PaymentType.Equals(Utility.EnumModel.PaymentTypeDefine.app_wx.ToString()))
            {
                if (exist_payment.Status == 2)
                {
                    Web.APPCode.PaymentHelper.SaveRoomFee(out_trade_no, "APP微信支付", "微信支付");
                    return(2);
                }
                WxPayData data = new WxPayData();
                data.SetValue("out_trade_no", out_trade_no);
                WxPayData result      = WxPayApi.OrderQueryAPP(data);//提交订单查询请求给API,接收返回数据
                var       sort_list   = data.FromXml(result.ToXml());
                var       trade_state = result.GetValue("trade_state");
                if (trade_state != null && trade_state.ToString() == "SUCCESS")
                {
                    Web.APPCode.PaymentHelper.SaveRoomFee(out_trade_no, "APP微信支付", "微信支付");
                    return(2);
                }
                return(1);
            }
            if (exist_payment.PaymentType.Equals(Utility.EnumModel.PaymentTypeDefine.app_alipay.ToString()))
            {
                if (exist_payment.Status == 2)
                {
                    Web.APPCode.PaymentHelper.SaveRoomFee(out_trade_no, "APP支付宝支付", "支付宝");
                    return(2);
                }
                return(AlipayAPPOrderQuery(out_trade_no));
            }
            return(1);
        }