<?php
namespace model\sample;
use \model\pro\cate;
use \model\pro\factory;
use \model\collocation;
class purc extends \model
{
    public $table = 'sample_purc';
    public $key = 'sp_s_id';
    public $order = 'sp_s_id';
    public $findCaches = []; //查询临时缓存
	public function __construct()
    {
		parent::__construct();
	}
	public function list($where=[],$page=0,$pagesize=0,$sidx='',$sord='asc',$orderby=''){

		return $data;
	}

    /**
     * 得到记录全量信息
     * @param id|row $var id或者行记录
     * @return array
     */
	public function getRowInfo($var){
        $row = $var;

        return $row;
	}

    /**
     * 得到记录全量信息
     * @param id|row $var id或者行记录
     * @return array
     */
	public function addRow($key){
        $data = [
            'sp_s_id' => $key,
            'sp_downorder_time' => getNowDate(),
            'sp_arrival_time' => getNowDate(),
            'sp_channel' => 0,
            'sp_state' => 0,
            'sp_supplier' => 0,
            'sp_purc_uaer' => '',
            'opuser' => getOpuser(),
            'create_time' => getNowTime(),
            'update_time' => getNowTime(),
        ];
        $this->db->insert($this->table,$data);
        return $this->db->id();
	}

	/**
	 * edit ceil 值修改
	 * @return array
	 */
	public function setValue($key,$field,$value){
        $row = $this->getRowByKey($key);
        if(empty($row)){
            $this->addRow($key);
        }
		return $this->db->update($this->table,[$field=>$value],[$this->key=>$key]);
	}
}
