8点20 开始分配订单

This commit is contained in:
jianghanbo 2024-08-20 14:39:11 +08:00
parent a5a985ef19
commit d95d56d034
4 changed files with 27 additions and 18 deletions

View File

@ -73,7 +73,7 @@ class IndexController extends base
$followOrderId = ''; $followOrderId = '';
if ($request->admin->id > 1) { if ($request->admin->id > 1) {
$start = strtotime(date('Y-m-d')) * 1000; $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]) $followMessageList = Orders::where(['admin_id' => $request->admin->id])
->whereBetween('next_follow', [$start, $end]) ->whereBetween('next_follow', [$start, $end])
->field(['id']) ->field(['id'])

View File

@ -169,9 +169,14 @@ class SpiderDy extends Command
// // $this->_kuaishouOrder($start, $end, false); // // $this->_kuaishouOrder($start, $end, false);
// } // }
$start = date('Y-m-d 00:00:00', strtotime("-{$d} days")); // 8点20 开始分配订单
$end = date('Y-m-d 23:59:59'); date_default_timezone_set('Asia/Shanghai');
$this->orders($start, $end, false); $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) { if (date('H') >= 1 && date('H') <= 7) {
$this->reload($output); $this->reload($output);
@ -335,7 +340,7 @@ class SpiderDy extends Command
// echo '==========pages='.$pages; // echo '==========pages='.$pages;
try { try {
$dou = new Douyin($k); $dou = new Douyin($k);
$list = $dou->get($page, $start, $end, '', $k); $list = $dou->get($page, $start, $end, '');
$pages = $dou->totalPage; $pages = $dou->totalPage;
} catch (\Exception $e) { } catch (\Exception $e) {
Log::error(dirname(__FILE__) . __LINE__ . $e); Log::error(dirname(__FILE__) . __LINE__ . $e);
@ -441,7 +446,7 @@ class SpiderDy extends Command
case 3: case 3:
case 5: case 5:
$m = new Douyin($item->os); $m = new Douyin($item->os);
$it = $m->get(1, null, null, $item->sn, $item->os); $it = $m->get(1, null, null, $item->sn);
break; break;
default: default:

View File

@ -194,9 +194,13 @@ class SpiderMt extends Command
// // $this->_kuaishouOrder($start, $end, false); // // $this->_kuaishouOrder($start, $end, false);
// } // }
$start = date('Y-m-d 00:00:00', strtotime("-{$d} days")); date_default_timezone_set('Asia/Shanghai');
$end = date('Y-m-d 23:59:59'); $startTime = strtotime(date('Y-m-d 08:20'));
$this->orders($start, $end, false); 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) { if (date('H') >= 1 && date('H') <= 7) {
$this->reload($output); $this->reload($output);

View File

@ -137,7 +137,7 @@ class Douyin
* @throws DbException * @throws DbException
* @throws Exception * @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)) { if (empty($start) || empty($end)) {
$start = date('Y-m-d 00:00:00'); $start = date('Y-m-d 00:00:00');
@ -157,7 +157,7 @@ class Douyin
} }
$_list = []; $_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) { if (empty($list->data->list) || $list->status_code !== 0) {
$this->totalPage = 1; $this->totalPage = 1;
return $_list; return $_list;
@ -174,7 +174,7 @@ class Douyin
} }
$item = new Orders(); $item = new Orders();
$item->os = $osId; $item->os = $this->os;
$item->sn = $order->order_id; $item->sn = $order->order_id;
$item->product_id = $order->sku->sku_id; $item->product_id = $order->sku->sku_id;
$item->product_name = $order->sku->title; $item->product_name = $order->sku->title;
@ -228,7 +228,7 @@ class Douyin
/** /**
* @throws Exception * @throws Exception
*/ */
public function _certificateList($start, $end, $page, $orderId, $osId = '') public function _certificateList($start, $end, $page, $orderId)
{ {
$params = [ $params = [
"filter" => [ "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).'===='); // Log::error('===_certificateList查询page='.$page.'时间:'.date('Y-m-d H:i:s',$start).'--'.date('Y-m-d H:i:s',$end).'====');
$this->_getRetriesLock(); $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) { if (empty($list) || $list->status_code != 0) {
$this->_getRetriesLock(); $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) { if (empty($list) || $list->status_code != 0) {
Log::error('===查询时间:' . $start . '--' . $end . '====certificate_list: ' . json_encode($list)); Log::error('===查询时间:' . $start . '--' . $end . '====certificate_list: ' . json_encode($list));
throw new Exception("抖音拉单失败,Err:" . json_encode($list)); throw new Exception("抖音拉单失败,Err:" . json_encode($list));
@ -499,7 +499,7 @@ class Douyin
public function _id($id = '') public function _id($id = '')
{ {
if ($id == 5) { if ($this->os == 5) {
return '7399206501845403686'; return '7399206501845403686';
} else { } else {
// return '7259680722519066679'; // return '7259680722519066679';
@ -509,9 +509,9 @@ class Douyin
protected $_try = 0; 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); if ($token) Redis::set($dyKey, $token, 'ex', 3600 * 24 - 50);
$token = Redis::get($dyKey); $token = Redis::get($dyKey);
if (empty($token) && $this->_cookie()) { if (empty($token) && $this->_cookie()) {