<?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, $type_product = Type_ProdutoMkt::Tp_MktProd_Normal){
      $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 .
              " AND p.tipo_produto = ". $type_product
      );

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