|
@@ -93,6 +93,7 @@ class StoreProduct extends BaseModel
|
|
|
$page = $data['page'];
|
|
$page = $data['page'];
|
|
|
$limit = $data['limit'];
|
|
$limit = $data['limit'];
|
|
|
$type = $data['type']; // 某些模板需要购物车数量 1 = 需要查询,0 = 不需要
|
|
$type = $data['type']; // 某些模板需要购物车数量 1 = 需要查询,0 = 不需要
|
|
|
|
|
+ $is_type = $data['is_type']; //特殊商品类型
|
|
|
$model = self::validWhere();
|
|
$model = self::validWhere();
|
|
|
if ($sId) {
|
|
if ($sId) {
|
|
|
$model->whereIn('id', function ($query) use ($sId) {
|
|
$model->whereIn('id', function ($query) use ($sId) {
|
|
@@ -107,6 +108,26 @@ class StoreProduct extends BaseModel
|
|
|
}
|
|
}
|
|
|
if (!empty($keyword)) $model->where('keyword|store_name', 'LIKE', htmlspecialchars("%$keyword%"));
|
|
if (!empty($keyword)) $model->where('keyword|store_name', 'LIKE', htmlspecialchars("%$keyword%"));
|
|
|
if ($news != 0) $model->where('is_new', 1);
|
|
if ($news != 0) $model->where('is_new', 1);
|
|
|
|
|
+ if ($is_type != 0) {
|
|
|
|
|
+ switch ($is_type) {
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ $model->where('is_inclusive', 1); //普惠商品
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 2:
|
|
|
|
|
+ $model->where('is_points', 1); //积分商品
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 3:
|
|
|
|
|
+ $model->where('is_explosive', 1); //报单商品
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 4:
|
|
|
|
|
+ $model->where('is_bargain', 1); //健康商品
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 5:
|
|
|
|
|
+ $model->where('is_seckill', 1); //生活商品
|
|
|
|
|
+ break;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
$baseOrder = '';
|
|
$baseOrder = '';
|
|
|
if ($priceOrder) $baseOrder = $priceOrder == 'desc' ? 'price DESC' : 'price ASC';
|
|
if ($priceOrder) $baseOrder = $priceOrder == 'desc' ? 'price DESC' : 'price ASC';
|
|
|
// if($salesOrder) $baseOrder = $salesOrder == 'desc' ? 'sales DESC' : 'sales ASC';//真实销量
|
|
// if($salesOrder) $baseOrder = $salesOrder == 'desc' ? 'sales DESC' : 'sales ASC';//真实销量
|
|
@@ -289,22 +310,22 @@ class StoreProduct extends BaseModel
|
|
|
return $isSingle ? $list : 0;
|
|
return $isSingle ? $list : 0;
|
|
|
//当$list为数组时$isSingle==true为一维数组 ,否则为二维
|
|
//当$list为数组时$isSingle==true为一维数组 ,否则为二维
|
|
|
if ($isSingle) {
|
|
if ($isSingle) {
|
|
|
- if (!empty($list['is_inclusive'])&&!empty($list['is_points'])&&!empty($list['is_explosive'])){
|
|
|
|
|
|
|
+ if (!empty($list['is_inclusive']) && !empty($list['is_points']) && !empty($list['is_explosive'])) {
|
|
|
if ($list['is_inclusive'] == 0 && $list['is_points'] == 0 && $list['is_explosive'] == 0) {
|
|
if ($list['is_inclusive'] == 0 && $list['is_points'] == 0 && $list['is_explosive'] == 0) {
|
|
|
$list['vip_price'] = isset($list['price']) ? bcsub($list['price'], bcmul($discount, $list['price'], 2), 2) : 0;
|
|
$list['vip_price'] = isset($list['price']) ? bcsub($list['price'], bcmul($discount, $list['price'], 2), 2) : 0;
|
|
|
}
|
|
}
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
$list['vip_price'] = isset($list['price']) ? bcsub($list['price'], bcmul($discount, $list['price'], 2), 2) : 0;
|
|
$list['vip_price'] = isset($list['price']) ? bcsub($list['price'], bcmul($discount, $list['price'], 2), 2) : 0;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
foreach ($list as &$item) {
|
|
foreach ($list as &$item) {
|
|
|
- if (!empty($list['is_inclusive'])&&!empty($list['is_points'])&&!empty($list['is_explosive'])){
|
|
|
|
|
|
|
+ if (!empty($list['is_inclusive']) && !empty($list['is_points']) && !empty($list['is_explosive'])) {
|
|
|
if ($item['is_inclusive'] == 0 && $item['is_points'] == 0 && $item['is_explosive'] == 0) {
|
|
if ($item['is_inclusive'] == 0 && $item['is_points'] == 0 && $item['is_explosive'] == 0) {
|
|
|
// @file_put_contents('quanju.txt', json_encode($item)."-5\r\n", 8);
|
|
// @file_put_contents('quanju.txt', json_encode($item)."-5\r\n", 8);
|
|
|
$item['vip_price'] = isset($item['price']) ? bcsub($item['price'], bcmul($discount, $item['price'], 2), 2) : 0;
|
|
$item['vip_price'] = isset($item['price']) ? bcsub($item['price'], bcmul($discount, $item['price'], 2), 2) : 0;
|
|
|
}
|
|
}
|
|
|
- }else{
|
|
|
|
|
|
|
+ } else {
|
|
|
$item['vip_price'] = isset($item['price']) ? bcsub($item['price'], bcmul($discount, $item['price'], 2), 2) : 0;
|
|
$item['vip_price'] = isset($item['price']) ? bcsub($item['price'], bcmul($discount, $item['price'], 2), 2) : 0;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|