97 lines
2.4 KiB
PHP
97 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace common\modules\systemlog;
|
|
|
|
use yii\behaviors\TimestampBehavior;
|
|
use yii\db\ActiveRecord;
|
|
|
|
/**
|
|
*
|
|
* CREATE TABLE `ch_system_log` (
|
|
* `id` int(11) NOT NULL AUTO_INCREMENT,
|
|
* `user_id` int(11) NOT NULL,
|
|
* `type` int(11) NOT NULL COMMENT '类型',
|
|
* `value` varchar(255) NOT NULL,
|
|
* `num` int(11) NOT NULL,
|
|
* `from_type` int(11) NOT NULL COMMENT '来源',
|
|
* `from_data` varchar(1000) DEFAULT NULL,
|
|
* `created_at` int(11) DEFAULT NULL,
|
|
* `updated_at` int(11) DEFAULT NULL,
|
|
* PRIMARY KEY (`id`),
|
|
* KEY `user_id` (`user_id`),
|
|
* KEY `money_type` (`type`),
|
|
* KEY `from_type` (`from_type`),
|
|
* KEY `created_at` (`created_at`),
|
|
* KEY `updated_at` (`updated_at`)
|
|
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='系统日志'
|
|
*/
|
|
|
|
/**
|
|
* 系统日志
|
|
* @property int $id
|
|
* @property int $user_id
|
|
* @property int $type
|
|
* @property string $value
|
|
* @property int $num
|
|
* @property int $from_type
|
|
* @property string $from_data
|
|
* @property int $created_at
|
|
* @property int $updated_at
|
|
*/
|
|
class SystemLog extends ActiveRecord
|
|
{
|
|
public function behaviors()
|
|
{
|
|
return [
|
|
TimestampBehavior::className(),
|
|
];
|
|
}
|
|
|
|
public function rules()
|
|
{
|
|
return [
|
|
['id', 'default', 'value' => 0],
|
|
|
|
['user_id', 'required'],
|
|
['user_id', 'default', 'value' => 0],
|
|
['user_id', 'exist', 'targetClass' => '\common\models\User', 'targetAttribute' => 'id'],
|
|
|
|
['type', 'required'],
|
|
['type', 'in', 'range' => SystemLogUtil::TYPE_LIST],
|
|
|
|
['value', 'required'],
|
|
['value', 'trim'],
|
|
['value', 'default', 'value' => ''],
|
|
|
|
['num', 'default', 'value' => 0],
|
|
|
|
['from_type', 'required'],
|
|
['from_type', 'in', 'range' => SystemLogUtil::FROM_TYPE_LIST],
|
|
|
|
['from_data', 'default', 'value' => ''],
|
|
|
|
['created_at', 'default', 'value' => 0],
|
|
['updated_at', 'default', 'value' => 0],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 已经购买过的宠物蛋列表
|
|
* @param $userID
|
|
* @return array
|
|
*/
|
|
public static function findBuyPetEggList($userID)
|
|
{
|
|
$list = self::find()->where(['user_id' => $userID])
|
|
->andWhere(['in', 'value', [201017, 201018, 201019, 201020, 201021]])
|
|
->all();
|
|
|
|
$itemIDList = [];
|
|
foreach ($list as $item) {
|
|
array_push($itemIDList, $item->value);
|
|
}
|
|
|
|
return $itemIDList;
|
|
}
|
|
}
|