第二阶段完善代理商激活码

This commit is contained in:
huangzhenpc
2025-02-12 10:45:49 +08:00
parent 46b14149c9
commit abfa783907
23 changed files with 2541 additions and 0 deletions

View 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();
}
}