| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace App\Http\Model;
- use function foo\func;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Database\Eloquent\Model;
- /**
- * Class StZqOdds
- * @package App\Http\Model
- * 足球 赔率
- */
- class StZqOdds extends Model
- {
- protected $table = 'st_zq_odds';
- public $timestamps = false;
- protected $fillable = ['match_id','others_match_id','odds_code','status','sort','p_code','odds','condition','odds_only','sole','source','type','team','lg_id','others_lg_id','ctime','utime','expire_time'];
- /*
- * 获取一段时间内所有的赔率
- */
- public static function getOddsID($models){
- $Odds_data = $models['model_odds']::select('id','sole','source')
- ->where([['utime','>',date('Y-m-d H:i:s' , strtotime("-1 day"))]])
- ->get()
- ->toArray();
- return $Odds_data;
- }
- /*
- * 更新赛事下赔率状态
- */
- public static function upOddsStatus($model=[],$others_match_id='',$others_lg_id=[],$source='',$odds_only=[]){
- $where = [];
- //普通 赔率
- if(!empty($others_match_id) and !empty($source)){
- $where = [
- ['others_match_id','=',$others_match_id],
- ['source','=',$source]
- ];
- //获取当前 赛事 所有 赔率only
- $odds_data = $model['model_odds']::select('odds_only')
- ->where($where)
- ->get()
- ->toArray();
- }
- //冠军联赛 赔率
- if(!empty($others_lg_id) and !empty($source)){
- //获取当前 赛事 所有 赔率only
- $odds_data = $model['model_odds']::select('odds_only')
- ->whereIn('others_lg_id',$others_lg_id)
- ->where(['source','=',$source])
- ->get()
- ->toArray();
- }
-
- if(empty($odds_data)) return true;
- //去除 本次请求的 赔率only
- if(is_array($odds_data) and !empty($odds_only)){
- foreach ($odds_data as $k => $v){
- foreach ($odds_only as $kk => $vv){
- if($v['odds_only'] == $vv) unset($odds_data[$k]);
- }
- }
- }
- if(empty($odds_data)) return true;
- //降维 获取所有only
- $only = [];
- if(is_array($odds_data)){
- foreach ($odds_data as $k => $v){
- $only[] = $v['odds_only'];
- }
- }
- //批量更新 赔率状态
- $ds = $model['model_odds']::whereIn('odds_only', $only)
- ->update(['status' => -1]);
- if($ds > 0 ) return true;
- }
- }
|