Showing
1 changed file
with
89 additions
and
17 deletions
@@ -347,16 +347,37 @@ class Helpers | @@ -347,16 +347,37 @@ class Helpers | ||
347 | if (!isset($articleData['id'])) { | 347 | if (!isset($articleData['id'])) { |
348 | return false; | 348 | return false; |
349 | } | 349 | } |
350 | - | 350 | + $width = $height = 360; |
351 | + if($articleData['conver_image_type'] == 2) { | ||
352 | + $width = 360; | ||
353 | + $height = 240; | ||
354 | + } | ||
351 | $result = array(); | 355 | $result = array(); |
352 | $result['id'] = $articleData['id']; | 356 | $result['id'] = $articleData['id']; |
353 | - $result['showTags'] = $showTag; | ||
354 | - $result['img'] = self::getImageUrl($articleData['src'], 640, 640); | 357 | + $result['classification'] = $articleData['category_name']; |
358 | + $result['isReco'] = $articleData['is_recommended']; | ||
355 | $result['url'] = $isApp ? $articleData['url'] : self::url('/info/index', array('id' => $articleData['id']), 'guang'); | 359 | $result['url'] = $isApp ? $articleData['url'] : self::url('/info/index', array('id' => $articleData['id']), 'guang'); |
360 | + $result['img'] = self::getImageUrl($articleData['src'], $width, $height); | ||
361 | + $result['isSquareImg'] = true; | ||
356 | $result['title'] = $articleData['title']; | 362 | $result['title'] = $articleData['title']; |
357 | - $result['text'] = $articleData['intro']; | ||
358 | - $result['publishTime'] = $articleData['publish_time']; | ||
359 | - $result['pageView'] = $articleData['views_num']; | 363 | + if(empty($articleData['author'])){ |
364 | + $articleData['author']['name'] = ''; | ||
365 | + $articleData['author']['avatar'] = ''; | ||
366 | + } | ||
367 | + $result['author'] = $articleData['author']['name']; | ||
368 | + $result['editorUrl'] = $articleData['author']['avatar']; | ||
369 | + $result['pTime'] = $articleData['publish_time']; | ||
370 | + $result['pView'] = $articleData['views_num']; | ||
371 | + $result['content'] = $articleData['intro']; | ||
372 | + $result['showTags'] = $showTag; | ||
373 | + $tags = array(); | ||
374 | + if (!empty($articleData['tags'])) { | ||
375 | + foreach ($articleData['tags'] as $tag) { | ||
376 | + $tags[] = self::formatTag($tag, $isApp); | ||
377 | + } | ||
378 | + } | ||
379 | + $result['tags'] = $tags; | ||
380 | + $result['comment'] = $articleData['comment_num']; | ||
360 | 381 | ||
361 | // 收藏 | 382 | // 收藏 |
362 | if ($isApp) { | 383 | if ($isApp) { |
@@ -366,9 +387,8 @@ class Helpers | @@ -366,9 +387,8 @@ class Helpers | ||
366 | } | 387 | } |
367 | // 点赞 | 388 | // 点赞 |
368 | else { | 389 | else { |
369 | - $result['like'] = array(); | ||
370 | - $result['like']['count'] = $articleData['praise_num']; | ||
371 | - $result['like']['isLiked'] = isset($articleData['isPraise']) && $articleData['isPraise'] === 'Y'; | 390 | + $result['like'] = $articleData['praise_num']; |
391 | + $result['liked'] = isset($articleData['isPraise']) && $articleData['isPraise'] === 'Y'; | ||
372 | } | 392 | } |
373 | 393 | ||
374 | // 分享链接 | 394 | // 分享链接 |
@@ -402,10 +422,31 @@ class Helpers | @@ -402,10 +422,31 @@ class Helpers | ||
402 | break; | 422 | break; |
403 | } | 423 | } |
404 | } | 424 | } |
405 | - | ||
406 | return $result; | 425 | return $result; |
407 | } | 426 | } |
408 | 427 | ||
428 | + public static function formatTag($tagData, $isApp = false, $uid = null) { | ||
429 | + $result = array(); | ||
430 | + $result['tag'] = $tagData['name']; | ||
431 | + $result['url'] = $tagData['url']; | ||
432 | + return $result; | ||
433 | + } | ||
434 | + | ||
435 | + public static function formatAd($adData, $isApp = false, $uid = null) { | ||
436 | + //此处不需要ad的id | ||
437 | + //if (!isset($adData['id'])) { | ||
438 | + // return false; | ||
439 | + //} | ||
440 | + $result = array(); | ||
441 | + // $result['id'] = $adData['id']; | ||
442 | + $result['img'] = self::getImageUrl($adData['src'], 640, 640); | ||
443 | + $result['url'] = $isApp ? $adData['url'] : self::url('/info/index', array('id' => $adData['id']), 'guang'); | ||
444 | + $result['title'] = $adData['title']; | ||
445 | + $result['bgColor'] = $adData['bgColor']; | ||
446 | + return $result; | ||
447 | + } | ||
448 | + | ||
449 | + | ||
409 | /** | 450 | /** |
410 | * 格式化广告焦点图数据 | 451 | * 格式化广告焦点图数据 |
411 | * | 452 | * |
@@ -644,11 +685,12 @@ class Helpers | @@ -644,11 +685,12 @@ class Helpers | ||
644 | * @param boolean $isValid 是否是可用商品(非失效商品),默认是 | 685 | * @param boolean $isValid 是否是可用商品(非失效商品),默认是 |
645 | * @return array 处理之后的购物车商品数据 | 686 | * @return array 处理之后的购物车商品数据 |
646 | */ | 687 | */ |
647 | - public static function formatCartGoods($cartGoods, $isAdvanceCart, $isValid = true) | 688 | + public static function formatCartGoods($cartGoods, $isAdvanceCart, $isValid = true, $isOffShelves = false) |
648 | { | 689 | { |
649 | $result = array(); | 690 | $result = array(); |
650 | 691 | ||
651 | $oneGoods = array(); | 692 | $oneGoods = array(); |
693 | + $cnAlphaBet = ''; | ||
652 | foreach ($cartGoods as $value) { | 694 | foreach ($cartGoods as $value) { |
653 | $oneGoods = array(); | 695 | $oneGoods = array(); |
654 | $oneGoods['id'] = $value['product_sku']; | 696 | $oneGoods['id'] = $value['product_sku']; |
@@ -659,13 +701,19 @@ class Helpers | @@ -659,13 +701,19 @@ class Helpers | ||
659 | $oneGoods['imgCover'] = !empty($value['goods_images']) ? Images::getImageUrl($value['goods_images'], 60, 60) : ''; | 701 | $oneGoods['imgCover'] = !empty($value['goods_images']) ? Images::getImageUrl($value['goods_images'], 60, 60) : ''; |
660 | $oneGoods['productColor'] = $value['color_name']; | 702 | $oneGoods['productColor'] = $value['color_name']; |
661 | $oneGoods['productSize'] = $value['size_name']; | 703 | $oneGoods['productSize'] = $value['size_name']; |
662 | - $oneGoods['productPrice'] = self::transPrice($value['real_price']); | 704 | + $oneGoods['productPrice'] = self::transPrice($value['last_vip_price']); //self::transPrice($value['real_price']); |
663 | $oneGoods['productNum'] = $value['buy_number']; | 705 | $oneGoods['productNum'] = $value['buy_number']; |
664 | $oneGoods['isVipPrice'] = $value['sales_price'] !== $value['last_vip_price']; | 706 | $oneGoods['isVipPrice'] = $value['sales_price'] !== $value['last_vip_price']; |
665 | $oneGoods['yohoIcon'] = isset($value['get_yoho_coin']) ? $value['get_yoho_coin'] : 0; | 707 | $oneGoods['yohoIcon'] = isset($value['get_yoho_coin']) ? $value['get_yoho_coin'] : 0; |
666 | - $oneGoods['productSubtotal'] = isset($value['subtotal']) ? self::transPrice($value['subtotal']) : $oneGoods['productPrice']; | 708 | + $oneGoods['productSubtotal'] = self::transPrice( floatval($value['last_vip_price']) * intval($value['buy_number']) ); |
709 | + $oneGoods['promotionId'] = empty($value['promotion_id']) ? '0' : $value['promotion_id']; | ||
667 | 710 | ||
668 | - if ($isValid) { | 711 | + // 已下架 |
712 | + if ($isOffShelves) { | ||
713 | + $oneGoods['isTipNoStore'] = true; | ||
714 | + $oneGoods['tipMessage'] = '库存不足'; | ||
715 | + } | ||
716 | + else if ($isValid) { | ||
669 | if ($value['buy_number'] > $value['storage_number']) { | 717 | if ($value['buy_number'] > $value['storage_number']) { |
670 | $oneGoods['isTipNoStore'] = true; // 是否在结算时候显示库存不足 | 718 | $oneGoods['isTipNoStore'] = true; // 是否在结算时候显示库存不足 |
671 | $oneGoods['tipMessage'] = '库存不足'; | 719 | $oneGoods['tipMessage'] = '库存不足'; |
@@ -676,7 +724,7 @@ class Helpers | @@ -676,7 +724,7 @@ class Helpers | ||
676 | $oneGoods['inValid'] = true; | 724 | $oneGoods['inValid'] = true; |
677 | } | 725 | } |
678 | 726 | ||
679 | - //,advanceBuy=>是否加价购,soldOut=>失效商品; | 727 | + // advanceBuy=>是否加价购,soldOut=>失效商品; |
680 | if (!isset($value['goods_type'])) { | 728 | if (!isset($value['goods_type'])) { |
681 | $oneGoods['inValid'] = true; | 729 | $oneGoods['inValid'] = true; |
682 | } | 730 | } |
@@ -705,8 +753,10 @@ class Helpers | @@ -705,8 +753,10 @@ class Helpers | ||
705 | if ($isAdvanceCart && !empty($value['expect_arrival_time'])) { | 753 | if ($isAdvanceCart && !empty($value['expect_arrival_time'])) { |
706 | $oneGoods['preSellDate'] = $value['expect_arrival_time']; | 754 | $oneGoods['preSellDate'] = $value['expect_arrival_time']; |
707 | } | 755 | } |
756 | + | ||
708 | // 商品链接 | 757 | // 商品链接 |
709 | - $oneGoods['link'] = self::url('/product/show_' . $value['product_sku'] . '_' . $value['product_skn'] . '.html'); | 758 | + $cnAlphaBet = isset($value['cn_alphabet']) ? $value['cn_alphabet'] : md5($value['product_name']); |
759 | + $oneGoods['link'] = self::url('/product/pro_' . $value['product_id'] . '_' . $value['goods_id'] . '/' . $cnAlphaBet . '.html', null, 'item'); | ||
710 | 760 | ||
711 | $result[] = $oneGoods; | 761 | $result[] = $oneGoods; |
712 | } | 762 | } |
@@ -739,6 +789,7 @@ class Helpers | @@ -739,6 +789,7 @@ class Helpers | ||
739 | 789 | ||
740 | $number = 0; | 790 | $number = 0; |
741 | $subjoinInfo = array(); | 791 | $subjoinInfo = array(); |
792 | + $cnAlphaBet = ''; | ||
742 | foreach ($value['goods_list'] as $single) { | 793 | foreach ($value['goods_list'] as $single) { |
743 | ++ $number; | 794 | ++ $number; |
744 | 795 | ||
@@ -751,7 +802,14 @@ class Helpers | @@ -751,7 +802,14 @@ class Helpers | ||
751 | $oneGoods['marketPrice'] = $isGift ? '' : self::transPrice($single['market_price']); // 市场价 | 802 | $oneGoods['marketPrice'] = $isGift ? '' : self::transPrice($single['market_price']); // 市场价 |
752 | $oneGoods['yohoIcon'] = 0; // 返YOHO币 | 803 | $oneGoods['yohoIcon'] = 0; // 返YOHO币 |
753 | // $oneGoods['storageNum'] = $single['storage_number']; // 库存量 | 804 | // $oneGoods['storageNum'] = $single['storage_number']; // 库存量 |
754 | - $oneGoods['subjoinLink'] = self::url('/product/show_' . $single['product_id'] . '_' . $single['product_skn'] . '.html'); | 805 | + // 商品链接 |
806 | + if (isset($single['goods_id'])) { | ||
807 | + $cnAlphaBet = isset($single['cn_alphabet']) ? $single['cn_alphabet'] : md5($single['product_name']); | ||
808 | + $oneGoods['subjoinLink'] = self::url('/product/pro_' . $single['product_id'] . '_' . $single['goods_id'] . '/' . $cnAlphaBet . '.html', null, 'item'); | ||
809 | + } else { | ||
810 | + $oneGoods['subjoinLink'] = self::url('/product/show_' . $single['product_id'] . '_' . $single['product_skn'] . '/' . Helpers::makeToken($single['product_skn']) . '.html', null, 'item'); | ||
811 | + } | ||
812 | + | ||
755 | // 赠品 | 813 | // 赠品 |
756 | if ($isGift) { | 814 | if ($isGift) { |
757 | $oneGoods['isGift'] = true; | 815 | $oneGoods['isGift'] = true; |
@@ -948,4 +1006,18 @@ class Helpers | @@ -948,4 +1006,18 @@ class Helpers | ||
948 | } | 1006 | } |
949 | return $area.'-'.$mobile; | 1007 | return $area.'-'.$mobile; |
950 | } | 1008 | } |
1009 | + | ||
1010 | + /** | ||
1011 | + * 判断是否是新用户 (未下单) | ||
1012 | + * | ||
1013 | + * @return bool (true:是, false:否) | ||
1014 | + */ | ||
1015 | + public static function isNewUser() | ||
1016 | + { | ||
1017 | + if (isset($_COOKIE['_isOldUser']) && $_COOKIE['_isOldUser'] == '4') { | ||
1018 | + return false; | ||
1019 | + } | ||
1020 | + return true; | ||
1021 | + } | ||
1022 | + | ||
951 | } | 1023 | } |
-
Please register or login to post a comment