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

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

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

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

  async offlinePay(params) {
    let rs = await this.callms("order", "saasOrderBulkOfflinePay", params);
    return rs;
  }

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

  async mapByIds(params) {
    let rs = await this.callms("order", "saasOrderMapByIds", params) || {};
    return rs.data || {};
  }

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

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

}
module.exports = OrderService;