117 lines
4.2 KiB
PHP
117 lines
4.2 KiB
PHP
<?php
|
||
|
||
namespace app\models;
|
||
|
||
use Yii;
|
||
use app\models\Model;
|
||
|
||
/**
|
||
* This is the model class for table "{{%order_comments}}".
|
||
*
|
||
* @property int $id ID
|
||
* @property int $cx_mch_id 平台商家ID
|
||
* @property int $order_id 订单ID
|
||
* @property int $order_detail_id 订单详情ID
|
||
* @property int $user_id 用户ID
|
||
* @property int $score 评分:1=差评,2=中评,3=好
|
||
* @property string $content 评价内容
|
||
* @property string $pic_urls 评价图片
|
||
* @property int $is_show 是否显示:0=不显示,1=显示
|
||
* @property int $is_virtual 是否虚拟用户
|
||
* @property string $virtual_user 虚拟用户名
|
||
* @property string $virtual_avatar 虚拟头像
|
||
* @property int $virtual_time 虚拟评价时间
|
||
* @property int $goods_id 商品ID
|
||
* @property int $goods_hub_id 商品库ID
|
||
* @property string $plugin_sign 插件标识
|
||
* @property string $reply_content 商家回复内容
|
||
* @property int $created_at 添加时间
|
||
* @property int $updated_at 更新时间
|
||
* @property int $deleted_at 删除时间
|
||
* @property int $is_delete 是否删除:0=否,1=是
|
||
* @property int $is_anonymous 是否匿名:0=否,1=是
|
||
* @property int $is_top 是否置顶:0=否,1=是
|
||
* @property string|null $goods_attr_info 商品信息
|
||
* @property int $attr_id 规格
|
||
*/
|
||
class OrderComments extends \yii\db\ActiveRecord
|
||
{
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public static function tableName()
|
||
{
|
||
return '{{%order_comments}}';
|
||
}
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function rules()
|
||
{
|
||
return [
|
||
[['content', 'pic_urls', 'reply_content', 'goods_attr_info', 'virtual_user', 'plugin_sign', 'virtual_avatar'], 'trim'],
|
||
[['cx_mch_id', 'order_id', 'order_detail_id', 'user_id', 'score', 'is_show', 'is_virtual', 'virtual_time', 'goods_id', 'goods_hub_id', 'created_at', 'updated_at', 'deleted_at', 'is_delete', 'is_anonymous', 'is_top', 'attr_id'], 'integer'],
|
||
[['order_id', 'order_detail_id', 'user_id', 'score', 'content', 'pic_urls', 'goods_hub_id', 'reply_content', 'created_at', 'updated_at', 'deleted_at'], 'required'],
|
||
[['content', 'pic_urls', 'reply_content', 'goods_attr_info'], 'string'],
|
||
[['virtual_user', 'plugin_sign'], 'string', 'max' => 255],
|
||
[['virtual_avatar'], 'string', 'max' => 2048],
|
||
];
|
||
}
|
||
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function attributeLabels()
|
||
{
|
||
return [
|
||
'id' => 'ID',
|
||
'cx_mch_id' => '平台商家ID',
|
||
'order_id' => '订单ID',
|
||
'order_detail_id' => '订单详情ID',
|
||
'user_id' => '用户ID',
|
||
'score' => '评分:1=差评,2=中评,3=好',
|
||
'content' => '评价内容',
|
||
'pic_urls' => '评价图片',
|
||
'is_show' => '是否显示:0=不显示,1=显示',
|
||
'is_virtual' => '是否虚拟用户',
|
||
'virtual_user' => '虚拟用户名',
|
||
'virtual_avatar' => '虚拟头像',
|
||
'virtual_time' => '虚拟评价时间',
|
||
'goods_id' => '商品ID',
|
||
'goods_hub_id' => '商品库ID',
|
||
'plugin_sign' => '插件标识',
|
||
'reply_content' => '商家回复内容',
|
||
'created_at' => '添加时间',
|
||
'updated_at' => '更新时间',
|
||
'deleted_at' => '删除时间',
|
||
'is_delete' => '是否删除:0=否,1=是',
|
||
'is_anonymous' => '是否匿名:0=否,1=是',
|
||
'is_top' => '是否置顶:0=否,1=是',
|
||
'goods_attr_info' => '商品信息',
|
||
'attr_id' => '规格',
|
||
];
|
||
}
|
||
|
||
|
||
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->content = Model::htmlTagFilter($this->content);
|
||
}
|
||
}
|