第二阶段完善代理商激活码
This commit is contained in:
39
app/manager/model/ActivationCode.php
Normal file
39
app/manager/model/ActivationCode.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace app\manager\model;
|
||||
|
||||
use think\Model;
|
||||
|
||||
class ActivationCode extends Model
|
||||
{
|
||||
protected $name = 'cursor_activation_codes';
|
||||
|
||||
// 自动写入时间戳
|
||||
protected $autoWriteTimestamp = true;
|
||||
protected $createTime = 'created_at';
|
||||
protected $updateTime = false;
|
||||
|
||||
// 设置字段类型
|
||||
protected $type = [
|
||||
'used_at' => 'datetime',
|
||||
'created_at' => 'datetime',
|
||||
];
|
||||
|
||||
// 获取代理商分配信息
|
||||
public function agentCode()
|
||||
{
|
||||
return $this->hasOne('app\manager\model\AgentCode', 'code_id');
|
||||
}
|
||||
|
||||
// 检查是否已分配给代理商
|
||||
public function isAssigned()
|
||||
{
|
||||
return (bool)$this->agentCode;
|
||||
}
|
||||
|
||||
// 检查是否可用
|
||||
public function isAvailable()
|
||||
{
|
||||
return !$this->is_used && !$this->isAssigned();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user