OrderEffectiveLogLists.php 1008 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace app\api\lists;
  3. use app\common\model\orders\OrderEffectiveLog;
  4. /**
  5. * @author 林海涛
  6. * @date 2024/7/24 下午3:29
  7. */
  8. class OrderEffectiveLogLists extends BaseApiDataLists
  9. {
  10. public function queryWhere()
  11. {
  12. $where = [];
  13. $where[] = ['user_id','=',$this->userId];
  14. $where[] = ['end_effective_time','>=',time()];
  15. return $where;
  16. }
  17. public function lists():array
  18. {
  19. return OrderEffectiveLog::with(['goods'=>function ($query) {
  20. $query->field(['id','goods_name','goods_image']);
  21. }])->where($this->queryWhere())
  22. ->limit($this->limitOffset, $this->limitLength)
  23. ->field(['id','goods_id','sn','effective_unit','effective_num','remark','end_effective_time'])
  24. ->append(['effective_unit_text'])
  25. ->order('create_time desc')
  26. ->select()
  27. ->toArray();
  28. }
  29. public function count(): int
  30. {
  31. return OrderEffectiveLog::where($this->queryWhere())->count();
  32. }
  33. }