const system = require("../../../system");
const ServiceBase = require("../../sve.base")

class StOrderItemService extends ServiceBase {
  constructor() {
    super("trade", ServiceBase.getDaoName(StOrderItemService));
    this.dictionary = system.getObject("util.dictionary");
  }

  async pageByCondition(params) {
    let page = {count: 0, rows: []};
    params.currentPage = Number(params.currentPage || 1);
    params.pageSize = Number(params.pageSize || 10);
    params.startRow = (params.currentPage - 1) * params.pageSize;

    page.count = await this.dao.countByCondition(params);
    if (page.count == 0) {
      return system.getResultSuccess(page);
    }

    page.rows = await this.dao.listByCondition(params);
    if (page.rows) {
      for (var row of page.rows) {
        this.handleDate(row, ["created_at"], null);
      }
      this.dictionary.setRowsName("ORDER_ITEM", page.rows, ["trade_status"]);
    }
    return system.getResultSuccess(page);
  }
}

module.exports = StOrderItemService;
// var task=new UserService();
// task.getUserStatisticGroupByApp().then(function(result){
//   console.log((result));
// }).catch(function(e){
//   console.log(e);
// });