更新分类

This commit is contained in:
shengchanzhe 2023-12-15 10:29:27 +08:00
parent 3dc7a8ce5f
commit 9616494680
2 changed files with 17 additions and 3 deletions

View File

@ -22,6 +22,7 @@ use FormBuilder\Form;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\facade\Db;
use think\facade\Route;
/**
@ -115,7 +116,7 @@ class MerchantCategoryRepository extends BaseRepository
* @Date: 2020/9/15
* @return array
*/
public function getSelect($v2=0)
public function getSelect($v2=0,$type=0)
{
$query = $this->search([])->field('merchant_category_id,category_name,background');
$list = $query->select()->toArray();
@ -126,6 +127,19 @@ class MerchantCategoryRepository extends BaseRepository
}
}
}
if($type==1){
$lists=[];
foreach($list as $k=>$v) {
if($type==1){
$find=Db::name('merchant')->where('category_id',$v['merchant_category_id'])
->where('status',1)->where('is_del',0)->cache(300)->find();
if($find){
$lists[]=$v;
}
}
}
$list=$lists;
}
return $list;
}
}

View File

@ -389,9 +389,9 @@ class MerchantIntention extends BaseController
* @Date: 2020/9/15
* @return mixed
*/
public function cateLst()
public function cateLst($type=0)
{
$lst = app()->make(MerchantCategoryRepository::class)->getSelect();
$lst = app()->make(MerchantCategoryRepository::class)->getSelect(0,$type);
return app('json')->success($lst);
}