120 lines
3.4 KiB
PHP
120 lines
3.4 KiB
PHP
<?php
|
|
|
|
namespace app\manystore\model\school;
|
|
|
|
use think\Model;
|
|
|
|
|
|
class Message extends Model
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
// 表名
|
|
protected $name = 'school_message';
|
|
|
|
// 自动写入时间戳字段
|
|
protected $autoWriteTimestamp = 'int';
|
|
|
|
// 定义时间戳字段名
|
|
protected $createTime = 'createtime';
|
|
protected $updateTime = false;
|
|
protected $deleteTime = false;
|
|
|
|
// 追加属性
|
|
protected $append = [
|
|
'platform_text',
|
|
'oper_type_text',
|
|
'to_type_text',
|
|
'status_text',
|
|
'mini_type_text'
|
|
];
|
|
|
|
|
|
|
|
public function getPlatformList()
|
|
{
|
|
return ['admin' => __('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 ? $value : (isset($data['platform']) ? $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\manystore\model\Admin', 'oper_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
}
|
|
|
|
|
|
public function user()
|
|
{
|
|
return $this->belongsTo('app\manystore\model\User', 'to_id', 'id', [], 'LEFT')->setEagerlyType(0);
|
|
}
|
|
}
|