package com.usoft.credit.util;

import com.alibaba.fastjson.JSON;
import com.usoft.credit.modal.*;

import java.util.ArrayList;
import java.util.List;


/**
 * 企业查询，个人查询公用方法
 * @author liuam
 * @since 2018/6/25 0025 下午 16:19
 */
public class QueryConditionUtil {
    /**
     * 查找企业信息
     *
     * @return
     */
    public static String getEnterpriseQuery(EnterpriseQuery query, String queryType, String SubreportIDs, Integer QueryReasonID) {
        // 使用JavaBean/Map方式（正式使用,仅供参考）
        QueryConditions queryConditions = new QueryConditions();
        List<QueryCondition> conditions = new ArrayList<QueryCondition>();
        QueryCondition queryCondition = new QueryCondition();
        // 查询类型
        queryCondition.setQueryType(queryType);
        List<Item> items = new ArrayList<Item>();

        // 收费子报告
        items.add(new Item("subreportIDs", SubreportIDs));
        // 查询原因
        items.add(new Item("queryReasonID", String.valueOf(QueryReasonID)));
        // 业务流水号
        items.add(new Item("refID", query.getRefID()));
        //被查询企业名称
        items.add(new Item("corpName", query.getEnname()));
        //被查询企业工商注册号
        items.add(new Item("registerNo", query.getRegisterNo()));
        //被查询企业社会信用代码
        items.add(new Item("creditCode", query.getCreditCode()));

        queryCondition.setItems(items);
        conditions.add(queryCondition);
        queryConditions.setConditions(conditions);
        return JSON.toJSONString(queryConditions);
    }

    /**
     * 查找个人信息
     *
     * @return
     */
    public static String getPersonQuery(PersonQuery query, String queryType, String SubreportIDs, Integer QueryReasonID) {
        QueryConditions queryConditions = new QueryConditions();
        List<QueryCondition> conditions = new ArrayList<QueryCondition>();
        QueryCondition queryCondition = new QueryCondition();

        queryCondition.setQueryType(queryType);
        List<Item> items = new ArrayList<Item>();
        // 收费子报告
        items.add(new Item("subreportIDs", SubreportIDs));
        // 查询原因
        items.add(new Item("queryReasonID", String.valueOf(QueryReasonID)));
        // 业务流水号
        items.add(new Item("refID", query.getRefID()));
        //被查询姓名
        items.add(new Item("name", query.getName()));
        //被查询个人证件号
        items.add(new Item("documentNo", query.getDocumentNo()));
        queryCondition.setItems(items);
        conditions.add(queryCondition);
        queryConditions.setConditions(conditions);

        return JSON.toJSONString(queryConditions);
    }
}
