Browse Source

feat: 引入StorageType枚举并更新CommissionService,以将其用于钱包余额更新

刘学玺 3 months ago
parent
commit
b5b2482ef2
2 changed files with 11 additions and 2 deletions
  1. 9 0
      app/Enums/StorageType.php
  2. 2 2
      app/Services/Coach/CommissionService.php

+ 9 - 0
app/Enums/StorageType.php

@@ -0,0 +1,9 @@
+<?php
+
+namespace App\Enums;
+
+enum StorageType: int
+{
+    case Balance = 1;
+    case Recharge = 2;
+}

+ 2 - 2
app/Services/Coach/CommissionService.php

@@ -10,6 +10,7 @@ use App\Models\Wallet;
 use App\Models\WalletSplitRecord;
 use Illuminate\Support\Facades\DB;
 use Illuminate\Support\Facades\Log;
+use App\Enums\StorageType;
 
 class CommissionService
 {
@@ -52,7 +53,6 @@ class CommissionService
 
                 // 处理代理商和平台分佣
                 $this->handleAgentAndPlatformCommission($order, $profitAmount, $inviterAmount);
-
             } catch (\Exception $e) {
                 Log::error('订单分佣失败', [
                     'order_id' => $order->id,
@@ -215,7 +215,7 @@ class CommissionService
             'owner_type' => Order::class,
             'role' => $role,
             'trans_type' => 1,
-            'storage_type' => 'balance',
+            'storage_type' => StorageType::Balance->value,
             'amount' => $amount,
             'before_balance' => $wallet->available_balance - $amount,
             'after_balance' => $wallet->available_balance,