From 4bda30e246d2f87d24e7a70a754643ad8755f7cc Mon Sep 17 00:00:00 2001 From: snake Date: Mon, 10 May 2021 21:26:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=AF=E4=BB=98=EF=BC=883=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../channel/wxpay/WxpayAppClientParam.java | 85 +++++++++++++++++++ .../channel/wxpay/WxpayChannelHandler.java | 9 +- 2 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 star-tiger-framework-pay/star-tiger-framework-pay-core/src/main/java/com/snake19870227/stiger/pay/channel/wxpay/WxpayAppClientParam.java diff --git a/star-tiger-framework-pay/star-tiger-framework-pay-core/src/main/java/com/snake19870227/stiger/pay/channel/wxpay/WxpayAppClientParam.java b/star-tiger-framework-pay/star-tiger-framework-pay-core/src/main/java/com/snake19870227/stiger/pay/channel/wxpay/WxpayAppClientParam.java new file mode 100644 index 0000000..c6be9c2 --- /dev/null +++ b/star-tiger-framework-pay/star-tiger-framework-pay-core/src/main/java/com/snake19870227/stiger/pay/channel/wxpay/WxpayAppClientParam.java @@ -0,0 +1,85 @@ +package com.snake19870227.stiger.pay.channel.wxpay; + +import io.swagger.annotations.ApiModelProperty; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.snake19870227.stiger.pay.channel.ChannelClientParam; + +/** + * @author BuHuaYang + * 2021/4/13 + */ +public class WxpayAppClientParam implements ChannelClientParam { + + @ApiModelProperty("签名") + private String sign; + @ApiModelProperty("prepayId") + private String prepayId; + @ApiModelProperty("partnerId") + private String partnerId; + @ApiModelProperty("appId") + private String appId; + @ApiModelProperty("格式:Sign=WXPay") + @JsonProperty("package") + private String packageValue; + @ApiModelProperty("时间戳") + private String timeStamp; + @ApiModelProperty("随机字符串") + private String nonceStr; + + public String getSign() { + return sign; + } + + public void setSign(String sign) { + this.sign = sign; + } + + public String getPrepayId() { + return prepayId; + } + + public void setPrepayId(String prepayId) { + this.prepayId = prepayId; + } + + public String getPartnerId() { + return partnerId; + } + + public void setPartnerId(String partnerId) { + this.partnerId = partnerId; + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getPackageValue() { + return packageValue; + } + + public void setPackageValue(String packageValue) { + this.packageValue = packageValue; + } + + public String getTimeStamp() { + return timeStamp; + } + + public void setTimeStamp(String timeStamp) { + this.timeStamp = timeStamp; + } + + public String getNonceStr() { + return nonceStr; + } + + public void setNonceStr(String nonceStr) { + this.nonceStr = nonceStr; + } +} diff --git a/star-tiger-framework-pay/star-tiger-framework-pay-core/src/main/java/com/snake19870227/stiger/pay/channel/wxpay/WxpayChannelHandler.java b/star-tiger-framework-pay/star-tiger-framework-pay-core/src/main/java/com/snake19870227/stiger/pay/channel/wxpay/WxpayChannelHandler.java index 7ed7088..0acb243 100644 --- a/star-tiger-framework-pay/star-tiger-framework-pay-core/src/main/java/com/snake19870227/stiger/pay/channel/wxpay/WxpayChannelHandler.java +++ b/star-tiger-framework-pay/star-tiger-framework-pay-core/src/main/java/com/snake19870227/stiger/pay/channel/wxpay/WxpayChannelHandler.java @@ -87,14 +87,17 @@ public TradeInfo create(String bizType, String bizFlow, PaymentMethodEnum pay String createDateTime = LocalDateTimeUtil.format(now, "yyyyMMddHHmmss"); String expireDateTime = LocalDateTimeUtil.format(now.plusMinutes(15), "yyyyMMddHHmmss"); - WxPayUnifiedOrderRequest request = WxPayUnifiedOrderRequest.newBuilder().body(bizType) + WxPayUnifiedOrderRequest.WxPayUnifiedOrderRequestBuilder requestBuilder = WxPayUnifiedOrderRequest.newBuilder().body(bizType) .outTradeNo(outTradeNo) .openid(openid) .totalFee(BaseWxPayRequest.yuanToFen(tradePrice.toString())) .tradeType(paymentMethodEnum.getId()) .timeStart(createDateTime).timeExpire(expireDateTime) - .spbillCreateIp(wxpayProperties.getSpbillCreateIp()) - .build(); + .spbillCreateIp(wxpayProperties.getSpbillCreateIp()); + if (StrUtil.isNotBlank(openid)) { + requestBuilder.openid(openid); + } + WxPayUnifiedOrderRequest request = requestBuilder.build(); ChannelClientParam clientParam = handleResponse(wxPayService, request); PayTrade payTrade = new PayTrade();