...
|
...
|
@@ -44,6 +44,7 @@ class DetailModel |
|
|
if (empty($baseInfo['productName'])) {
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
$result['goodsName'] = $baseInfo['productName'];
|
|
|
|
|
|
// 商品促销短语
|
...
|
...
|
@@ -290,16 +291,10 @@ class DetailModel |
|
|
$soldOut = ($baseInfo['storage'] == 0) || ($baseInfo['status'] == 0 || $totalStorageNum === 0);
|
|
|
$notForSale = $baseInfo['attribute'] == 2;
|
|
|
|
|
|
// 是否为限购商品
|
|
|
$isLimited = ($baseInfo['isLimitBuy'] === 'Y');
|
|
|
|
|
|
|
|
|
|
|
|
// 显示加入购物车链接
|
|
|
if (!$soldOut && !$notForSale && !$isLimited) {
|
|
|
if (!$soldOut && !$notForSale) {
|
|
|
ksort($colorGroup, SORT_NUMERIC);
|
|
|
|
|
|
$result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html');
|
|
|
|
|
|
$result['cartInfo']['productId'] = $productId;
|
|
|
$result['cartInfo']['thumbs'] = $thumbImageList;
|
|
|
$result['cartInfo']['name'] = isset($result['goodsName']) ? $result['goodsName'] : '';
|
...
|
...
|
@@ -308,6 +303,26 @@ class DetailModel |
|
|
$result['cartInfo']['totalNum'] = $totalStorageNum;
|
|
|
$result['cartInfo']['colors'] = $colorGroup;
|
|
|
$result['cartInfo']['sizes'] = $sizeGroup;
|
|
|
|
|
|
// 限购商品
|
|
|
if ($baseInfo['isLimitBuy'] === 'Y') {
|
|
|
// 是否开售
|
|
|
$isBeginSale = (isset($baseInfo['saleStatus']) && $baseInfo['saleStatus'] == 1);
|
|
|
// 限购商品有关的展示状态
|
|
|
$showStatus = 1;
|
|
|
if (isset($baseInfo['showStatus'])) {
|
|
|
$showStatus = intval($baseInfo['showStatus']);
|
|
|
}
|
|
|
|
|
|
// 处理限购商品有关的按钮状态
|
|
|
self::procShowStatus($result, $showStatus, $isBeginSale);
|
|
|
|
|
|
$result['cartInfo']['limitProductCode'] = $baseInfo['limitProductCode'];
|
|
|
$result['cartInfo']['limitCodeUrl'] = self::getLimitCodeUrl($baseInfo['erpProductId']);
|
|
|
$result['cartInfo']['limitProductPay'] = Helpers::url('/cart/index/orderEnsure');
|
|
|
} else {
|
|
|
$result['cartInfo']['addToCartUrl'] = Helpers::url('/product/buy_' . $productId . '_' . $goodsId . '.html');
|
|
|
}
|
|
|
}
|
|
|
// 非卖品
|
|
|
elseif ($notForSale) {
|
...
|
...
|
@@ -317,22 +332,6 @@ class DetailModel |
|
|
elseif ($soldOut) {
|
|
|
$result['cartInfo']['soldOut'] = true;
|
|
|
}
|
|
|
// 限购商品
|
|
|
elseif ($isLimited) {
|
|
|
// 是否开售
|
|
|
$isBeginSale = (isset($baseInfo['saleStatus']) && $baseInfo['saleStatus'] == 1);
|
|
|
// 限购商品有关的展示状态
|
|
|
$showStatus = 1;
|
|
|
if (isset($baseInfo['showStatus'])) {
|
|
|
$showStatus = intval($baseInfo['showStatus']);
|
|
|
}
|
|
|
|
|
|
// 处理限购商品有关的按钮状态
|
|
|
self::procShowStatus($result, $showStatus, $isBeginSale);
|
|
|
|
|
|
$result['cartInfo']['limitProductCode'] = $baseInfo['limitProductCode'];
|
|
|
$result['cartInfo']['limitCodeUrl'] = 'yohobuy://' . Helpers::url('/product', array('skn' => $baseInfo['erpProductId']));
|
|
|
}
|
|
|
|
|
|
// 是否收藏
|
|
|
$result['isCollect'] = false;
|
...
|
...
|
@@ -717,6 +716,8 @@ class DetailModel |
|
|
* 获取为你优选的商品
|
|
|
*
|
|
|
* @param int $productSkn 商品SKN
|
|
|
* @param int $channel
|
|
|
* @param int $brandId
|
|
|
* @return array
|
|
|
*/
|
|
|
public static function getPreference($productSkn, $channel, $brandId)
|
...
|
...
|
@@ -738,6 +739,89 @@ class DetailModel |
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 获取限购商品详情
|
|
|
*
|
|
|
* @param int $uid 用户UID
|
|
|
* @param string $productCode
|
|
|
* @return array
|
|
|
*/
|
|
|
public static function getLimitProductData($uid, $productCode)
|
|
|
{
|
|
|
$result = array();
|
|
|
|
|
|
do {
|
|
|
$productData = DetailData::limitProductData($uid, $productCode);
|
|
|
|
|
|
if (empty($productData) || empty($productData['data'])) {
|
|
|
break;
|
|
|
}
|
|
|
$product = $productData['data'];
|
|
|
|
|
|
$result['price'] = $product['price'];
|
|
|
$result['name'] = $product['productName'];
|
|
|
// 发售日期
|
|
|
$result['releaseDate'] = $product['saleTime'] . '发售';
|
|
|
// baner
|
|
|
$result['banner'] = $product['defaultUrl'];
|
|
|
$result['description'] = $product['description'];
|
|
|
|
|
|
// 附件
|
|
|
if (isset($product['attachment'])) {
|
|
|
foreach ($product['attachment'] as $item) {
|
|
|
$result['attaches'][] = self::procLimitProductAttach($item);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
} while (false);
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 处理限购商品附件数据
|
|
|
*
|
|
|
* @param array $attachment 附件数据
|
|
|
* @return array
|
|
|
*/
|
|
|
private static function procLimitProductAttach($attachment)
|
|
|
{
|
|
|
$result = array();
|
|
|
|
|
|
switch(intval($attachment['attachType'])) {
|
|
|
case 1: // 大图文字
|
|
|
$result['img'] = array(
|
|
|
'attachUrl' => Helpers::getImageUrl($attachment['attachUrl'], 290, 200),
|
|
|
'attachName' => $attachment['attachName'],
|
|
|
'intro' => $attachment['intro'],
|
|
|
'orderBy' => $attachment['orderBy']
|
|
|
);
|
|
|
break;
|
|
|
case 2: // 视频
|
|
|
$result['video'] = array(
|
|
|
'attachUrl' => $attachment['attachUrl'],
|
|
|
'orderBy' => $attachment['orderBy'],
|
|
|
'img' => Helpers::getImageUrl($attachment['intro'], 290, 200)
|
|
|
);
|
|
|
break;
|
|
|
case 3: // 文本类型
|
|
|
$result['text'] = array(
|
|
|
'intro' => $attachment['intro'],
|
|
|
'orderBy' => $attachment['orderBy']
|
|
|
);
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
if(count($result) > 1) {
|
|
|
Helpers::sortArrByField($result, 'orderBy');
|
|
|
}
|
|
|
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 处理限购商品的有关按钮状态(或取现购买以及底部商品购买按钮)
|
|
|
*
|
...
|
...
|
@@ -783,4 +867,22 @@ class DetailModel |
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 根据设备类型获得限购商品跳转app的url
|
|
|
*
|
|
|
* @param string $skn 商品skn
|
|
|
* @return string 限购商品跳转url
|
|
|
*/
|
|
|
private static function getLimitCodeUrl($skn)
|
|
|
{
|
|
|
$url = 'yohoapp://yoho.app/openwith?product_skn=' . $skn;
|
|
|
|
|
|
// 苹果设备或者苹果IPAD
|
|
|
if (strstr($_SERVER['HTTP_USER_AGENT'], 'iPhone') || strstr($_SERVER['HTTP_USER_AGENT'], 'iPad')) {
|
|
|
$url = 'yohobuy://' . Helpers::url('/product', array('skn' => $skn));
|
|
|
}
|
|
|
|
|
|
return $url;
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|