From 9a13c23788c97271ef79a24566eb471565dd33af Mon Sep 17 00:00:00 2001 From: "HESU\\HESU" <1696136552@qq.com> Date: Tue, 15 Jul 2025 13:52:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A2=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/crm/controller/CustomerController.php | 1 + app/crm/model/Customer.php | 4 ++-- app/crm/model/CustomerTag.php | 2 +- app/crm/model/Tag.php | 2 +- app/crm/service/CustomerService.php | 11 ++++++----- config/route.php | 7 ++++++- 6 files changed, 17 insertions(+), 10 deletions(-) diff --git a/app/crm/controller/CustomerController.php b/app/crm/controller/CustomerController.php index d8b4887..9c9cd05 100644 --- a/app/crm/controller/CustomerController.php +++ b/app/crm/controller/CustomerController.php @@ -130,6 +130,7 @@ class CustomerController extends BaseController $param = $request->all(); $param['user_id'] = $request->user->uid; $result = (new CustomerService())->list($param); + return $this->success($this->page($result)); } catch (\Throwable $e) { return $this->error($e->getMessage()); diff --git a/app/crm/model/Customer.php b/app/crm/model/Customer.php index 3935a79..6c17787 100644 --- a/app/crm/model/Customer.php +++ b/app/crm/model/Customer.php @@ -66,7 +66,7 @@ class Customer extends Model */ public static function getCustomer($customer, $request, $tag = false) { - $language = $request->user['language'] ?: 'en'; + $language = 'zh_CN' ?: 'en'; $customer['grade_txt'] = Util::language($language, Constants::GRADE_EN[$customer['grade']], Constants::GRADE_ZH[$customer['grade']], Constants::GRADE_RU[$customer['grade']]); $customer['magnitude_txt'] = Util::language($language, Constants::MAGNITUDE_EN[$customer['magnitude']], Constants::MAGNITUDE[$customer['magnitude']], Constants::MAGNITUDE_RU[$customer['magnitude']]); $customer['sex_txt'] = Util::language($language, Constants::SEX_EN[$customer['sex']], Constants::SEX[$customer['sex']], Constants::SEX_RU[$customer['sex']]); @@ -117,7 +117,7 @@ class Customer extends Model */ public function tags() { - return $this->belongsToMany(Tag::class, 'customer_tag', 'customer_id', 'tag_id') + return $this->belongsToMany(Tag::class, 'crm_customer_tag', 'customer_id', 'tag_id') ->withTimestamps(); // 如果需要记录关联时间 } diff --git a/app/crm/model/CustomerTag.php b/app/crm/model/CustomerTag.php index b6a26bf..3a0c567 100644 --- a/app/crm/model/CustomerTag.php +++ b/app/crm/model/CustomerTag.php @@ -14,7 +14,7 @@ class CustomerTag extends Model * * @var string */ - protected $table = 'customer_tag'; + protected $table = 'crm_customer_tag'; /** * The primary key associated with the table. diff --git a/app/crm/model/Tag.php b/app/crm/model/Tag.php index 3e7ec25..e58bb87 100644 --- a/app/crm/model/Tag.php +++ b/app/crm/model/Tag.php @@ -50,6 +50,6 @@ class Tag extends Model public function customers() { - return $this->belongsToMany(Customer::class, 'customer_tag', 'tag_id', 'customer_id'); + return $this->belongsToMany(Customer::class, 'crm_customer_tag', 'tag_id', 'customer_id'); } } \ No newline at end of file diff --git a/app/crm/service/CustomerService.php b/app/crm/service/CustomerService.php index d21d460..74baab2 100644 --- a/app/crm/service/CustomerService.php +++ b/app/crm/service/CustomerService.php @@ -17,11 +17,12 @@ class CustomerService if(empty($user_id) || $user_id == 0){ $where[] = ['user_id', '=', $user_id]; } - $user = Customer::with('user')->where($where)->paginate($perPage, ['*'], 'page', $page); - $user = $user->toArray(); - foreach ($user['data'] as &$item) { - unset($item['password']); - } + $user = Customer::where($where)->paginate($perPage, ['*'], 'page', $page); +// $user = Customer::with('user')->where($where)->paginate($perPage, ['*'], 'page', $page); +// $user = $user->toArray(); +// foreach ($user['data'] as &$item) { +// unset($item['password']); +// } return $user; } } \ No newline at end of file diff --git a/config/route.php b/config/route.php index e8af21a..4c29ced 100644 --- a/config/route.php +++ b/config/route.php @@ -81,10 +81,15 @@ Route::group('/ticket', function () { //crm Route::group('/crm', function () { + //跟进 Route::any('/follow/list', [app\crm\controller\FollowController::class, 'list']); Route::any('/follow/detail', [app\crm\controller\FollowController::class, 'detail']); Route::any('/follow/add', [app\crm\controller\FollowController::class, 'save']); Route::any('/follow/getFollowType', [app\crm\controller\FollowController::class, 'getFollowType']); - Route::any('/follow/getFollowType', [app\crm\controller\FollowController::class, 'getFollowType']); + + //客户 + Route::any('/customer/list', [app\crm\controller\CustomerController::class, 'list']); + Route::any('/customer/detail', [app\crm\controller\CustomerController::class, 'detail']); + Route::any('/customer/add', [app\crm\controller\CustomerController::class, 'save']); });