FirmOrderLists.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <?php
  2. namespace app\api\lists\recharge;
  3. use app\api\lists\BaseApiDataLists;
  4. use app\common\lists\ListsSearchInterface;
  5. use app\common\model\recharge\RechargeOrder;
  6. /**
  7. * @author 林海涛
  8. * @date 2024/7/15 上午10:14
  9. */
  10. class FirmOrderLists extends BaseApiDataLists implements ListsSearchInterface
  11. {
  12. public function setSearch(): array
  13. {
  14. return [
  15. '=' => ['sn', 'payment_type','pay_way', 'pay_status','refund_status'],
  16. ];
  17. }
  18. /**
  19. * @notes 搜索条件
  20. * @author 段誉
  21. * @date 2023/2/24 16:08
  22. */
  23. public function queryWhere()
  24. {
  25. $where = [];
  26. $where[] = ['order_type','=',0];
  27. $where[] = ['user_id','=',$this->userId];
  28. // 创建时间
  29. if (!empty($this->params['create_time'])) {
  30. $time = [strtotime($this->params['create_time'][0]), strtotime($this->params['create_time'][1])];
  31. $where[] = ['create_time', 'between', $time];
  32. }
  33. //更新时间
  34. if (!empty($this->params['update_time'])) {
  35. $time = [strtotime($this->params['update_time'][0]), strtotime($this->params['update_time'][1])];
  36. $where[] = ['update_time', 'between', $time];
  37. }
  38. if (!empty($this->params['pay_time'])) {
  39. $time = [strtotime($this->params['pay_time'][0]), strtotime($this->params['pay_time'][1])];
  40. $where[] = ['pay_time', 'between', $time];
  41. }
  42. if (!empty($this->params['pay_time'])) {
  43. $time = [strtotime($this->params['pay_time'][0]), strtotime($this->params['pay_time'][1])];
  44. $where[] = ['pay_time', 'between', $time];
  45. }
  46. return $where;
  47. }
  48. public function lists(): array
  49. {
  50. $lists = RechargeOrder::with(['order_goods'=>function ($query) {
  51. $query->visible(['goods_name','goods_image','goods_number','good_unit']);
  52. },'service_work'=>function ($query) {
  53. $query->visible(['service_status']);
  54. }])
  55. ->where($this->queryWhere())
  56. ->where($this->searchWhere)
  57. ->visible(['id','sn','order_type','order_total','order_amount','payment_type','pay_way','pay_status','create_time'])
  58. ->order('id', 'desc')
  59. ->select()
  60. ->toArray();
  61. return $lists;
  62. }
  63. /**
  64. * @notes 获取数量
  65. * @return int
  66. */
  67. public function count(): int
  68. {
  69. return RechargeOrder::where($this->queryWhere())->where($this->searchWhere)->count();
  70. }
  71. }