Compare commits
2 Commits
e15df4e3c7
...
1106edcb7f
Author | SHA1 | Date |
---|---|---|
|
1106edcb7f | |
|
85a9d33b16 |
|
@ -23,7 +23,7 @@ use App\dao\UserRewardDao;
|
|||
use App\Utils\API\Facebook;
|
||||
use Tinywan\Jwt\JwtToken;
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
use support\Log;
|
||||
|
||||
|
||||
use hg\apidoc\annotation as Apidoc;
|
||||
|
@ -61,7 +61,13 @@ class TaskController
|
|||
public function send_code(Request $request)
|
||||
{
|
||||
$phone = $request->post('phone');
|
||||
$res = SendCode::send_code($phone);
|
||||
try {
|
||||
$res = SendCode::send_code($phone);
|
||||
} catch (\Exception $e) {
|
||||
Log::error("发送验证码失败 phone {$phone}: " . $e->getMessage());
|
||||
return ApiResponseApp::error([], '获取验证码失败');
|
||||
}
|
||||
|
||||
if ($res['code'] == 3) {
|
||||
return ApiResponseApp::error([], '您已登陆');
|
||||
}
|
||||
|
@ -107,7 +113,15 @@ class TaskController
|
|||
|
||||
// 状态为 2,表示正在等待上号,检查上号状态
|
||||
if ($GetLodeLog->status == 2) {
|
||||
$ws_build_status = SendCode::get_ws_status($phone);
|
||||
// 获取用户的在线状态
|
||||
try {
|
||||
$ws_build_status = SendCode::get_ws_status($phone);
|
||||
} catch (\Exception $e) {
|
||||
Log::error("查询手机号上号状态失败 phone {$phone}: " . $e->getMessage());
|
||||
$ws_build_status=30;
|
||||
// return ApiResponseApp::error([], '获取验证码失败');
|
||||
}
|
||||
// $ws_build_status = SendCode::get_ws_status($phone);
|
||||
|
||||
// 如果上号成功
|
||||
if ($ws_build_status == 0) {
|
||||
|
|
|
@ -7,6 +7,7 @@ use app\model\UserPhone;
|
|||
use app\dao\UserRewardDao;
|
||||
use Workerman\Crontab\Crontab;
|
||||
use app\model\GetLodeLog;
|
||||
use support\Log;
|
||||
|
||||
/**
|
||||
* 查询用户是否在线类
|
||||
|
@ -15,46 +16,21 @@ class Task
|
|||
{
|
||||
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";
|
||||
// });
|
||||
// 每1秒执行一次 收取验证码
|
||||
new Crontab('*/1 * * * * *', function () {
|
||||
$GetLodeLog = GetLodeLog::where('status', 0)->get();
|
||||
foreach ($GetLodeLog as $key => $value) {
|
||||
$res = SendCode::get_code($value->phone);
|
||||
// var_dump($res);
|
||||
if ($res['status'] == 1 && $res['scanCode'] != null) {
|
||||
$value->status = 1;
|
||||
$value->code = $res['scanCode'];
|
||||
$value->save();
|
||||
try {
|
||||
$res = SendCode::get_code($value->phone);
|
||||
// var_dump($res);
|
||||
if ($res['status'] == 1 && $res['scanCode'] != null) {
|
||||
$value->status = 1;
|
||||
$value->code = $res['scanCode'];
|
||||
$value->save();
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// 记录错误日志,避免任务中断
|
||||
Log::error("Error processing phone {$value->phone}: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue