Просмотр исходного кода

获取所以子集分类数据

林海涛 1 год назад
Родитель
Сommit
911a684c4a

+ 112 - 0
app/adminapi/controller/goods/GoodsController.php

@@ -0,0 +1,112 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+
+namespace app\adminapi\controller\goods;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\goods\GoodsLists;
+use app\adminapi\logic\goods\GoodsLogic;
+use app\adminapi\validate\goods\GoodsValidate;
+
+
+/**
+ * Goods控制器
+ * Class GoodsController
+ * @package app\adminapi\controller\goods
+ */
+class GoodsController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 18:37
+     */
+    public function lists()
+    {
+        return $this->dataLists(new GoodsLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 18:37
+     */
+    public function add()
+    {
+        $params = (new GoodsValidate())->post()->goCheck('add');
+        $result = GoodsLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(GoodsLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 18:37
+     */
+    public function edit()
+    {
+        $params = (new GoodsValidate())->post()->goCheck('edit');
+        $result = GoodsLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(GoodsLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 18:37
+     */
+    public function delete()
+    {
+        $params = (new GoodsValidate())->post()->goCheck('delete');
+        GoodsLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 18:37
+     */
+    public function detail()
+    {
+        $data = GoodsCategory::field('id,pid,name')
+            ->order(['weigh' => 'desc', 'id' => 'desc'])
+            ->select()
+            ->toArray();
+        $params = (new GoodsValidate())->goCheck('detail');
+        $result = GoodsLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 112 - 0
app/adminapi/controller/goods_category/GoodsCategoryController.php

@@ -0,0 +1,112 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+
+namespace app\adminapi\controller\goods_category;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\goods_category\GoodsCategoryLists;
+use app\adminapi\logic\goods_category\GoodsCategoryLogic;
+use app\adminapi\validate\goods_category\GoodsCategoryValidate;
+
+
+/**
+ * GoodsCategory控制器
+ * Class GoodsCategoryController
+ * @package app\adminapi\controller\goods_category
+ */
+class GoodsCategoryController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function lists()
+    {
+        return $this->dataLists(new GoodsCategoryLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function add()
+    {
+        $params = (new GoodsCategoryValidate())->post()->goCheck('add');
+        $result = GoodsCategoryLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(GoodsCategoryLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function edit()
+    {
+        $params = (new GoodsCategoryValidate())->post()->goCheck('edit');
+        $result = GoodsCategoryLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(GoodsCategoryLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function delete()
+    {
+        $params = (new GoodsCategoryValidate())->post()->goCheck('delete');
+        GoodsCategoryLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function detail()
+    {
+        $params = (new GoodsCategoryValidate())->goCheck('detail');
+        $result = GoodsCategoryLogic::detail($params);
+        return $this->data($result);
+    }
+
+   public function treeData()
+   {
+       $result = GoodsCategoryLogic::getTreeData();
+       return $this->data($result);
+   }
+}

+ 108 - 0
app/adminapi/controller/home_service/HomeServiceController.php

@@ -0,0 +1,108 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+
+namespace app\adminapi\controller\home_service;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\home_service\HomeServiceLists;
+use app\adminapi\logic\home_service\HomeServiceLogic;
+use app\adminapi\validate\home_service\HomeServiceValidate;
+
+
+/**
+ * HomeService控制器
+ * Class HomeServiceController
+ * @package app\adminapi\controller\home_service
+ */
+class HomeServiceController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 16:44
+     */
+    public function lists()
+    {
+        return $this->dataLists(new HomeServiceLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 16:44
+     */
+    public function add()
+    {
+        $params = (new HomeServiceValidate())->post()->goCheck('add');
+        $result = HomeServiceLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(HomeServiceLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 16:44
+     */
+    public function edit()
+    {
+        $params = (new HomeServiceValidate())->post()->goCheck('edit');
+        $result = HomeServiceLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(HomeServiceLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 16:44
+     */
+    public function delete()
+    {
+        $params = (new HomeServiceValidate())->post()->goCheck('delete');
+        HomeServiceLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 16:44
+     */
+    public function detail()
+    {
+        $params = (new HomeServiceValidate())->goCheck('detail');
+        $result = HomeServiceLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 108 - 0
app/adminapi/controller/top_ranking/TopRankingController.php

@@ -0,0 +1,108 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+
+namespace app\adminapi\controller\top_ranking;
+
+
+use app\adminapi\controller\BaseAdminController;
+use app\adminapi\lists\top_ranking\TopRankingLists;
+use app\adminapi\logic\top_ranking\TopRankingLogic;
+use app\adminapi\validate\top_ranking\TopRankingValidate;
+
+
+/**
+ * TopRanking控制器
+ * Class TopRankingController
+ * @package app\adminapi\controller\top_ranking
+ */
+class TopRankingController extends BaseAdminController
+{
+
+
+    /**
+     * @notes 获取列表
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 16:15
+     */
+    public function lists()
+    {
+        return $this->dataLists(new TopRankingLists());
+    }
+
+
+    /**
+     * @notes 添加
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 16:15
+     */
+    public function add()
+    {
+        $params = (new TopRankingValidate())->post()->goCheck('add');
+        $result = TopRankingLogic::add($params);
+        if (true === $result) {
+            return $this->success('添加成功', [], 1, 1);
+        }
+        return $this->fail(TopRankingLogic::getError());
+    }
+
+
+    /**
+     * @notes 编辑
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 16:15
+     */
+    public function edit()
+    {
+        $params = (new TopRankingValidate())->post()->goCheck('edit');
+        $result = TopRankingLogic::edit($params);
+        if (true === $result) {
+            return $this->success('编辑成功', [], 1, 1);
+        }
+        return $this->fail(TopRankingLogic::getError());
+    }
+
+
+    /**
+     * @notes 删除
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 16:15
+     */
+    public function delete()
+    {
+        $params = (new TopRankingValidate())->post()->goCheck('delete');
+        TopRankingLogic::delete($params);
+        return $this->success('删除成功', [], 1, 1);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @return \think\response\Json
+     * @author likeadmin
+     * @date 2024/07/07 16:15
+     */
+    public function detail()
+    {
+        $params = (new TopRankingValidate())->goCheck('detail');
+        $result = TopRankingLogic::detail($params);
+        return $this->data($result);
+    }
+
+
+}

+ 103 - 0
app/adminapi/lists/goods/GoodsLists.php

@@ -0,0 +1,103 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\lists\goods;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\goods\Goods;
+use app\common\lists\ListsSearchInterface;
+use app\common\model\goods_category\GoodsCategory;
+use app\common\service\FileService;
+
+
+/**
+ * Goods列表
+ * Class GoodsLists
+ * @package app\adminapi\listsgoods
+ */
+class GoodsLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/07 18:37
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['goods_status'],
+            '%like%' => ['goods_name','goods_brand'],
+            'between' => ['service_total', 'service_fee'],
+        ];
+    }
+
+    public function queryWhere()
+    {
+        $where = [];
+        if (!empty($this->params['goods_category_id'])) {
+            $goodsCategoryId = end($this->params['goods_category_id']);
+            $goodsCategoryData = GoodsCategory::where(['status'=>1])->order(['pid' => 'asc','weigh' => 'desc', 'id' => 'desc'])
+                ->select()->toArray();
+            $ids =get_tree_ids($goodsCategoryData,$goodsCategoryId);
+            $ids[] = $goodsCategoryId;
+            $where[] = ['goods_category_id','in' ,$ids];
+        }
+        return $where;
+    }
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/07/07 18:37
+     */
+    public function lists(): array
+    {
+        $lists = Goods::order(['id' => 'desc'])
+            ->where($this->searchWhere)
+            ->where($this->queryWhere())
+            ->limit($this->limitOffset, $this->limitLength)
+            ->select()
+            ->toArray();
+        $goodsCategoryObj = GoodsCategory::where(['status'=>1])->order(['pid' => 'asc','weigh' => 'desc', 'id' => 'desc'])
+            ->select();
+        foreach ($lists as &$item) {
+            $item['goods_category_ids'] = array_map("intval",$item['goods_category_ids']);
+            $item['goods_category_ids_str'] = implode(' / ',$goodsCategoryObj->whereIn('id', $item['goods_category_ids'])->column('name'));
+            $item['goods_image'] = $item['goods_image'] ?  FileService::getFileUrl($item['goods_image']):null;
+            $item['goods_video'] = $item['goods_video'] ? FileService::getFileUrl($item['goods_video']):null;
+        }
+        return $lists;
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/07/07 18:37
+     */
+    public function count(): int
+    {
+        return Goods::where($this->searchWhere)->count();
+    }
+
+}

+ 78 - 0
app/adminapi/lists/goods_category/GoodsCategoryLists.php

@@ -0,0 +1,78 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\lists\goods_category;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\goods_category\GoodsCategory;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * GoodsCategory列表
+ * Class GoodsCategoryLists
+ * @package app\adminapi\listsgoods_category
+ */
+class GoodsCategoryLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['category_type', 'name', 'is_goods', 'status'],

+        ];
+    }
+
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function lists(): array
+    {
+        $lists = GoodsCategory::where($this->searchWhere)
+            ->field(['id', 'pid', 'category_type', 'name', 'is_goods', 'status', 'weigh'])
+            ->order(['id' => 'desc'])
+            ->select()
+            ->toArray();
+
+        return linear_to_tree($lists, 'children', 'id', 'pid');
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function count(): int
+    {
+        return GoodsCategory::where($this->searchWhere)->count();
+    }
+
+}

+ 87 - 0
app/adminapi/lists/home_service/HomeServiceLists.php

@@ -0,0 +1,87 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\lists\home_service;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\home_service\HomeService;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * HomeService列表
+ * Class HomeServiceLists
+ * @package app\adminapi\listshome_service
+ */
+class HomeServiceLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/07 16:44
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['name',],
+        ];
+    }
+
+    public function queryWhere(){
+        $where = [];
+        // 用户余额
+        if (isset($this->params['goods_id']) && is_array($this->params['goods_id'])) {
+            $where[] = ['goods_id', 'in',$this->params['goods_id']];
+        }
+        return $where;
+    }
+
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/07/07 16:44
+     */
+    public function lists(): array
+    {
+        return HomeService::with('goods')
+            ->where($this->searchWhere)
+            ->where($this->queryWhere())
+            ->field(['id', 'name', 'goods_id', 'picture', 'sort'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['sort' => 'desc','id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/07/07 16:44
+     */
+    public function count(): int
+    {
+        return HomeService::where($this->searchWhere)->count();
+    }
+
+}

+ 87 - 0
app/adminapi/lists/top_ranking/TopRankingLists.php

@@ -0,0 +1,87 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\lists\top_ranking;
+
+
+use app\adminapi\lists\BaseAdminDataLists;
+use app\common\model\top_ranking\TopRanking;
+use app\common\lists\ListsSearchInterface;
+
+
+/**
+ * TopRanking列表
+ * Class TopRankingLists
+ * @package app\adminapi\liststop_ranking
+ */
+class TopRankingLists extends BaseAdminDataLists implements ListsSearchInterface
+{
+
+
+    /**
+     * @notes 设置搜索条件
+     * @return \string[][]
+     * @author likeadmin
+     * @date 2024/07/07 16:15
+     */
+    public function setSearch(): array
+    {
+        return [
+            '=' => ['name'],
+
+        ];
+    }
+
+    public function queryWhere(){
+        $where = [];
+        // 用户余额
+        if (isset($this->params['goods_id']) && is_array($this->params['goods_id'])) {
+            $where[] = ['goods_id', 'in',$this->params['goods_id']];
+        }
+        return $where;
+    }
+    /**
+     * @notes 获取列表
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author likeadmin
+     * @date 2024/07/07 16:15
+     */
+    public function lists(): array
+    {
+        return TopRanking::with('goods')
+            ->where($this->searchWhere)
+            ->where($this->queryWhere())
+            ->field(['id', 'name', 'goods_id', 'sort'])
+            ->limit($this->limitOffset, $this->limitLength)
+            ->order(['sort' => 'desc','id' => 'desc'])
+            ->select()
+            ->toArray();
+    }
+
+
+    /**
+     * @notes 获取数量
+     * @return int
+     * @author likeadmin
+     * @date 2024/07/07 16:15
+     */
+    public function count(): int
+    {
+        return TopRanking::where($this->searchWhere)->count();
+    }
+
+}

+ 139 - 0
app/adminapi/logic/goods/GoodsLogic.php

@@ -0,0 +1,139 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\logic\goods;
+
+
+use app\common\model\goods\Goods;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * Goods逻辑
+ * Class GoodsLogic
+ * @package app\adminapi\logic\goods
+ */
+class GoodsLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/07 18:37
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            $params['goods_category_id'] = end($params['goods_category_ids']);
+            Goods::create([
+                'goods_category_ids' => json_encode($params['goods_category_ids'],true),
+                'goods_category_id' => $params['goods_category_id'],
+                'goods_name' => $params['goods_name'],
+                'goods_image' => $params['goods_image'],
+                'goods_video' => $params['goods_video'],
+                'goods_number' => $params['goods_number'],
+                'good_unit' => $params['good_unit'],
+                'goods_size' => $params['goods_size'],
+                'goods_type' => $params['goods_type'],
+                'goods_brand' => $params['goods_brand'],
+                'install_guide' => $params['install_guide'],
+                'base_service_fee' => $params['base_service_fee'],
+                'service_total' => $params['service_total'],
+                'service_fee' => $params['service_fee'],
+                'service_image' => $params['service_image'],
+                'fee_schedule' => $params['fee_schedule'],
+                'goods_status' => $params['goods_status'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/07 18:37
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            Goods::where('id', $params['id'])->update([
+                'goods_category_ids' => $params['goods_category_ids'],
+                'goods_category_id' => $params['goods_category_id'],
+                'goods_name' => $params['goods_name'],
+                'goods_image' => $params['goods_image'],
+                'goods_video' => $params['goods_video'],
+                'goods_number' => $params['goods_number'],
+                'good_unit' => $params['good_unit'],
+                'goods_size' => $params['goods_size'],
+                'goods_type' => $params['goods_type'],
+                'goods_brand' => $params['goods_brand'],
+                'install_guide' => $params['install_guide'],
+                'base_service_fee' => $params['base_service_fee'],
+                'service_total' => $params['service_total'],
+                'service_fee' => $params['service_fee'],
+                'service_image' => $params['service_image'],
+                'fee_schedule' => $params['fee_schedule'],
+                'goods_status' => $params['goods_status'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/07 18:37
+     */
+    public static function delete(array $params): bool
+    {
+        return Goods::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/07/07 18:37
+     */
+    public static function detail($params): array
+    {
+        return Goods::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 131 - 0
app/adminapi/logic/goods_category/GoodsCategoryLogic.php

@@ -0,0 +1,131 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\logic\goods_category;
+
+
+use app\common\model\goods_category\GoodsCategory;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * GoodsCategory逻辑
+ * Class GoodsCategoryLogic
+ * @package app\adminapi\logic\goods_category
+ */
+class GoodsCategoryLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            GoodsCategory::create([
+                'pid' => $params['pid'],
+                'category_type' => $params['category_type'],
+                'name' => $params['name'],
+                'is_goods' => $params['is_goods'],
+                'status' => $params['status'],
+                'weigh' => $params['weigh'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            GoodsCategory::where('id', $params['id'])->update([
+                'pid' => $params['pid'],
+                'category_type' => $params['category_type'],
+                'name' => $params['name'],
+                'is_goods' => $params['is_goods'],
+                'status' => $params['status'],
+                'weigh' => $params['weigh'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public static function delete(array $params): bool
+    {
+        return GoodsCategory::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public static function detail($params): array
+    {
+        return GoodsCategory::findOrEmpty($params['id'])->toArray();
+    }
+
+    public static function getTreeData():array
+    {
+        $data = GoodsCategory::field('id,pid,name')
+            ->where('status', 1)
+            ->order(['weigh' => 'desc', 'id' => 'desc'])
+            ->select()
+            ->toArray();
+        foreach($data as $k => $v){
+            $v['label'] = $v['name'];
+            $v['value'] = $v['id'];
+            $data[$k] = $v;
+        }
+        return linear_to_tree($data, 'children');
+    }
+}

+ 112 - 0
app/adminapi/logic/home_service/HomeServiceLogic.php

@@ -0,0 +1,112 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\logic\home_service;
+
+
+use app\common\model\home_service\HomeService;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * HomeService逻辑
+ * Class HomeServiceLogic
+ * @package app\adminapi\logic\home_service
+ */
+class HomeServiceLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/07 16:44
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            HomeService::create([
+                'name' => $params['name'],
+                'goods_id' => $params['goods_id'],
+                'picture' => $params['picture'],
+                'sort' => $params['sort'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/07 16:44
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            HomeService::where('id', $params['id'])->update([
+                'name' => $params['name'],
+                'goods_id' => $params['goods_id'],
+                'picture' => $params['picture'],
+                'sort' => $params['sort'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/07 16:44
+     */
+    public static function delete(array $params): bool
+    {
+        return HomeService::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/07/07 16:44
+     */
+    public static function detail($params): array
+    {
+        return HomeService::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 110 - 0
app/adminapi/logic/top_ranking/TopRankingLogic.php

@@ -0,0 +1,110 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\logic\top_ranking;
+
+
+use app\common\model\top_ranking\TopRanking;
+use app\common\logic\BaseLogic;
+use think\facade\Db;
+
+
+/**
+ * TopRanking逻辑
+ * Class TopRankingLogic
+ * @package app\adminapi\logic\top_ranking
+ */
+class TopRankingLogic extends BaseLogic
+{
+
+
+    /**
+     * @notes 添加
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/07 16:15
+     */
+    public static function add(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            TopRanking::create([
+                'name' => $params['name'],
+                'goods_id' => $params['goods_id'],
+                'sort' => $params['sort'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 编辑
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/07 16:15
+     */
+    public static function edit(array $params): bool
+    {
+        Db::startTrans();
+        try {
+            TopRanking::where('id', $params['id'])->update([
+                'name' => $params['name'],
+                'goods_id' => $params['goods_id'],
+                'sort' => $params['sort'],
+            ]);
+
+            Db::commit();
+            return true;
+        } catch (\Exception $e) {
+            Db::rollback();
+            self::setError($e->getMessage());
+            return false;
+        }
+    }
+
+
+    /**
+     * @notes 删除
+     * @param array $params
+     * @return bool
+     * @author likeadmin
+     * @date 2024/07/07 16:15
+     */
+    public static function delete(array $params): bool
+    {
+        return TopRanking::destroy($params['id']);
+    }
+
+
+    /**
+     * @notes 获取详情
+     * @param $params
+     * @return array
+     * @author likeadmin
+     * @date 2024/07/07 16:15
+     */
+    public static function detail($params): array
+    {
+        return TopRanking::findOrEmpty($params['id'])->toArray();
+    }
+}

+ 110 - 0
app/adminapi/validate/goods/GoodsValidate.php

@@ -0,0 +1,110 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\validate\goods;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * Goods验证器
+ * Class GoodsValidate
+ * @package app\adminapi\validate\goods
+ */
+class GoodsValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'goods_category_ids' => 'require',
+        'goods_name' => 'require',
+        'goods_number' => 'require',
+        'base_service_fee' => 'require',
+        'service_total' => 'require',
+        'service_fee' => 'require',
+        'goods_status' => 'require',
+
+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'goods_category_ids' => '服务类目',
+        'goods_name' => '商品名称',
+        'goods_number' => '商品数量',
+        'base_service_fee' => '基础服务费',
+        'service_total' => '服务原价',
+        'service_fee' => '服务价格',
+        'goods_status' => '商品状态',
+
+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return GoodsValidate
+     * @author likeadmin
+     * @date 2024/07/07 18:37
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['goods_category_ids','goods_category_id','goods_name','goods_number','base_service_fee','service_total','service_fee','goods_status']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return GoodsValidate
+     * @author likeadmin
+     * @date 2024/07/07 18:37
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','goods_category_ids','goods_category_id','goods_name','goods_number','base_service_fee','service_total','service_fee','goods_status']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return GoodsValidate
+     * @author likeadmin
+     * @date 2024/07/07 18:37
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return GoodsValidate
+     * @author likeadmin
+     * @date 2024/07/07 18:37
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 106 - 0
app/adminapi/validate/goods_category/GoodsCategoryValidate.php

@@ -0,0 +1,106 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\validate\goods_category;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * GoodsCategory验证器
+ * Class GoodsCategoryValidate
+ * @package app\adminapi\validate\goods_category
+ */
+class GoodsCategoryValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'pid' => 'require',
+        'category_type' => 'require',
+        'name' => 'require',
+        'is_goods' => 'require',
+        'status' => 'require',
+        'weigh' => 'require',

+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'pid' => '父级ID',
+        'category_type' => '服务类型',
+        'name' => '名称',
+        'is_goods' => '服务产品',
+        'status' => '状态',
+        'weigh' => '权重',

+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return GoodsCategoryValidate
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['pid','category_type','name','is_goods','status','weigh']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return GoodsCategoryValidate
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','pid','category_type','name','is_goods','status','weigh']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return GoodsCategoryValidate
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return GoodsCategoryValidate
+     * @author likeadmin
+     * @date 2024/07/07 18:23
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 100 - 0
app/adminapi/validate/home_service/HomeServiceValidate.php

@@ -0,0 +1,100 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\validate\home_service;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * HomeService验证器
+ * Class HomeServiceValidate
+ * @package app\adminapi\validate\home_service
+ */
+class HomeServiceValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'name' => 'require',
+        'goods_id' => 'require',
+        'picture' => 'require',

+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'name' => '名称',
+        'goods_id' => '商品ID',
+        'picture' => '图片',

+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return HomeServiceValidate
+     * @author likeadmin
+     * @date 2024/07/07 16:44
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['name','goods_id','picture']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return HomeServiceValidate
+     * @author likeadmin
+     * @date 2024/07/07 16:44
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','name','goods_id','picture']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return HomeServiceValidate
+     * @author likeadmin
+     * @date 2024/07/07 16:44
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return HomeServiceValidate
+     * @author likeadmin
+     * @date 2024/07/07 16:44
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 98 - 0
app/adminapi/validate/top_ranking/TopRankingValidate.php

@@ -0,0 +1,98 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\adminapi\validate\top_ranking;
+
+
+use app\common\validate\BaseValidate;
+
+
+/**
+ * TopRanking验证器
+ * Class TopRankingValidate
+ * @package app\adminapi\validate\top_ranking
+ */
+class TopRankingValidate extends BaseValidate
+{
+
+     /**
+      * 设置校验规则
+      * @var string[]
+      */
+    protected $rule = [
+        'id' => 'require',
+        'name' => 'require',
+        'goods_id' => 'require',

+    ];
+
+
+    /**
+     * 参数描述
+     * @var string[]
+     */
+    protected $field = [
+        'id' => 'id',
+        'name' => '名称',
+        'goods_id' => '商品ID',

+    ];
+
+
+    /**
+     * @notes 添加场景
+     * @return TopRankingValidate
+     * @author likeadmin
+     * @date 2024/07/07 16:15
+     */
+    public function sceneAdd()
+    {
+        return $this->only(['name','goods_id']);
+    }
+
+
+    /**
+     * @notes 编辑场景
+     * @return TopRankingValidate
+     * @author likeadmin
+     * @date 2024/07/07 16:15
+     */
+    public function sceneEdit()
+    {
+        return $this->only(['id','name','goods_id']);
+    }
+
+
+    /**
+     * @notes 删除场景
+     * @return TopRankingValidate
+     * @author likeadmin
+     * @date 2024/07/07 16:15
+     */
+    public function sceneDelete()
+    {
+        return $this->only(['id']);
+    }
+
+
+    /**
+     * @notes 详情场景
+     * @return TopRankingValidate
+     * @author likeadmin
+     * @date 2024/07/07 16:15
+     */
+    public function sceneDetail()
+    {
+        return $this->only(['id']);
+    }
+
+}

+ 24 - 0
app/common.php

@@ -112,6 +112,30 @@ function linear_to_tree($data, $sub_key_name = 'sub', $id_name = 'id', $parent_i
     return $tree;
 }
 
+/**
+ * 根据父级ID获取所有子集的值
+ * @param $data
+ * @param $pid
+ * @param $idField
+ * @param $pidField
+ * @return array
+ */
+function get_tree_ids($data,$pid = 0, $idField = 'id',$pidField = 'pid')
+{
+
+    $child = [];
+    foreach($data as $val){
+        if ($val[$pidField] == $pid) {
+            $children = get_tree_ids($data, $val[$idField],$idField,$pidField,);
+            if ( count($children) > 0) {
+                $child = array_merge($child,$children);
+            }
+            $child[] = $val['id'];
+        }
+    }
+    return $child;
+}
+
 
 /**
  * @notes 删除目标目录

+ 36 - 0
app/common/model/goods/Goods.php

@@ -0,0 +1,36 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model\goods;
+
+
+use app\common\model\BaseModel;
+
+
+
+/**
+ * Goods模型
+ * Class Goods
+ * @package app\common\model\goods
+ */
+class Goods extends BaseModel
+{
+    
+    protected $name = 'goods';
+
+
+    protected $type = [
+        'goods_category_ids' =>  'array',
+    ];
+}

+ 34 - 0
app/common/model/goods_category/GoodsCategory.php

@@ -0,0 +1,34 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model\goods_category;
+
+
+use app\common\model\BaseModel;
+
+
+
+/**
+ * GoodsCategory模型
+ * Class GoodsCategory
+ * @package app\common\model\goods_category
+ */
+class GoodsCategory extends BaseModel
+{
+    
+    protected $name = 'goods_category';
+    
+
+    
+}

+ 36 - 0
app/common/model/home_service/HomeService.php

@@ -0,0 +1,36 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model\home_service;
+
+
+use app\common\model\BaseModel;
+use app\common\model\goods\Goods;
+
+
+/**
+ * HomeService模型
+ * Class HomeService
+ * @package app\common\model\home_service
+ */
+class HomeService extends BaseModel
+{
+    
+    protected $name = 'home_service';
+
+    public function goods(){
+        return $this->hasOne(Goods::class, 'id', 'goods_id')
+            ->field('id,goods_name');
+    }
+}

+ 37 - 0
app/common/model/top_ranking/TopRanking.php

@@ -0,0 +1,37 @@
+<?php
+// +----------------------------------------------------------------------
+// | likeadmin快速开发前后端分离管理后台(PHP版)
+// +----------------------------------------------------------------------
+// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
+// | 开源版本可自由商用,可去除界面版权logo
+// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
+// | github下载:https://github.com/likeshop-github/likeadmin
+// | 访问官网:https://www.likeadmin.cn
+// | likeadmin团队 版权所有 拥有最终解释权
+// +----------------------------------------------------------------------
+// | author: likeadminTeam
+// +----------------------------------------------------------------------
+
+namespace app\common\model\top_ranking;
+
+
+use app\common\model\BaseModel;
+use app\common\model\goods\Goods;
+
+
+/**
+ * TopRanking模型
+ * Class TopRanking
+ * @package app\common\model\top_ranking
+ */
+class TopRanking extends BaseModel
+{
+    
+    protected $name = 'top_ranking';
+
+    public function goods(){
+        return $this->hasOne(Goods::class, 'id', 'goods_id')
+            ->field('id,goods_name');
+    }
+    
+}