QueueAuxiliaryDao.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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\other\queue;
  12. use app\dao\BaseDao;
  13. use app\model\other\queue\QueueAuxiliary;
  14. /**
  15. * 队列辅助
  16. * Class QueueAuxiliaryDao
  17. * @package app\dao\other\queue
  18. */
  19. class QueueAuxiliaryDao extends BaseDao
  20. {
  21. /**
  22. * @return string
  23. */
  24. protected function setModel(): string
  25. {
  26. return QueueAuxiliary::class;
  27. }
  28. /**
  29. * 添加订单缓存记录
  30. * @param array $data
  31. * @return int|string
  32. */
  33. public function saveOrderCacheLog(array $data)
  34. {
  35. return $this->getModel()->insertGetId($data);
  36. }
  37. /**
  38. * 获取发货缓存数据列表
  39. * @param array $where
  40. * @param int $page
  41. * @param int $limit
  42. * @return array
  43. * @throws \think\db\exception\DataNotFoundException
  44. * @throws \think\db\exception\DbException
  45. * @throws \think\db\exception\ModelNotFoundException
  46. */
  47. public function getOrderExpreList(array $where, int $page = 0, int $limit = 0)
  48. {
  49. return $this->search($where)->when($page && $limit, function ($query) use ($page, $limit) {
  50. $query->page($page, $limit);
  51. })->order('add_time asc')->select()->toArray();
  52. }
  53. /**
  54. * 查询单条订单缓存数据
  55. * @param array $where
  56. * @return array|\think\Model|null
  57. * @throws \think\db\exception\DataNotFoundException
  58. * @throws \think\db\exception\DbException
  59. * @throws \think\db\exception\ModelNotFoundException
  60. */
  61. public function getOrderCacheOne(array $where)
  62. {
  63. return $this->search($where)->find();
  64. }
  65. /**
  66. * 获取发货记录
  67. * @param array $where
  68. * @param int $page
  69. * @param int $limit
  70. * @param string $order
  71. * @return array
  72. * @throws \think\db\exception\DataNotFoundException
  73. * @throws \think\db\exception\DbException
  74. * @throws \think\db\exception\ModelNotFoundException
  75. */
  76. public function deliveryLogList(array $where, int $page = 0, int $limit = 0, string $order = '')
  77. {
  78. foreach ($where as $k => $v) {
  79. if ($v == "") unset($where[$k]);
  80. }
  81. return $this->search($where)
  82. ->order(($order ? $order . ' ,' : '') . 'add_time desc')
  83. ->page($page, $limit)->select()->toArray();
  84. }
  85. /**
  86. * 获取某个队列的数据缓存
  87. * @param $bindingId
  88. * @param $type
  89. * @return array
  90. * @throws \think\db\exception\DataNotFoundException
  91. * @throws \think\db\exception\DbException
  92. * @throws \think\db\exception\ModelNotFoundException
  93. */
  94. public function getCacheOidList($bindingId, $type)
  95. {
  96. return $this->search(['binding_id' => $bindingId, 'type' => $type])->select()->toArray();
  97. }
  98. }