|
@@ -200,9 +200,23 @@ class PostRepository
|
|
|
$uid = $token['user']->id;
|
|
|
$username = $token['user']->username;
|
|
|
//验证小号数量
|
|
|
-
|
|
|
+ $number = max([
|
|
|
+ $request['add_pv'],
|
|
|
+ $request['add_praise_count'],
|
|
|
+ $request['add_collect_count'],
|
|
|
+ $request['add_share_count']
|
|
|
+ ]);
|
|
|
+
|
|
|
+ $members = $this->getSystemMember($number);
|
|
|
+ if(!$members || $members['status_code'] != 200){
|
|
|
+ return Response::create([
|
|
|
+ 'message' => $members['message'],
|
|
|
+ 'status_code' => 500
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ $post = $this->post->find($request['post_id']);
|
|
|
$postData = $this->postData->where('post_id', $request['post_id'])->first();
|
|
|
- if (!$postData) {
|
|
|
+ if (!$postData || !$post) {
|
|
|
return Response::create([
|
|
|
'message' => '获取内容失败',
|
|
|
'status_code' => 500
|
|
@@ -249,6 +263,62 @@ class PostRepository
|
|
|
]);
|
|
|
|
|
|
DB::commit();
|
|
|
+
|
|
|
+ $virus = $this->behavior
|
|
|
+ ->whereIn('behavior_identification', ['read', 'forward', 'like', 'collect'])
|
|
|
+ ->pluck('virus_behavior_id', 'behavior_identification');
|
|
|
+ if($post->title){
|
|
|
+ $desc = $post->title;
|
|
|
+ }else{
|
|
|
+ $desc = subtext(strip_tags($post->content), 20);
|
|
|
+ }
|
|
|
+ $data = [
|
|
|
+ 'behavior_value' => 1,
|
|
|
+ 'post_id' => $post->id,
|
|
|
+ 'post_author_uid' => $post->uid,
|
|
|
+ 'post_desc' => $desc,
|
|
|
+ 'post_cover' => $post->img,
|
|
|
+ 'action_id' => $post->id,
|
|
|
+ ];
|
|
|
+
|
|
|
+ foreach($members['data'] as $key => $member){
|
|
|
+ if(isset($virus['read']) && $request['add_pv'] > $key){
|
|
|
+ $newData = array_merge($data, [
|
|
|
+ 'behavior_id' => $virus['read'],
|
|
|
+ 'behavior_flag' => 'read',
|
|
|
+ 'target_id' => $member['uid'],
|
|
|
+ ]);
|
|
|
+ $this->rabbitMqUtil->push('virus_add', $newData);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isset($virus['like']) && $request['add_praise_count'] > $key){
|
|
|
+ $newData = array_merge($data, [
|
|
|
+ 'behavior_id' => $virus['like'],
|
|
|
+ 'behavior_flag' => 'like',
|
|
|
+ 'target_id' => $member['uid'],
|
|
|
+ ]);
|
|
|
+ $this->rabbitMqUtil->push('virus_add', $newData);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isset($virus['collect']) && $request['add_collect_count'] > $key){
|
|
|
+ $newData = array_merge($data, [
|
|
|
+ 'behavior_id' => $virus['collect'],
|
|
|
+ 'behavior_flag' => 'collect',
|
|
|
+ 'target_id' => $member['uid'],
|
|
|
+ ]);
|
|
|
+ $this->rabbitMqUtil->push('virus_add', $newData);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isset($virus['forward']) && $request['add_share_count'] > $key){
|
|
|
+ $newData = array_merge($data, [
|
|
|
+ 'behavior_id' => $virus['forward'],
|
|
|
+ 'behavior_flag' => 'forward',
|
|
|
+ 'target_id' => $member['uid'],
|
|
|
+ ]);
|
|
|
+ $this->rabbitMqUtil->push('virus_add', $newData);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return Response::create();
|
|
|
|
|
|
} catch (QueryException $exception) {
|