mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-10-31 10:38:42 +08:00 
			
		
		
		
	优化统一下单时参数校验逻辑
This commit is contained in:
		
							
								
								
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								pom.xml
									
									
									
									
									
								
							| @ -152,7 +152,7 @@ | |||||||
|       <dependency> |       <dependency> | ||||||
|         <groupId>org.apache.commons</groupId> |         <groupId>org.apache.commons</groupId> | ||||||
|         <artifactId>commons-lang3</artifactId> |         <artifactId>commons-lang3</artifactId> | ||||||
|         <version>3.6</version> |         <version>3.5</version> | ||||||
|       </dependency> |       </dependency> | ||||||
|       <dependency> |       <dependency> | ||||||
|         <groupId>org.slf4j</groupId> |         <groupId>org.slf4j</groupId> | ||||||
|  | |||||||
| @ -333,12 +333,18 @@ public class WxPayUnifiedOrderRequest extends WxPayBaseRequest { | |||||||
|  |  | ||||||
|   @Override |   @Override | ||||||
|   protected void checkConstraints() throws WxPayException { |   protected void checkConstraints() throws WxPayException { | ||||||
|     if (TradeType.JSAPI.equals(this.getTradeType()) && this.getOpenid() == null && this.getSubOpenid() == null) { |     if (TradeType.JSAPI.equals(this.getTradeType())) { | ||||||
|       throw new WxPayException("当 trade_type是'JSAPI'时未指定openid或sub_openid"); |       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) { |     if (TradeType.NATIVE.equals(this.getTradeType()) && StringUtils.isBlank(this.getProductId())) { | ||||||
|       throw new WxPayException("当 trade_type是'NATIVE'时未指定product_id"); |       throw new WxPayException("当trade_type是'NATIVE'时,需指定非空的product_id值"); | ||||||
|     } |     } | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Binary Wang
					Binary Wang