From 4f1c66efceeff6be1d3f174c841ed77c69bc7079 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Fri, 13 Oct 2017 11:52:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BB=9F=E4=B8=80=E4=B8=8B?= =?UTF-8?q?=E5=8D=95=E6=97=B6=E5=8F=82=E6=95=B0=E6=A0=A1=E9=AA=8C=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../bean/request/WxPayUnifiedOrderRequest.java | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 53a49b98..c5e57b88 100644 --- a/pom.xml +++ b/pom.xml @@ -152,7 +152,7 @@ org.apache.commons commons-lang3 - 3.6 + 3.5 org.slf4j diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java index ecd73dd5..f45a2d0c 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/request/WxPayUnifiedOrderRequest.java @@ -333,12 +333,18 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { @Override protected void checkConstraints() throws WxPayException { - if (TradeType.JSAPI.equals(this.getTradeType()) && this.getOpenid() == null && this.getSubOpenid() == null) { - throw new WxPayException("当 trade_type是'JSAPI'时未指定openid或sub_openid"); + if (TradeType.JSAPI.equals(this.getTradeType())) { + if (StringUtils.isBlank(this.getSubAppId()) && StringUtils.isBlank(this.getOpenid())) { + throw new WxPayException("当trade_type是'JSAPI'时,需指定非空的openid值"); + } + + if (StringUtils.isNotBlank(this.getSubAppId()) && StringUtils.isBlank(this.getSubOpenid())) { + throw new WxPayException("在服务商模式下,当trade_type是'JSAPI'时,需指定非空的sub_openid值"); + } } - if (TradeType.NATIVE.equals(this.getTradeType()) && this.getProductId() == null) { - throw new WxPayException("当 trade_type是'NATIVE'时未指定product_id"); + if (TradeType.NATIVE.equals(this.getTradeType()) && StringUtils.isBlank(this.getProductId())) { + throw new WxPayException("当trade_type是'NATIVE'时,需指定非空的product_id值"); } }