CutterOrderDao.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace app\extra\dao\cutter;
  3. use app\extra\basic\Dao;
  4. use app\model\cutter\CutterOrder;
  5. class CutterOrderDao extends Dao
  6. {
  7. /**
  8. * 设置模型
  9. * @return string
  10. */
  11. protected function setModel(): string
  12. {
  13. return CutterOrder::class;
  14. }
  15. public function getList(array $where,string $field = '*',int $page = 0, int $limit = 0,string $order='id desc')
  16. {
  17. return $this->getModel()->where($where)->field($field)->when($page&&$limit,function($query)use($page,$limit){
  18. $query->page($page,$limit);
  19. })->with(['task','user'=>function ($query) {
  20. return $query->field(['uid','nickname','avatar']);
  21. }])->select();
  22. }
  23. public function getLst(array $where,string $field = '*',int $page = 0, int $limit = 0,string $order='id desc')
  24. {
  25. return $this->getModel()->where($where)->field($field)->when($page&&$limit,function($query)use($page,$limit){
  26. $query->page($page,$limit);
  27. })->with('task')->order($order)->select();
  28. }
  29. public function getDetails(array $where,string $field = '*')
  30. {
  31. return $this->getModel()->where($where)->field($field)->with(['task'=>function($query){
  32. $query->withField('id,title,explain,material,price,end_time,hot,kefu_id,created_at')->with(['kefu'=>function($query){
  33. $query->field('id,name,wechat,phone,qrcode');
  34. }])->withCount(['orderCount'=>'people']);
  35. }])->findOrEmpty();
  36. }
  37. public function getOrder(array $where,string $field = '*')
  38. {
  39. return $this->getModel()->where($where)->field($field)->with('task')->findOrEmpty();
  40. }
  41. }