You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
yanzong/app/command/SyncGoodsToEs.php

49 lines
1.4 KiB

6 months ago
<?php
namespace app\command;
6 months ago
use app\common\service\GoodsCateEs;
6 months ago
use app\common\service\GoodsEs;
6 months ago
use think\console\Command;
6 months ago
use think\console\Output;
use think\console\Input;
6 months ago
class SyncGoodsToEs extends Command
{
protected function configure()
{
// 指令配置
5 months ago
$this->setName('syncGoodsToEs')->setDescription('同步商品数据到ES');
$this->addArgument("type");
$this->addArgument("goods_id");
3 months ago
$this->addArgument("store_id");
6 months ago
}
protected function execute(Input $input, Output $output)
{
5 months ago
$type = $input->getArgument("type");
$goods_id = $input->getArgument("goods_id");
3 months ago
$store_id = $input->getArgument("store_id");
5 months ago
if ($type == "goods") {
3 months ago
$goodsCateService = new GoodsCateEs();
//$goodsService = new GoodsEs();
//$goodsService->createGoodsIndex();
$goodsCateService->batchCreateGoods($goods_id, $store_id);
5 months ago
} elseif ($type == "goods_cate"){
3 months ago
$goodsCateService = new GoodsCateEs();
//$goodsCateService->createGoodsCateIndex();
$goodsCateService->batchCreateGoodsCategory($goods_id, $store_id);
6 months ago
}
5 months ago
3 months ago
// try {
// $goodsService->batchCreateData();
// }catch (\Exception $e) {
// $output->writeln($e->getMessage());
// }
5 months ago
6 months ago
}
}