mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-05-22 06:49:15 +08:00
修改模型方法名称
This commit is contained in:
parent
935dd521b6
commit
9e17f2107c
@ -24,7 +24,7 @@ class Goods extends Controller
|
|||||||
*/
|
*/
|
||||||
public function getCate()
|
public function getCate()
|
||||||
{
|
{
|
||||||
$this->success('获取分类成功', ShopGoodsCate::getTreeData());
|
$this->success('获取分类成功', ShopGoodsCate::treeJson());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,7 +70,7 @@ class Goods extends Controller
|
|||||||
protected function _page_filter(array &$data)
|
protected function _page_filter(array &$data)
|
||||||
{
|
{
|
||||||
$this->marks = ShopGoodsMark::items();
|
$this->marks = ShopGoodsMark::items();
|
||||||
$this->cates = ShopGoodsCate::getLevelData();
|
$this->cates = ShopGoodsCate::treeTable(true);
|
||||||
GoodsService::instance()->bindData($data, false);
|
GoodsService::instance()->bindData($data, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +136,7 @@ class Goods extends Controller
|
|||||||
$data['cateids'] = str2arr($data['cateids'] ?? '');
|
$data['cateids'] = str2arr($data['cateids'] ?? '');
|
||||||
// 其他表单数据
|
// 其他表单数据
|
||||||
$this->marks = ShopGoodsMark::items();
|
$this->marks = ShopGoodsMark::items();
|
||||||
$this->cates = ShopGoodsCate::getLevelData();
|
$this->cates = ShopGoodsCate::treeTable();
|
||||||
$this->trucks = ExpressService::instance()->templates();
|
$this->trucks = ExpressService::instance()->templates();
|
||||||
$this->upgrades = UserUpgradeService::instance()->levels();
|
$this->upgrades = UserUpgradeService::instance()->levels();
|
||||||
$this->payments = BaseUserPayment::mk()->where(['status' => 1, 'deleted' => 0])->order('sort desc,id desc')->column('type,code,name', 'code');
|
$this->payments = BaseUserPayment::mk()->where(['status' => 1, 'deleted' => 0])->order('sort desc,id desc')->column('type,code,name', 'code');
|
||||||
|
@ -41,7 +41,7 @@ class ShopGoodsCate extends Model
|
|||||||
* @throws \think\db\exception\DbException
|
* @throws \think\db\exception\DbException
|
||||||
* @throws \think\db\exception\ModelNotFoundException
|
* @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');
|
$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());
|
return DataExtend::arr2tree($query->withoutField('sort,status,deleted,create_at')->select()->toArray());
|
||||||
@ -52,7 +52,7 @@ class ShopGoodsCate extends Model
|
|||||||
* @param bool $simple 仅子级别
|
* @param bool $simple 仅子级别
|
||||||
* @return array
|
* @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');
|
$query = static::mk()->where(['status' => 1])->order('sort desc,id asc');
|
||||||
$cates = array_column(DataExtend::arr2table($query->column('id,pid,name', 'id')), null, 'id');
|
$cates = array_column(DataExtend::arr2table($query->column('id,pid,name', 'id')), null, 'id');
|
||||||
|
@ -70,7 +70,7 @@ class GoodsService extends Service
|
|||||||
public function bindData(array &$data = [], bool $simple = true): array
|
public function bindData(array &$data = [], bool $simple = true): array
|
||||||
{
|
{
|
||||||
$marks = ShopGoodsMark::items();
|
$marks = ShopGoodsMark::items();
|
||||||
$cates = ShopGoodsCate::getLevelData();
|
$cates = ShopGoodsCate::treeTable();
|
||||||
$codes = array_unique(array_column($data, 'code'));
|
$codes = array_unique(array_column($data, 'code'));
|
||||||
$items = ShopGoodsItem::mk()->whereIn('goods_code', $codes)->where(['status' => 1])->select()->toArray();
|
$items = ShopGoodsItem::mk()->whereIn('goods_code', $codes)->where(['status' => 1])->select()->toArray();
|
||||||
foreach ($data as &$vo) {
|
foreach ($data as &$vo) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user