116 lines
3.5 KiB
PHP
116 lines
3.5 KiB
PHP
<?php
|
||
|
||
namespace app\models;
|
||
|
||
use Yii;
|
||
use app\models\Model;
|
||
|
||
/**
|
||
* This is the model class for table "{{%feedback}}".
|
||
*
|
||
* @property int $id ID
|
||
* @property int $cx_mch_id 平台商户ID
|
||
* @property int $user_id 用户ID
|
||
* @property int $cat_id 分类ID
|
||
* @property string|null $contact 联系方式:QQ|手机号
|
||
* @property string $content 反馈内容
|
||
* @property string|null $pic_list 反馈图片
|
||
* @property int $created_at 添加时间
|
||
* @property int $updated_at 更新时间
|
||
* @property int $is_delete 是否删除:0=否,1=是
|
||
* @property int $deleted_at 删除时间
|
||
* @property int $review_user_id 处理人ID
|
||
* @property int $review_status 处理状态:0=待处理,1=已处理
|
||
* @property int $review_time 处理时间
|
||
* @property string|null $review_comment 处理意见
|
||
*/
|
||
class Feedback extends \yii\db\ActiveRecord
|
||
{
|
||
const REVIEW_STATUS_WAITTING = 0;
|
||
const REVIEW_STATUS_DONE = 1;
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public static function tableName()
|
||
{
|
||
return '{{%feedback}}';
|
||
}
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function rules()
|
||
{
|
||
return [
|
||
[['contact', 'content', 'pic_list', 'review_comment'], 'trim'],
|
||
[['cx_mch_id', 'cat_id', 'created_at', 'updated_at', 'is_delete', 'deleted_at', 'review_user_id', 'review_status', 'review_time', 'user_id'], 'integer'],
|
||
[['content', 'review_user_id'], 'required'],
|
||
[['pic_list'], 'string'],
|
||
[['contact'], 'string', 'max' => 64],
|
||
[['content', 'review_comment'], 'string', 'max' => 2048],
|
||
];
|
||
}
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function attributeLabels()
|
||
{
|
||
return [
|
||
'id' => 'ID',
|
||
'cx_mch_id' => '平台商户ID',
|
||
'user_id' => '用户ID',
|
||
'cat_id' => '分类ID',
|
||
'contact' => '联系方式:QQ|手机号',
|
||
'content' => '反馈内容',
|
||
'pic_list' => '反馈图片',
|
||
'created_at' => '添加时间',
|
||
'updated_at' => '更新时间',
|
||
'is_delete' => '是否删除:0=否,1=是 ',
|
||
'deleted_at' => '删除时间',
|
||
'review_user_id' => '处理人ID',
|
||
'review_status' => '处理状态:0=待处理,1=已处理',
|
||
'review_time' => '处理时间',
|
||
'review_comment' => '处理意见',
|
||
];
|
||
}
|
||
|
||
public function beforeSave($insert) {
|
||
if(parent::beforeSave($insert)){
|
||
if($this->isNewRecord){
|
||
$this->created_at = time();
|
||
}
|
||
$this->updated_at = time();
|
||
if($this->is_delete == 1)
|
||
$this->deleted_at = time();
|
||
$this->htmlTagFilter();
|
||
return true;
|
||
} else {
|
||
return false;
|
||
}
|
||
}
|
||
|
||
public function htmlTagFilter()
|
||
{
|
||
$this->contact = Model::htmlTagFilter($this->contact);
|
||
$this->content = Model::htmlTagFilter($this->content);
|
||
$this->review_comment = Model::htmlTagFilter($this->review_comment);
|
||
}
|
||
|
||
|
||
public static function reviewStatusLabels()
|
||
{
|
||
return [
|
||
'0' => '待处理',
|
||
'1' => '已处理',
|
||
];
|
||
}
|
||
|
||
public static function getReviewStatus($status)
|
||
{
|
||
$labels = self::reviewStatusLabels();
|
||
return isset($labels[$status]) ? $labels[$status] : "未知";
|
||
}
|
||
}
|