<?php
/**
*------Create thems Model------
*------SCWPHP  Version 1.0.0------
*------Dev Model Jions------
*------Create Time 2017-06-13 18:45:24------
*/
namespace App\Models;

use DB;


class Comendnotice extends BaseModel {

    protected $table = 'comendnotice';

    //添加赛事结束纪录
    function addcomendnotice($match_id){
        $data = \App\Models\Comendnotice::where(['match_id'=>$match_id,'game_code'=>'zq'])->first();
        if(!$data){
            $model = new \App\Models\Comendnotice();
            $model->status = 0;//联赛id
            $model->game_code = 'zq';
            $model->match_id = $match_id;//赛事id
            $model->ctime = date('Y-m-d H:i:s');
            $model->save();

            $newapp = new \App\Lib\Settlement\SettlementWinFail();
            $ret = $newapp->doRun($model->id);
        }else{
            $newapp = new \App\Lib\Settlement\SettlementWinFail();
            \App\Models\Comendnotice::where(['match_id'=>$match_id,'game_code'=>'zq'])->update(['status'=>0]);
            $ret = $newapp->doRun($data->toArray()['id']);
            $ret2 =$data->toArray()['id'];
            if ($ret2['status']==1){
                \App\Models\Comendnotice::where(['match_id'=>$match_id,'game_code'=>'zq'])->update(['status'=>4]);
            }
        }
        return $ret;
    }


}