|
@@ -85,7 +85,6 @@ class StoreProduct extends BaseModel
|
|
|
|
|
|
public static function getProductList($data, $uid)
|
|
|
{
|
|
|
- var_dump($data);
|
|
|
$sId = $data['sid'];
|
|
|
$cId = $data['cid'];
|
|
|
$keyword = $data['keyword'];
|
|
@@ -113,25 +112,25 @@ class StoreProduct extends BaseModel
|
|
|
|
|
|
if (!empty($keyword)) $model->where('pro.keyword|pro.store_name', 'LIKE', htmlspecialchars("%$keyword%"));
|
|
|
if ($news != 0) $model->where('pro.is_new', 1);
|
|
|
- $ids=$model->column('id');
|
|
|
-
|
|
|
+ $ids = $model->column('id');
|
|
|
+
|
|
|
$baseOrder = '';
|
|
|
if ($priceOrder) $baseOrder = $priceOrder == 'desc' ? 'c.price DESC' : 'c.price ASC';
|
|
|
|
|
|
if ($salesOrder) $baseOrder = $salesOrder == 'desc' ? 'c.sales DESC' : 'c.sales ASC';
|
|
|
if ($baseOrder) $baseOrder .= ', ';
|
|
|
-
|
|
|
- $time=time();
|
|
|
- $list=Db::name('store_combination')->alias('c')->field('c.id,c.product_id,c.title store_name,c.image,c.sales,c.price,c.stock')->where("c.is_del=0 and c.is_show=1 and c.start_time<{$time} and c.stop_time>{$time}")->page((int)$page, (int)$limit)->whereIn('c.product_id',$ids)->order($baseOrder . 'c.sort DESC, c.add_time DESC')->select();
|
|
|
-
|
|
|
+
|
|
|
+ $time = time();
|
|
|
+ $list = Db::name('store_combination')->alias('c')->field('c.id,c.product_id,c.title store_name,c.image,c.sales,c.price,c.stock')->where("c.is_del=0 and c.is_show=1 and c.start_time<{$time} and c.stop_time>{$time}")->page((int)$page, (int)$limit)->whereIn('c.product_id', $ids)->order($baseOrder . 'c.sort DESC, c.add_time DESC')->select();
|
|
|
+
|
|
|
$list = count($list) ? $list->toArray() : [];
|
|
|
- foreach($list as $k=>$v){
|
|
|
- $data=Db::name('store_product')->field('cate_id,ficti')->where('id',$v['product_id'])->find();
|
|
|
- $list[$k]['cate_id']=$data['cate_id'];
|
|
|
- $list[$k]['ficti']=$data['ficti'];
|
|
|
+ foreach ($list as $k => $v) {
|
|
|
+ $data = Db::name('store_product')->field('cate_id,ficti')->where('id', $v['product_id'])->find();
|
|
|
+ $list[$k]['cate_id'] = $data['cate_id'];
|
|
|
+ $list[$k]['ficti'] = $data['ficti'];
|
|
|
}
|
|
|
return $list;
|
|
|
- }else if($data['isActivity']){
|
|
|
+ } else if ($data['isActivity']) {
|
|
|
$model = self::where('pro.is_del', 0)->where('pro.is_show', 1)->where('pro.mer_id', 0)->alias('pro');
|
|
|
if ($sId) {
|
|
|
$model->whereIn('pro.id', function ($query) use ($sId) {
|
|
@@ -147,7 +146,7 @@ class StoreProduct extends BaseModel
|
|
|
|
|
|
if (!empty($keyword)) $model->where('pro.keyword|pro.store_name', 'LIKE', htmlspecialchars("%$keyword%"));
|
|
|
if ($news != 0) $model->where('pro.is_new', 1);
|
|
|
- $ids=$model->column('id');
|
|
|
+ $ids = $model->column('id');
|
|
|
|
|
|
$baseOrder = '';
|
|
|
if ($priceOrder) $baseOrder = $priceOrder == 'desc' ? 'c.price DESC' : 'c.price ASC';
|
|
@@ -155,16 +154,15 @@ class StoreProduct extends BaseModel
|
|
|
if ($salesOrder) $baseOrder = $salesOrder == 'desc' ? 'c.sales DESC' : 'c.sales ASC';
|
|
|
if ($baseOrder) $baseOrder .= ', ';
|
|
|
|
|
|
- $time=time();
|
|
|
- $list=Db::name('store_activity_product')->alias('c')->field('c.id,c.product_id,c.title store_name,c.image,c.sales,c.price,c.stock')->where("c.is_del=0 and c.is_show=1")->page((int)$page, (int)$limit)->whereIn('c.product_id',$ids)->order($baseOrder . 'c.sort DESC, c.add_time DESC')->select();
|
|
|
+ $time = time();
|
|
|
+ $list = Db::name('store_activity_product')->alias('c')->field('c.id,c.product_id,c.title store_name,c.image,c.sales,c.price,c.stock')->where("c.is_del=0 and c.is_show=1")->page((int)$page, (int)$limit)->whereIn('c.product_id', $ids)->order($baseOrder . 'c.sort DESC, c.add_time DESC')->select();
|
|
|
|
|
|
$list = count($list) ? $list->toArray() : [];
|
|
|
- foreach($list as $k=>$v){
|
|
|
- $data=Db::name('store_product')->field('cate_id,ficti')->where('id',$v['product_id'])->find();
|
|
|
- $list[$k]['cate_id']=$data['cate_id'];
|
|
|
- $list[$k]['ficti']=$data['ficti'];
|
|
|
+ foreach ($list as $k => $v) {
|
|
|
+ $data = Db::name('store_product')->field('cate_id,ficti')->where('id', $v['product_id'])->find();
|
|
|
+ $list[$k]['cate_id'] = $data['cate_id'];
|
|
|
+ $list[$k]['ficti'] = $data['ficti'];
|
|
|
}
|
|
|
-
|
|
|
return $list;
|
|
|
}
|
|
|
|
|
@@ -181,6 +179,10 @@ class StoreProduct extends BaseModel
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ if (isset($data['is_wdc']) && $data['is_wdc'] != '') {
|
|
|
+ $model->where('is_wdc', $data['is_wdc']);
|
|
|
+ }
|
|
|
+
|
|
|
if (!empty($keyword)) $model->where('keyword|store_name', 'LIKE', htmlspecialchars("%$keyword%"));
|
|
|
if ($news != 0) $model->where('is_new', 1);
|
|
|
$baseOrder = '';
|
|
@@ -190,7 +192,7 @@ class StoreProduct extends BaseModel
|
|
|
if ($salesOrder) $baseOrder = $salesOrder == 'desc' ? 'sales DESC' : 'sales ASC';
|
|
|
if ($baseOrder) $baseOrder .= ', ';
|
|
|
$model->order($baseOrder . 'sort DESC, add_time DESC');
|
|
|
- $list = $model->page((int)$page, (int)$limit)->field('id,store_name,cate_id,image,IFNULL(sales,0) + IFNULL(ficti,0) as sales,price,stock,is_gift,is_wdc')->where('is_wdc',$data['is_wdc'])->where('is_pink',0)->select()->each(function ($item) use ($uid, $type) {
|
|
|
+ $list = $model->page((int)$page, (int)$limit)->field('id,store_name,cate_id,image,IFNULL(sales,0) + IFNULL(ficti,0) as sales,price,stock,is_gift,is_wdc')->select()->each(function ($item) use ($uid, $type) {
|
|
|
if ($type) {
|
|
|
$item['is_att'] = StoreProductAttrValueModel::where('product_id', $item['id'])->count() ? true : false;
|
|
|
if ($uid) $item['cart_num'] = StoreCart::where('is_pay', 0)->where('is_del', 0)->where('is_new', 0)->where('type', 'product')->where('product_id', $item['id'])->where('uid', $uid)->value('cart_num');
|
|
@@ -204,7 +206,6 @@ class StoreProduct extends BaseModel
|
|
|
$list[$k]['activity'] = self::activity($v['id']);
|
|
|
}
|
|
|
}
|
|
|
- var_dump(StoreProduct::getLastSql());
|
|
|
return self::setLevelPrice($list, $uid);
|
|
|
}
|
|
|
|
|
@@ -317,6 +318,7 @@ class StoreProduct extends BaseModel
|
|
|
}
|
|
|
return self::setLevelPrice($list, $uid);
|
|
|
}
|
|
|
+
|
|
|
|
|
|
* 爆单区
|
|
|
* @param string $field
|
|
@@ -343,6 +345,7 @@ class StoreProduct extends BaseModel
|
|
|
}
|
|
|
return self::setLevelPrice($list, $uid);
|
|
|
}
|
|
|
+
|
|
|
|
|
|
* wdc区
|
|
|
* @param string $field
|
|
@@ -369,6 +372,7 @@ class StoreProduct extends BaseModel
|
|
|
}
|
|
|
return self::setLevelPrice($list, $uid);
|
|
|
}
|
|
|
+
|
|
|
|
|
|
* 热卖产品
|
|
|
* @param string $field
|