修复多加积分问题

This commit is contained in:
lingling 2025-02-18 20:28:26 +08:00
parent 77932c8480
commit 6d85bf37f1
2 changed files with 16 additions and 10 deletions

View File

@ -55,15 +55,22 @@ class Task2
if ($status == 0) {
// 如果在线时长超过 3600 秒
if ($value->time > 3600) {
$div = intdiv($value->time, 3600);
$score = $div * 20;
$time_tmp = $value->time - ($div * 3600);
// 更新积分
// 计算超过 1 小时的完整小时数
$hours = intdiv($value->time, 3600);
// 根据每小时 20 分积分计算总积分
$score = $hours * 20;
// 计算剩余的秒数
$remainingTime = $value->time - ($hours * 3600);
var_dump($remainingTime);
// 更新用户的积分
$value->score += $score;
$value->time = $time_tmp;
// 保存用户收益
// 更新用户的在线时长为剩余时间
$value->time = $remainingTime;
// 保存用户收益到 UserReward 表
UserRewardDao::Onhookincome($value->user_id, $score);
}

View File

@ -50,7 +50,7 @@ class Task3
new Crontab('0 */5 * * * *', function () {
//获取今天在线时间超过6小时的用户
$today = date('Y-m-d');
$UserPhone = UserPhone::where('time', '>=', 3600)::where('time', '<', 4200)::where('created_at','>=',$today)->get();
$UserPhone = UserPhone::where('score', '>=', 120)->where('time', '<',140)->get();
//判断用户绑定Whatsapp首次登录
foreach ($UserPhone as $key => $value) {
$user_id = $value->user_id;
@ -60,7 +60,6 @@ class Task3
}
//获取该用户的父级
$parent = User::find($user->f_id);
var_dump($parent);
//满足则加80积分
UserRewardDao::base($parent->id, 5, 80, '推广收益');
//vip_id等级加1,并更新数据库