const system = require("../system");

class Dictionary {
    constructor() {
        this.SAAS_INTEVOICE = {
            owner_type: {"00": "商户发票", "10": "平台发票"},
            fee_type: {"00": "注册订单费用", "10": "平台转账费用", "20": "商户转账费用"},
            invoice_type: {"10": "增值税专用发票", "20": " 增值税普通发票", "30": "普通发票"},
            invoice_join: {"10": "记账联", "20": "发票联", "30": "抵扣联", "40": "销售方次"},
        };
        this.SAAS_INVOICE_APPLY = {
            owner_type: {"00": "商户发票", "10": "平台发票"},
            fee_type: {"00": "注册订单费用", "10": "平台转账费用", "20": "商户转账费用"},
            invoice_type: {"10": "增值税专用发票", "20": " 增值税普通发票", "30": "普通发票"},
            status: {"1000":"待审核", "1010":"审核通过", "1020":"审核不通过", "1030":"发票办理", "1040":"发票开具", "1050":"平台办理中", "1060":"办理完成"},
        }
    }

    getDict(module, field) {
        return (this[(module || "")] || {})[field] || {};
    }

    //调用方法： setRowName("ORDER", order, ["order_type", "acc_type", "trade_mode", "trade_status", "check_status"]);
    setRowName(module, row, fields) {
        if (!module || !row || !fields || fields.length == 0) {
            return;
        }
        for (let field of fields) {
            row[field + "_name"] = this.getDict(module, field)[row[field] || ""] || "";
        }
    }

    // setRowsName("ORDER", orders, ["order_type", "acc_type", "trade_mode", "trade_status", "check_status"]);
    setRowsName(module, rows, fields) {
        if (!module || !rows || !fields || fields.length == 0) {
            return;
        }
        for (let row of rows) {
            this.setRowName(module, row, fields)
        }
    }
}

module.exports = Dictionary;
