diff --git a/app/common/controller/UserController.php b/app/common/controller/UserController.php index c32f153..2a22145 100644 --- a/app/common/controller/UserController.php +++ b/app/common/controller/UserController.php @@ -56,4 +56,23 @@ class UserController extends BaseController } } + /** + * 修改密码 + * @param Request $request + * @return \support\Response + * @throws \Random\RandomException + */ + public function savePassword(Request $request) + { + try { + $uid = $request->user->uid; + $data = $request->all(); + $result = (new UserService())->savePassword($uid,$data);; + return $this->success($result, '编辑成功'); + } catch (\Throwable $e) { + return $this->error($e->getMessage()); + } + } + + } \ No newline at end of file diff --git a/app/common/logic/UserLogic.php b/app/common/logic/UserLogic.php index 28ebf6e..4b58247 100644 --- a/app/common/logic/UserLogic.php +++ b/app/common/logic/UserLogic.php @@ -42,4 +42,15 @@ class UserLogic return $user; } + /** + * 修改密码 + */ + public function savePassword(int $uid, array $data) + { + $password = password_hash($data['password_new'], PASSWORD_DEFAULT); + $res = User::where('id',$uid)->update(['password' => $password]); + + return $res; + } + } \ No newline at end of file diff --git a/app/common/service/UserService.php b/app/common/service/UserService.php index c55c4cc..85684d3 100644 --- a/app/common/service/UserService.php +++ b/app/common/service/UserService.php @@ -4,7 +4,9 @@ namespace app\common\service; use app\common\logic\UserLogic; use app\common\model\Corp; +use app\common\model\User; use app\crm\model\Country; +use support\exception\BusinessException; class UserService { @@ -69,7 +71,7 @@ class UserService } /** - * 获取用户信息(包括菜单和权限) + * 编辑用户信息 */ public function edit(int $uid, array $data) { @@ -81,4 +83,20 @@ class UserService $user = $this->logic->edit($uid,$data); return $user; } + + /** + * 修改用户密码 + */ + public function savePassword(int $uid, array $data) + { + // 对密码进行哈希处理 + $password = $data['password']; + $user = User::find($uid); + if (!password_verify($password, $user->password)) { + throw new BusinessException('密码错误'); + } + + $user = $this->logic->savePassword($uid,$data); + return $user; + } } \ No newline at end of file diff --git a/app/crm/service/CustomerService.php b/app/crm/service/CustomerService.php index 648c0d8..51737b1 100644 --- a/app/crm/service/CustomerService.php +++ b/app/crm/service/CustomerService.php @@ -21,7 +21,8 @@ class CustomerService $page = $params['current'] ?? 1; $keyword = $params['keyword'] ?? ''; $recycle = $params['recycle'] ?? ''; - $grade = $params['grade'] ?? ''; + $follow = $params['follow'] ?? ''; + $follow_last = $params['follow_last'] ?? ''; $where = []; $user_id =$params['user_id']; if(empty($user_id) || $user_id == 0){ @@ -36,6 +37,24 @@ class CustomerService $where[] = ['user_id', $user_id]; } + + $grade = []; + if (!Util::isEmpty($follow) && $follow == 0) { + $where[] = ['grade', '<=', 2]; + } elseif (!Util::isEmpty($follow) && $follow == 1) { + $grade = [3, 4]; + } elseif (!Util::isEmpty($follow) && $follow == 2) { + $where[] = ['grade', '=', 5]; + } + + if (!Util::isEmpty($follow_last) && $follow_last == 0) { + $where[] = ['follow_last', '>', strtotime('-1 day')]; + } elseif (!Util::isEmpty($follow_last) && $follow_last == 1) { + $where[] = ['follow_last', '>', strtotime('-3 day')]; + } elseif (!Util::isEmpty($follow_last) && $follow_last == 2) { + $where[] = ['follow_last', '>', strtotime('-7 day')]; + } + $query = Customer::where($where); if(!empty($tagId)){ diff --git a/config/route.php b/config/route.php index 737ce1b..d0c9db4 100644 --- a/config/route.php +++ b/config/route.php @@ -114,5 +114,6 @@ Route::group('/crm', function () { Route::any('/user/edit', [app\common\controller\UserController::class, 'edit']); + Route::any('/user/savePassword', [app\common\controller\UserController::class, 'savePassword']); });