|
@@ -0,0 +1,235 @@
|
|
|
|
+<?php
|
|
|
|
+/**
|
|
|
|
+ * Created by PhpStorm.
|
|
|
|
+ * User: edz
|
|
|
|
+ * Date: 2019-06-10
|
|
|
|
+ * Time: 17:53
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+namespace App\Repositories;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+use App\Models\BindPhoneRecord;
|
|
|
|
+use App\Models\BindWxRecord;
|
|
|
|
+use App\Models\CommentAccountRecord;
|
|
|
|
+use App\Models\GeneralLedgerRecord;
|
|
|
|
+use App\Models\RegisteredAccountsRecord;
|
|
|
|
+use App\Models\ReleaseRecord;
|
|
|
|
+use Illuminate\Database\QueryException;
|
|
|
|
+use Illuminate\Support\Facades\Log;
|
|
|
|
+
|
|
|
|
+class BehaviorRecordRepositories
|
|
|
|
+{
|
|
|
|
+ public function __construct(RegisteredAccountsRecord $registeredAccountsRecord,
|
|
|
|
+ GeneralLedgerRecord $generalLedgerRecord,
|
|
|
|
+ ReleaseRecord $releaseRecord,
|
|
|
|
+ CommentAccountRecord $commentAccountRecord,
|
|
|
|
+ BindPhoneRecord $bindPhoneRecord,
|
|
|
|
+ BindWxRecord $bindWxRecord)
|
|
|
|
+ {
|
|
|
|
+ $this->registeredAccountsRecord = $registeredAccountsRecord;
|
|
|
|
+ $this->generalLedgerRecord = $generalLedgerRecord;
|
|
|
|
+ $this->releaseRecord = $releaseRecord;
|
|
|
|
+ $this->commentAccountRecord = $commentAccountRecord;
|
|
|
|
+ $this->bindPhoneRecord = $bindPhoneRecord;
|
|
|
|
+ $this->bindWxRecord = $bindWxRecord;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 根据行为标识获取行为记录表
|
|
|
|
+ * @param $behavior
|
|
|
|
+ */
|
|
|
|
+ public function getBehaviorTable($behavior)
|
|
|
|
+ {
|
|
|
|
+ $tables = [
|
|
|
|
+ 'register' => 'registered_accounts_record',
|
|
|
|
+ 'publish' => 'release_record',
|
|
|
|
+ 'read' => 'general_ledger_record',
|
|
|
|
+ 'like' => 'general_ledger_record',
|
|
|
|
+ 'unlike' => 'general_ledger_record',
|
|
|
|
+ 'forward' => 'general_ledger_record',
|
|
|
|
+ 'collect' => 'general_ledger_record',
|
|
|
|
+ 'comment' => 'comment_account_record',
|
|
|
|
+ 'bind_phone' => 'bind_phone_record',
|
|
|
|
+ 'bind_wechat' => 'bind_wx_record'
|
|
|
|
+ ];
|
|
|
|
+ return isset($tables[$behavior]) ? $tables[$behavior] : false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 记录账本
|
|
|
|
+ * @param $info
|
|
|
|
+ * @return bool
|
|
|
|
+ */
|
|
|
|
+ public function addRecord($info)
|
|
|
|
+ {
|
|
|
|
+ Log::debug('add-record-request:' . json_encode($info));
|
|
|
|
+ $behavior = $info['behavior_flag'];
|
|
|
|
+ $behaviorTable = $this->getBehaviorTable($behavior);
|
|
|
|
+ Log::debug('add-record-behavior-table:' . $behaviorTable);
|
|
|
|
+ if ($behaviorTable) {
|
|
|
|
+ if ($behaviorTable == 'registered_accounts_record') {
|
|
|
|
+ return $this->addRegisterRecord($info);
|
|
|
|
+ } elseif ($behaviorTable == 'release_record') {
|
|
|
|
+ return $this->addReleaseRecord($info);
|
|
|
|
+ } elseif ($behaviorTable == 'general_ledger_record') {
|
|
|
|
+ return $this->addGeneralRecord($info);
|
|
|
|
+ } elseif ($behaviorTable == 'comment_account_record') {
|
|
|
|
+ return $this->addCommentRecord($info);
|
|
|
|
+ } elseif ($behaviorTable == 'bind_phone_record') {
|
|
|
|
+ return $this->addBindPhoneRecord($info);
|
|
|
|
+ } elseif ($behaviorTable == 'bind_wx_record') {
|
|
|
|
+ return $this->addBindWxRecord($info);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 记录账本-用户注册
|
|
|
|
+ * @param $register
|
|
|
|
+ * @return bool
|
|
|
|
+ */
|
|
|
|
+ public function addRegisterRecord($register)
|
|
|
|
+ {
|
|
|
|
+ try {
|
|
|
|
+ $data['virus_behavior_id'] = $register['virus_behavior_id'];
|
|
|
|
+ $data['uid'] = $register['uid'];
|
|
|
|
+ $data['trigger_time'] = $register['trigger_time'];
|
|
|
|
+ $data['physical_exertion'] = $register['physical_exertion'];
|
|
|
|
+ $data['trigger_type'] = $register['trigger_type'];
|
|
|
|
+ $data['generation_type'] = $register['generation_type'];
|
|
|
|
+ $data['absolute_progression'] = $register['absolute_progression'];
|
|
|
|
+ $data['superior_uid'] = $register['superior_uid'];
|
|
|
|
+ $data['release_status'] = $register['release_status'];
|
|
|
|
+ $data['generation_quantity'] = $register['generation_quantity'];
|
|
|
|
+ $data['quantity_issued'] = $register['quantity_issued'];
|
|
|
|
+ return $this->registeredAccountsRecord->create($data);
|
|
|
|
+ } catch (QueryException $exception) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 记录账本-内容发布
|
|
|
|
+ * @param $release
|
|
|
|
+ * @return bool
|
|
|
|
+ */
|
|
|
|
+ public function addReleaseRecord($release)
|
|
|
|
+ {
|
|
|
|
+ try {
|
|
|
|
+ $data['virus_behavior_id'] = $release['virus_behavior_id'];
|
|
|
|
+ $data['uid'] = $release['uid'];
|
|
|
|
+ $data['trigger_time'] = $release['trigger_time'];
|
|
|
|
+ $data['related_content_id'] = $release['related_content_id'];
|
|
|
|
+ $data['physical_exertion'] = $release['physical_exertion'];
|
|
|
|
+ $data['trigger_type'] = $release['trigger_type'];
|
|
|
|
+ $data['generation_type'] = $release['generation_type'];
|
|
|
|
+ $data['release_status'] = $release['release_status'];
|
|
|
|
+ $data['generation_quantity'] = $release['generation_quantity'];
|
|
|
|
+ $data['quantity_issued'] = $release['quantity_issued'];
|
|
|
|
+ return $this->releaseRecord->create($data);
|
|
|
|
+ } catch (QueryException $exception) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 记录账本-阅读,转发,点赞,收藏,不喜欢
|
|
|
|
+ * @param $general
|
|
|
|
+ * @return bool
|
|
|
|
+ */
|
|
|
|
+ public function addGeneralRecord($general)
|
|
|
|
+ {
|
|
|
|
+ try {
|
|
|
|
+ $data['virus_behavior_id'] = $general['virus_behavior_id'];
|
|
|
|
+ $data['uid'] = $general['uid'];
|
|
|
|
+ $data['trigger_time'] = $general['trigger_time'];
|
|
|
|
+ $data['related_content_id'] = $general['related_content_id'];
|
|
|
|
+ $data['content_author_id'] = $general['content_author_id'];
|
|
|
|
+ $data['physical_exertion'] = $general['physical_exertion'];
|
|
|
|
+ $data['trigger_type'] = $general['trigger_type'];
|
|
|
|
+ $data['generation_type'] = $general['generation_type'];
|
|
|
|
+ $data['release_status'] = $general['release_status'];
|
|
|
|
+ $data['generation_quantity'] = $general['generation_quantity'];
|
|
|
|
+ $data['quantity_issued'] = $general['quantity_issued'];
|
|
|
|
+ return $this->generalLedgerRecord->create($data);
|
|
|
|
+ } catch (QueryException $exception) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 记录账本-评论
|
|
|
|
+ * @param $comment
|
|
|
|
+ * @return bool
|
|
|
|
+ */
|
|
|
|
+ public function addCommentRecord($comment)
|
|
|
|
+ {
|
|
|
|
+ try {
|
|
|
|
+ $data['virus_behavior_id'] = $comment['virus_behavior_id'];
|
|
|
|
+ $data['uid'] = $comment['uid'];
|
|
|
|
+ $data['upper_trigger_time'] = $comment['upper_trigger_time'];
|
|
|
|
+ $data['related_content_id'] = $comment['related_content_id'];
|
|
|
|
+ $data['content_author_id'] = $comment['content_author_id'];
|
|
|
|
+ $data['superior_commentator_id'] = $comment['superior_commentator_id'];
|
|
|
|
+ $data['physical_exertion'] = $comment['physical_exertion'];
|
|
|
|
+ $data['trigger_type'] = $comment['trigger_type'];
|
|
|
|
+ $data['generation_type'] = $comment['generation_type'];
|
|
|
|
+ $data['release_status'] = $comment['release_status'];
|
|
|
|
+ $data['generation_quantity'] = $comment['generation_quantity'];
|
|
|
|
+ $data['quantity_issued'] = $comment['quantity_issued'];
|
|
|
|
+ return $this->generalLedgerRecord->create($data);
|
|
|
|
+ } catch (QueryException $exception) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 记录账本-绑定手机
|
|
|
|
+ * @param $bindphone
|
|
|
|
+ * @return bool
|
|
|
|
+ */
|
|
|
|
+ public function addBindPhoneRecord($bindphone)
|
|
|
|
+ {
|
|
|
|
+ try {
|
|
|
|
+ $data['virus_behavior_id'] = $bindphone['virus_behavior_id'];
|
|
|
|
+ $data['uid'] = $bindphone['uid'];
|
|
|
|
+ $data['trigger_time'] = $bindphone['trigger_time'];
|
|
|
|
+ $data['phone'] = $bindphone['phone'];
|
|
|
|
+ $data['physical_exertion'] = $bindphone['physical_exertion'];
|
|
|
|
+ $data['trigger_type'] = $bindphone['trigger_type'];
|
|
|
|
+ $data['generation_type'] = $bindphone['generation_type'];
|
|
|
|
+ $data['release_status'] = $bindphone['release_status'];
|
|
|
|
+ $data['generation_quantity'] = $bindphone['generation_quantity'];
|
|
|
|
+ $data['quantity_issued'] = $bindphone['quantity_issued'];
|
|
|
|
+ return $this->bindPhoneRecord->create($data);
|
|
|
|
+ } catch (QueryException $exception) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 记录账本-绑定微信
|
|
|
|
+ * @param $bindwx
|
|
|
|
+ * @return bool
|
|
|
|
+ */
|
|
|
|
+ public function addBindWxRecord($bindwx)
|
|
|
|
+ {
|
|
|
|
+ try {
|
|
|
|
+ $data['virus_behavior_id'] = $bindwx['virus_behavior_id'];
|
|
|
|
+ $data['uid'] = $bindwx['uid'];
|
|
|
|
+ $data['trigger_time'] = $bindwx['trigger_time'];
|
|
|
|
+ $data['weixin'] = $bindwx['weixin'];
|
|
|
|
+ $data['physical_exertion'] = $bindwx['physical_exertion'];
|
|
|
|
+ $data['trigger_type'] = $bindwx['trigger_type'];
|
|
|
|
+ $data['generation_type'] = $bindwx['generation_type'];
|
|
|
|
+ $data['release_status'] = $bindwx['release_status'];
|
|
|
|
+ $data['generation_quantity'] = $bindwx['generation_quantity'];
|
|
|
|
+ $data['quantity_issued'] = $bindwx['quantity_issued'];
|
|
|
|
+ return $this->bindWxRecord->create($data);
|
|
|
|
+ } catch (QueryException $exception) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|