mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-10-31 10:38:42 +08:00 
			
		
		
		
	🆕【微信支付】增加商家转账到零钱结果回调的解析方法
This commit is contained in:
		| @ -72,6 +72,12 @@ public class TransferBatchesRequest implements Serializable { | |||||||
|   @SerializedName("transfer_scene_id") |   @SerializedName("transfer_scene_id") | ||||||
|   private String transferSceneId; |   private String transferSceneId; | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    * 异步接收微信支付结果通知的回调地址,通知url必须为公网可访问的url,必须为https,不能携带参数 | ||||||
|  |    */ | ||||||
|  |   @SerializedName("notify_url") | ||||||
|  |   private String notifyUrl; | ||||||
|  |  | ||||||
|   @Data |   @Data | ||||||
|   @Builder(builderMethodName = "newBuilder") |   @Builder(builderMethodName = "newBuilder") | ||||||
|   @AllArgsConstructor |   @AllArgsConstructor | ||||||
|  | |||||||
| @ -0,0 +1,92 @@ | |||||||
|  | package com.github.binarywang.wxpay.bean.transfer; | ||||||
|  |  | ||||||
|  | import com.github.binarywang.wxpay.bean.notify.OriginNotifyResponse; | ||||||
|  | import com.github.binarywang.wxpay.bean.notify.WxPayBaseNotifyV3Result; | ||||||
|  | import com.google.gson.annotations.SerializedName; | ||||||
|  | import lombok.Data; | ||||||
|  | import lombok.NoArgsConstructor; | ||||||
|  |  | ||||||
|  | import java.io.Serializable; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  *  <pre> | ||||||
|  |  *    商家转账到零钱接口将转账结果通知用户 | ||||||
|  |  *    文档地址:https://pay.weixin.qq.com/docs/merchant/apis/batch-transfer-to-balance/transfer-batch-callback-notice.html | ||||||
|  |  *  </pre> | ||||||
|  |  */ | ||||||
|  | @Data | ||||||
|  | public class TransferNotifyResult implements Serializable, WxPayBaseNotifyV3Result<TransferNotifyResult.DecryptNotifyResult> { | ||||||
|  |   /** | ||||||
|  |    * 源数据 | ||||||
|  |    */ | ||||||
|  |   private OriginNotifyResponse rawData; | ||||||
|  |   /** | ||||||
|  |    * 解密后的数据 | ||||||
|  |    */ | ||||||
|  |   private TransferNotifyResult.DecryptNotifyResult result; | ||||||
|  |  | ||||||
|  |   @Data | ||||||
|  |   @NoArgsConstructor | ||||||
|  |   public static class DecryptNotifyResult implements Serializable { | ||||||
|  |     /** | ||||||
|  |      * 商户号 | ||||||
|  |      */ | ||||||
|  |     @SerializedName(value = "mchid") | ||||||
|  |     private String mchid; | ||||||
|  |     /** | ||||||
|  |      * 商家批次单号 | ||||||
|  |      */ | ||||||
|  |     @SerializedName(value = "out_batch_no") | ||||||
|  |     private String outBatchNo; | ||||||
|  |     /** | ||||||
|  |      * 微信批次单号 | ||||||
|  |      */ | ||||||
|  |     @SerializedName(value = "batch_id") | ||||||
|  |     private String batchId; | ||||||
|  |     /** | ||||||
|  |      * 批次状态 | ||||||
|  |      */ | ||||||
|  |     @SerializedName(value = "batch_status") | ||||||
|  |     private String batchStatus; | ||||||
|  |     /** | ||||||
|  |      * 批次总笔数 | ||||||
|  |      */ | ||||||
|  |     @SerializedName(value = "total_num") | ||||||
|  |     private Integer totalNum; | ||||||
|  |     /** | ||||||
|  |      * 批次总金额 | ||||||
|  |      */ | ||||||
|  |     @SerializedName(value = "total_amount") | ||||||
|  |     private Integer totalAmount; | ||||||
|  |     /** | ||||||
|  |      * 转账成功金额 | ||||||
|  |      */ | ||||||
|  |     @SerializedName(value = "success_amount") | ||||||
|  |     private Integer successAmount; | ||||||
|  |     /** | ||||||
|  |      * 转账成功笔数 | ||||||
|  |      */ | ||||||
|  |     @SerializedName(value = "success_num") | ||||||
|  |     private Integer successNum; | ||||||
|  |     /** | ||||||
|  |      * 转账失败金额 | ||||||
|  |      */ | ||||||
|  |     @SerializedName(value = "fail_amount") | ||||||
|  |     private Integer failAmount; | ||||||
|  |     /** | ||||||
|  |      * 转账失败笔数 | ||||||
|  |      */ | ||||||
|  |     @SerializedName(value = "fail_num") | ||||||
|  |     private Integer failNum; | ||||||
|  |     /** | ||||||
|  |      * 批次更新时间 | ||||||
|  |      */ | ||||||
|  |     @SerializedName(value = "update_time") | ||||||
|  |     private String updateTime; | ||||||
|  |     /** | ||||||
|  |      * 批次关闭原因 | ||||||
|  |      */ | ||||||
|  |     @SerializedName(value = "close_reason") | ||||||
|  |     private String closeReason; | ||||||
|  |   } | ||||||
|  | } | ||||||
| @ -1,5 +1,6 @@ | |||||||
| package com.github.binarywang.wxpay.service; | package com.github.binarywang.wxpay.service; | ||||||
|  |  | ||||||
|  | import com.github.binarywang.wxpay.bean.notify.SignatureHeader; | ||||||
| import com.github.binarywang.wxpay.bean.transfer.*; | import com.github.binarywang.wxpay.bean.transfer.*; | ||||||
| import com.github.binarywang.wxpay.exception.WxPayException; | import com.github.binarywang.wxpay.exception.WxPayException; | ||||||
|  |  | ||||||
| @ -28,6 +29,17 @@ public interface TransferService { | |||||||
|    */ |    */ | ||||||
|   TransferBatchesResult transferBatches(TransferBatchesRequest request) throws WxPayException; |   TransferBatchesResult transferBatches(TransferBatchesRequest request) throws WxPayException; | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    * 解析商家转账结果 | ||||||
|  |    * 详见<a href="https://pay.weixin.qq.com/docs/merchant/apis/batch-transfer-to-balance/transfer-batch-callback-notice.html"></a> | ||||||
|  |    * | ||||||
|  |    * @param notifyData 通知数据 | ||||||
|  |    * @param header     通知头部数据,不传则表示不校验头 | ||||||
|  |    * @return the wx transfer notify result | ||||||
|  |    * @throws WxPayException the wx pay exception | ||||||
|  |    */ | ||||||
|  |   TransferNotifyResult parseTransferNotifyResult(String notifyData, SignatureHeader header) throws WxPayException; | ||||||
|  |  | ||||||
|   /** |   /** | ||||||
|    * <pre> |    * <pre> | ||||||
|    * |    * | ||||||
|  | |||||||
| @ -1,5 +1,6 @@ | |||||||
| package com.github.binarywang.wxpay.service.impl; | package com.github.binarywang.wxpay.service.impl; | ||||||
|  |  | ||||||
|  | import com.github.binarywang.wxpay.bean.notify.SignatureHeader; | ||||||
| import com.github.binarywang.wxpay.bean.transfer.*; | import com.github.binarywang.wxpay.bean.transfer.*; | ||||||
| import com.github.binarywang.wxpay.exception.WxPayException; | import com.github.binarywang.wxpay.exception.WxPayException; | ||||||
| import com.github.binarywang.wxpay.service.TransferService; | import com.github.binarywang.wxpay.service.TransferService; | ||||||
| @ -36,6 +37,11 @@ public class TransferServiceImpl implements TransferService { | |||||||
|     return GSON.fromJson(result, TransferBatchesResult.class); |     return GSON.fromJson(result, TransferBatchesResult.class); | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   @Override | ||||||
|  |   public TransferNotifyResult parseTransferNotifyResult(String notifyData, SignatureHeader header) throws WxPayException { | ||||||
|  |     return this.payService.baseParseOrderNotifyV3Result(notifyData, header, TransferNotifyResult.class, TransferNotifyResult.DecryptNotifyResult.class); | ||||||
|  |   } | ||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   public QueryTransferBatchesResult transferBatchesBatchId(QueryTransferBatchesRequest request) throws WxPayException { |   public QueryTransferBatchesResult transferBatchesBatchId(QueryTransferBatchesRequest request) throws WxPayException { | ||||||
|     String url; |     String url; | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 wzkris
					wzkris