DeliveryServiceDao.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 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\order;
  12. use app\dao\BaseDao;
  13. use app\model\order\DeliveryService;
  14. /**配送dao
  15. * Class DeliveryServiceDao
  16. * @package app\dao\service
  17. */
  18. class DeliveryServiceDao extends BaseDao
  19. {
  20. /**
  21. * 设置模型
  22. * @return string
  23. */
  24. protected function setModel(): string
  25. {
  26. return DeliveryService::class;
  27. }
  28. /**
  29. * 获取配送员列表
  30. * @param array $where
  31. * @param int $page
  32. * @param int $limit
  33. * @return array
  34. * @throws \think\db\exception\DataNotFoundException
  35. * @throws \think\db\exception\DbException
  36. * @throws \think\db\exception\ModelNotFoundException
  37. */
  38. public function getServiceList(array $where, int $page, int $limit)
  39. {
  40. return $this->search($where, false)->when($page && $limit, function ($query) use ($page, $limit) {
  41. $query->page($page, $limit);
  42. })->when(isset($where['noId']), function ($query) use ($where) {
  43. $query->where('id', '<>', $where['noId']);
  44. })->order('id DESC')->select()->toArray();
  45. }
  46. /**获取所有配送员列表
  47. * @return array
  48. * @throws \think\db\exception\DataNotFoundException
  49. * @throws \think\db\exception\DbException
  50. * @throws \think\db\exception\ModelNotFoundException
  51. */
  52. public function getList(int $page, int $limit)
  53. {
  54. $list = $this->getModel()->where(['status' => 1])->order('id DESC')->limit($page, $limit)->select()->toArray();
  55. foreach ($list as &$item) {
  56. $item['wx_name'] = $item['nickname'];
  57. }
  58. $count = $this->getModel()->where(['status' => 1])->count();
  59. return [$list, $count];
  60. }
  61. }