60 lines
1.6 KiB
PHP
60 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace app\common\model;
|
|
|
|
use think\Model;
|
|
|
|
/**
|
|
* 客户操作日志模型
|
|
*/
|
|
class QywxCustomerOperationLog extends Model
|
|
{
|
|
protected $table = 'zyt_qywx_customer_operation_log';
|
|
protected $autoWriteTimestamp = true;
|
|
|
|
// 字段类型
|
|
protected $type = [
|
|
'operator_id' => 'integer',
|
|
'staff_id' => 'integer',
|
|
'created_at' => 'datetime',
|
|
];
|
|
|
|
// 隐藏字段
|
|
protected $hidden = [];
|
|
|
|
// 验证规则
|
|
protected $rule = [
|
|
'operation_type' => 'require|max:20',
|
|
'operator_id' => 'require|integer',
|
|
'operator_name' => 'require|max:50',
|
|
];
|
|
|
|
// 错误信息
|
|
protected $message = [
|
|
'operation_type.require' => '操作类型不能为空',
|
|
'operation_type.max' => '操作类型不能超过20个字符',
|
|
'operator_id.require' => '操作人ID不能为空',
|
|
'operator_id.integer' => '操作人ID必须是整数',
|
|
'operator_name.require' => '操作人姓名不能为空',
|
|
'operator_name.max' => '操作人姓名不能超过50个字符',
|
|
];
|
|
|
|
/**
|
|
* @notes 记录操作日志
|
|
*/
|
|
public static function record($operationType, $operatorId, $operatorName, $externalUserId = null, $staffId = null, $content = null)
|
|
{
|
|
$log = new self();
|
|
$log->operation_type = $operationType;
|
|
$log->operator_id = $operatorId;
|
|
$log->operator_name = $operatorName;
|
|
$log->external_user_id = $externalUserId;
|
|
$log->staff_id = $staffId;
|
|
$log->content = $content;
|
|
$log->save();
|
|
return $log;
|
|
}
|
|
}
|