Files
CKB-Interface/application/store/model/UserFlowPackageModel.php
2026-03-24 10:39:16 +08:00

34 lines
753 B
PHP

<?php
namespace app\store\model;
use think\Model;
/**
* 用户流量套餐模型
*/
class UserFlowPackageModel extends Model
{
protected $name = 'user_flow_package';
/**
* 获取用户当前有效的流量套餐
*
* @param int $userId 用户ID
* @return array|null 用户套餐信息
*/
public static function getUserActivePackage($userId)
{
if (empty($userId)) {
return null;
}
return self::where('userId', $userId)
->where('status', 1) // 1表示有效
->where('expireTime', '>', time()) // 未过期
->order('expireTime', 'asc') // 按到期时间排序,最先到期的排在前面
->find();
}
}