<?php
namespace api\action\v1;

use api\action\baseAction;
use model\pro\pro;
use model\pro\product;

/**
 * Class proAction
 * @package api\action\v1
 */
class proAction extends baseAction
{
	/**
     * 获取商品同步日志
	 * @param  $start_time  string [必填] 开始时间 
	 * @param  $end_time  string [选填] 结束时间
     */
    public function getSynLog()
    {
		set_time_limit(0);
        try {
            $params = $this->getParaam();
			if(empty($params['start_time'])){
                 $this->returnJson(500,'start_time必填');
            }
			$product = new product();
			$data = $product->getSynLog($params);
			return $this->returnJson(200,'ok',$data);
		}catch (Exception $e) {
            $this->returnJson(500,$e->getMessage());
        }
	}
	
	
	/**
     * 宜配科技商品信息【同步专用】
	 * @param  $p_id  int [选填] 商品ID, 多个ID用英文逗号分隔
     */
    public function getProductInfoBySyn()
    {
		ini_set('memory_limit', \mvc::$cfg['upload']['memory_limit']);
		set_time_limit(0);
        try {
            $params = $this->getParaam();
			$product = new product();
			$data = $product->getProductInfoBySyn(explode(',', $params['p_id']));
			return $this->returnJson(200,'ok',$data);
		}catch (Exception $e) {
            $this->returnJson(500,$e->getMessage());
        }
	}

	/**
     * 国际车型库
	 * @param  $page  int [必填] 第几页
	 * @param  $page_size  int [选填] 每页数量 默认 500
     */
    public function getModel()
    {
		ini_set('memory_limit', \mvc::$cfg['upload']['memory_limit']);
		set_time_limit(0);
        try {
			$params = $this->getParaam();
			$product = new product();
			$data = $product->getModel($params);
			return $this->returnJson(200,'ok',$data);
		}catch (Exception $e) {
            $this->returnJson(500,$e->getMessage());
        }
	}


	/**
     * 中国车型库
	 * @param  $page  int [必填] 第几页
	 * @param  $page_size  int [选填] 每页数量 默认 500
     */
    public function getCnModel()
    {
		ini_set('memory_limit', \mvc::$cfg['upload']['memory_limit']);
		set_time_limit(0);
        try {
			$params = $this->getParaam();
			$product = new product();
			$data = $product->getCnModel($params);
			return $this->returnJson(200,'ok',$data);
		}catch (Exception $e) {
            $this->returnJson(500,$e->getMessage());
        }
	}


	/**
     * 小类
     */
    public function getAllCate()
    {
        try {
			$product = new product();
			$data = $product->getAllCate();
			return $this->returnJson(200,'ok',$data);
		}catch (Exception $e) {
            $this->returnJson(500,$e->getMessage());
        }
	}


	/**
     * 获取关联属性
	 * @param  $o_parent_id  int [必填] 
     */
    public function getObject()
    {
        try {
			$params = $this->getParaam();
			$product = new product();
			$data = $product->getObject($params['o_parent_id']);
			return $this->returnJson(200,'ok',$data);
		}catch (Exception $e) {
            $this->returnJson(500,$e->getMessage());
        }
	}


	public function getTbBarnd()
    {
        try {
			$product = new product();
			$data = $product->getTbBarnd();
			return $this->returnJson(200,'ok',$data);
		}catch (Exception $e) {
            $this->returnJson(500,$e->getMessage());
        }
	}

	public function getPbBarnd()
    {
        try {
			$product = new product();
			$data = $product->getPbBarnd();
			return $this->returnJson(200,'ok',$data);
		}catch (Exception $e) {
            $this->returnJson(500,$e->getMessage());
        }
	}


}