diff --git a/app/crm/controller/FollowController.php b/app/crm/controller/FollowController.php index 7f08e7d..7ee34a4 100644 --- a/app/crm/controller/FollowController.php +++ b/app/crm/controller/FollowController.php @@ -39,9 +39,9 @@ class FollowController extends BaseController public function list(Request $request) { try { - $data = $this->validate(new FollowValidate(), $request->get(), 'upwd_list'); - $result = (new FollowService())->list($request->all()); - return $this->success($this->page($result)); + $data = $this->validate(new FollowValidate(), $request->get(), 'list'); + $result = (new FollowService())->list($request->all(),$request->user->uid); + return $this->success($result); } catch (\Throwable $e) { return $this->error($e->getMessage()); } @@ -69,7 +69,7 @@ class FollowController extends BaseController return $this->error('记录不存在'); } - $res = Follow::getFollow($res); + $res = FollowService::getFollow($res); return $this->success($res); } @@ -96,7 +96,7 @@ class FollowController extends BaseController } $data = [ - 'user_id'=>$request->user['id'], + 'user_id'=>$request->user->uid, 'customer_id'=>$customer_id, 'type'=>$type, 'picture'=>$picture, @@ -117,6 +117,18 @@ class FollowController extends BaseController $customer->warn = 0; $customer->save(); + $follow_next = Util::getParam($request, 'follow_next', 0); + $follow_remark = Util::getParam($request, 'follow_remark', 0); + if($res && (!empty($follow_next))){ + $data = [ + 'follow_next' => $follow_next, + 'follow_remark' => $follow_remark, + 'warn' => 0, + ]; + $res = Customer::where('id', $customer_id) + ->update($data); + } + if ($res) { return $this->success($res,trans('save_success')); } else { diff --git a/app/crm/model/Customer.php b/app/crm/model/Customer.php index 7db2f1e..c03d4ac 100644 --- a/app/crm/model/Customer.php +++ b/app/crm/model/Customer.php @@ -17,7 +17,7 @@ class Customer extends Model * * @var string */ - protected $table = 'customer'; + protected $table = 'crm_customer'; /** * The primary key associated with the table. diff --git a/app/crm/model/CustomerHis.php b/app/crm/model/CustomerHis.php index b7039dd..65d7de6 100644 --- a/app/crm/model/CustomerHis.php +++ b/app/crm/model/CustomerHis.php @@ -17,7 +17,7 @@ class CustomerHis extends Model * * @var string */ - protected $table = 'customer_his'; + protected $table = 'crm_customer_his'; /** * The primary key associated with the table. diff --git a/app/crm/model/Follow.php b/app/crm/model/Follow.php index e44c08b..778b669 100644 --- a/app/crm/model/Follow.php +++ b/app/crm/model/Follow.php @@ -16,7 +16,7 @@ class Follow extends Model * * @var string */ - protected $table = 'follow'; + protected $table = 'crm_follow'; /** * The primary key associated with the table. @@ -47,15 +47,4 @@ class Follow extends Model // 'updated_at' => 'timestamp', // 指定序列化格式 // 'created_at' => 'timestamp', // 指定序列化格式 ]; - - public static function getFollow($follow,$domain = 'https://vehicle-album.oss-cn-beijing.aliyuncs.com') - { - $follow['type_txt'] = Constants::FOLLOW[$follow['type']]; - $follow['firstFollowtime'] = $follow['follow_time']; - $ossservice = new OssService(); - $oss_picture = $ossservice->generatePrivateUrl($follow['picture'],86400); - $follow['oss_picture'] = $oss_picture; -// $follow = Util::formatDate($follow); - return $follow; - } } \ No newline at end of file diff --git a/app/crm/model/Tag.php b/app/crm/model/Tag.php index 4b00471..3e7ec25 100644 --- a/app/crm/model/Tag.php +++ b/app/crm/model/Tag.php @@ -17,7 +17,7 @@ class Tag extends Model * * @var string */ - protected $table = 'tag'; + protected $table = 'crm_tag'; /** * The primary key associated with the table. diff --git a/app/crm/model/TagGroup.php b/app/crm/model/TagGroup.php index 9c2e419..5b5e28e 100644 --- a/app/crm/model/TagGroup.php +++ b/app/crm/model/TagGroup.php @@ -17,7 +17,7 @@ class TagGroup extends Model * * @var string */ - protected $table = 'tag_group'; + protected $table = 'crm_tag_group'; /** * The primary key associated with the table. diff --git a/app/crm/service/FollowService.php b/app/crm/service/FollowService.php index b870416..89b7c2b 100644 --- a/app/crm/service/FollowService.php +++ b/app/crm/service/FollowService.php @@ -2,13 +2,15 @@ namespace app\crm\service; +use app\common\service\OssService; use app\crm\model\Follow; use app\crm\utils\Util; +use config\constants\Constants; class FollowService { - public function list($param) + public function list($param, $userId) { @@ -22,16 +24,9 @@ class FollowService $where['customer_id'] = $customer_id; //用户角色 - $userId = $request->user['id']; - if(Util::isEmpty($userId)){ - return $this->error(trans('user_none')); - } - if($request->user['role']!=1){ - $where['user_id'] = $userId; - } //跟进id - $id = Util::getParam($request,'id'); + $id = $param['id']??null; if(!Util::isEmpty($id)){ $where['id'] = $id; } @@ -43,11 +38,27 @@ class FollowService // $host = $request->host(); - $url = 'http:'.$request->url(); +// $url = 'http:'.$request->url(); foreach ($data as &$value){ - $value = Follow::getFollow($value); + $value = self::getFollow($value); } - return $this->success($data,trans('success')); + return $data; + } + + + + public static function getFollow($follow,$domain = 'https://vehicle-album.oss-cn-beijing.aliyuncs.com') + { + $follow['type_txt'] = Constants::FOLLOW[$follow['type']]; + $follow['firstFollowtime'] = $follow['follow_time']; + $oss_picture = ''; + if(!empty($follow['picture'])){ + $ossservice = new OssService(); + $oss_picture = $ossservice->generatePrivateUrl($follow['picture'],86400); + } + $follow['oss_picture'] = $oss_picture; +// $follow = Util::formatDate($follow); + return $follow; } } \ No newline at end of file diff --git a/app/crm/validate/FollowValidate.php b/app/crm/validate/FollowValidate.php index 2ed6e71..a92c4a0 100644 --- a/app/crm/validate/FollowValidate.php +++ b/app/crm/validate/FollowValidate.php @@ -16,6 +16,6 @@ class FollowValidate extends Validate ]; protected $scene = [ - 'upwd_list' => ['customer_id'], + 'list' => ['customer_id'], ]; } \ No newline at end of file diff --git a/config/route.php b/config/route.php index db2c831..0e25da4 100644 --- a/config/route.php +++ b/config/route.php @@ -65,3 +65,12 @@ 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']); +}); + diff --git a/resource/translations/ar/messages.php b/resource/translations/ar/messages.php index a701f87..7430697 100644 --- a/resource/translations/ar/messages.php +++ b/resource/translations/ar/messages.php @@ -2,4 +2,35 @@ return [ 'status_not_modified' => 'الدولة لا يمكن تعديلها عكسيا', + 'success' => ' النجاح', + 'fail' => ' الفشل', + 'login_success' => ' تم تسجيل الدخول بنجاح', + 'password_error' => ' كلمة المرور غير صحيحة', + 'user_none' => ' المستخدم غير موجود', + 'user_id' => ' معرف المستخدم', + 'user_login' => ' الرجاء تسجيل الدخول أولاً', + 'not_null' => ' لا يمكن أن يكون فارغًا', + 'code_error' => ' رمز التحقق غير صحيح', + 'format_error' => ' تنسيق غير صحيح', + 'email_repeat' => ' البريد الإلكتروني مكرر', + 'email_error' => ' تنسيق البريد الإلكتروني غير صحيح', + 'save_success' => ' تم الحفظ بنجاح', + 'save_fail' => ' فشل الحفظ', + 'register_success' => ' تم التسجيل بنجاح', + 'register_fail' => ' فشل التسجيل', + 'language_success' => ' تم تغيير اللغة بنجاح', + 'language_fail' => ' فشل تغيير اللغة', + 'param_error' => ' خطأ في المعلمات', + 'required_not_null' => ' الحقول المطلوبة لا يمكن أن تكون فارغة', + 'picture_not_null' => ' لا يمكن أن تكون الصورة فارغة', + 'contacts_not_null' => ' لا يمكن أن يكون جهة الاتصال أو البريد الإلكتروني أو الهاتف فارغين جميعًا في نفس الوقت', + 'car_type_not_null' => ' لا يمكن أن تكون التفضيلات فارغة', + 'channel_not_null' => ' لا يمكن أن تكون القناة فارغة', + 'email_consistent' => ' البريد الإلكتروني غير متطابق', + 'sign_not_null' => ' لم يتم تعيين الشركة التابعة', + 'password_short' => ' لا يمكن أن تكون كلمة المرور أقل من 6 أحرف', + 'id_empty' => ' لا يمكن أن يكون المعرف فارغًا', + 'customer_id' => ' معرف العميل', + 'tag_group_id' => ' معرف مجموعة العلامات', + 'claim_fail' => ' لا يمكن استلام العملاء الذين لديهم مالك بالفعل', ]; \ No newline at end of file diff --git a/resource/translations/en/messages.php b/resource/translations/en/messages.php index c676eb2..342ffad 100644 --- a/resource/translations/en/messages.php +++ b/resource/translations/en/messages.php @@ -2,4 +2,35 @@ return [ 'status_not_modified' => 'The status cannot be reversed for modification', + 'success' => ' success', + 'fail' => ' fail', + 'login_success' => ' login success', + 'password_error' => ' password error', + 'user_none' => ' user none', + 'user_id' => ' user ID', + 'user_login' => ' Please log in first', + 'not_null' => ' not null', + 'code_error' => ' code error', + 'format_error' => ' format error', + 'email_repeat' => ' email repeat', + 'email_error' => ' Email format error', + 'save_success' => ' save success', + 'save_fail' => ' save fail', + 'register_success' => ' register success', + 'register_fail' => ' register fail', + 'language_success' => ' Successfully switched languages', + 'language_fail' => ' Language switching failed', + 'param_error' => ' param error', + 'required_not_null' => ' required not_ ull', + 'picture_not_null' => ' picture not null', + 'contacts_not_null' => ' Contact person, email, and phone cannot be empty at the same time', + 'car_type_not_null' => ' preference_not_null', + 'channel_not_null' => ' channel not null', + 'email_consistent' => ' Inconsistent email addresses', + 'sign_not_null' => ' No affiliated company has been set', + 'password_short' => ' Password cannot be less than 6 characters', + 'id_empty' => ' ID cannot be empty', + 'customer_id' => ' customer ID', + 'tag_group_id' => ' tag group ID', + 'claim_fail' => ' Cannot claim ownership of customers', ]; \ No newline at end of file diff --git a/resource/translations/ru/messages.php b/resource/translations/ru/messages.php index 96ab3a4..3a1839f 100644 --- a/resource/translations/ru/messages.php +++ b/resource/translations/ru/messages.php @@ -2,4 +2,35 @@ return [ 'status_not_modified' => 'Статус не может быть изменен в обратном направлении', + 'success' => ' Успех', + 'fail' => ' Неудача', + 'login_success' => ' Регистрация завершена', + 'password_error' => ' Ошибка пароля', + 'user_none' => ' Пользователь не существует', + 'user_id' => ' Идентификатор пользователя', + 'user_login' => ' Пожалуйста, войдите.', + 'not_null' => ' Нельзя быть пустым', + 'code_error' => ' Ошибка кода проверки', + 'format_error' => ' Ошибка формата', + 'email_repeat' => ' Почтовый ящик повторяется', + 'email_error' => ' Ошибка формата почтового ящика', + 'save_success' => ' Сохранить успешно', + 'save_fail' => ' Ошибка сохранения', + 'register_success' => ' Регистрация успешно', + 'register_fail' => ' Ошибка регистрации', + 'language_success' => ' Переключить язык успешно', + 'language_fail' => ' Ошибка переключения языка', + 'param_error' => ' Ошибка параметра', + 'required_not_null' => ' Обязательное заполнение не может быть пустым.', + 'picture_not_null' => ' Фотографии не могут быть пустыми', + 'contacts_not_null' => ' Контакты, почтовый ящик, телефон не может быть одновременно пустым', + 'car_type_not_null' => ' Предпочтения не могут быть пустыми', + 'channel_not_null' => ' Каналы не могут быть пустыми', + 'email_consistent' => ' Почтовый ящик не совпадает', + 'sign_not_null' => ' Компания не создана', + 'password_short' => ' Пароль не может быть меньше 6.', + 'id_empty' => ' ID не может быть пустым', + 'customer_id' => ' Идентификатор клиента', + 'tag_group_id' => ' Идентификатор группы меток', + 'claim_fail' => ' Невозможность получения принадлежащего клиенту', ]; \ No newline at end of file diff --git a/resource/translations/zh/messages.php b/resource/translations/zh/messages.php index 229d7ee..96c3cb7 100644 --- a/resource/translations/zh/messages.php +++ b/resource/translations/zh/messages.php @@ -2,4 +2,35 @@ return [ 'status_not_modified' => '状态不能逆向修改', + 'success' => ' 成功', + 'fail' => ' 失败', + 'login_success' => ' 登录成功', + 'password_error' => ' 密码错误', + 'user_none' => ' 用户不存在', + 'user_id' => ' 用户ID', + 'user_login' => ' 请先登录', + 'not_null' => ' 不能为空', + 'code_error' => ' 验证码错误', + 'format_error' => ' 格式错误', + 'email_repeat' => ' 邮箱重复', + 'email_error' => ' 邮箱格式错误', + 'save_success' => ' 保存成功', + 'save_fail' => ' 保存失败', + 'register_success' => ' 注册成功', + 'register_fail' => ' 注册失败', + 'language_success' => ' 切换语言成功', + 'language_fail' => ' 切换语言失败', + 'param_error' => ' 参数错误', + 'required_not_null' => ' 必填项不能为空', + 'picture_not_null' => ' 图片不能为空', + 'contacts_not_null' => ' 联系人,邮箱,电话不能同时为空', + 'car_type_not_null' => ' 偏好不能为空', + 'channel_not_null' => ' 渠道不能为空', + 'email_consistent' => ' 邮箱不一致', + 'sign_not_null' => ' 未设置所属公司', + 'password_short' => ' 密码不能少于6位', + 'id_empty' => ' id不能为空', + 'customer_id' => ' 客户ID', + 'tag_group_id' => ' 标签组ID', + 'claim_fail' => ' 不能领取有归属客户', ]; \ No newline at end of file