Ken 1 week ago
parent
commit
b064b156a4
2 changed files with 9 additions and 5 deletions
  1. 2 2
      app/Http/Controllers/admin/Rebate.php
  2. 7 3
      app/Models/Rebate.php

+ 2 - 2
app/Http/Controllers/admin/Rebate.php

@@ -13,7 +13,7 @@ use Illuminate\Http\Request;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Validation\ValidationException;
 use Exception;
-
+use App\Models\Rebate as RebateModel;
 class Rebate extends Controller
 {
     function index()
@@ -43,7 +43,7 @@ class Rebate extends Controller
             $params = request()->validate([
                 'id' => ['required', 'integer', 'min:1'],
             ]);
-            $params['status'] = 0;
+            $params['status'] = RebateModel::STATUS_WEI_FAN_YONG;
             $rebate = RebateService::findOne($params);
             if (!$rebate) throw new Exception('数据不存在', HttpStatus::CUSTOM_ERROR);
             $date = Carbon::now('America/New_York')->format('Y-m-d');

+ 7 - 3
app/Models/Rebate.php

@@ -11,6 +11,10 @@ class Rebate extends BaseModel
         'amount', 'status', 'first_name', 'username', 'audited_by',
         'profit', 'huishui_percentage', 'huishui_restriction', 'huishui_amount',
     ];
+    const STATUS_WEI_FAN_YONG = 0;//未返佣
+    const STATUS_FAN_YONG = 1; //已返佣
+
+
 
 
     static function updateProfit($data)
@@ -41,7 +45,7 @@ class Rebate extends BaseModel
 
     protected function getHuishuiRestrictionAttribute($value)
     {
-        if ($this->status == 0) {
+        if ($this->status == static::STATUS_WEI_FAN_YONG) {
             $huishui_restriction = Config::where('field', 'huishui_restriction')->first()->val;
             return $huishui_restriction;
         }
@@ -51,7 +55,7 @@ class Rebate extends BaseModel
 
     protected function getHuishuiPercentageAttribute($value)
     {
-        if ($this->status == 0) {
+        if ($this->status == static::STATUS_WEI_FAN_YONG) {
             $huishui_percentage = Config::where('field', 'huishui_percentage')->first()->val;
             return $huishui_percentage;
         }
@@ -60,7 +64,7 @@ class Rebate extends BaseModel
 
     protected function getHuishuiAmountAttribute($value)
     {
-        if ($this->status == 0) {
+        if ($this->status == static::STATUS_WEI_FAN_YONG) {
             $value = 0;
             $huishui_restriction = Config::where('field', 'huishui_restriction')->first()->val;
             $huishui_percentage = Config::where('field', 'huishui_percentage')->first()->val;