|
@@ -98,13 +98,50 @@ class goodsModel extends Model
|
|
//去掉多规格颜色显示 好商城V3-B11
|
|
//去掉多规格颜色显示 好商城V3-B11
|
|
// $field = "CONCAT(goods_commonid,',',color_id) as nc_distinct ," . $field;
|
|
// $field = "CONCAT(goods_commonid,',',color_id) as nc_distinct ," . $field;
|
|
// $count = $this->getGoodsOnlineCount($condition, "distinct CONCAT(goods_commonid,',',color_id)");
|
|
// $count = $this->getGoodsOnlineCount($condition, "distinct CONCAT(goods_commonid,',',color_id)");
|
|
- $field = "CONCAT(goods_commonid) as nc_distinct ," . $field;
|
|
|
|
|
|
+ $fieldex = "CONCAT(goods_commonid) as nc_distinct, max(goods_storage) as max_goods_storage, " . $field;
|
|
$count = $this->getGoodsOnlineCount($condition, "distinct CONCAT(goods_commonid)");
|
|
$count = $this->getGoodsOnlineCount($condition, "distinct CONCAT(goods_commonid)");
|
|
$goods_list = array();
|
|
$goods_list = array();
|
|
if ($count != 0) {
|
|
if ($count != 0) {
|
|
- $goods_list = $this->getGoodsOnlineList($condition, $field, $page, $order, 0, 'nc_distinct', false, $count);
|
|
|
|
|
|
+ $goods_list = $this->getGoodsOnlineList($condition, $fieldex, $page, $order, 0, 'nc_distinct', false, $count);
|
|
}
|
|
}
|
|
- return $goods_list;
|
|
|
|
|
|
+
|
|
|
|
+ $goods_ret = array();
|
|
|
|
+ $goods_cids = array();
|
|
|
|
+ foreach($goods_list as $goods)
|
|
|
|
+ {
|
|
|
|
+ $g_storage = intval($goods['goods_storage']);
|
|
|
|
+ if($g_storage > 0 || $g_storage == intval($goods['max_goods_storage'])) {
|
|
|
|
+ array_push($goods_ret,$goods);
|
|
|
|
+ } else {
|
|
|
|
+ array_push($goods_cids,intval($goods['goods_commonid']));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(!empty($goods_cids))
|
|
|
|
+ {
|
|
|
|
+ arsort($goods_cids);
|
|
|
|
+ $condition['goods_commonid'] = array('in', $goods_cids);
|
|
|
|
+ $items = $this->cls()->table('goods')->field($field)->where($condition)->order('goods_commonid desc,goods_storage desc')->limit(false)->select();
|
|
|
|
+
|
|
|
|
+ foreach($goods_cids as $commonid)
|
|
|
|
+ {
|
|
|
|
+ $fAdd = true;
|
|
|
|
+ foreach($items as $key => $goods)
|
|
|
|
+ {
|
|
|
|
+ if($commonid == intval($goods['goods_commonid'])) {
|
|
|
|
+ if($fAdd) {
|
|
|
|
+ array_push($goods_ret,$goods);
|
|
|
|
+ $fAdd = false;
|
|
|
|
+ }
|
|
|
|
+ unset($items[$key]);
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return $goods_ret;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|