Prod.class.php
5.28 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
/**
* prod信息
*
* @name Service_Prod
* @version 1.0 (2013-6-5)
* @package Service/Prod
* @author hbomb
* @since 1.0
*/
class Service_Prod extends Lib_Service
{
const ROUTER = 'prod.yohood.prod';
private static $_tag = 'tag_yohood_prod_';
private static $_key = 'key_yohood_prod_';
/**
* 获取prod
*
* @param array|int $recom_status
* @param int $offset
* @param int $limit
* @return array
*/
public function getProd ($recom_status, $offset, $limit)
{
if(is_array($recom_status))
{
$recom_status = implode(',', $recom_status);
}
$replaces = array('recom_status' => $recom_status);
return self::service(self::ROUTER)->tag(self::$_tag)->fetchAssoc('getProd', array('offset' => $offset, 'limit' => $limit), $replaces);
}
/**
* 根据brand_id获取prod
*
* @param unknown_type $offset
* @param unknown_type $limit
* @param unknown_type $brand_id
* @param int|array $recom_status
* @return array
*/
public function getProdByBrandId ($offset, $limit, $brand_id, $recom_status)
{
if(is_array($recom_status))
{
$recom_status = implode(',', $recom_status);
}
$replaces = array('recom_status' => $recom_status);
return self::service(self::ROUTER)->tag(self::$_tag)->fetchAssoc('getProdByBrandId', array('offset' => $offset, 'limit' => $limit, 'brand_id'=> $brand_id), $replaces);
}
/**
* 根据brand_id获取prod总数
*
* @param string $brand_id
* @param int|array $recom_status
* @return array
*/
public function getProdTotalByBrandId($brand_id, $recom_status)
{
if(is_array($recom_status))
{
$recom_status = implode(',', $recom_status);
}
$replaces = array('recom_status' => $recom_status);
return self::service(self::ROUTER)->tag(self::$_tag)->fetchOne('getProdTotalByBrandId', array('brand_id'=> $brand_id), $replaces);
}
/**
* 获取所有prod个数. 用于前端分页
*
* @param array|int $recom_status
* @return int
*/
public function getProdTotal($recom_status)
{
if(is_array($recom_status))
{
$recom_status = implode(',', $recom_status);
}
$replaces = array('recom_status' => $recom_status);
return self::service(self::ROUTER)->tag(self::$_tag)->fetchOne('getProdTotal', array(), $replaces);
}
/**
* 根据id更新prod操作.
* @param string $name
* @param string $brand_id
* @param string $url
* @param string $pic
* @param string $text
* @param int $sort
* @param string $create_time
* @param int $price
* @param int $recom_status
* @param string $market_price
* @param string $product_skn
* @param string $product_id
* @param int $id
* @return boolean
*/
public function updateProd ($name, $brand_id, $url, $pic, $text, $sort, $create_time, $price, $recom_status, $market_price, $product_skn, $product_id, $id)
{
$param = array(
'id'=>$id,
'pic'=> $pic,
'text'=> $text,
'create_time'=> $create_time,
'name'=>$name,
'sort' => $sort,
'brand_id'=>$brand_id,
'url'=>$url,
'price' => $price,
'recom_status'=> $recom_status,
'market_price'=> $market_price,
'product_skn'=> $product_skn,
'product_id'=> $product_id
);
$status = self::service(self::ROUTER)->cache(false)->update('updateProd', $param)->status();
if($status)
{
self::service(self::ROUTER)->delTags(self::$_tag);
}
return $status;
}
/**
* 用户提交prod.
*
* @param string $name
* @param string $brand_id
* @param string $url
* @param string $pic
* @param string $text
* @param int $sort
* @param int $price
* @param int $recom_status
* @param string $market_price
* @param string $product_skn
* @param string $product_id
* @return int
*/
public function submitProd ($name, $brand_id, $url, $pic, $text, $sort, $price, $recom_status, $market_price, $product_skn, $product_id)
{
$param = array(
'pic'=> $pic,
'text'=> $text,
'name'=> $name,
'brand_id'=> $brand_id,
'url'=> $url,
'sort' => $sort,
'price' => $price,
'recom_status'=> $recom_status,
'market_price'=> $market_price,
'product_skn'=> $product_skn,
'product_id'=> $product_id
);
$status = self::service(self::ROUTER)->cache(false)->insert('insertProd', $param)->lastInsertId();
if($status)
{
self::service(self::ROUTER)->delTags(self::$_tag);
}
return $status;
}
/**
* 删除prod
* @param unknown_type $id
*/
public function delProd($id)
{
$status = self::service(self::ROUTER)->cache(false)->delete('delProd',array('id'=>$id))->status();
if($status)
{
self::service(self::ROUTER)->delTags(self::$_tag);
}
return $status;
}
}