TrafficInfoLists.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\shopapi\lists;
  20. use app\common\enum\AccountLogEnum;
  21. use app\common\lists\ListsSearchInterface;
  22. use app\common\model\Article;
  23. use app\common\model\Info;
  24. use app\common\model\InfoCategory;
  25. use app\common\model\Banner;
  26. class TrafficInfoLists extends BaseShopDataLists
  27. {
  28. public function setSearchWhere(){
  29. $where[]=['is_show','=',1];
  30. $params = $this->params;
  31. if(isset($params['type']) && $params['type']<>''){
  32. $where[] = ['type','=',$params['type']];
  33. }
  34. if(isset($params['cid']) && $params['cid']<>''){
  35. $where[] = ['cid','in',$params['cid']];
  36. }
  37. return $where;
  38. }
  39. /**
  40. * @notes 宣传信息列表
  41. * @return array
  42. * @throws \think\db\exception\DataNotFoundException
  43. * @throws \think\db\exception\DbException
  44. * @throws \think\db\exception\ModelNotFoundException
  45. * @author Tab
  46. * @date 2021/7/14 9:48
  47. */
  48. public function lists(): array
  49. {
  50. $lists = Info::field('id,type,cid,title,synopsis,image,address,phone,latitude,longitude,sort,is_show,create_time')
  51. ->where(['is_show'=>1])
  52. ->where($this->setSearchWhere())
  53. ->append(['category','type_desc','is_show_desc'])
  54. ->order([
  55. 'sort' => 'desc',
  56. 'id' => 'desc'
  57. ])
  58. ->limit($this->limitOffset, $this->limitLength)
  59. ->select()
  60. ->toArray();
  61. $data['info_list'] = $lists;
  62. return $data;
  63. }
  64. /**
  65. * @notes 文章/帮助总记录数
  66. * @return int
  67. * @author Tab
  68. * @date 2021/7/14 9:48
  69. */
  70. public function count(): int
  71. {
  72. return Info::where($this->setSearchWhere())->count();
  73. }
  74. }