package com.engine.htxc.eseal.counterparty.convert;

import com.engine.htxc.commonutil.db.DbTools;
import com.engine.htxc.eseal.counterparty.vo.Counterparty;
import com.engine.integration.util.StringUtils;
import weaver.general.Util;

import java.util.Map;

/**
 * @author K1810015
 * @version 1.0.0
 * @ClassName CounterpartyDao.java
 * @createTime 2022-08-02 16:23:00
 */
public class CounterpartyDao {
   public static Counterparty getTabletoVo(String dsfbm){
       Counterparty counterparty=new Counterparty();
       if(StringUtils.isBlank(dsfbm)){
           return null;
       }
       String sql=" select t.id,dsflx,dsfmc,frxm,frsfzhm,lxdh,email, " +
               "(select zjhm from uf_dsfgl_dt1 where mainid=t.id and zjlx='103100') as cardno, " +
               "(select zjhm from uf_dsfgl_dt1 where mainid=t.id and zjlx='103200') code " +
               " from uf_dsfgl t where dsfbm= ? ";
       DbTools dbTools=new DbTools();
       Map<String,Object> map= dbTools.getsqltomap(sql,dsfbm);
       if(map==null || map.size()<=0){
           return null;
       }
       String dsflx= Util.null2String(map.get("dsflx"));
       if("0".equals(dsflx)){

           counterparty.setSignatoryType("PERSONAL");
           counterparty.setCodeType("ID");
           counterparty.setCode(Util.null2String(map.get("cardno")));
           counterparty.setName(Util.null2String(map.get("frxm")));
           counterparty.setMail(Util.null2String(map.get("email")));
           counterparty.setMobile(Util.null2String(map.get("lxdh")));
       }else if("1".equals(dsflx)){

           counterparty.setSignatoryType("ENTERPRISE");
           counterparty.setCodeType("USC");
           counterparty.setCode(Util.null2String(map.get("code")));
       }else if("2".equals(dsflx)){

           counterparty.setSignatoryType("ENTERPRISE");
           counterparty.setCodeType("USC");
           counterparty.setCode(Util.null2String(map.get("code")));
       }
       return counterparty;
   }


}
