链街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.
 
 
 
 

71 lines
1.8 KiB

<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
class setStoreUsers extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'migrateData:setStoreUsers';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Command 店铺的账号表整理';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
* 店铺的登录账号,店长、店员
* 将旧账号表的关联的店铺id和角色洗到新的店铺账号表
* @return int
*/
public function handle()
{
// 如果表不存在则创建
if(!Schema::hasTable('lanzu_store_users')){
Schema::create('lanzu_store_users',function (Blueprint $table){
$table->id();
});
}
$account = DB::table('ims_cjdc_account')->get();
$bar = $this->output->createProgressBar(count($account));
$bar->start();
foreach ($account as $ka => $va){
$data = [];
$storeUsers = DB::table('lanzu_store_users')->find($va->uid);
if(!empty($storeUsers)){
$data =[
'user_category'=>$va->role,
'store_id'=>$va->storeid
];
DB::table('lanzu_store_users')->where('id',$va->uid)->update($data);
}
$bar->advance();
}
$bar->finish();
return 0;
}
}