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

  async microAdd(params) {
    var rs = await this.callms("order", "saasOrderMicroAdd", params);
    return rs;
  }

  async info(params) {
    var rs = await this.callms("order", "saasOrderInfo", params);
    return rs;
  }

  async platformInfo(params) {
    var rs = await this.callms("order", "saasOrderPlatformOrderInfo", params);
    return rs;
  }

  async page(params) {
    var rs = await this.callms("order", "saasOrderPage", params);
    if (rs && rs.data && rs.data.rows) {
      this.transOrderField(rs.data.rows);
    }
    return rs;
  }
  async audit(params) {
    var rs = await this.callms("order", "saasOrderAudit", params);
    return rs;
  }

  async deliver(params) {
    var rs = await this.callms("order", "saasOrderDeliver", params);
    return rs;
  }

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

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