Detail.php
4.09 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
<?php
namespace Product;
use LibModels\Wap\Product\DetailData;
/**
* 商品详情页模板相关的数据模型
*
* @name DetailModel
* @package Product
* @copyright yoho.inc
* @version 1.0 (2015-11-19 10:49:36)
* @author fei.hong <fei.hong@yoho.cn>
*/
class DetailModel
{
/**
* 商品基本信息
*
* @param int $productId 商品ID
* @param int $uid 当前登录用户ID, 未登录为0
* @return array
*/
public static function getBaseInfo($productId, $uid)
{
$result = array();
if (is_numeric($productId)) {
// 调用接口
$baseInfo = DetailData::baseInfo($productId, $uid);
// 商品名称
if (isset($baseInfo['productName'])) {
$result['goodsName'] = $baseInfo['productName'];
}
// 商品价格
if (isset($baseInfo['productPriceBo'])) {
$result['goodsPrice'] = array();
$result['goodsPrice']['currentPrice'] = $baseInfo['productPriceBo']['formatSalesPrice'];
if ($baseInfo['productPriceBo']['formatMarketPrice'] !== $baseInfo['productPriceBo']['formatSalesPrice']) {
$result['goodsPrice']['previousPrice'] = $baseInfo['productPriceBo']['formatMarketPrice'];
}
}
// VIP商品价格
if (isset($baseInfo['productPriceBo']['vipPrices'])) {
$build = array();
foreach ($baseInfo['productPriceBo']['vipPrices'] as $value) {
$build['level'] = $value['vipLevel'];
$build['text'] = $value['vipPrice'];
$result['vipLevel']['list'][] = $build;
}
}
// 上市期
if (isset($baseInfo['expectArrivalTime'])) {
$result['periodOfMarket'] = date('n', $baseInfo['firstShelveTime']) . '月';
}
// 商品咨询和商品评价
$result['feedbacks'] = array();
if (isset($baseInfo['consultBoWrapper'])) {
$result['feedbacks']['consultTotal'] = $baseInfo['consultBoWrapper']['consultTotal'];
$result['feedbacks']['consults'] = array();
}
if (isset($baseInfo['commentBoWrapper'])) {
$result['feedbacks']['commentTotal'] = $baseInfo['commentBoWrapper']['commentTotal'];
$result['feedbacks']['comments'] = array();
$build = array();
foreach ($baseInfo['commentBoWrapper']['commentBoList'] as $value) {
$build['userName'] = $value['nickName'];
$build['desc'] = $value['colorName'] . $value['sizeName'];
$build['content'] = $value['content'];
$build['time'] = $value['createTime'];
$result['feedbacks']['comments'][] = $build;
}
}
if (!empty($baseInfo['goodsList'])) {
foreach ($baseInfo['goodsList'] as $value) {
foreach ($value['goodsImagesList'] as $image) {
}
foreach ($value['goodsSizeBoList'] as $size) {
}
}
// 多个
if (isset($baseInfo['goodsList'][1])) {
$result['bannerTop']['list'] = array();
foreach ($baseInfo['goodsList'][1] as $value) {
}
}
// 单个
else {
$result['bannerTop'] = array();
$result['bannerTop']['img'] = '';
}
}
}
return $result;
var_dump($baseInfo);
}
/**
* 商品尺码信息
*
* @param int $productSkn
* @return array
*/
public static function getSizeInfo($productSkn)
{
$sizeInfo = DetailData::sizeInfo($productSkn);
var_dump($sizeInfo);
}
}