From d95d56d03461dd415c63e62eb7bb4e77ef09be75 Mon Sep 17 00:00:00 2001 From: jianghanbo Date: Tue, 20 Aug 2024 14:39:11 +0800 Subject: [PATCH] =?UTF-8?q?8=E7=82=B920=20=E5=BC=80=E5=A7=8B=E5=88=86?= =?UTF-8?q?=E9=85=8D=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/admin/controller/IndexController.php | 2 +- service/app/command/SpiderDy.php | 15 ++++++++++----- service/app/command/SpiderMt.php | 10 +++++++--- service/app/server/Douyin.php | 18 +++++++++--------- 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/service/app/admin/controller/IndexController.php b/service/app/admin/controller/IndexController.php index bd1ff6e2..e558b360 100644 --- a/service/app/admin/controller/IndexController.php +++ b/service/app/admin/controller/IndexController.php @@ -73,7 +73,7 @@ class IndexController extends base $followOrderId = ''; if ($request->admin->id > 1) { $start = strtotime(date('Y-m-d')) * 1000; - $end = strtotime(date('Y-m-d', strtotime('+1 days'))) * 1000; + $end = strtotime(date('Y-m-d', strtotime('+1 days'))) * 1000 - 1; $followMessageList = Orders::where(['admin_id' => $request->admin->id]) ->whereBetween('next_follow', [$start, $end]) ->field(['id']) diff --git a/service/app/command/SpiderDy.php b/service/app/command/SpiderDy.php index d96ce1d6..d531432e 100644 --- a/service/app/command/SpiderDy.php +++ b/service/app/command/SpiderDy.php @@ -169,9 +169,14 @@ class SpiderDy extends Command // // $this->_kuaishouOrder($start, $end, false); // } - $start = date('Y-m-d 00:00:00', strtotime("-{$d} days")); - $end = date('Y-m-d 23:59:59'); - $this->orders($start, $end, false); + // 8点20 开始分配订单 + date_default_timezone_set('Asia/Shanghai'); + $startTime = strtotime(date('Y-m-d 08:20')); + if (time() > $startTime) { + $start = date('Y-m-d 00:00:00', strtotime("-{$d} days")); + $end = date('Y-m-d 23:59:59'); + $this->orders($start, $end, false); + } if (date('H') >= 1 && date('H') <= 7) { $this->reload($output); @@ -335,7 +340,7 @@ class SpiderDy extends Command // echo '==========pages='.$pages; try { $dou = new Douyin($k); - $list = $dou->get($page, $start, $end, '', $k); + $list = $dou->get($page, $start, $end, ''); $pages = $dou->totalPage; } catch (\Exception $e) { Log::error(dirname(__FILE__) . __LINE__ . $e); @@ -441,7 +446,7 @@ class SpiderDy extends Command case 3: case 5: $m = new Douyin($item->os); - $it = $m->get(1, null, null, $item->sn, $item->os); + $it = $m->get(1, null, null, $item->sn); break; default: diff --git a/service/app/command/SpiderMt.php b/service/app/command/SpiderMt.php index 64c23724..62a918c3 100644 --- a/service/app/command/SpiderMt.php +++ b/service/app/command/SpiderMt.php @@ -194,9 +194,13 @@ class SpiderMt extends Command // // $this->_kuaishouOrder($start, $end, false); // } - $start = date('Y-m-d 00:00:00', strtotime("-{$d} days")); - $end = date('Y-m-d 23:59:59'); - $this->orders($start, $end, false); + date_default_timezone_set('Asia/Shanghai'); + $startTime = strtotime(date('Y-m-d 08:20')); + if (time() > $startTime) { + $start = date('Y-m-d 00:00:00', strtotime("-{$d} days")); + $end = date('Y-m-d 23:59:59'); + $this->orders($start, $end, false); + } if (date('H') >= 1 && date('H') <= 7) { $this->reload($output); diff --git a/service/app/server/Douyin.php b/service/app/server/Douyin.php index 1be72e48..2b999b3f 100644 --- a/service/app/server/Douyin.php +++ b/service/app/server/Douyin.php @@ -137,7 +137,7 @@ class Douyin * @throws DbException * @throws Exception */ - public function get($page, $start = null, $end = null, $orderId = '', $osId = 3) + public function get($page, $start = null, $end = null, $orderId = '') { if (empty($start) || empty($end)) { $start = date('Y-m-d 00:00:00'); @@ -157,7 +157,7 @@ class Douyin } $_list = []; - $list = $this->_certificateList($start, $end, $page, $orderId, $osId); + $list = $this->_certificateList($start, $end, $page, $orderId); if (empty($list->data->list) || $list->status_code !== 0) { $this->totalPage = 1; return $_list; @@ -174,7 +174,7 @@ class Douyin } $item = new Orders(); - $item->os = $osId; + $item->os = $this->os; $item->sn = $order->order_id; $item->product_id = $order->sku->sku_id; $item->product_name = $order->sku->title; @@ -228,7 +228,7 @@ class Douyin /** * @throws Exception */ - public function _certificateList($start, $end, $page, $orderId, $osId = '') + public function _certificateList($start, $end, $page, $orderId) { $params = [ "filter" => [ @@ -249,11 +249,11 @@ class Douyin // Log::error('===_certificateList查询page='.$page.'时间:'.date('Y-m-d H:i:s',$start).'--'.date('Y-m-d H:i:s',$end).'===='); $this->_getRetriesLock(); - $list = $this->_curl("/life/trip/fulfilment/v1/query/certificate_list?end_time={$end}&page_index={$page}&page_size=50&start_time={$start}&root_life_account_id=" . $this->_id($osId), $params, 'POST'); + $list = $this->_curl("/life/trip/fulfilment/v1/query/certificate_list?end_time={$end}&page_index={$page}&page_size=50&start_time={$start}&root_life_account_id=" . $this->_id(), $params, 'POST'); if (empty($list) || $list->status_code != 0) { $this->_getRetriesLock(); - $list = $this->_curl("/life/trip/fulfilment/v1/query/certificate_list?end_time={$end}&page_index={$page}&page_size=50&start_time={$start}&root_life_account_id=" . $this->_id($osId), $params, 'POST'); + $list = $this->_curl("/life/trip/fulfilment/v1/query/certificate_list?end_time={$end}&page_index={$page}&page_size=50&start_time={$start}&root_life_account_id=" . $this->_id(), $params, 'POST'); if (empty($list) || $list->status_code != 0) { Log::error('===查询时间:' . $start . '--' . $end . '====certificate_list: ' . json_encode($list)); throw new Exception("抖音拉单失败,Err:" . json_encode($list)); @@ -499,7 +499,7 @@ class Douyin public function _id($id = '') { - if ($id == 5) { + if ($this->os == 5) { return '7399206501845403686'; } else { // return '7259680722519066679'; @@ -509,9 +509,9 @@ class Douyin protected $_try = 0; - public function _token($token = '', $os = 3) + public function _token($token = '') { - $dyKey = sprintf('Douyin:token-%s', $os); + $dyKey = sprintf('Douyin:token-%s', $this->os); if ($token) Redis::set($dyKey, $token, 'ex', 3600 * 24 - 50); $token = Redis::get($dyKey); if (empty($token) && $this->_cookie()) {