Userscorelog.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace app\admin\controller;
  3. use app\common\controller\Backend;
  4. /**
  5. * 用户积分流水
  6. *
  7. * @icon fa fa-circle-o
  8. */
  9. class Userscorelog extends Backend
  10. {
  11. /**
  12. * Userscorelog模型对象
  13. * @var \app\admin\model\Userscorelog
  14. */
  15. protected $model = null;
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = new \app\admin\model\Userscorelog;
  20. }
  21. /**
  22. * 查看
  23. */
  24. public function index()
  25. {
  26. //当前是否为关联查询
  27. $this->relationSearch = true;
  28. //设置过滤方法
  29. $this->request->filter(['strip_tags', 'trim']);
  30. if ($this->request->isAjax()) {
  31. //如果发送的来源是Selectpage,则转发到Selectpage
  32. if ($this->request->request('keyField')) {
  33. return $this->selectpage();
  34. }
  35. list($where, $sort, $order, $offset, $limit) = $this->buildparams();
  36. $list = $this->model
  37. ->with(['user'])
  38. ->where($where)
  39. ->order($sort, $order)
  40. ->paginate($limit);
  41. foreach ($list as $row) {
  42. $row->getRelation('user')->visible(['username','nickname','mobile']);
  43. }
  44. $wallet_logtype = config('wallet.logtype');
  45. $lists = collection($list->items())->toArray();
  46. foreach ($lists as &$row) {
  47. $row['log_type_text'] = isset($wallet_logtype[$row['log_type']]) ? $wallet_logtype[$row['log_type']] : '';
  48. }
  49. $result = array("total" => $list->total(), "rows" => $lists);
  50. return json($result);
  51. }
  52. return $this->view->fetch();
  53. }
  54. }