|
@@ -23,6 +23,8 @@ use app\adminapi\lists\BaseAdminDataLists;
|
|
|
use app\common\lists\ListsExcelInterface;
|
|
use app\common\lists\ListsExcelInterface;
|
|
|
use app\common\lists\ListsSearchInterface;
|
|
use app\common\lists\ListsSearchInterface;
|
|
|
use app\common\model\Goods;
|
|
use app\common\model\Goods;
|
|
|
|
|
+use app\common\model\GoodsCategory;
|
|
|
|
|
+use app\common\model\GoodsCategoryIndex;
|
|
|
use app\common\model\GoodsItem;
|
|
use app\common\model\GoodsItem;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -57,9 +59,32 @@ class GoodsSpecPriceLists extends BaseAdminDataLists implements ListsSearchInter
|
|
|
$searchWhere[] = ['g.code|g.name', 'like', '%' . $this->params['keyword'] . '%'];
|
|
$searchWhere[] = ['g.code|g.name', 'like', '%' . $this->params['keyword'] . '%'];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 分类搜索
|
|
|
|
|
|
|
+ // 分类搜索 - 使用GoodsCategoryIndex表
|
|
|
if (!empty($this->params['category_id'])) {
|
|
if (!empty($this->params['category_id'])) {
|
|
|
- $searchWhere[] = ['g.category_id', '=', $this->params['category_id']];
|
|
|
|
|
|
|
+ $goodsCategory = GoodsCategory::find($this->params['category_id']);
|
|
|
|
|
+ $level = $goodsCategory['level'] ?? '';
|
|
|
|
|
+ $categoryIds = [];
|
|
|
|
|
+ switch ($level) {
|
|
|
|
|
+ case 1:
|
|
|
|
|
+ $categoryIds = GoodsCategory::alias('A')
|
|
|
|
|
+ ->join('goods_category B', 'A.id = B.pid')
|
|
|
|
|
+ ->where(['A.pid' => $this->params['category_id']])
|
|
|
|
|
+ ->field('A.id as aid,B.id as bid')
|
|
|
|
|
+ ->select()->toArray();
|
|
|
|
|
+ $categoryIds = array_merge(array_column($categoryIds, 'aid'), array_column($categoryIds, 'bid'));
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 2:
|
|
|
|
|
+ $categoryIds = GoodsCategory::where(['pid' => $this->params['category_id']])
|
|
|
|
|
+ ->column('id');
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ $categoryIds = array_merge([(int)$this->params['category_id']], $categoryIds);
|
|
|
|
|
+ $goodsIds = GoodsCategoryIndex::where([['category_id', 'in', $categoryIds]])->column('goods_id');
|
|
|
|
|
+ if ($goodsIds) {
|
|
|
|
|
+ $searchWhere[] = ['g.id', 'in', $goodsIds];
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $searchWhere[] = ['g.id', '=', 0]; // 没有匹配的商品
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 供应商搜索
|
|
// 供应商搜索
|