const system = require("../../../system");
const ServiceBase = require("../../svems.base")
const settings = require("../../../../config/settings")
class InvoiceService extends ServiceBase {
    constructor() {
        super();
    }

    async merchantinvoicePage(params){
        var rs = await this.callms("invoice", "merchantinvoicePage", params);
        if (rs && rs.data && rs.data.rows) {
            this.transOrderField(rs.data.rows);
        }
        return rs;
    }

    async merchantinvoiceapplyPage(params){
        var rs = await this.callms("invoice", "merchantinvoiceapplyPage", params);
        if (rs && rs.data && rs.data.rows) {
            this.transOrderField(rs.data.rows);
        }
        return rs;
    }

    async applySave(params){
        var rs = await this.callms("invoice", "invoiceapplySave", params);
        return rs;
    }

    transOrderField(rows) {
        if (!rows || rows.length == 0) {
            return;
        }

        for (let row of rows) {
            row.price = system.f2y(row.price);
        }
    }

}
module.exports = InvoiceService;
