|
@@ -20,265 +20,270 @@ class DetailModel |
|
@@ -20,265 +20,270 @@ class DetailModel |
20
|
/**
|
20
|
/**
|
21
|
* 商品基本信息
|
21
|
* 商品基本信息
|
22
|
*
|
22
|
*
|
23
|
- * @param int $productId 商品ID
|
23
|
+ * @param int $productId 商品ID SKN 和 ID 只需要传一个
|
24
|
* @param int $goodsId 某个颜色的商品
|
24
|
* @param int $goodsId 某个颜色的商品
|
25
|
* @param int $uid 当前登录用户ID, 未登录为0
|
25
|
* @param int $uid 当前登录用户ID, 未登录为0
|
|
|
26
|
+ * @param int $productSkn SKN 和 ID 只需要传一个
|
26
|
* @return array
|
27
|
* @return array
|
27
|
*/
|
28
|
*/
|
28
|
- public static function getBaseInfo($productId, $goodsId, $uid, $vipLevel)
|
29
|
+ public static function getBaseInfo($productId, $goodsId, $uid, $vipLevel, $productSkn = null)
|
29
|
{
|
30
|
{
|
30
|
$result = array();
|
31
|
$result = array();
|
31
|
|
32
|
|
|
|
33
|
+ $baseInfo = array();
|
|
|
34
|
+ // 通过ID获取
|
32
|
if (is_numeric($productId) && is_numeric($goodsId)) {
|
35
|
if (is_numeric($productId) && is_numeric($goodsId)) {
|
33
|
- // 调用服务
|
|
|
34
|
$baseInfo = DetailData::baseInfo($productId, $uid);
|
36
|
$baseInfo = DetailData::baseInfo($productId, $uid);
|
|
|
37
|
+ }
|
|
|
38
|
+ // 通过SKN获取
|
|
|
39
|
+ elseif (is_numeric($productSkn)) {
|
|
|
40
|
+ $baseInfo = DetailData::baseInfo(null, $uid, $productSkn);
|
|
|
41
|
+ }
|
|
|
42
|
+
|
|
|
43
|
+ // 商品名称
|
|
|
44
|
+ if (empty($baseInfo['productName'])) {
|
|
|
45
|
+ return $result;
|
|
|
46
|
+ }
|
|
|
47
|
+ $result['goodsName'] = $baseInfo['productName'];
|
35
|
|
48
|
|
36
|
- // 商品名称
|
|
|
37
|
- if (empty($baseInfo['productName'])) {
|
|
|
38
|
- return $result;
|
|
|
39
|
- }
|
|
|
40
|
-
|
|
|
41
|
- $result['goodsName'] = $baseInfo['productName'];
|
|
|
42
|
-
|
|
|
43
|
- // 商品促销短语
|
|
|
44
|
- if (!empty($baseInfo['salesPhrase'])) {
|
|
|
45
|
- $result['goodsSubtitle'] = $baseInfo['salesPhrase'];
|
|
|
46
|
- }
|
49
|
+ // 商品促销短语
|
|
|
50
|
+ if (!empty($baseInfo['salesPhrase'])) {
|
|
|
51
|
+ $result['goodsSubtitle'] = $baseInfo['salesPhrase'];
|
|
|
52
|
+ }
|
47
|
|
53
|
|
48
|
- // 商品标签
|
|
|
49
|
- if (!empty($baseInfo['productTagBoList'])) {
|
|
|
50
|
- foreach ($baseInfo['productTagBoList'] as $value) {
|
|
|
51
|
- switch ($value['tagLabel']) {
|
|
|
52
|
- case 'is_soon_sold_out': // 即将售磬
|
|
|
53
|
- $result['tags']['is_soon_sold_out'] = true;
|
|
|
54
|
- break;
|
|
|
55
|
- case 'is_new': // 新品NEW
|
|
|
56
|
- $result['tags']['is_new'] = true;
|
|
|
57
|
- break;
|
|
|
58
|
- case 'is_discount': // SALE
|
|
|
59
|
- $result['tags']['is_discount'] = true;
|
|
|
60
|
- break;
|
|
|
61
|
- case 'is_limited': // 限量
|
|
|
62
|
- $result['tags']['is_limited'] = true;
|
|
|
63
|
- break;
|
|
|
64
|
- case 'is_yohood': // YOHOOD
|
|
|
65
|
- $result['tags']['is_yohood'] = true;
|
|
|
66
|
- break;
|
|
|
67
|
- case 'is_advance': // 再到着
|
|
|
68
|
- $result['tags']['is_advance'] = true;
|
|
|
69
|
- break;
|
|
|
70
|
- }
|
54
|
+ // 商品标签
|
|
|
55
|
+ if (!empty($baseInfo['productTagBoList'])) {
|
|
|
56
|
+ foreach ($baseInfo['productTagBoList'] as $value) {
|
|
|
57
|
+ switch ($value['tagLabel']) {
|
|
|
58
|
+ case 'is_soon_sold_out': // 即将售磬
|
|
|
59
|
+ $result['tags']['is_soon_sold_out'] = true;
|
|
|
60
|
+ break;
|
|
|
61
|
+ case 'is_new': // 新品NEW
|
|
|
62
|
+ $result['tags']['is_new'] = true;
|
|
|
63
|
+ break;
|
|
|
64
|
+ case 'is_discount': // SALE
|
|
|
65
|
+ $result['tags']['is_discount'] = true;
|
|
|
66
|
+ break;
|
|
|
67
|
+ case 'is_limited': // 限量
|
|
|
68
|
+ $result['tags']['is_limited'] = true;
|
|
|
69
|
+ break;
|
|
|
70
|
+ case 'is_yohood': // YOHOOD
|
|
|
71
|
+ $result['tags']['is_yohood'] = true;
|
|
|
72
|
+ break;
|
|
|
73
|
+ case 'is_advance': // 再到着
|
|
|
74
|
+ $result['tags']['is_advance'] = true;
|
|
|
75
|
+ break;
|
71
|
}
|
76
|
}
|
72
|
}
|
77
|
}
|
|
|
78
|
+ }
|
73
|
|
79
|
|
74
|
- // 商品价格
|
|
|
75
|
- if (isset($baseInfo['productPriceBo'])) {
|
|
|
76
|
- $result['goodsPrice'] = array();
|
|
|
77
|
- $result['goodsPrice']['currentPrice'] = $baseInfo['productPriceBo']['formatSalesPrice'];
|
|
|
78
|
- if ($baseInfo['productPriceBo']['formatMarketPrice'] !== $baseInfo['productPriceBo']['formatSalesPrice']) {
|
|
|
79
|
- $result['goodsPrice']['previousPrice'] = $baseInfo['productPriceBo']['formatMarketPrice'];
|
|
|
80
|
- }
|
80
|
+ // 商品价格
|
|
|
81
|
+ if (isset($baseInfo['productPriceBo'])) {
|
|
|
82
|
+ $result['goodsPrice'] = array();
|
|
|
83
|
+ $result['goodsPrice']['currentPrice'] = $baseInfo['productPriceBo']['formatSalesPrice'];
|
|
|
84
|
+ if ($baseInfo['productPriceBo']['formatMarketPrice'] !== $baseInfo['productPriceBo']['formatSalesPrice']) {
|
|
|
85
|
+ $result['goodsPrice']['previousPrice'] = $baseInfo['productPriceBo']['formatMarketPrice'];
|
81
|
}
|
86
|
}
|
82
|
- // VIP商品价格
|
|
|
83
|
- if (isset($baseInfo['productPriceBo']['vipPrices'])) {
|
|
|
84
|
- $build = array();
|
|
|
85
|
- foreach ($baseInfo['productPriceBo']['vipPrices'] as $value) {
|
|
|
86
|
- $build['level'] = $value['vipLevel'];
|
|
|
87
|
- $build['text'] = $value['vipPrice'];
|
|
|
88
|
- $build['currentLevel'] = ($value['vipLevel'] == $vipLevel) ? true : false;
|
|
|
89
|
- $result['vipLevel']['list'][] = $build;
|
|
|
90
|
- }
|
87
|
+ }
|
|
|
88
|
+ // VIP商品价格
|
|
|
89
|
+ if (isset($baseInfo['productPriceBo']['vipPrices'])) {
|
|
|
90
|
+ $build = array();
|
|
|
91
|
+ foreach ($baseInfo['productPriceBo']['vipPrices'] as $value) {
|
|
|
92
|
+ $build['level'] = $value['vipLevel'];
|
|
|
93
|
+ $build['text'] = $value['vipPrice'];
|
|
|
94
|
+ $build['currentLevel'] = ($value['vipLevel'] == $vipLevel) ? true : false;
|
|
|
95
|
+ $result['vipLevel']['list'][] = $build;
|
91
|
}
|
96
|
}
|
|
|
97
|
+ }
|
92
|
|
98
|
|
93
|
- // 上市期
|
|
|
94
|
- if (isset($baseInfo['expectArrivalTime']) && !empty($baseInfo['expectArrivalTime'])) {
|
|
|
95
|
- $result['periodOfMarket'] = $baseInfo['expectArrivalTime'] . '月';
|
|
|
96
|
- }
|
99
|
+ // 上市期
|
|
|
100
|
+ if (isset($baseInfo['expectArrivalTime']) && !empty($baseInfo['expectArrivalTime'])) {
|
|
|
101
|
+ $result['periodOfMarket'] = $baseInfo['expectArrivalTime'] . '月';
|
|
|
102
|
+ }
|
97
|
|
103
|
|
98
|
- // 促销信息
|
|
|
99
|
- if (isset($baseInfo['promotionBoList'])) {
|
|
|
100
|
- $build = array();
|
|
|
101
|
- foreach ($baseInfo['promotionBoList'] as $value) {
|
|
|
102
|
- $build['text'] = '【' . $value['promotionType'] . '】' . $value['promotionTitle'];
|
|
|
103
|
- $result['goodsDiscount']['list'][] = $build;
|
|
|
104
|
- }
|
104
|
+ // 促销信息
|
|
|
105
|
+ if (isset($baseInfo['promotionBoList'])) {
|
|
|
106
|
+ $build = array();
|
|
|
107
|
+ foreach ($baseInfo['promotionBoList'] as $value) {
|
|
|
108
|
+ $build['text'] = '【' . $value['promotionType'] . '】' . $value['promotionTitle'];
|
|
|
109
|
+ $result['goodsDiscount']['list'][] = $build;
|
105
|
}
|
110
|
}
|
|
|
111
|
+ }
|
106
|
|
112
|
|
107
|
- $result['feedbacks'] = array();
|
|
|
108
|
-
|
|
|
109
|
- // 商品咨询
|
|
|
110
|
- $result['feedbacks']['consultsNum'] = 0;
|
|
|
111
|
- if (!empty($baseInfo['consultBoWrapper'])) {
|
|
|
112
|
- $result['feedbacks']['consultsNum'] = $baseInfo['consultBoWrapper']['consultTotal'];
|
|
|
113
|
- $result['feedbacks']['consults'] = array();
|
|
|
114
|
- $build = array();
|
|
|
115
|
- foreach ($baseInfo['consultBoWrapper']['consultBoList'] as $value) {
|
|
|
116
|
- $build['question'] = $value['ask'];
|
|
|
117
|
- $build['time'] = $value['askTime'];
|
|
|
118
|
- $build['answer'] = $value['answer'];
|
|
|
119
|
- $result['feedbacks']['consults'][] = $build;
|
|
|
120
|
- }
|
|
|
121
|
- $result['feedbacks']['consultsUrl'] = Helpers::url('/product/detail/consults', array('product_id' => $productId, 'total' => $result['feedbacks']['consultsNum']));
|
|
|
122
|
- }
|
|
|
123
|
- // 暂无咨询
|
|
|
124
|
- else {
|
|
|
125
|
- $result['feedbacks']['consultsUrl'] = Helpers::url('/product/detail/consultform', array('product_id' => $productId));
|
113
|
+ $result['feedbacks'] = array();
|
|
|
114
|
+
|
|
|
115
|
+ // 商品咨询
|
|
|
116
|
+ $result['feedbacks']['consultsNum'] = 0;
|
|
|
117
|
+ if (!empty($baseInfo['consultBoWrapper'])) {
|
|
|
118
|
+ $result['feedbacks']['consultsNum'] = $baseInfo['consultBoWrapper']['consultTotal'];
|
|
|
119
|
+ $result['feedbacks']['consults'] = array();
|
|
|
120
|
+ $build = array();
|
|
|
121
|
+ foreach ($baseInfo['consultBoWrapper']['consultBoList'] as $value) {
|
|
|
122
|
+ $build['question'] = $value['ask'];
|
|
|
123
|
+ $build['time'] = $value['askTime'];
|
|
|
124
|
+ $build['answer'] = $value['answer'];
|
|
|
125
|
+ $result['feedbacks']['consults'][] = $build;
|
126
|
}
|
126
|
}
|
|
|
127
|
+ $result['feedbacks']['consultsUrl'] = Helpers::url('/product/detail/consults', array('product_id' => $productId, 'total' => $result['feedbacks']['consultsNum']));
|
|
|
128
|
+ }
|
|
|
129
|
+ // 暂无咨询
|
|
|
130
|
+ else {
|
|
|
131
|
+ $result['feedbacks']['consultsUrl'] = Helpers::url('/product/detail/consultform', array('product_id' => $productId));
|
|
|
132
|
+ }
|
127
|
|
133
|
|
128
|
- // 商品评价
|
|
|
129
|
- $result['feedbacks']['commentsNum'] = 0;
|
|
|
130
|
- if (!empty($baseInfo['commentBoWrapper'])) {
|
|
|
131
|
- $result['feedbacks']['commentsNum'] = $baseInfo['commentBoWrapper']['commentTotal'];
|
|
|
132
|
- $result['feedbacks']['comments'] = array();
|
|
|
133
|
- $build = array();
|
|
|
134
|
- foreach ($baseInfo['commentBoWrapper']['commentBoList'] as $value) {
|
|
|
135
|
- $build['userName'] = $value['nickName'];
|
|
|
136
|
- $build['desc'] = $value['colorName'] . '/' . $value['sizeName'];
|
|
|
137
|
- $build['content'] = isset($value['content']) ? $value['content'] : '';
|
|
|
138
|
- $build['time'] = $value['createTime'];
|
|
|
139
|
- $result['feedbacks']['comments'][] = $build;
|
|
|
140
|
- }
|
|
|
141
|
- $result['feedbacks']['commentsUrl'] = Helpers::url('/product/detail/comments', array('product_id' => $productId, 'total' => $result['feedbacks']['commentsNum']));
|
134
|
+ // 商品评价
|
|
|
135
|
+ $result['feedbacks']['commentsNum'] = 0;
|
|
|
136
|
+ if (!empty($baseInfo['commentBoWrapper'])) {
|
|
|
137
|
+ $result['feedbacks']['commentsNum'] = $baseInfo['commentBoWrapper']['commentTotal'];
|
|
|
138
|
+ $result['feedbacks']['comments'] = array();
|
|
|
139
|
+ $build = array();
|
|
|
140
|
+ foreach ($baseInfo['commentBoWrapper']['commentBoList'] as $value) {
|
|
|
141
|
+ $build['userName'] = $value['nickName'];
|
|
|
142
|
+ $build['desc'] = $value['colorName'] . '/' . $value['sizeName'];
|
|
|
143
|
+ $build['content'] = isset($value['content']) ? $value['content'] : '';
|
|
|
144
|
+ $build['time'] = $value['createTime'];
|
|
|
145
|
+ $result['feedbacks']['comments'][] = $build;
|
142
|
}
|
146
|
}
|
|
|
147
|
+ $result['feedbacks']['commentsUrl'] = Helpers::url('/product/detail/comments', array('product_id' => $productId, 'total' => $result['feedbacks']['commentsNum']));
|
|
|
148
|
+ }
|
143
|
|
149
|
|
144
|
- // 品牌信息
|
|
|
145
|
- if (!empty($baseInfo['brand'])) {
|
|
|
146
|
- $result['enterStore'] = array(
|
|
|
147
|
- 'img' => Helpers::getImageUrl($baseInfo['brand']['brandIco'], 47, 47),
|
|
|
148
|
- 'storeName' => $baseInfo['brand']['brandName'],
|
|
|
149
|
- 'url' => Helpers::url('', array(), $baseInfo['brand']['brandDomain'])
|
|
|
150
|
- );
|
|
|
151
|
- // 为你优选的链接
|
|
|
152
|
- $result['preferenceUrl'] = Helpers::url('/product/detail/preference', array('productSkn' => $baseInfo['erpProductId'], 'brandId' => $baseInfo['brand']['id']), '');
|
|
|
153
|
- }
|
150
|
+ // 品牌信息
|
|
|
151
|
+ if (!empty($baseInfo['brand'])) {
|
|
|
152
|
+ $result['enterStore'] = array(
|
|
|
153
|
+ 'img' => Helpers::getImageUrl($baseInfo['brand']['brandIco'], 47, 47),
|
|
|
154
|
+ 'storeName' => $baseInfo['brand']['brandName'],
|
|
|
155
|
+ 'url' => Helpers::url('', array(), $baseInfo['brand']['brandDomain'])
|
|
|
156
|
+ );
|
|
|
157
|
+ // 为你优选的链接
|
|
|
158
|
+ $result['preferenceUrl'] = Helpers::url('/product/detail/preference', array('productSkn' => $baseInfo['erpProductId'], 'brandId' => $baseInfo['brand']['id']), '');
|
|
|
159
|
+ }
|
154
|
|
160
|
|
155
|
- // 商品信息
|
|
|
156
|
- if (!empty($baseInfo['goodsList'])) {
|
|
|
157
|
- $colorGroup = array();
|
|
|
158
|
- $sizeGroup = array();
|
|
|
159
|
- $goodsGroup = array();
|
|
|
160
|
- $sizeList = array();
|
|
|
161
|
- $thumbImageList = array();
|
|
|
162
|
- $colorStorageGroup = array(); // 颜色分组的库存总数集合, 多个之间用/分隔
|
|
|
163
|
- $sizeStorageStr = ''; // 尺码库存总数集合, 多个之间用/分隔
|
161
|
+ // 商品信息
|
|
|
162
|
+ if (!empty($baseInfo['goodsList'])) {
|
|
|
163
|
+ $colorGroup = array();
|
|
|
164
|
+ $sizeGroup = array();
|
|
|
165
|
+ $goodsGroup = array();
|
|
|
166
|
+ $sizeList = array();
|
|
|
167
|
+ $thumbImageList = array();
|
|
|
168
|
+ $colorStorageGroup = array(); // 颜色分组的库存总数集合, 多个之间用/分隔
|
|
|
169
|
+ $sizeStorageStr = ''; // 尺码库存总数集合, 多个之间用/分隔
|
|
|
170
|
+ $colorStorageNum = 0;
|
|
|
171
|
+ $totalStorageNum = 0; // 总库存数
|
|
|
172
|
+ foreach ($baseInfo['goodsList'] as $value) {
|
164
|
$colorStorageNum = 0;
|
173
|
$colorStorageNum = 0;
|
165
|
- $totalStorageNum = 0; // 总库存数
|
|
|
166
|
- foreach ($baseInfo['goodsList'] as $value) {
|
|
|
167
|
- $colorStorageNum = 0;
|
|
|
168
|
- $sizeStorageStr = '';
|
|
|
169
|
-
|
|
|
170
|
- // 商品分组
|
|
|
171
|
- if (isset($value['goodsImagesList'])) {
|
|
|
172
|
- foreach ($value['goodsImagesList'] as $goods) {
|
|
|
173
|
- $goodsGroup[] = array(
|
|
|
174
|
- 'goodsId' => $goods['goodsId'],
|
|
|
175
|
- 'img' => $goods['imageUrl'],
|
|
|
176
|
- );
|
|
|
177
|
- }
|
|
|
178
|
- }
|
|
|
179
|
-
|
|
|
180
|
- // 商品的尺码列表
|
|
|
181
|
- if (isset($value['goodsSizeBoList'])) {
|
|
|
182
|
- foreach ($value['goodsSizeBoList'] as $size) {
|
|
|
183
|
- $sizeList[$value['colorId']][] = array(
|
|
|
184
|
- 'id' => $size['id'],
|
|
|
185
|
- 'skuId' => $size['goodsSizeSkuId'],
|
|
|
186
|
- 'goodsId' => $size['goodsId'],
|
|
|
187
|
- 'colorId' => $value['colorId'],
|
|
|
188
|
- 'name' => $size['sizeName'],
|
|
|
189
|
- 'sizeNum' => $size['goodsSizeStorageNum'],
|
|
|
190
|
- );
|
|
|
191
|
- $colorStorageNum += intval($size['goodsSizeStorageNum']);
|
|
|
192
|
- $sizeStorageStr .= $size['goodsSizeStorageNum'] . '/';
|
|
|
193
|
- $colorStorageGroup[$size['sizeName']][$value['colorName']] = $size['goodsSizeStorageNum'];
|
|
|
194
|
- }
|
|
|
195
|
-
|
|
|
196
|
- // 颜色分组
|
|
|
197
|
- $colorGroup[] = array(
|
|
|
198
|
- 'id' => $value['colorId'],
|
|
|
199
|
- 'skcId' => $value['productSkc'],
|
|
|
200
|
- 'name' => $value['colorName'],
|
|
|
201
|
- 'goodsName' => $value['goodsName'],
|
|
|
202
|
- 'colorNum' => $colorStorageNum,
|
|
|
203
|
- 'sizeNumStr' => rtrim($sizeStorageStr, '/'),
|
174
|
+ $sizeStorageStr = '';
|
|
|
175
|
+
|
|
|
176
|
+ // 商品分组
|
|
|
177
|
+ if (isset($value['goodsImagesList'])) {
|
|
|
178
|
+ foreach ($value['goodsImagesList'] as $goods) {
|
|
|
179
|
+ $goodsGroup[] = array(
|
|
|
180
|
+ 'goodsId' => $goods['goodsId'],
|
|
|
181
|
+ 'img' => $goods['imageUrl'],
|
204
|
);
|
182
|
);
|
205
|
}
|
183
|
}
|
|
|
184
|
+ }
|
206
|
|
185
|
|
207
|
- // 缩略图
|
|
|
208
|
- $thumbImageList[] = array('img' => Helpers::getImageUrl($value['colorImage'], 60, 60));
|
|
|
209
|
-
|
|
|
210
|
- // 添加尺码对应的各个颜色的库存量
|
|
|
211
|
- foreach ($sizeList as $colorId => $sizeArr) {
|
|
|
212
|
- foreach ($sizeArr as $key => $value) {
|
|
|
213
|
- $sizeList[$colorId][$key]['colorNumStr'] = implode('/', array_values($colorStorageGroup[$value['name']]));
|
|
|
214
|
- }
|
186
|
+ // 商品的尺码列表
|
|
|
187
|
+ if (isset($value['goodsSizeBoList'])) {
|
|
|
188
|
+ foreach ($value['goodsSizeBoList'] as $size) {
|
|
|
189
|
+ $sizeList[$value['colorId']][] = array(
|
|
|
190
|
+ 'id' => $size['id'],
|
|
|
191
|
+ 'skuId' => $size['goodsSizeSkuId'],
|
|
|
192
|
+ 'goodsId' => $size['goodsId'],
|
|
|
193
|
+ 'colorId' => $value['colorId'],
|
|
|
194
|
+ 'name' => $size['sizeName'],
|
|
|
195
|
+ 'sizeNum' => $size['goodsSizeStorageNum'],
|
|
|
196
|
+ );
|
|
|
197
|
+ $colorStorageNum += intval($size['goodsSizeStorageNum']);
|
|
|
198
|
+ $sizeStorageStr .= $size['goodsSizeStorageNum'] . '/';
|
|
|
199
|
+ $colorStorageGroup[$size['sizeName']][$value['colorId']] = $size['goodsSizeStorageNum'];
|
215
|
}
|
200
|
}
|
216
|
|
201
|
|
217
|
- // 商品库存总数
|
|
|
218
|
- $totalStorageNum += $colorStorageNum;
|
202
|
+ // 颜色分组
|
|
|
203
|
+ $colorGroup[] = array(
|
|
|
204
|
+ 'id' => $value['colorId'],
|
|
|
205
|
+ 'skcId' => $value['productSkc'],
|
|
|
206
|
+ 'name' => $value['colorName'],
|
|
|
207
|
+ 'goodsName' => $value['goodsName'],
|
|
|
208
|
+ 'colorNum' => $colorStorageNum,
|
|
|
209
|
+ 'sizeNumStr' => rtrim($sizeStorageStr, '/'),
|
|
|
210
|
+ );
|
219
|
}
|
211
|
}
|
220
|
|
212
|
|
221
|
- // 格式化尺码对应的各个颜色分组
|
|
|
222
|
- foreach ($colorGroup as $value) {
|
|
|
223
|
- $sizeGroup[]['size'] = $sizeList[ $value['id'] ];
|
|
|
224
|
- }
|
213
|
+ // 缩略图
|
|
|
214
|
+ $thumbImageList[] = array('img' => Helpers::getImageUrl($value['colorImage'], 60, 60));
|
225
|
|
215
|
|
226
|
- // 商品图: 多个
|
|
|
227
|
- if (isset($goodsGroup[1])) {
|
|
|
228
|
- foreach ($goodsGroup as $value) {
|
|
|
229
|
- $result['bannerTop']['list'][] = array(
|
|
|
230
|
- 'img' => Helpers::getImageUrl($value['img'], 450, 600)
|
|
|
231
|
- );
|
216
|
+ // 添加尺码对应的各个颜色的库存量
|
|
|
217
|
+ foreach ($sizeList as $colorId => $sizeArr) {
|
|
|
218
|
+ foreach ($sizeArr as $key => $value) {
|
|
|
219
|
+ $sizeList[$colorId][$key]['colorNumStr'] = implode('/', array_values($colorStorageGroup[$value['name']]));
|
232
|
}
|
220
|
}
|
233
|
}
|
221
|
}
|
234
|
- // 商品图: 单个
|
|
|
235
|
- elseif (isset($goodsGroup[0])) {
|
|
|
236
|
- $result['bannerTop'] = array(
|
|
|
237
|
- 'img' => Helpers::getImageUrl($goodsGroup[0]['img'], 450, 600)
|
|
|
238
|
- );
|
|
|
239
|
- }
|
222
|
+
|
|
|
223
|
+ // 商品库存总数
|
|
|
224
|
+ $totalStorageNum += $colorStorageNum;
|
240
|
}
|
225
|
}
|
241
|
|
226
|
|
242
|
- // 悬浮的购物车信息
|
|
|
243
|
- $result['cartInfo'] = array(
|
|
|
244
|
- 'cartUrl' => Helpers::url('/cart/index/index', null), // 购物车链接
|
|
|
245
|
- 'numInCart' => 0,
|
|
|
246
|
- 'goodsInstore' => $baseInfo['storage'], // 库存量
|
|
|
247
|
- );
|
|
|
248
|
- $soldOut = ($baseInfo['storage'] == 0) || ($baseInfo['status'] == 0);
|
|
|
249
|
- $notForSale = $baseInfo['attribute'] == 2;
|
|
|
250
|
- // 显示加入购物车链接
|
|
|
251
|
- if (!$soldOut && !$notForSale) {
|
|
|
252
|
- $result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html');
|
|
|
253
|
- $result['cartInfo']['productId'] = $productId;
|
|
|
254
|
- $result['cartInfo']['thumbs'] = $thumbImageList;
|
|
|
255
|
- $result['cartInfo']['name'] = isset($result['goodsName']) ? $result['goodsName'] : '';
|
|
|
256
|
- $result['cartInfo']['price'] = isset($result['goodsPrice']['previousPrice']) ? $result['goodsPrice']['previousPrice'] : '';
|
|
|
257
|
- $result['cartInfo']['salePrice'] = isset($result['goodsPrice']['currentPrice']) ? $result['goodsPrice']['currentPrice'] : '';
|
|
|
258
|
- $result['cartInfo']['totalNum'] = $totalStorageNum;
|
|
|
259
|
- $result['cartInfo']['colors'] = $colorGroup;
|
|
|
260
|
- $result['cartInfo']['sizes'] = $sizeGroup;
|
227
|
+ // 格式化尺码对应的各个颜色分组
|
|
|
228
|
+ foreach ($colorGroup as $value) {
|
|
|
229
|
+ $sizeGroup[]['size'] = $sizeList[ $value['id'] ];
|
261
|
}
|
230
|
}
|
262
|
- // 非卖品
|
|
|
263
|
- elseif ($notForSale) {
|
|
|
264
|
- $result['cartInfo']['notForSale'] = true;
|
231
|
+
|
|
|
232
|
+ // 商品图: 多个
|
|
|
233
|
+ if (isset($goodsGroup[1])) {
|
|
|
234
|
+ foreach ($goodsGroup as $value) {
|
|
|
235
|
+ $result['bannerTop']['list'][] = array(
|
|
|
236
|
+ 'img' => Helpers::getImageUrl($value['img'], 450, 600)
|
|
|
237
|
+ );
|
|
|
238
|
+ }
|
265
|
}
|
239
|
}
|
266
|
- // 已售磬
|
|
|
267
|
- elseif ($soldOut) {
|
|
|
268
|
- $result['cartInfo']['soldOut'] = true;
|
240
|
+ // 商品图: 单个
|
|
|
241
|
+ elseif (isset($goodsGroup[0])) {
|
|
|
242
|
+ $result['bannerTop'] = array(
|
|
|
243
|
+ 'img' => Helpers::getImageUrl($goodsGroup[0]['img'], 450, 600)
|
|
|
244
|
+ );
|
269
|
}
|
245
|
}
|
|
|
246
|
+ }
|
270
|
|
247
|
|
271
|
- // 是否收藏
|
|
|
272
|
- $result['isCollect'] = false;
|
|
|
273
|
- if (isset($baseInfo['isCollect']) && $baseInfo['isCollect'] === 'Y') {
|
|
|
274
|
- $result['isCollect'] = true;
|
|
|
275
|
- }
|
248
|
+ // 悬浮的购物车信息
|
|
|
249
|
+ $result['cartInfo'] = array(
|
|
|
250
|
+ 'cartUrl' => Helpers::url('/cart/index/index', null), // 购物车链接
|
|
|
251
|
+ 'numInCart' => 0,
|
|
|
252
|
+ 'goodsInstore' => $baseInfo['storage'], // 库存量
|
|
|
253
|
+ );
|
|
|
254
|
+ $soldOut = ($baseInfo['storage'] == 0) || ($baseInfo['status'] == 0);
|
|
|
255
|
+ $notForSale = $baseInfo['attribute'] == 2;
|
|
|
256
|
+ // 显示加入购物车链接
|
|
|
257
|
+ if (!$soldOut && !$notForSale) {
|
|
|
258
|
+ $result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html');
|
|
|
259
|
+ $result['cartInfo']['productId'] = $productId;
|
|
|
260
|
+ $result['cartInfo']['thumbs'] = $thumbImageList;
|
|
|
261
|
+ $result['cartInfo']['name'] = isset($result['goodsName']) ? $result['goodsName'] : '';
|
|
|
262
|
+ $result['cartInfo']['price'] = isset($result['goodsPrice']['previousPrice']) ? $result['goodsPrice']['previousPrice'] : '';
|
|
|
263
|
+ $result['cartInfo']['salePrice'] = isset($result['goodsPrice']['currentPrice']) ? $result['goodsPrice']['currentPrice'] : '';
|
|
|
264
|
+ $result['cartInfo']['totalNum'] = $totalStorageNum;
|
|
|
265
|
+ $result['cartInfo']['colors'] = $colorGroup;
|
|
|
266
|
+ $result['cartInfo']['sizes'] = $sizeGroup;
|
|
|
267
|
+ }
|
|
|
268
|
+ // 非卖品
|
|
|
269
|
+ elseif ($notForSale) {
|
|
|
270
|
+ $result['cartInfo']['notForSale'] = true;
|
|
|
271
|
+ }
|
|
|
272
|
+ // 已售磬
|
|
|
273
|
+ elseif ($soldOut) {
|
|
|
274
|
+ $result['cartInfo']['soldOut'] = true;
|
|
|
275
|
+ }
|
276
|
|
276
|
|
277
|
- // 底部简介的URL链接
|
|
|
278
|
- $result['introUrl'] = Helpers::url('/product/intro_' . $baseInfo['erpProductId'] . '/' . $baseInfo['cnAlphabet'] . '.html', null, '');
|
|
|
279
|
- $result['id'] = $productId;
|
277
|
+ // 是否收藏
|
|
|
278
|
+ $result['isCollect'] = false;
|
|
|
279
|
+ if (isset($baseInfo['isCollect']) && $baseInfo['isCollect'] === 'Y') {
|
|
|
280
|
+ $result['isCollect'] = true;
|
280
|
}
|
281
|
}
|
281
|
|
282
|
|
|
|
283
|
+ // 底部简介的URL链接
|
|
|
284
|
+ $result['introUrl'] = Helpers::url('/product/intro_' . $baseInfo['erpProductId'] . '/' . $baseInfo['cnAlphabet'] . '.html', null, '');
|
|
|
285
|
+ $result['id'] = $productId;
|
|
|
286
|
+
|
282
|
return $result;
|
287
|
return $result;
|
283
|
}
|
288
|
}
|
284
|
|
289
|
|