Ken 3 days ago
parent
commit
97e6bcde1f

+ 8 - 1
app/Models/Backflow.php

@@ -10,16 +10,23 @@ namespace App\Models;
  * @property $backflow_ratio
  * @property $member_id
  * @property $amount
+ * @property $grant_time
  *
  */
 class Backflow extends BaseModel
 {
     protected $table = 'backflow';
-    protected $fillable = ['date', 'member_id', 'recharge_amount', 'withdrawal_amount', 'backflow_ratio', 'amount', 'status'];
+    protected $fillable = ['date', 'member_id', 'grant_time', 'recharge_amount', 'withdrawal_amount', 'backflow_ratio', 'amount', 'status'];
 
     function user()
     {
         return $this->belongsTo(User::class, 'member_id', 'member_id')
             ->select(['id', 'member_id', 'username', 'first_name']);
     }
+
+    protected function getGrantTimeAttribute($value): string
+    {
+        if ($value > 0) return date('Y-m-d H:i', strtotime($value));
+        return "";
+    }
 }

+ 1 - 0
app/Services/BackflowService.php

@@ -54,6 +54,7 @@ class BackflowService extends BaseService
         } else {
             $backflow->amount = 0;
         }
+        $backflow->grant_time = time();
         $backflow->status = 1;
         if (false !== $backflow->save()) return true;
         throw new Exception('发放失败', HttpStatus::CUSTOM_ERROR);

+ 30 - 0
database/migrations/2026_01_28_094017_update_backflow.php

@@ -0,0 +1,30 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration
+{
+    /**
+     * Run the migrations.
+     *
+     * @return void
+     */
+    public function up()
+    {
+        Schema::table('backflow', function (Blueprint $table) {
+            $table->integer('grant_time')->default(0)->comment('发放时间');
+        });
+    }
+
+    /**
+     * Reverse the migrations.
+     *
+     * @return void
+     */
+    public function down()
+    {
+        //
+    }
+};