#1010 微信支付模块增加单次分账接口

This commit is contained in:
王广鑫
2019-10-22 13:45:55 +08:00
committed by Binary Wang
parent 70ce3a2ff9
commit 81df397536
10 changed files with 351 additions and 5 deletions

View File

@@ -0,0 +1,33 @@
package com.github.binarywang.wxpay.bean.profitsharing;
import com.github.binarywang.wxpay.bean.result.BaseWxPayResult;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
/**
* @author Wang GuangXin 2019/10/22 10:06
* @version 1.0
*/
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@XStreamAlias("xml")
public class ProfitSharingResult extends BaseWxPayResult {
/**
* 微信订单号.
*/
@XStreamAlias("transaction_id")
private String transactionId;
/**
* 商户分账单号.
*/
@XStreamAlias("out_order_no")
private String outOrderNo;
/**
* 微信分账单号.
*/
@XStreamAlias("order_id")
private String orderId;
}

View File

@@ -0,0 +1,86 @@
package com.github.binarywang.wxpay.bean.profitsharing;
import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest;
import com.github.binarywang.wxpay.constant.WxPayConstants;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import lombok.*;
import me.chanjar.weixin.common.annotation.Required;
/**
* @author Wang GuangXin 2019/10/21 17:57
* @version 1.0
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Builder(builderMethodName = "newBuilder")
@NoArgsConstructor
@AllArgsConstructor
@XStreamAlias("xml")
public class ProfitsharingRequest extends BaseWxPayRequest {
private static final long serialVersionUID = 212049937430575842L;
/**
* <pre>
* 字段名:微信订单号.
* 变量名transaction_id
* 是否必填:是
* String(32)
* 示例值4208450740201411110007820472
* 描述:微信支付订单号
* </pre>
*/
@XStreamAlias("transaction_id")
@Required
private String transactionId;
/**
* <pre>
* 字段名:商户分账单号.
* 变量名out_order_no
* 是否必填:是
* String(64)
* 示例值P20150806125346
* 描述商户系统内部的分账单号在商户系统内部唯一单次分账、多次分账、完结分账应使用不同的商户分账单号同一分账单号多次请求等同一次。只能是数字、大小写字母_-|*@
* </pre>
*/
@XStreamAlias("out_order_no")
@Required
private String outOrderNo;
/**
* <pre>
* 字段名:分账接收方列表.
* 变量名receivers
* 是否必填:是
* String(10240)
* 示例值:[
* {
* "type": "MERCHANT_ID",
* "account":"190001001",
* "amount":100,
* "description": "分到商户"
* },
* {
* "type": "PERSONAL_WECHATID",
* "account":"86693952",
* "amount":888,
* "description": "分到个人"
* }
* ]
* 描述分账接收方列表不超过50个json对象不能设置分账方作为分账接受方使用Json格式
* </pre>
*/
@XStreamAlias("receivers")
@Required
private String receivers;
@Override
protected void checkConstraints() throws WxPayException {
/**
* 目前仅支持HMAC-SHA256
*/
this.setSignType(WxPayConstants.SignType.HMAC_SHA256);
}
}

View File

@@ -0,0 +1,47 @@
package com.github.binarywang.wxpay.bean.profitsharing;
import java.io.Serializable;
/**
* @author Wang GuangXin 2019/10/22 11:07
* @version 1.0
*/
public class Receiver implements Serializable {
private String type;
private String account;
private Integer amount;
private String description;
/**
* @param type MERCHANT_ID商户ID
* PERSONAL_WECHATID个人微信号PERSONAL_OPENID个人openid由父商户APPID转换得到PERSONAL_SUB_OPENID: 个人sub_openid由子商户APPID转换得到
* @param account 类型是MERCHANT_ID时是商户ID
* 类型是PERSONAL_WECHATID时是个人微信号
* 类型是PERSONAL_OPENID时是个人openid
* 类型是PERSONAL_SUB_OPENID时是个人sub_openid
* @param amount 分账金额,单位为分,只能为整数,不能超过原订单支付金额及最大分账比例金额
* @param description 分账的原因描述,分账账单中需要体现
*/
public Receiver(String type, String account, Integer amount, String description) {
this.type = type;
this.account = account;
this.amount = amount;
this.description = description;
}
public String getType() {
return type;
}
public String getAccount() {
return account;
}
public Integer getAmount() {
return amount;
}
public String getDescription() {
return description;
}
}

View File

@@ -0,0 +1,51 @@
package com.github.binarywang.wxpay.bean.profitsharing;
import com.google.gson.Gson;
import java.io.Serializable;
import java.util.ArrayList;
/**
* @author Wang GuangXin 2019/10/22 11:01
* @version 1.0
*/
public class ReceiverList implements Serializable {
private static final long serialVersionUID = -1316860887694489921L;
ArrayList list;
private ReceiverList() {
}
/**
* 获取一个实例
* @return
*/
public static ReceiverList getInstance() {
ReceiverList receiverList = new ReceiverList();
receiverList.list = new ArrayList();
return receiverList;
}
/**
* 添加一个分账条目
* 注意微信上限为50个
* @param receiver
* @return
*/
public ReceiverList add(Receiver receiver) {
this.list.add(receiver);
return this;
}
/**
* 转为JSON格式
* @return
*/
public String toJSONString() {
Gson gson = new Gson();
return gson.toJson(this.list);
}
}