<?php !defined('APP_DIR') ? die('acceess not defined') : '';
class actions_api_sellwarning{
    /**
     * http://esfadmin.house365.com/365frame/index.php?ctrl=api_sellwarning&method=sellwarnings&city=nj&ids=100232962,91379522
     *
     */
    public function sellwarnings(){
        $city = $_GET['city'];
        $ids = $_GET['ids'];
        $ids = explode(',',$ids);
        $query_struct = array(
            'fields' => 'city, id',
            'where' => array(
                'city' => $city,
                'id'  => $ids,
            ),
        );
        $warnings = bm('sellwarning')->get_all($query_struct,'id');
        db::close();
        echo 'var sellwarnings = ' . json_encode($warnings) . ';';exit();
    }
    
    /**
     * 冻结房源
     *
     */
    public function dongjie(){
        $city = $_GET['city'];
        $id = intval($_GET['id']);
        $query_struct = array(
            'where' => array(
                'city' => $city,
                'id' => $id,
            )
        );
        
        $data = bm('sellwarning')->get($query_struct);
        //print_r($data);die('aaaa');
        if ($data){
            //经纪人和门店信息
            $broker = bm('broker')->get($data['uid']);
            $agency = bm('broker')->agencyByCode($broker['agentcode']);
            
            //冻结房源疑似房源表操作记录
            bm('sellwarning')->refuse($data);
            
            //经纪人降为1星
            $_broker = array(
                'uid' => $broker['uid'],
                'starlevel' => 1,
                'mistake_time' => time(),
            );
            bm('broker')->edit($_broker);
        }
        die('success');
    }
}