UserMining.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace app\models\mining;
  3. use app\models\user\User;
  4. use crmeb\basic\BaseModel;
  5. use crmeb\traits\ModelTrait;
  6. class UserMining extends BaseModel
  7. {
  8. /**
  9. * 数据表主键
  10. * @var string
  11. */
  12. protected $pk = 'id';
  13. /**
  14. * 模型名称
  15. * @var string
  16. */
  17. protected $name = 'user_mining';
  18. use ModelTrait;
  19. public static function getList($where)
  20. {
  21. $model = new self();
  22. if (isset($where['uid']) && $where['uid']) {
  23. if (is_array($where['uid'])) {
  24. $umid = UserMiningMachine::where('uid', 'in', $where['uid'])->column('id');
  25. } else {
  26. $umid = UserMiningMachine::where('uid', $where['uid'])->column('id');
  27. }
  28. $model = $model->where('umid', 'in', $umid);
  29. }
  30. if (isset($where['type']) && $where['type']) $model = $model->where('get_money_type', $where['type']);
  31. $model = $model->order('id desc');
  32. $data = ($data = $model->page((int)$where['page'], (int)$where['limit'])->select()->each(function ($item) {
  33. $item['user_machine'] = UserMiningMachine::get($item['umid']);
  34. $item['machine'] = MiningMachine::get($item['user_machine']['mid']);
  35. })) && count($data) ? $data->toArray() : [];
  36. $count = $model->count();
  37. return compact('count', 'data');
  38. }
  39. }