<?php

class ModelShopeeShopee extends Model
{
    public function getShopeeOrderIds($order_id)
    {
        $query = $this->db->query(
            "SELECT
                mo.mktOrderId
              FROM `oc_marketplace_order` mo
              inner join oc_order o on (o.order_id = mo.order_id)
              WHERE mo.order_id = " . (int)$order_id
                    . " and o.mkt_integracao_tipo = " . Type_MarketPlace::Tp_Shopee);

        if ($query->rows) {
            return $query->rows;
        } else {
            return false;
        }
    }

    public function getErrorShopee($product_id){
      $query = $this->db->query(
        " SELECT * FROM oc_marketplace_product p
            WHERE p.product_key_id  = ".$product_id."
              AND p.tipo_integracao = ". Type_MarketPlace::Tp_Shopee
      );

      if(isset($query->row['mensagem_error'])){
        $this->session->data['mkt_error'][$product_id] = $query->row['mensagem_error'] != '' ? $query->row['mensagem_error'] : '';
      }
      return $query->row;
    }
}
