Ken 6 小时之前
父节点
当前提交
7661f5bf69
共有 1 个文件被更改,包括 13 次插入0 次删除
  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');