<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of GrowthBidHouseRecordFinish
 *
 * @author user
 */
class GrowthBidRentRecordFinish  extends GrowthBidRentRecord {
    public function __construct($table = 'growth_bid_rent_record_finish') {
        parent::__construct($table);
        $this->growthBidPeriods = new GrowthBidPeriods();
    }
    
    /**
     *  获取经纪人房源竞投记录
     * @param int $brokerId 经纪人编号
     * @param int $time 时间戳
     * @return array 竞投房源记录
     */
    public function getBidFinishByBorkerId($brokerId, $time = '') 
    {
        $time = (isset($time) && $time !='') ? $time : time();
        $dateTime = date('Y-m-d H:i:s', $time);
        $sql = SqlCombinHelper::select_sql($this->table, 'house_id, type',  
                "broker_id = {$brokerId} AND tg_start_time <= '{$dateTime}'"
                . " AND tg_end_time >= '{$dateTime}'");
        $bidFinishHouse = $this->mc->get($sql);
        if ($bidFinishHouse === false) {
            $bidFinishHouse = $this->dbback->getAll($sql);
            $this->mc->set($sql, $bidFinishHouse, 3600);
        }
        return $bidFinishHouse;
    }
}
