ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# tp5 ## 放入队列 ![](https://img.kancloud.cn/30/69/306991746ad9f26773f165a184440004_1260x397.png) ## 队列配置 ![](https://img.kancloud.cn/7f/07/7f078759a2ba3175566c1118f7643092_1249x507.png) ## 队列消费 ![](https://img.kancloud.cn/e5/64/e564d6cfc994e688cec0a97f7b452c73_1225x937.png) ## 命令行 ![](https://img.kancloud.cn/c6/ca/c6ca1e803839a368a1ea9314ee752f70_1085x320.png) #tp6 ## 队列配置 ![](https://img.kancloud.cn/93/4a/934ab7cc388b0359a38287907b147165_1399x842.png) ## 放入队列 ![](https://img.kancloud.cn/05/37/0537849ea1132f3e10af8e5caba9eadf_1190x287.png) ## 消费队列 ``` ~~~ /** * 抖音开放平台-获取达人橱窗商品信息 */ public function showcaseGoodList(Job $job, $data) { list($authority_id, $access_token, $open_id) = $data; $data['attempts'] = $job->attempts(); if ($job->attempts() > 2) { Log::error('TalentJob->showcaseGoodList failed after max times! ' . \json_encode($data)); $job->delete(); return; } try { $page = $totalPage = 1; $tool = new UserRequst($authority_id); app()->make(UserDao::class)->setTiktokSyncStatusOne($authority_id, 'goods_status', 2); do { $data['page'] = $page; $res = $tool->getStoreGoodsList($access_token, $open_id, $page); if (empty($res['results'])) { Log::error('TalentJob->showcaseGoodList results empty! ' . \json_encode(['res' => $res, 'data' => $data], \JSON_UNESCAPED_UNICODE)); $job->delete(); return; } $showcaseDao = new ShowcaseDao(); $showcaseDao->updateTalentGood($authority_id, ['status' => 0]); foreach ($res['results'] as &$value) { $value['authority_id'] = $authority_id; $value['status'] = 1; TalentGoods::updateOrCreate(['authority_id' => $authority_id, 'product_id' => $value['product_id']], $value); } $page++; if ($page == 1) { $totalPage = ceil($res['total'] / 20); $data['total'] = $res['total'] ?? 0; } } while ($page <= $totalPage); // 修改账户信息为已同步完成橱窗商品 app()->make(UserDao::class)->setTiktokSyncStatusOne($authority_id, 'goods_status', 3); Log::info('TalentJob->showcaseGoodList success! ' . \json_encode($data, \JSON_UNESCAPED_UNICODE)); $job->delete(); } catch (Throwable $e) { if (stripos($e->getMessage(), 'access_token过期')) { $job->delete(); Log::error('TalentJob->showcaseGoodList Exception! ' . \json_encode($data) . ' ' . $e->getMessage() . ' ' . substr($e->getTraceAsString(), 0, 1000)); return ''; } $job->release(20); // 延迟时间 Log::error('TalentJob->showcaseGoodList exception! ' . $e->getMessage() . ' ' . \json_encode($data) . substr($e->getTraceAsString(), 0, 1000)); } } ~~~ ``` ![](https://img.kancloud.cn/89/fc/89fcce0597cf3ce961fc8ab821f26ba7_1336x822.png) ![](https://img.kancloud.cn/86/46/8646a8efce88e3046335733adf95d1e3_1159x592.png)