客户标签

This commit is contained in:
2025-07-17 16:25:47 +08:00
parent cb06f7a0e9
commit 02b752aa98
2 changed files with 13 additions and 5 deletions
+10 -5
View File
@@ -17,7 +17,7 @@ class TagGroupController extends BaseController
{ {
$list = TagGroup::with('tags')->get(); $list = TagGroup::with('tags')->get();
$languageArr = Constants::LANGUAGE; $languageArr = Constants::LANGUAGE;
$language = $request->user['language']; $language = 'zh_CN';
foreach ($list as &$item) { foreach ($list as &$item) {
$item['names'] = unserialize($item['names']); $item['names'] = unserialize($item['names']);
if (in_array($language, $languageArr)) { if (in_array($language, $languageArr)) {
@@ -52,10 +52,15 @@ class TagGroupController extends BaseController
return $this->error( trans('tag_group_id') . trans('not_null')); return $this->error( trans('tag_group_id') . trans('not_null'));
} }
if(empty($tagId)){
$res = CustomerTag::where(['customer_id' => $customerId, 'group_id' => $groupId])->delete(); try {
}else{ if(empty($tagId)){
$res = CustomerTag::updateOrCreate(['customer_id' => $customerId, 'group_id' => $groupId], ['tag_id' => $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){ if($res){
+3
View File
@@ -104,5 +104,8 @@ Route::group('/crm', function () {
Route::any('/customer/statistics', [app\crm\controller\CustomerController::class, 'statistics']); Route::any('/customer/statistics', [app\crm\controller\CustomerController::class, 'statistics']);
Route::any('/customer/getChannel', [app\crm\controller\CustomerController::class, 'getChannel']); Route::any('/customer/getChannel', [app\crm\controller\CustomerController::class, 'getChannel']);
Route::any('/customer/getCountry', [app\crm\controller\CustomerController::class, 'getCountry']); 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']);
}); });