MemberSalesModel.php
1.7 KB
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
<?php
/**
* Created by PhpStorm.
* User: 29925
* Date: 2018/8/9
* Time: 14:34
*/
namespace app\member\model;
use think\Db;
use think\Model;
class MemberSalesModel extends Model
{
protected $autoWriteTimestamp = true;
/**
* 添加销售人员
*/
public function addMemberSales($data) {
$this->allowField(true)->data($data,true)->isUpdate(false)->save();
return $this;
}
/**
* 编辑销售人员
*/
public function editMemberSales($data) {
$this->allowField(true)->data($data,true)->isUpdate(true)->save();
return $this;
}
public function doName($user)
{
$userQuery = $this;
$result = $userQuery->where('user_login', $user['user_login'])->find();
if (!empty($result)) {
$comparePasswordResult = cmf_compare_password($user['user_pass'], $result['user_pass']);
$hookParam =[
'user'=>$user,
'compare_password_result'=>$comparePasswordResult
];
hook_one("user_login_start",$hookParam);
if ($comparePasswordResult) {
//拉黑判断。
// if($result['user_status']==0){
// return 3;
// }
session('user_sale', $result);
$data = [
'last_login_time' => time(),
'last_login_ip' => get_client_ip(0, true),
];
$userQuery->where('id', $result["id"])->update($data);
return 0;
}
return 1;
}
$hookParam =[
'user'=>$user,
'compare_password_result'=>false
];
hook_one("user_login_start",$hookParam);
return 2;
}
}