Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string type = Request.Form["querytype"];

            if (type == "alirefundquery")
            {
                typeChannel = "Ali";
                Response.Write("<span style='color:#00CD00;font-size:20px'>" + "Ali" + "</span><br/>");
                BCRefundQuerytResult result = BCPay.BCRefundQueryByCondition("ALI", null, null, null, null, null, 50);
                refunds = result.refunds;
            }
            if (type == "wxrefundquery")
            {
                typeChannel = "WX";
                Response.Write("<span style='color:#00CD00;font-size:20px'>" + "WX" + "</span><br/>");
                BCRefundQuerytResult result = BCPay.BCRefundQueryByCondition("WX", null, null, null, null, null, 50);
                refunds = result.refunds;
            }
            if (type == "unionrefundquery")
            {
                typeChannel = "UN";
                Response.Write("<span style='color:#00CD00;font-size:20px'>" + "UN" + "</span><br/>");
                BCRefundQuerytResult result = BCPay.BCRefundQueryByCondition("UN", null, null, null, null, null, 50);
                refunds = result.refunds;
            }
            this.bind();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 退款订单查询
        /// </summary>
        /// <param name="channel">渠道类型
        ///     根据不同场景选择不同的支付方式
        ///     必填
        ///     可以通过enum BCPay.QueryChannel获取
        ///     channel的参数值含义:
        ///     WX: 微信所有类型支付
        ///     WX_APP: 微信手机APP支付
        ///     WX_NATIVE: 微信公众号二维码支付
        ///     WX_JSAPI: 微信公众号支付
        ///     ALI: 支付宝所有类型支付
        ///     ALI_APP: 支付宝APP支付
        ///     ALI_WEB: 支付宝网页支付
        ///     ALI_QRCODE: 支付宝内嵌二维码支付
        ///     UN: 银联所有类型支付
        ///     UN_APP: 银联APP支付
        ///     UN_WEB: 银联网页支付</param>
        /// <param name="billNo">商户订单号
        /// </param>
        /// <param name="refundNo">商户退款单号
        /// </param>
        /// <param name="startTime">起始时间
        ///     毫秒时间戳, 13位, 可以使用BCUtil.GetTimeStamp()方法获取
        ///     选填</param>
        /// <param name="endTime">结束时间
        ///     毫秒时间戳, 13位, 可以使用BCUtil.GetTimeStamp()方法获取
        ///     选填</param>
        /// <param name="skip">查询起始位置
        ///     默认为0。设置为10表示忽略满足条件的前10条数据
        ///     选填
        /// </param>
        /// <param name="limit">查询的条数
        ///     默认为10,最大为50。设置为10表示只返回满足条件的10条数据
        ///     选填
        /// </param>
        /// <returns>
        ///     BCRefundQuerytResult
        /// </returns>
        public static BCRefundQuerytResult BCRefundQueryByCondition(string channel, string billNo, string refundNo, long?startTime, long?endTime, int?skip, int?limit)
        {
            Random random      = new Random();
            string payQueryUrl = BCPrivateUtil.mLocalDefaultHosts[random.Next(0, 4)] + BCConstants.version + BCConstants.refundsURL;

            long timestamp = BCUtil.GetTimeStamp(DateTime.Now);

            JsonData data = new JsonData();

            data["app_id"]     = BCCache.Instance.appId;
            data["app_sign"]   = BCPrivateUtil.getAppSignature(BCCache.Instance.appId, BCCache.Instance.appSecret, timestamp.ToString());
            data["timestamp"]  = timestamp;
            data["channel"]    = channel;
            data["bill_no"]    = billNo;
            data["refund_no"]  = refundNo;
            data["start_time"] = startTime;
            data["end_time"]   = endTime;
            data["skip"]       = skip;
            data["limit"]      = limit;

            string paraString = data.ToJson();

            try
            {
                string          url          = payQueryUrl + "?para=" + HttpUtility.UrlEncode(paraString, Encoding.UTF8);
                HttpWebResponse response     = BCPrivateUtil.CreateGetHttpResponse(url, BCCache.Instance.networkTimeout, null, null);
                string          respString   = BCPrivateUtil.GetResponseString(response);
                JsonData        responseData = JsonMapper.ToObject(respString);

                BCRefundQuerytResult result = new BCRefundQuerytResult();

                result.resultCode = int.Parse(responseData["result_code"].ToString());
                result.resultMsg  = responseData["result_msg"].ToString();
                if (result.resultCode == 0)
                {
                    result.count = int.Parse(responseData["count"].ToString());
                    if (responseData["refunds"].IsArray)
                    {
                        List <BCRefund> refunds = new List <BCRefund>();
                        foreach (JsonData refundData in responseData["refunds"])
                        {
                            BCRefund refund = new BCRefund();
                            refund.title       = refundData["title"].ToString();
                            refund.billNo      = refundData["bill_no"].ToString();
                            refund.refundNo    = refundData["refund_no"].ToString();
                            refund.totalFee    = int.Parse(refundData["total_fee"].ToString());
                            refund.refundFee   = int.Parse(refundData["refund_fee"].ToString());
                            refund.channel     = refundData["channel"].ToString();
                            refund.finish      = (bool)refundData["finish"];
                            refund.result      = (bool)refundData["result"];
                            refund.createdTime = BCUtil.GetDateTime((long)refundData["created_time"]);
                            refunds.Add(refund);
                        }
                        result.refunds = refunds;
                    }
                }
                else
                {
                    result.errDetail = responseData["err_detail"].ToString();
                }

                return(result);
            }
            catch (Exception e)
            {
                BCRefundQuerytResult result = new BCRefundQuerytResult();
                result.resultCode = 99;
                result.resultMsg  = e.Message;
                return(result);
            }
        }