Ken hai 4 días
pai
achega
bff6b125d2
Modificáronse 1 ficheiros con 9 adicións e 0 borrados
  1. 9 0
      app/Services/BackflowService.php

+ 9 - 0
app/Services/BackflowService.php

@@ -34,6 +34,15 @@ class BackflowService extends BaseService
         } else {
             $backflow = static::$MODEL::create($data);
         }
+        $restriction = Config::where('field', 'huishui_percentage')->first()->val;
+        $difference = bcadd($backflow->recharge_amount, $backflow->withdrawal_amount, 2);
+        $difference = $difference * -1;
+        if ($difference >= $restriction) {
+            $backflow->amount = bcmul($difference, $backflow->backflow_ratio, 2);
+        }else{
+            $backflow->amount = 0;
+        }
+        $backflow->save();
         return $backflow;
     }