mark 2 years ago
parent
commit
e80d5df60d
2 changed files with 70 additions and 0 deletions
  1. 59 0
      app/Console/Commands/updateUserFinance.php
  2. 11 0
      app/Http/Logic/Cron/CronLogic.php

+ 59 - 0
app/Console/Commands/updateUserFinance.php

@@ -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"]
+                    ]
+                );
+        }
+    }
+}

+ 11 - 0
app/Http/Logic/Cron/CronLogic.php

@@ -578,6 +578,7 @@ class CronLogic extends BaseLogic
                                "cash_receive_at"=>date("Y-m-d H:i:s")
                            ]
                        );
+                   $cash_status = 1;//打款成功
 
                }else{
                    //打款失败
@@ -589,7 +590,17 @@ class CronLogic extends BaseLogic
                                "upstream_response"=>json_encode($res)
                            ]
                        );
+                   $cash_status = 2;//打款失败
                }
+
+               //修改提现流水的状态
+               UserFinanceModel::query()->where("id",$cashLog["user_finance_id"])
+                   ->update(
+                       [
+                            "cash_status"=>$cash_status,
+                           "updated_at"=>date("Y-m-d H:i:s")
+                       ]
+                   );
            }
         }
     }