GeoConfirm.php
4.1 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
/**
* Created by PhpStorm.
* User: zhl
* Date: 2025/10/22
* Time: 17:03
*/
namespace App\Models\Geo;
use App\Models\Base;
use App\Models\Project\DeployBuild;
use App\Models\Project\Project;
use App\Models\Workchat\MessagePush;
/**
* GEO 客户确认相关数据
* Class GeoConfirm
* @package App\Models\Geo
*/
class GeoConfirm extends Base
{
/**
* @var string table
*/
protected $table = 'gl_project_geo_confirm';
/**
* 客户确认类型
*/
const TYPE_TITLE = 1;
const TYPE_KEYWORD = 2;
/**
* 数据状态
*/
const STATUS_INIT = 1; # 初始化数据,仅保存完成
const STATUS_RUNNING = 2; # 已推送客户,等待客户确认
const STATUS_FINISH = 3; # 客户已确认完成
/**
* 客户确认数据类型
* @return array
*/
public static function typeMapping()
{
return [
self::TYPE_TITLE => '文章标题已整理,请查看并确认',
self::TYPE_KEYWORD => '核心关键词问题已整理,请查看并确认'
];
}
/**
* @remark :确认返回数据
* @name :typeDesc
* @author :lyh
* @method :post
* @time :2025/10/31 10:10
*/
public static function typeDesc($num = 10)
{
return [
self::TYPE_TITLE => '需选择确认'.$num.'个文章标题,后续根据您确认的文章标题整理文章内容;如有补充展会、资质证书等资料,可一并提供。',
self::TYPE_KEYWORD => '需选择确认'.$num.'个核心关键词问题,后续根据您确认的核心关键词问题整理文章标题;建议提供展会、资质证书等资料。'
];
}
/**
* 客户确认数据状态
* @return array
*/
public static function statusMapping()
{
return [
self::STATUS_INIT => '初始数据',
self::STATUS_RUNNING => '数据确认中',
self::STATUS_FINISH => '客户已确认'
];
}
/**
* 保存确认数据
* @param $project_id
* @param $type
* @param $confirm
* @param $confirm_num
* @param $confirm_ip
* @return bool
*/
public static function saveConfirm($project_id, $type, $confirm, $confirm_num, $confirm_ip)
{
$data = self::where(compact('project_id', 'type'))->first();
if (empty($data))
return false;
$data->confirm = $confirm;
$data->confirm_ip = $confirm_ip;
$data->confirm_num = $confirm_num;
$data->confirm_at = now();
$data->status = self::STATUS_FINISH;
$data->save();
return $data;
}
/**
* 推送确认消息
* @param $id
* @return bool
*/
public static function sendConfirmMessage($id, $friend_id,$send = 1)
{
$data = self::where(compact('id'))->first();
$project_id = $data->project_id;
$content_type = 'Link';
$send_time = now();
$type = MessagePush::TYPE_GEO_CONFIRM;
$token = uniqid().$friend_id;
$created_at = $updated_at = now();
$projectModel = new Project();
$company = $projectModel->getValue(['id'=>$project_id],'company');
$seo_plan_name = 'GEO';
$content_array = [
'title' => "【{$company} {$seo_plan_name}】".self::typeMapping()[$data->type],
'desc' => self::typeDesc($data->max_num)[$data->type],
'size' => 0,
'thumbSize' => 0,
'thumbUrl' => 'https://hub.globalso.com/logocm.png',
'url' => 'https://oa.quanqiusou.cn/public-geo-confirm?token=' . $token
];
$content = json_encode($content_array, JSON_UNESCAPED_UNICODE);
if($send){
$data->send_at = now();
$data->status = self::STATUS_RUNNING;
MessagePush::insert(compact('project_id', 'friend_id', 'type', 'content_type', 'content', 'send_time', 'updated_at', 'created_at'));
}
// 消息推送, 更新数据
$data->confirm = '';
$data->uniqid = $token;
$data->save();
return $content_array;
}
}