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

class IborderbaseService extends ServiceBase {
  constructor() {
    super("order", ServiceBase.getDaoName(IborderbaseService));
    this.orderSve_1 = system.getObject("service.order.iborderSve");
    this.orderSve_2 = system.getObject("service.order.iborderdkSve");
    this.orderSve_3 = system.getObject("service.order.iborderdzSve");
  }

  getService(productType) {
    return this["orderSve_" + productType];
  }

  async apiAdd(params) {
    try {
      let sve = this.getService(params.productType);
      if (!sve) {
        return system.getResult(null, `产品类型错误${params.productType}`);
      }
      return sve.addOrder(params);
    } catch (error) {
      console.log(error);
      return system.getResult(null, "接口异常");
    }
  }

  async apiSaveInfo() {
    try {
      let sve = this.getService(params.productType);
      if (!sve) {
        return system.getResult(null, `产品类型错误${params.productType}`);
      }
      return sve.saveInfo(params);
    } catch (error) {
      console.log(error);
      return system.getResult(null, "接口异常");
    }
  }
}

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