package org.dromara.resource.dubbo;

import cn.hutool.core.bean.BeanUtil;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.dromara.common.core.enums.SignType;
import org.dromara.resource.api.RemoteJzqService;
import org.dromara.resource.api.domain.RemoteJzq;
import org.dromara.resource.junziqian.common.bean.sign.JzqSign;
import org.dromara.resource.service.impl.JzqSignServiceImpl;
import org.dromara.system.api.RemoteConfigService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.File;

/**
 * @author sunzexing
 * @version 1.0
 * @title RemoteJzqServiceImpl
 * @description
 * @create 2024-05-20 9:55
 */


@DubboService
@Service
public class RemoteJzqServiceImpl implements RemoteJzqService {


    private static final Logger log = LoggerFactory.getLogger(RemoteJzqServiceImpl.class);
    @Resource
    public JzqSignServiceImpl  JzqSignService;


    @DubboReference
    private RemoteConfigService remoteConfigService;

    public String becomeSign(RemoteJzq sign, String domain, SignType signType) {
//        RemoteSysUnitDomainVo site = remoteConfigService.queryByDomainName(domain);
//
//        if(site == null || StringUtils.isEmpty(site.getSignConfig())){
//            throw new Exception("未找到该域名的大鸿签签约配置信息");
//        }
//
//        JSONObject signConfig = JSONObject.parseObject(site.getSignConfig());
//
//        sign.setApplicationId(signConfig.getString("appId"));
//        sign.setBusinessId(signConfig.getString("businessId"));
//
//        if(StringUtils.isEmpty(sign.getContractModelNum())){
//            if(1 == signType.getId()){
//                sign.setContractModelNum(signConfig.getString("user_worker_pro"));
//            }else if(2 == signType.getId()){
//                sign.setContractModelNum(signConfig.getString("user_worker_conf"));
//            }
//        }
        JzqSign JzqSign = BeanUtil.copyProperties(sign,JzqSign.class);
        return this.JzqSignService.becomeSign(JzqSign);
    }


    public String link(String applyNo, String fullName, String identityCard, int identityType) {
        return this.JzqSignService.link(applyNo,fullName,identityCard,identityType);
    }


    public String bankThreeVerify(String name, String identityCard, String cardNo) {
        return JzqSignService.bankThreeVerify(name,identityCard,cardNo);
    }

    public String userValid(String name ,String identityCard){
        return JzqSignService.userValid(name,identityCard);
    }


    public String ocrIdentity(String file, Integer front) {
        return JzqSignService.ocrIdentity(file,front);
    }

    public String bankFourVerify(String name,String identityCard,String cardNo,String mobilePhone){
        return JzqSignService.bankFourVerify(name,identityCard,cardNo,mobilePhone);
    }

    public String ocrBank(File file){
        return JzqSignService.ocrBank(file);
    }

    public String startH5Face(String orderNo,String name,String identityCard,String backUrl,Integer startFrom){
        return JzqSignService.startH5Face(orderNo,name,identityCard,backUrl,startFrom);
    }

    public String organizationCreate(String emailOrMobile,String name,Integer organizationType,Integer identificationType,String organizationRegNo,
                                     File organizationRegImg,String legalName,String legalIdentityCard,String legalMobile){
        return JzqSignService.organizationCreate(emailOrMobile,name,organizationType,identificationType,organizationRegNo,organizationRegImg,legalName,legalIdentityCard,legalMobile);
    }

    public String cloudCertiPerInfo(String fullName,String identityCard,File idenFront,File idenReverse){
        return JzqSignService.cloudCertiPerInfo(fullName,identityCard,idenFront,idenReverse);
    }

    public String linkFile(String applyNo){
        return JzqSignService.linkFile(applyNo);
    }

}
