Ver código fonte

银行实名认证三要素

Evan 2 anos atrás
pai
commit
0e868b175e

+ 82 - 41
mp-admin/src/main/java/com/qs/mp/web/controller/api/channel/ChannelWithdrawController.java

@@ -130,64 +130,105 @@ public class ChannelWithdrawController extends BaseApiController {
     }
 
 
-    Map<String, String> mapData = new HashMap<>();
-    mapData.put("partner_id", partnerId);
-    mapData.put("method", YsPayMethodConstants.BANK_CARD_AUTH_METHOD);
-    mapData.put("timestamp", DateUtil.getDateNow());
-    mapData.put("sign_type", "RSA");
-    mapData.put("charset", "utf-8");
-    mapData.put("version", "3.0");
-
-    JSONObject json = new JSONObject();
+    OnlineReqDataVo req = new OnlineReqDataVo();
+    //商户在银盛支付平台开设的用户号[商户号],接入时需要替换成自己的
+    req.setPartnerId(partnerId);
+    req.setReqUrl(YsServerApiConstants.OPEN_API);
+    req.setPrivateKeyFilePath(privateKeyPath);
+    req.setPrivateKeyPassword(privateKeyPass);
+    req.setYsPublicKeyFilePath(publicKeyPath);
+    //银行实名认证三要素下单业务参数
+    Map<String, Object> bizContent = new HashMap<>();
     String tradeNo = DateUtil.getDateNowYmd() + DateUtil.getRandom(14);
-    json.put("out_trade_no", tradeNo);
-    json.put("shopdate", DateUtil.getDateNowYmd());
-    json.put("bank_account_name", param.getUserName());
-    json.put("bank_account_no", param.getCardNo());
-    json.put("id_card", param.getIdCard());
-    mapData.put("biz_content", json.toString());
-    //参数签名
-    try {
-      String sign = YsOnlineSignUtils.sign(mapData, privateKeyPass, privateKeyPath);
-      mapData.put("sign", sign);
-      logger.info("认证信息签名成功,sign = " + sign);
-    } catch (Exception e) {
-      System.err.println("签名异常" + e);
-    }
-
+    //商户生成的订单号,生成规则前8位必须为交易日期,如20180525,范围跨度支持包含当天在内的前后一天
+    bizContent.put("out_trade_no", tradeNo);
+    //商户日期(该参数做交易与查询时需要一致)该日期需在当日的前后一天时间范围之内
+    bizContent.put("shopdate", DateUtil.getDateNowYmd());
+    //实名认证姓名--请填写真实信息
+    bizContent.put("bank_account_name", param.getUserName());
+    //银行帐号,支持对公对私
+    bizContent.put("bank_account_no", param.getCardNo());
+    //证件号码,目前只支持身份证
+    bizContent.put("id_card", param.getIdCard());
+    req.setParamData(bizContent);
     String result = null;
