Commit a7799d85 authored by zhz's avatar zhz

bug2862,2868

parent 9cff256a
......@@ -279,10 +279,12 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
case 1:
$order[] = ['sale_num','DESC'];
$order[] = ['eval_score','DESC'];
$order[] = ['goodsCommonId','DESC'];
$saleSort = true;
break;
case 2:
$order[] = ['sale_num','DESC'];
$order[] = ['goodsCommonId','DESC'];
$saleSort = true;
break;
case 3:
......@@ -297,6 +299,8 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
default:
$order[] = ['sale_num','DESC'];
$order[] = ['eval_score','DESC'];
$order[] = ['goodsCommonId','DESC'];
$saleSort = true;
break;
}
return array($where,$order,$attrStr,$saleSort);
......@@ -458,7 +462,6 @@ class GoodsCommonServiceModel extends \Business\AbstractModel
if($pageSize === 0){
\Error\ErrorModel::throwException(\Error\CodeConfigModel::commonError);
}
$limit = array($pageIndex*$pageSize,$pageSize);
$where = array();
$where[] = "store_id={$storeId}";
......
......@@ -399,11 +399,14 @@ class StoreServiceModel extends \Business\AbstractModel{
public function getRecommendGoods($storeId,$activities){
$storeClassDAO = \DAO\StoreGoodsClassModel::getInstance();
$tempStcs = $storeClassDAO->getList(array('store_id'=>$storeId),'stc_id,stc_name');
$recommendGoods = [];
if($tempStcs) {
$storeClassGoodsDao = \DAO\StoreGoodsClassGoodsModel::getInstance();
$stcGoods = $storeClassGoodsDao->getList('stc_id in('.implode(',',array_column($tempStcs,'stc_id')).')','stc_id,goods_common_id');
foreach ($tempStcs as $stc) {
$recommendGoods[$stc['stc_id']] = array('stcId'=>$stc['stc_id'],'stcName'=>$stc['stc_name'],'goods'=>[]);
}
}
$recommendGoods = [];
if($stcGoods){
$goodsIds = array_column($stcGoods,'goods_common_id');
$goodsCommonDAO = \DAO\GoodsCommonModel::getInstance();
......@@ -412,7 +415,6 @@ class StoreServiceModel extends \Business\AbstractModel{
}else{
$tempGoods = $goodsCommonDAO->getListWithSale(array('han_goods_common.goods_commonid in('.implode(',',$goodsIds).')'),'goods_name,goods_image,goods_price,goods_marketprice,han_goods_common.goods_commonid,IFNULL(discount_price,han_goods_common.goods_price) AS goodsPrice',$activities);
}
if($tempGoods && $tempStcs){
$stcs = [];
foreach ($tempStcs as $v){
......@@ -431,18 +433,19 @@ class StoreServiceModel extends \Business\AbstractModel{
'goodsPrice'=>$goods[$v['goods_common_id']]['goodsPrice'],
'goodsMarketPrice'=>$goods[$v['goods_common_id']]['goods_marketprice'],
];
if(key_exists($v['stc_id'],$recommendGoods)){
if(count($recommendGoods[$v['stc_id']]['goods']) >= 8){
continue;
}
array_push($recommendGoods[$v['stc_id']]['goods'],$good);
}else{
$recommendGoods[$v['stc_id']] = [
'stcId'=>$v['stc_id'],
'stcName'=>$stcs[$v['stc_id']]['stc_name'],
'goods'=>array($good)
];
}
array_push($recommendGoods[$v['stc_id']]['goods'],$good);
// if(key_exists($v['stc_id'],$recommendGoods)){
// if(count($recommendGoods[$v['stc_id']]['goods']) >= 8){
// continue;
// }
// array_push($recommendGoods[$v['stc_id']]['goods'],$good);
// }else{
// $recommendGoods[$v['stc_id']] = [
// 'stcId'=>$v['stc_id'],
// 'stcName'=>$stcs[$v['stc_id']]['stc_name'],
// 'goods'=>array($good)
// ];
// }
}
}
$tempRecommendGoods = array();
......
File mode changed from 100755 to 100644
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