package com.sifang.modules.sys.service;

import com.sifang.modules.customer.Service.CustomerEntryService;
import com.sifang.modules.customer.dao.CrmCustomerIncomingApplicationDao;
import com.sifang.modules.customer.dao.CrmCustomerIncomingApplicationLeaseItemDao;
import com.sifang.modules.customer.dao.CrmCustomerIncomingApplicationPerInfoDao;
import com.sifang.modules.customer.entity.CrmCustomerIncomingApplication;
import com.sifang.modules.customer.entity.CrmCustomerIncomingApplicationEquipInfoNormal;
import com.sifang.modules.customer.entity.CrmCustomerIncomingApplicationLeaseItem;
import com.sifang.modules.customer.entity.CrmCustomerIncomingApplicationPerInfo;
import com.sifang.modules.sunshine.SystemSetting.utils.StringUtil;
import com.sifang.modules.sys.common.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;



@Service
public class SupplementUploadService extends BaseService {

    @Autowired
    CustomerEntryService entryService;

    @Autowired
    private CrmCustomerIncomingApplicationDao applicationDao;

    @Autowired
    private CrmCustomerIncomingApplicationPerInfoDao perInfoDao;

    @Autowired
    private CrmCustomerIncomingApplicationLeaseItemDao equipInfoNormalDao;



    public void supplementUpload(int type,String entryId){

        CrmCustomerIncomingApplication application=applicationDao.getByEntryId(entryId);

        CrmCustomerIncomingApplicationPerInfo perInfo=perInfoDao.getByApplicationId(application.getId());

        String fileUrl="";

        switch (type){
            case 1:
                fileUrl=perInfo.getIdCardFrontImg();
                break;
            case 2:
                fileUrl=perInfo.getIdCardBackImg();
                break;
            case 3:
                fileUrl=perInfo.getHousePropertyImg();
                break;
            case 4:
                fileUrl=perInfo.getResidenceFrontImg();
                break;
            case 5:
                fileUrl=perInfo.getResidenceBackImg();
                break;
            case 6:
                fileUrl=perInfo.getAccountCardImg();
                break;
            default:
                throw new IllegalArgumentException("unknown type ");
        }
        if(StringUtil.isBlank(fileUrl)){
            return;
        }
       // if(type < 20){
           // entryService.uploadProject(application,fileUrl,"0");
      /*  }else if(type>=20){
            byte[] buffer = Base64Url.openFile(fileUrl);
            String entryIdFileSize=String.valueOf(buffer.length);
            String entryIdFileName=fileUrl.substring(fileUrl.lastIndexOf("/")+1);
            entryService.uploadCheckProject(application,entryIdFileName,fileUrl,entryIdFileSize);
        }*/


    }



}