-    try {
-      logger.info("银行实名认证三要素调用sdk接口addScanMerc请求入参为:"+ JSONObject.toJSONString(mapData));
-      result = OkHttpUtil.post("https://openapi.ysepay.com/gateway.do", mapData);
-    } catch (Exception e) {
+    try{
+      logger.info("银行实名认证三要素调用sdk接口addScanMerc请求入参为:"+ JSONObject.toJSONString(req));
+      //根据返回结果处理自己的业务逻辑,result内容详见接口文档
+      result = BankAuthorityApi.sendBankAuthThreePrecise(req);
+    }catch (Exception e){
       logger.info("银行实名认证三要素失败:"+ e.getMessage());
-
     }
+    logger.info("银行实名认证三要素result =" + result);
+
+
+
+//    Map<String, String> mapData = new HashMap<>();
+//    mapData.put("partner_id", partnerId);
+//    mapData.put("method", YsPayMethodConstants.BANK_CARD_AUTH_METHOD);
+//    mapData.put("timestamp", DateUtil.getDateNow());
+//    mapData.put("sign_type", "RSA");
+//    mapData.put("charset", "utf-8");
+//    mapData.put("version", "3.0");
+//
+//    JSONObject json = new JSONObject();
+//    String tradeNo = DateUtil.getDateNowYmd() + DateUtil.getRandom(14);
+//    json.put("out_trade_no", tradeNo);
+//    json.put("shopdate", DateUtil.getDateNowYmd());
+//    json.put("bank_account_name", param.getUserName());
+//    json.put("bank_account_no", param.getCardNo());
+//    json.put("id_card", param.getIdCard());
+//    mapData.put("biz_content", json.toString());
+//    //参数签名
+//    try {
+//      String sign = YsOnlineSignUtils.sign(mapData, privateKeyPass, privateKeyPath);
+//      mapData.put("sign", sign);
+//      logger.info("认证信息签名成功,sign = " + sign);
+//    } catch (Exception e) {
+//      System.err.println("签名异常" + e);
+//    }
+//
+//    String result = null;
+//    try {
+//      logger.info("银行实名认证三要素调用sdk接口addScanMerc请求入参为:"+ JSONObject.toJSONString(mapData));
+//      result = OkHttpUtil.post("https://openapi.ysepay.com/gateway.do", mapData);
+//    } catch (Exception e) {
+//      logger.info("银行实名认证三要素失败:"+ e.getMessage());
+//
+//    }
+
+    // 解析结果
+//    JSONObject jsonObject = JSON.parseObject(result, Feature.OrderedField);
+//    // 加签内容
+//    String content = JSONObject.toJSONString(
+//        jsonObject.get("ysepay_authenticate_three_key_element_precise_response"),
+//        SerializerFeature.WriteMapNullValue);
+//    JSONObject contentJsonObject = JSON.parseObject(content);
+//
+//    // 校验结果
+//    String orderStatus = (String) contentJsonObject.get("order_status");
+//    if (StringUtils.isBlank(orderStatus) || !"SUCCESS".equals(orderStatus)) {
+//      return AjaxResult.error("绑卡认证失败,请核实信息正确性");
+//    }
+
 
     // 保存银行认证的请求记录
     YsCallLog ysCallLog = new YsCallLog();
     ysCallLog.setBizId(tradeNo);
     ysCallLog.setBizType(YsCallBizTypeEnum.BANK_CARD_AUTH);
     ysCallLog.setInterfaceId(YsPayMethodConstants.BANK_CARD_AUTH_METHOD);
-    ysCallLog.setReqJson(JSONObject.toJSONString(mapData));
+    ysCallLog.setReqJson(JSONObject.toJSONString(bizContent));
     ysCallLog.setResJson(result);
     ysCallLogService.save(ysCallLog);
 
-    if (result == null) {
-      logger.error("银行实名认证三要素失败,res为空,req =" + JSONObject.toJSONString(mapData));
+    if (StringUtils.isBlank(result)) {
+      logger.error("银行实名认证三要素失败,res为空,req =" + JSONObject.toJSONString(bizContent));
       return AjaxResult.error("认证失败");
     }
 
-    // 解析结果
-    JSONObject jsonObject = JSON.parseObject(result, Feature.OrderedField);
-    // 加签内容
-    String content = JSONObject.toJSONString(
-        jsonObject.get("ysepay_authenticate_three_key_element_precise_response"),
-        SerializerFeature.WriteMapNullValue);
-    JSONObject contentJsonObject = JSON.parseObject(content);
-
     // 校验结果
-    String orderStatus = (String) contentJsonObject.get("order_status");
+    JSONObject response = JSONObject.parseObject(result);
+    String orderStatus = (String) response.get("order_status");
     if (StringUtils.isBlank(orderStatus) || !"SUCCESS".equals(orderStatus)) {
       return AjaxResult.error("绑卡认证失败,请核实信息正确性");
     }

+ 1 - 1
mp-admin/src/main/resources/application-dev.yml

@@ -145,7 +145,7 @@ bind:
 # 银盛支付配置
 ys-pay:
     private-key-path: /Users/cup/WORK/data/ysPay/ysPayPre.pfx
-    public-key-path: /Users/cup/WORK/data/ysPay/ysPayPub.cer
+    public-key-path: /Users/cup/WORK/data/ysPay/businessgate.cer
     # 支付完后跳转
     return-url: https://test-mp-h5.quanshu123.com
     # 支付回调地址

+ 1 - 1
mp-admin/src/main/resources/application-test.yml

@@ -150,7 +150,7 @@ bind:
 # 银盛支付配置
 ys-pay:
   private-key-path: /home/quanshu/mp-server/data/ysPayPre.pfx
-  public-key-path: /home/quanshu/mp-server/cert/ysPayPub.cer
+  public-key-path: /home/quanshu/mp-server/cert/businessgate.cer
   # 支付完后跳转
   return-url: https://test-mp-h5.quanshu123.com
   # 回调地址

+ 1 - 1
mp-common/src/main/java/com/qs/mp/common/enums/YsCallBizTypeEnum.java

@@ -18,7 +18,7 @@ public enum YsCallBizTypeEnum implements IEnum<Integer> {
     DIVISION(2,"分账"),
 
 
-    BANK_CARD_AUTH(3, "银行卡身份认证"),
+    BANK_CARD_AUTH(3, "银行实名认证三要素"),
 
     ;