链街Dcat后台
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.
 
 
 
 

65 lines
1.2 KiB

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\LanzuGoods;
use App\Models\LanzuStore;
class SetGoodsMarketId extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'migrateData:SetGoodsMarketId';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command 根据商品表中storeid设置市场id';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$goods = LanzuGoods::all();
$no_store_ids = [];
foreach($goods as $key => $item){
$store = LanzuStore::find($item->store_id);
if($store){
$item->market_id = $store->market_id;
$item->save();
print_r($item->id.'\r\n');
}else{
$no_store_ids[] = $item->store_id;
break;
}
}
var_dump($no_store_ids);
return 0;
}
}