var system = require("../../../system");
const apiBase = require("../../api.base");

class XbgApi extends apiBase {

    constructor() {
        super();
        this.restClient = system.getObject("util.restClient");
        this.url = "https://bpohhr.gongsibao.com/api/xbgApi/";
        this.testCompanyIds = [492];
    }

    async test(pobj, query) {
        return system.getResultSuccess({
            hello: "ok"
        });
    }
    async setCompanyIds(qobj) {
        // qobj.id
        // 查ecmpanyIds
        qobj.ecompany_id = this.testCompanyIds;
    }
    //合同模板
    async etemplateList(qobj) {

        this.setCompanyIds(qobj);
        var params = qobj || {};
        if (!params.ecompany_id) {
            return system.getResult("参数ecompany_id为空")
        }
        try {
            var params = qobj || {};
            var rs = await this.restClient.execPost(params, this.url+"etemplateList");
            return JSON.parse(rs.stdout);
        } catch (e) {
            console.log(e);
            return system.getResult("接口异常");
        }
    }

    //已签合同
    async acontractList(qobj) {
        this.setCompanyIds(qobj);
        var params = qobj || {};
        if (!params.ecompany_id) {
            return system.getResult("参数ecompany_id为空")
        }
        try {
            var rs = await this.restClient.execPost(params, this.url+"acontractList");
            return JSON.parse(rs.stdout);
        } catch (e) {
            console.log(e);
            return system.getResult("接口异常");
        }
    }

    //纳税人人员
    async ratepayingListToPe(qobj) {
        this.setCompanyIds(qobj);
        var params = qobj || {};
        if (!params.ecompany_id) {
            return system.getResult("参数ecompany_id为空")
        }
        try {
            var rs = await this.restClient.execPost(params, this.url+"ratepayingListToPe");
            return JSON.parse(rs.stdout);
        } catch (e) {
            console.log(e);
            return system.getResult("接口异常");
        }
    }

    //纳税人按月
    async ratepayingListToMonth(qobj) {
        this.setCompanyIds(qobj);
        var params = qobj || {};
        if (!params.ecompany_id) {
            return system.getResult("参数ecompany_id为空")
        }
        try {
            var rs = await this.restClient.execPost(params, this.url+"ratepayingListToMonth");
            return JSON.parse(rs.stdout);
        } catch (e) {
            console.log(e);
            return system.getResult("接口异常");
        }
    }

    //纳税人个人详情
    async ratepayingListToOne(qobj) {
        this.setCompanyIds(qobj);
        var params = qobj || {};
        if (!params.ecompany_id) {
            return system.getResult("参数ecompany_id为空")
        }
        try {
            var rs = await this.restClient.execPost(params, this.url+"ratepayingListToOne");
            return JSON.parse(rs.stdout);
        } catch (e) {
            console.log(e);
            return system.getResult("接口异常");
        }
    }

    //数据概览
    async dataOverview(qobj) {
        this.setCompanyIds(qobj);
        var params = qobj || {};
        if (!params.ecompany_id) {
            return system.getResult("参数ecompany_id为空")
        }
        try {
            var rs = await this.restClient.execPost(params, this.url+"dataOverview");
            return JSON.parse(rs.stdout);
        } catch (e) {
            console.log(e);
            return system.getResult("接口异常");
        }

    }


    exam() {
        return "xxx";
    }
    classDesc() {
        return {
            groupName: "auth",
            groupDesc: "认证相关的包",
            name: "AccessAuthAPI",
            desc: "关于认证的类",
            exam: "",
        };
    }
    methodDescs() {
        return [{
            methodDesc: "生成访问token",
            methodName: "getAccessKey",
            paramdescs: [{
                paramDesc: "访问appkey",
                paramName: "appkey",
                paramType: "string",
                defaultValue: "x",
            },
                {
                    paramDesc: "访问secret",
                    paramName: "secret",
                    paramType: "string",
                    defaultValue: null,
                }
            ],
            rtnTypeDesc: "xxxx",
            rtnType: "xxx"
        }];
    }

}

module.exports = XbgApi;