Shopgoodscategory.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * Shopcategory.php
  4. * Niushop商城系统 - 团队十年电商经验汇集巨献!
  5. * =========================================================
  6. * Copy right 2015-2025 山西牛酷信息科技有限公司, 保留所有权利。
  7. * ----------------------------------------------
  8. * 官方网址: http://www.niushop.com.cn
  9. * 这不是一个自由软件!您只能在不用于商业目的的前提下对程序代码进行修改和使用。
  10. * 任何企业和个人不允许对程序代码以任何形式任何目的再发布。
  11. * =========================================================
  12. * @author : niuteam
  13. * @date : 2015.1.17
  14. * @version : v1.0.0.0
  15. */
  16. namespace app\api\controller;
  17. use app\model\goods\GoodsShopCategory as GoodsShopCategoryModel;
  18. /**
  19. * 店铺商品分类
  20. * Class Shopcategory
  21. * @package app\api\controller
  22. */
  23. class Shopgoodscategory extends BaseApi
  24. {
  25. /**
  26. * 树状结构信息
  27. */
  28. public function tree()
  29. {
  30. $site_id = isset($this->params['site_id']) ? $this->params['site_id'] : 0;
  31. $level = isset($this->params['level']) ? $this->params['level'] : 2;// 分类等级 1 2
  32. $template = isset($this->params['template']) ? $this->params['template'] : 2;// 模板 1:无图,2:有图,3:有商品
  33. if (empty($site_id)) {
  34. return $this->response($this->error('', 'REQUEST_SITE_ID'));
  35. }
  36. $condition = [
  37. [ 'site_id', "=", $site_id ],
  38. [ 'is_show', '=', 1 ],
  39. [ 'level', '<=', $level ]
  40. ];
  41. $goods_category_model = new GoodsShopCategoryModel();
  42. $list = $goods_category_model->getShopCategoryTree($condition);
  43. return $this->response($list);
  44. }
  45. }