mirror of
https://github.com/dromara/payment-spring-boot.git
synced 2026-03-13 21:33:41 +08:00
优化逻辑
This commit is contained in:
@@ -270,8 +270,10 @@ public class WechatMarketingApi extends AbstractApi {
|
||||
body.add("file", file.getResource());
|
||||
// 签名
|
||||
String metaStr = this.getMapper().writeValueAsString(meta);
|
||||
return RequestEntity.post(uri).header("Content-Type", MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.header("Meta-Info",metaStr).body(body);
|
||||
return RequestEntity.post(uri)
|
||||
.header("Content-Type", MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
.header("Meta-Info",metaStr)
|
||||
.body(body);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -20,8 +20,8 @@ public class WechatMetaBean implements InitializingBean {
|
||||
|
||||
@Override
|
||||
public void afterPropertiesSet() throws Exception {
|
||||
Assert.notNull(wechatPayProperties, "wechatPayProperties must not be null");
|
||||
Assert.notNull(keyPair, "wechat pay p12 certificate has not loaded");
|
||||
Assert.hasText(serialNumber, "wechat pay p12 certificate SerialNumber must not null");
|
||||
Assert.notNull(wechatPayProperties, "wechatPayProperties is required");
|
||||
Assert.notNull(keyPair, "wechat pay p12 certificate is required");
|
||||
Assert.hasText(serialNumber, "wechat pay p12 certificate SerialNumber is required");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import org.springframework.web.util.UriComponentsBuilder;
|
||||
import java.net.URI;
|
||||
|
||||
/**
|
||||
* The type Wechat pay v 3 api.
|
||||
* The type Wechat pay api.
|
||||
*
|
||||
* @author Dax
|
||||
* @since 16 :15
|
||||
|
||||
@@ -146,8 +146,6 @@ public class WechatPayClient {
|
||||
if (encodedQuery != null) {
|
||||
canonicalUrl += "?" + encodedQuery;
|
||||
}
|
||||
|
||||
|
||||
// 签名
|
||||
HttpMethod httpMethod = requestEntity.getMethod();
|
||||
Assert.notNull(httpMethod, "httpMethod is required");
|
||||
|
||||
@@ -8,8 +8,11 @@ import org.springframework.http.ResponseEntity;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* The type Wechat response entity.
|
||||
*
|
||||
* @param <T> the type parameter
|
||||
* @author Dax
|
||||
* @since 13:20
|
||||
* @since 13 :20
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@@ -18,6 +21,11 @@ public class WechatResponseEntity<T> {
|
||||
private T body;
|
||||
|
||||
|
||||
/**
|
||||
* Convert {@link ResponseEntity} to {@link WechatResponseEntity}.
|
||||
*
|
||||
* @param responseEntity the response entity
|
||||
*/
|
||||
public void convert(ResponseEntity<T> responseEntity) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("wechat response {}", responseEntity);
|
||||
@@ -31,10 +39,64 @@ public class WechatResponseEntity<T> {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Is 1 xx informational boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean is1xxInformational() {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("wechat httpStatus {}", this.httpStatus);
|
||||
}
|
||||
return HttpStatus.valueOf(this.httpStatus).is1xxInformational();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is 2xx successful boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean is2xxSuccessful() {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("wechat httpStatus {}", this.httpStatus);
|
||||
}
|
||||
return HttpStatus.valueOf(this.httpStatus).is2xxSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is 3xx redirection boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean is3xxRedirection() {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("wechat httpStatus {}", this.httpStatus);
|
||||
}
|
||||
return HttpStatus.valueOf(this.httpStatus).is3xxRedirection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is 4xx client error boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean is4xxClientError() {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("wechat httpStatus {}", this.httpStatus);
|
||||
}
|
||||
return HttpStatus.valueOf(this.httpStatus).is4xxClientError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Is 5xx server error boolean.
|
||||
*
|
||||
* @return the boolean
|
||||
*/
|
||||
public boolean is5xxServerError() {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("wechat httpStatus {}", this.httpStatus);
|
||||
}
|
||||
return HttpStatus.valueOf(this.httpStatus).is5xxServerError();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user