From d6beca388d6e5c75e2ad72f8b3b1a7d50ed8ae26 Mon Sep 17 00:00:00 2001 From: liangyuyan <1103300295@qq.com> Date: Sat, 5 Sep 2020 14:33:29 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=A7=E5=95=86?= =?UTF-8?q?=E6=88=B7=E9=92=B1=E5=8C=85=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/SetStoreBalance.php | 42 ++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 app/Console/Commands/SetStoreBalance.php diff --git a/app/Console/Commands/SetStoreBalance.php b/app/Console/Commands/SetStoreBalance.php new file mode 100644 index 0000000..2440b45 --- /dev/null +++ b/app/Console/Commands/SetStoreBalance.php @@ -0,0 +1,42 @@ + Date: Sat, 5 Sep 2020 14:34:14 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=97=A7=E5=95=86?= =?UTF-8?q?=E6=88=B7=E9=92=B1=E5=8C=85=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Commands/SetGoodsMarketId.php | 2 +- app/Console/Commands/SetStoreBalance.php | 48 +++++++++++++++++++++-- 2 files changed, 46 insertions(+), 4 deletions(-) diff --git a/app/Console/Commands/SetGoodsMarketId.php b/app/Console/Commands/SetGoodsMarketId.php index 1bf52c4..7fd4f21 100644 --- a/app/Console/Commands/SetGoodsMarketId.php +++ b/app/Console/Commands/SetGoodsMarketId.php @@ -15,7 +15,7 @@ class SetGoodsMarketId extends Command * * @var string */ - protected $signature = 'command:SetGoodsMarketId'; + protected $signature = 'migrateData:SetGoodsMarketId'; /** * The console command description. diff --git a/app/Console/Commands/SetStoreBalance.php b/app/Console/Commands/SetStoreBalance.php index 2440b45..c61a322 100644 --- a/app/Console/Commands/SetStoreBalance.php +++ b/app/Console/Commands/SetStoreBalance.php @@ -3,6 +3,8 @@ namespace App\Console\Commands; use Illuminate\Console\Command; +use App\Models\v3\Store as StoreModel; +use Illuminate\Support\Facades\DB; class SetStoreBalance extends Command { @@ -11,14 +13,14 @@ class SetStoreBalance extends Command * * @var string */ - protected $signature = 'command:name'; + protected $signature = 'migrateData:setStoreBalance'; /** * The console command description. * * @var string */ - protected $description = 'Command description'; + protected $description = 'Command 在user_balance表添加商户钱包'; /** * Create a new command instance. @@ -32,11 +34,51 @@ class SetStoreBalance extends Command /** * Execute the console command. - * + * 添加商户钱包 + * 先判断是否存在,不存在则添加一条店铺的钱包记录 * @return int */ public function handle() { + $oldData = DB::table('ims_cjdc_store')->get(); + var_dump('start_time:'.date('H:i:s',time())); + $bar = $this->output->createProgressBar(count($oldData)); + $bar->start(); + + $data = []; + $newData = []; + foreach ($oldData as $key => $value){ + // 查询店铺是否存在balance + $exist = DB::table('lanzu_user_balance') + ->where('source_id',$value->id) + ->where('user_type',5) + ->first(); + + if(empty($exist)){ + $newData[] = [ + 'source_id' => $value->id, + 'user_type' => 5, + 'balance' => 0, + 'created_at' => time(), + 'updated_at' => time() + ]; + }else{ + $data[] = [ + 'store_id' => $value->id, + 'balance_id' => $exist->id + ]; + } + $bar->advance(); + } + // 添加到新表 + $res = DB::table('lanzu_user_balance')->insert($newData); + + $bar->finish(); + var_dump(' end_time: '.date('H:i:s',time())); + var_dump('new_total: '.count($newData)); + var_dump('exist: '.count($data)); + var_dump('res: '.$res); + // var_dump($data); return 0; } } From e3a5cd3f46a3d3156102d43ebe5845f18ef19487 Mon Sep 17 00:00:00 2001 From: liangyuyan <1103300295@qq.com> Date: Sat, 5 Sep 2020 14:57:08 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=B7=B2=E5=9C=A8=E9=A6=96=E9=A1=B5=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Admin/Controllers/v3/CategoryController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Admin/Controllers/v3/CategoryController.php b/app/Admin/Controllers/v3/CategoryController.php index be548dd..dd41624 100644 --- a/app/Admin/Controllers/v3/CategoryController.php +++ b/app/Admin/Controllers/v3/CategoryController.php @@ -32,7 +32,7 @@ class CategoryController extends AdminController $logo = ""; $actions = ''; - $actions = (in_array($branch['id'],$select)) ?'已绑定':$actions; + $actions = (in_array($branch['id'],$select)) ?'在首页显示':$actions; return "{$branch['id']} - {$branch['title']} $logo $actions"; });