Store.php
2.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* Created by PhpStorm.
* User: Administrator
* Date: 2020/5/8
* Time: 13:24
*/
namespace app\index\model;
use think\Model;
class Store extends Model
{
public function getProvinceIdsAttr($value){
$province_ids = [];
if(!empty($value)){
$province_ids = explode(',',trim($value,','));
}
return $province_ids;
}
public function getThumbnailAttr($value){
return cdnurl($value);
}
public function selectData($where){
$data = $this->where($where)->select();
$areaModel = new Area();
foreach($data as $key => $vo){
//判断会员是否过期
$is_vip = '2';
if(!empty($vo['vip_passtime'])){
if($vo['vip_passtime'] > time()){
$is_vip = "1";
}
}
$is_svip = '2';
if(!empty($vo['svip_passtime'])){
if($vo['svip_passtime'] > time()){
$is_svip = "1";
}
}
$data[$key]['is_vip'] = $is_vip;
$data[$key]['is_svip'] = $is_svip;
//获取省市区
$province_name = $areaModel->where(['id'=>$vo['province_id']])->value('name');
$city_name = $areaModel->where(['id'=>$vo['city_id']])->value('name');
$county_name = $areaModel->where(['id'=>$vo['county_id']])->value('name');
$data[$key]['province_name'] = $province_name;
$data[$key]['city_name'] = $city_name;
$data[$key]['county_name'] = $county_name;
}
return $data;
}
public function findData($where){
$data = $this->where($where)->find();
//判断会员是否过期
$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;
//获取省市区
$areaModel = new Area();
$province_name = $areaModel->where(['id'=>$data['province_id']])->value('name');
$city_name = $areaModel->where(['id'=>$data['city_id']])->value('name');
$county_name = $areaModel->where(['id'=>$data['county_id']])->value('name');
$data['province_name'] = $province_name;
$data['city_name'] = $city_name;
$data['county_name'] = $county_name;
return $data;
}
}