| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- <?php
- namespace app\command;
- use app\extra\dyLife\data\BaseData;
- use app\model\saas\SaasGoods;
- use app\model\saas\SaasStore;
- use Symfony\Component\Console\Command\Command;
- use Symfony\Component\Console\Input\InputInterface;
- use Symfony\Component\Console\Output\OutputInterface;
- class UpdateGoods extends Command
- {
- protected static string $defaultName = 'update:all';
- protected static string $defaultDescription = '统一生成Model';
- protected function execute(InputInterface $input, OutputInterface $output): int
- {
- try {
- $nextPage = 1;
- while (is_numeric($nextPage)) {
- $resp = (new SaasGoods)->where("status",1)->with(['skuSpecs'])->page($nextPage,10)->select();
- if ($resp->isEmpty()) {
- $output->writeln("没有任务啦==".getDateFull());
- $nextPage = null;
- return true;
- }
- foreach ($resp as $param) {
- $store = (new SaasStore)->where("poi_id",$param['poi_id'])->findOrEmpty();
- // 获取attr_key_value_map参数
- $valMap = (new BaseData)->config([
- "appid" => sConf("wechat.appid"),
- "secret" => sConf("wechat.secret"),
- "account" => sConf("wechat.shop_id"),
- ])->token()->getStoreCategoryTemplate($param['category_id'],$param['product_type']);
- $data = (new BaseData)->config([
- "appid" => sConf("wechat.mini_appid"),
- "secret" => sConf("wechat.mini_secret"),
- ])->token()->createGoodsData($param->toArray(),[],$store->toArray(),$valMap,"edit");
- echo getDateFull()."====修改返回信息\n";
- echo json_encode($data)."\n";
- }
- $nextPage = $nextPage+1;
- $output->writeln("进入下一页=={$nextPage}==".getDateFull());
- }
- } catch (\Throwable $throwable) {
- echo getDateFull()."==报错啦===".$throwable->getFile()."\n";
- echo getDateFull()."==报错啦===".$throwable->getLine()."\n";
- echo getDateFull()."==报错啦===".$throwable->getMessage()."\n";
- }
- return self::SUCCESS;
- }
- }
|