46 lines
1.1 KiB
PHP
46 lines
1.1 KiB
PHP
<?php
|
|||
|
|
|
||
|
|
namespace app\common\service;
|
||
|
|
|
||
|
|
use app\common\model\Messages;
|
||
|
|
use app\common\traits\ServiceTrait;
|
||
|
|
use think\Log;
|
||
|
|
|
||
|
|
class MessageService
|
||
|
|
{
|
||
|
|
use ServiceTrait;
|
||
|
|
|
||
|
|
/** @var Messages */
|
||
|
|
public static $Model = Messages::class;
|
||
|
|
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param $to_user_id
|
||
|
|
* @param $title
|
||
|
|
* @param $content
|
||
|
|
* @param $extra_json
|
||
|
|
* @param $from_user_id
|
||
|
|
* @return mixed
|
||
|
|
* @throws \Exception
|
||
|
|
*/
|
||
|
|
public static function createData($to_user_id, $title, $content, $extra_json = [], $from_user_id = 0)
|
||
|
|
{
|
||
|
|
$data = [
|
||
|
|
'message_type' => CommonService::NO,
|
||
|
|
'from_user_id' => $from_user_id,
|
||
|
|
'to_user_id' => $to_user_id,
|
||
|
|
'title' => $title,
|
||
|
|
'content' => $content,
|
||
|
|
'extra_json' => $extra_json,
|
||
|
|
'is_read' => CommonService::STATUS_OFF,
|
||
|
|
];
|
||
|
|
|
||
|
|
$res = self::create($data);
|
||
|
|
if (!$res) {
|
||
|
|
Log::info(__METHOD__ . '-写入数据失败失败:' . json_encode($data, JSON_UNESCAPED_UNICODE));
|
||
|
|
exception('写入数据失败失败');
|
||
|
|
}
|
||
|
|
|
||
|
|
return $res;
|
||
|
|
}
|
||
|
|
}
|