where(['match_id' => $match_id, 'game_code' => $type])->first(); if (!$data) { $res = $this->insert(['game_code' => $type, 'status' => 0, 'pcount' => $pcount, 'game_start_time' => $game_start_time, 'match_id' => $match_id, 'ctime' => date('Y-m-d H:i:s')]); if (!$res) { return -6030001222; } } return 1; } // public function getNeedSettelent() { $lastDay = date("Y-m-d H:i:s", time() - 86400 * 30); $now = date("Y-m-d H:i:s", time() - 5 * 36000); $model = $this->where([['game_start_time', '<=', $now], ['game_start_time', '>=', $lastDay], ['ctime', '>=', $lastDay], ['pcount', '=', 0]])->orderBy('game_start_time', 'asc')->first(); return $model; } //找到比赛已经结束,还没结算的记录,插入到消息通知表里[多个球类] public function InsertEndGame($day = 30) { $types = ['zq', 'lq', 'wq', 'bq']; foreach ($types as $gtype) { $rows = $this->findByType($gtype, $day); if (!empty($rows) && count($rows) > 0) { Common::SET_NOMAM_RECORD('自动结算之添加通知消息!', ['count' => count($rows)]); foreach ($rows as $matchidObj) { $matchid = $matchidObj->match_id; $start_time = $matchidObj->start_time; $this->addcomendnotice($matchid, $gtype, 0, $start_time); } } } return true; } public function findByType($type, $days = 30) { $days = intval($days); $time = date("Y-m-d 00:00:00", (time() - 86400 * $days)); $table = "st_" . $type . "_result"; $sql = <<='$time' and status=2 ) as tabb where match_id not in (select match_id from comendnotice where game_code='$type') order by match_id asc EOS; $result = DB::select($sql); return $result; } }