Jelajahi Sumber

Merge branch 'test-cyr' of sxzgd/java-insagent-pc into test

caiyaru 2 tahun lalu
induk
melakukan
9425af6215

+ 2 - 0
src/main/java/com/ydtech/config/properties/UnionPayApiConfigurationProperties.java

@@ -21,6 +21,8 @@ public class UnionPayApiConfigurationProperties {
 
     private String accessTokenUrl;
 
+    private String twoFactorVerifyUrl;
+
     private String threeFactorVerifyUrl;
 
     private String bankCardVerifyUrl;

+ 30 - 3
src/main/java/com/ydtech/modules/admin/components/UnionPayRequestApiComponent.java

@@ -62,6 +62,32 @@ public class UnionPayRequestApiComponent {
 
     /**
      * 运营商二要素验证接口
+     * @param request
+     */
+    public UnionPayResponse twoFactorVerifyRequest(UnionPayRequest request) {
+        String url = unionPayApiConfigurationProperties.getTwoFactorVerifyUrl();
+        JSONObject params=new JSONObject();
+        if (StringUtils.isBlank(request.getPhoneNo())) {
+            throw new InvalidParameterException("手机号不允许为空!");
+        }
+        params.put("phoneNo", request.getPhoneNo());
+
+        //01:验证姓名+手机号,此时用户姓名必输 02:身份证+手机号,此时证件类型、证件
+        if (StringUtils.isNotBlank(request.getCertNo())) {
+            params.put("verifyType", "02");
+            params.put("certType", "01");//证件类型 01:身份证
+            params.put("certNo", request.getCertNo());
+        } else if (StringUtils.isNotBlank(request.getName())) {
+            params.put("verifyType", "01");
+            params.put("name", request.getName());
+        } else {
+            throw new InvalidParameterException("身份证、用户姓名至少传值一个!");
+        }
+        return commonRequest(url, params);
+    }
+
+    /**
+     * 运营商三要素验证接口
      *
      * @param request
      */
@@ -259,10 +285,11 @@ public class UnionPayRequestApiComponent {
                 String token = resp.getString("accessToken");
                 int expiresIn = resp.getIntValue("expiresIn"); //失效时间
                 Map<String, String> map = new HashMap<>();
-                map.put(UNION_PAY_ACCESS_TOKEN_KEY, "OPEN-ACCESS-TOKEN AccessToken=" + token + ", AppId=" + appId );
+                String tokenValue = "OPEN-ACCESS-TOKEN AccessToken=" + token + ", AppId=" + appId;
+                map.put(UNION_PAY_ACCESS_TOKEN_KEY, tokenValue );
                 redisTemplate.opsForHash().putAll(UNION_PAY_MAP, map);
-                redisTemplate.expire(UNION_PAY_ACCESS_TOKEN_KEY, expiresIn - 30, TimeUnit.SECONDS);
-                return token;
+                redisTemplate.expire(UNION_PAY_MAP, expiresIn - 30, TimeUnit.SECONDS);
+                return tokenValue;
             } else {
                 throw new SystemException("获取银联Token异常[" + resp.getString("errCode") + ":" +
                         resp.getString("errInfo") + "]");

+ 1 - 0
src/main/resources/application-pre.yml

@@ -26,6 +26,7 @@ unionPay:
     appId: 10037e6f8e41423b01912b657e5c116c
     appKey: 1110043747cb40f4911096480ea93f3e
     accessTokenUrl: https://api-mop.chinaums.com/v2/token/access
+    twoFactorVerifyUrl: https://api-mop.chinaums.com/v1/datacenter/smartverification/encrypted/mobile/2factor/verify
     threeFactorVerifyUrl: https://api-mop.chinaums.com/v1/datacenter/smartverification/encrypted/mobile/3factor/verify
     bankCardVerifyUrl: https://api-mop.chinaums.com/v1/datacenter/smartverification/encrypted/bankcard/verify
     publicKey: 0414bb7e9c3914bb65b85079b1dc6e1ca2a0ee04dd9bb55b2f8d31704a6dec0cca695739e128f9c931330e1c0f493be4d56244236434c9d344c4716ba64a4470ba

+ 1 - 0
src/main/resources/application-prod.yml

@@ -26,6 +26,7 @@ unionPay:
     appId: 10037e6f8e41423b01912b657e5c116c
     appKey: 1110043747cb40f4911096480ea93f3e
     accessTokenUrl: https://api-mop.chinaums.com/v2/token/access
+    twoFactorVerifyUrl: https://api-mop.chinaums.com/v1/datacenter/smartverification/encrypted/mobile/2factor/verify
     threeFactorVerifyUrl: https://api-mop.chinaums.com/v1/datacenter/smartverification/encrypted/mobile/3factor/verify
     bankCardVerifyUrl: https://api-mop.chinaums.com/v1/datacenter/smartverification/encrypted/bankcard/verify
     publicKey: 0414bb7e9c3914bb65b85079b1dc6e1ca2a0ee04dd9bb55b2f8d31704a6dec0cca695739e128f9c931330e1c0f493be4d56244236434c9d344c4716ba64a4470ba

+ 1 - 0
src/main/resources/application-test.yml

@@ -28,6 +28,7 @@ unionPay:
     appId: 10037e6f8e41423b01912b657e5c116c
     appKey: 1110043747cb40f4911096480ea93f3e
     accessTokenUrl: https://test-api-open.chinaums.com/v2/token/access
+    twoFactorVerifyUrl: https://test-api-open.chinaums.com/v1/datacenter/smartverification/encrypted/mobile/2factor/verify
     threeFactorVerifyUrl: https://test-api-open.chinaums.com/v1/datacenter/smartverification/encrypted/mobile/3factor/verify
     bankCardVerifyUrl: https://test-api-open.chinaums.com/v1/datacenter/smartverification/encrypted/bankcard/verify
     publicKey: 0414bb7e9c3914bb65b85079b1dc6e1ca2a0ee04dd9bb55b2f8d31704a6dec0cca695739e128f9c931330e1c0f493be4d56244236434c9d344c4716ba64a4470ba