select(['app_id', 'open_id', 'album_id', 'episode_id', 'type', 'seq']) ->where('app_id', $appId)->where('open_id', $openId)->where('enable', 1); if(!empty($albumIdList)) { $model->whereIn('album_id', $albumIdList); } if(!empty($type)) { $model->where('type', $type); } if(!empty($startDate)) { $model->where('update_time', '>=', $startDate.' 00:00:00'); } if(!empty($endDate)) { $model->where('update_time', '<=', $endDate.' 23:59:59'); } if(!empty($page)) { $model->orderBy('update_time', 'desc')->offset(($page-1)*$pageSize)->limit($pageSize); } return [$model->get(), $model->count()]; } public static function addRecord($appId, $openId, $type, $albumId, $episodeId, $seq) { $con = [ 'app_id' => $appId, 'open_id' => $openId, 'type' => $type, 'album_id' => $albumId ]; $attr = [ 'enable' => 1, 'episode_id' => $episodeId, 'seq' => $seq ]; return self::query()->updateOrCreate($con, $attr); } public static function delRecord($appId, $openId, $type, $albumId) { return self::query()->where('app_id', $appId)->where('open_id', $openId)->where('type', $type) ->where('album_id', $albumId)->update(['enable' => 0, 'update_time' => date('Y-m-d H:i:s')]); } }