|
@@ -0,0 +1,59 @@
|
|
|
|
+<?php
|
|
|
|
+
|
|
|
|
+namespace App\Console\Commands;
|
|
|
|
+
|
|
|
|
+use App\Models\UserFinanceModel;
|
|
|
|
+use App\Models\UserOrderModel;
|
|
|
|
+use Illuminate\Console\Command;
|
|
|
|
+
|
|
|
|
+class updateUserFinance extends Command
|
|
|
|
+{
|
|
|
|
+ /**
|
|
|
|
+ * The name and signature of the console command.
|
|
|
|
+ *
|
|
|
|
+ * @var string
|
|
|
|
+ */
|
|
|
|
+ protected $signature = 'updateUserFianance';
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * The console command description.
|
|
|
|
+ *
|
|
|
|
+ * @var string
|
|
|
|
+ */
|
|
|
|
+ protected $description = '修复用户流水记录';
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Create a new command instance.
|
|
|
|
+ *
|
|
|
|
+ * @return void
|
|
|
|
+ */
|
|
|
|
+ public function __construct()
|
|
|
|
+ {
|
|
|
|
+ parent::__construct();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Execute the console command.
|
|
|
|
+ *
|
|
|
|
+ * @return mixed
|
|
|
|
+ */
|
|
|
|
+ public function handle()
|
|
|
|
+ {
|
|
|
|
+ //获取没有用户ID的流水记录
|
|
|
|
+ $datas = UserFinanceModel::query()
|
|
|
|
+ ->whereNull("user_id")
|
|
|
|
+ ->get();
|
|
|
|
+ foreach ($datas as $data) {
|
|
|
|
+ $order = UserOrderModel::query()
|
|
|
|
+ ->where("order_number",$data["order_number"])
|
|
|
|
+ ->first();
|
|
|
|
+ UserFinanceModel::query()
|
|
|
|
+ ->where("id",$data["id"])
|
|
|
|
+ ->update(
|
|
|
|
+ [
|
|
|
|
+ "user_id"=>$order["user_id"]
|
|
|
|
+ ]
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|