|
...
|
...
|
@@ -9,6 +9,7 @@ |
|
|
|
|
|
|
|
namespace App\Http\Logic\Aside\Geo;
|
|
|
|
|
|
|
|
use App\Helper\Gpt;
|
|
|
|
use App\Http\Logic\Aside\BaseLogic;
|
|
|
|
use App\Models\Geo\GeoWritings;
|
|
|
|
use App\Models\Geo\GeoWritingsTask;
|
|
...
|
...
|
@@ -29,37 +30,39 @@ class GeoWritingsTaskLogic extends BaseLogic |
|
|
|
* @method :post
|
|
|
|
* @time :2025/10/25 15:13
|
|
|
|
*/
|
|
|
|
public function listWritingTask($map,$page,$row,$order){
|
|
|
|
$data = $this->model->lists($map,$page,$row,$order);
|
|
|
|
public function listWritingTask($map, $page, $row, $order)
|
|
|
|
{
|
|
|
|
$data = $this->model->lists($map, $page, $row, $order);
|
|
|
|
return $this->success($data);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @remark :保存AI文章数据
|
|
|
|
* @name :saveWritingTask
|
|
|
|
* @param :project_id->项目ID;company->公司名称;brand->品牌词;keyword->关键词;prefix->前缀;suffix->后缀;event_title->事件标题;
|
|
|
|
* event_content->事件内容;title->标题;description->描述;footer->结尾引用;img->图片;ai_model->ai_model
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2025/10/25 14:41
|
|
|
|
* @param :project_id->项目ID;company->公司名称;brand->品牌词;keyword->关键词;prefix->前缀;suffix->后缀;event_title->事件标题;
|
|
|
|
* event_content->事件内容;title->标题;description->描述;footer->结尾引用;img->图片;ai_model->ai_model
|
|
|
|
*/
|
|
|
|
public function saveWritingTask(){
|
|
|
|
public function saveWritingTask()
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
if(isset($this->param['id']) &&!empty($this->param['id'])){
|
|
|
|
if (isset($this->param['id']) && !empty($this->param['id'])) {
|
|
|
|
$id = $this->param['id'];
|
|
|
|
$this->model->edit($this->param,['id'=>$id]);
|
|
|
|
}else{
|
|
|
|
$this->model->edit($this->param, ['id' => $id]);
|
|
|
|
} else {
|
|
|
|
//自动保存一条数据
|
|
|
|
$writingModel = new GeoWritings();
|
|
|
|
$this->param['writings_id'] = $writingModel->addReturnId(['project_id'=>$this->param['project_id'],
|
|
|
|
'type'=>$writingModel::TYPE_AI_CREATE,'status'=>$writingModel::STATUS_AI_WAIT,
|
|
|
|
'uniqid'=>md5(uniqid().rand(1, 99999).$this->param['project_id'])]);
|
|
|
|
$this->param['writings_id'] = $writingModel->addReturnId(['project_id' => $this->param['project_id'],
|
|
|
|
'type' => $writingModel::TYPE_AI_CREATE, 'status' => $writingModel::STATUS_AI_WAIT,
|
|
|
|
'uniqid' => md5(uniqid() . rand(1, 99999) . $this->param['project_id'])]);
|
|
|
|
$id = $this->model->addReturnId($this->param);
|
|
|
|
}
|
|
|
|
}catch (\Exception $e){
|
|
|
|
$this->fail('保存数据失败,请联系管理员'.$e->getMessage());
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
$this->fail('保存数据失败,请联系管理员' . $e->getMessage());
|
|
|
|
}
|
|
|
|
return $this->success(['id'=>$id]);
|
|
|
|
return $this->success(['id' => $id]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -71,10 +74,102 @@ class GeoWritingsTaskLogic extends BaseLogic |
|
|
|
*/
|
|
|
|
public function delWritingTask()
|
|
|
|
{
|
|
|
|
$res = $this->model->del(['id'=>['in',$this->param['id']]]);
|
|
|
|
if($res === false){
|
|
|
|
$res = $this->model->del(['id' => ['in', $this->param['id']]]);
|
|
|
|
if ($res === false) {
|
|
|
|
$this->fail('删除失败,请联系管理员');
|
|
|
|
}
|
|
|
|
return $this->success();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Ai请求标题
|
|
|
|
* @return mixed|string
|
|
|
|
* @author Akun
|
|
|
|
* @date 2025/11/24 16:24
|
|
|
|
*/
|
|
|
|
public function sendAiTitle()
|
|
|
|
{
|
|
|
|
$brand = isset($this->param['brand']) && $this->param['brand'] ? $this->param['brand'] : '';
|
|
|
|
$prefix = isset($this->param['prefix']) && $this->param['prefix'] ? $this->param['prefix'] : '';
|
|
|
|
$keyword = isset($this->param['keyword']) && $this->param['keyword'] ? $this->param['keyword'] : '';
|
|
|
|
$suffix = isset($this->param['suffix']) && $this->param['suffix'] ? $this->param['suffix'] : '';
|
|
|
|
$event_content = isset($this->param['event_content']) && $this->param['event_content'] ? $this->param['event_content'] : '';
|
|
|
|
$desc = '帮我写1个有吸引力的英文新闻标题,并确保这个标题在Google上面唯一存在的,只需要回复我标题,不需要别的内容(比如序号、你的提示、寒暄、解释、注释之类的),标题不要超过100字符数。';
|
|
|
|
|
|
|
|
$config_title = [
|
|
|
|
"brand" => "请根据公司品牌词:{$brand}",
|
|
|
|
"keyword" => "和这个公司产品的关键词:{$prefix}{$keyword}{$suffix}",
|
|
|
|
"event_content" => "以及公司参与的事件内容:{$event_content}",
|
|
|
|
"desc" => $desc
|
|
|
|
];
|
|
|
|
foreach ($config_title as $k => $v) {
|
|
|
|
if (empty($$k)) {
|
|
|
|
unset($config_title[$k]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$aiCommand = implode(',', $config_title);
|
|
|
|
$gptHelper = new Gpt();
|
|
|
|
return $gptHelper->openai_chat_qqs($aiCommand);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 组装AI生成文章语句
|
|
|
|
* @author Akun
|
|
|
|
* @date 2025/11/25 10:48
|
|
|
|
*/
|
|
|
|
public function getAiCommand()
|
|
|
|
{
|
|
|
|
$title = isset($this->param['title']) && $this->param['title'] ? $this->param['title'] : '';
|
|
|
|
$description = isset($this->param['description']) && $this->param['description'] ? $this->param['description'] : '';
|
|
|
|
$event_content = isset($this->param['event_content']) && $this->param['event_content'] ? $this->param['event_content'] : '';
|
|
|
|
$keyword = isset($this->param['keyword']) && $this->param['keyword'] ? $this->param['keyword'] : '';
|
|
|
|
$prefix = isset($this->param['prefix']) && $this->param['prefix'] ? $this->param['prefix'] : '';
|
|
|
|
$suffix = isset($this->param['suffix']) && $this->param['suffix'] ? $this->param['suffix'] : '';
|
|
|
|
$footer = isset($this->param['footer']) && $this->param['footer'] ? $this->param['footer'] : '';
|
|
|
|
|
|
|
|
//引言配置
|
|
|
|
$introduction = '给我写一个Press Release引言内容';
|
|
|
|
$industry = $keyword;
|
|
|
|
$character = '只需要1个段落,大约150-200字';
|
|
|
|
$desc = '所有内容一定要用英文,只需要回复我新闻稿引言内容,不需要别的内容(比如序号、你的提示、寒暄、解释、注释之类的)。';
|
|
|
|
$config_introduction = [
|
|
|
|
"title" => "请根据这个文章标题:{$title}",
|
|
|
|
"description" => "并同时参考公司的介绍:{$description}",
|
|
|
|
"event_content" => "以及公司参与的事件内容:{$event_content}",
|
|
|
|
"introduction" => $introduction,
|
|
|
|
"industry" => "引言内容请参考并引用'{$industry}'行业的一些专业数据报告",
|
|
|
|
"character" => $character,
|
|
|
|
"keyword" => "请一定要出现这个关键词'{$prefix}{$keyword}{$suffix}'",
|
|
|
|
'desc' => $desc
|
|
|
|
];
|
|
|
|
foreach ($config_introduction as $ki => $vi) {
|
|
|
|
if (empty($$ki)) {
|
|
|
|
unset($config_introduction[$ki]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$aiCommandIntroduction = implode(',', $config_introduction);
|
|
|
|
|
|
|
|
//正文配置
|
|
|
|
$content = '给我写一篇Press Release正文内容(已经有引言内容了)';
|
|
|
|
$character = '需要 5-6 个大纲,每个大纲需要标题和 1-2 段内容,最后1-2个大纲主要介绍企业的核心优势、主营产品应用场景、主要客户案例,字数大约1000字';
|
|
|
|
$desc = '所有内容一定要用英文,只需要回复我新闻稿正文内容,不需要别的内容(比如序号、你的提示、寒暄、解释、注释之类的)。';
|
|
|
|
$config_content = [
|
|
|
|
"title" => "请根据这个文章标题:{$title}",
|
|
|
|
"description" => "并同时参考公司的介绍:{$description}",
|
|
|
|
"event_content" => "以及公司参与的事件内容:{$event_content}",
|
|
|
|
"content" => $content,
|
|
|
|
"keyword" => "正文内容请参考并引用'{$prefix}{$keyword}{$suffix}'行业的一些专业数据报告",
|
|
|
|
"character" => $character,
|
|
|
|
"footer" => "并最后附带内容:{$footer}",
|
|
|
|
"desc" => $desc
|
|
|
|
];
|
|
|
|
foreach ($config_content as $kc => $vc) {
|
|
|
|
if (empty($$kc)) {
|
|
|
|
unset($config_content[$kc]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$aiCommandMain = implode(',', $config_content);
|
|
|
|
|
|
|
|
return ['command_introduction' => $aiCommandIntroduction, 'command_main' => $aiCommandMain];
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|