Authored by Rock Zhang

Merge branch 'beta' into develop

... ... @@ -189,8 +189,8 @@ class Helpers
* @return float|string 转换之后的价格
*/
public static function transPrice($price)
{
return !empty($price) ? number_format($price, 2, '.', '') : 0;
{
return !empty($price) ? number_format($price, 2, '.', '') : 0;
}
/**
... ... @@ -218,9 +218,23 @@ class Helpers
$productData['market_price'] = false;
}
// 如果$productData['default_images']为空,就取$productData['goods_list']中第一个,为空就不处理
if (empty($productData['default_images'])) {
$productData['default_images'] = $productData['goods_list'][0]['images_url'];
$flag = false; // 判别默认的商品是否将默认的图片URL赋值到skn
$firstGood = array(); // 第一个skc产品
// 如果设置了默认图片,就取默认的图片
foreach ($productData['goods_list'] as $k => $oneGoods) {
if ($k === 0) {
$firstGood = $oneGoods;
}
// 此skc是默认的,则将图片赋值给skn
if ($oneGoods['is_default'] === 'Y') {
$productData['default_images'] = self::procProductImg($oneGoods);
$flag = true;
}
}
// 如果还未赋值,则取第一个skc产品的默认图片
if (!$flag && !empty($firstGood)) {
$productDatap['default_images'] = self::procProductImg($firstGood);
}
$result = array();
... ... @@ -272,6 +286,25 @@ class Helpers
}
/**
* 根据性别来决定 默认图片获取字段 如果是 2、3 则优先从cover2 --》 cover1 -- 》 images_url
* 否则优先从cover1 --》 cover2 -- 》 images_url
* @param array $images
* @return string 商品图片
*/
private static function procProductImg($images)
{
$imgUrl = isset($images['images_url']) ? $images['images_url'] : '';
$cover1 = isset($images['cover_1']) ? $images['cover_1'] : '';
$cover2 = isset($images['cover_2']) ? $images['cover_2'] : '';
$gender = self::getGenderByCookie();
if ($gender === '2,3') {
return !empty($cover2) ? $cover2 : !empty($cover1) ? $cover1 : $imgUrl;
} else {
return !empty($cover1) ? $cover1 : !empty($cover2) ? $cover2 : $imgUrl;
}
}
/**
* 格式化资讯文章
*
* @param array $articleData 需要格式化的资讯数据
... ...
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
... ... @@ -50,22 +50,28 @@
商品总金额
<span>{{sumPrice}}</span>
</li>
{{#if salePrice}}
<li>
活动金额
<span>{{salePrice}}</span>
</li>
{{/if}}
<li>
运费
<span>{{freight}}</span>
</li>
{{#if coupon}}
<li>
优惠券
<span>{{coupon}}</span>
</li>
{{/if}}
{{#if yohoCoin}}
<li>
YOHO币
<span>{{yohoCoin}}</span>
</li>
{{/if}}
<li>
实付金额
<span>{{price}}</span>
... ...
... ... @@ -145,10 +145,10 @@ class OrderModel
$result['orderTime'] = date('Y-m-d H:i:s', $orderDetail['data']['create_time']);
$result['goods'] = Helpers::formatOrderGoods($orderDetail['data']['order_goods'], $count, true);
$result['sumPrice'] = $orderDetail['data']['goods_total_amount']; // 商品总金额
$result['salePrice'] = $orderDetail['data']['promotion_amount']; // 活动金额
$result['salePrice'] = self::filterOrderPrice($orderDetail['data']['promotion_amount']); // 活动金额
$result['freight'] = $orderDetail['data']['shipping_cost']; // 运费
$result['coupon'] = $orderDetail['data']['coupons_amount']; // 优惠券
$result['yohoCoin'] = $orderDetail['data']['yoho_coin_num']; // YOHO币
$result['coupon'] = self::filterOrderPrice($orderDetail['data']['coupons_amount']); // 优惠券
$result['yohoCoin'] = self::filterOrderPrice($orderDetail['data']['yoho_coin_num']); // YOHO币
$result['price'] = $orderDetail['data']['amount']; // 实付金额
$result['goodsAmount'] = $orderDetail['data']['payment_amount']; // 商品总金额没有人民币符号
$result['orderCount'] = $count; // 订单总件数
... ... @@ -267,4 +267,15 @@ class OrderModel
return $result;
}
/**
* 过滤掉为0的价格数据
*
* @param $price
* @return string 过滤之后的价格
*/
private static function filterOrderPrice($price)
{
return empty(intval(preg_replace('/[+|\-|¥]/s', '', $price))) ? '' : $price;
}
}
... ...