MailLogic.php
3.5 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
<?php
namespace App\Http\Logic\Aside\Mail;
use App\Http\Logic\Aside\BaseLogic;
use App\Models\Mail\Mail as MailModel;
use App\Models\Mail\MailUser;
use App\Models\User\User;
use Illuminate\Support\Facades\DB;
use mysql_xdevapi\Exception;
class MailLogic extends BaseLogic
{
public function __construct()
{
parent::__construct();
$this->model = new MailModel();
$this->param = $this->requestAll;
}
/**
* @remark :列表
* @name :mail_lists
* @author :lyh
* @method :post
* @time :2023/6/21 16:38
*/
public function mail_lists($map,$page,$row,$order = 'created_at',$filed = ['*']){
$lists = $this->model->lists($map,$page,$row,$order,$filed);
if(!empty($lists)){
foreach ($lists['list'] as $k => $v){
$lists['list'][$k]['user_list_name'] = $this->model->getUserListName($v['user_list']);
}
}
return $this->success($lists);
}
/**
* @remark :添加站内信时获取会员列表
* @name :getUser
* @author :lyh
* @method :post
* @time :2023/7/8 9:30
*/
public function getUserList($map){
$userModel = new User();
$lists = $userModel->list($map,'created_at',['id','project_id','name','mobile','created_at']);
return $this->success($lists);
}
/**
* @remark :站内信详情
* @name :mail_info
* @author :lyh
* @method :post
* @time :2023/7/8 9:29
*/
public function mail_info(){
$info = $this->model->read($this->param);
//参数处理
$info['user_list'] = trim($info['user_list'],',');
$info['user_list_name'] = $this->model->getUserListName($info['user_list']);
if($info === false) {
$this->fail('当前数据不存在');
}
return $this->success($info);
}
/**
* @remark :添加站内信
* @name :mail_add
* @author :lyh
* @method :post
* @time :2023/7/8 9:28
*/
public function mail_add(){
//参数处理
if(isset($this->param['user_list']) && !empty($this->param['user_list'])){
$this->param['user_list'] = $this->model->setUserList($this->param['user_list']);
}
$rs = $this->model->add($this->param);
if($rs === false){
$this->fail('添加失败');
}
return $this->success();
}
/**
* @remark :编辑站内信
* @name :mail_edit
* @author :lyh
* @method :post
* @time :2023/7/8 9:27
*/
public function mail_edit(){
//参数处理
if(isset($this->param['user_list']) && !empty($this->param['user_list'])){
$this->param['user_list'] = $this->model->setUserList($this->param['user_list']);
}
$rs = $this->model->edit($this->param,['id'=>$this->param['id']]);
if($rs === false){
$this->fail('编辑失败');
}
return $this->success();
}
/**
* @remark :删除站内信
* @name :mail_del
* @author :lyh
* @method :post
* @time :2023/7/8 9:27
*/
public function mail_del(){
DB::beginTransaction();
try {
$this->model->del(['id'=>['in',$this->param['id']]]);
$mailUserModel = new MailUser();
$mailUserModel->del(['mail_id'=>['in',$this->param['id']]]);
DB::commit();
}catch (Exception $e){
DB::rollBack();
$this->fail('error');
}
return $this->success();
}
}