75 lines
2.1 KiB
PHP
75 lines
2.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace app\common\model;
|
|
|
|
use think\Model;
|
|
|
|
/**
|
|
* 客户添加日志模型
|
|
*/
|
|
class QywxCustomerAddLog extends Model
|
|
{
|
|
protected $table = 'zyt_qywx_customer_add_log';
|
|
protected $autoWriteTimestamp = true;
|
|
|
|
// 字段类型
|
|
protected $type = [
|
|
'staff_id' => 'integer',
|
|
'add_time' => 'datetime',
|
|
'created_at' => 'datetime',
|
|
];
|
|
|
|
// 隐藏字段
|
|
protected $hidden = [];
|
|
|
|
// 验证规则
|
|
protected $rule = [
|
|
'external_user_id' => 'require|max:50',
|
|
'staff_id' => 'require|integer',
|
|
'staff_name' => 'require|max:50',
|
|
'add_time' => 'require|datetime',
|
|
'user_info' => 'require',
|
|
'source' => 'require|max:20',
|
|
];
|
|
|
|
// 错误信息
|
|
protected $message = [
|
|
'external_user_id.require' => '外部用户ID不能为空',
|
|
'external_user_id.max' => '外部用户ID不能超过50个字符',
|
|
'staff_id.require' => '员工ID不能为空',
|
|
'staff_id.integer' => '员工ID必须是整数',
|
|
'staff_name.require' => '员工姓名不能为空',
|
|
'staff_name.max' => '员工姓名不能超过50个字符',
|
|
'add_time.require' => '添加时间不能为空',
|
|
'add_time.datetime' => '添加时间格式不正确',
|
|
'user_info.require' => '用户信息不能为空',
|
|
'source.require' => '来源不能为空',
|
|
'source.max' => '来源不能超过20个字符',
|
|
];
|
|
|
|
/**
|
|
* @notes 获取员工加粉统计
|
|
*/
|
|
public static function getStaffAddCount($staffId, $startDate, $endDate)
|
|
{
|
|
return self::where('staff_id', $staffId)
|
|
->where('add_time', '>=', $startDate)
|
|
->where('add_time', '<=', $endDate)
|
|
->count();
|
|
}
|
|
|
|
/**
|
|
* @notes 获取所有员工加粉统计
|
|
*/
|
|
public static function getStaffAddCountList($startDate, $endDate)
|
|
{
|
|
return self::field('staff_id, staff_name, count(*) as add_count')
|
|
->where('add_time', '>=', $startDate)
|
|
->where('add_time', '<=', $endDate)
|
|
->group('staff_id, staff_name')
|
|
->select();
|
|
}
|
|
}
|