ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 发布命令 ![](https://img.kancloud.cn/f8/9f/f89f37b1d89ffffc3e0c3d27135aee8b_965x520.png) ![](https://img.kancloud.cn/f9/89/f9891ab6e64cd11c285b3b95080ef2fe_1547x804.png) ## 执行命令 ``` ~~~ <?php namespace app\command\talent; use app\applet\model\user\UserTiktokModel; use think\console\Command; use think\console\Input; use think\console\input\Option; use think\console\Output; use think\facade\Queue; /** * 更新达人商品橱窗数据 */ class TalentShowcaseGoodSync extends Command { protected function configure() { // 指令配置 $this->setName('Talent:ShowcaseGoodSync') ->addOption('user_tiktok_id', 'u', Option::VALUE_OPTIONAL, 'tiktok表主键id') ->setDescription('同步达人商品橱窗数据'); } protected function execute(Input $input, Output $output) { // 指令输出 $output->writeln('开始更新达人商品橱窗数据!'); $userTiktokId = $input->getOption('user_tiktok_id'); $userTiktokModel = UserTiktokModel::where([ 'type' => 'talent', 'status' => 1, 'banned' => 1, ]); if ($userTiktokId) { $userTiktokModel = $userTiktokModel->whereIn('id', \explode(',', $userTiktokId)); } $userTiktokModel = $userTiktokModel->field('id,authority_id,access_token,open_id'); $userTiktokModel->chunk(10, function ($userTiktoks) { foreach ($userTiktoks as $userTiktok) { # 发送同步达人橱窗任务 $jobData = [$userTiktok->authority_id, $userTiktok->access_token, $userTiktok->open_id]; Queue::push('TalentJob@showcaseGoodList', $jobData, "TalentJob"); } }); } } ~~~ ``` ![](https://img.kancloud.cn/76/9f/769f268a9e125d657d6228fa54563d11_1362x850.png) ## 命令行执行 ``` php think Talent:ShowcaseGoodSync ``` ![](https://img.kancloud.cn/7e/8b/7e8bfaf42e3f4546239c3b09603f3dd2_922x210.png)