|
...
|
...
|
@@ -5,12 +5,15 @@ namespace App\Http\Logic\Bside\Product; |
|
|
|
use App\Exceptions\BsideGlobalException;
|
|
|
|
use App\Helper\Arr;
|
|
|
|
use App\Helper\Common;
|
|
|
|
use App\Helper\Gpt;
|
|
|
|
use App\Http\Logic\Bside\BaseLogic;
|
|
|
|
use App\Models\Ai\AiCommand;
|
|
|
|
use App\Models\Com\NoticeLog;
|
|
|
|
use App\Models\News\News;
|
|
|
|
use App\Models\Product\Keyword;
|
|
|
|
use App\Models\Product\KeywordRelated;
|
|
|
|
use App\Models\Product\Product;
|
|
|
|
use App\Models\Project\AggregateKeywordComment;
|
|
|
|
use App\Models\RouteMap\RouteMap;
|
|
|
|
use App\Models\User\User;
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
...
|
...
|
@@ -345,4 +348,46 @@ class KeywordLogic extends BaseLogic |
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存数据
|
|
|
|
* @name :sendComment
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/6/9 11:19
|
|
|
|
*/
|
|
|
|
public function sendComment()
|
|
|
|
{
|
|
|
|
$aiCommonModel = new AiCommand();
|
|
|
|
$info = $aiCommonModel->read(['key' => 'tag_comment','project_id'=>$this->user['project_id']]);
|
|
|
|
if($info === false){
|
|
|
|
$info = $aiCommonModel->read(['key' => 'tag_comment']);
|
|
|
|
$info['ai'] = str_replace('50', $this->param['count'], $info['ai']);
|
|
|
|
}
|
|
|
|
$text = Gpt::instance()->openai_chat_qqs($info['ai']);
|
|
|
|
$text = Common::deal_keywords($text);
|
|
|
|
preg_match_all('/\{[^{}]*\}/', $text, $matches);
|
|
|
|
$data = [];
|
|
|
|
if (!empty($text)) {
|
|
|
|
foreach ($matches[0] as $item) {
|
|
|
|
$item = str_replace("'", '"', $item);
|
|
|
|
// 解码成 PHP 关联数组
|
|
|
|
$item = json_decode($item, true);
|
|
|
|
if (!isset($item['name']) || !isset($item['comment'])) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$data[] = [
|
|
|
|
'nickname' => $item['name'],
|
|
|
|
'text' => $item['comment'],
|
|
|
|
'project_id' => $this->user['project_id'],
|
|
|
|
'type' => 1,
|
|
|
|
'uid' => 0,
|
|
|
|
'created_at' => date('Y-m-d H:i:s'),
|
|
|
|
'updated_at' => date('Y-m-d H:i:s')
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$keywordCommonModel = new AggregateKeywordComment();
|
|
|
|
$keywordCommonModel->insertAll($data);
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|