<?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 GrowthBidHouseRecordFinish  extends GrowthBidHouseRecord {
    public function __construct($table = 'growth_bid_house_record_finish') {
        parent::__construct($table);
        $this->growthBidPeriods = new GrowthBidPeriods();
    }
    
    /**
     *  获取经纪人房源竞投记录
     * @param int $brokerId 经纪人编号
     * @param int $time 时间戳
     * @return array 竞投房源记录
     */
    public function getBidFinishByBorkerId($brokerId, $time = '') 
    { global $conf_city;
        $time = (isset($time) && $time !='') ? $time : time();
        $today = date('Y-m-d');
        $memkey = $conf_city . '_fininshlist_' . $brokerId . '_' . $today;
        $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($memkey);
        if ($bidFinishHouse === false) {
            $bidFinishHouse = $this->dbback->getAll($sql);
            $this->mc->set($memkey, $bidFinishHouse, 3600);
        }
        return $bidFinishHouse;
    }
}
