|
@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
+import java.util.Collections;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
@@ -41,18 +42,14 @@ public class WxApiService {
|
|
|
* @param type : 应用类型
|
|
|
* @return {@link String}
|
|
|
*/
|
|
|
- public String getOpenIdByType(String code, String appId, String secret, Integer type) {
|
|
|
- Map<String, String> resultMap = null;
|
|
|
+ public Map<String, String> getOpenIdByType(String code, String appId, String secret, Integer type) {
|
|
|
if (Objects.equals(type, PayApplicationTypeEnum.WX_MINI_APP.getType())) {
|
|
|
- resultMap = this.getAppletOpenId(code, appId, secret);
|
|
|
+ return this.getAppletOpenId(code, appId, secret);
|
|
|
}
|
|
|
if (Objects.equals(type, PayApplicationTypeEnum.WX_MP.getType())) {
|
|
|
- resultMap = this.getMpOpenId(code, appId, secret);
|
|
|
+ return this.getMpOpenId(code, appId, secret);
|
|
|
}
|
|
|
- if (resultMap != null && resultMap.containsKey("openid")) {
|
|
|
- return resultMap.get("openid");
|
|
|
- }
|
|
|
- return null;
|
|
|
+ return Collections.emptyMap();
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -63,7 +60,7 @@ public class WxApiService {
|
|
|
* @param secret : 应用密钥
|
|
|
* @return {@link String}
|
|
|
*/
|
|
|
- public Map<String, String> getAppletOpenId(String code, String appId, String secret) {
|
|
|
+ private Map<String, String> getAppletOpenId(String code, String appId, String secret) {
|
|
|
// 请求微信服务器,使用code获取openid
|
|
|
Map<String, String> paramMap = new HashMap<>(4);
|
|
|
paramMap.put("appid", appId);
|