过滤掉订单详情页中yoho币,活动价,优惠券为0的情况,默认不显示
Code Review By Rock Zhang
Showing
2 changed files
with
20 additions
and
3 deletions
@@ -50,22 +50,28 @@ | @@ -50,22 +50,28 @@ | ||
50 | 商品总金额 | 50 | 商品总金额 |
51 | <span>{{sumPrice}}</span> | 51 | <span>{{sumPrice}}</span> |
52 | </li> | 52 | </li> |
53 | + {{#if salePrice}} | ||
53 | <li> | 54 | <li> |
54 | 活动金额 | 55 | 活动金额 |
55 | <span>{{salePrice}}</span> | 56 | <span>{{salePrice}}</span> |
56 | </li> | 57 | </li> |
58 | + {{/if}} | ||
57 | <li> | 59 | <li> |
58 | 运费 | 60 | 运费 |
59 | <span>{{freight}}</span> | 61 | <span>{{freight}}</span> |
60 | </li> | 62 | </li> |
63 | + {{#if coupon}} | ||
61 | <li> | 64 | <li> |
62 | 优惠券 | 65 | 优惠券 |
63 | <span>{{coupon}}</span> | 66 | <span>{{coupon}}</span> |
64 | </li> | 67 | </li> |
68 | + {{/if}} | ||
69 | + {{#if yohoCoin}} | ||
65 | <li> | 70 | <li> |
66 | YOHO币 | 71 | YOHO币 |
67 | <span>{{yohoCoin}}</span> | 72 | <span>{{yohoCoin}}</span> |
68 | </li> | 73 | </li> |
74 | + {{/if}} | ||
69 | <li> | 75 | <li> |
70 | 实付金额 | 76 | 实付金额 |
71 | <span>{{price}}</span> | 77 | <span>{{price}}</span> |
@@ -145,10 +145,10 @@ class OrderModel | @@ -145,10 +145,10 @@ class OrderModel | ||
145 | $result['orderTime'] = date('Y-m-d H:i:s', $orderDetail['data']['create_time']); | 145 | $result['orderTime'] = date('Y-m-d H:i:s', $orderDetail['data']['create_time']); |
146 | $result['goods'] = Helpers::formatOrderGoods($orderDetail['data']['order_goods'], $count, true); | 146 | $result['goods'] = Helpers::formatOrderGoods($orderDetail['data']['order_goods'], $count, true); |
147 | $result['sumPrice'] = $orderDetail['data']['goods_total_amount']; // 商品总金额 | 147 | $result['sumPrice'] = $orderDetail['data']['goods_total_amount']; // 商品总金额 |
148 | - $result['salePrice'] = $orderDetail['data']['promotion_amount']; // 活动金额 | 148 | + $result['salePrice'] = self::filterOrderPrice($orderDetail['data']['promotion_amount']); // 活动金额 |
149 | $result['freight'] = $orderDetail['data']['shipping_cost']; // 运费 | 149 | $result['freight'] = $orderDetail['data']['shipping_cost']; // 运费 |
150 | - $result['coupon'] = $orderDetail['data']['coupons_amount']; // 优惠券 | ||
151 | - $result['yohoCoin'] = $orderDetail['data']['yoho_coin_num']; // YOHO币 | 150 | + $result['coupon'] = self::filterOrderPrice($orderDetail['data']['coupons_amount']); // 优惠券 |
151 | + $result['yohoCoin'] = self::filterOrderPrice($orderDetail['data']['yoho_coin_num']); // YOHO币 | ||
152 | $result['price'] = $orderDetail['data']['amount']; // 实付金额 | 152 | $result['price'] = $orderDetail['data']['amount']; // 实付金额 |
153 | $result['goodsAmount'] = $orderDetail['data']['payment_amount']; // 商品总金额没有人民币符号 | 153 | $result['goodsAmount'] = $orderDetail['data']['payment_amount']; // 商品总金额没有人民币符号 |
154 | $result['orderCount'] = $count; // 订单总件数 | 154 | $result['orderCount'] = $count; // 订单总件数 |
@@ -267,4 +267,15 @@ class OrderModel | @@ -267,4 +267,15 @@ class OrderModel | ||
267 | return $result; | 267 | return $result; |
268 | } | 268 | } |
269 | 269 | ||
270 | + /** | ||
271 | + * 过滤掉为0的价格数据 | ||
272 | + * | ||
273 | + * @param $price | ||
274 | + * @return string 过滤之后的价格 | ||
275 | + */ | ||
276 | + private static function filterOrderPrice($price) | ||
277 | + { | ||
278 | + return empty(intval(preg_replace('/[+|\-|¥]/s', '', $price))) ? '' : $price; | ||
279 | + } | ||
280 | + | ||
270 | } | 281 | } |
-
Please register or login to post a comment