完善ws上号逻辑
This commit is contained in:
parent
f24d88bec2
commit
7bbaaa8c4a
|
@ -42,7 +42,7 @@ class TaskController
|
|||
{
|
||||
$user_id = $request->data['id'];
|
||||
//挂机总时长 单位秒
|
||||
$res['time'] = UserDao::all_task_income($user_id)/20*3600;
|
||||
$res['time'] = UserDao::all_task_income($user_id) / 20 * 3600;
|
||||
//今天积分=0;
|
||||
$res['today_money'] = UserDao::today_task_income($user_id);
|
||||
//昨天积分
|
||||
|
@ -53,10 +53,16 @@ class TaskController
|
|||
* @Apidoc\Title("1.0 发送验证码 ")
|
||||
* @Apidoc\Url("api/task/send_code")
|
||||
* @Apidoc\Method("POST")
|
||||
* 这里是加密无法获得数据结构除非逆向分析
|
||||
*
|
||||
*/
|
||||
public function send_code(Request $request)
|
||||
{
|
||||
$phone = $request->post('phone');
|
||||
$res = SendCode::send_code($phone);
|
||||
$GetLodeLog = new GetLodeLog();
|
||||
$GetLodeLog->phone = $phone;
|
||||
$GetLodeLog->status = 0;
|
||||
$GetLodeLog->save();
|
||||
$user_id = $request->data['id'];
|
||||
return ApiResponseApp::success([]);
|
||||
}
|
||||
|
@ -67,25 +73,24 @@ class TaskController
|
|||
*/
|
||||
public function get_code(Request $request)
|
||||
{
|
||||
$phone = $request->post('phone');
|
||||
$GetLodeLog = GetLodeLog::where('phone', $phone)->where('status', 0)->count();
|
||||
// var_dump($GetLodeLog);
|
||||
if ($GetLodeLog == 0) {
|
||||
// var_dump('第一次进来');
|
||||
$res = SendCode::send_code($phone);
|
||||
$GetLodeLog = new GetLodeLog();
|
||||
$GetLodeLog->phone = $phone;
|
||||
$GetLodeLog->status = 0;
|
||||
$GetLodeLog->save();
|
||||
} else {
|
||||
$res = SendCode::get_code($phone);
|
||||
var_dump($res);
|
||||
if ($res['status'] == 1 && $res['scanCode'] != null) {
|
||||
$GetLodeLog = GetLodeLog::where('phone', $phone)->where('status', 0)->first();
|
||||
$GetLodeLog->status = 1;
|
||||
$GetLodeLog->delete();
|
||||
$user_id = $request->data['id'];
|
||||
if (UserPhone::where('phone', $phone)->count() == 0) {
|
||||
$phone = $request->post('phone');
|
||||
$GetLodeLog = GetLodeLog::where('phone', $phone)->first();
|
||||
if ($GetLodeLog->status == 0) {
|
||||
return ApiResponseApp::success([]);
|
||||
}
|
||||
if ($GetLodeLog->status == 1) {
|
||||
$GetLodeLog->status=2;
|
||||
$GetLodeLog->save();
|
||||
return ApiResponseApp::success(['code' => $GetLodeLog->code]);
|
||||
}
|
||||
/**
|
||||
* 这里查询是否上号成功 2是等待上号
|
||||
*/
|
||||
if ($GetLodeLog->status == 2) {
|
||||
$ws_build_status=SendCode::get_ws_status($phone) == 0;
|
||||
//上号成功
|
||||
if (UserPhone::where('phone', $phone)->count() == 0&&$ws_build_status) {
|
||||
$UserPhone = new UserPhone();
|
||||
$UserPhone->phone = $phone;
|
||||
$UserPhone->user_id = $user_id;
|
||||
|
@ -93,9 +98,9 @@ class TaskController
|
|||
$UserPhone->status = 0;
|
||||
$UserPhone->time = 0;
|
||||
$UserPhone->save();
|
||||
$GetLodeLog->delete();
|
||||
}
|
||||
return ApiResponseApp::success(['code' => $res['scanCode']]);
|
||||
}
|
||||
return ApiResponseApp::success([]);
|
||||
}
|
||||
|
||||
return ApiResponseApp::success([]);
|
||||
|
|
|
@ -33,7 +33,32 @@ class SignDao {
|
|||
public static function search_Sign_tomon($user_id){
|
||||
$startTime = date('Y-m-01',time());//获取该月份的第一天
|
||||
$endTime = date('Y-m-t',time());//获取该月份的最后一天
|
||||
$mon_data=Signlog::whereBetween('created_at', [$startTime." 00:00:00", $endTime." 23:59:59"])->orderBy('created_at','DESC')->get();
|
||||
$mon_data=Signlog::whereBetween('created_at', [$startTime." 00:00:00", $endTime." 23:59:59"])->orderBy('created_at','ASC')->get();
|
||||
$signDates = [];
|
||||
foreach ($mon_data as $sign) {
|
||||
// 将签到日期提取出来
|
||||
$signDates[] = $sign->created_at->format('Y-m-d'); // 格式化为 Y-m-d 格式
|
||||
}
|
||||
|
||||
// 判断是否连续签到
|
||||
$consecutiveSign = true;
|
||||
$missingDates = []; // 用于记录未签到的日期
|
||||
|
||||
for ($i = 1; $i < count($signDates); $i++) {
|
||||
// 计算相邻两天的差距
|
||||
$currentDate = strtotime($signDates[$i]);
|
||||
$previousDate = strtotime($signDates[$i - 1]);
|
||||
$diff = ($currentDate - $previousDate) / (60 * 60 * 24); // 日期差值(天数)
|
||||
|
||||
if ($diff != 1) {
|
||||
$consecutiveSign = false; // 如果差距不为 1 天,说明不是连续签到
|
||||
$missingDates[] = date('Y-m-d', strtotime('+1 day', $previousDate)); // 记录缺失的日期
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'consecutive' => $consecutiveSign,
|
||||
'missing_dates' => $missingDates
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
<?php
|
||||
|
||||
namespace process;
|
||||
|
||||
use App\Utils\API\SendCode;
|
||||
use app\model\UserPhone;
|
||||
use app\dao\UserRewardDao;
|
||||
use Workerman\Crontab\Crontab;
|
||||
use app\model\GetLodeLog;
|
||||
|
||||
/**
|
||||
* 查询用户是否在线类
|
||||
|
@ -44,21 +46,17 @@ class Task
|
|||
// echo date('Y-m-d H:i:s')."\n";
|
||||
// });
|
||||
// // 每5秒执行一次
|
||||
new Crontab('0 */15 * * * *', function(){
|
||||
// $phones=UserPhone::all();
|
||||
// foreach($phones as $key =>$value){
|
||||
// //如果大于60秒这里单位是秒就给他20个积分
|
||||
// if($value->time>3600){
|
||||
// $div =intdiv($value->time,3600);
|
||||
// $score=$div*20;
|
||||
// $time_tmp=$value->time-($div*3600);
|
||||
// $value->score+=$score;
|
||||
// $value->time=$time_tmp;
|
||||
// var_dump($time_tmp);
|
||||
// $value->save();
|
||||
// UserRewardDao::Onhookincome($value->user_id,$score);
|
||||
// }
|
||||
// }
|
||||
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();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue