<?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.
 */

class VasBroker extends Vas{
  
    /**
     * 增值服务类型1是定投推广，2是房源包装
     * @var type 
     */
    private static $brokerUserType = array(
        'setpromot' => 1,
        'packinghouse' => 2,      
    );
    public function __construct($table = 'vas_user') {
        parent::__construct($table);
    }
    
    //已经使用定投推广的人数
    public function getUsedSetPromotBrokerNum(){
        $conf = "type = ".self::$brokerUserType['setpromot'];
        $brokerNum = parent::findNumberBy($conf);
        return $brokerNum;
    }
    
    //已经使用房源包装的人数
    public function getUsedPackingHouseBrokerNum(){
        $conf = "type = ".self::$brokerUserType['packinghouse'];
        $brokerNum = parent::findNumberBy($conf);
        return $brokerNum;
    }
    
    public function addJoinVasRecord($type, $brokerId) {
        $fieldData = array();
        $fieldData['type'] = $type;
        $fieldData['uid'] = $brokerId;
        $sql = SqlCombinHelper::replace_sql($this->table, $fieldData);
        return $this->db->execute($sql);
    }
    
    /**
     * 
     * @param type $brokerId
     * @return type
     */
    public function addJoinSetPromotRecord($brokerId) {
        return $this->addJoinVasRecord(self::$brokerUserType['setpromot'], $brokerId);
    }
    
    /**
     * 
     * @param type $brokerId
     * @return type
     */
    public function addJoinPackingHouseRecord($brokerId) {
        return $this->addJoinVasRecord(self::$brokerUserType['packinghouse'], $brokerId);
    }
    
    
    
    
    
}