package com.seeyon.apps.esign.node;

import com.seeyon.apps.common.workflow.node.ACommonSuperNode;
import com.seeyon.apps.esign.po.auth.AuthPsnInfo;
import com.seeyon.apps.esign.po.auth.PsnAuthConfig;
import com.seeyon.apps.ext.workflow.vo.FormDataVo;
import com.seeyon.apps.ext.workflow.vo.SuperNodeContext;
import com.seeyon.cap4.form.bean.FormDataMasterBean;

import java.util.HashMap;
import java.util.Map;

public class EsignPersonAuthNode extends ACommonSuperNode {
    @Override
    public String getPluginId() {
        return "";
    }

    @Override
    public String getFormParse() {
        return "";
    }

    @Override
    public SuperNodeContext proceed(String s, FormDataVo formDataVo, FormDataMasterBean formDataMasterBean) throws Exception {
        Map<String,Object> authParams = new HashMap<>();
        PsnAuthConfig psnAuthConfig = buildPsnAuthConfig(formDataVo,formDataMasterBean);
        String notifyUrl= "";
        authParams.put("psnAuthConfig",psnAuthConfig);
        authParams.put("notifyUrl",notifyUrl);

        return null;
    }

    private PsnAuthConfig buildPsnAuthConfig(FormDataVo formDataVo, FormDataMasterBean formDataMasterBean) throws Exception {
        PsnAuthConfig psnAuthConfig = new PsnAuthConfig();
        psnAuthConfig.setPsnAccount(formDataVo.getFieldData("客户联系电话").getStringValue());
        AuthPsnInfo authPsnInfo = new AuthPsnInfo();
        authPsnInfo.setPsnName(formDataVo.getFieldData("客户联系人姓名").getStringValue());
        authPsnInfo.setPsnMobile(formDataVo.getFieldData("客户联系电话").getStringValue());
        authPsnInfo.setPsnIDCardType("CRED_PSN_CH_IDCARD");
        authPsnInfo.setPsnIDCardNum(formDataVo.getFieldData("客户身份证号").getStringValue());
        authPsnInfo.setPsnIdentityVerify(true);
        return psnAuthConfig;
    }

    @Override
    public String getNodeId() {
        return "";
    }

    @Override
    public String getNodeName() {
        return "";
    }
}
