new:电商收付通商户、平台提现

This commit is contained in:
曾浩 2020-09-21 10:29:00 +08:00
parent 9b20c749ce
commit 00bc9656b6
8 changed files with 339 additions and 9 deletions

View File

@ -69,7 +69,7 @@ public class CombineTransactionsResult implements Serializable {
* </pre>
*/
@SerializedName(value = "scene_info")
private CombineTransactionsNotifyResult.SceneInfo sceneInfo;
private CombineTransactionsResult.SceneInfo sceneInfo;
/**
* <pre>
@ -83,7 +83,7 @@ public class CombineTransactionsResult implements Serializable {
* </pre>
*/
@SerializedName(value = "sub_orders")
private List<CombineTransactionsNotifyResult.SubOrders> subOrders;
private List<CombineTransactionsResult.SubOrders> subOrders;
/**
* <pre>
@ -95,7 +95,7 @@ public class CombineTransactionsResult implements Serializable {
* </pre>
*/
@SerializedName(value = "combine_payer_info")
private CombineTransactionsNotifyResult.CombinePayerInfo combinePayerInfo;
private CombineTransactionsResult.CombinePayerInfo combinePayerInfo;
@Data
@NoArgsConstructor
@ -248,7 +248,7 @@ public class CombineTransactionsResult implements Serializable {
* </pre>
*/
@SerializedName(value = "amount")
private CombineTransactionsNotifyResult.Amount amount;
private CombineTransactionsResult.Amount amount;
}

View File

@ -0,0 +1,89 @@
package com.github.binarywang.wxpay.bean.ecommerce;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* 二级商户账户余额提现
* <pre>
* 文档地址https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/pay/combine/chapter3_3.shtml
* </pre>
*/
@Data
@NoArgsConstructor
public class EcommerceWithdrawRequest implements Serializable {
/**
* <pre>
* 字段名二级商户号
* 变量名sub_mchid
* 是否必填
* 类型string32
* 描述
* 电商平台二级商户号由微信支付生成并下发
* 示例值1900000109
* </pre>
*/
@SerializedName(value = "sub_mchid")
private String subMchid;
/**
* <pre>
* 字段名商户提现单号
* 变量名out_request_no
* 是否必填
* 类型string32
* 描述
* 必须是字母数字
* 示例值 20190611222222222200000000012122
* </pre>
*/
@SerializedName(value = "out_request_no")
private String outRequestNo;
/**
* <pre>
* 字段名提现金额
* 变量名amount
* 是否必填
* 类型int64
* 描述
* 提现金额单位
* 示例值100
* </pre>
*/
@SerializedName(value = "amount")
private Integer amount;
/**
* <pre>
* 字段名备注
* 变量名remark
* 是否必填
* 类型string56
* 描述
* 商户对提现单的备注
* 示例值交易提现
* </pre>
*/
@SerializedName(value = "remark")
private String remark;
/**
* <pre>
* 字段名银行附言
* 变量名bank_memo
* 是否必填
* 类型string32
* 描述
* 展示在收款银行系统中的附言数字字母最长32个汉字能否成功展示依赖银行系统支持
* 示例值微信支付提现
* </pre>
*/
@SerializedName(value = "bank_memo")
private String bankMemo;
}

View File

@ -0,0 +1,60 @@
package com.github.binarywang.wxpay.bean.ecommerce;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* 二级商户账户余额提现 结果
* <pre>
* 文档地址https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/fund/chapter3_2.shtml
* </pre>
*/
@Data
@NoArgsConstructor
public class EcommerceWithdrawResult implements Serializable {
/**
* <pre>
* 字段名二级商户号
* 变量名sub_mchid
* 是否必填
* 类型string32
* 描述
* 电商平台二级商户号由微信支付生成并下发
* 示例值1900000109
* </pre>
*/
@SerializedName(value = "sub_mchid")
private String subMchid;
/**
* <pre>
* 字段名微信支付提现单号
* 变量名withdraw_id
* 是否必填
* 类型string128
* 描述
* 电商平台提交二级商户提现申请后由微信支付返回的申请单号作为查询申请状态的唯一标识
* 示例值 12321937198237912739132791732912793127931279317929791239112123
* </pre>
*/
@SerializedName(value = "withdraw_id")
private String withdrawId;
/**
* <pre>
* 字段名商户提现单号
* 变量名out_request_no
* 是否必填
* 类型string32
* 描述
* 必须是字母数字
* 示例值 20190611222222222200000000012122
* </pre>
*/
@SerializedName(value = "out_request_no")
private String outRequestNo;
}

View File

@ -0,0 +1,91 @@
package com.github.binarywang.wxpay.bean.ecommerce;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* 电商平台提现
* <pre>
* 文档地址https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/fund/chapter3_5.shtml
* </pre>
*/
@Data
@NoArgsConstructor
public class MerchantWithdrawRequest implements Serializable {
/**
* <pre>
* 字段名商户提现单号
* 变量名out_request_no
* 是否必填
* 类型string32
* 描述
* 商户提现单号由商户自定义生成
* 示例值20190611222222222200000000012122
* </pre>
*/
@SerializedName(value = "out_request_no")
private String outRequestNo;
/**
* <pre>
* 字段名提现金额
* 变量名amount
* 是否必填
* 类型int64
* 描述
* 提现金额单位RMB
* 示例值1
* </pre>
*/
@SerializedName(value = "amount")
private Integer amount;
/**
* <pre>
* 字段名备注
* 变量名remark
* 是否必填
* 类型string56
* 描述
* 商户对提现单的备注
* 示例值交易提现
* </pre>
*/
@SerializedName(value = "remark")
private String remark;
/**
* <pre>
* 字段名银行附言
* 变量名bank_memo
* 是否必填
* 类型string32
* 描述
* 展示在收款银行系统中的附言数字字母最长32个汉字能否成功展示依赖银行系统支持
* 示例值xx平台提现
* </pre>
*/
@SerializedName(value = "bank_memo")
private String bankMemo;
/**
* <pre>
* 字段名账户类型
* 变量名account_type
* 是否必填
* 类型string16
* 描述
* 枚举值
* BASIC基本账户
* OPERATION运营账户
* FEES手续费账户
* 示例值BASIC
* </pre>
*/
@SerializedName(value = "account_type")
private String accountType;
}

View File

@ -0,0 +1,46 @@
package com.github.binarywang.wxpay.bean.ecommerce;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
* 电商平台提现 结果
* <pre>
* 文档地址https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/fund/chapter3_5.shtml
* </pre>
*/
@Data
@NoArgsConstructor
public class MerchantWithdrawResult implements Serializable {
/**
* <pre>
* 字段名微信支付提现单号
* 变量名withdraw_id
* 是否必填 文档里面是理论上应该都有值
* 类型string128
* 描述
* 微信支付系统生成的提现单号
* 示例值12321937198237912739132791732912793127931279317929791239112123
* </pre>
*/
@SerializedName(value = "withdraw_id")
private String withdrawId;
/**
* <pre>
* 字段名商户提现单号
* 变量名out_request_no
* 是否必填
* 类型string32
* 描述
* 必须是字母数字
* 示例值 20190611222222222200000000012122
* </pre>
*/
@SerializedName(value = "out_request_no")
private String outRequestNo;
}

View File

@ -203,7 +203,7 @@ public class PartnerTransactionsResult implements Serializable {
* </pre>
*/
@SerializedName(value = "combine_payer_info")
private PartnerTransactionsNotifyResult.CombinePayerInfo combinePayerInfo;
private PartnerTransactionsResult.CombinePayerInfo combinePayerInfo;
/**
* <pre>
@ -215,7 +215,7 @@ public class PartnerTransactionsResult implements Serializable {
* </pre>
*/
@SerializedName(value = "amount")
private PartnerTransactionsNotifyResult.Amount amount;
private PartnerTransactionsResult.Amount amount;
/**
* <pre>
@ -227,7 +227,7 @@ public class PartnerTransactionsResult implements Serializable {
* </pre>
*/
@SerializedName(value = "scene_info")
private PartnerTransactionsNotifyResult.SceneInfo sceneInfo;
private PartnerTransactionsResult.SceneInfo sceneInfo;
/**
* <pre>
@ -239,7 +239,7 @@ public class PartnerTransactionsResult implements Serializable {
* </pre>
*/
@SerializedName(value = "promotion_detail")
private List<PartnerTransactionsNotifyResult.PromotionDetail> promotionDetails;
private List<PartnerTransactionsResult.PromotionDetail> promotionDetails;
@Data
@NoArgsConstructor
@ -507,7 +507,7 @@ public class PartnerTransactionsResult implements Serializable {
* </pre>
*/
@SerializedName(value = "goods_detail")
private List<PartnerTransactionsNotifyResult.GoodsDetail> goodsDetails;
private List<PartnerTransactionsResult.GoodsDetail> goodsDetails;
}

View File

@ -261,4 +261,27 @@ public interface EcommerceService {
*/
RefundsResult refunds(RefundsRequest request) throws WxPayException;
/**
* <pre>
* 二级商户账户余额提现API
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/fund/chapter3_2.shtml
* </pre>
*
* @param request 提现请求
* @return 返回数据 return withdraw result
* @throws WxPayException the wx pay exception
*/
EcommerceWithdrawResult withdraw(EcommerceWithdrawRequest request) throws WxPayException;
/**
* <pre>
* 电商平台提现API
* 文档地址: https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/ecommerce/fund/chapter3_5.shtml
* </pre>
*
* @param request 提现请求
* @return 返回数据 return withdraw result
* @throws WxPayException the wx pay exception
*/
MerchantWithdrawResult withdraw(MerchantWithdrawRequest request) throws WxPayException;
}

View File

@ -20,6 +20,7 @@ import java.util.Objects;
@RequiredArgsConstructor
public class EcommerceServiceImpl implements EcommerceService {
private static final Gson GSON = new GsonBuilder().create();
private final WxPayService payService;
@ -201,6 +202,26 @@ public class EcommerceServiceImpl implements EcommerceService {
return GSON.fromJson(response, RefundsResult.class);
}
@Override
public EcommerceWithdrawResult withdraw(EcommerceWithdrawRequest request) throws WxPayException {
String url = String.format("%s/v3/ecommerce/fund/withdraw", this.payService.getPayBaseUrl());
String response = this.payService.postV3(url, GSON.toJson(request));
return GSON.fromJson(response, EcommerceWithdrawResult.class);
}
@Override
public MerchantWithdrawResult withdraw(MerchantWithdrawRequest request) throws WxPayException {
String url = String.format("%s/v3/merchant/fund/withdraw", this.payService.getPayBaseUrl());
String response = this.payService.postV3(url, GSON.toJson(request));
return GSON.fromJson(response, MerchantWithdrawResult.class);
}
/**
* 校验通知签名
* @param header 通知头信息
* @param data 通知数据
* @return true:校验通过 false:校验不通过
*/
private boolean verifyNotifySign(SignatureHeader header, String data) {
String beforeSign = String.format("%s\n%s\n%s\n",
header.getTimeStamp(),