MoneyLog.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. namespace app\admin\controller\trade;
  3. use app\common\controller\Backend;
  4. /**
  5. * 资金变动明细管理
  6. *
  7. * @icon fa fa-circle-o
  8. */
  9. class MoneyLog extends Backend
  10. {
  11. /**
  12. * Moneylog模型对象
  13. * @var \app\admin\model\trade\Moneylog
  14. */
  15. protected $model = null;
  16. public function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->model = new \app\common\model\Moneylog;
  20. $this->assignconfig('user_id', $this->request->param('ids/d', 0));
  21. }
  22. /**
  23. * 查看
  24. * @return string|Json
  25. * @throws \think\Exception
  26. * @throws DbException
  27. */
  28. public function index()
  29. {
  30. //设置过滤方法
  31. $this->request->filter(['strip_tags', 'trim']);
  32. if (false === $this->request->isAjax()) {
  33. return $this->view->fetch();
  34. }
  35. //如果发送的来源是 Selectpage,则转发到 Selectpage
  36. if ($this->request->request('keyField')) {
  37. return $this->selectpage();
  38. }
  39. [$where, $sort, $order, $offset, $limit] = $this->buildparams();
  40. $map = [];
  41. $user_id = $this->request->param('user_id/d', 0);
  42. if($user_id > 0) $map['user_id'] = $user_id ;
  43. $list = $this->model->with('users,fromuser')
  44. ->where($where)->where($map)
  45. ->order($sort, $order)
  46. ->paginate($limit);
  47. $result = ['total' => $list->total(), 'rows' => $list->items()];
  48. return json($result);
  49. }
  50. }