查询特殊减额结果
更新时间:2025.09.11接口限频:单特殊减额目标商户号100qps
接口说明
支持商户:【普通商户】
请求方式:【GET】/v3/aggracct-bc/wb-channel/special-reduction/{out_request_no}
请求域名:【主域名】https://api.mch.weixin.qq.com 使用该域名将访问就近的接入点
【备域名】https://api2.mch.weixin.qq.com 使用该域名将访问异地的接入点 ,指引点击查看
请求参数
Header HTTP头参数
Authorization 必填 string
请参考签名认证生成认证信息
Accept 必填 string
请设置为application/json
Wechatpay-Serial 必填 string
【微信支付公钥ID】或【微信支付平台证书序列号】 请求参数中的敏感字段,需要使用微信支付公钥加密(推荐),请参考获取微信支付公钥ID说明以及微信支付公钥加密敏感信息指引;也可以使用微信支付平台证书公钥加密,参考获取平台证书序列号、平台证书加密敏感信息指引
path 路径参数
out_request_no 必填 string(32)
【特殊减额单号】 特殊减额单号
query 查询参数
mchid 必填 string(32)
【微信支付商户号】 微信支付商户号
bal_account_no 必填 string(1024)
【额度台账号】 【加密】额度台账号
请求示例
GET
1curl -X GET \ 2 https://api.mch.weixin.qq.com/v3/aggracct-bc/wb-channel/special-reduction/htozr8denqegbt6tk6u10iymo7yww5pn?mchid=1900016681&bal_account_no=8609cb22e1774a50a930e414cc71eca06121bcd266335cda230d24a7886a8d9f \ 3 -H "Authorization: WECHATPAY2-SHA256-RSA2048 mchid=\"1900000001\",..." \ 4 -H "Accept: application/json" \ 5 -H "Wechatpay-Serial: 5157F09EFDC096DE15EBE81A47057A7232F1B8E1" 6
需配合微信支付工具库 WXPayUtility 使用,请参考Java
1package com.java.demo; 2 3import com.java.utils.WXPayUtility; // 引用微信支付工具库,参考:https://pay.weixin.qq.com/doc/v3/merchant/4014931831 4 5import com.google.gson.annotations.SerializedName; 6import com.google.gson.annotations.Expose; 7import okhttp3.MediaType; 8import okhttp3.OkHttpClient; 9import okhttp3.Request; 10import okhttp3.RequestBody; 11import okhttp3.Response; 12 13import java.io.IOException; 14import java.io.UncheckedIOException; 15import java.security.PrivateKey; 16import java.security.PublicKey; 17import java.util.ArrayList; 18import java.util.HashMap; 19import java.util.List; 20import java.util.Map; 21 22/** 23 * 查询特殊减额结果 24 */ 25public class QuerySpecialReduction { 26 private static String HOST = "https://api.mch.weixin.qq.com"; 27 private static String METHOD = "GET"; 28 private static String PATH = "/v3/aggracct-bc/wb-channel/special-reduction/{out_request_no}"; 29 30 public static void main(String[] args) { 31 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/merchant/4013070756 32 QuerySpecialReduction client = new QuerySpecialReduction( 33 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/merchant/4013070756 34 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013053053 35 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 36 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013038816 37 "/path/to/wxp_pub.pem" // 微信支付公钥文件路径,本地文件路径 38 ); 39 40 QuerySpecialReductionRequest request = new QuerySpecialReductionRequest(); 41 request.outRequestNo = "htozr8denqegbt6tk6u10iymo7yww5pn"; 42 request.mchid = "1900016681"; 43 request.balAccountNo = "8609cb22e1774a50a930e414cc71eca06121bcd266335cda230d24a7886a8d9f"; 44 try { 45 SpecialReduction response = client.run(request); 46 // TODO: 请求成功,继续业务逻辑 47 System.out.println(response); 48 } catch (WXPayUtility.ApiException e) { 49 // TODO: 请求失败,根据状态码执行不同的逻辑 50 e.printStackTrace(); 51 } 52 } 53 54 public SpecialReduction run(QuerySpecialReductionRequest request) { 55 String uri = PATH; 56 uri = uri.replace("{out_request_no}", WXPayUtility.urlEncode(request.outRequestNo)); 57 Map<String, Object> args = new HashMap<>(); 58 args.put("mchid", request.mchid); 59 args.put("bal_account_no", request.balAccountNo); 60 String queryString = WXPayUtility.urlEncode(args); 61 if (!queryString.isEmpty()) { 62 uri = uri + "?" + queryString; 63 } 64 65 Request.Builder reqBuilder = new Request.Builder().url(HOST + uri); 66 reqBuilder.addHeader("Accept", "application/json"); 67 reqBuilder.addHeader("Wechatpay-Serial", wechatPayPublicKeyId); 68 reqBuilder.addHeader("Authorization", WXPayUtility.buildAuthorization(mchid, certificateSerialNo, privateKey, METHOD, uri, null)); 69 reqBuilder.method(METHOD, null); 70 Request httpRequest = reqBuilder.build(); 71 72 // 发送HTTP请求 73 OkHttpClient client = new OkHttpClient.Builder().build(); 74 try (Response httpResponse = client.newCall(httpRequest).execute()) { 75 String respBody = WXPayUtility.extractBody(httpResponse); 76 if (httpResponse.code() >= 200 && httpResponse.code() < 300) { 77 // 2XX 成功,验证应答签名 78 WXPayUtility.validateResponse(this.wechatPayPublicKeyId, this.wechatPayPublicKey, 79 httpResponse.headers(), respBody); 80 81 // 从HTTP应答报文构建返回数据 82 return WXPayUtility.fromJson(respBody, SpecialReduction.class); 83 } else { 84 throw new WXPayUtility.ApiException(httpResponse.code(), respBody, httpResponse.headers()); 85 } 86 } catch (IOException e) { 87 throw new UncheckedIOException("Sending request to " + uri + " failed.", e); 88 } 89 } 90 91 private final String mchid; 92 private final String certificateSerialNo; 93 private final PrivateKey privateKey; 94 private final String wechatPayPublicKeyId; 95 private final PublicKey wechatPayPublicKey; 96 97 public QuerySpecialReduction(String mchid, String certificateSerialNo, String privateKeyFilePath, String wechatPayPublicKeyId, String wechatPayPublicKeyFilePath) { 98 this.mchid = mchid; 99 this.certificateSerialNo = certificateSerialNo; 100 this.privateKey = WXPayUtility.loadPrivateKeyFromPath(privateKeyFilePath); 101 this.wechatPayPublicKeyId = wechatPayPublicKeyId; 102 this.wechatPayPublicKey = WXPayUtility.loadPublicKeyFromPath(wechatPayPublicKeyFilePath); 103 } 104 105 public String encrypt(String plainText) { 106 return WXPayUtility.encrypt(this.wechatPayPublicKey, plainText); 107 } 108 109 public static class QuerySpecialReductionRequest { 110 @SerializedName("out_request_no") 111 @Expose(serialize = false) 112 public String outRequestNo; 113 114 @SerializedName("mchid") 115 @Expose(serialize = false) 116 public String mchid; 117 118 @SerializedName("bal_account_no") 119 @Expose(serialize = false) 120 public String balAccountNo; 121 } 122 123 public static class SpecialReduction { 124 @SerializedName("mchid") 125 public String mchid; 126 127 @SerializedName("bal_account_no") 128 public String balAccountNo; 129 130 @SerializedName("out_request_no") 131 public String outRequestNo; 132 133 @SerializedName("reduction_type") 134 public SpecialReductionType reductionType; 135 136 @SerializedName("amount") 137 public Long amount; 138 139 @SerializedName("state") 140 public SpecialReductionState state; 141 142 @SerializedName("reason") 143 public String reason; 144 145 @SerializedName("quota_change_no") 146 public String quotaChangeNo; 147 148 @SerializedName("success_time") 149 public String successTime; 150 151 @SerializedName("fail_time") 152 public String failTime; 153 154 @SerializedName("fail_reason") 155 public SpecialReductionFailReason failReason; 156 } 157 158 public enum SpecialReductionType { 159 @SerializedName("REDUCTION_TYPE_UNKNOWN") 160 REDUCTION_TYPE_UNKNOWN, 161 @SerializedName("FINANCIAL_PENALTY") 162 FINANCIAL_PENALTY, 163 @SerializedName("JUDICIAL_DEDUCTION") 164 JUDICIAL_DEDUCTION 165 } 166 167 public enum SpecialReductionState { 168 @SerializedName("STATE_UNKNOWN") 169 STATE_UNKNOWN, 170 @SerializedName("PROCESSING") 171 PROCESSING, 172 @SerializedName("SUCCESS") 173 SUCCESS, 174 @SerializedName("FAILED") 175 FAILED 176 } 177 178 public enum SpecialReductionFailReason { 179 @SerializedName("FAIL_REASON_UNKNOWN") 180 FAIL_REASON_UNKNOWN, 181 @SerializedName("BALANCE_NOT_ENOUGH") 182 BALANCE_NOT_ENOUGH, 183 @SerializedName("RECEIPT_NOT_EXIST") 184 RECEIPT_NOT_EXIST, 185 @SerializedName("TIME_OUT_CLOSED") 186 TIME_OUT_CLOSED 187 } 188 189} 190
需配合微信支付工具库 wxpay_utility 使用,请参考Go
1package main 2 3import ( 4 "demo/wxpay_utility" // 引用微信支付工具库,参考 https://pay.weixin.qq.com/doc/v3/merchant/4015119334 5 "encoding/json" 6 "fmt" 7 "net/http" 8 "net/url" 9 "strings" 10) 11 12func main() { 13 // TODO: 请准备商户开发必要参数,参考:https://pay.weixin.qq.com/doc/v3/merchant/4013070756 14 config, err := wxpay_utility.CreateMchConfig( 15 "19xxxxxxxx", // 商户号,是由微信支付系统生成并分配给每个商户的唯一标识符,商户号获取方式参考 https://pay.weixin.qq.com/doc/v3/merchant/4013070756 16 "1DDE55AD98Exxxxxxxxxx", // 商户API证书序列号,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013053053 17 "/path/to/apiclient_key.pem", // 商户API证书私钥文件路径,本地文件路径 18 "PUB_KEY_ID_xxxxxxxxxxxxx", // 微信支付公钥ID,如何获取请参考 https://pay.weixin.qq.com/doc/v3/merchant/4013038816 19 "/path/to/wxp_pub.pem", // 微信支付公钥文件路径,本地文件路径 20 ) 21 if err != nil { 22 fmt.Println(err) 23 return 24 } 25 26 request := &QuerySpecialReductionRequest{ 27 OutRequestNo: wxpay_utility.String("htozr8denqegbt6tk6u10iymo7yww5pn"), 28 Mchid: wxpay_utility.String("1900016681"), 29 BalAccountNo: wxpay_utility.String("8609cb22e1774a50a930e414cc71eca06121bcd266335cda230d24a7886a8d9f"), 30 } 31 32 response, err := QuerySpecialReduction(config, request) 33 if err != nil { 34 fmt.Printf("请求失败: %+v\n", err) 35 // TODO: 请求失败,根据状态码执行不同的处理 36 return 37 } 38 39 // TODO: 请求成功,继续业务逻辑 40 fmt.Printf("请求成功: %+v\n", response) 41} 42 43func QuerySpecialReduction(config *wxpay_utility.MchConfig, request *QuerySpecialReductionRequest) (response *SpecialReduction, err error) { 44 const ( 45 host = "https://api.mch.weixin.qq.com" 46 method = "GET" 47 path = "/v3/aggracct-bc/wb-channel/special-reduction/{out_request_no}" 48 ) 49 50 reqUrl, err := url.Parse(fmt.Sprintf("%s%s", host, path)) 51 if err != nil { 52 return nil, err 53 } 54 reqUrl.Path = strings.Replace(reqUrl.Path, "{out_request_no}", url.PathEscape(*request.OutRequestNo), -1) 55 query := reqUrl.Query() 56 if request.Mchid != nil { 57 query.Add("mchid", *request.Mchid) 58 } 59 if request.BalAccountNo != nil { 60 query.Add("bal_account_no", *request.BalAccountNo) 61 } 62 reqUrl.RawQuery = query.Encode() 63 httpRequest, err := http.NewRequest(method, reqUrl.String(), nil) 64 if err != nil { 65 return nil, err 66 } 67 httpRequest.Header.Set("Accept", "application/json") 68 httpRequest.Header.Set("Wechatpay-Serial", config.WechatPayPublicKeyId()) 69 authorization, err := wxpay_utility.BuildAuthorization(config.MchId(), config.CertificateSerialNo(), config.PrivateKey(), method, reqUrl.RequestURI(), nil) 70 if err != nil { 71 return nil, err 72 } 73 httpRequest.Header.Set("Authorization", authorization) 74 75 client := &http.Client{} 76 httpResponse, err := client.Do(httpRequest) 77 if err != nil { 78 return nil, err 79 } 80 respBody, err := wxpay_utility.ExtractResponseBody(httpResponse) 81 if err != nil { 82 return nil, err 83 } 84 if httpResponse.StatusCode >= 200 && httpResponse.StatusCode < 300 { 85 // 2XX 成功,验证应答签名 86 err = wxpay_utility.ValidateResponse( 87 config.WechatPayPublicKeyId(), 88 config.WechatPayPublicKey(), 89 &httpResponse.Header, 90 respBody, 91 ) 92 if err != nil { 93 return nil, err 94 } 95 response := &SpecialReduction{} 96 if err := json.Unmarshal(respBody, response); err != nil { 97 return nil, err 98 } 99 100 return response, nil 101 } else { 102 return nil, wxpay_utility.NewApiException( 103 httpResponse.StatusCode, 104 httpResponse.Header, 105 respBody, 106 ) 107 } 108} 109 110type QuerySpecialReductionRequest struct { 111 OutRequestNo *string `json:"out_request_no,omitempty"` 112 Mchid *string `json:"mchid,omitempty"` 113 BalAccountNo *string `json:"bal_account_no,omitempty"` 114} 115 116func (o *QuerySpecialReductionRequest) MarshalJSON() ([]byte, error) { 117 type Alias QuerySpecialReductionRequest 118 a := &struct { 119 OutRequestNo *string `json:"out_request_no,omitempty"` 120 Mchid *string `json:"mchid,omitempty"` 121 BalAccountNo *string `json:"bal_account_no,omitempty"` 122 *Alias 123 }{ 124 // 序列化时移除非 Body 字段 125 OutRequestNo: nil, 126 Mchid: nil, 127 BalAccountNo: nil, 128 Alias: (*Alias)(o), 129 } 130 return json.Marshal(a) 131} 132 133type SpecialReduction struct { 134 Mchid *string `json:"mchid,omitempty"` 135 BalAccountNo *string `json:"bal_account_no,omitempty"` 136 OutRequestNo *string `json:"out_request_no,omitempty"` 137 ReductionType *SpecialReductionType `json:"reduction_type,omitempty"` 138 Amount *int64 `json:"amount,omitempty"` 139 State *SpecialReductionState `json:"state,omitempty"` 140 Reason *string `json:"reason,omitempty"` 141 QuotaChangeNo *string `json:"quota_change_no,omitempty"` 142 SuccessTime *string `json:"success_time,omitempty"` 143 FailTime *string `json:"fail_time,omitempty"` 144 FailReason *SpecialReductionFailReason `json:"fail_reason,omitempty"` 145} 146 147type SpecialReductionType string 148 149func (e SpecialReductionType) Ptr() *SpecialReductionType { 150 return &e 151} 152 153const ( 154 SPECIALREDUCTIONTYPE_REDUCTION_TYPE_UNKNOWN SpecialReductionType = "REDUCTION_TYPE_UNKNOWN" 155 SPECIALREDUCTIONTYPE_FINANCIAL_PENALTY SpecialReductionType = "FINANCIAL_PENALTY" 156 SPECIALREDUCTIONTYPE_JUDICIAL_DEDUCTION SpecialReductionType = "JUDICIAL_DEDUCTION" 157) 158 159type SpecialReductionState string 160 161func (e SpecialReductionState) Ptr() *SpecialReductionState { 162 return &e 163} 164 165const ( 166 SPECIALREDUCTIONSTATE_STATE_UNKNOWN SpecialReductionState = "STATE_UNKNOWN" 167 SPECIALREDUCTIONSTATE_PROCESSING SpecialReductionState = "PROCESSING" 168 SPECIALREDUCTIONSTATE_SUCCESS SpecialReductionState = "SUCCESS" 169 SPECIALREDUCTIONSTATE_FAILED SpecialReductionState = "FAILED" 170) 171 172type SpecialReductionFailReason string 173 174func (e SpecialReductionFailReason) Ptr() *SpecialReductionFailReason { 175 return &e 176} 177 178const ( 179 SPECIALREDUCTIONFAILREASON_FAIL_REASON_UNKNOWN SpecialReductionFailReason = "FAIL_REASON_UNKNOWN" 180 SPECIALREDUCTIONFAILREASON_BALANCE_NOT_ENOUGH SpecialReductionFailReason = "BALANCE_NOT_ENOUGH" 181 SPECIALREDUCTIONFAILREASON_RECEIPT_NOT_EXIST SpecialReductionFailReason = "RECEIPT_NOT_EXIST" 182 SPECIALREDUCTIONFAILREASON_TIME_OUT_CLOSED SpecialReductionFailReason = "TIME_OUT_CLOSED" 183) 184
应答参数
200 OK
mchid 选填 string
【特殊减额目标商户号】 特殊减额目标商户号
bal_account_no 选填 string
【额度台账号】 【加密】额度台账号
out_request_no 选填 string
【商户特殊减额单号】 商户特殊减额单号
reduction_type 选填 string
【特殊减额类型】 查询特殊减额结果仅state=SUCCESS 时返回。
可选取值
REDUCTION_TYPE_UNKNOWN: 未知FINANCIAL_PENALTY: 金融惩戒JUDICIAL_DEDUCTION: 司法扣划
amount 选填 integer
【减额金额】 查询特殊减额结果仅state=SUCCESS 时返回,单位分。
state 选填 string
【处理结果】 处理结果
可选取值
STATE_UNKNOWN: 未知PROCESSING: 处理中SUCCESS: 处理成功FAILED: 处理失败
reason 选填 string
【特殊减额原因】 特殊减额原因,只在state=success返回。
quota_change_no 选填 string
【微信支付额度变更单号】 微信支付额度变更单号,仅state=SUCCESS时有效
success_time 选填 string
【成功时间】 成功时间,仅state=SUCCESS时返回有效。遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日13点29分35秒
fail_time 选填 string
【失败时间】 失败时间,仅state=FAILED时有效。遵循rfc3339标准格式,格式为yyyy-MM-DDTHH:mm:ss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日13点29分35秒
fail_reason 选填 string
【失败原因】 失败原因,仅state=FAILED时有效
可选取值
FAIL_REASON_UNKNOWN: 未知BALANCE_NOT_ENOUGH: 余额不足RECEIPT_NOT_EXIST: 单据不存在,已关单TIME_OUT_CLOSED: 系统异常处理超时,关单
应答示例
200 OK
1{ 2 "mchid" : "1900016681", 3 "bal_account_no" : "8609cb22e1774a50a930e414cc71eca06121bcd266335cda230d24a7886a8d9f", 4 "out_request_no" : "htozr8denqegbt6tk6u10iymo7yww5pn", 5 "reduction_type" : "JUDICIAL_DEDUCTION", 6 "amount" : 1, 7 "state" : "SUCCESS", 8 "reason" : "司法案件号:202508080009", 9 "quota_change_no" : "m6a6dx8iit7m932dx03ue2lw2ofo2r88", 10 "success_time" : "2015-05-20T13:29:35+08:00", 11 "fail_time" : "2015-05-20T13:29:35+08:00", 12 "fail_reason" : "BALANCE_NOT_ENOUGH" 13} 14
错误码
以下是本接口返回的错误码列表。详细错误码规则,请参考微信支付接口规则-错误码和错误提示

