__('Platform admin'), 'user' => __('Platform user'), 'shop' => __('Platform shop')]; } public function getOperTypeList() { return ['admin' => __('Oper_type admin'), 'user' => __('Oper_type user'), 'system' => __('Oper_type system'), 'shop' => __('Oper_type shop')]; } public function getToTypeList() { return ['admin' => __('To_type admin'), 'user' => __('To_type user'), 'system' => __('To_type system'), 'shop' => __('To_type shop')]; } public function getStatusList() { return ['system' => __('Status system'), 'classes' => __('Status classes'), 'order' => __('Status order')]; } public function getMiniTypeList() { return ['order_notice' => __('Mini_type order_notice'), 'classes_auth' => __('Mini_type classes_auth'), 'classes_apply' => __('Mini_type classes_apply'), 'shop_apply' => __('Mini_type shop_apply'), 'classes_order_notice' => __('Mini_type classes_order_notice'), 'user_auth' => __('Mini_type user_auth'), 'aftercare' => __('Mini_type aftercare'), 'other' => __('Mini_type other')]; } public function getPlatformTextAttr($value, $data) { $value = $value ?: ($data['platform'] ?? ''); $valueArr = explode(',', $value); $list = $this->getPlatformList(); return implode(',', array_intersect_key($list, array_flip($valueArr))); } public function getOperTypeTextAttr($value, $data) { $value = $value ? $value : (isset($data['oper_type']) ? $data['oper_type'] : ''); $list = $this->getOperTypeList(); return isset($list[$value]) ? $list[$value] : ''; } public function getToTypeTextAttr($value, $data) { $value = $value ? $value : (isset($data['to_type']) ? $data['to_type'] : ''); $list = $this->getToTypeList(); return isset($list[$value]) ? $list[$value] : ''; } public function getStatusTextAttr($value, $data) { $value = $value ? $value : (isset($data['status']) ? $data['status'] : ''); $list = $this->getStatusList(); return isset($list[$value]) ? $list[$value] : ''; } public function getMiniTypeTextAttr($value, $data) { $value = $value ? $value : (isset($data['mini_type']) ? $data['mini_type'] : ''); $list = $this->getMiniTypeList(); return isset($list[$value]) ? $list[$value] : ''; } protected function setPlatformAttr($value) { return is_array($value) ? implode(',', $value) : $value; } public function admin() { return $this->belongsTo('app\admin\model\Admin', 'oper_id', 'id', [], 'LEFT')->setEagerlyType(0); } public function user() { return $this->belongsTo('app\admin\model\User', 'to_id', 'id', [], 'LEFT')->setEagerlyType(0); } /** 发送站内信 * @param $title 站内信标题 * @param $desc 内容 * @param $mini_type 消息子类型 * @param $to_id 接收者id * @param $to_type 接收者类型 * @param $status 消息大类型 * @param $platform 发送平台 * @param $params 额外参数 * @param $oper_id 发送人id * @param $oper_type 发送人类型 * */ public static function send($title,$desc,$mini_type,$to_id,$to_type="user",$status="system",$platform="user",$params=[],$oper_id=0,$oper_type="system"){ $data = [ 'title' => $title, 'desc' => $desc, 'params' => json_encode($params), 'platform' => $platform, 'oper_id' => $oper_id, 'oper_type' => $oper_type, 'to_id' => $to_id, 'to_type' => $to_type, 'status' => $status, 'mini_type' => $mini_type, ]; $message = new self(); $message->save($data); return $message; } }