webman/process/Task3.php

77 lines
2.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace process;
use App\Utils\API\SendCode;
use app\model\UserPhone;
use app\dao\UserRewardDao;
use Workerman\Crontab\Crontab;
use app\model\GetLodeLog;
use app\model\User;
/**
* 获取今天在线时间超过6小时的用户
*/
class Task3
{
public function onWorkerStart()
{
// // 每秒钟执行一次
// new Crontab('*/1 * * * * *', function(){
// echo date('Y-m-d H:i:s')."\n";
// });
// // 每5秒执行一次
// new Crontab('*/5 * * * * *', function(){
// echo date('Y-m-d H:i:s')."\n";
// });
// // 每分钟执行一次
// new Crontab('0 */1 * * * *', function(){
// echo date('Y-m-d H:i:s')."\n";
// });
// // 每5分钟执行一次
// new Crontab('0 */5 * * * *', function(){
// echo date('Y-m-d H:i:s')."\n";
// });
// // 每分钟的第一秒执行
// new Crontab('1 * * * * *', function(){
// echo date('Y-m-d H:i:s')."\n";
// });
// // 每天的7点50执行注意这里省略了秒位
// new Crontab('50 7 * * *', function(){
// echo date('Y-m-d H:i:s')."\n";
// });
// // 每5秒执行一次
new Crontab('0 */5 * * * *', function () {
//获取今天在线时间超过6小时的用户
$today = date('Y-m-d');
$UserPhone = UserPhone::where('time', '>=', 3600)::where('time', '<', 4200)::where('created_at','>=',$today)->get();
//判断用户绑定Whatsapp首次登录
foreach ($UserPhone as $key => $value) {
$user_id = $value->user_id;
$user = User::find($user_id);
if (!$user) {
continue;
}
//获取该用户的父级
$parent = User::find($user->f_id);
var_dump($parent);
//满足则加80积分
UserRewardDao::base($parent->id, 5, 80, '推广收益');
//vip_id等级加1,并更新数据库
$parent->vip_id += 1;
//今天邀请人数加1
$parent->today_num += 1;
$parent->today_team_income+=80;
$parent->save();
}
});
}
}