diff --git a/app/Console/Commands/MigrateStoreAccount.php b/app/Console/Commands/MigrateStoreAccount.php index 5e4debd..8cdbccb 100644 --- a/app/Console/Commands/MigrateStoreAccount.php +++ b/app/Console/Commands/MigrateStoreAccount.php @@ -77,11 +77,14 @@ class MigrateStoreAccount extends Command foreach ($oldData as $key => $value){ $storeId = $value->store_id; $userId = $value->user_id; - if(empty($userId)){ - $error[] = ['id'=>$userId]; + if(empty($userId) || empty($storeId)){ + $error[] = ['user_id'=>$userId,'store_id'=>$storeId]; break; } - + $userType = 0; + $moneyType = 0; + $sourceId = $value->order_id; + $sourceType = 0; // 判断是否存在 总账 $exist = DB::table($newTableName) ->where('user_id',$userId) @@ -90,24 +93,25 @@ class MigrateStoreAccount extends Command ->where('source_type',0) ->where('money_type') ->exists(); - + $desc = ''; + $comment = ''; if(!$exist){ $newData =[ - 'id'=>$userId, - 'nick_name'=>$value->name, + 'user_id'=>$userId, + 'user_type'=>$userType, - 'avatar'=>$value->img, - 'openid'=>$value->openid, + 'money'=>$value->money, + 'money_type'=>$moneyType, - 'total_score'=>$value->total_score, - 'wallet'=>$value->wallet, + 'source_id'=>$sourceId, + 'source_type'=>$sourceType, - 'real_name'=>$value->user_name, - 'tel'=>$value->user_tel, - 'unionid'=>$value->unionid, + 'desc'=>$desc, + 'comment'=>$comment, + 'status'=>1, - 'created_at' => strtotime($value->join_time), - 'updated_at' => $value->updated_at, + 'created_at' => time(), + 'updated_at' => time(), ]; $res = DB::table($newTableName)->insert($newData); @@ -154,4 +158,9 @@ class MigrateStoreAccount extends Command var_dump($error); return 0; } + + public function getMoneyType($type,$note) + { + + } } diff --git a/app/Console/Commands/MigrateStoreBalance.php b/app/Console/Commands/MigrateStoreBalance.php new file mode 100644 index 0000000..487b85d --- /dev/null +++ b/app/Console/Commands/MigrateStoreBalance.php @@ -0,0 +1,80 @@ +orderBy('id','asc')->get(); + $bar = $this->output->createProgressBar(count($oldData)); + $bar->start(); + $startTime = time(); + $error = []; + $newData = []; + foreach ($oldData as $key => $value){ + $storeId = $value->store_id; + + + + $bar->advance(); + } + + DB::table($newTableName)->insert($newData); + + $bar->finish(); + var_dump([time()-$startTime]); + var_dump($error); + return 0; + } +}