You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
863 B
40 lines
863 B
<?php
|
|
|
|
namespace api\logic;
|
|
|
|
use common\models\DailyActiveUser;
|
|
use yii\base\Component;
|
|
use Yii;
|
|
|
|
/**
|
|
* @author iron
|
|
* @email weiriron@gmail.com
|
|
* Class CartLogic
|
|
* @package api\logic
|
|
*/
|
|
class UserLogic extends Component
|
|
{
|
|
|
|
public function DailyActive()
|
|
{
|
|
$date = date('Y-m-d', time());
|
|
$DAU = DailyActiveUser::find()
|
|
->where(['date' => $date])
|
|
->one();
|
|
if ($DAU) {
|
|
$ids = $DAU->user_ids;
|
|
if (in_array(Yii::$app->user->id, $ids)) {
|
|
return;
|
|
}
|
|
array_push($ids, Yii::$app->user->id);
|
|
$DAU->user_id = $ids;
|
|
$DAU->count += 1;
|
|
} else {
|
|
$DAU = new DailyActiveUser();
|
|
$DAU->user_ids = array(Yii::$app->user->getId());
|
|
$DAU->date = $date;
|
|
}
|
|
$DAU->save();
|
|
}
|
|
|
|
}
|