alroyso hace 11 meses
padre
commit
4cb712912d
Se han modificado 2 ficheros con 40 adiciones y 13 borrados
  1. 6 5
      app/Notifications/TicketClosed.php
  2. 34 8
      app/Services/OrderService.php

+ 6 - 5
app/Notifications/TicketClosed.php

@@ -32,11 +32,12 @@ class TicketClosed extends Notification implements ShouldQueue
 
     public function toMail($notifiable)
     {
-        return (new MailMessage)
-            ->subject(trans('close_ticket', ['id' => $this->id, 'title' => $this->title]))
-            ->line($this->reason)
-            ->action(trans('notification.view_ticket'), $this->url)
-            ->line(__('If your problem has not been solved, Feel free to open other one.'));
+        return "";
+//        return (new MailMessage)
+//            ->subject(trans('close_ticket', ['id' => $this->id, 'title' => $this->title]))
+//            ->line($this->reason)
+//            ->action(trans('notification.view_ticket'), $this->url)
+//            ->line(__('If your problem has not been solved, Feel free to open other one.'));
     }
 
     public function toCustom($notifiable)

+ 34 - 8
app/Services/OrderService.php

@@ -6,8 +6,10 @@ use App\Components\Helpers;
 use App\Models\Order;
 use App\Models\ReferralLog;
 use App\Models\User;
+use DB;
 use Log;
 
+
 class OrderService
 {
     public static $order;
@@ -215,6 +217,8 @@ class OrderService
             }
             // 按照返利模式进行返利判断
             if ($referralType == 2 || $referral) {
+                // 可以考虑将此操作移至数据库事务中,以便在出错时回滚
+
                 return $this->addReferralLog(
                     $user->id,
                     $inviter->id,
@@ -241,14 +245,36 @@ class OrderService
      */
     private function addReferralLog(int $inviteeId, int $inviterId, int $oid, int $amount, int $commission): bool
     {
-        $log = new ReferralLog();
-        $log->invitee_id = $inviteeId;
-        $log->inviter_id = $inviterId;
-        $log->order_id = $oid;
-        $log->amount = $amount;
-        $log->commission = $commission;
-
-        return $log->save();
+//        $log = new ReferralLog();
+//        $log->invitee_id = $inviteeId;
+//        $log->inviter_id = $inviterId;
+//        $log->order_id = $oid;
+//        $log->amount = $amount;
+//        $log->commission = $commission;
+//
+//        return $log->save();
+
+        try {
+            $log = new ReferralLog();
+            $log->invitee_id = $inviteeId;
+            $log->inviter_id = $inviterId;
+            $log->order_id = $oid;
+            $log->amount = $amount;
+            $log->commission = $commission;
+
+            return $log->save();
+        } catch (\Exception $e) {
+            // 记录错误日志,包括异常信息和相关数据
+            Log::error("Failed to add referral log", [
+                'exception' => $e->getMessage(),
+                'userid' => $inviteeId,
+                'inviterId' => $inviterId,
+                'orderId' => $oid,
+                'amount' => $amount,
+                'commission' => $commission
+            ]);
+            return false;
+        }
     }
 
     // 激活预支付套餐