var system = require("../../../system")
const CtlBase = require("../../ctl.base");
//商户信息
class MerchantCtl extends CtlBase {
    constructor() {
        super("all", CtlBase.getServiceName(MerchantCtl));
    }

    async allList(qobj){
        var params = qobj || {};
        this.doTimeCondition(params, ["signBegin", "signEnd"]);
        try {
            var page = await this.service.signPage(params);
            return system.getResult2(page);
        } catch (e) {
            console.log(e);
            return system.getErrResult2("您的网络不稳, 请稍后重试");
        }
    }
    //数据概览
    async dataSummarize(qobj){
        var params = qobj || {};
        if (params.month) {
            let date = this.getMonthDays(params.month);
            params.signBegin =date[0];
            params.signEnd =date[date.length-1];
        }
        this.doTimeCondition(params, ["signBegin", "signEnd"]);
        try {
            var page = await this.service.dataSummarize(params);
            return system.getResult2(page);
        } catch (e) {
            console.log(e);
            return system.getErrResult2("您的网络不稳, 请稍后重试");
        }
    }

    //首页图表
    async dataChart(qobj){
        var params = qobj || {};
        if (params.month) {
            let date = this.getMonthDays(params.month);
            params.signBegin =date[0];
            params.signEnd =date[date.length-1];
        }
        this.doTimeCondition(params, ["signBegin", "signEnd"]);

        try {
            var page = await this.service.dataChart(params);
            return system.getResult2(page);
        } catch (e) {
            console.log(e);
            return system.getErrResult2("您的网络不稳, 请稍后重试");
        }
    }
    //统计商户报表
    async commercialCount(qobj){
        var params = qobj || {};
        try {
            var page = await this.service.commercialCount(params);
            return system.getResult2(page);
        } catch (e) {
            console.log(e);
            return system.getErrResult2("您的网络不稳, 请稍后重试");
        }
    }
    //统计商户报表 详情
    async commercialList(qobj){
        var params = qobj || {};
        if (params.month) {
            let date = this.getMonthDays(params.month);
            params.signBegin =date[0];
            params.signEnd =date[date.length-1];
        }
        this.doTimeCondition(params, ["signBegin", "signEnd"]);
        try {
            var page = await this.service.commercialList(params);
            return system.getResult2(page);
        } catch (e) {
            console.log(e);
            return system.getErrResult2("您的网络不稳, 请稍后重试");
        }

    }


    //统计报表 个人
    async commercialCountToList(qobj){
        var params = qobj || {};
        try {
            var page = await this.service.commercialCountTo(params);
            return system.getResult2(page);
        } catch (e) {
            console.log(e);
            return system.getErrResult2("您的网络不稳, 请稍后重试");
        }
    }
    //统计报表 个人 图表
    async commercialCountToChares(qobj){
        var params = qobj || {};
        if (params.month) {
            let date = this.getMonthDays(params.month);
            params.signBegin =date[0];
            params.signEnd =date[date.length-1];
        }
        try {
            var page = await this.service.commercialCountToChares(params);
            return system.getResult2(page);
        } catch (e) {
            console.log(e);
            return system.getErrResult2("您的网络不稳, 请稍后重试");
        }
    }

    async tenantSel(qobj){
        var params = qobj || {};
        try {
            var page = await this.service.tenantSel(params);
            return system.getResult2(page);
        } catch (e) {
            console.log(e);
            return system.getErrResult2("您的网络不稳, 请稍后重试");
        }
    }




}

module.exports = MerchantCtl;