hy-farm/muchang/common/modules/sign/vo/SignContinueGift.php
2026-05-29 19:54:56 +08:00

75 lines
1.9 KiB
PHP

<?php
namespace common\modules\sign\vo;
use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord;
/**
*
* CREATE TABLE `sign_continue_gift` (
* `id` int(11) NOT NULL AUTO_INCREMENT,
* `user_id` int(11) NOT NULL,
* `week` varchar(45) NOT NULL COMMENT '周一时间,标记每周',
* `count` varchar(45) NOT NULL COMMENT '连续几天奖励',
* `created_at` int(11) DEFAULT NULL,
* `updated_at` int(11) DEFAULT NULL,
* PRIMARY KEY (`id`),
* KEY `user_id` (`user_id`),
* KEY `week` (`week`),
* KEY `count` (`count`)
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='连续签到奖励领取记录'
*/
/**
* 连续签到奖励领取记录
* @property int $id
* @property int $user_id
* @property string $week //周一时间,标记每周
* @property int $count //连续几天奖励
* @property int $created_at
* @property int $updated_at
*/
class SignContinueGift extends ActiveRecord
{
public function behaviors()
{
return [
TimestampBehavior::className(),
];
}
public function rules()
{
return [
['id', 'default', 'value' => 0],
['user_id', 'required'],
['user_id', 'exist', 'targetClass' => '\common\models\User', 'targetAttribute' => 'id'],
['week', 'default', 'value' => ''],
['count', 'default', 'value' => 0],
['created_at', 'default', 'value' => 0],
['updated_at', 'default', 'value' => 0],
];
}
public static function findByUserIDAndWeekAndCount($userID, $week, $count)
{
return self::findOne(['user_id' => $userID, 'week' => $week, 'count' => $count]);
}
/**
* @param $userID
* @param $week
* @return static[]
*/
public static function findAllByUserIDAndWeek($userID, $week)
{
return self::findAll(['user_id' => $userID, 'week' => $week]);
}
}