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
{
/**
... ... @@ -18,10 +19,10 @@ class ItemModel
* @var array
*/
private static $multiResources = array();
/**
* 获取商品信息
*
*
* @param string $productId
* @param string $goodsId
* @param string $uid
... ... @@ -29,13 +30,13 @@ class ItemModel
* @param string $productSkn
* @return array
*/
public static function getProductInfo($productId, $goodsId, $uid, $vipLevel = 0, $productSkn = null)
public static function getProductInfo($productId, $goodsId, $uid, $vipLevel = 0, $productSkn = null)
{
$goodsInfo = array();
$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'];
}
//收藏喜欢
... ... @@ -58,34 +59,51 @@ class ItemModel
// 商品标签
$goodsInfo['tags'] = self::getTagsDataByProductInfo($baseInfo);
// 商品促销短语
if (!empty($baseInfo['salesPhrase'])) {
$goodsInfo['saleTip'] = $baseInfo['salesPhrase'];
}
// 商品价格
if (isset($baseInfo['productPriceBo'])) {
$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;
}
}
//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'] . '月';
... ... @@ -93,26 +111,26 @@ class ItemModel
unset($goodsInfo['salePrice']);
$goodsInfo['hasOtherPrice'] = false;
}
//商品咨询和评论数据
$consultComment = self::getConsultCommentDataByProductInfo($baseInfo);
// 品牌信息
if (!empty($baseInfo['brand'])) {
$goodsInfo['brandImg'] = Helpers::getImageUrl($baseInfo['brand']['brandIco'], 47, 47);
$goodsInfo['brandImg'] = Helpers::getImageUrl($baseInfo['brand']['brandIco'], 47, 47);
$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'];
}
}
//sku商品信息
$skuData = self::getSkuDataByProductBaseInfo($baseInfo);
$goodsInfo['img'] = $skuData['defaultImage'];
$goodsInfo['colors'] = $skuData['skuGoods'];
$totalStorageNum = $skuData['totalStorageNum'];
// 是否收藏
$goodsInfo['isCollect'] = $favoriteData['product'];
// 限购商品
... ... @@ -124,16 +142,16 @@ class ItemModel
if (isset($baseInfo['showStatus'])) {
$showStatus = intval($baseInfo['showStatus']);
}
$fashTopGoods = self::getFashionTopGoodsStatus($uid, $showStatus, $isBeginSale);
//潮流尖货状态
$goodsInfo['fashionTopGoods'] = array(
'getLimitedCode' => $fashTopGoods['getLimitedCode'],//限购码状态
'hasLimitedCode' => $fashTopGoods['hasLimitedCode'],//是否已经获取限购码
'limitedCodeSoldOut'=> $fashTopGoods['limitedCodeSoldOut'],//限购码是否已经抢光
'getLimitedCodeDis' => $fashTopGoods['getLimitedCodeDis'],//限购码是否失效
);
if($fashTopGoods['soldOut']) {
'getLimitedCode' => $fashTopGoods['getLimitedCode'],//限购码状态
'hasLimitedCode' => $fashTopGoods['hasLimitedCode'],//是否已经获取限购码
'limitedCodeSoldOut' => $fashTopGoods['limitedCodeSoldOut'],//限购码是否已经抢光
'getLimitedCodeDis' => $fashTopGoods['getLimitedCodeDis'],//限购码是否失效
);
if ($fashTopGoods['soldOut']) {
$goodsInfo['soldOut'] = $fashTopGoods['soldOut'];
$totalStorageNum = 0;//改总数为已售磬
} else {
... ... @@ -142,56 +160,55 @@ class ItemModel
$goodsInfo['buyNow'] = $fashTopGoods['buyNow'];//是否立即购买
}
}
$soldOut = $baseInfo['status'] == 0 || $totalStorageNum === 0;
$notForSale = $baseInfo['attribute'] == 2;//非卖品
$virtualGoods = $baseInfo['attribute'] == 3;//虚拟商品
if (!$soldOut && !$notForSale && !$virtualGoods) {
$goodsInfo['addToCart'] = true;
//立即购买或者即将开售存在
if((isset($goodsInfo['buyNow']) && $goodsInfo['buyNow']) ||
(isset($goodsInfo['openSoon']) && $goodsInfo['openSoon'])) {
$goodsInfo['addToCart'] = true;
//立即购买或者即将开售存在
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'];
//统计需要的商品信息
$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']);
... ... @@ -201,11 +218,11 @@ class ItemModel
$domainBrand = BrandsModel::getBrandByDomain($banner['brandDomain']);
if (!empty($domainBrand['type'])) {
switch (intval($domainBrand['type'])) {
case 1:
case 1:
//多品店不显示
$banner = array();
break;
case 2:
case 2:
if (empty($domainBrand['shopId'])) {
break;
}
... ... @@ -222,26 +239,26 @@ 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);
}
/**
* 商品尺码信息
*
*
* @param string $productSkn
* @param int $maxSortId
* @return array
*/
public static function getSizeInfo($productSkn, $maxSortId)
public static function getSizeInfo($productSkn, $maxSortId)
{
if (is_numeric($productSkn)) {
//并发资源中是否存在数据
$sizeInfo = self::getMultiDataByResourceName('ItemData::sizeInfo');
if(empty($sizeInfo)) {
if (empty($sizeInfo)) {
//获取尺码
$sizeInfo = ItemData::sizeInfo($productSkn);
$sizeInfo = ItemData::sizeInfo($productSkn);
}
if(empty($sizeInfo)) {
if (empty($sizeInfo)) {
return array();
}
$productId = $sizeInfo['productBo']['id'];
... ... @@ -261,35 +278,34 @@ 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();
}
}
/**
* 获取购物车商品信息
*
*
* @param int $productId
* @param int $uid
* @param int $vipLevel
* @return array
*/
public static function getCartProductInfo($productId, $uid, $vipLevel)
public static function getCartProductInfo($productId, $uid, $vipLevel)
{
$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'];
... ... @@ -299,18 +315,18 @@ class ItemModel
if (!empty($baseInfo['salesPhrase'])) {
$goodsInfo['saleTip'] = $baseInfo['salesPhrase'];
}
// 商品价格
if (isset($baseInfo['productPriceBo'])) {
$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;
}
}
// 上市期
if (isset($baseInfo['expectArrivalTime']) && !empty($baseInfo['expectArrivalTime'])) {
$goodsInfo['arrivalDate'] = $baseInfo['expectArrivalTime'] . '月';
... ... @@ -318,23 +334,23 @@ class ItemModel
unset($goodsInfo['salePrice']);
$goodsInfo['hasOtherPrice'] = false;
}
//VIP数据
$goodsInfo['vipPrice'] = self::getVipDataByProductBaseInfo($baseInfo, $vipLevel);
//sku商品信息
$skuData = self::getSkuDataByProductBaseInfo($baseInfo);
$totalStorageNum = $skuData['totalStorageNum'];
$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;
}
// 限购商品
if ($baseInfo['isLimitBuy'] === 'Y') {
// 是否开售
... ... @@ -344,16 +360,16 @@ class ItemModel
if (isset($baseInfo['showStatus'])) {
$showStatus = intval($baseInfo['showStatus']);
}
$fashTopGoods = self::getFashionTopGoodsStatus($uid, $showStatus, $isBeginSale);
//潮流尖货状态
$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 {
... ... @@ -362,7 +378,7 @@ class ItemModel
$goodsInfo['buyNow'] = $fashTopGoods['buyNow'];//是否立即购买
}
}
//商品状态
$soldOut = $baseInfo['status'] == 0 || $totalStorageNum === 0;
$notForSale = $baseInfo['attribute'] == 2;//非卖品
... ... @@ -370,54 +386,53 @@ class ItemModel
if (!$soldOut && !$notForSale && !$virtualGoods) {
$goodsInfo['addToCart'] = true;
//立即购买或者即将开售存在
if((isset($goodsInfo['buyNow']) && $goodsInfo['buyNow']) ||
(isset($goodsInfo['openSoon']) && $goodsInfo['openSoon'])) {
unset($goodsInfo['addToCart']);
}
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']);
}
}
}
return $goodsInfo;
}
/**
* 获取分类导航列表
*
*
* @param string $smallSortId
* @return array
*/
public static function getSortNav($smallSortId)
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);
}
... ... @@ -427,17 +442,17 @@ class ItemModel
}
return $navs;
}
/**
* 获取咨询列表
*
*
* @param int $uid
* @param int $productId
* @param int $pageNum
* @param int $pageSize
* @return array
*/
public static function getConsults($uid, $productId, $pageNum = 1, $pageSize = 30)
public static function getConsults($uid, $productId, $pageNum = 1, $pageSize = 30)
{
$result = array();
if (is_numeric($productId) && is_numeric($pageNum) && is_numeric($pageSize)) {
... ... @@ -454,23 +469,23 @@ 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;
}
}
}
return $result;
}
/**
* 获取评论
*
*
* @param int $productId
* @param int $pageNum
* @param int $pageSize
* @return array
* @return array
*/
public static function getComments($productId, $pageNum = 1, $pageSize = 10)
public static function getComments($productId, $pageNum = 1, $pageSize = 10)
{
$result = array();
if (is_numeric($productId) && is_numeric($pageNum) && is_numeric($pageSize)) {
... ... @@ -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);
}
... ... @@ -496,12 +511,12 @@ class ItemModel
}
}
}
return $result;
return $result;
}
/**
* 获取商品活动banner
*
*
* @param int $productId
* @return array
*/
... ... @@ -509,41 +524,40 @@ 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'];
}
return $result;
}
/**
* 获取商品热区
*
*
* @param string $productId
* @return array
*/
public static function getProductHotArea($productId)
public static function getProductHotArea($productId)
{
$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,22 +571,22 @@ class ItemModel
);
}
}
if(!empty($point)) {
if (!empty($point)) {
$temp['list'][] = $point;
}
}
if(!empty($temp)) {
$result[] = $temp;
if (!empty($temp)) {
$result[] = $temp;
}
}
}
}
return $result;
}
/**
* 获取商品模特卡
*
*
* @param string $productId
* @return array
*/
... ... @@ -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'],
... ... @@ -594,7 +608,7 @@ class ItemModel
}
return $result;
}
/**
* 添加咨询
*
... ... @@ -607,10 +621,10 @@ class ItemModel
{
return ItemData::addConsult($uid, $productId, $content);
}
/**
* 获取商品的舒适度
*
*
* @param int $productId
* @return array
*/
... ... @@ -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,19 +648,19 @@ 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']
);
}
}
}
return $result;
}
/**
* 获取商品的喜欢
* @param int $uid
... ... @@ -657,25 +671,25 @@ 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;
}
}
return $result;
}
/**
* 根据商品信息设置并发请求
*
*
* @param array $productInfo
*/
private static function setMultiResourceByProductBaseInfo(&$baseInfo)
... ... @@ -693,33 +707,33 @@ 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);
}
/**
* 根据资源名称获取并发数据
*
*
* @param string $resourceName
* @return array
*/
private static function getMultiDataByResourceName($resourceName)
{
if(isset(self::$multiResources[$resourceName])) {
if (isset(self::$multiResources[$resourceName])) {
return self::$multiResources[$resourceName];
} else {
return false;
}
}
/**
* 根据最大分类ID获取尺寸属性
*
*
* @param string $maxSortId
* @param array $sizeList
* @return array
* @return array
*/
private static function getSizeAttrByMaxSortId($maxSortId, array $sizeList)
{
... ... @@ -738,34 +752,34 @@ 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);
}
}
return $sizeInfos;
}
/**
* 获取尺寸信息
*
*
* @param array $sizeInfo
* @return array
* @return array
*/
private static function getSizeDataBySizeInfo(array &$sizeInfo)
private static function getSizeDataBySizeInfo(array &$sizeInfo)
{
$size = array();
// 尺码信息
... ... @@ -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']);
... ... @@ -803,13 +817,13 @@ class ItemModel
$sizes = array($value['sizeName']);
//判断是否显示参考尺码
if ($boyReference && ($gender == 1 || $gender == 3) && $showReference) {
$sizes[] = empty($value['boyReferSize']['referenceName']) ? ' ' : $value['boyReferSize']['referenceName'];
} else if ($girlReference && ($gender == 2 || $gender == 3) && $showReference) {
$sizes[] = empty($value['boyReferSize']['referenceName']) ? ' ' : $value['boyReferSize']['referenceName'];
} 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();
}
}
}
//其他尺码信息
foreach ($value['sortAttributes'] as $attr) {
... ... @@ -819,20 +833,20 @@ 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']);
}
}
}
// 测量方式
if (!empty($sizeInfo['sizeImage'])) {
$size['sizeImg'] = $sizeInfo['sizeImage'];
}
return $size;
}
/**
* 使sizeBoList id以 sizeAttributeBos id顺序一样
* @param type array $sizeInfoBo
... ... @@ -843,7 +857,7 @@ class ItemModel
if (empty($sizeInfoBo['sizeBoList']) || empty($sizeInfoBo['sizeAttributeBos'])) {
return array();
}
foreach ($sizeInfoBo['sizeBoList'] as $sizek => $sizeBoList) {
$sortArr = array();
foreach ($sizeBoList['sortAttributes'] as $sortAttributes) {
... ... @@ -851,7 +865,7 @@ class ItemModel
}
$sizeInfoBo['sizeBoList'][$sizek]['sortAttributes'] = $sortArr;
}
foreach ($sizeInfoBo['sizeBoList'] as $sizek => $sizeBoList) {
$sortArr = array();
foreach ($sizeInfoBo['sizeAttributeBos'] as $val) {
... ... @@ -859,17 +873,17 @@ class ItemModel
}
$sizeInfoBo['sizeBoList'][$sizek]['sortAttributes'] = $sortArr;
}
return $sizeInfoBo;
}
/**
* 获取模特数据
*
*
* @param array $sizeInfo
* @return array
* @return array
*/
private static function getReferenceDataBySizeInfo(array &$sizeInfo)
private static function getReferenceDataBySizeInfo(array &$sizeInfo)
{
$reference = array();
if (!empty($sizeInfo['modelBos'])) {
... ... @@ -877,45 +891,45 @@ 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;
}
}
return $reference;
}
/**
* 获取洗涤材质
*
*
* @param array $sizeInfo
* @return array
*/
private static function getMaterialDataBySizeInfo(array &$sizeInfo)
private static function getMaterialDataBySizeInfo(array &$sizeInfo)
{
$material = array();
//洗涤提示
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']);
}
}
if (!empty($sizeInfo['productMaterialList'])) {
//商品材质[洗涤说明]
$material['materialDetail'] = array();
... ... @@ -930,14 +944,14 @@ class ItemModel
}
return $material;
}
/**
* 获取描述数据
*
*
* @param array $sizeInfo
* @return array
*/
private static function getDescriptionDataBySizeInfo(array &$sizeInfo)
private static function getDescriptionDataBySizeInfo(array &$sizeInfo)
{
$description = array();
// 商品信息
... ... @@ -951,26 +965,26 @@ 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']);
}
return $description;
}
/**
* 获取商品详情页介绍
*
*
* @param array $sizeInfo
* @return string
*/
private static function getDetailDataBySizeInfo(array &$sizeInfo)
private static function getDetailDataBySizeInfo(array &$sizeInfo)
{
$details = '';
// 详情配图
... ... @@ -987,14 +1001,14 @@ class ItemModel
}
return $details;
}
/**
* 获取sku商品数据
*
*
* @param array $baseInfo
* @return array
* @return array
*/
private static function getSkuDataByProductBaseInfo(array &$baseInfo)
private static function getSkuDataByProductBaseInfo(array &$baseInfo)
{
$totalStorageNum = 0;
$skuGoods = array();//sku商品
... ... @@ -1003,9 +1017,9 @@ class ItemModel
if (!empty($baseInfo['goodsList'])) {
$goodsGroup = array();
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,52 +1027,52 @@ 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) {
$size['goodsSizeStorageNum'] = 0;
$size['goodsSizeStorageNum'] = 0;
}
$goodsGroup['size'][] = array(
'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,23 +1081,23 @@ 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);
}
/**
* 获取品牌数据
*
*
* @param array $baseInfo
* @return array
*/
private static function getBrandDataByProductBaseInfo(array &$baseInfo)
private static function getBrandDataByProductBaseInfo(array &$baseInfo)
{
if(empty($baseInfo['brand'])) {
if (empty($baseInfo['brand'])) {
return array();
}
$brandId = $baseInfo['brand']['id'];
... ... @@ -1091,56 +1105,55 @@ 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
);
}
/**
* 获取vip数据
*
*
* @param array $baseInfo
* @param int $vipLevel
* @param int $uid
* @return array
*/
private static function getVipDataByProductBaseInfo(array &$baseInfo, $vipLevel = 0, $uid = 0)
private static function getVipDataByProductBaseInfo(array &$baseInfo, $vipLevel = 0, $uid = 0)
{
$vipData = array();
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进度
... ... @@ -1162,37 +1175,28 @@ class ItemModel
}
return $vipData;
}
/**
* 获取活动数据(促销相关活动)
*
*
* @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) {
$build['type'] = $value['promotionType'];
$build['des'] = $value['promotionTitle'];
$activity[] = $build;
}
$build = array();
foreach ($activityData as $value) {
$build['type'] = $value['promotionType'];
$build['des'] = $value['promotionTitle'];
$activity[] = $build;
}
return $activity;
}
/**
* 获取标签相关数据
*
*
* @param array $baseInfo
* @return array
*/
... ... @@ -1231,45 +1235,46 @@ class ItemModel
}
return $tags;
}
/**
* 获取模特试穿
*
*
* @param string $productSkn
* @return array
* @return array
*/
public static function getProductModelTry($productSkn)
{
$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']);
}
}
return $modelTry;
}
/**
* 处理限购商品的有关按钮状态(或取现购买以及底部商品购买按钮)
*
* @param int $uid
* @param int $uid
* @param int $showStatus 限购商品的关联状态
* @param boolean $isBeginSale 限购商品是否已开售
*/
... ... @@ -1282,12 +1287,12 @@ class ItemModel
//openSoon//即将开售
//dis //失效
//buyNow //是否立即购买
$result = array('getLimitedCode' => false, 'hasLimitedCode' => false,
'limitedCodeSoldOut' => false, 'openSoon' => false, 'dis' => false,
'buyNow' => false, 'soldOut'=> false, 'getLimitedCodeDis'=> false);
$result = array('getLimitedCode' => false, 'hasLimitedCode' => false,
'limitedCodeSoldOut' => false, 'openSoon' => false, 'dis' => 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;
... ... @@ -1321,32 +1326,32 @@ class ItemModel
$result['hasLimitedCode'] = true;
$result['limitedCodeSoldOut'] = true;
$result['getLimitedCode'] = false;
break;
case 6: // 开售前,即将开售(用户已领取限购码)
$result['openSoon'] = true;
$result['hasLimitedCode'] = true;
if(!empty($uid)) {//限购码失效
if (!empty($uid)) {//限购码失效
$result['getLimitedCodeDis'] = true;
}
}
break;
case 7: // 开售后,用户已经用获得的限购码购买过商品
$result['buyNow'] = true;
$result['dis'] = true;
$result['hasLimitedCode'] = true;
if(!empty($uid)) {//限购码失效
if (!empty($uid)) {//限购码失效
$result['getLimitedCodeDis'] = true;
}
default:
break;
}
return $result;
}
/**
* 获取商品咨询和评论数据
*
*
* @param array $baseInfo
* @return array
*/
... ... @@ -1368,5 +1373,5 @@ class ItemModel
}
return $consultComment;
}
}
\ No newline at end of file
... ...