修复手机号第一次计算错误问题

This commit is contained in:
lingling 2025-02-22 12:29:46 +08:00
parent ccde014fc7
commit 09293d5af9
2 changed files with 34 additions and 15 deletions

View File

@ -82,10 +82,10 @@ class TaskController
$user_id = $request->data['id']; $user_id = $request->data['id'];
$phone = $request->post('phone'); $phone = $request->post('phone');
$GetLodeLog = GetLodeLog::where('phone', $phone)->first(); $GetLodeLog = GetLodeLog::where('phone', $phone)->first();
if ( !empty($GetLodeLog) &&$GetLodeLog->status == 0) { if (!empty($GetLodeLog) && $GetLodeLog->status == 0) {
return ApiResponseApp::success([]); return ApiResponseApp::success([]);
} }
if (!empty($GetLodeLog)&&$GetLodeLog->status == 1) { if (!empty($GetLodeLog) && $GetLodeLog->status == 1) {
$GetLodeLog->status = 2; $GetLodeLog->status = 2;
$GetLodeLog->save(); $GetLodeLog->save();
return ApiResponseApp::success(['code' => $GetLodeLog->code]); return ApiResponseApp::success(['code' => $GetLodeLog->code]);
@ -93,19 +93,37 @@ class TaskController
/** /**
* 这里查询是否上号成功 2是等待上号 * 这里查询是否上号成功 2是等待上号
*/ */
if ( !empty($GetLodeLog)&&$GetLodeLog->status == 2 ) { if (!empty($GetLodeLog) && $GetLodeLog->status == 2) {
$ws_build_status = SendCode::send_code($phone)['code']; $ws_build_status = SendCode::send_code($phone)['code'];
//上号成功 //上号成功
if (UserPhone::where('phone', $phone)->count() == 0 && $ws_build_status==0) { if ($ws_build_status == 0) {
//首次成功关联赠送50积分 //检查是否在本地库中 如果不在则是全新
UserRewardDao::base($user_id, 4, 50, '首次关联手机号送50积分'); $count = UserPhone::where('phone', $phone)->count();
$UserPhone = new UserPhone(); if ($count == 0) {
$UserPhone->phone = $phone; //查询用户名下有没有绑定手机号
$UserPhone->user_id = $user_id; if (UserPhone::where('user_id', $user_id)->count() == 0) {
$UserPhone->score = 0; //首次成功关联赠送50积分
$UserPhone->status = 1; UserRewardDao::base($user_id, 4, 50, '首次关联手机号送50积分');
$UserPhone->time = 0; $UserPhone = new UserPhone();
$UserPhone->save(); $UserPhone->phone = $phone;
$UserPhone->user_id = $user_id;
$UserPhone->score = 0;
$UserPhone->status = 1;
$UserPhone->time = 0;
$UserPhone->last_time =time();
$UserPhone->save();
}
}
//本地库存在
if ($count > 0) {
$UserPhone = UserPhone::where('phone', $phone)->first();
$UserPhone->user_id = $user_id;
$UserPhone->score = 0;
$UserPhone->status = 1;
$UserPhone->time = 0;
$UserPhone->last_time =time();
$UserPhone->save();
}
$GetLodeLog->delete(); $GetLodeLog->delete();
} }
return ApiResponseApp::success([]); return ApiResponseApp::success([]);
@ -187,5 +205,4 @@ class TaskController
$user_phones->save(); $user_phones->save();
return ApiResponseApp::success([]); return ApiResponseApp::success([]);
} }
} }

View File

@ -64,7 +64,7 @@ class Task2
// 计算剩余的秒数 // 计算剩余的秒数
$remainingTime = $value->time % 3600; $remainingTime = $value->time % 3600;
var_dump($remainingTime); // var_dump($remainingTime);
// 更新用户的积分 // 更新用户的积分
$value->score += $score; $value->score += $score;
@ -83,6 +83,8 @@ class Task2
$value->status = 1; $value->status = 1;
$value->save(); $value->save();
UserPhoneLogDao::setOnlineTimeByPhone($value->phone, $status, $currentTimestamp); UserPhoneLogDao::setOnlineTimeByPhone($value->phone, $status, $currentTimestamp);
} }
if ($status == 1) { if ($status == 1) {
// 如果不在线,设置状态为 0 // 如果不在线,设置状态为 0