cxgj/models/common/msg/CommonSysMsgEditForm.php
2023-11-27 09:45:13 +08:00

82 lines
2.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?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("保存成功");
}
}