const system = require("../../../system");
const ServiceBase = require("../../sve.base")
/**
 * 订单产品表
 */
class OproductService extends ServiceBase {
  constructor() {
    super("product", ServiceBase.getDaoName(OproductService));
    this.oproductprocessDao = system.getObject("db.product.oproductprocessDao");
  }

  async productDics(params) {
    let list = await this.dao.dics(params);
    return system.getResultSuccess(list);
  }
  
  /**
   * 更新订单状态
   * @param {*} order_id 
   * @param {*} updateStatus 
   * @param {*} params 
   */
  async updateStatus(orderId, updateStatus, params) {
    try {
      let _order = this.iborderbaseDao.findById(orderId);
      if(!_order){
        return system.getResult(null,`系统错误 错误信息 ${error}`);
      }

      var statusObj = findStatus(_order.productId, _order.status);

      // statusObj.next_status 存在不存在 updateStatus

      this[statusObj.func](order, statusObj, params);  
    } catch (error) {
      return system.getResult(null,`系统错误 错误信息 ${error}`);
    }
    
  }

  // async setOrderStatus(orderList) {

  //   var productIds = [];
  //   var statues = [];

  //   list = SELECT * FROM o_product_process WHERE product_id IN(: productIds) AND statues IN(: statues)

  //   var map = {};
  //   for (var item of list) {
  //     map[item.product_id + "_" + item.status] = item;
  //   }

  //   for (var order of orderList) {
  //     order.status = map[order.product_id + "_" + order.status] || {};
  //   }
  // }




}

module.exports = OproductService;