修复结算页中价格为0时不显示为0.00的bug
Code Review By Rock Zhang
Showing
2 changed files
with
4 additions
and
3 deletions
@@ -186,11 +186,12 @@ class Helpers | @@ -186,11 +186,12 @@ class Helpers | ||
186 | * 转换价格 | 186 | * 转换价格 |
187 | * | 187 | * |
188 | * @param float|string $price 价格 | 188 | * @param float|string $price 价格 |
189 | + * @param boolean $isSepcialZero 是否需要特殊的0,默认否 | ||
189 | * @return float|string 转换之后的价格 | 190 | * @return float|string 转换之后的价格 |
190 | */ | 191 | */ |
191 | - public static function transPrice($price) | 192 | + public static function transPrice($price, $isSepcialZero = false) |
192 | { | 193 | { |
193 | - return !empty($price) ? number_format($price, 2, '.', '') : 0; | 194 | + return (!empty($price) || $isSepcialZero) ? number_format($price, 2, '.', '') : 0; |
194 | } | 195 | } |
195 | 196 | ||
196 | /** | 197 | /** |
@@ -518,7 +518,7 @@ class CartModel | @@ -518,7 +518,7 @@ class CartModel | ||
518 | if (isset($payReturn['shopping_cart_data']) && !empty($payReturn['shopping_cart_data'])) { | 518 | if (isset($payReturn['shopping_cart_data']) && !empty($payReturn['shopping_cart_data'])) { |
519 | $result['cartPayData'] = isset($orderCompute['promotion_formula_list']) ? $orderCompute['promotion_formula_list'] : $payReturn['shopping_cart_data']['promotion_formula_list']; | 519 | $result['cartPayData'] = isset($orderCompute['promotion_formula_list']) ? $orderCompute['promotion_formula_list'] : $payReturn['shopping_cart_data']['promotion_formula_list']; |
520 | $price = isset($orderCompute['last_order_amount']) ? $orderCompute['last_order_amount'] : $payReturn['shopping_cart_data']['last_order_amount']; | 520 | $price = isset($orderCompute['last_order_amount']) ? $orderCompute['last_order_amount'] : $payReturn['shopping_cart_data']['last_order_amount']; |
521 | - $result['price'] = Helpers::transPrice($price); | 521 | + $result['price'] = Helpers::transPrice($price, true); |
522 | // 订单商品数 | 522 | // 订单商品数 |
523 | $result['num'] = $payReturn['shopping_cart_data']['selected_goods_count']; | 523 | $result['num'] = $payReturn['shopping_cart_data']['selected_goods_count']; |
524 | // 商品金额 | 524 | // 商品金额 |
-
Please register or login to post a comment