Bläddra i källkod

删除客户后删除相对应的移交和跟进记录

yb 2 månader sedan
förälder
incheckning
96f95ea461
1 ändrade filer med 7 tillägg och 0 borttagningar
  1. 7 0
      app/admin/service/consultant/CustomService.php

+ 7 - 0
app/admin/service/consultant/CustomService.php

@@ -489,13 +489,20 @@ class CustomService
         if (!is_array($ids)) {
             $ids = [$ids];
         }
+        Db::beginTransaction();
         try {
             if (is_array($ids)) {
                 MarketCustomer::whereIn('id', $ids)->delete();
+                MarketCustomerFollow::whereIn('market_customer_id', $ids)->delete();//删除跟进记录
+                MarketCustomerLogs::whereIn('market_customer_id', $ids)->delete();//删除移交记录
             } else {
                 MarketCustomer::where('id', $ids)->delete();
+                MarketCustomerFollow::where('market_customer_id', $ids)->delete();//删除跟进记录
+                MarketCustomerLogs::where('market_customer_id', $ids)->delete();//删除移交记录
             }
+            Db::commit();
         } catch (\Exception $e) {
+            Db::rollBack();
             return json_fail('删除失败');
         }