StoreHangOrderDao.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 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\StoreHangOrder;
  14. /**
  15. * Class StoreHangOrderDao
  16. * @package app\dao\order
  17. */
  18. class StoreHangOrderDao extends BaseDao
  19. {
  20. /**
  21. * @return string
  22. */
  23. protected function setModel(): string
  24. {
  25. return StoreHangOrder::class;
  26. }
  27. /**
  28. * @param array $where
  29. * @param int $limit
  30. * @return array
  31. * @throws \think\db\exception\DataNotFoundException
  32. * @throws \think\db\exception\DbException
  33. * @throws \think\db\exception\ModelNotFoundException
  34. */
  35. public function getHang(array $where, int $limit = 50)
  36. {
  37. return $this->search($where)->with('user')->limit($limit)->order('add_time desc')->select()->toArray();
  38. }
  39. /**
  40. * 获取挂单分页
  41. * @param array $where
  42. * @param int $page
  43. * @param int $limit
  44. * @return array
  45. * @throws \think\db\exception\DataNotFoundException
  46. * @throws \think\db\exception\DbException
  47. * @throws \think\db\exception\ModelNotFoundException
  48. */
  49. public function getHangPage(array $where, int $page, int $limit)
  50. {
  51. return $this->search($where)->when(isset($where['search']) && $where['search'] !== '', function ($query) use ($where) {
  52. $query->whereIn('uid', function ($query) use ($where) {
  53. $query->name('user')->whereIn('uid', function ($query) use ($where) {
  54. $query->name('store_user')->where('store_id', $where['store_id'])->field('uid');
  55. })->where('phone|nickname', 'like', "%" . $where['search'] . "%")->field('uid');
  56. });
  57. })->with('user')->page($page, $limit)->order('add_time desc')->select()->toArray();
  58. }
  59. }