Dao.php
4.3 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?php
/**
* User: elkan
* Date: 14-7-29
* Time: 下午3:49
* To change this template use File | Settings | File Templates.
*/
use YHMDelivery\SqlMap\Delivery;
class YHMDelivery_Models_Delivery_Dao extends YHMDelivery_Dao
{
private $_tag = 'passport_delivery_';
public function __construct()
{
$this->router = 'delivery.yhm_passport';
}
/**
* 查看用户收获地址
* @param int $uid
* @return array
*/
function getUserDelivery($uid)
{
return $this->dao()->tag($this->_tag . $uid)->key('getUserDelivery')->fetchAssoc(Delivery\Delivery::SELECT_USER_DELIVERY_ADDRESS, array("uid" => $uid));
}
/**
* 添加收获地址
* @param int $uid
* @param string $delivery_name
* @param int $area_code
* @param string $address
* @param int $zip_code
* @param int $telphone
* @param int $is_default
* @return int
*/
function add($uid, $delivery_name, $area_code, $address, $zip_code, $telphone, $is_default)
{
return $this->dao()->tag($this->_tag . $uid)->insert(Delivery\Delivery::INSERT_DELIVERY, array(
"uid" => $uid,
"delivery_name" => $delivery_name,
"area_code" => $area_code,
"address" => $address,
"zip_code" => $zip_code,
"telphone" => $telphone,
"is_default" => $is_default
))->lastInsertId();
}
/**
* 检测是否有默认地址
* @param int $uid
* @return int
*/
function isDefault($uid)
{
return $this->dao()->tag($this->_tag . $uid)->fetchRow(Delivery\Delivery::SELECT_USER_DEFAULT_ADDRESS, array("uid" => $uid));
}
/**
* 先修改原本的默认地址
* @param int $id
* @param int $uid
* @return
*/
function updateEmptyDefaultAddress($uid)
{
return $this->dao()->tag($this->_tag . $uid)->update(Delivery\Delivery::UPDATE_USER_OLD_DEFAULT_ADDRESS, array("uid" => $uid));
}
/**
* 修改用户默认地址
* @param int $id
* @param int $uid
* @return
*/
function updateUserDefaultAddress($id, $uid)
{
return $this->dao()->tag($this->_tag . $uid)->update(Delivery\Delivery::UPDATE_USER_DEFAULT_ADDRESS, array("id" => $id, "uid" => $uid));
}
/**
* 删除用户收获地址
* @param int $id
* @param int $uid
* @return type
*/
function deleteDefaultAddress($id, $uid)
{
return $this->dao()->tag($this->_tag . $uid)->delete(Delivery\Delivery::DELETE_USER_DEFAULT_ADDRESS, array(
"id" => $id,
"uid" => $uid
))->rowCount();
}
/**
* 修改用户地址信息
* @param int $id
* @param int $uid
* @param string $delivery_name
* @param int $area_code
* @param string $address
* @param int $zip_code
* @param int $telphone
* @param int $is_default
* @param int $uid
* @return
*/
function updateDeliveryAddress($id, $uid, $delivery_name, $area_code, $address, $zip_code, $telphone, $is_default)
{
return $this->dao()->tag($this->_tag . $uid)->update(Delivery\Delivery::UPDATE_DELIVERY_ADDRESS_BY_ID, array(
"id" => $id,
"delivery_name" => $delivery_name,
"area_code" => $area_code,
"address" => $address,
"zip_code" => $zip_code,
"telphone" => $telphone,
"is_default" => $is_default)
);
}
/**
* 获取用户默认地址
* @param int $uid
* @return type
*/
function getDefaultDeliveryByUid($uid)
{
return $this->dao()->tag($this->_tag . $uid)->key('getDefaultDeliveryByUid')->fetchRow(Delivery\Delivery::SELECT_DEFAULT_DELIVERY_BY_UID, array('uid' => $uid));
}
/**
* 取最近的一条收货地址
* @param type $uid
* @return type
*/
function getDeliveryByUid($uid)
{
return $this->dao()->tag($this->_tag . $uid)->key('getDeliveryByUid')->fetchRow(Delivery\Delivery::SELECT_DELIVERY_BY_UID, array('uid' => $uid));
}
/**
* 通过id获取地区
* @param type $id
*/
function getDeliveryById($id)
{
return $this->dao()->cache(false)->fetchRow(Delivery\Delivery::SELECT_DELIVERY_BY_ID, array('id' => $id));
}
}