| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- /**
- *------Create thems Model------
- *------SCWPHP Version 1.0.0------
- *------Dev Model Jions------
- *------Create Time 2017-06-21 06:03:42------
- */
- namespace App\Commons\Model;
- use \System\Model;
- class Message extends Model
- {
- public $timestamps = false;
- protected $table = 'message';
- //lm("message",'commons')->updateMessage();
- function updateMessage($sender, $reciver, $title, $content, $type)
- {
- $data['add_time'] = date ('Y-m-d H:i:s');
- $data['formname'] = $sender;
- $data['toname'] = $reciver;
- $data['title'] = $title;
- $data['type'] = $type;
- $data['content'] = $content;
- //普通消息
- if ($data['type'] == 2) {
- $dataName = explode (',', $data['toname']);
- foreach ($dataName as $v) {
- $data['toname'] = $v;
- $this->addNotice ($data);
- }
- }
- //系统消息
- if ($data['type'] == 1) {
- $data['formname'] = 'system';
- $data['toname'] = 'all';
- $this->addNotice ($data);
- }
- //系统通知
- if ($data['type'] == 3) {
- $data['formname'] = 'notice';
- $data['toname'] = 'all';
- $this->addNotice ($data);
- }
- //系统通知
- if ($data['type'] == 4) {
- $data['formname'] = 'admin';
- $data['toname'] = 'admin_all';
- $this->addNotice ($data);
- }
- }
- //添加公告数据
- function addNotice($data)
- {
- $res = lm ('message', 'Commons')->insert ($data);
- if (!$res) {
- return -6030001222;
- }
- }
- public function add($title, $content, $from, $to, $type = 1, $addStatus = 2)
- {
- $data = ['title' => $title,
- 'content' => $content,
- 'formname' => $from,
- 'toname' => $to,
- 'add_time' => date ('Y-m-d H:i:s'),
- 'type' => $type,
- 'add_status' => $addStatus
- ];
- return self::insert ($data);
- }
- }
|