User.php
1.6 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
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2020/4/28
* Time: 17:20
*/
namespace app\index\model;
use think\Db;
use think\Model;
class User extends Model
{
public function findData($where){
$data = $this->where($where)->find();
if(!empty($data)){
//判断是否为会员
$is_vip = '2';
if(!empty($data['vip_passtime'])){
if($data['vip_passtime'] > time()){
$is_vip = "1";
}
}
$is_svip = '2';
if(!empty($data['svip_passtime'])){
if($data['svip_passtime'] > time()){
$is_svip = "1";
}
}
$data['is_vip'] = $is_vip;
$data['is_svip'] = $is_svip;
//获取购买的vip省份
$province_ids = [];
$user_province = Db::name('user_province')->where(['user_id'=>$data['id'],'expiration_time'=>['gt',time()]])->select();
foreach($user_province as $key => $u_p){
$province_ids[] = $u_p['province_id'];
}
$data['province_ids'] = $province_ids;
}
return $data;
}
public function updateData($where,$data){
$result = $this->where($where)->update($data);
return $result;
}
public function insertData($data){
$result = $this->insertGetId($data);
return $result;
}
public function selectData($where){
$where['status'] = ['eq',"normal"];
$data = $this->where($where)->select();
return $data;
}
}