修复库存不足标记显示的bug;失效商品不显示库存不足
Code Review By Rock Zhang
Showing
3 changed files
with
15 additions
and
10 deletions
@@ -23,15 +23,15 @@ class Yohobuy | @@ -23,15 +23,15 @@ class Yohobuy | ||
23 | // const SERVICE_URL = 'http://service.api.yohobuy.com/'; | 23 | // const SERVICE_URL = 'http://service.api.yohobuy.com/'; |
24 | // const YOHOBUY_URL = 'http://www.yohobuy.com/'; | 24 | // const YOHOBUY_URL = 'http://www.yohobuy.com/'; |
25 | 25 | ||
26 | - const API_URL = 'http://apih5.yoho.cn/'; | ||
27 | - const API_URL2 = 'http://apih5.yoho.cn/'; | ||
28 | - const SERVICE_URL = 'http://serviceh5.yoho.cn/'; | ||
29 | - const YOHOBUY_URL = 'http://www.yohobuy.com/'; | 26 | +// const API_URL = 'http://apih5.yoho.cn/'; |
27 | +// const API_URL2 = 'http://apih5.yoho.cn/'; | ||
28 | +// const SERVICE_URL = 'http://serviceh5.yoho.cn/'; | ||
29 | +// const YOHOBUY_URL = 'http://www.yohobuy.com/'; | ||
30 | 30 | ||
31 | // /* 测试环境 */ | 31 | // /* 测试环境 */ |
32 | -// const API_URL = 'http://testapi.yoho.cn:28078/'; | ||
33 | -// const SERVICE_URL = 'http://testservice.yoho.cn:28077/'; | ||
34 | -// const YOHOBUY_URL = 'http://www.yohobuy.com/'; | 32 | + const API_URL = 'http://testapi.yoho.cn:28078/'; |
33 | + const SERVICE_URL = 'http://testservice.yoho.cn:28077/'; | ||
34 | + const YOHOBUY_URL = 'http://www.yohobuy.com/'; | ||
35 | 35 | ||
36 | /** | 36 | /** |
37 | * 私钥列表 | 37 | * 私钥列表 |
@@ -560,9 +560,10 @@ class Helpers | @@ -560,9 +560,10 @@ class Helpers | ||
560 | * 格式化购物车商品 | 560 | * 格式化购物车商品 |
561 | * | 561 | * |
562 | * @param array $cartGoods 购物车商品列表 | 562 | * @param array $cartGoods 购物车商品列表 |
563 | + * @param boolean $isValid 是否是可用商品(非失效商品),默认是 | ||
563 | * @return array 处理之后的购物车商品数据 | 564 | * @return array 处理之后的购物车商品数据 |
564 | */ | 565 | */ |
565 | - public static function formatCartGoods($cartGoods) | 566 | + public static function formatCartGoods($cartGoods, $isValid = true) |
566 | { | 567 | { |
567 | $arr = array(); | 568 | $arr = array(); |
568 | 569 | ||
@@ -577,7 +578,11 @@ class Helpers | @@ -577,7 +578,11 @@ class Helpers | ||
577 | $oneGoods['isSelected'] = $value['selected'] === 'Y'; | 578 | $oneGoods['isSelected'] = $value['selected'] === 'Y'; |
578 | $oneGoods['price'] = self::transPrice($value['sales_price']); | 579 | $oneGoods['price'] = self::transPrice($value['sales_price']); |
579 | $oneGoods['count'] = $value['buy_number']; | 580 | $oneGoods['count'] = $value['buy_number']; |
580 | - $oneGoods['lowStocks'] = ($value['buy_number'] < $value['storage_number']); | 581 | + |
582 | + if ($isValid) { | ||
583 | + $oneGoods['lowStocks'] = ($value['buy_number'] > $value['storage_number']); | ||
584 | + } | ||
585 | + | ||
581 | //gift=>是否赠品,advanceBuy=>是否加价购,soldOut=>失效商品; | 586 | //gift=>是否赠品,advanceBuy=>是否加价购,soldOut=>失效商品; |
582 | if (!isset($value['goods_type'])) { | 587 | if (!isset($value['goods_type'])) { |
583 | $oneGoods['isSoldOut'] = true; | 588 | $oneGoods['isSoldOut'] = true; |
@@ -739,7 +739,7 @@ class CartModel | @@ -739,7 +739,7 @@ class CartModel | ||
739 | } | 739 | } |
740 | 740 | ||
741 | // 失效商品列表 | 741 | // 失效商品列表 |
742 | - $notValidGoods = Helpers::formatCartGoods($data['sold_out_goods_list']); | 742 | + $notValidGoods = Helpers::formatCartGoods($data['sold_out_goods_list'], false); |
743 | if (!empty($notValidGoods)) { | 743 | if (!empty($notValidGoods)) { |
744 | $result['notValidGoods'] = $notValidGoods; | 744 | $result['notValidGoods'] = $notValidGoods; |
745 | } | 745 | } |
-
Please register or login to post a comment