Coupon.php
2.4 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
83
84
85
86
87
88
89
90
91
92
93
94
<?php
namespace app\index\model\wanlshop;
use think\Model;
use traits\model\SoftDelete;
class Coupon extends Model
{
use SoftDelete;
// 表名
protected $name = 'wanlshop_coupon';
// 自动写入时间戳字段
protected $autoWriteTimestamp = 'int';
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
protected $deleteTime = 'deletetime';
// 追加属性
protected $append = [
'type_text',
'usertype_text',
'rangetype_text',
'pretype_text'
];
public function getTypeList()
{
return ['reduction' => __('Type reduction'), 'discount' => __('Type discount'), 'shipping' => __('Type shipping')];
}
public function getUsertypeList()
{
return ['reduction' => __('Usertype reduction'), 'discount' => __('Usertype discount')];
}
public function getRangetypeList()
{
return ['all' => __('Rangetype all'), 'goods' => __('Rangetype goods'), 'category' => __('Rangetype category')];
}
public function getPretypeList()
{
return ['appoint' => __('Pretype appoint'), 'fixed' => __('Pretype fixed')];
}
public function getTypeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
$list = $this->getTypeList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getUsertypeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['usertype']) ? $data['usertype'] : '');
$list = $this->getUsertypeList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getRangetypeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['rangetype']) ? $data['rangetype'] : '');
$list = $this->getRangetypeList();
return isset($list[$value]) ? $list[$value] : '';
}
public function getPretypeTextAttr($value, $data)
{
$value = $value ? $value : (isset($data['pretype']) ? $data['pretype'] : '');
$list = $this->getPretypeList();
return isset($list[$value]) ? $list[$value] : '';
}
public function shop()
{
return $this->belongsTo('app\index\model\wanlshop\Shop', 'shop_id', 'id', [], 'LEFT')->setEagerlyType(0);
}
}