Authored by 郭成尧

商品详情页促销活动信息接口拆分

... ... @@ -326,4 +326,19 @@ class ItemData
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 商品促销信息
* @param $skn 商品 skn
* @return mixed
*/
public static function promotion($skn)
{
$param = Yohobuy::param();
$param['method'] = 'app.product.promotion';
$param['product_skn'] = $skn;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
\ No newline at end of file
... ...
<?php
namespace Product;
use LibModels\Web\Product\ItemData;
use WebPlugin\Helpers;
use WebPlugin\Images;
use LibModels\Web\Product\SearchData;
use LibModels\Web\Product\FavoriteData;
use Api\Yohobuy;
use WebPlugin\Cache;
use Configs\WebCacheConfig;
use Configs\ChannelConfig;
use Configs\WebCacheConfig;
use LibModels\Web\Product\BrandData;
use Product\BrandsModel;
use LibModels\Web\Product\FavoriteData;
use LibModels\Web\Product\ItemData;
use LibModels\Web\Product\SearchData;
use WebPlugin\Cache;
use WebPlugin\Helpers;
use WebPlugin\Images;
class ItemModel
{
/**
... ... @@ -35,7 +36,7 @@ class ItemModel
$statGoodsInfo = array();
$banner = array();
$baseInfo = ItemData::baseInfo($productId, $uid, $productSkn);
if(empty($baseInfo['productName']) && empty($baseInfo['erpProductId']) && empty($baseInfo['productPriceBo'])) {
if (empty($baseInfo['productName']) && empty($baseInfo['erpProductId']) && empty($baseInfo['productPriceBo'])) {
return array();
}
$baseInfo['uid'] = $uid;
... ... @@ -50,7 +51,7 @@ class ItemModel
$brandId = 0;
//设置并发请求数据
self::setMultiResourceByProductBaseInfo($baseInfo);
if(isset($baseInfo['brand']['id'])) {
if (isset($baseInfo['brand']['id'])) {
$brandId = $baseInfo['brand']['id'];
}
//收藏喜欢
... ... @@ -69,7 +70,7 @@ class ItemModel
$goodsInfo['marketPrice'] = $baseInfo['productPriceBo']['formatMarketPrice'];
$goodsInfo['hasOtherPrice'] = true;//非市场价格
$goodsInfo['salePrice'] = $baseInfo['productPriceBo']['formatSalesPrice'];
if($goodsInfo['marketPrice'] == $goodsInfo['salePrice']) {//价格相同,只显示市场价格
if ($goodsInfo['marketPrice'] == $goodsInfo['salePrice']) {//价格相同,只显示市场价格
unset($goodsInfo['salePrice']);
$goodsInfo['hasOtherPrice'] = false;
}
... ... @@ -77,15 +78,32 @@ class ItemModel
//VIP数据
$goodsInfo['vipPrice'] = self::getVipDataByProductBaseInfo($baseInfo, $vipLevel, $uid);
//促销活动banner
$goodsInfo['activity'] = self::getActivityDataByProductBaseInfo($baseInfo);
// 促销信息声明
$goodsInfo['activity'] = array();
// 促销 banner
$promotionBanner = self::getProductActivityBanner($baseInfo['id']);
if (!empty($promotionBanner)) {
$goodsInfo['activity'][] = $promotionBanner;
}
// 促销活动,另外调用接口获取
$activityOrigin = ItemData::promotion($baseInfo['productPriceBo']['productSkn']);
if ($activityOrigin['code'] === 200) {
$activityList = self::getActivityDataByProductBaseInfo($activityOrigin['data']);
if (!empty($activityList)) {
$goodsInfo['activity'] = array_merge($goodsInfo['activity'], $activityList);
}
}
if (isset($baseInfo['productPriceBo']['yohoCoinNum']) && $baseInfo['productPriceBo']['yohoCoinNum'] !== 0) {
array_push($goodsInfo['activity'],
array('type' => '返YOHO币', 'des' => '每件返 ' . $baseInfo['productPriceBo']['yohoCoinNum'] . '个 YOHO币')
);
}
// 上市期
if (isset($baseInfo['expectArrivalTime']) && !empty($baseInfo['expectArrivalTime'])) {
$goodsInfo['arrivalDate'] = $baseInfo['expectArrivalTime'] . '月';
... ... @@ -102,7 +120,7 @@ class ItemModel
$goodsInfo['brandName'] = $baseInfo['brand']['brandName'];
$goodsInfo['brandUrl'] = Helpers::url('', array(), $baseInfo['brand']['brandDomain']);
$banner = self::getBrandDataByProductBaseInfo($baseInfo);
if(isset($banner['isCollect']) && isset($favoriteData['brand'])) {
if (isset($banner['isCollect']) && isset($favoriteData['brand'])) {
$banner['isCollect'] = $favoriteData['brand'];
}
}
... ... @@ -130,10 +148,10 @@ class ItemModel
$goodsInfo['fashionTopGoods'] = array(
'getLimitedCode' => $fashTopGoods['getLimitedCode'],//限购码状态
'hasLimitedCode' => $fashTopGoods['hasLimitedCode'],//是否已经获取限购码
'limitedCodeSoldOut'=> $fashTopGoods['limitedCodeSoldOut'],//限购码是否已经抢光
'limitedCodeSoldOut' => $fashTopGoods['limitedCodeSoldOut'],//限购码是否已经抢光
'getLimitedCodeDis' => $fashTopGoods['getLimitedCodeDis'],//限购码是否失效
);
if($fashTopGoods['soldOut']) {
if ($fashTopGoods['soldOut']) {
$goodsInfo['soldOut'] = $fashTopGoods['soldOut'];
$totalStorageNum = 0;//改总数为已售磬
} else {
... ... @@ -149,37 +167,36 @@ class ItemModel
if (!$soldOut && !$notForSale && !$virtualGoods) {
$goodsInfo['addToCart'] = true;
//立即购买或者即将开售存在
if((isset($goodsInfo['buyNow']) && $goodsInfo['buyNow']) ||
(isset($goodsInfo['openSoon']) && $goodsInfo['openSoon'])) {
if ((isset($goodsInfo['buyNow']) && $goodsInfo['buyNow']) ||
(isset($goodsInfo['openSoon']) && $goodsInfo['openSoon'])
) {
unset($goodsInfo['addToCart']);
}
}// 非卖品
elseif ($notForSale) {
$goodsInfo['notForSale'] = true;
}
// 已售磬
} // 已售磬
elseif ($soldOut) {
$goodsInfo['soldOut'] = true;
unset($goodsInfo['fashionTopGoods']);
}
//虚拟商品
else if($virtualGoods) {
} //虚拟商品
else if ($virtualGoods) {
$goodsInfo['buyNow'] = true;//是否立即购买
$goodsInfo['buyNowBase'] = Helpers::url('/ticket', array(), 'shopping');
$goodsInfo['virtualGoods'] = $virtualGoods;
if(isset($goodsInfo['salePrice'])) {
if (isset($goodsInfo['salePrice'])) {
$goodsInfo['advancePrice'] = $goodsInfo['salePrice'];//先行价格
unset($goodsInfo['salePrice']);
}
}
//去掉即将售罄
if(empty($totalStorageNum) || $soldOut) {
if(isset($goodsInfo['tags']['isFew'])) {
if (empty($totalStorageNum) || $soldOut) {
if (isset($goodsInfo['tags']['isFew'])) {
unset($goodsInfo['tags']['isFew']);//去掉即将售罄
}
}
//分享相关
$goodsInfo['weixinUrl'] = Helpers::url($_SERVER['REQUEST_URI'], array(),'item');
$goodsInfo['weixinUrl'] = Helpers::url($_SERVER['REQUEST_URI'], array(), 'item');
$goodsInfo['sharedTitle'] = $goodsInfo['name'];
$goodsInfo['shareImg'] = $goodsInfo['img'];
$goodsInfo['shareDesc'] = $baseInfo['phrase'];
... ... @@ -188,10 +205,10 @@ class ItemModel
$statGoodsInfo['uid'] = $uid;
$statGoodsInfo['skn'] = $baseInfo['erpProductId'];
$statGoodsInfo['productId'] = $productId;
$statGoodsInfo['productName'] = str_replace("'", "’",$goodsInfo['name']);
$statGoodsInfo['brandName'] = empty($goodsInfo['brandName'])? '' : str_replace("'", "’", $goodsInfo['brandName']);
$statGoodsInfo['productName'] = str_replace("'", "’", $goodsInfo['name']);
$statGoodsInfo['brandName'] = empty($goodsInfo['brandName']) ? '' : str_replace("'", "’", $goodsInfo['brandName']);
$statGoodsInfo['marketPrice'] = str_replace('¥', '', $goodsInfo['marketPrice']);
if(isset($goodsInfo['salePrice'])) {
if (isset($goodsInfo['salePrice'])) {
$statGoodsInfo['salePrice'] = str_replace('¥', '', $goodsInfo['salePrice']);
} else {
$statGoodsInfo['salePrice'] = str_replace('¥', '', $goodsInfo['marketPrice']);
... ... @@ -222,7 +239,7 @@ class ItemModel
$statGoodsInfo['productUrl'] = $goodsInfo['weixinUrl'];
$statGoodsInfo['smallSortId'] = $goodsInfo['smallSortId'];
$statGoodsInfo['soldOut'] = intval($soldOut);
return array('goodsInfo'=> $goodsInfo,'consultComment' => $consultComment, 'banner'=> $banner,'statGoodsInfo' => $statGoodsInfo);
return array('goodsInfo' => $goodsInfo, 'consultComment' => $consultComment, 'banner' => $banner, 'statGoodsInfo' => $statGoodsInfo);
}
/**
... ... @@ -237,11 +254,11 @@ class ItemModel
if (is_numeric($productSkn)) {
//并发资源中是否存在数据
$sizeInfo = self::getMultiDataByResourceName('ItemData::sizeInfo');
if(empty($sizeInfo)) {
if (empty($sizeInfo)) {
//获取尺码
$sizeInfo = ItemData::sizeInfo($productSkn);
}
if(empty($sizeInfo)) {
if (empty($sizeInfo)) {
return array();
}
$productId = $sizeInfo['productBo']['id'];
... ... @@ -261,15 +278,14 @@ class ItemModel
$fittingReport = self::getProductModelTry($productSkn);
//获取尺寸说明
$sizeAttr = array();
if(!empty($sizeInfo['sizeInfoBo'])) {
if (!empty($sizeInfo['sizeInfoBo'])) {
//根据最大分类ID获取尺寸属性
$sizeAttr = self::getSizeAttrByMaxSortId($maxSortId, $sizeInfo['sizeInfoBo']);
}
return array('material'=> $material, 'size'=> $size, 'reference'=> $reference,
'modelCards'=> $modelCards,'details'=> $details,'fittingReport' =>$fittingReport,
'description'=> $description,'sizeTitleJson' => json_encode($sizeAttr));
}
else {
return array('material' => $material, 'size' => $size, 'reference' => $reference,
'modelCards' => $modelCards, 'details' => $details, 'fittingReport' => $fittingReport,
'description' => $description, 'sizeTitleJson' => json_encode($sizeAttr));
} else {
return array();
}
... ... @@ -288,8 +304,8 @@ class ItemModel
$goodsInfo = array();
$size = array();
$baseInfo = ItemData::baseInfo($productId, $uid);
if(!empty($baseInfo)) {
if(empty($baseInfo['productName']) && empty($baseInfo['erpProductId']) && empty($baseInfo['productPriceBo'])) {
if (!empty($baseInfo)) {
if (empty($baseInfo['productName']) && empty($baseInfo['erpProductId']) && empty($baseInfo['productPriceBo'])) {
return array();
}
$goodsInfo['name'] = $baseInfo['productName'];
... ... @@ -305,7 +321,7 @@ class ItemModel
$goodsInfo['marketPrice'] = Helpers::transPrice($baseInfo['productPriceBo']['marketPrice']);
$goodsInfo['salePrice'] = Helpers::transPrice($baseInfo['productPriceBo']['salesPrice']);
$goodsInfo['hasOtherPrice'] = true;//非市场价格
if($goodsInfo['marketPrice'] == $goodsInfo['salePrice']) {//价格相同,只显示市场价格
if ($goodsInfo['marketPrice'] == $goodsInfo['salePrice']) {//价格相同,只显示市场价格
unset($goodsInfo['salePrice']);
$goodsInfo['hasOtherPrice'] = false;
}
... ... @@ -328,9 +344,9 @@ class ItemModel
$goodsInfo['img'] = $skuData['defaultImage'];
$goodsInfo['colors'] = $skuData['skuGoods'];
$favoriteData = FavoriteData::getUidProductFav($uid, $productId);
$goodsInfo['isCollect'] = $favoriteData['code'] == 200 && $favoriteData['data'] ? true:false;
$goodsInfo['isCollect'] = $favoriteData['code'] == 200 && $favoriteData['data'] ? true : false;
$sizeInfo = ItemData::sizeInfo($baseInfo['erpProductId']);
if(!empty($sizeInfo)) {
if (!empty($sizeInfo)) {
$size = self::getSizeDataBySizeInfo($sizeInfo);
$goodsInfo['size'] = $size;
}
... ... @@ -350,10 +366,10 @@ class ItemModel
$goodsInfo['fashionTopGoods'] = array(
'getLimitedCode' => $fashTopGoods['getLimitedCode'],//限购码状态
'hasLimitedCode' => $fashTopGoods['hasLimitedCode'],//是否已经获取限购码
'limitedCodeSoldOut'=> $fashTopGoods['limitedCodeSoldOut'],//限购码是否已经抢光
'limitedCodeSoldOut' => $fashTopGoods['limitedCodeSoldOut'],//限购码是否已经抢光
'getLimitedCodeDis' => $fashTopGoods['getLimitedCodeDis'],//限购码是否失效
);
if($fashTopGoods['soldOut']) {
if ($fashTopGoods['soldOut']) {
$goodsInfo['soldOut'] = $fashTopGoods['soldOut'];
$totalStorageNum = 0;//改总数为已售磬
} else {
... ... @@ -370,24 +386,23 @@ class ItemModel
if (!$soldOut && !$notForSale && !$virtualGoods) {
$goodsInfo['addToCart'] = true;
//立即购买或者即将开售存在
if((isset($goodsInfo['buyNow']) && $goodsInfo['buyNow']) ||
(isset($goodsInfo['openSoon']) && $goodsInfo['openSoon'])) {
if ((isset($goodsInfo['buyNow']) && $goodsInfo['buyNow']) ||
(isset($goodsInfo['openSoon']) && $goodsInfo['openSoon'])
) {
unset($goodsInfo['addToCart']);
}
}// 非卖品
elseif ($notForSale) {
//$goodsInfo['notForSale'] = true;
$goodsInfo['addToCart'] = true;//赠品
}
// 已售磬
} // 已售磬
elseif ($soldOut) {
$goodsInfo['soldOut'] = true;
}
else if($virtualGoods) {
} else if ($virtualGoods) {
$goodsInfo['buyNow'] = true;//是否立即购买
$goodsInfo['buyNowBase'] = Helpers::url('/ticket', array(), 'shopping');
$goodsInfo['virtualGoods'] = $virtualGoods;
if(isset($goodsInfo['salePrice'])) {
if (isset($goodsInfo['salePrice'])) {
$goodsInfo['advancePrice'] = $goodsInfo['salePrice'];//先行价格
unset($goodsInfo['salePrice']);
}
... ... @@ -405,19 +420,19 @@ class ItemModel
*/
public static function getSortNav($smallSortId)
{
$key = WebCacheConfig::KEY_WEB_ITEM_SORT_DATA.'_'.$smallSortId;
$key = WebCacheConfig::KEY_WEB_ITEM_SORT_DATA . '_' . $smallSortId;
$navs = Cache::get($key);
if(empty($navs)) {
$data = SearchData::getSortByCondition(array('sort'=> $smallSortId));
if(!empty($data['data'])) {
if (empty($navs)) {
$data = SearchData::getSortByCondition(array('sort' => $smallSortId));
if (!empty($data['data'])) {
$sort = current($data['data']['sort']);
//一级分类
$navs[] = array('href' => Helpers::url('', array('msort'=> $sort['sort_id'],
'gender' => Helpers::getGenderByCookie()),'list'), 'name' => $sort['sort_name'],'pathTitle' => $sort['sort_name']);
if(!empty($sort['sub'])) {//二级分类
$navs[] = array('href' => Helpers::url('', array('msort' => $sort['sort_id'],
'gender' => Helpers::getGenderByCookie()), 'list'), 'name' => $sort['sort_name'], 'pathTitle' => $sort['sort_name']);
if (!empty($sort['sub'])) {//二级分类
$subSort = current($sort['sub']);
$navs[] = array('href' => Helpers::url('', array('msort'=> $sort['sort_id'],'misort'=>$subSort['sort_id'],
'gender' => Helpers::getGenderByCookie()),'list'), 'name' => $subSort['sort_name'], 'pathTitle' => $subSort['sort_name']);
$navs[] = array('href' => Helpers::url('', array('msort' => $sort['sort_id'], 'misort' => $subSort['sort_id'],
'gender' => Helpers::getGenderByCookie()), 'list'), 'name' => $subSort['sort_name'], 'pathTitle' => $subSort['sort_name']);
}
Cache::set($key, $navs);
}
... ... @@ -454,7 +469,7 @@ class ItemModel
$build['like'] = intval($value['like']);
$build['isUseful'] = $value['is_useful'] === 'Y';
$build['useful'] = intval($value['useful']);
$build['total']= $value['total'];
$build['total'] = $value['total'];
$result[] = $build;
}
}
... ... @@ -479,8 +494,8 @@ class ItemModel
$build = array();
foreach ($commentList['data'] as $value) {
$headIco = ChannelConfig::$itemHeadDefaultImgIco;
if(!empty($value['head_ico'])) {
if(preg_match('@http://@', $value['head_ico'])) {
if (!empty($value['head_ico'])) {
if (preg_match('@http://@', $value['head_ico'])) {
$headIco = preg_replace('@http:\/\/img(.+)\.static\.yhbimg\.com\/headimg@', 'http://head.static.yhbimg.com/yhb-head/', $value['head_ico']);
$headIco = Images::getImageUrl($headIco, 30, 30);
}
... ... @@ -509,11 +524,10 @@ class ItemModel
{
$result = array();
$data = self::getMultiDataByResourceName('ItemData::getProductBanner');
if(empty($data)) {
if (empty($data)) {
$data = ItemData::getProductBanner($productId);
}
if(isset($data['code']) && $data['code'] == 200 && !empty($data['data']))
{
if (isset($data['code']) && $data['code'] == 200 && !empty($data['data'])) {
$result['activityImg'] = Images::getImageUrl($data['data']['bannerImg'], 260, 64);
$result['url'] = $data['data']['promotionUrl'];
}
... ... @@ -530,20 +544,20 @@ class ItemModel
{
$result = array();
$data = ItemData::getProductHotArea($productId);
if(isset($data['code']) && $data['code'] == 200) {
if(!empty($data['data'])) {
if (isset($data['code']) && $data['code'] == 200) {
if (!empty($data['data'])) {
foreach ($data['data'] as $area) {
$temp = array();
$pos = 1;
if(isset($area['imageUrl'])) {
if (isset($area['imageUrl'])) {
$temp['img'] = Images::getForceSourceUrl($area['imageUrl']);
}
foreach($area['infos'] as $val) {
if(isset($val['product'])) {
$point = array('label' => $pos++,'height' => $val['height'],
'left' => $val['left'],'top' => $val['top'],
'width'=> $val['width'],'product' => array());
if(!empty($val['product']['goodsList'])) {
foreach ($area['infos'] as $val) {
if (isset($val['product'])) {
$point = array('label' => $pos++, 'height' => $val['height'],
'left' => $val['left'], 'top' => $val['top'],
'width' => $val['width'], 'product' => array());
if (!empty($val['product']['goodsList'])) {
$goods = current($val['product']['goodsList']);
//封面图
$point['img'] = Images::getImageUrl($goods['colorImage'], 60, 60);
... ... @@ -557,11 +571,11 @@ class ItemModel
);
}
}
if(!empty($point)) {
if (!empty($point)) {
$temp['list'][] = $point;
}
}
if(!empty($temp)) {
if (!empty($temp)) {
$result[] = $temp;
}
}
... ... @@ -580,11 +594,11 @@ class ItemModel
{
$result = array();
$data = self::getMultiDataByResourceName('ItemData::getProductModelCard');
if(empty($data)) {
if (empty($data)) {
$data = ItemData::getProductModelCard($productId);
}
if(isset($data['code']) && $data['code'] == 200) {
foreach($data['data'] as $val) {
if (isset($data['code']) && $data['code'] == 200) {
foreach ($data['data'] as $val) {
$result[] = array(
'url' => Images::getForceSourceUrl($val['modelImg']),
'size' => $val['size'],
... ... @@ -618,15 +632,15 @@ class ItemModel
{
$result = array();
$comfort = self::getMultiDataByResourceName('ItemData::getProductComfort');
if(empty($comfort)) {
if (empty($comfort)) {
$comfort = ItemData::getProductComfort($productId);
}
if(!empty($comfort['data'])) {
foreach($comfort['data'] as $val) {
if (!empty($comfort['data'])) {
foreach ($comfort['data'] as $val) {
$blocks = array();
$flag = false;
for($i =1;$i<=5; $i++) {
if($i == $val['wearSense']['value']) {
for ($i = 1; $i <= 5; $i++) {
if ($i == $val['wearSense']['value']) {
$flag = true;
$blocks[] = array('cur' => true);
} else {
... ... @@ -634,12 +648,12 @@ class ItemModel
}
}
//存在,添加
if($flag) {
if ($flag) {
$result[] = array(
'name' => $val['caption']['caption'],
'minDes'=> $val['caption']['low'],
'blocks'=> $blocks,
'maxDes'=>$val['caption']['high']
'minDes' => $val['caption']['low'],
'blocks' => $blocks,
'maxDes' => $val['caption']['high']
);
}
}
... ... @@ -657,15 +671,15 @@ class ItemModel
public static function getProductFavoriteData($uid, $productId, $brandId)
{
$result = array('product' => false, 'brand' => false);
if(!empty($uid)) {
if(!empty($productId)) {
if (!empty($uid)) {
if (!empty($productId)) {
$productData = self::getMultiDataByResourceName('FavoriteData::getUidProductFav');
if(empty($productData)) {
if (empty($productData)) {
$productData = FavoriteData::getUidProductFav($uid, $productId);
}
$result['product'] = $productData['code'] == 200 && $productData['data'] ? true : false;
}
if(!empty($brandId)) {
if (!empty($brandId)) {
$brandData = FavoriteData::isFavoriteBrand($uid, $brandId);
$result['brand'] = isset($brandData['code']) && $brandData['code'] == 200 ? true : false;
}
... ... @@ -693,7 +707,7 @@ class ItemModel
$multiResourcesUrl['ItemData::getProductModelCard'] = ItemData::getProductModelCard($productId, $isOnlyUrl);
$multiResourcesUrl['ItemData::getProductModelTry'] = ItemData::getProductModelTry($skn, $isOnlyUrl);
$multiResourcesUrl['BrandData::getBannerInfo'] = BrandData::getBannerInfo($brandId, $isOnlyUrl);
if(!empty($uid)) {
if (!empty($uid)) {
$multiResourcesUrl['FavoriteData::getUidProductFav'] = FavoriteData::getUidProductFav($uid, $productId, $isOnlyUrl);
}
self::$multiResources = Yohobuy::getMulti($multiResourcesUrl, array(), false, 5, true);
... ... @@ -707,7 +721,7 @@ class ItemModel
*/
private static function getMultiDataByResourceName($resourceName)
{
if(isset(self::$multiResources[$resourceName])) {
if (isset(self::$multiResources[$resourceName])) {
return self::$multiResources[$resourceName];
} else {
return false;
... ... @@ -738,21 +752,21 @@ class ItemModel
$sizeInfos = array();
$attributeNames = array();
//获取属性名称
foreach($sizeList['sizeAttributeBos'] as $size) {
foreach ($sizeList['sizeAttributeBos'] as $size) {
$attributeNames[$size['id']] = $size['attributeName'];
}
foreach($sizeList['sizeBoList'] as $size) {
foreach ($sizeList['sizeBoList'] as $size) {
$sizeValues = array();
foreach($size['sortAttributes'] as $sort) {
if(in_array($sort['id'], $attributeIds)) {
if(!empty($sort['sizeValue'])) {
$sizeValues[] = $attributeNames[$sort['id']].' '.$sort['sizeValue'].'cm';
foreach ($size['sortAttributes'] as $sort) {
if (in_array($sort['id'], $attributeIds)) {
if (!empty($sort['sizeValue'])) {
$sizeValues[] = $attributeNames[$sort['id']] . ' ' . $sort['sizeValue'] . 'cm';
}
}
}
//获取尺寸属性
if(!empty($sizeValues)) {
if (!empty($sizeValues)) {
$sizeInfos[$size['sizeName']] = implode(' / ', $sizeValues);
}
}
... ... @@ -785,14 +799,14 @@ class ItemModel
}
// 判断是否显示参考尺码
$showReference = ($boyReference && !empty($sizeInfo['sizeInfoBo']['sizeBoList'][0]['boyReferSize'])) ||
($girlReference && !empty($sizeInfo['sizeInfoBo']['sizeBoList'][0]['girlReferSize']) );
($girlReference && !empty($sizeInfo['sizeInfoBo']['sizeBoList'][0]['girlReferSize']));
if (!empty($sizeInfo['sizeInfoBo']['sizeAttributeBos'])) {
//尺码信息头部
$size['thead'] = array(0 => array('name' => '吊牌尺码', 'id' => ''));
//显示参考尺码
if ($showReference) {
$size['thead'][1] = array('name' => $referenceName,'id' => '');
$size['thead'][1] = array('name' => $referenceName, 'id' => '');
}
foreach ($sizeInfo['sizeInfoBo']['sizeAttributeBos'] as $attr) {
$size['thead'][] = array('name' => empty($attr['attributeName']) ? ' ' : $attr['attributeName'], 'id' => $attr['id']);
... ... @@ -807,7 +821,7 @@ class ItemModel
} else if ($girlReference && ($gender == 2 || $gender == 3) && $showReference) {
$sizes[] = empty($value['girlReferSize']['referenceName']) ? ' ' : $value['girlReferSize']['referenceName'];
} else {
if(isset($size['thead'][1]) && $showReference) {
if (isset($size['thead'][1]) && $showReference) {
$size['thead'][1] = array();
}
}
... ... @@ -819,7 +833,7 @@ class ItemModel
$size['tbody'][] = $sizes;
}
//参考尺码为空
if(isset($size['thead'][1]) && empty($size['thead'][1]) && $showReference) {
if (isset($size['thead'][1]) && empty($size['thead'][1]) && $showReference) {
unset($size['thead'][1]);
$size['thead'] = array_values($size['thead']);
}
... ... @@ -877,21 +891,21 @@ class ItemModel
//模特信息
$reference['tbody'] = array();
$reference['thead'] = array(
array('name' => ''), array('name' => '模特', 'modelCol'=> true),
array('name' => '身高'),array('name' => '体重'),
array('name' => '三围'),array('name' => '吊牌尺码'),
array('name' => ''), array('name' => '模特', 'modelCol' => true),
array('name' => '身高'), array('name' => '体重'),
array('name' => '三围'), array('name' => '吊牌尺码'),
array('name' => '试穿描述'),
);
//模特数据
foreach($sizeInfo['modelBos'] as $value) {
foreach ($sizeInfo['modelBos'] as $value) {
$modelValue = array(Images::getForceSourceUrl($value['avatar']),
$value['modelName'],$value['height'],$value['weight'],$value['vitalStatistics'],
$value['fitModelBo']['fit_size'],$value['fitModelBo']['feel']
$value['modelName'], $value['height'], $value['weight'], $value['vitalStatistics'],
$value['fitModelBo']['fit_size'], $value['fitModelBo']['feel']
);
//是否有备注
if (!empty($value['fitModelBo']['fit_remark'])) {
$modelValue[] = $value['fitModelBo']['fit_remark'];
$reference['thead'][7] = array('name' => '备注','remarkCol' => true);
$reference['thead'][7] = array('name' => '备注', 'remarkCol' => true);
}
$reference['tbody'][] = $modelValue;
}
... ... @@ -912,7 +926,7 @@ class ItemModel
if (!empty($sizeInfo['washTipsBoList'])) {
$material['wash'] = array();
foreach ($sizeInfo['washTipsBoList'] as $value) {
$material['wash'][] = array('name' => $value['caption'],'img' => $value['img']);
$material['wash'][] = array('name' => $value['caption'], 'img' => $value['img']);
}
}
... ... @@ -951,12 +965,12 @@ class ItemModel
$sex = '女款';
break;
}
$description['basic'][] = array('key' =>'编号','value' => $sizeInfo['productDescBo']['erpProductId']);
$description['basic'][] = array('key' =>'颜色','value' => $sizeInfo['productDescBo']['colorName'], 'dColor' => true);
$description['basic'][] = array('key' =>'性别','value' => $sex);
$description['basic'][] = array('key' => '编号', 'value' => $sizeInfo['productDescBo']['erpProductId']);
$description['basic'][] = array('key' => '颜色', 'value' => $sizeInfo['productDescBo']['colorName'], 'dColor' => true);
$description['basic'][] = array('key' => '性别', 'value' => $sex);
if (!empty($sizeInfo['productDescBo']['standardBos'])) {
foreach ($sizeInfo['productDescBo']['standardBos'] as $value) {
$description['basic'][] = array('key' => $value['standardName'], 'value'=> $value['standardVal']);
$description['basic'][] = array('key' => $value['standardName'], 'value' => $value['standardVal']);
}
}
$description['comfort'] = self::getProductComfort($sizeInfo['productBo']['id']);
... ... @@ -1005,7 +1019,7 @@ class ItemModel
foreach ($baseInfo['goodsList'] as $pos => $value) {
// 如果status为0,即skc下架时就跳过该商品$value['status'] === 0
if (empty($value['colorImage']) ) {
if (empty($value['colorImage'])) {
continue;
}
if (isset($value['goodsImagesList'])) {
... ... @@ -1013,37 +1027,37 @@ class ItemModel
$goodsGroup = array(
'productSkc' => $value['productSkc'],
'src' => Images::getImageUrl($value['colorImage'], 40, 40),
'title' => trim($baseInfo['productName']).' '.$value['colorName'],
'title' => trim($baseInfo['productName']) . ' ' . $value['colorName'],
'name' => $value['colorName'],
'focus'=> false,
'focus' => false,
'total' => 0,
'thumbs' => array(),
'size' => array(),
);
foreach ($value['goodsImagesList'] as $goods) {
if(!empty($goods['imageUrl'])) {
if (!empty($goods['imageUrl'])) {
$goodsGroup['thumbs'][] = array(
'url' => '','shower' => Images::getImageUrl($goods['imageUrl'], 420, 560),
'url' => '', 'shower' => Images::getImageUrl($goods['imageUrl'], 420, 560),
'img' => Images::getImageUrl($goods['imageUrl'], 75, 100),
);
}
}
//缩略图空,不显示
if(empty($goodsGroup['thumbs'])) {
if (empty($goodsGroup['thumbs'])) {
continue;
}
//默认第一张图片
if($pos == 0) {
if ($pos == 0) {
$defaultImage = Images::getImageUrl($value['colorImage'], 420, 560);
}
//商品的尺码列表
foreach ($value['goodsSizeBoList'] as $size) {
if($baseInfo['attribute'] == 3 ) { //虚拟商品,增加为一件
$size['goodsSizeStorageNum'] = $size['goodsSizeStorageNum'] > 1 ? 1: 0;
if ($baseInfo['attribute'] == 3) { //虚拟商品,增加为一件
$size['goodsSizeStorageNum'] = $size['goodsSizeStorageNum'] > 1 ? 1 : 0;
}
//如果status为0,即skc下架时就跳过该商品
if ($value['status'] === 0) {
... ... @@ -1053,12 +1067,12 @@ class ItemModel
'name' => $size['sizeName'],
'sku' => $size['goodsSizeSkuId'],
'num' => intval($size['goodsSizeStorageNum']),
'goodsId'=> $size['goodsId']
'goodsId' => $size['goodsId']
);
//单个sku商品的总数
$goodsGroup['total'] += intval($size['goodsSizeStorageNum']);
if($goodsGroup['total']> 0 && !$chooseSkuFlag) { //默认选中该sku商品
if ($goodsGroup['total'] > 0 && !$chooseSkuFlag) { //默认选中该sku商品
$goodsGroup['focus'] = true;
$chooseSkuFlag = true;//选中sku商品
}
... ... @@ -1067,11 +1081,11 @@ class ItemModel
}
$skuGoods[] = $goodsGroup;
}
if(!empty($skuGoods) && !$chooseSkuFlag) {//没有选中一个sku商品,默认选中第一个sku商品
if (!empty($skuGoods) && !$chooseSkuFlag) {//没有选中一个sku商品,默认选中第一个sku商品
$skuGoods[0]['focus'] = true;
}
}
return array('skuGoods' => $skuGoods,'totalStorageNum' => $totalStorageNum,
return array('skuGoods' => $skuGoods, 'totalStorageNum' => $totalStorageNum,
'defaultImage' => $defaultImage);
}
... ... @@ -1083,7 +1097,7 @@ class ItemModel
*/
private static function getBrandDataByProductBaseInfo(array &$baseInfo)
{
if(empty($baseInfo['brand'])) {
if (empty($baseInfo['brand'])) {
return array();
}
$brandId = $baseInfo['brand']['id'];
... ... @@ -1091,38 +1105,37 @@ class ItemModel
$logo = '';
$bannerInfo = array();
$result = self::getMultiDataByResourceName('BrandData::getBannerInfo');
if(empty($result)) {
if (empty($result)) {
$result = BrandData::getBannerInfo($brandId);//品牌banner
}
if(!empty($baseInfo['brand']['brandIco'])) {
if (!empty($baseInfo['brand']['brandIco'])) {
$logo = Images::getForceSourceUrl($baseInfo['brand']['brandIco']);
}
if(isset($result['code']) && $result['code'] == 200 && !empty($result['data'])) {
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data'])) {
$bannerInfo = $result['data'];
if(!empty($bannerInfo['bannerUrl'])) {
if (!empty($bannerInfo['bannerUrl'])) {
$bgImg = Images::getForceSourceUrl($bannerInfo['bannerUrl']);
}
}
//banner的logo
if(!empty($bannerInfo['logo']))
{
if (!empty($bannerInfo['logo'])) {
$logo = Images::getForceSourceUrl($bannerInfo['logo']);
}
$homeUrl = 'javascript:void(0)';
if(!empty($baseInfo['brand']['brandDomain'])){
if (!empty($baseInfo['brand']['brandDomain'])) {
$homeUrl = Helpers::url('', array(), $baseInfo['brand']['brandDomain']);
}
//导航的品牌banner
return array(
'brandId' => $baseInfo['brand']['id'],
'bgColor' => !empty($bannerInfo['colorValue']) ? $bannerInfo['colorValue']: '#000000',
'bgImg'=> $bgImg,
'logo'=> $logo,
'bgColor' => !empty($bannerInfo['colorValue']) ? $bannerInfo['colorValue'] : '#000000',
'bgImg' => $bgImg,
'logo' => $logo,
'alt' => $baseInfo['brand']['brandName'],
'brandName' => $baseInfo['brand']['brandName'],
'brandDomain' => $baseInfo['brand']['brandDomain'],
'homeUrl'=> $homeUrl,
'isCollect'=> false
'homeUrl' => $homeUrl,
'isCollect' => false
);
}
... ... @@ -1140,7 +1153,7 @@ class ItemModel
if (!empty($baseInfo['productPriceBo']['vipPrices'])) {
$build = array();
//不是普通会员
if($vipLevel > 0) {
if ($vipLevel > 0) {
foreach ($baseInfo['productPriceBo']['vipPrices'] as $value) {
$build['level'] = $value['vipLevel'];
$build['price'] = $value['vipPrice'];
... ... @@ -1151,10 +1164,10 @@ class ItemModel
}
$vipData['unLogin'] = false;
//登录状态
if(empty($uid)) {
if (empty($uid)) {
$vipData['unLogin'] = Helpers::url('/signin.html', array());
}
if(empty($vipLevel) && !empty($uid)) {
if (empty($vipLevel) && !empty($uid)) {
$vipData['normalUser'] = true;
}
//查看vip进度
... ... @@ -1169,24 +1182,15 @@ class ItemModel
* @param array $baseInfo
* @return array
*/
private static function getActivityDataByProductBaseInfo(array &$baseInfo)
private static function getActivityDataByProductBaseInfo(array &$activityData)
{
$activity = array();
//促销活动banner
$activityBanner = self::getProductActivityBanner($baseInfo['id']);
if(!empty($activityBanner)) {
$activity[] = $activityBanner;
}
// 促销信息活动
if (isset($baseInfo['promotionBoList'])) {
$build = array();
foreach ($baseInfo['promotionBoList'] as $value) {
foreach ($activityData as $value) {
$build['type'] = $value['promotionType'];
$build['des'] = $value['promotionTitle'];
$activity[] = $build;
}
}
return $activity;
}
... ... @@ -1242,23 +1246,24 @@ class ItemModel
{
$modelTry = array();
$result = self::getMultiDataByResourceName('ItemData::getProductModelTry');
if(empty($result)) {
if (empty($result)) {
$result = ItemData::getProductModelTry($productSkn);
}
if(isset($result['code']) && $result['code'] == 200 && !empty($result['data'])) {
if (isset($result['code']) && $result['code'] == 200 && !empty($result['data'])) {
//先显示模特信息
if(isset($result['data']['modelTryBoList']) && !empty($result['data']['modelTryBoList'])) {
$modelTry['thead'] = array('模特','身高','体重','三围','试穿尺码','试穿描述');
if (isset($result['data']['modelTryBoList']) && !empty($result['data']['modelTryBoList'])) {
$modelTry['thead'] = array('模特', '身高', '体重', '三围', '试穿尺码', '试穿描述');
$modelTry['tbody'] = array();
foreach($result['data']['modelTryBoList'] as $val) {
if(isset($val['modelBo']) && isset($val['sizeBo']) &&
isset($val['modelBo']['modelName']) && isset($val['sizeBo']['sizeName'])) {
foreach ($result['data']['modelTryBoList'] as $val) {
if (isset($val['modelBo']) && isset($val['sizeBo']) &&
isset($val['modelBo']['modelName']) && isset($val['sizeBo']['sizeName'])
) {
$modelTry['tbody'][] = array($val['modelBo']['modelName'],
$val['modelBo']['height'],$val['modelBo']['weight'],$val['modelBo']['vitalStatistics'],
$val['modelBo']['height'], $val['modelBo']['weight'], $val['modelBo']['vitalStatistics'],
$val['sizeBo']['sizeName'], $val['tryDesc']);
}
}
} else if(isset($result['data']['modelTryImgBoList']) && !empty($result['data']['modelTryImgBoList'])) {//后显示模特图
} else if (isset($result['data']['modelTryImgBoList']) && !empty($result['data']['modelTryImgBoList'])) {//后显示模特图
$tryImg = current($result['data']['modelTryImgBoList']);
$modelTry['frImg'] = Images::getForceSourceUrl($tryImg['tryImg']);
}
... ... @@ -1284,10 +1289,10 @@ class ItemModel
//buyNow //是否立即购买
$result = array('getLimitedCode' => false, 'hasLimitedCode' => false,
'limitedCodeSoldOut' => false, 'openSoon' => false, 'dis' => false,
'buyNow' => false, 'soldOut'=> false, 'getLimitedCodeDis'=> false);
'buyNow' => false, 'soldOut' => false, 'getLimitedCodeDis' => false);
// 显示获取限购码按钮
$result['getLimitedCode'] = true;
switch($showStatus) {
switch ($showStatus) {
case 1: // 开售前/后,立即分享获得限购码(用户未领取限购码)
if ($isBeginSale) { // 开售后
$result['buyNow'] = true;
... ... @@ -1312,7 +1317,7 @@ class ItemModel
$result['buyNow'] = true;
$result['dis'] = false;
$result['hasLimitedCode'] = true;
if(!empty($uid)) {//限购码失效
if (!empty($uid)) {//限购码失效
$result['getLimitedCodeDis'] = true;
}
break;
... ... @@ -1326,7 +1331,7 @@ class ItemModel
case 6: // 开售前,即将开售(用户已领取限购码)
$result['openSoon'] = true;
$result['hasLimitedCode'] = true;
if(!empty($uid)) {//限购码失效
if (!empty($uid)) {//限购码失效
$result['getLimitedCodeDis'] = true;
}
break;
... ... @@ -1334,7 +1339,7 @@ class ItemModel
$result['buyNow'] = true;
$result['dis'] = true;
$result['hasLimitedCode'] = true;
if(!empty($uid)) {//限购码失效
if (!empty($uid)) {//限购码失效
$result['getLimitedCodeDis'] = true;
}
default:
... ...