|
@@ -9,6 +9,7 @@ |
|
@@ -9,6 +9,7 @@ |
|
9
|
|
9
|
|
|
10
|
namespace App\Http\Logic\Aside\Geo;
|
10
|
namespace App\Http\Logic\Aside\Geo;
|
|
11
|
|
11
|
|
|
|
|
12
|
+use App\Helper\Gpt;
|
|
12
|
use App\Http\Logic\Aside\BaseLogic;
|
13
|
use App\Http\Logic\Aside\BaseLogic;
|
|
13
|
use App\Models\Geo\GeoWritings;
|
14
|
use App\Models\Geo\GeoWritings;
|
|
14
|
use App\Models\Geo\GeoWritingsTask;
|
15
|
use App\Models\Geo\GeoWritingsTask;
|
|
@@ -29,37 +30,39 @@ class GeoWritingsTaskLogic extends BaseLogic |
|
@@ -29,37 +30,39 @@ class GeoWritingsTaskLogic extends BaseLogic |
|
29
|
* @method :post
|
30
|
* @method :post
|
|
30
|
* @time :2025/10/25 15:13
|
31
|
* @time :2025/10/25 15:13
|
|
31
|
*/
|
32
|
*/
|
|
32
|
- public function listWritingTask($map,$page,$row,$order){
|
|
|
|
33
|
- $data = $this->model->lists($map,$page,$row,$order);
|
33
|
+ public function listWritingTask($map, $page, $row, $order)
|
|
|
|
34
|
+ {
|
|
|
|
35
|
+ $data = $this->model->lists($map, $page, $row, $order);
|
|
34
|
return $this->success($data);
|
36
|
return $this->success($data);
|
|
35
|
}
|
37
|
}
|
|
36
|
|
38
|
|
|
37
|
/**
|
39
|
/**
|
|
38
|
* @remark :保存AI文章数据
|
40
|
* @remark :保存AI文章数据
|
|
39
|
* @name :saveWritingTask
|
41
|
* @name :saveWritingTask
|
|
|
|
42
|
+ * @param :project_id->项目ID;company->公司名称;brand->品牌词;keyword->关键词;prefix->前缀;suffix->后缀;event_title->事件标题;
|
|
|
|
43
|
+ * event_content->事件内容;title->标题;description->描述;footer->结尾引用;img->图片;ai_model->ai_model
|
|
40
|
* @author :lyh
|
44
|
* @author :lyh
|
|
41
|
* @method :post
|
45
|
* @method :post
|
|
42
|
* @time :2025/10/25 14:41
|
46
|
* @time :2025/10/25 14:41
|
|
43
|
- * @param :project_id->项目ID;company->公司名称;brand->品牌词;keyword->关键词;prefix->前缀;suffix->后缀;event_title->事件标题;
|
|
|
|
44
|
- * event_content->事件内容;title->标题;description->描述;footer->结尾引用;img->图片;ai_model->ai_model
|
|
|
|
45
|
*/
|
47
|
*/
|
|
46
|
- public function saveWritingTask(){
|
48
|
+ public function saveWritingTask()
|
|
|
|
49
|
+ {
|
|
47
|
try {
|
50
|
try {
|
|
48
|
- if(isset($this->param['id']) &&!empty($this->param['id'])){
|
51
|
+ if (isset($this->param['id']) && !empty($this->param['id'])) {
|
|
49
|
$id = $this->param['id'];
|
52
|
$id = $this->param['id'];
|
|
50
|
- $this->model->edit($this->param,['id'=>$id]);
|
|
|
|
51
|
- }else{
|
53
|
+ $this->model->edit($this->param, ['id' => $id]);
|
|
|
|
54
|
+ } else {
|
|
52
|
//自动保存一条数据
|
55
|
//自动保存一条数据
|
|
53
|
$writingModel = new GeoWritings();
|
56
|
$writingModel = new GeoWritings();
|
|
54
|
- $this->param['writings_id'] = $writingModel->addReturnId(['project_id'=>$this->param['project_id'],
|
|
|
|
55
|
- 'type'=>$writingModel::TYPE_AI_CREATE,'status'=>$writingModel::STATUS_AI_WAIT,
|
|
|
|
56
|
- 'uniqid'=>md5(uniqid().rand(1, 99999).$this->param['project_id'])]);
|
57
|
+ $this->param['writings_id'] = $writingModel->addReturnId(['project_id' => $this->param['project_id'],
|
|
|
|
58
|
+ 'type' => $writingModel::TYPE_AI_CREATE, 'status' => $writingModel::STATUS_AI_WAIT,
|
|
|
|
59
|
+ 'uniqid' => md5(uniqid() . rand(1, 99999) . $this->param['project_id'])]);
|
|
57
|
$id = $this->model->addReturnId($this->param);
|
60
|
$id = $this->model->addReturnId($this->param);
|
|
58
|
}
|
61
|
}
|
|
59
|
- }catch (\Exception $e){
|
|
|
|
60
|
- $this->fail('保存数据失败,请联系管理员'.$e->getMessage());
|
62
|
+ } catch (\Exception $e) {
|
|
|
|
63
|
+ $this->fail('保存数据失败,请联系管理员' . $e->getMessage());
|
|
61
|
}
|
64
|
}
|
|
62
|
- return $this->success(['id'=>$id]);
|
65
|
+ return $this->success(['id' => $id]);
|
|
63
|
}
|
66
|
}
|
|
64
|
|
67
|
|
|
65
|
/**
|
68
|
/**
|
|
@@ -71,10 +74,102 @@ class GeoWritingsTaskLogic extends BaseLogic |
|
@@ -71,10 +74,102 @@ class GeoWritingsTaskLogic extends BaseLogic |
|
71
|
*/
|
74
|
*/
|
|
72
|
public function delWritingTask()
|
75
|
public function delWritingTask()
|
|
73
|
{
|
76
|
{
|
|
74
|
- $res = $this->model->del(['id'=>['in',$this->param['id']]]);
|
|
|
|
75
|
- if($res === false){
|
77
|
+ $res = $this->model->del(['id' => ['in', $this->param['id']]]);
|
|
|
|
78
|
+ if ($res === false) {
|
|
76
|
$this->fail('删除失败,请联系管理员');
|
79
|
$this->fail('删除失败,请联系管理员');
|
|
77
|
}
|
80
|
}
|
|
78
|
return $this->success();
|
81
|
return $this->success();
|
|
79
|
}
|
82
|
}
|
|
|
|
83
|
+
|
|
|
|
84
|
+ /**
|
|
|
|
85
|
+ * Ai请求标题
|
|
|
|
86
|
+ * @return mixed|string
|
|
|
|
87
|
+ * @author Akun
|
|
|
|
88
|
+ * @date 2025/11/24 16:24
|
|
|
|
89
|
+ */
|
|
|
|
90
|
+ public function sendAiTitle()
|
|
|
|
91
|
+ {
|
|
|
|
92
|
+ $brand = isset($this->param['brand']) && $this->param['brand'] ? $this->param['brand'] : '';
|
|
|
|
93
|
+ $prefix = isset($this->param['prefix']) && $this->param['prefix'] ? $this->param['prefix'] : '';
|
|
|
|
94
|
+ $keyword = isset($this->param['keyword']) && $this->param['keyword'] ? $this->param['keyword'] : '';
|
|
|
|
95
|
+ $suffix = isset($this->param['suffix']) && $this->param['suffix'] ? $this->param['suffix'] : '';
|
|
|
|
96
|
+ $event_content = isset($this->param['event_content']) && $this->param['event_content'] ? $this->param['event_content'] : '';
|
|
|
|
97
|
+ $desc = '帮我写1个有吸引力的英文新闻标题,并确保这个标题在Google上面唯一存在的,只需要回复我标题,不需要别的内容(比如序号、你的提示、寒暄、解释、注释之类的),标题不要超过100字符数。';
|
|
|
|
98
|
+
|
|
|
|
99
|
+ $config_title = [
|
|
|
|
100
|
+ "brand" => "请根据公司品牌词:{$brand}",
|
|
|
|
101
|
+ "keyword" => "和这个公司产品的关键词:{$prefix}{$keyword}{$suffix}",
|
|
|
|
102
|
+ "event_content" => "以及公司参与的事件内容:{$event_content}",
|
|
|
|
103
|
+ "desc" => $desc
|
|
|
|
104
|
+ ];
|
|
|
|
105
|
+ foreach ($config_title as $k => $v) {
|
|
|
|
106
|
+ if (empty($$k)) {
|
|
|
|
107
|
+ unset($config_title[$k]);
|
|
|
|
108
|
+ }
|
|
|
|
109
|
+ }
|
|
|
|
110
|
+ $aiCommand = implode(',', $config_title);
|
|
|
|
111
|
+ $gptHelper = new Gpt();
|
|
|
|
112
|
+ return $gptHelper->openai_chat_qqs($aiCommand);
|
|
|
|
113
|
+ }
|
|
|
|
114
|
+
|
|
|
|
115
|
+ /**
|
|
|
|
116
|
+ * 组装AI生成文章语句
|
|
|
|
117
|
+ * @author Akun
|
|
|
|
118
|
+ * @date 2025/11/25 10:48
|
|
|
|
119
|
+ */
|
|
|
|
120
|
+ public function getAiCommand()
|
|
|
|
121
|
+ {
|
|
|
|
122
|
+ $title = isset($this->param['title']) && $this->param['title'] ? $this->param['title'] : '';
|
|
|
|
123
|
+ $description = isset($this->param['description']) && $this->param['description'] ? $this->param['description'] : '';
|
|
|
|
124
|
+ $event_content = isset($this->param['event_content']) && $this->param['event_content'] ? $this->param['event_content'] : '';
|
|
|
|
125
|
+ $keyword = isset($this->param['keyword']) && $this->param['keyword'] ? $this->param['keyword'] : '';
|
|
|
|
126
|
+ $prefix = isset($this->param['prefix']) && $this->param['prefix'] ? $this->param['prefix'] : '';
|
|
|
|
127
|
+ $suffix = isset($this->param['suffix']) && $this->param['suffix'] ? $this->param['suffix'] : '';
|
|
|
|
128
|
+ $footer = isset($this->param['footer']) && $this->param['footer'] ? $this->param['footer'] : '';
|
|
|
|
129
|
+
|
|
|
|
130
|
+ //引言配置
|
|
|
|
131
|
+ $introduction = '给我写一个Press Release引言内容';
|
|
|
|
132
|
+ $industry = $keyword;
|
|
|
|
133
|
+ $character = '只需要1个段落,大约150-200字';
|
|
|
|
134
|
+ $desc = '所有内容一定要用英文,只需要回复我新闻稿引言内容,不需要别的内容(比如序号、你的提示、寒暄、解释、注释之类的)。';
|
|
|
|
135
|
+ $config_introduction = [
|
|
|
|
136
|
+ "title" => "请根据这个文章标题:{$title}",
|
|
|
|
137
|
+ "description" => "并同时参考公司的介绍:{$description}",
|
|
|
|
138
|
+ "event_content" => "以及公司参与的事件内容:{$event_content}",
|
|
|
|
139
|
+ "introduction" => $introduction,
|
|
|
|
140
|
+ "industry" => "引言内容请参考并引用'{$industry}'行业的一些专业数据报告",
|
|
|
|
141
|
+ "character" => $character,
|
|
|
|
142
|
+ "keyword" => "请一定要出现这个关键词'{$prefix}{$keyword}{$suffix}'",
|
|
|
|
143
|
+ 'desc' => $desc
|
|
|
|
144
|
+ ];
|
|
|
|
145
|
+ foreach ($config_introduction as $ki => $vi) {
|
|
|
|
146
|
+ if (empty($$ki)) {
|
|
|
|
147
|
+ unset($config_introduction[$ki]);
|
|
|
|
148
|
+ }
|
|
|
|
149
|
+ }
|
|
|
|
150
|
+ $aiCommandIntroduction = implode(',', $config_introduction);
|
|
|
|
151
|
+
|
|
|
|
152
|
+ //正文配置
|
|
|
|
153
|
+ $content = '给我写一篇Press Release正文内容(已经有引言内容了)';
|
|
|
|
154
|
+ $character = '需要 5-6 个大纲,每个大纲需要标题和 1-2 段内容,最后1-2个大纲主要介绍企业的核心优势、主营产品应用场景、主要客户案例,字数大约1000字';
|
|
|
|
155
|
+ $desc = '所有内容一定要用英文,只需要回复我新闻稿正文内容,不需要别的内容(比如序号、你的提示、寒暄、解释、注释之类的)。';
|
|
|
|
156
|
+ $config_content = [
|
|
|
|
157
|
+ "title" => "请根据这个文章标题:{$title}",
|
|
|
|
158
|
+ "description" => "并同时参考公司的介绍:{$description}",
|
|
|
|
159
|
+ "event_content" => "以及公司参与的事件内容:{$event_content}",
|
|
|
|
160
|
+ "content" => $content,
|
|
|
|
161
|
+ "keyword" => "正文内容请参考并引用'{$prefix}{$keyword}{$suffix}'行业的一些专业数据报告",
|
|
|
|
162
|
+ "character" => $character,
|
|
|
|
163
|
+ "footer" => "并最后附带内容:{$footer}",
|
|
|
|
164
|
+ "desc" => $desc
|
|
|
|
165
|
+ ];
|
|
|
|
166
|
+ foreach ($config_content as $kc => $vc) {
|
|
|
|
167
|
+ if (empty($$kc)) {
|
|
|
|
168
|
+ unset($config_content[$kc]);
|
|
|
|
169
|
+ }
|
|
|
|
170
|
+ }
|
|
|
|
171
|
+ $aiCommandMain = implode(',', $config_content);
|
|
|
|
172
|
+
|
|
|
|
173
|
+ return ['command_introduction' => $aiCommandIntroduction, 'command_main' => $aiCommandMain];
|
|
|
|
174
|
+ }
|
|
80
|
} |
175
|
} |