WarningTemplate.php
2.6 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
<?php
/**
+-----------------------------------------------------------------------------------------------------------------------
* 短信模板类:各种业务发送短信的模板
+-----------------------------------------------------------------------------------------------------------------------
* PHP version 7
*
* @category App\Sms
* @package App\Sms
* @author Richer <yangzi1028@163.com>
* @date 2020年6月15日,16:08:39
* @copyright 2021-2022 Richer (http://www.Richer.com/)
* @license http://www.Richer.com/ License
* @link http://www.Richer.com/
*/
namespace App\Sms;
use App\Models\Traits\ExpressTrait;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;
/**
* Class Template
*
* @category App\Sms
* @package App\Sms
* @author Richer <yangzi1028@163.com>
* @date 2020年6月15日,16:08:39
* @copyright 2021-2022 Richer (http://www.Richer.com/)
* @license http://www.Richer.com/ License
* @link http://www.Richer.com/
*/
class WarningTemplate
{
use ExpressTrait;
protected $temp_id = 'e72d2ce54c0f44a7a99118507022ed68';
/**
* 获取消息发送的参数
*
* @param Model $model 对象模型
* @param string $target 发送目标
* @param string $operate
* @return array
*/
public function getParams($model, $target = 'user', $operate = 'warning')
{
// 当前用户的配置
$params = [];
switch ($operate) {
case 'warning':
$params = $this->getWarningParams($model, $target);
break;
}
return $params;
}
/**
* @param $model
* @param $target
* @return array
*/
protected function getWarningParams($model, $target)
{
// $room_title = optional($model->village)->title . optional($model->group)->title. optional($model->building)->title . optional($model->room)->title;
$params = [
optional($model->village)->title,
optional($model->group)->title,
optional($model->building)->title ,
optional($model->room)->title,
$model->level_zh,
optional($model->smoke)->number
];
return [
// 'mobile' => $model->user->mobile,
'params' => my_json_encode($params),
// 'params' => my_json_encode([$room_title, $model->level_zh, optional($model->smoke)->number]),
// 'params' => '[\"'.$room_title . '\",\"' . $model->level_zh . '\",\"' . optional($model->smoke)->number. '\"]' ,
'template' => $this->temp_id,
];
}
}