package com.sifang.modules.customer.dao;

import com.sifang.modules.customer.entity.CustomerEntry;
import com.sifang.modules.customer.entity.CustomerEntryOrgFiles;
import com.sifang.modules.sys.common.persistence.BaseDao;
import com.sifang.modules.sys.common.persistence.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.Date;

@Repository
public class CustomerEntryOrgFilesDao extends BaseDao<CustomerEntryOrgFiles> {

    @Autowired
    private CustomerEntryDao customerEntryDao;

    public void createOne(String entryId, String traderId, String regnoUrl,String creditCertificate) {
        CustomerEntryOrgFiles orgFiles = new CustomerEntryOrgFiles();
        orgFiles.setEntryId(entryId);
        orgFiles.setTraderId(traderId);
        orgFiles.setRegnoUrl(regnoUrl);
        orgFiles.setCreditCertificate(creditCertificate);
        CustomerEntry customerEntry = customerEntryDao.get(entryId);
        //广发直接审核通过
        if ("03".equals(customerEntry.getPartnerId())){
            orgFiles.setStatus("3");
        }else {
            orgFiles.setStatus("0");
        }
        orgFiles.setCreateTime(new Date());
        save(orgFiles);
    }

    public CustomerEntryOrgFiles findOneByEntryId(String entryId) {
        return getByHql("from CustomerEntryOrgFiles where entryId = :p1", new Parameter(entryId));
    }
}
