|
|
@@ -29,7 +29,7 @@ class GoodsService extends BaseService
|
|
|
// 使用新的分类商品查询方法
|
|
|
return self::getCategoryGoodsList($where, $page, $pageSize);
|
|
|
} else {
|
|
|
- $data = GoodsClass::getList('*', $where, 'updateTime DESC');
|
|
|
+ $data = GoodsClass::getList('*', $where, 'inTurn DESC, sold DESC');
|
|
|
$list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
|
|
|
if (empty($list)) {
|
|
|
return $data;
|
|
|
@@ -127,32 +127,32 @@ class GoodsService extends BaseService
|
|
|
->joinWith(['goods' => function($query) use ($where) {
|
|
|
// 商品表的筛选条件
|
|
|
if (isset($where['mainId'])) {
|
|
|
- $query->andWhere(['goods.mainId' => $where['mainId']]);
|
|
|
+ $query->andWhere(['xhGoods.mainId' => $where['mainId']]);
|
|
|
}
|
|
|
if (isset($where['delStatus'])) {
|
|
|
- $query->andWhere(['goods.delStatus' => $where['delStatus']]);
|
|
|
+ $query->andWhere(['xhGoods.delStatus' => $where['delStatus']]);
|
|
|
}
|
|
|
if (isset($where['status'])) {
|
|
|
- $query->andWhere(['goods.status' => $where['status']]);
|
|
|
+ $query->andWhere(['xhGoods.status' => $where['status']]);
|
|
|
}
|
|
|
if (isset($where['name'])) {
|
|
|
- $query->andWhere(['like', 'goods.name', $where['name']]);
|
|
|
+ $query->andWhere(['like', 'xhGoods.name', $where['name']]);
|
|
|
}
|
|
|
// 如果需要筛选有库存的商品
|
|
|
if (isset($where['hasStock']) && $where['hasStock'] == 1) {
|
|
|
- $query->andWhere(['>', 'goods.stock', 0]);
|
|
|
+ $query->andWhere(['>', 'xhGoods.stock', 0]);
|
|
|
}
|
|
|
}]);
|
|
|
|
|
|
// 分类表的筛选条件
|
|
|
if (isset($where['cId'])) {
|
|
|
- $query->andWhere(['goodsCategory.cId' => $where['cId']]);
|
|
|
+ $query->andWhere(['cId' => $where['cId']]);
|
|
|
}
|
|
|
if (isset($where['flower'])) {
|
|
|
- $query->andWhere(['goodsCategory.flower' => $where['flower']]);
|
|
|
+ $query->andWhere(['xhGoodsCategory.flower' => $where['flower']]);
|
|
|
}
|
|
|
if (isset($where['flowerNum'])) {
|
|
|
- $query->andWhere(['goodsCategory.flowerNum' => $where['flowerNum']]);
|
|
|
+ $query->andWhere(['xhGoodsCategory.flowerNum' => $where['flowerNum']]);
|
|
|
}
|
|
|
|
|
|
// 计算总数
|
|
|
@@ -163,7 +163,7 @@ class GoodsService extends BaseService
|
|
|
$query->offset($offset)->limit($pageSize);
|
|
|
|
|
|
// 排序
|
|
|
- $query->orderBy(['goodsCategory.inTurn' => SORT_DESC]);
|
|
|
+ $query->orderBy(['xhGoods.inTurn' => SORT_DESC, 'xhGoods.sold' => SORT_DESC]);
|
|
|
|
|
|
// 获取数据
|
|
|
$list = $query->all();
|