|
|
@@ -304,6 +304,43 @@ class VideoService extends BaseService
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 更新播放浏览历史
|
|
|
+ * @param $userId 用户ID
|
|
|
+ * @param $id 视频ID
|
|
|
+ * @return false
|
|
|
+ */
|
|
|
+ public function updatePlay($userId, $id)
|
|
|
+ {
|
|
|
+ // 浏览历史
|
|
|
+ if(!VideoCollectService::make()->getCollectCacheInfo($userId, $id, 1)){
|
|
|
+ $info = $this->model->from('videos as a')
|
|
|
+ ->where(['a.id'=> $id,'a.mark'=>1])
|
|
|
+ ->select(['a.id','a.tags','a.user_id'])
|
|
|
+ ->first();
|
|
|
+
|
|
|
+ if(empty($info)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ 'user_id'=> $userId,
|
|
|
+ 'type'=> 1,
|
|
|
+ 'collect_id'=> $id,
|
|
|
+ 'collect_uid'=> isset($info['user_id'])? $info['user_id'] : 0,
|
|
|
+ 'tags'=> isset($info['tags'])? $info['tags'] : '',
|
|
|
+ 'create_time'=> time(),
|
|
|
+ 'status'=> 1,
|
|
|
+ ];
|
|
|
+ VideoCollectModel::insert($data);
|
|
|
+ RedisService::set("caches:videos:collect:temp_{$userId}_{$id}_1", $data, rand(10,30));
|
|
|
+ RedisService::clear("caches:videos:recommend:{$userId}");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 浏览量
|
|
|
+ $this->updateView($userId, $id);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 更新浏览量
|
|
|
* @param $userId
|
|
|
* @param $dynamicId
|