package com.usoft.credit.service.enterprise;

import com.usoft.credit.config.PyConfig;
import com.usoft.credit.modal.EnterpriseQuery;
import com.usoft.credit.service.ErpQueryService;
import com.usoft.credit.util.QueryConditionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 企业风险接口实现层
 * created by shicr on 2018/6/12
 **/
@Service
public class EnRiskInfoService {

    //查询类型
    private static String ENTERPRISE_RISK = "25123";

    //查询原因ID
    private static Integer QueryReasonID = 101;

    //收费子报告类型
    private static String SubreportIDs = "22527";


    @Autowired
    private ErpQueryService erpQueryService;

    @Autowired
    private PyConfig pyConfig;


    /**
     * 查询并保存返回查询json串
     *
     * @param query
     * @return
     */
    public String queryEnRiskInfo(EnterpriseQuery query) {
        //拼装查询的json
        String enrisk = QueryConditionUtil.getEnterpriseQuery(query, ENTERPRISE_RISK, SubreportIDs, QueryReasonID);
        //发起鹏元征信的请求
        String enriskResult = erpQueryService.requestApi(pyConfig.getHost(), pyConfig.getPathUnZip(), enrisk);
        return enriskResult;
    }
}
