Authored by 周少峰

cart students

... ... @@ -711,7 +711,8 @@ class Helpers
$oneGoods['productSize'] = $value['size_name'];
$oneGoods['productPrice'] = self::transPrice($value['last_vip_price']); //self::transPrice($value['real_price']);
$oneGoods['productNum'] = $value['buy_number'];
$oneGoods['isVipPrice'] = $value['sales_price'] !== $value['last_vip_price'];
$oneGoods['isVipPrice'] = $value['sales_price'] !== $value['last_vip_price'] && $value['discount_tag'] === 'V';
$oneGoods['isStuPrice'] = $value['sales_price'] !== $value['last_vip_price'] && $value['discount_tag'] === 'S';
$oneGoods['yohoIcon'] = isset($value['get_yoho_coin']) ? $value['get_yoho_coin'] : 0;
$oneGoods['productSubtotal'] = self::transPrice( floatval($value['last_vip_price']) * intval($value['buy_number']) );
$oneGoods['promotionId'] = empty($value['promotion_id']) ? '0' : $value['promotion_id'];
... ...
... ... @@ -162,6 +162,10 @@
{{#isVipPrice}}
<span class="vipPrice">(VIP)</span>
{{/isVipPrice}}
{{#isStuPrice}}
<span class="vipPrice">(学生价)</span>
{{/isStuPrice}}
</td>
<td>{{yohoIcon}}个</td>
<td class="adjust-cart-num">
... ...
... ... @@ -55,6 +55,7 @@ class CartModel
// 调用接口,获取购物车数据
$cartData = CartData::cartData($uid, $shoppingKey);
// print_r($cartData); exit;
// 接口异常时,购物车置为空
if (empty($cartData['data'])) {
$result['isEmpty'] = true;
... ... @@ -1393,17 +1394,23 @@ class CartModel
private static function genProductAmount($promotionList, $default)
{
$result = $default;
// VIP价格
$vipAmount = null;
// 学生价
$stuAmount = null;
foreach ($promotionList as $value) {
if ($value['promotion'] === 'VIP优惠') {
$vipAmount = strtr($value['promotion_amount'], array('¥' => '', '-' => '', '+' => ''));
break;
} elseif ($value['promotion'] === '学生优惠') {
$stuAmount = strtr($value['promotion_amount'], array('¥' => '', '-' => '', '+' => ''));
}
}
if (null !== $vipAmount) {
$result = floatval($default) - floatval($vipAmount);
}
if (null !== $stuAmount) {
$result = floatval($default) - floatval($stuAmount);
}
$result = Helpers::transPrice($result);
return $result;
... ...