From 02b752aa98e5094d10a0838cd2f3710b54ba72a5 Mon Sep 17 00:00:00 2001 From: "HESU\\HESU" <1696136552@qq.com> Date: Thu, 17 Jul 2025 16:25:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/crm/controller/TagGroupController.php | 15 ++++++++++----- config/route.php | 3 +++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/crm/controller/TagGroupController.php b/app/crm/controller/TagGroupController.php index 7e5dff1..3cf24e1 100644 --- a/app/crm/controller/TagGroupController.php +++ b/app/crm/controller/TagGroupController.php @@ -17,7 +17,7 @@ class TagGroupController extends BaseController { $list = TagGroup::with('tags')->get(); $languageArr = Constants::LANGUAGE; - $language = $request->user['language']; + $language = 'zh_CN'; foreach ($list as &$item) { $item['names'] = unserialize($item['names']); if (in_array($language, $languageArr)) { @@ -52,10 +52,15 @@ class TagGroupController extends BaseController return $this->error( trans('tag_group_id') . trans('not_null')); } - if(empty($tagId)){ - $res = CustomerTag::where(['customer_id' => $customerId, 'group_id' => $groupId])->delete(); - }else{ - $res = CustomerTag::updateOrCreate(['customer_id' => $customerId, 'group_id' => $groupId], ['tag_id' => $tagId]); + + try { + if(empty($tagId)){ + $res = CustomerTag::where(['customer_id' => $customerId, 'group_id' => $groupId])->delete(); + }else{ + $res = CustomerTag::updateOrCreate(['customer_id' => $customerId, 'group_id' => $groupId], ['tag_id' => $tagId]); + } + } catch (\Throwable $e) { + return $this->error($e->getMessage()); } if($res){ diff --git a/config/route.php b/config/route.php index 4fd7025..b694023 100644 --- a/config/route.php +++ b/config/route.php @@ -104,5 +104,8 @@ Route::group('/crm', function () { Route::any('/customer/statistics', [app\crm\controller\CustomerController::class, 'statistics']); Route::any('/customer/getChannel', [app\crm\controller\CustomerController::class, 'getChannel']); Route::any('/customer/getCountry', [app\crm\controller\CustomerController::class, 'getCountry']); + + Route::any('/tagGroup/list', [app\crm\controller\TagGroupController::class, 'list']); + Route::any('/tagGroup/updatePivot', [app\crm\controller\TagGroupController::class, 'updatePivot']); });