Authored by Rock Zhang

修复购物车结算页选择优惠券中优惠券是否可用的判定逻辑(通过php去过滤掉不可用的优惠券)

但那种免邮券还是不能用

Code Review By Rock Zhang
... ... @@ -95,12 +95,13 @@ function orderCompute() {
}
if (res.discount_amount) {
res.discount_amount = (+res.discount_amount).toFixed(2);
}
}*/
if (res.last_order_amount) {
res.last_order_amount = (+res.last_order_amount).toFixed(2);
}*/
}
priceHtml = priceTmpl({
cartPayData: res.promotion_formula_list
cartPayData: res.promotion_formula_list,
price: res.last_order_amount
});
$price.html(priceHtml);
... ...
... ... @@ -104,6 +104,9 @@
  {{promotion_amount}}
</li>
{{/cartPayData}}
<li class="cost">
应付金额: <em>¥{{price}}</em>
</li>
</ul>
</section>
... ... @@ -131,6 +134,9 @@
&nbsp;&nbsp;\{{promotion_amount}}
</li>
\{{/cartPayData}}
<li class="cost">
应付金额: <em>¥\{{price}}</em>
</li>
</ul>
</script>
{{> layout/footer}}
... ...
... ... @@ -451,6 +451,8 @@ class CartModel
// 订单数据
if (isset($payReturn['shopping_cart_data']) && !empty($payReturn['shopping_cart_data'])) {
$result['cartPayData'] = isset($orderCompute['promotion_formula_list']) ? $orderCompute['promotion_formula_list'] : $payReturn['shopping_cart_data']['promotion_formula_list'];
$price = isset($orderCompute['last_order_amount']) ? $orderCompute['last_order_amount'] : $payReturn['shopping_cart_data']['last_order_amount'];
$result['price'] = Helpers::transPrice($price);
/*$sumPrice = isset($orderCompute['order_amount']) ? $orderCompute['order_amount'] : $payReturn['shopping_cart_data']['order_amount'];
... ... @@ -569,17 +571,21 @@ class CartModel
$coupons = CartData::getCouponList($uid);
do {
if ($onlyTotal) {
$result['count'] = count($coupons['data']['couponList']);
break;
}
if (isset($coupons['data']['couponList'])) {
foreach ($coupons['data']['couponList'] as &$val) {
$val['notAvailable'] = $val['isValidity'] === 'N';
foreach ($coupons['data']['couponList'] as $val) {
$notAvailableRes = self::searchCoupon($uid, $val['couponCode']);
// 处理可用的优惠券
if ($val['isValidity'] === 'N' || (isset($notAvailableRes['code']) && $notAvailableRes['code'] !== 200)) {
// $val['notAvailable'] = true;
continue;
}
$result[] = $val;
}
}
$result = $coupons['data']['couponList'];
if ($onlyTotal) {
$count = count($result);
$result = array('count' => $count);
}
}while(0);
... ...