diff --git a/service/app/command/SpiderDy.php b/service/app/command/SpiderDy.php index 102f46f5..7db7e6cc 100644 --- a/service/app/command/SpiderDy.php +++ b/service/app/command/SpiderDy.php @@ -142,18 +142,6 @@ class SpiderDy extends Command return 1; } - // echo "状态1\n"; - // $this->poolUser(1); - // echo "状态2\n"; - // $this->poolUser(2); - // echo "状态3\n"; - // $this->poolUser(3); - // echo "状态4\n"; - // $this->poolUser(4); - // echo "状态5\n"; - // $this->poolUser(5); - // return 1; - // $this->checks($output); // $output->writeln('CHECK spider:dy'); @@ -238,19 +226,15 @@ class SpiderDy extends Command $order->is_check = 1; $order->check_sn = $json->check_sn; $back = $order->save(); - echo "订单在自己名下"; } else { - // echo "订单在自己名下2 $order_id"; $order = Orders::where('sn', $order_id)->find(); // print_r($order->toArray()); if (!empty($order) && $order->admin_id == 0) { - echo '订单不在自己的名下,并且没有分人。'; $order->is_check = 1; $order->check_sn = $json->check_sn; $order->admin_id = $json->admin_id; $back = $order->save(); } elseif (!empty($order) && $order->admin_id !== $json->admin_id) { - echo '订单不在自己的名下,并且分人了。'; $item = new Orders(); $item->os = 1; $item->sn = $order->sn; @@ -339,7 +323,6 @@ class SpiderDy extends Command case 3: case 5: -// echo '==========pages='.$pages; try { $dou = new Douyin($k); $list = $dou->get($page, $start, $end, ''); @@ -487,18 +470,15 @@ class SpiderDy extends Command { $user = Admins::cache(true)->where('id', $admin_id)->find(); if ((!config('app.debug', true) || config('app.debug', true) === 'false') && (time() * 1000 - $order->create_at) / 1000 < 2 * 24 * 3600) { - echo "发送短信\n"; print_r([$order->mobile, 261607, ['title' => $order->product_name, 'mobile' => $user->mobile]]); $has = Blacks::where('mobile', $order->mobile)->find(); if (empty($has) && !empty($order->mobile)) { SMS::juhe_sms_send($order->mobile, 261607, ['title' => $order->product_name, 'mobile' => $user->mobile]); } else { - echo "黑名单不发送短信\n"; sleep(10); } } else { - echo "不发送短信\n"; print_r([$order->mobile, 261607, ['title' => $order->product_name, 'mobile' => $user->mobile]]); } } diff --git a/service/app/command/SpiderMt.php b/service/app/command/SpiderMt.php index a9d24c4d..cc512bcd 100644 --- a/service/app/command/SpiderMt.php +++ b/service/app/command/SpiderMt.php @@ -165,18 +165,6 @@ class SpiderMt extends Command return 1; } - // echo "状态1\n"; - // $this->poolUser(1); - // echo "状态2\n"; - // $this->poolUser(2); - // echo "状态3\n"; - // $this->poolUser(3); - // echo "状态4\n"; - // $this->poolUser(4); - // echo "状态5\n"; - // $this->poolUser(5); - // return 1; - // $this->checks($output); // $output->writeln('CHECK spider:mt'); @@ -261,20 +249,16 @@ class SpiderMt extends Command $order->is_check = 1; $order->check_sn = $json->check_sn; $back = $order->save(); - echo "订单在自己名下"; } else { - // echo "订单在自己名下2 $order_id"; $order = Orders::where('sn', $order_id)->find(); // print_r($order->toArray()); if (!empty($order) && $order->admin_id == 0) { - echo '订单不在自己的名下,并且没有分人。'; $order->is_check = 1; $order->check_sn = $json->check_sn; $order->admin_id = $json->admin_id; $order->give_time = time(); $back = $order->save(); } elseif (!empty($order) && $order->admin_id !== $json->admin_id) { - echo '订单不在自己的名下,并且分人了。'; $item = new Orders(); $item->os = 1; $item->sn = $order->sn; @@ -377,7 +361,7 @@ class SpiderMt extends Command # code... break; } -echo 'order:' . json_encode($list); + foreach ($list as $order) { $item = Orders::where('os', $order->os)->where('sn', $order->sn)->find(); @@ -507,19 +491,16 @@ echo 'order:' . json_encode($list); { $user = Admins::cache(true)->where('id', $admin_id)->find(); if ((!config('app.debug', true) || config('app.debug', true) === 'false') && (time() * 1000 - $order->create_at) / 1000 < 2 * 24 * 3600) { - echo "发送短信\n"; print_r([$order->mobile, 261607, ['title' => $order->product_name, 'mobile' => $user->mobile]]); $has = Blacks::where('mobile', $order->mobile)->find(); if (empty($has) && !empty($order->mobile)) { SMS::juhe_sms_send($order->mobile, 261607, ['title' => $order->product_name, 'mobile' => $user->mobile]); } else { - echo "黑名单不发送短信\n"; sleep(10); } } else { - echo "不发送短信\n"; - print_r([$order->mobile, 261607, ['title' => $order->product_name, 'mobile' => $user->mobile]]); + Log::info('不发送短信' . json_encode([$order->mobile, 261607, ['title' => $order->product_name, 'mobile' => $user->mobile]])); } } diff --git a/service/app/command/SpiderTc.php b/service/app/command/SpiderTc.php index ed3c492c..ee04067b 100644 --- a/service/app/command/SpiderTc.php +++ b/service/app/command/SpiderTc.php @@ -6,12 +6,6 @@ use app\admin\controller\AdminController; use app\model\Admins; use app\model\Blacks; use app\model\Finances; -use app\model\Logs; -use app\model\Orders; -use app\server\Douyin; -use app\server\Meituan; -use app\server\Kuaishou; -use app\server\Orders as ServerOrders; use app\server\SMS; use app\server\Tongcheng; use stdClass; @@ -295,18 +289,14 @@ class SpiderTc extends Command $user = Admins::cache(true)->where('id', $admin_id)->find(); $templateId = 261607; if ((!config('app.debug', true) || config('app.debug', true) === 'false') && (time() * 1000 - $order->create_at) / 1000 < 2 * 24 * 3600) { - echo "发送短信\n"; print_r([$order->mobile, $templateId, ['title' => $order->product_name, 'mobile' => $user->mobile]]); $has = Blacks::where('mobile', $order->mobile)->find(); if (empty($has) && !empty($order->mobile)) { SMS::juhe_sms_send($order->mobile, $templateId, ['title' => $order->product_name, 'mobile' => $user->mobile]); } else { - echo "黑名单不发送短信\n"; sleep(10); } - } else { - echo "不发送短信\n"; print_r([$order->mobile, $templateId, ['title' => $order->product_name, 'mobile' => $user->mobile]]); } } diff --git a/service/app/server/Douyin.php b/service/app/server/Douyin.php index 2b999b3f..c58e2a47 100644 --- a/service/app/server/Douyin.php +++ b/service/app/server/Douyin.php @@ -88,7 +88,6 @@ class Douyin if ($list && $list->status_code == 0 && !empty($list->order_list)) { foreach ($list->order_list as $order) { - echo "抖音 订单号:{$order->order_info->order_id} \n\n"; if (empty($cert)) { $cert = $this->_cert($order->order_info->order_id); if (empty($cert)) { @@ -162,7 +161,7 @@ class Douyin $this->totalPage = 1; return $_list; } - echo date('Y-m-d', $start) . '--' . date('Y-m-d', $end) . " 抖音 page:{$page} total_count:" . $list->data->pagination->total_count . " page_count:" . $list->data->pagination->page_count . " \n\n"; + Log::info(date('Y-m-d', $start) . '--' . date('Y-m-d', $end) . " 抖音 page:{$page} total_count:" . $list->data->pagination->total_count . " page_count:" . $list->data->pagination->page_count ); foreach ($list->data->list as $order) { Log::info("抖音 订单号:{$order->order_id} \n\n"); @@ -283,64 +282,10 @@ class Douyin return true; } - /*public function _killMiddleProcesses($pattern, $maxProcesses) - { - // 检查操作系统是否为 Linux - if (PHP_OS !== 'Linux') { - echo "当前系统不是 Linux,跳过执行。\n"; - return false; - } - - // 获取当前进程的 PID - $currentPid = getmypid(); - - // 获取进程列表 - $command = "ps aux | grep '$pattern' | grep -v grep | grep -v '$currentPid' | awk '{print $2,$10}'"; - $output = []; - exec($command, $output); - - $processCount = count($output); - - // 如果进程数量超过最大值,则终止中间部分的 x-12 个进程 - if ($processCount > $maxProcesses) { - $processesToKill = $processCount - $maxProcesses; - $processesKilled = 0; - - // 找到运行时间最短的不包含自己的进程并终止它 - foreach ($output as $line) { - list($pid, $runtime) = explode(' ', $line); - $runtimeParts = explode(':', $runtime); - $hours = intval($runtimeParts[0]); - $minutes = intval($runtimeParts[1]); - $totalMinutes = $hours * 60 + $minutes; - - - if ($pid !== $currentPid) { - exec("kill -9 $pid"); - $processesKilled++; - - echo "Killed process with PID: $pid\n"; - - if ($processesKilled >= $processesToKill) { - break; - } - } - } - - if ($processesKilled === 0) { - echo "No processes to kill.\n"; - } - } else { - echo "Process count is not over the limit.\n"; - } - return true; - }*/ - public function _killMiddleProcesses($pattern, $maxProcesses) { // 检查操作系统是否为 Linux if (PHP_OS !== 'Linux') { - echo "当前系统不是 Linux,跳过执行。\n"; return false; } @@ -391,14 +336,14 @@ class Douyin exec("kill -9 {$process['pid']}"); $processesKilled++; - echo "Killed process with PID: {$process['pid']}\n"; + Log::info("Killed process with PID: {$process['pid']}\n"); } if ($processesKilled === 0) { - echo "No processes to kill.\n"; + Log::info( "No processes to kill.\n"); } } else { - echo "Process count is not over the limit.\n"; + Log::info( "Process count is not over the limit.\n"); } return true; diff --git a/service/app/server/Meituan.php b/service/app/server/Meituan.php index 41af6446..3eccdc7f 100644 --- a/service/app/server/Meituan.php +++ b/service/app/server/Meituan.php @@ -79,10 +79,10 @@ class Meituan { $_list = []; if($list && $list->code == 0 && $list->data && is_array($list->data->orderList)) { foreach($list->data->orderList as $order) { - echo "美团 订单号:{$order->orderId} \n\n"; + Log::info("美团 订单号:{$order->orderId} \n\n"); if(in_array($order->orderId, ['',''])) { - echo "异常订单:". $order->orderId; + Log::info( "异常订单:". $order->orderId); sleep(100); } $item = new Orders(); @@ -143,10 +143,6 @@ class Meituan { curl_setopt($ch, CURLOPT_COOKIE, $this->_cookie()); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - if ($this->os == 7) { - echo $this->os . $http; - echo $this->_cookie(); - } curl_setopt($ch, CURLOPT_HTTPHEADER, $header); if($method == 'POST') { curl_setopt($ch, CURLOPT_POST, true); diff --git a/service/app/server/Tongcheng.php b/service/app/server/Tongcheng.php index 26fc39c4..650272ca 100644 --- a/service/app/server/Tongcheng.php +++ b/service/app/server/Tongcheng.php @@ -138,7 +138,6 @@ class Tongcheng { { // 检查操作系统是否为 Linux if (PHP_OS !== 'Linux') { - echo "当前系统不是 Linux,跳过执行。\n"; return false; } @@ -189,14 +188,14 @@ class Tongcheng { exec("kill -9 {$process['pid']}"); $processesKilled++; - echo "Killed process with PID: {$process['pid']}\n"; + Log::info("Killed process with PID: {$process['pid']}\n"); } if ($processesKilled === 0) { - echo "No processes to kill.\n"; + Log::info("No processes to kill.\n"); } } else { - echo "Process count is not over the limit.\n"; + Log::info("Process count is not over the limit.\n"); } return true;