Authored by 梁志锋

Merge branch 'feature/cart' of http://git.dev.yoho.cn/web/yohobuy into feature/cart

framework @ e9d066dd
Subproject commit 75bbc3b075de19f239532f60c5995d06c5f814e2
Subproject commit e9d066dd88a8e7e37103021c427a205a5cfcdcec
... ...
... ... @@ -190,7 +190,7 @@ class Helpers
*/
public static function transPrice($price)
{
return (!empty($price) && !is_float($price)) ? $price . '.00' : $price;
return (!empty($price) && !is_float($price)) ? $price . '.00' : number_format($price, 2, '.', '');
}
/**
... ...
... ... @@ -80,6 +80,7 @@ function orderCompute() {
sumPrice: res.order_amount,
salePrice: res.discount_amount,
freight: res.promotion_formula_list[1].promotion_amount,
couponPrice: res.coupon_amount,
yohoCoin: res.use_yoho_coin,
price: res.last_order_amount
});
... ...
... ... @@ -3,6 +3,7 @@
* @author: bikai<kai.bi@yoho.cn>
* @date: 2015/12/14
*/
var $ = require('jquery');
var info = window.cookie('order-info');
// info 必须是 JSON 字符串
... ... @@ -10,10 +11,10 @@ try {
info = JSON.parse(info);
} catch (e) {
info = {
deliveryId: null,
deliveryTimeId: null,
paymentTypeId: null,
yohoCoin: null,
deliveryId: 1,
deliveryTimeId: 1,
paymentTypeId: 1,
yohoCoin: $('.coin').data('yoho-coin') || 0,
addressId: null,
couponCode: null,
couponValue: null,
... ...
... ... @@ -41,7 +41,7 @@
<section class="block">
<ul class="sale-invoice">
{{#if coupon}}
{{# coupon}}
<li class="coupon">
<a href="/shoppingCart/selectCoupon">
<!-- <a href="{{url}}"> -->
... ... @@ -65,7 +65,7 @@
{{/if}}
</a>
</li>
{{/if}}
{{/coupon}}
{{# yohoCoin}}
<li class="coin" data-yoho-coin="{{.}}">
... ... @@ -114,11 +114,17 @@
</li>
<li>
<span>运费</span>
+ ¥{{freight}}
+ {{freight}}
</li>
{{#couponPrice}}
<li>
<span>优惠券</span>
- ¥{{.}}
</li>
{{/couponPrice}}
<li>
<span>YOHO币</span>
- ¥{{yohoCoin}}
- {{yohoCoin}}
</li>
<li class="cost">
应付金额: <em>¥{{price}}</em>
... ... @@ -156,6 +162,12 @@
<span>运费</span>
+ \{{freight}}
</li>
\{{#couponPrice}}
<li>
<span>优惠券</span>
- ¥\{{.}}
</li>
\{{/couponPrice}}
<li>
<span>YOHO币</span>
- ¥\{{yohoCoin}}
... ...
... ... @@ -23,7 +23,7 @@ class CartModel
* @param int $productSku 商品SKU
* @param int $buyNumber 购买数量
* @param int $goodsType 商品类型,0表示普通商品,1表示加价购商品
* @param int int $isEdit 是否是编辑商品SKU,0表示不是编辑
* @param int $isEdit 是否是编辑商品SKU,0表示不是编辑
* @param null|int $promotionId 促销id,默认null(加价购有关)
* @param null|int $uid 用户UID,可以不传
* @return array 加入购物车接口返回的数据
... ... @@ -406,7 +406,7 @@ class CartModel
$oneGoods['name'] = $single['product_name'];
$oneGoods['color'] = $single['color_name'];
$oneGoods['size'] = $single['size_name'];
$oneGoods['price'] = Helpers::transPrice($single['real_price']); // last_price有些带.00,有些不带,real_price都不带.00
$oneGoods['price'] = Helpers::transPrice($single['sales_price']);
$oneGoods['count'] = $single['buy_number'];
$result['goods'][] = $oneGoods;
... ... @@ -428,18 +428,20 @@ class CartModel
}
// 有货币
$result['yohoCoin'] = isset($orderCompute['use_yoho_coin']) ? isset($orderCompute['use_yoho_coin']) : $payReturn['yoho_coin'];
$result['yohoCoin'] = (isset($orderCompute['use_yoho_coin']) && !empty($orderCompute['use_yoho_coin'])) ? $orderCompute['use_yoho_coin'] : $payReturn['yoho_coin'];
// 订单数据
if (isset($payReturn['shopping_cart_data']) && !empty($payReturn['shopping_cart_data'])) {
$sumPrice = isset($orderCompute['order_amount']) ? $orderCompute['order_amount'] : $payReturn['shopping_cart_data']['order_amount'];
$salePrice = isset($orderCompute['discount_amount']) ? $orderCompute['discount_amount'] : $payReturn['shopping_cart_data']['discount_amount'];
$freight = isset($orderCompute['promotion_formula_list']['promotion_amount']) ? $orderCompute['promotion_formula_list'][1]['promotion_amount'] : $payReturn['shopping_cart_data']['promotion_formula_list'][1]['promotion_amount'];
$couponPrice = isset($orderCompute['coupon_amount']) ? $orderCompute['coupon_amount'] : false;
$salePrice = isset($orderCompute['discount_amount']) ? $orderCompute['discount_amount'] : $payReturn['shopping_cart_data']['promotion_formula_list'][3]['promotion_amount'];
$price = isset($orderCompute['last_order_amount']) ? $orderCompute['last_order_amount'] : $payReturn['shopping_cart_data']['last_order_amount'];
$freight = isset($orderCompute['promotion_formula_list']['promotion_amount']) ? $orderCompute['promotion_formula_list']['promotion_amount'] : $payReturn['shopping_cart_data']['promotion_formula_list'][1]['promotion_amount'];
$result['sumPrice'] = Helpers::transPrice($sumPrice);
$result['salePrice'] = Helpers::transPrice($salePrice);
$result['price'] = Helpers::transPrice($price);
$result['freight'] = strtr($freight, array('¥'=>'','¥'=>'')) . '.00';
$result['freight'] = $freight;
$result['couponPrice'] = $couponPrice;
}
// 发票有关数据
... ... @@ -468,7 +470,7 @@ class CartModel
// 优惠券数据
$coupons = array();
!empty($orderCompute['coupon_amount']) && $coupons['value'] = $orderInfo['couponValue'];
$coupons += self::getCouponList($uid, 0, 1, true);
$coupons += self::getCouponList($uid, true);
$result['coupon'] = $coupons;
}
... ... @@ -535,7 +537,7 @@ class CartModel
if (isset($coupons['data'])) {
if ($onlyTotal) {
$result['count'] = $coupons['data']['total'];
$result['count'] = count($coupons['data']['couponList']);
} else {
$couponArr = array();
isset($coupons['data']['couponList']) && $couponArr = $coupons['data']['couponList'];
... ... @@ -605,7 +607,6 @@ class CartModel
{
$result = array();
$oneGoods = array();
// 购买的可用商品列表
$validGoods = Helpers::formatCartGoods($data['goods_list']);
!empty($validGoods) && $result['goods'] = $validGoods;
... ...