quanwei
2025-11-28 3ea53e61cc23fdb3ddf8b38a199ca60a6da8c407
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
 
namespace app\branch\model\branch;
 
use app\common\model\branch\LoginLog as LoginLogModel;
use app\common\model\branch\User as UserModel;
use app\branch\model\branch\Branch as BranchModel;
/**
 * 后台管理员登录模型
 */
class User extends UserModel
{
    /**
     *检查登录
     */
    public function checkLogin($user)
    {
        $where['user_name'] = $user['username'];
        $where['password'] = $user['password'];
        $where['is_delete'] = 0;
 
        if (!$user = $this->where($where)->with(['app'])->find()) {
            return false;
        }
        if (empty($user['app'])) {
            $this->error = '登录失败, 未找到应用信息';
            return false;
        }
        if ($user['app']['is_delete']) {
            $this->error = '登录失败, 当前用户已删除';
            return false;
        }
        $branch = BranchModel::detail($user['branch_id']);
        if ($branch['is_delete']) {
            $this->error = '登录失败, 当前商户已删除';
            return false;
        }
        $branch = BranchModel::detail($user['branch_id']);
        if ($branch['is_recycle']) {
            $this->error = '登录失败, 当前商户已禁止';
            return false;
        }
        // 增加分会信息 by lyzflash
        $user['branch_name'] = $branch['name'];
        $user['branch_type'] = $branch['branch_type']['value'];
        // 保存登录状态
        $this->loginState($user);
        // 写入登录日志
        LoginLogModel::add($user, \request()->ip(), '登录成功');
        return true;
    }
 
 
    /*
    * 修改密码
    */
    public function editPass($data, $user)
    {
        $user_info = User::detail($user['branch_user_id']);
        if ($data['password'] != $data['confirmPass']) {
            $this->error = '新密码输入不一致';
            return false;
        }
        if ($user_info['password'] != salt_hash($data['oldpass'])) {
            $this->error = '原始密码错误';
            return false;
        }
        $date['password'] = salt_hash($data['password']);
        $user_info->save($date);
        return true;
    }
 
}