mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
🎨 #3070【微信支付】优化服务商模式下下单接口,去掉部分重复代码
This commit is contained in:
@@ -250,6 +250,34 @@ public class CombineNotifyResult implements Serializable {
|
||||
*/
|
||||
@SerializedName(value = "out_trade_no")
|
||||
private String outTradeNo;
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:子商户应用ID
|
||||
* 变量名:sub_appid
|
||||
* 是否必填:是
|
||||
* 类型:string[1,32]
|
||||
* 描述:
|
||||
* 子商户申请的应用ID,全局唯一。请求基础下单接口时请注意APPID的应用属性,例如公众号场景下,
|
||||
* 需使用应用属性为公众号的APPID 若sub_openid有传的情况下,
|
||||
* sub_appid必填,且sub_appid需与sub_openid对应
|
||||
* 示例值:wxd678efh567hg6999
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "sub_appid")
|
||||
private String subAppid;
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:二级商户号
|
||||
* 变量名:sub_mchid
|
||||
* 是否必填:是
|
||||
* 类型:string[1,32]
|
||||
* 描述:
|
||||
* 二级商户商户号,由微信支付生成并下发。服务商子商户的商户号,被合单方。直连商户不用传二级商户号。
|
||||
* 示例值:1900000109
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "sub_mchid")
|
||||
private String subMchid;
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:订单金额
|
||||
|
||||
@@ -240,6 +240,32 @@ public class CombineTransactionsRequest implements Serializable {
|
||||
*/
|
||||
@SerializedName(value = "out_trade_no")
|
||||
private String outTradeNo;
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:订单优惠标记
|
||||
* 变量名:goods_tag
|
||||
* 是否必填:是
|
||||
* 类型:string[1,32]
|
||||
* 描述:
|
||||
* 订单优惠标记,使用代金券或立减优惠功能时需要的参数,说明详见代金券或立减优惠
|
||||
* 示例值:WXG
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "goods_tag")
|
||||
private String goodsTag;
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:二级商户号
|
||||
* 变量名:sub_mchid
|
||||
* 是否必填:是
|
||||
* 类型:string[1,32]
|
||||
* 描述:
|
||||
* 二级商户商户号,由微信支付生成并下发。服务商子商户的商户号,被合单方。直连商户不用传二级商户号。
|
||||
* 示例值:1900000109
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "sub_mchid")
|
||||
private String subMchid;
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:商品描述
|
||||
@@ -264,6 +290,21 @@ public class CombineTransactionsRequest implements Serializable {
|
||||
*/
|
||||
@SerializedName(value = "settle_info")
|
||||
private SettleInfo settleInfo;
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:子商户应用ID
|
||||
* 变量名:sub_appid
|
||||
* 是否必填:是
|
||||
* 类型:string[1,32]
|
||||
* 描述:
|
||||
* 子商户申请的应用ID,全局唯一。请求基础下单接口时请注意APPID的应用属性,例如公众号场景下,
|
||||
* 需使用应用属性为公众号的APPID 若sub_openid有传的情况下,
|
||||
* sub_appid必填,且sub_appid需与sub_openid对应
|
||||
* 示例值:wxd678efh567hg6999
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "sub_appid")
|
||||
private String subAppid;
|
||||
}
|
||||
|
||||
@Data
|
||||
@@ -283,6 +324,21 @@ public class CombineTransactionsRequest implements Serializable {
|
||||
*/
|
||||
@SerializedName(value = "openid")
|
||||
private String openid;
|
||||
/**
|
||||
* <pre>
|
||||
* 字段名:子用户标识
|
||||
* 变量名:sub_openid
|
||||
* 是否必填:是
|
||||
* 类型:string[1,128]
|
||||
* 描述:
|
||||
* 服务商模式下,使用某个子商户的Appid获取的对应用户Openid,
|
||||
* 是用户在该子商户Appid下的唯一标识。openid和sub_openid可以选传其中之一,
|
||||
* 如果选择传sub_openid,则必须传sub_appid。
|
||||
* 示例值:oUpF8uMuAJO_M2pxb1Q9zNjWeS6o
|
||||
* </pre>
|
||||
*/
|
||||
@SerializedName(value = "sub_openid")
|
||||
private String subOpenid;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.github.binarywang.wxpay.bean.result;
|
||||
|
||||
import com.github.binarywang.wxpay.bean.result.enums.PartnerTradeTypeEnum;
|
||||
import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum;
|
||||
import com.github.binarywang.wxpay.v3.util.SignUtils;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
@@ -133,32 +132,4 @@ public class WxPayUnifiedOrderV3Result implements Serializable {
|
||||
throw new WxRuntimeException("不支持的支付类型");
|
||||
}
|
||||
}
|
||||
|
||||
public <T> T getPartnerPayInfo(PartnerTradeTypeEnum tradeType, String appId, String mchId, PrivateKey privateKey) {
|
||||
String timestamp = String.valueOf(System.currentTimeMillis() / 1000);
|
||||
String nonceStr = SignUtils.genRandomStr();
|
||||
switch (tradeType) {
|
||||
case JSAPI:
|
||||
JsapiResult jsapiResult = new JsapiResult();
|
||||
jsapiResult.setAppId(appId).setTimeStamp(timestamp)
|
||||
.setPackageValue("prepay_id=" + this.prepayId).setNonceStr(nonceStr)
|
||||
//签名类型,默认为RSA,仅支持RSA。
|
||||
.setSignType("RSA").setPaySign(SignUtils.sign(jsapiResult.getSignStr(), privateKey));
|
||||
return (T) jsapiResult;
|
||||
case H5:
|
||||
return (T) this.h5Url;
|
||||
case APP:
|
||||
AppResult appResult = new AppResult();
|
||||
appResult.setAppid(appId).setPrepayId(this.prepayId).setPartnerId(mchId)
|
||||
.setNoncestr(nonceStr).setTimestamp(timestamp)
|
||||
//暂填写固定值Sign=WXPay
|
||||
.setPackageValue("Sign=WXPay")
|
||||
.setSign(SignUtils.sign(appResult.getSignStr(), privateKey));
|
||||
return (T) appResult;
|
||||
case NATIVE:
|
||||
return (T) this.codeUrl;
|
||||
default:
|
||||
throw new WxRuntimeException("不支持的支付类型");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.github.binarywang.wxpay.bean.result.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 支付方式
|
||||
*
|
||||
* @author thinsstar
|
||||
*/
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum PartnerTradeTypeEnum {
|
||||
/**
|
||||
* APP
|
||||
*/
|
||||
APP("/v3/pay/partner/transactions/app", "/v3/combine-transactions/app", TradeTypeEnum.APP),
|
||||
/**
|
||||
* JSAPI 或 小程序
|
||||
*/
|
||||
JSAPI("/v3/pay/partner/transactions/jsapi", "/v3/combine-transactions/jsapi", TradeTypeEnum.JSAPI),
|
||||
/**
|
||||
* NATIVE
|
||||
*/
|
||||
NATIVE("/v3/pay/partner/transactions/native", "/v3/combine-transactions/native", TradeTypeEnum.NATIVE),
|
||||
/**
|
||||
* H5
|
||||
*/
|
||||
H5("/v3/pay/partner/transactions/h5", "/v3/combine-transactions/h5", TradeTypeEnum.H5);
|
||||
|
||||
/**
|
||||
* 单独下单url
|
||||
*/
|
||||
private final String partnerUrl;
|
||||
|
||||
/**
|
||||
* 合并下单url
|
||||
*/
|
||||
private final String combineUrl;
|
||||
|
||||
/**
|
||||
* 直连支付枚举
|
||||
*/
|
||||
private final TradeTypeEnum directConnTrade;
|
||||
}
|
||||
@@ -14,19 +14,19 @@ public enum TradeTypeEnum {
|
||||
/**
|
||||
* APP
|
||||
*/
|
||||
APP("/v3/pay/transactions/app", "/v3/combine-transactions/app"),
|
||||
APP("/v3/pay/transactions/app", "/v3/combine-transactions/app", "/v3/pay/partner/transactions/app"),
|
||||
/**
|
||||
* JSAPI 或 小程序
|
||||
*/
|
||||
JSAPI("/v3/pay/transactions/jsapi", "/v3/combine-transactions/jsapi"),
|
||||
JSAPI("/v3/pay/transactions/jsapi", "/v3/combine-transactions/jsapi", "/v3/pay/partner/transactions/jsapi"),
|
||||
/**
|
||||
* NATIVE
|
||||
*/
|
||||
NATIVE("/v3/pay/transactions/native", "/v3/combine-transactions/native"),
|
||||
NATIVE("/v3/pay/transactions/native", "/v3/combine-transactions/native", "/v3/pay/partner/transactions/native"),
|
||||
/**
|
||||
* H5
|
||||
*/
|
||||
H5("/v3/pay/transactions/h5", "/v3/combine-transactions/h5");
|
||||
H5("/v3/pay/transactions/h5", "/v3/combine-transactions/h5", "/v3/pay/partner/transactions/native");
|
||||
|
||||
/**
|
||||
* 单独下单url
|
||||
@@ -37,4 +37,9 @@ public enum TradeTypeEnum {
|
||||
* 合并下单url
|
||||
*/
|
||||
private final String combineUrl;
|
||||
|
||||
/**
|
||||
* 服务商下单
|
||||
*/
|
||||
private final String basePartnerUrl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user