MoneyLog.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. protected $relationSearch = true;
  17. protected $searchFields = 'id,user_id';
  18. public function _initialize()
  19. {
  20. parent::_initialize();
  21. $this->model = new \app\common\model\MoneyLog;
  22. $this->assignconfig('user_id', $this->request->param('ids/d', 0));
  23. }
  24. /**
  25. * 查看
  26. * @return string|Json
  27. * @throws \think\Exception
  28. * @throws DbException
  29. */
  30. public function index()
  31. {
  32. //设置过滤方法
  33. $this->request->filter(['strip_tags', 'trim']);
  34. if (false === $this->request->isAjax()) {
  35. return $this->view->fetch();
  36. }
  37. //如果发送的来源是 Selectpage,则转发到 Selectpage
  38. if ($this->request->request('keyField')) {
  39. return $this->selectpage();
  40. }
  41. [$where, $sort, $order, $offset, $limit] = $this->buildparams();
  42. $map = [];
  43. $user_id = $this->request->param('user_id/d', 0);
  44. if($user_id > 0) $map['user_id'] = $user_id ;
  45. $list = $this->model->with('users,fromuser')
  46. ->where($where)->where($map)
  47. ->order($sort, $order)
  48. ->paginate($limit);
  49. $result = ['total' => $list->total(), 'rows' => $list->items()];
  50. return json($result);
  51. }
  52. }