var System = require("../../system");
const querystring = require('querystring');
var settings = require("../../../config/settings");
const logCtl = System.getObject("web.oplogCtl");
const crypto = require('crypto');
const uuidv4 = require('uuid/v4');
const axios = require('axios');


//工商查询操作
class UitlLBWService {
    constructor() {
        this.config = settings.lbwConfig();
    }

    // async personTwo(params, opName) { // 个人二要素验证
    //     var result = {
    //         code: 1,
    //         message: "success",
    //         data: {}
    //     };
    //     var reqUrl = this.eSignBaoBankVerifyUrl + "/infoauth/psn/identity";
    //     var tResult = await this.returnResult(params, reqUrl, opName, "personTwo", result);
    //     if (tResult.errCode != 0) {
    //         result.code = -110;
    //         if (tResult.message && tResult.message.indexOf(":") > 0) {
    //             var tmpListStr = tResult.message.split(':');
    //             result.message = tmpListStr[1] ? tmpListStr[1] : tmpListStr[0];
    //         } else {
    //             result.message = "个人二要素验证失败";
    //         }
    //         return result;
    //     }
    //     if (tResult.errCode == 0 && tResult.data && !tResult.data.pass) {
    //         result.code = -120;
    //         result.message = "姓名或身份证错误";
    //         return result;
    //     }
    //     result.data = tResult.data;
    //     return result;
    // }

    async bankthree(params, opName) { //三要素验证
            // name: account.userName,
            // idno: account.personsSign,
            // cardno: account
        var result = {
            code: 1,
            message: "success",
            data: {}
        };
        let reqUrl = this.config.validate_bank;

        var tResult = await this.returnResult(params, reqUrl, opName, "createAccountId", result);
        if (tResult.errCode != 0) {
            result.code = -110;
            if (tResult.message && tResult.message.indexOf(":") > 0) {
                var tmpListStr = tResult.message.split(':');
                result.message = tmpListStr[1] ? tmpListStr[1] : tmpListStr[0];
            } else {
                result.message = "三要素验证失败，错误信息[" + tResult.message + "]";
            }
            return result;
        }
        if (tResult.errCode == 0 && tResult.data && !tResult.data.pass) {
            result.code = -120;
            result.message = "亲，提供的信息不正确，请验证后再试！";
            return result;
        }
        result.data = tResult.data;
        return result;
    }
    //
    // async bankfour(params, opName) { //四要素验证
    //     var result = {
    //         code: 1,
    //         message: "success",
    //         data: {}
    //     };
    //     var reqUrl = this.eSignBaoBankVerifyUrl + "/infoauth/psn/bankfour";
    //     var tResult = await this.returnResult(params, reqUrl, opName, "createAccountId", result);
    //     if (tResult.errCode != 0) {
    //         result.code = -110;
    //         if (tResult.message && tResult.message.indexOf(":") > 0) {
    //             var tmpListStr = tResult.message.split(':');
    //             result.message = tmpListStr[1] ? tmpListStr[1] : tmpListStr[0];
    //         } else {
    //             result.message = "接口请求错误";
    //         }
    //         return result;
    //     }
    //     if (tResult.errCode == 0 && tResult.data && !tResult.data.pass) {
    //         result.code = -120;
    //         result.message = "亲，提供的信息不正确，请验证后再试！";
    //         return result;
    //     }
    //     result.data = tResult.data;
    //     return result;
    // }

}
module.exports = UitlLBWService;
