NoticeLists.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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\NoticeEnum;
  21. use app\common\lists\BaseDataLists;
  22. use app\common\model\Notice;
  23. /**
  24. * 通知列表
  25. * Class NoticeLists
  26. * @package app\shopapi\lists
  27. */
  28. class NoticeLists extends BaseShopDataLists
  29. {
  30. public function setSearch()
  31. {
  32. $this->searchWhere = [
  33. ['user_id', '=', $this->userId],
  34. ['send_type', '=', NoticeEnum::SYSTEM]
  35. ];
  36. // 系统通知
  37. if (isset($this->params['type']) && $this->params['type'] == 'system') {
  38. $this->searchWhere[] = [
  39. ['scene_id', '<>', NoticeEnum::EARNINGS_NOTICE]
  40. ];
  41. }
  42. // 收益通知
  43. if (isset($this->params['type']) && $this->params['type'] == 'earnings') {
  44. $this->searchWhere[] = [
  45. ['scene_id', '=', NoticeEnum::EARNINGS_NOTICE]
  46. ];
  47. }
  48. }
  49. /**
  50. * @notes 列表
  51. * @return array
  52. * @throws \think\db\exception\DataNotFoundException
  53. * @throws \think\db\exception\DbException
  54. * @throws \think\db\exception\ModelNotFoundException
  55. * @author Tab
  56. * @date 2021/8/25 10:39
  57. */
  58. public function lists(): array
  59. {
  60. $this->setSearch();
  61. $lists = Notice::field('id,title,content,create_time')
  62. ->where($this->searchWhere)
  63. ->order('id', 'desc')
  64. ->limit($this->limitOffset, $this->limitLength)
  65. ->select()
  66. ->toArray();
  67. return $lists;
  68. }
  69. /**
  70. * @notes 记录数
  71. * @return int
  72. * @author Tab
  73. * @date 2021/8/25 10:39
  74. */
  75. public function count(): int
  76. {
  77. $this->setSearch();
  78. $count = Notice::where($this->searchWhere)->count();
  79. return $count;
  80. }
  81. }