GeoWritings.php
3.0 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2025/10/22
* Time: 17:25
*/
namespace App\Models\Geo;
use App\Models\Base;
use App\Models\ProjectAssociation\ProjectAssociation;
use App\Models\Workchat\MessagePush;
use Illuminate\Support\Facades\Crypt;
/**
* GEO 文章相关
* Class GeoWritings
* @package App\Models\Geo
*/
class GeoWritings extends Base
{
/**
* @var string $table
*/
protected $table = 'gl_project_geo_writings';
/**
* 文章来源类型
*/
const TYPE_AI_CREATE = 1;
const TYPE_SUBMIT = 2;
/**
* 文章状态类型
*/
const STATUS_INIT = 1; # 文章仅保存完成,未推送给客户
const STATUS_RUNNING = 2; # 已推送客户,等待客户确认
const STATUS_FINISH = 3; # 客户已确认完成
const STATUS_AI_WAIT = 7; # 任务提交成功,等待AI生成
const STATUS_AI_RUNNING = 8; # AI生成中
const IS_DEL_FALSE = 0;
const IS_DEL_TRUE = 1;
/**
* @return array
*/
public static function typeMapping()
{
return [
self::TYPE_AI_CREATE => 'AI生成文章',
self::TYPE_SUBMIT => '上传已有文章'
];
}
/**
* 状态隐私
* @return array
*/
public static function statusMapping()
{
return [
self::STATUS_INIT => '已就绪,待推送',
self::STATUS_RUNNING => '已推送,待确认',
self::STATUS_FINISH => '已确认',
self::STATUS_AI_WAIT => '等待生成',
self::STATUS_AI_RUNNING => '生成中',
];
}
/**
* 推送确认消息
* TODO 通过项目ID,时间生成推送token,页面打开后, 回传token解码确定展示项目数据
* @param $project_id
* @return bool
* @throws \Exception
*/
public static function sendConfirmMessage($project_id)
{
$friend = ProjectAssociation::where(['project_id' => $project_id])->first();
if (empty($friend)) {
throw new \Exception('项目未绑定微信群');
}
$content_type = 'Link';
$send_time = now();
$type = MessagePush::TYPE_GEO_CONFIRM;
$friend_id = $friend->friend_id;
$created_at = $updated_at = now();
$param = [
'project_id' => $project_id,
'send_at' => time()
];
$token = Crypt::encrypt($param);
$content_array = [
'title' => "确认核心文章",
'desc' => '确认核心文章',
'size' => 0,
'thumbSize' => 0,
'thumbUrl' => 'https://hub.globalso.com/logocm.png',
'url' => 'https://oa.quanqiusou.cn/public-geo-article-list?token=' . $token
];
$content = json_encode($content_array, JSON_UNESCAPED_UNICODE);
MessagePush::insert(compact('project_id', 'friend_id', 'type', 'content_type', 'content', 'send_time', 'updated_at', 'created_at'));
return true;
}
}