SystemTicketDao.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\dao\system;
  12. use app\dao\BaseDao;
  13. use app\model\system\SystemTicket;
  14. class SystemTicketDao extends BaseDao
  15. {
  16. protected function setModel(): string
  17. {
  18. return SystemTicket::class;
  19. }
  20. public function getConditionModel($where)
  21. {
  22. return $this->getModel()->where('is_del', 0)
  23. ->when(isset($where['keyword']) && $where['keyword'] !== '', function ($query) use ($where) {
  24. $query->where('print_name', 'like', '%' . $where['keyword'] . '%');
  25. })->when(isset($where['type']) && $where['type'] != 0, function ($query) use ($where) {
  26. $query->where('type', $where['type']);
  27. })->when(isset($where['status']) && $where['status'] !== '', function ($query) use ($where) {
  28. $query->where('status', $where['status']);
  29. })->when(isset($where['print_type']) && $where['print_type'] != 0, function ($query) use ($where) {
  30. $query->where('print_type', $where['print_type']);
  31. });
  32. }
  33. public function ticketList($where, $page = 0, $limit = 0)
  34. {
  35. return $this->getConditionModel($where)->order('id desc')->when($page != 0, function ($query) use ($page, $limit) {
  36. $query->page($page, $limit);
  37. })->select()->toArray();
  38. }
  39. public function ticketCount($where)
  40. {
  41. return $this->getConditionModel($where)->count();
  42. }
  43. }