Commit f044366c authored by zhz's avatar zhz

goodsimage

parent a768b8dd
...@@ -90,5 +90,13 @@ class ImageConst{ ...@@ -90,5 +90,13 @@ class ImageConst{
4=>self::reportPath 4=>self::reportPath
); );
const sizeScale = 1.5;
const goodsListImgSize = 334;
const CommentGoodsImgSize = 138;
const CommentDetailGoodsImgSize = 148;
const SaleGoodsImgSize = 148;
const SpecSelectGoodsImgSize = 450;//规格弹出框(含购物车)
const goodsDetailImgSize = 750;
const goodsCollectionImgSize = 336;
const footPrintGoodsImgSize = 216;
} }
...@@ -112,11 +112,9 @@ class ImageUtil { ...@@ -112,11 +112,9 @@ class ImageUtil {
* @param int $type 图片规格 * @param int $type 图片规格
* @return mixed|string 返回图片路径 * @return mixed|string 返回图片路径
*/ */
public static function getGoodsImgUrl($goodsImg,$type=240){ public static function getGoodsImgUrl($goodsImg,$width=\Our\ImageConst::goodsListImgSize, $height = 0){
$width = $width * \Our\ImageConst::sizeScale;
// if(!in_array($type,\Our\ArrayConst::goodsImageExt)){ $height ? $height = $height * \Our\ImageConst::sizeScale : $height = $width;
// $type = 240;
// }
if (empty($goodsImg)) { if (empty($goodsImg)) {
$directory =\Our\ImageConst::defaultPath; $directory =\Our\ImageConst::defaultPath;
//$goodsImg = str_ireplace('.', '_' . $type . '.', 'default_goods_image.gif'); //$goodsImg = str_ireplace('.', '_' . $type . '.', 'default_goods_image.gif');
...@@ -128,7 +126,7 @@ class ImageUtil { ...@@ -128,7 +126,7 @@ class ImageUtil {
//$goodsImg .= '?x-oss-process=image/resize,m_pad,h_226,w_334'; //$goodsImg .= '?x-oss-process=image/resize,m_pad,h_226,w_334';
} }
$goodsImg = \Our\Common::getStaticFile($goodsImg,$directory); $goodsImg = \Our\Common::getStaticFile($goodsImg,$directory);
$goodsImg .= '?x-oss-process=image/resize,m_fixed,h_226,w_334'; $goodsImg .= "?x-oss-process=image/resize,m_fill,h_{$height},w_{$width}";
return $goodsImg; return $goodsImg;
} }
......
...@@ -24,7 +24,7 @@ class CommentServiceModel extends \Business\AbstractModel { ...@@ -24,7 +24,7 @@ class CommentServiceModel extends \Business\AbstractModel {
if(is_array($list) && !empty($list)){ if(is_array($list) && !empty($list)){
$totalCount = \Our\RedisHelper::cachedFunction(\Redis\Db6\CommentToBuyerRedisModel::getInstance(),array(&$CommentToBuyerDAO, 'getCount'),array($where),\Our\ApiConst::oneHour,array($memberId)); $totalCount = \Our\RedisHelper::cachedFunction(\Redis\Db6\CommentToBuyerRedisModel::getInstance(),array(&$CommentToBuyerDAO, 'getCount'),array($where),\Our\ApiConst::oneHour,array($memberId));
foreach ($list as $v){ foreach ($list as $v){
$comments[] = array('id'=>$v['id'],'goodsImage'=>\Our\ImageUtil::getGoodsImgUrl($v['goods_image']),'content'=>$v['content'],'state'=>$v['state'],'addTime'=>$v['addtime']); $comments[] = array('id'=>$v['id'],'goodsImage'=>\Our\ImageUtil::getGoodsImgUrl($v['goods_image'],\Our\ImageConst::CommentGoodsImgSize),'content'=>$v['content'],'state'=>$v['state'],'addTime'=>$v['addtime']);
} }
}else{ }else{
$totalCount = 0; $totalCount = 0;
...@@ -64,7 +64,7 @@ class CommentServiceModel extends \Business\AbstractModel { ...@@ -64,7 +64,7 @@ class CommentServiceModel extends \Business\AbstractModel {
list($storeInfo,$storeLabel) = \DAO\StoreModel::getInstance()->get($comment['store_id']); list($storeInfo,$storeLabel) = \DAO\StoreModel::getInstance()->get($comment['store_id']);
$goodsDao = \DAO\GoodsModel::getInstance(); $goodsDao = \DAO\GoodsModel::getInstance();
$goods = \Our\RedisHelper::cachedFunction(\Redis\Db4\GoodsRedisModel::getInstance(),array(&$goodsDao, 'find'),array(array('goods_id'=>$comment['goods_id']),'*'),\Our\ApiConst::oneHour,array($comment['goods_id'])); $goods = \Our\RedisHelper::cachedFunction(\Redis\Db4\GoodsRedisModel::getInstance(),array(&$goodsDao, 'find'),array(array('goods_id'=>$comment['goods_id']),'*'),\Our\ApiConst::oneHour,array($comment['goods_id']));
return array('content'=>$comment['content'],'addTime'=>$comment['addtime'],'goodsName'=>$comment['goods_name'],'goodsImage'=>\Our\ImageUtil::getGoodsImgUrl($comment['goods_image']),'goodsAttr'=>$attr,'goodsPrice'=>(int)$comment['goods_pay_price'],'storeLabel'=>$storeLabel,'storeName'=>$storeInfo['store_name'],'storeId'=>$comment['store_id'],'goodsCommonId'=>$goodsCommonId,'groupId'=>$groupId); return array('content'=>$comment['content'],'addTime'=>$comment['addtime'],'goodsName'=>$comment['goods_name'],'goodsImage'=>\Our\ImageUtil::getGoodsImgUrl($comment['goods_image'],\Our\ImageConst::CommentDetailGoodsImgSize),'goodsAttr'=>$attr,'goodsPrice'=>(int)$comment['goods_pay_price'],'storeLabel'=>$storeLabel,'storeName'=>$storeInfo['store_name'],'storeId'=>$comment['store_id'],'goodsCommonId'=>$goodsCommonId,'groupId'=>$groupId);
} }
private static $_instance = null; private static $_instance = null;
/** /**
......
...@@ -263,7 +263,7 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -263,7 +263,7 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
if(is_array($list) && !empty($list)){ if(is_array($list) && !empty($list)){
$totalCount = \Our\RedisHelper::cachedFunction(\Redis\Db4\GoodsCommonRedisModel::getInstance(),array(&$commonDAO, 'getCount'),array(implode(' and ',$where),$attrStr),\Our\ApiConst::oneDaySecond,array($storeId)); $totalCount = \Our\RedisHelper::cachedFunction(\Redis\Db4\GoodsCommonRedisModel::getInstance(),array(&$commonDAO, 'getCount'),array(implode(' and ',$where),$attrStr),\Our\ApiConst::oneDaySecond,array($storeId));
foreach ($list as $v){ foreach ($list as $v){
$v['goodsImage'] = \Our\ImageUtil::getGoodsImgUrl($v['goodsImage'],360); $v['goodsImage'] = \Our\ImageUtil::getGoodsImgUrl($v['goodsImage']);
$v['goodsPrice'] = (int)$v['goodsPrice']; $v['goodsPrice'] = (int)$v['goodsPrice'];
unset($v['goods_price']); unset($v['goods_price']);
$goods[] = $v; $goods[] = $v;
...@@ -335,7 +335,7 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -335,7 +335,7 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
public function getAttr($goodsCommonId,$memberId = null){ public function getAttr($goodsCommonId,$memberId = null){
$goodsCommonId = (int)$goodsCommonId; $goodsCommonId = (int)$goodsCommonId;
$commonInfo = $this->checkGoodsCommon($goodsCommonId); $commonInfo = $this->checkGoodsCommon($goodsCommonId);
$commonInfo['goods_image'] = \Our\ImageUtil::getGoodsImgUrl($commonInfo['goods_image']); $commonInfo['goods_image'] = \Our\ImageUtil::getGoodsImgUrl($commonInfo['goods_image'],\Our\ImageConst::SpecSelectGoodsImgSize);
//该用户是否有参加销售活动 //该用户是否有参加销售活动
//$activities = $this->isJoin($commonInfo['store_id'],$memberId); //$activities = $this->isJoin($commonInfo['store_id'],$memberId);
$activities = \DAO\SaleMemberModel::getInstance()->isJoinStore($commonInfo['store_id'],$memberId); $activities = \DAO\SaleMemberModel::getInstance()->isJoinStore($commonInfo['store_id'],$memberId);
...@@ -350,10 +350,10 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -350,10 +350,10 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
if($image && is_array($image)){ if($image && is_array($image)){
$i = 0; $i = 0;
foreach ($image as $k=>$v){ foreach ($image as $k=>$v){
$image[$k]['goods_image'] = \Our\ImageUtil::getGoodsImgUrl($v['goods_image'],1280); $image[$k]['goods_image'] = \Our\ImageUtil::getGoodsImgUrl($v['goods_image'],\Our\ImageConst::SpecSelectGoodsImgSize);
$attrImage[$v['attr_name']][$v['attr_value']][] = $image[$k]['goods_image']; $attrImage[$v['attr_name']][$v['attr_value']][] = $image[$k]['goods_image'];
if($i < 5 ){ if($i < 5 ){
$images[] = $image[$k]['goods_image']; $images[] = \Our\ImageUtil::getGoodsImgUrl($v['goods_image'],\Our\ImageConst::goodsDetailImgSize);
} }
$i += 1; $i += 1;
} }
...@@ -975,7 +975,7 @@ class GoodsCommonServiceModel extends \Business\AbstractModel ...@@ -975,7 +975,7 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
$goods[] = [ $goods[] = [
'goodsCommonId'=>$v['goods_commonid'], 'goodsCommonId'=>$v['goods_commonid'],
'goodsName'=>$v['goods_name'], 'goodsName'=>$v['goods_name'],
'goodsImage'=>\Our\ImageUtil::getGoodsImgUrl($v['goods_image'],360), 'goodsImage'=>\Our\ImageUtil::getGoodsImgUrl($v['goods_image']),
'goodsMarketPrice'=>$v['goods_marketprice'], 'goodsMarketPrice'=>$v['goods_marketprice'],
'goodsPrice'=>$v['goods_price'] 'goodsPrice'=>$v['goods_price']
]; ];
......
...@@ -44,7 +44,7 @@ class GroupSaleServiceModel extends \Business\AbstractModel { ...@@ -44,7 +44,7 @@ class GroupSaleServiceModel extends \Business\AbstractModel {
$data['image'] = []; $data['image'] = [];
if($blImg = unserialize($data['bl_image'])){ if($blImg = unserialize($data['bl_image'])){
foreach ($blImg as $v){ foreach ($blImg as $v){
$data['image'][] = \Our\ImageUtil::getGoodsImgUrl($v,1280); $data['image'][] = \Our\ImageUtil::getGoodsImgUrl($v,\Our\ImageConst::goodsDetailImgSize);
} }
} }
$data['goods'] = []; $data['goods'] = [];
......
...@@ -762,9 +762,22 @@ class StoreServiceModel extends \Business\AbstractModel{ ...@@ -762,9 +762,22 @@ class StoreServiceModel extends \Business\AbstractModel{
} }
$goods = []; $goods = [];
if(is_array($list) && !empty($list)){ if(is_array($list) && !empty($list)){
foreach ($list as $v){ foreach ($list as $k=>$v){
unset($v['goods_price']); unset($v['goods_price']);
$v['goodsImage'] = \Our\ImageUtil::getGoodsImgUrl($v['goodsImage'],360); switch ($k) {
case 0:
$v['goodsImage'] = \Our\ImageUtil::getGoodsImgUrl($v['goodsImage'],300, 410);
break;
case 1:
$v['goodsImage'] = \Our\ImageUtil::getGoodsImgUrl($v['goodsImage'],380, 198);
break;
case 2:
$v['goodsImage'] = \Our\ImageUtil::getGoodsImgUrl($v['goodsImage'],380, 198);
break;
default:
$v['goodsImage'] = \Our\ImageUtil::getGoodsImgUrl($v['goodsImage'],380, 198);
break;
}
$v['goodsPrice'] = (int)$v['goodsPrice']; $v['goodsPrice'] = (int)$v['goodsPrice'];
$goods[] = $v; $goods[] = $v;
} }
......
...@@ -78,7 +78,7 @@ class FootprintServiceModel extends \Business\AbstractModel ...@@ -78,7 +78,7 @@ class FootprintServiceModel extends \Business\AbstractModel
'goodsCommonId'=>$goodsCommon['goods_commonid'], 'goodsCommonId'=>$goodsCommon['goods_commonid'],
'groupId'=>0, 'groupId'=>0,
'goodsName'=>$goodsCommon['goods_name'], 'goodsName'=>$goodsCommon['goods_name'],
'goodsImage'=>\Our\ImageUtil::getGoodsImgUrl($goodsCommon['goods_image'],360), 'goodsImage'=>\Our\ImageUtil::getGoodsImgUrl($goodsCommon['goods_image'],\Our\ImageConst::footPrintGoodsImgSize),
'goodsPrice'=>$goodsCommon['goods_price'], 'goodsPrice'=>$goodsCommon['goods_price'],
'viewDate'=>$dates[$v] 'viewDate'=>$dates[$v]
]; ];
...@@ -92,7 +92,7 @@ class FootprintServiceModel extends \Business\AbstractModel ...@@ -92,7 +92,7 @@ class FootprintServiceModel extends \Business\AbstractModel
$list = \Our\RedisHelper::cachedFunction(\Redis\Db4\GoodsCommonRedisModel::getInstance(),array(&$commonDAO, 'getListWithSale'),array($where,$field,$acts,[],[],'',false),\Our\ApiConst::oneMinute);; $list = \Our\RedisHelper::cachedFunction(\Redis\Db4\GoodsCommonRedisModel::getInstance(),array(&$commonDAO, 'getListWithSale'),array($where,$field,$acts,[],[],'',false),\Our\ApiConst::oneMinute);;
if($list){ if($list){
foreach ($list as $goodsCommon) { foreach ($list as $goodsCommon) {
$goodsCommon['goodsImage'] = \Our\ImageUtil::getGoodsImgUrl($goodsCommon['goodsImage'],360); $goodsCommon['goodsImage'] = \Our\ImageUtil::getGoodsImgUrl($goodsCommon['goodsImage'],\Our\ImageConst::footPrintGoodsImgSize);
$goodsCommon['viewDate'] = $dates[$goodsCommon['goodsCommonId']]; $goodsCommon['viewDate'] = $dates[$goodsCommon['goodsCommonId']];
$goodsCommon['groupId'] = 0; $goodsCommon['groupId'] = 0;
//$footPrints[] = $goodsCommon; //$footPrints[] = $goodsCommon;
...@@ -113,7 +113,7 @@ class FootprintServiceModel extends \Business\AbstractModel ...@@ -113,7 +113,7 @@ class FootprintServiceModel extends \Business\AbstractModel
'goodsCommonId'=>0, 'goodsCommonId'=>0,
'groupId'=>$group['blId'], 'groupId'=>$group['blId'],
'goodsName'=>$group['name'], 'goodsName'=>$group['name'],
'goodsImage'=>\Our\ImageUtil::getGoodsImgUrl($group['image'],360), 'goodsImage'=>\Our\ImageUtil::getGoodsImgUrl($group['image'],\Our\ImageConst::footPrintGoodsImgSize),
'goodsPrice'=>$group['discountPrice'], 'goodsPrice'=>$group['discountPrice'],
'viewDate'=>$dates[$group['blId']] 'viewDate'=>$dates[$group['blId']]
]; ];
......
...@@ -254,7 +254,7 @@ class MemberCenterServiceModel extends \Business\AbstractModel ...@@ -254,7 +254,7 @@ class MemberCenterServiceModel extends \Business\AbstractModel
// } // }
foreach ($list as $v){ foreach ($list as $v){
//if($stores['store_id'] && $stores['store_id']['open_flag'] == 1 && $stores['store_id']['store_state'] == 1) { //if($stores['store_id'] && $stores['store_id']['open_flag'] == 1 && $stores['store_id']['store_state'] == 1) {
$goods[] = array('favid'=>$v['favid'],'goodsCommonId'=>$v['goods_commonid'],'goodsImage'=>\Our\ImageUtil::getGoodsImgUrl($v['goods_image']),'goodsName'=>$v['goods_name'],'goodsPrice'=>$v['goods_price'],'goodsId'=>$v['goods_id']); $goods[] = array('favid'=>$v['favid'],'goodsCommonId'=>$v['goods_commonid'],'goodsImage'=>\Our\ImageUtil::getGoodsImgUrl($v['goods_image'],\our\ApiConst::goodsCollectionImgSize),'goodsName'=>$v['goods_name'],'goodsPrice'=>$v['goods_price'],'goodsId'=>$v['goods_id']);
// } // }
} }
if($where) { if($where) {
......
...@@ -86,7 +86,7 @@ class SalespersonServiceModel extends \Business\AbstractModel ...@@ -86,7 +86,7 @@ class SalespersonServiceModel extends \Business\AbstractModel
if($goodsList[$v['goodsId']]) { if($goodsList[$v['goodsId']]) {
$goods['goodsId'] = $v['goodsId']; $goods['goodsId'] = $v['goodsId'];
$goods['goodsCommonId'] = $goodsList[$v['goodsId']]['goods_commonid']; $goods['goodsCommonId'] = $goodsList[$v['goodsId']]['goods_commonid'];
$goods['goodsImage'] = \Our\ImageUtil::getGoodsImgUrl($goodsList[$v['goodsId']]['goods_image']); $goods['goodsImage'] = \Our\ImageUtil::getGoodsImgUrl($goodsList[$v['goodsId']]['goods_image'],\Our\ApiConst::SaleGoodsImgSize);
$goods['goodsName'] = $goodsList[$v['goodsId']]['goods_name']; $goods['goodsName'] = $goodsList[$v['goodsId']]['goods_name'];
$goods['goodsCount'] = (int)$v['goodsCount']; $goods['goodsCount'] = (int)$v['goodsCount'];
$hashData[$v['sale_act_id']][$v['sale_act_id'].'_'.$memberId.'_'.$v['goodsId']] = serialize($goods); $hashData[$v['sale_act_id']][$v['sale_act_id'].'_'.$memberId.'_'.$v['goodsId']] = serialize($goods);
...@@ -116,7 +116,7 @@ class SalespersonServiceModel extends \Business\AbstractModel ...@@ -116,7 +116,7 @@ class SalespersonServiceModel extends \Business\AbstractModel
if(!in_array($id,$existIds)){ if(!in_array($id,$existIds)){
if($goodsList[$id]) { if($goodsList[$id]) {
$data = [ $data = [
'goodsImage'=>\Our\ImageUtil::getGoodsImgUrl($goodsList[$id]['goods_image']), 'goodsImage'=>\Our\ImageUtil::getGoodsImgUrl($goodsList[$id]['goods_image'],\Our\ApiConst::SaleGoodsImgSize),
'goodsName'=>$goodsList[$id]['goods_name'], 'goodsName'=>$goodsList[$id]['goods_name'],
'goodsCount'=>0, 'goodsCount'=>0,
'goodsId'=>$id, 'goodsId'=>$id,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment