This commit is contained in:
2025-07-15 13:52:31 +08:00
parent d102e61ddb
commit 9a13c23788
6 changed files with 17 additions and 10 deletions
@@ -130,6 +130,7 @@ class CustomerController extends BaseController
$param = $request->all(); $param = $request->all();
$param['user_id'] = $request->user->uid; $param['user_id'] = $request->user->uid;
$result = (new CustomerService())->list($param); $result = (new CustomerService())->list($param);
return $this->success($this->page($result)); return $this->success($this->page($result));
} catch (\Throwable $e) { } catch (\Throwable $e) {
return $this->error($e->getMessage()); return $this->error($e->getMessage());
+2 -2
View File
@@ -66,7 +66,7 @@ class Customer extends Model
*/ */
public static function getCustomer($customer, $request, $tag = false) 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['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['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']]); $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() 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(); // 如果需要记录关联时间 ->withTimestamps(); // 如果需要记录关联时间
} }
+1 -1
View File
@@ -14,7 +14,7 @@ class CustomerTag extends Model
* *
* @var string * @var string
*/ */
protected $table = 'customer_tag'; protected $table = 'crm_customer_tag';
/** /**
* The primary key associated with the table. * The primary key associated with the table.
+1 -1
View File
@@ -50,6 +50,6 @@ class Tag extends Model
public function customers() 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');
} }
} }
+6 -5
View File
@@ -17,11 +17,12 @@ class CustomerService
if(empty($user_id) || $user_id == 0){ if(empty($user_id) || $user_id == 0){
$where[] = ['user_id', '=', $user_id]; $where[] = ['user_id', '=', $user_id];
} }
$user = Customer::with('user')->where($where)->paginate($perPage, ['*'], 'page', $page); $user = Customer::where($where)->paginate($perPage, ['*'], 'page', $page);
$user = $user->toArray(); // $user = Customer::with('user')->where($where)->paginate($perPage, ['*'], 'page', $page);
foreach ($user['data'] as &$item) { // $user = $user->toArray();
unset($item['password']); // foreach ($user['data'] as &$item) {
} // unset($item['password']);
// }
return $user; return $user;
} }
} }
+6 -1
View File
@@ -81,10 +81,15 @@ Route::group('/ticket', function () {
//crm //crm
Route::group('/crm', function () { Route::group('/crm', function () {
//跟进
Route::any('/follow/list', [app\crm\controller\FollowController::class, 'list']); Route::any('/follow/list', [app\crm\controller\FollowController::class, 'list']);
Route::any('/follow/detail', [app\crm\controller\FollowController::class, 'detail']); Route::any('/follow/detail', [app\crm\controller\FollowController::class, 'detail']);
Route::any('/follow/add', [app\crm\controller\FollowController::class, 'save']); 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('/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']);
}); });