code review by fei.hong: do add criteo analysis codes
Showing
4 changed files
with
111 additions
and
55 deletions
@@ -682,10 +682,12 @@ class Helpers | @@ -682,10 +682,12 @@ class Helpers | ||
682 | * | 682 | * |
683 | * @param array $cartGoods 购物车商品列表 | 683 | * @param array $cartGoods 购物车商品列表 |
684 | * @param bool $isAdvanceCart 是否是预售购物车(和上市期有关) | 684 | * @param bool $isAdvanceCart 是否是预售购物车(和上市期有关) |
685 | - * @param boolean $isValid 是否是可用商品(非失效商品),默认是 | 685 | + * @param bool $isValid 是否是可用商品(非失效商品),默认是 |
686 | + * @param bool $isOffShelves 是否卖光了, 默认否 | ||
687 | + * @param array $analysis 第三方数据分析用的 | ||
686 | * @return array 处理之后的购物车商品数据 | 688 | * @return array 处理之后的购物车商品数据 |
687 | */ | 689 | */ |
688 | - public static function formatCartGoods($cartGoods, $isAdvanceCart, $isValid = true, $isOffShelves = false) | 690 | + public static function formatCartGoods($cartGoods, $isAdvanceCart, $isValid = true, $isOffShelves = false, &$analysis = array()) |
689 | { | 691 | { |
690 | $result = array(); | 692 | $result = array(); |
691 | 693 | ||
@@ -744,6 +746,29 @@ class Helpers | @@ -744,6 +746,29 @@ class Helpers | ||
744 | elseif ($value['real_price'] == 0) { | 746 | elseif ($value['real_price'] == 0) { |
745 | $oneGoods['productPrice'] = self::transPrice($value['sales_price']); | 747 | $oneGoods['productPrice'] = self::transPrice($value['sales_price']); |
746 | $oneGoods['xForOne'] = true; | 748 | $oneGoods['xForOne'] = true; |
749 | + | ||
750 | + // 分析用: 商品ID列表 | ||
751 | + $analysis['ids'][] = $value['product_id']; | ||
752 | + // 分析用: 品友 | ||
753 | + $analysis['ipinyou'] .= $value['product_id'] . ',' . $value['buy_number'] . ';'; | ||
754 | + // 分析用: CRITEO | ||
755 | + $analysis['criteo'][] = array( | ||
756 | + 'id' => $value['product_skn'], | ||
757 | + 'quantity' => intval($value['buy_number']), | ||
758 | + 'price' => $value['last_vip_price'], | ||
759 | + ); | ||
760 | + } | ||
761 | + else { | ||
762 | + // 分析用: 商品ID列表 | ||
763 | + $analysis['ids'][] = $value['product_id']; | ||
764 | + // 分析用: 品友 | ||
765 | + $analysis['ipinyou'] .= $value['product_id'] . ',' . $value['buy_number'] . ';'; | ||
766 | + // 分析用: CRITEO | ||
767 | + $analysis['criteo'][] = array( | ||
768 | + 'id' => $value['product_skn'], | ||
769 | + 'quantity' => intval($value['buy_number']), | ||
770 | + 'price' => $value['last_vip_price'], | ||
771 | + ); | ||
747 | } | 772 | } |
748 | 773 | ||
749 | // 商品类型:预售或普通 | 774 | // 商品类型:预售或普通 |
@@ -341,4 +341,40 @@ | @@ -341,4 +341,40 @@ | ||
341 | <div class="loading"><span></span>请稍后...</div> | 341 | <div class="loading"><span></span>请稍后...</div> |
342 | </div> | 342 | </div> |
343 | <!-- 商品详细信息窗口 --> | 343 | <!-- 商品详细信息窗口 --> |
344 | + | ||
345 | +<script type="text/javascript"> | ||
346 | +(function (d) { | ||
347 | +window.bd_cpro_rtid="P1fsPWc"; | ||
348 | +var s = d.createElement("script");s.type = "text/javascript";s.async = true;s.src = location.protocol + "//cpro.baidu.com/cpro/ui/rt.js"; | ||
349 | +var s0 = d.getElementsByTagName("script")[0];s0.parentNode.insertBefore(s, s0); | ||
350 | +})(document); | ||
351 | +</script> | ||
352 | +<script type="text/javascript" src="http://static.criteo.net/js/ld/ld.js" async="true"></script> | ||
353 | +<script type="text/javascript"> | ||
354 | +window.criteo_q = window.criteo_q || []; | ||
355 | +window.criteo_q.push( | ||
356 | +{event:"setAccount", account: 16184}, | ||
357 | +{event:"setCustomerId", id: "{{uid}}"}, | ||
358 | +{event:"setSiteType", type: "d"}, | ||
359 | +{event:"viewBasket", item: {{{cartEnsure.criteo}}} } | ||
360 | +); | ||
361 | +</script> | ||
362 | +<!-- 聚效 --> | ||
363 | +<script type="text/javascript"> | ||
364 | +var _mvq = window._mvq || []; | ||
365 | +window._mvq = _mvq; | ||
366 | +_mvq.push(['$setAccount', 'm-23428-1']); | ||
367 | +_mvq.push(['$setGeneral', 'cartview', '', /*用户名*/ '', '{{uid}}']); | ||
368 | +_mvq.push(['$logConversion']); | ||
369 | +_mvq.push(['$addItem', '', /*商品id*/ '{{cartEnsure.ids}}', '', '']); | ||
370 | +_mvq.push(['$logData']); | ||
371 | +</script> | ||
372 | +<script> | ||
373 | +!function(w,d,e){ | ||
374 | +var _money='{{cartEnsure.ipinyouAmount}}'; | ||
375 | +var _productList='{{cartEnsure.ipinyou}}'; | ||
376 | +var b=location.href,c=d.referrer,f,s,g=d.cookie,h=g.match(/(^|;)\s*ipycookie=([^;]*)/),i=g.match(/(^|;)\s*ipysession=([^;]*)/);if (w.parent!=w){f=b;b=c;c=f;};u='//stats.ipinyou.com/cvt?a='+e('MC.Ok.7NFMIlCH_F_LE2riRlF2r_')+'&c='+e(h?h[2]:'')+'&s='+e(i?i[2].match(/jump\%3D(\d+)/)[1]:'')+'&u='+e(b)+'&r='+e(c)+'&rd='+(new Date()).getTime()+'&Money='+e(_money)+'&ProductList='+e(_productList)+'&e='; | ||
377 | +function _(){if(!d.body){setTimeout(_(),100);}else{s= d.createElement('script');s.src = u;d.body.insertBefore(s,d.body.firstChild);}}_(); | ||
378 | +}(window,document,encodeURIComponent); | ||
379 | +</script> | ||
344 | {{> layout/footer}} | 380 | {{> layout/footer}} |
@@ -36,6 +36,9 @@ class CartModel | @@ -36,6 +36,9 @@ class CartModel | ||
36 | public static function myCartData($uid, $shoppingKey, $cartDelList) | 36 | public static function myCartData($uid, $shoppingKey, $cartDelList) |
37 | { | 37 | { |
38 | $result = array(); | 38 | $result = array(); |
39 | + | ||
40 | + // 存放分析用的数据 | ||
41 | + $analysisData = array('ipinyou' => ''); | ||
39 | 42 | ||
40 | do { | 43 | do { |
41 | $result['isEmpty'] = false; | 44 | $result['isEmpty'] = false; |
@@ -47,7 +50,7 @@ class CartModel | @@ -47,7 +50,7 @@ class CartModel | ||
47 | 50 | ||
48 | // 调用接口,获取购物车数据 | 51 | // 调用接口,获取购物车数据 |
49 | $cartData = CartData::cartData($uid, $shoppingKey); | 52 | $cartData = CartData::cartData($uid, $shoppingKey); |
50 | - | 53 | + |
51 | // 接口异常时,购物车置为空 | 54 | // 接口异常时,购物车置为空 |
52 | if (empty($cartData['data'])) { | 55 | if (empty($cartData['data'])) { |
53 | $result['isEmpty'] = true; | 56 | $result['isEmpty'] = true; |
@@ -55,7 +58,7 @@ class CartModel | @@ -55,7 +58,7 @@ class CartModel | ||
55 | $result['viewOrderUrl'] = Helpers::url('/home/orders', array('t' => time())); | 58 | $result['viewOrderUrl'] = Helpers::url('/home/orders', array('t' => time())); |
56 | break; | 59 | break; |
57 | } | 60 | } |
58 | - | 61 | + |
59 | $ordinaryCartData = $cartData['data']['ordinary_cart_data']; | 62 | $ordinaryCartData = $cartData['data']['ordinary_cart_data']; |
60 | $advanceCartData = $cartData['data']['advance_cart_data']; | 63 | $advanceCartData = $cartData['data']['advance_cart_data']; |
61 | 64 | ||
@@ -71,7 +74,7 @@ class CartModel | @@ -71,7 +74,7 @@ class CartModel | ||
71 | $ordinaryOffShelves = empty($ordinaryCartData['off_shelves_goods_list']); | 74 | $ordinaryOffShelves = empty($ordinaryCartData['off_shelves_goods_list']); |
72 | // 预售商品是否有失效的 | 75 | // 预售商品是否有失效的 |
73 | $advanceOffShelves = empty($advanceCartData['off_shelves_goods_list']); | 76 | $advanceOffShelves = empty($advanceCartData['off_shelves_goods_list']); |
74 | - | 77 | + |
75 | /* 移除的商品列表 */ | 78 | /* 移除的商品列表 */ |
76 | if (!empty($cartDelList)) { | 79 | if (!empty($cartDelList)) { |
77 | $result['deleteShop'] = json_decode($cartDelList, true); | 80 | $result['deleteShop'] = json_decode($cartDelList, true); |
@@ -121,44 +124,36 @@ class CartModel | @@ -121,44 +124,36 @@ class CartModel | ||
121 | // 普通的 | 124 | // 普通的 |
122 | if (!empty($ordinaryCartData['goods_list'])) { | 125 | if (!empty($ordinaryCartData['goods_list'])) { |
123 | $result['commonSell']['cartProductNum'] = strval($ordinaryCount); | 126 | $result['commonSell']['cartProductNum'] = strval($ordinaryCount); |
124 | - $result['commonSell']['productItem'] = Helpers::formatCartGoods($ordinaryCartData['goods_list'], false, true); | 127 | + $result['commonSell']['productItem'] = Helpers::formatCartGoods($ordinaryCartData['goods_list'], false, true, false, $analysisData); |
125 | } | 128 | } |
126 | // 预售的 | 129 | // 预售的 |
127 | if (!empty($advanceCartData['goods_list'])) { | 130 | if (!empty($advanceCartData['goods_list'])) { |
128 | $result['preSell']['cartProductNum'] = strval($advanceCount); | 131 | $result['preSell']['cartProductNum'] = strval($advanceCount); |
129 | - $result['preSell']['productItem'] = Helpers::formatCartGoods($advanceCartData['goods_list'], true, true); | 132 | + $result['preSell']['productItem'] = Helpers::formatCartGoods($advanceCartData['goods_list'], true, true, false, $analysisData); |
130 | } | 133 | } |
131 | 134 | ||
132 | /* 已售磬失效 */ | 135 | /* 已售磬失效 */ |
133 | // 普通的 | 136 | // 普通的 |
134 | if (!$ordinarySoldOut) { | 137 | if (!$ordinarySoldOut) { |
135 | //$result['commonSell']['cartProductNum'] += count($ordinaryCartData['sold_out_goods_list']); | 138 | //$result['commonSell']['cartProductNum'] += count($ordinaryCartData['sold_out_goods_list']); |
136 | - $result['commonSell']['productItem'] = isset($result['commonSell']['productItem']) | ||
137 | - ? self::appendProductItem($result['commonSell']['productItem'], Helpers::formatCartGoods($ordinaryCartData['sold_out_goods_list'], false, true), count($result['commonSell']['productItem'])) | ||
138 | - : Helpers::formatCartGoods($ordinaryCartData['sold_out_goods_list'], false, true); | 139 | + $result['commonSell']['productItem'] = isset($result['commonSell']['productItem']) ? self::appendProductItem($result['commonSell']['productItem'], Helpers::formatCartGoods($ordinaryCartData['sold_out_goods_list'], false, true), count($result['commonSell']['productItem'])) : Helpers::formatCartGoods($ordinaryCartData['sold_out_goods_list'], false, true, false, $analysisData); |
139 | } | 140 | } |
140 | // 预售的 | 141 | // 预售的 |
141 | if (!$advanceSoldOut) { | 142 | if (!$advanceSoldOut) { |
142 | //$result['preSell']['cartProductNum'] += count($advanceCartData['sold_out_goods_list']); | 143 | //$result['preSell']['cartProductNum'] += count($advanceCartData['sold_out_goods_list']); |
143 | - $result['preSell']['productItem'] = isset($result['preSell']['productItem']) | ||
144 | - ? self::appendProductItem($result['preSell']['productItem'], Helpers::formatCartGoods($advanceCartData['sold_out_goods_list'], true, true), count($result['preSell']['productItem'])) | ||
145 | - : Helpers::formatCartGoods($advanceCartData['sold_out_goods_list'], true, true); | 144 | + $result['preSell']['productItem'] = isset($result['preSell']['productItem']) ? self::appendProductItem($result['preSell']['productItem'], Helpers::formatCartGoods($advanceCartData['sold_out_goods_list'], true, true), count($result['preSell']['productItem'])) : Helpers::formatCartGoods($advanceCartData['sold_out_goods_list'], true, true, false, $analysisData); |
146 | } | 145 | } |
147 | - | 146 | + |
148 | /* 已失效的 */ | 147 | /* 已失效的 */ |
149 | // 普通的 | 148 | // 普通的 |
150 | if (!$ordinaryOffShelves) { | 149 | if (!$ordinaryOffShelves) { |
151 | //$result['commonSell']['cartProductNum'] += count($ordinaryCartData['off_shelves_goods_list']); | 150 | //$result['commonSell']['cartProductNum'] += count($ordinaryCartData['off_shelves_goods_list']); |
152 | - $result['commonSell']['productItem'] = isset($result['commonSell']['productItem']) | ||
153 | - ? self::appendProductItem($result['commonSell']['productItem'], Helpers::formatCartGoods($ordinaryCartData['off_shelves_goods_list'], false, true, true), count($result['commonSell']['productItem'])) | ||
154 | - : Helpers::formatCartGoods($ordinaryCartData['off_shelves_goods_list'], false, true, true); | 151 | + $result['commonSell']['productItem'] = isset($result['commonSell']['productItem']) ? self::appendProductItem($result['commonSell']['productItem'], Helpers::formatCartGoods($ordinaryCartData['off_shelves_goods_list'], false, true, true), count($result['commonSell']['productItem'])) : Helpers::formatCartGoods($ordinaryCartData['off_shelves_goods_list'], false, true, true, $analysisData); |
155 | } | 152 | } |
156 | // 预售的 | 153 | // 预售的 |
157 | if (!$advanceOffShelves) { | 154 | if (!$advanceOffShelves) { |
158 | //$result['preSell']['cartProductNum'] += count($advanceCartData['off_shelves_goods_list']); | 155 | //$result['preSell']['cartProductNum'] += count($advanceCartData['off_shelves_goods_list']); |
159 | - $result['preSell']['productItem'] = isset($result['preSell']['productItem']) | ||
160 | - ? self::appendProductItem($result['preSell']['productItem'], Helpers::formatCartGoods($advanceCartData['off_shelves_goods_list'], true, true, true), count($result['preSell']['productItem'])) | ||
161 | - : Helpers::formatCartGoods($advanceCartData['off_shelves_goods_list'], true, true, true); | 156 | + $result['preSell']['productItem'] = isset($result['preSell']['productItem']) ? self::appendProductItem($result['preSell']['productItem'], Helpers::formatCartGoods($advanceCartData['off_shelves_goods_list'], true, true, true), count($result['preSell']['productItem'])) : Helpers::formatCartGoods($advanceCartData['off_shelves_goods_list'], true, true, true, $analysisData); |
162 | } | 157 | } |
163 | 158 | ||
164 | /* 赠品 */ | 159 | /* 赠品 */ |
@@ -168,22 +163,17 @@ class CartModel | @@ -168,22 +163,17 @@ class CartModel | ||
168 | } | 163 | } |
169 | // 普通的 | 164 | // 普通的 |
170 | if (!empty($ordinaryCartData['gift_list'])) { | 165 | if (!empty($ordinaryCartData['gift_list'])) { |
171 | - $result['subjoinItem'] = isset($result['subjoinItem']) ? self::appendProductItem($result['subjoinItem'], Helpers::formatGiftPriceGoods($ordinaryCartData['gift_list'], true), count($result['subjoinItem'])) | ||
172 | - : Helpers::formatGiftPriceGoods($ordinaryCartData['gift_list'], true); | 166 | + $result['subjoinItem'] = isset($result['subjoinItem']) ? self::appendProductItem($result['subjoinItem'], Helpers::formatGiftPriceGoods($ordinaryCartData['gift_list'], true), count($result['subjoinItem'])) : Helpers::formatGiftPriceGoods($ordinaryCartData['gift_list'], true); |
173 | } | 167 | } |
174 | 168 | ||
175 | /* 加价购 */ | 169 | /* 加价购 */ |
176 | // 预售的 | 170 | // 预售的 |
177 | if (!empty($advanceCartData['price_gift'])) { | 171 | if (!empty($advanceCartData['price_gift'])) { |
178 | - $result['subjoinItem'] = isset($result['subjoinItem']) | ||
179 | - ? self::appendProductItem($result['subjoinItem'], Helpers::formatGiftPriceGoods($advanceCartData['price_gift'], false), count($result['subjoinItem'])) | ||
180 | - : Helpers::formatGiftPriceGoods($advanceCartData['price_gift'], false); | 172 | + $result['subjoinItem'] = isset($result['subjoinItem']) ? self::appendProductItem($result['subjoinItem'], Helpers::formatGiftPriceGoods($advanceCartData['price_gift'], false), count($result['subjoinItem'])) : Helpers::formatGiftPriceGoods($advanceCartData['price_gift'], false); |
181 | } | 173 | } |
182 | // 普通的 | 174 | // 普通的 |
183 | if (!empty($ordinaryCartData['price_gift'])) { | 175 | if (!empty($ordinaryCartData['price_gift'])) { |
184 | - $result['subjoinItem'] = isset($result['subjoinItem']) | ||
185 | - ? self::appendProductItem($result['subjoinItem'], Helpers::formatGiftPriceGoods($ordinaryCartData['price_gift'], false), count($result['subjoinItem'])) | ||
186 | - : Helpers::formatGiftPriceGoods($ordinaryCartData['price_gift'], false); | 176 | + $result['subjoinItem'] = isset($result['subjoinItem']) ? self::appendProductItem($result['subjoinItem'], Helpers::formatGiftPriceGoods($ordinaryCartData['price_gift'], false), count($result['subjoinItem'])) : Helpers::formatGiftPriceGoods($ordinaryCartData['price_gift'], false); |
187 | } | 177 | } |
188 | 178 | ||
189 | /* 促销短语 */ | 179 | /* 促销短语 */ |
@@ -197,13 +187,19 @@ class CartModel | @@ -197,13 +187,19 @@ class CartModel | ||
197 | //$result['salesPromotion'] = array_merge($result['salesPromotion'], self::buildPromotionData($advanceCartData['promotion_info'])); | 187 | //$result['salesPromotion'] = array_merge($result['salesPromotion'], self::buildPromotionData($advanceCartData['promotion_info'])); |
198 | $result['salesPromotion'] = self::buildPromotionData($advanceCartData['promotion_info']); | 188 | $result['salesPromotion'] = self::buildPromotionData($advanceCartData['promotion_info']); |
199 | } | 189 | } |
200 | - | 190 | + |
201 | // 清空变量 | 191 | // 清空变量 |
202 | $advanceCartData = array(); | 192 | $advanceCartData = array(); |
203 | $ordinaryCartData = array(); | 193 | $ordinaryCartData = array(); |
204 | $cartData = array(); | 194 | $cartData = array(); |
205 | 195 | ||
206 | } while (false); | 196 | } while (false); |
197 | + | ||
198 | + // 增加第三方分析用的数据 | ||
199 | + $result['ids'] = empty($analysisData['ids']) ? '' : implode(',', $analysisData['ids']); | ||
200 | + $result['ipinyou'] = empty($analysisData['ipinyou']) ? '' : $analysisData['ipinyou']; | ||
201 | + $result['ipinyouAmount'] = isset($result['productAllA']) ? $result['productAllA'] : '0.00'; | ||
202 | + $result['criteo'] = empty($analysisData['criteo']) ? '' : json_encode($analysisData['criteo']); | ||
207 | 203 | ||
208 | return $result; | 204 | return $result; |
209 | } | 205 | } |
@@ -423,7 +419,7 @@ class CartModel | @@ -423,7 +419,7 @@ class CartModel | ||
423 | break; | 419 | break; |
424 | } | 420 | } |
425 | 421 | ||
426 | - | 422 | + |
427 | $result['data']['hasPrev'] = false; | 423 | $result['data']['hasPrev'] = false; |
428 | $result['data']['hasNext'] = true; | 424 | $result['data']['hasNext'] = true; |
429 | if (intval($page) > 1) { | 425 | if (intval($page) > 1) { |
@@ -476,20 +472,20 @@ class CartModel | @@ -476,20 +472,20 @@ class CartModel | ||
476 | if (empty($sknList)) { | 472 | if (empty($sknList)) { |
477 | break; | 473 | break; |
478 | } | 474 | } |
479 | - | 475 | + |
480 | // 组装 skn => goodsId 对应关系 | 476 | // 组装 skn => goodsId 对应关系 |
481 | $sknArr = array(); | 477 | $sknArr = array(); |
482 | foreach ($sknList as $value) { | 478 | foreach ($sknList as $value) { |
483 | $value = explode('-', $value); | 479 | $value = explode('-', $value); |
484 | if (isset($value[1])) { | 480 | if (isset($value[1])) { |
485 | - $sknArr[ $value[0] ] = $value[1]; | 481 | + $sknArr[$value[0]] = $value[1]; |
486 | } | 482 | } |
487 | } | 483 | } |
488 | - | 484 | + |
489 | if (array() === $sknArr) { | 485 | if (array() === $sknArr) { |
490 | break; | 486 | break; |
491 | } | 487 | } |
492 | - | 488 | + |
493 | // 通过SKN列表搜索调用商品信息 | 489 | // 通过SKN列表搜索调用商品信息 |
494 | $browse = CartData::browseRecordFromSearch(implode(' ', array_keys($sknArr))); | 490 | $browse = CartData::browseRecordFromSearch(implode(' ', array_keys($sknArr))); |
495 | if (empty($browse['data']['product_list'])) { | 491 | if (empty($browse['data']['product_list'])) { |
@@ -532,11 +528,11 @@ class CartModel | @@ -532,11 +528,11 @@ class CartModel | ||
532 | $build['href'] = Helpers::url('/product/pro_' . $value['product_id'] . '_' . $goodsId . '/' . $value['cn_alphabet'] . '.html', null, 'item'); | 528 | $build['href'] = Helpers::url('/product/pro_' . $value['product_id'] . '_' . $goodsId . '/' . $value['cn_alphabet'] . '.html', null, 'item'); |
533 | 529 | ||
534 | $result['data']['item'][] = $build; | 530 | $result['data']['item'][] = $build; |
535 | - | 531 | + |
536 | break; | 532 | break; |
537 | } | 533 | } |
538 | } | 534 | } |
539 | - | 535 | + |
540 | // 当数据量不足6个时,判定为没有下一页 | 536 | // 当数据量不足6个时,判定为没有下一页 |
541 | if (!isset($result['data']['item'][5])) { | 537 | if (!isset($result['data']['item'][5])) { |
542 | $result['data']['hasNext'] = false; | 538 | $result['data']['hasNext'] = false; |
@@ -574,7 +570,7 @@ class CartModel | @@ -574,7 +570,7 @@ class CartModel | ||
574 | if ($value['payment_type'] == 1 && $value['is_support'] === 'Y') { | 570 | if ($value['payment_type'] == 1 && $value['is_support'] === 'Y') { |
575 | $result['onlinePay']['checked'] = $isDefault ? true : false; | 571 | $result['onlinePay']['checked'] = $isDefault ? true : false; |
576 | $result['onlinePay']['paymentId'] = $value['payment_id']; | 572 | $result['onlinePay']['paymentId'] = $value['payment_id']; |
577 | - } | 573 | + } |
578 | // 货到付款 | 574 | // 货到付款 |
579 | elseif ($value['payment_type'] == 2 && $value['is_support'] === 'Y') { | 575 | elseif ($value['payment_type'] == 2 && $value['is_support'] === 'Y') { |
580 | $result['deliveryPay']['checked'] = $isDefault ? true : false; | 576 | $result['deliveryPay']['checked'] = $isDefault ? true : false; |
@@ -586,7 +582,7 @@ class CartModel | @@ -586,7 +582,7 @@ class CartModel | ||
586 | $result['defaultPayWay'] = $value['payment_type_name']; | 582 | $result['defaultPayWay'] = $value['payment_type_name']; |
587 | } | 583 | } |
588 | } | 584 | } |
589 | - } | 585 | + } |
590 | 586 | ||
591 | // 未设置时,设置默认 | 587 | // 未设置时,设置默认 |
592 | if (!isset($result['defaultPayWay'])) { | 588 | if (!isset($result['defaultPayWay'])) { |
@@ -597,7 +593,7 @@ class CartModel | @@ -597,7 +593,7 @@ class CartModel | ||
597 | $result['defaultPayWay'] = '在线支付'; | 593 | $result['defaultPayWay'] = '在线支付'; |
598 | $result['supportDeliveryPay'] = true; | 594 | $result['supportDeliveryPay'] = true; |
599 | } | 595 | } |
600 | - | 596 | + |
601 | if (!empty($pay['data']['delivery_time'])) { | 597 | if (!empty($pay['data']['delivery_time'])) { |
602 | $build = array(); | 598 | $build = array(); |
603 | foreach ($pay['data']['delivery_time'] as $value) { | 599 | foreach ($pay['data']['delivery_time'] as $value) { |
@@ -610,8 +606,8 @@ class CartModel | @@ -610,8 +606,8 @@ class CartModel | ||
610 | } | 606 | } |
611 | $result['delivery'][] = $build; | 607 | $result['delivery'][] = $build; |
612 | } | 608 | } |
613 | - } | ||
614 | - | 609 | + } |
610 | + | ||
615 | // 默认 | 611 | // 默认 |
616 | if (!isset($result['defaultDelivery'])) { | 612 | if (!isset($result['defaultDelivery'])) { |
617 | $result['defaultDelivery'] = '只工作日送货(双休日、节假日不送)'; | 613 | $result['defaultDelivery'] = '只工作日送货(双休日、节假日不送)'; |
@@ -619,7 +615,7 @@ class CartModel | @@ -619,7 +615,7 @@ class CartModel | ||
619 | $result['delivery'][0]['checked'] = true; | 615 | $result['delivery'][0]['checked'] = true; |
620 | } | 616 | } |
621 | } | 617 | } |
622 | - | 618 | + |
623 | // 支付支持的平台 | 619 | // 支付支持的平台 |
624 | $result['supportLine'] = array( | 620 | $result['supportLine'] = array( |
625 | array('src' => 'http://static.yohobuy.com/images/pay/icon/zhifubao.png'), | 621 | array('src' => 'http://static.yohobuy.com/images/pay/icon/zhifubao.png'), |
@@ -738,7 +734,7 @@ class CartModel | @@ -738,7 +734,7 @@ class CartModel | ||
738 | $result['isPreSell'] = $isAdvanceCart ? true : false; | 734 | $result['isPreSell'] = $isAdvanceCart ? true : false; |
739 | // 顺丰查看详情 | 735 | // 顺丰查看详情 |
740 | $result['sfUrl'] = Helpers::url('/help/index/logisticsarea', null, 'default'); | 736 | $result['sfUrl'] = Helpers::url('/help/index/logisticsarea', null, 'default'); |
741 | - | 737 | + |
742 | // 是否是新客访问, 控制显示新手引导 | 738 | // 是否是新客访问, 控制显示新手引导 |
743 | $isNewUser = Helpers::isNewUser(); | 739 | $isNewUser = Helpers::isNewUser(); |
744 | // 新用户(未下单)且未设置收货地址的,提示引导 | 740 | // 新用户(未下单)且未设置收货地址的,提示引导 |
@@ -746,7 +742,6 @@ class CartModel | @@ -746,7 +742,6 @@ class CartModel | ||
746 | $isNewUser = false; | 742 | $isNewUser = false; |
747 | } | 743 | } |
748 | $result['isNewUser'] = $isNewUser ? true : false; | 744 | $result['isNewUser'] = $isNewUser ? true : false; |
749 | - | ||
750 | } while (false); | 745 | } while (false); |
751 | 746 | ||
752 | return $result; | 747 | return $result; |
@@ -904,7 +899,7 @@ class CartModel | @@ -904,7 +899,7 @@ class CartModel | ||
904 | $phone = explode('-', strtr($value['phone'], array('null' => ''))); | 899 | $phone = explode('-', strtr($value['phone'], array('null' => ''))); |
905 | $mobile = strtr($value['mobile'], array('null' => '')); | 900 | $mobile = strtr($value['mobile'], array('null' => '')); |
906 | $mobile = substr($mobile, 0, 3) . '****' . substr($mobile, 7); | 901 | $mobile = substr($mobile, 0, 3) . '****' . substr($mobile, 7); |
907 | - | 902 | + |
908 | $build = array(); | 903 | $build = array(); |
909 | $build['id'] = $value['address_id']; | 904 | $build['id'] = $value['address_id']; |
910 | $build['user'] = $value['consignee']; | 905 | $build['user'] = $value['consignee']; |
@@ -1007,7 +1002,7 @@ class CartModel | @@ -1007,7 +1002,7 @@ class CartModel | ||
1007 | } else if (!empty($phoneNum) && !is_numeric($phoneNum)) { | 1002 | } else if (!empty($phoneNum) && !is_numeric($phoneNum)) { |
1008 | $result['code'] = 406; | 1003 | $result['code'] = 406; |
1009 | $result['message'] = '输入的固定电话格式不正确'; | 1004 | $result['message'] = '输入的固定电话格式不正确'; |
1010 | - } else if ((!empty($phoneNum) && empty($phoneCode)) || (!empty($phoneCode) && empty($phoneNum)) ) { | 1005 | + } else if ((!empty($phoneNum) && empty($phoneCode)) || (!empty($phoneCode) && empty($phoneNum))) { |
1011 | $result['code'] = 407; | 1006 | $result['code'] = 407; |
1012 | $result['message'] = '输入的固定电话格式不正确'; | 1007 | $result['message'] = '输入的固定电话格式不正确'; |
1013 | } else { | 1008 | } else { |
@@ -1105,7 +1100,6 @@ class CartModel | @@ -1105,7 +1100,6 @@ class CartModel | ||
1105 | $result[] = $build; | 1100 | $result[] = $build; |
1106 | } | 1101 | } |
1107 | $couponList = array(); | 1102 | $couponList = array(); |
1108 | - | ||
1109 | } while (false); | 1103 | } while (false); |
1110 | 1104 | ||
1111 | return $result; | 1105 | return $result; |
@@ -1140,7 +1134,7 @@ class CartModel | @@ -1140,7 +1134,7 @@ class CartModel | ||
1140 | 1134 | ||
1141 | return $result; | 1135 | return $result; |
1142 | } | 1136 | } |
1143 | - | 1137 | + |
1144 | /** | 1138 | /** |
1145 | * 获取购物车总数 | 1139 | * 获取购物车总数 |
1146 | * | 1140 | * |
@@ -1152,7 +1146,7 @@ class CartModel | @@ -1152,7 +1146,7 @@ class CartModel | ||
1152 | { | 1146 | { |
1153 | return CartData::cartCount($uid, $shoppingKey); | 1147 | return CartData::cartCount($uid, $shoppingKey); |
1154 | } | 1148 | } |
1155 | - | 1149 | + |
1156 | /** | 1150 | /** |
1157 | * 追加商品 | 1151 | * 追加商品 |
1158 | * | 1152 | * |
@@ -1165,9 +1159,9 @@ class CartModel | @@ -1165,9 +1159,9 @@ class CartModel | ||
1165 | { | 1159 | { |
1166 | foreach ($data as $value) { | 1160 | foreach ($data as $value) { |
1167 | $source[$index] = $value; | 1161 | $source[$index] = $value; |
1168 | - ++ $index; | 1162 | + ++$index; |
1169 | } | 1163 | } |
1170 | - | 1164 | + |
1171 | return $source; | 1165 | return $source; |
1172 | } | 1166 | } |
1173 | 1167 | ||
@@ -1178,10 +1172,10 @@ class CartModel | @@ -1178,10 +1172,10 @@ class CartModel | ||
1178 | * @param int $default 默认值 | 1172 | * @param int $default 默认值 |
1179 | * @return float | 1173 | * @return float |
1180 | */ | 1174 | */ |
1181 | - private static function genProductAmount($promotionList, $default) | 1175 | + private static function genProductAmount($promotionList, $default) |
1182 | { | 1176 | { |
1183 | $result = $default; | 1177 | $result = $default; |
1184 | - | 1178 | + |
1185 | $vipAmount = null; | 1179 | $vipAmount = null; |
1186 | foreach ($promotionList as $value) { | 1180 | foreach ($promotionList as $value) { |
1187 | if ($value['promotion'] === 'VIP优惠') { | 1181 | if ($value['promotion'] === 'VIP优惠') { |
@@ -1193,10 +1187,10 @@ class CartModel | @@ -1193,10 +1187,10 @@ class CartModel | ||
1193 | $result = floatval($default) - floatval($vipAmount); | 1187 | $result = floatval($default) - floatval($vipAmount); |
1194 | } | 1188 | } |
1195 | $result = Helpers::transPrice($result); | 1189 | $result = Helpers::transPrice($result); |
1196 | - | 1190 | + |
1197 | return $result; | 1191 | return $result; |
1198 | } | 1192 | } |
1199 | - | 1193 | + |
1200 | /** | 1194 | /** |
1201 | * 构建促销短语数据 | 1195 | * 构建促销短语数据 |
1202 | * | 1196 | * |
@@ -35,6 +35,7 @@ class IndexController extends WebAction | @@ -35,6 +35,7 @@ class IndexController extends WebAction | ||
35 | $this->_view->display('cart', array( | 35 | $this->_view->display('cart', array( |
36 | 'cartEnsurePage' => true, | 36 | 'cartEnsurePage' => true, |
37 | 'cartEnsure' => CartModel::myCartData($uid, $shoppingKey, $cartDelList), | 37 | 'cartEnsure' => CartModel::myCartData($uid, $shoppingKey, $cartDelList), |
38 | + 'uid' => $uid ? $uid : '', | ||
38 | )); | 39 | )); |
39 | } | 40 | } |
40 | 41 |
-
Please register or login to post a comment