|
|
@@ -0,0 +1,81 @@
|
|
|
+<?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;
|
|
|
+use App\Models\MoneyBuyMatch as MoneyBuyMatchModel;
|
|
|
+use App\Lib\Biz\Sport\Common;
|
|
|
+
|
|
|
+
|
|
|
+class Comendnotice extends BaseModel
|
|
|
+{
|
|
|
+
|
|
|
+ protected $table = 'comendnotice';
|
|
|
+ public $timestamps = false;
|
|
|
+ protected $fillable = ['status', 'pcount', 'logs', 'game_code', 'match_id', 'result', 'done_time', 'start_time', 'ctime'];
|
|
|
+
|
|
|
+ //添加赛事结束纪录
|
|
|
+ function addcomendnotice($match_id, $type, $pcount = 1, $game_start_time = 0)
|
|
|
+ {
|
|
|
+ $data = $this->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 = <<<EOS
|
|
|
+ select tabb.match_id,tabb.start_time from
|
|
|
+( select match_id,start_time from $table where start_time>='$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;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|