UserEquityLists.php 871 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. namespace app\api\lists;
  3. use app\common\model\equity\UserEquity;
  4. class UserEquityLists extends BaseApiDataLists
  5. {
  6. public function queryWhere()
  7. {
  8. $where = [];
  9. $where[] = ['user_id','=',$this->userId];
  10. $where[] = ['number','>',0];
  11. $where[] = ['end_time','>=',time()];
  12. if(isset($this->params['goods_id']) && !empty($this->params['goods_id'])){
  13. $where[] = ['goods_id','=',$this->params['goods_id']];
  14. }
  15. return $where;
  16. }
  17. public function lists():array
  18. {
  19. return UserEquity::with(['equityConfig'])->where($this->queryWhere())
  20. ->limit($this->limitOffset, $this->limitLength)
  21. ->order('create_time desc')
  22. ->select()
  23. ->toArray();
  24. }
  25. public function count(): int
  26. {
  27. return UserEquity::where($this->queryWhere())->count();
  28. }
  29. }