Product.php
8.79 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
<?php
/**
* 商品详情页面展示
* Class QLibView_Product
*/
class QLibView_Product
{
protected $view;
public function __construct($product_id, $goods_id)
{
$this->view = new stdClass();
$this->view->goods_id = $goods_id;
$this->view->product = $product = QINProduct_Models_Product_Client::getOneProduct($product_id, 'all');
$goodsImage = QINProduct_Models_Goods_Images_Client::getImages($product_id, $goods_id);
$images = array();
if (!empty($goodsImage)) {
foreach ($goodsImage as $v) {
$images[] = array(
'big' => QINLib_Images::QFSImage($v['image_url'], 'goodsimg', '420x560', 2),
'small' => QINLib_Images::QFSImage($v['image_url'], 'goodsimg', '75x100', 2)
);
}
}
$this->view->shareImgURL= QINLib_Images::QFSImage($goodsImage[0]['image_url'], 'goodsimg', '420x560', 2);
$this->view->goodsImage = $images;
$this->view->brand = $brand = QINProduct_Models_Brand_Client::getOneBrand($product['brand_id']);
$this->view->brandDomain = '';
if(!empty($brand['brand_domain'])){
$this->view->brandDomain = 'http://'.$brand['brand_domain'] . QLibConfigs_Static::$brandSiteUrl;
}
$this->view->brandBanner = $brandBanner = QINProduct_Models_Brand_Banner_Client::getBannerById($product['brand_id']);
$this->view->gender = $product['gender'] == 3 || empty($product['gender']) ? '1,3' : $product['gender'] . ',3';
$this->view->maxsort = QINProduct_Models_Sort_Client::getSortById($product['max_sort_id']);
$this->view->middlesort = QINProduct_Models_Sort_Client::getSortById($product['middle_sort_id']);
//舒适度等其它商品属性
$this->view->specialAttr = QINProduct_Models_Special_Client::getSpecial($this->view->product['id']);
}
/**
* 商品详情页面品牌banner
* @param $brand_id
* @return $this
*/
public function brandBanner()
{
$this->display('brand');
return $this;
}
/**
* 商品页面mini导航条
* @return $this
*/
public function mininav()
{
$this->display('mininav');
return $this;
}
/**
* 商品页面上部商品详情
* @return $this
*/
public function details()
{
$this->display('details');
return $this;
}
/**
* 商品编码,颜色,性别,舒适度等简介
* @return $this
*/
public function goodsBaseDesc()
{
$this->display('base');
return $this;
}
/**
* 产品材质
* @return $this
*/
public function metarial()
{
$this->display('metarial');
return $this;
}
/**
* 尺码信息
* @param $product_skn
* @return $this|array
*/
public function size()
{
$relation = QINProduct_Models_Size_Relationskn_Client::getRelation($this->view->product['erp_product_id']);
$allSize = QINProduct_Models_Size_Client::getAllSizes();
$this->view->allAttribute = QINProduct_Models_Size_Attribute_Client::getSizeAttribute();
//分类尺码信息
$size = QINProduct_Models_Size_Sortsize_Client::getSortSize($this->view->product['small_sort_id']);
//分类属性
$attribute = QINProduct_Models_Size_Attribute_Client::getAttributeRelationBySort($this->view->product['small_sort_id']);
$data = array();
foreach ($size as $sizeKey=>$sizeVal) {
foreach ($attribute as $attributeKey=>$attributeVal) {
foreach ($relation as $relationKey=>$relationVal) {
if ($relationVal['size_id'] != $sizeVal['size_id'] || $relationVal['size_attribute_id'] != $attributeVal['attribute_id']) {
continue;
}
$data[$sizeVal['size_id']]['size_name'] = $allSize[$sizeVal['size_id']]['size_name'];
$data[$sizeVal['size_id']][$attributeVal['attribute_id']] = empty($relationVal['size_value']) ? '' : $relationVal['size_value'];
}
}
}
$this->view->sizeInfo = $data;
$this->display('size');
return $this;
}
/**
* 测量示意图
* @return $this
*/
public function cateImage()
{
$this->display('cateimage');
return $this;
}
/**
* 试穿报告
* @return $this
*/
public function tryon()
{
$this->display('tryon');
return $this;
}
/**
* 模特卡
* @return $this
*/
public function modelcard()
{
$this->display('modelcard');
return $this;
}
/**
* 商品详情介绍
* @return $this
*/
public function description()
{
//搭配
$list = QINProduct_Models_Collocation_Client::getCollocation($this->view->product['id']);
foreach ($list as $key => $v) {
if (empty($v['info'])) {
continue;
}
$list[$key]['info'] = $info = json_decode($v['info'], true);
foreach ($info as $k => $val) {
$list[$key]['info'][$k]['product'] = $this->getProductInfo($val['id']);
}
}
$this->view->collocation = $list;
$this->display('description');
return $this;
}
/**
* 穿搭配数据组合
* @param int $product_id
* @return array
*/
private function getProductInfo($product_skn)
{
$data = QINProduct_Models_Product_Client::getFullProductBySkn($product_skn);
if(empty($data)) {
return array();
}
$product ['id'] = $data ['id'];
$product_id = $data['id'];
$product ['product_name'] = $data ['product_name'];
$product ['cn_alphabet'] = $data ['cn_alphabet'];
$product ['erp_product_id'] = $data ['erp_product_id'];
$product ['brand_id'] = $data ['brand_id'];
$product ['sales_phrase'] = isset($data ['sales_phrase']) ? $data ['sales_phrase'] :'';
$product ['shelve_time'] = isset($data ['shelve_time']) ? $data ['shelve_time'] : 0;
$product ['is_outlets'] = isset($data['is_outlets']) ? 'N' : $data['is_outlets'];
$product ['phrase'] = empty($data['phrase']) ? '' : $data['phrase'];
$product ['style'] = empty($data['style']) ? '' : $data['style'];
$product['status'] = 0;
if(isset($data['status']))
{
$product['status'] = $data['status'];
}
$goods_list = QINProduct_Models_Goods_Client::getGoodsByProduct($product_id);
foreach ($goods_list as $k => $v) {
if(empty($v['color_image']))
{
unset($goods_list[$k]);
continue;
}
$goods_list[$k]['url'] = 'http://item.yohobuy.com/product/pro_' . $product_id . '_' . $v['id'] . '/' . $product['cn_alphabet'] . '.html';
}
if(empty($goods_list))
{
return array();
}
$product['goods'] = $goods_list;
$goods = array_shift ( $goods_list );
$product['url'] = $goods ['url'];
$product['default_pic'] = $goods ['color_image'];
$price = QINProduct_Models_Price_Client::getPriceByProduct($product_id);
$product['price'] = array(
'market_price' => $price['market_price'],
'sales_price' => $price['sales_price'],
'special_price' => $price['special_price'],
'yoho_coin_num' => $price['yoho_coin_num'],
'vip_discount_type' => $price['vip_discount_type'],
'vip_discount' => $price['vip_discount'],
'list_sales_price' => number_format($price['sales_price'], 2),
'list_market_price' => number_format($price['market_price'],2),
'vip_price' => $price['vip_price']
);
return $product;
}
/**
* 售后服务
* @return $this
*/
public function aftersale()
{
$this->display('aftersale');
return $this;
}
/**
* 咨询评论
* @return $this
*/
public function comment()
{
$this->display('comment');
return $this;
}
/**
* 选择模板
* @param $template
* @return bool|mixed
*/
protected function display($template)
{
if (empty($template)) {
return false;
}
return include __DIR__ . '/Template/Product/' . $template . '.phtml';
}
/**
* 模板变量获取
* @param $name
* @return mixed
*/
public function __get($name)
{
return $this->view->$name;
}
/**
* 模板变量获取
* @param $name
* @return mixed
*/
public function __isset($name)
{
return empty($this->view->$name);
}
}