// +---------------------------------------------------------------------- namespace App\Services; use App\Models\ChatMessageModel; use App\Models\ConfigModel; /** * 聊天-服务类 * Class ChatMessageService * @package App\Services */ class ChatMessageService extends BaseService { // 静态对象 protected static $instance = null; /** * 构造函数 * ChatMessageService constructor. */ public function __construct() { $this->model = new ChatMessageModel(); } /** * 静态入口 * @return static|null */ public static function make(){ if(!self::$instance){ self::$instance = (new static()); } return self::$instance; } /** * 聊天对话窗口唯一KEY * @param $fromUid * @param $toUid * @return string */ public function getChatKey($fromUid, $toUid) { $chatKeys = [$fromUid, $toUid]; asort($chatKeys); return implode('', $chatKeys); } /** * 推送保存消息,如订单消息 * @param $data 消息数据 * @return int|number */ public function pushMessage($data) { return $this->model->edit($data); } }