Ken hai 2 horas
pai
achega
7661f5bf69
Modificáronse 1 ficheiros con 13 adicións e 0 borrados
  1. 13 0
      app/Models/Rebate.php

+ 13 - 0
app/Models/Rebate.php

@@ -51,6 +51,19 @@ class Rebate extends Authenticatable
     }
 
 
+    protected function getHuishuiAmountAttribute($value)
+    {
+        $value = 0;
+        $huishui_restriction = Config::where('field', 'huishui_restriction')->first()->val;
+        $huishui_percentage = Config::where('field', 'huishui_percentage')->first()->val;
+        $lose = $this->profit * -1;
+        if ($lose >= $huishui_restriction) {
+            $value = bcmul($lose, $huishui_percentage, 2); // 返利金额
+        }
+        return $value;
+    }
+
+
     protected function getCreatedAtAttribute($value)
     {
         return \Carbon\Carbon::parse($value)->setTimezone('Asia/Shanghai')->format('Y-m-d H:i:s');