Commit f215014c authored by 安宁's avatar 安宁

增加钉钉机器人提醒

parent 417e7a3c
......@@ -295,10 +295,7 @@ class Task extends CommonModel
];
$result = self::create($data);
// self::update(['sort' => $result['id']], ['id' => $result['id']]);
self::taskHook($memberCode, $data['code'], 'create');
if ($parentCode) {
self::taskHook($memberCode, $parentCode, 'createChild', '', '', 0, '', '', ['taskName' => trim($taskTitle)]);
}
$isExecutor = 0;
$logType = 'inviteMember';
if ($assignTo) {
......@@ -317,6 +314,10 @@ class Task extends CommonModel
TaskTag::setTag($tagCode, $data['code']);
}
}
self::taskHook($memberCode, $data['code'], 'create');
if ($parentCode) {
self::taskHook($memberCode, $parentCode, 'createChild', '', '', 0, '', '', ['taskName' => trim($taskTitle)]);
}
}
//todo 添加任务动态
......@@ -325,7 +326,7 @@ class Task extends CommonModel
} catch (Exception $e) {
Db::rollback();
return error(9, $e->getMessage());
}
}die();
return $this->read($result['code']);
}
......@@ -933,6 +934,5 @@ class Task extends CommonModel
{
$data = ['memberCode' => $memberCode, 'taskCode' => $taskCode, 'remark' => $remark, 'type' => $type, 'content' => $content, 'isComment' => $isComment, 'toMemberCode' => $toMemberCode, 'fileCode' => $fileCode, 'data' => $data, 'tag' => $tag];
Hook::listen($tag, $data);
}
}
......@@ -25,6 +25,7 @@ use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\exception\DbException;
use think\facade\Request;
use think\facade\Log;
class Task
{
......@@ -273,17 +274,17 @@ class Task
//json_encode($task)
$result = $notifyModel->add($notifyData['title'], $notifyData['content'], $notifyData['type'], $data['memberCode'], $taskMember['member_code'], $notifyData['action'], [], $notifyData['terminal'], $notifyData['avatar']);
if (isOpenDingTalkNoticePush()) {
if ($member['dingtalk_userid']) {
$params = [
'msgtype' => "oa",
'oa' => [
'message_url' => 'http://dingtalk.com',
'head' => ['bgcolor' => 'FFBBBBBB', 'text' => '任务动态'],
'body' => ['title' => $notifyData['title'], 'content' => $notifyData['content']],
]
];
$messageDingTalk->sendCorporationMessage($member['dingtalk_userid'], $params);
}
// if ($member['dingtalk_userid']) {
// $params = [
// 'msgtype' => "oa",
// 'oa' => [
// 'message_url' => 'http://dingtalk.com',
// 'head' => ['bgcolor' => 'FFBBBBBB', 'text' => '任务动态'],
// 'body' => ['title' => $notifyData['title'], 'content' => $notifyData['content']],
// ]
// ];
// $messageDingTalk->sendCorporationMessage($member['dingtalk_userid'], $params);
// }
}
if (isOpenMailNoticePush()) {
if (config('mail.open')) {
......@@ -309,6 +310,8 @@ class Task
$messageService->sendToUid($taskMember['member_code'], $socketMessage, $socketAction);
}
}
//发送钉钉消息
$this->dingding('link', $task, $notifyData);
}
}
//通知所有组织内的成员
......@@ -317,4 +320,27 @@ class Task
$messageService->sendToGroup($project['organization_code'], $socketGroupMessage, 'organization:task');
}
}
public function dingding($type, $task, $obj)
{
$ding = new \DingNotice\DingTalk([
"default" => [
'enabled' => true,
'token' => "a4eeb2dc0dd7a3cc627a0e9cff12487b393b667d35d1c3598f3e987536e33e6c",
'timeout' => 2.0,
'ssl_verify' => false,
'secret' => 'SEC216b9359e12f0193a623ec3e4da2d65ce6fb6d29c16cb9f98be29d6b476303ad',
]
]);
$data = '';
if ($type == 'text') {
$ding->at([],true)->text($obj['title']);
} elseif ($type == 'link') {
$title = $obj['title'];
$text = $obj['content'];
$url = config('app.app_host');
$messageUrl = $url.'/index.html#/project/space/task/'.$task['project_code'].'/detail/'.$task['code'];
$ding->link($title, $text, $messageUrl);
}
}
}
......@@ -29,7 +29,8 @@
"firebase/php-jwt": "^5.0",
"phpmailer/phpmailer": "^6.0",
"mingyoung/dingtalk": "^2.3.0",
"zoujingli/ip2region": "^1.0"
"zoujingli/ip2region": "^1.0",
"wangju/ding-notice": "^1.0"
},
"autoload": {
"psr-4": {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment