82 lines
2.2 KiB
PHP
82 lines
2.2 KiB
PHP
<?php
|
||
|
||
/**
|
||
* @author Any
|
||
* @description KISS
|
||
* @date 2021年9月28日
|
||
* @version 1.0.0
|
||
*
|
||
* _____LOG_____
|
||
*
|
||
*/
|
||
namespace app\models\common\msg;
|
||
|
||
use app\models\msg\SysMsg;
|
||
use app\models\Model;
|
||
use app\components\SiteHelper;
|
||
|
||
|
||
class CommonSysMsgEditForm extends Model
|
||
{
|
||
public $type;
|
||
public $title;
|
||
public $content;
|
||
public $is_richtext;
|
||
public $status;
|
||
|
||
public $to_user_id;
|
||
public $order_id;
|
||
public $cx_mch_id;
|
||
public $model;
|
||
|
||
|
||
public function rules()
|
||
{
|
||
return [
|
||
[['title', 'content'], 'trim'],
|
||
[['title', 'content'], 'string'],
|
||
[['type', 'is_richtext', 'status', 'to_user_id', 'order_id', 'cx_mch_id'], 'integer'],
|
||
[['is_richtext', 'to_user_id', 'order_id'], 'default', 'value' => 0],
|
||
[['model'], 'safe'],
|
||
[['type', 'title', 'content', 'is_richtext', 'status', 'cx_mch_id', 'model'], 'required'],
|
||
];
|
||
}
|
||
|
||
public function attributeLabels()
|
||
{
|
||
return [
|
||
'cx_mch_id' => '平台商户ID',
|
||
'type' => '消息类型',
|
||
'to_user_id' => '接收用户:0=所有用户',
|
||
'title' => '标题',
|
||
'is_richtext' => '是否富文本:0=否,1=是',
|
||
'content' => '消息内容',
|
||
'status' => '状态:0=草稿,1=已发布',
|
||
'order_id' => '订单ID',
|
||
];
|
||
}
|
||
|
||
public function save()
|
||
{
|
||
if(!$this->validate()){
|
||
return $this->getModelError();
|
||
}
|
||
if($this->model->isNewRecord){
|
||
$this->model->cx_mch_id = $this->cx_mch_id;
|
||
$this->model->is_delete = 0;
|
||
$this->model->type = $this->type;
|
||
}
|
||
$this->model->to_user_id = $this->to_user_id;
|
||
$this->model->title = $this->title;
|
||
$this->model->is_richtext = $this->is_richtext;
|
||
$this->model->content = $this->content;
|
||
$this->model->status = $this->status;
|
||
$this->model->order_id = $this->order_id;
|
||
if(!$this->model->save()){
|
||
return $this->getModelError($this->model);
|
||
}
|
||
return $this->apiReturnSuccess("保存成功");
|
||
}
|
||
}
|
||
|