修改模型方法名称

This commit is contained in:
Anyon 2022-04-15 17:02:41 +08:00
parent 935dd521b6
commit 9e17f2107c
4 changed files with 6 additions and 6 deletions

View File

@ -24,7 +24,7 @@ class Goods extends Controller
*/
public function getCate()
{
$this->success('获取分类成功', ShopGoodsCate::getTreeData());
$this->success('获取分类成功', ShopGoodsCate::treeJson());
}
/**

View File

@ -70,7 +70,7 @@ class Goods extends Controller
protected function _page_filter(array &$data)
{
$this->marks = ShopGoodsMark::items();
$this->cates = ShopGoodsCate::getLevelData();
$this->cates = ShopGoodsCate::treeTable(true);
GoodsService::instance()->bindData($data, false);
}
@ -136,7 +136,7 @@ class Goods extends Controller
$data['cateids'] = str2arr($data['cateids'] ?? '');
// 其他表单数据
$this->marks = ShopGoodsMark::items();
$this->cates = ShopGoodsCate::getLevelData();
$this->cates = ShopGoodsCate::treeTable();
$this->trucks = ExpressService::instance()->templates();
$this->upgrades = UserUpgradeService::instance()->levels();
$this->payments = BaseUserPayment::mk()->where(['status' => 1, 'deleted' => 0])->order('sort desc,id desc')->column('type,code,name', 'code');

View File

@ -41,7 +41,7 @@ class ShopGoodsCate extends Model
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function getTreeData(): array
public static function treeJson(): array
{
$query = static::mk()->where(['deleted' => 0, 'status' => 1])->order('sort desc,id desc');
return DataExtend::arr2tree($query->withoutField('sort,status,deleted,create_at')->select()->toArray());
@ -52,7 +52,7 @@ class ShopGoodsCate extends Model
* @param bool $simple 仅子级别
* @return array
*/
public static function getLevelData(bool $simple = false): array
public static function treeTable(bool $simple = false): array
{
$query = static::mk()->where(['status' => 1])->order('sort desc,id asc');
$cates = array_column(DataExtend::arr2table($query->column('id,pid,name', 'id')), null, 'id');

View File

@ -70,7 +70,7 @@ class GoodsService extends Service
public function bindData(array &$data = [], bool $simple = true): array
{
$marks = ShopGoodsMark::items();
$cates = ShopGoodsCate::getLevelData();
$cates = ShopGoodsCate::treeTable();
$codes = array_unique(array_column($data, 'code'));
$items = ShopGoodsItem::mk()->whereIn('goods_code', $codes)->where(['status' => 1])->select()->toArray();
foreach ($data as &$vo) {