TicketProject.php
3.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
<?php
namespace App\Models\WorkOrder;
use App\Models\Base;
use App\Models\Manage\Manage;
use App\Models\Manage\ManageHr;
use App\Models\Project\Project;
use App\Models\ProjectAssociation\ProjectAssociation;
use App\Models\Workchat\MessagePush;
use Illuminate\Database\Eloquent\Factories\HasFactory;
class TicketProject extends Base
{
use HasFactory;
protected $table = 'gl_ticket_projects';
public function projectV6()
{
return $this->hasOne(Project::class, 'id', 'table_id')
->select(['id', 'title', 'company', 'is_upgrade' ,'project_type']);
}
// 项目经理
public function pm()
{
return $this->hasOne(ManageHr::class, 'manage_id', 'pm_id')
->where('manage_id', '>', 0)
->select(['manage_id', 'name', 'nickname']);
}
//售后服务经理
public function assm()
{
return $this->hasOne(ManageHr::class, 'manage_id', 'assm_id')
->where('manage_id', '>', 0)
->select(['manage_id', 'name', 'nickname']);
}
// 优化师
public function seom()
{
return $this->hasOne(ManageHr::class, 'manage_id', 'seom_id')
->where('manage_id', '>', 0)
->select(['manage_id', 'name', 'nickname']);
}
/**
* 第一负责人
*/
public function first_engineer()
{
return $this->hasOne(ManageHr::class, 'manage_id', 'engineer_id')
->where('manage_id', '>', 0)
->select(['manage_id', 'name', 'nickname']);
}
/**
* 绑定的企微群
*/
public function association()
{
return $this->hasOne(ProjectAssociation::class, 'project_id', 'table_id')
->where('status', 1)
->where('binding_app', ProjectAssociation::ENTERPRISE_WECHAT)
->select(['id', 'project_id', 'friend_id', 'binding_app']);
}
/**
* @return void
* 企微群推送工单消息
*/
public function pushWechatGroupMsg($desc="可提交新的工单、查询工单进度、AI会同步通知售后人员!")
{
if (!empty($this->wechat_group_id))
{
$message_push = new MessagePush();
$message_push->project_id = $this->table_id;
$message_push->friend_id = $this->wechat_group_id;
$message_push->content_type = 'Link';
$message_push->content = json_encode([
'title' => "AI协同工单 - " . $this->company_name,
'desc' => $desc,
'size' => 0,
'thumbSize' => 0,
'thumbUrl' => 'https://hub.globalso.com/logocm.png',
'url' => 'https://oa.quanqiusou.cn/afterorder?project_id='.$this->uuid
], JSON_UNESCAPED_UNICODE);
$message_push->send_time = now();
$message_push->type = MessagePush::TYPE_TICKET;
$message_push->save();
}
}
public function getTeam()
{
return ManageHr::whereIn('manage_id', json_decode($this->team, true))
->where('manage_id', '>', 0)
->select(['manage_id', 'name', 'nickname', 'mobile'])->get()->toArray();
}
}