LedgerSmhChange.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. namespace app\admin\controller\ledger;
  3. use app\common\controller\Backend;
  4. use app\common\model\UserModel;
  5. use fast\Action;
  6. use fast\RechargeStatus;
  7. use fast\RechargeType;
  8. use think\exception\DbException;
  9. use think\response\Json;
  10. /**
  11. * 算力变动明细管理
  12. *
  13. * @icon fa fa-circle-o
  14. */
  15. class LedgerSmhChange extends Backend
  16. {
  17. /**
  18. * LedgerSmhChange模型对象
  19. */
  20. protected $model = null;
  21. public function _initialize()
  22. {
  23. parent::_initialize();
  24. $this->model = new \app\common\model\LedgerSmhChangeModel();
  25. }
  26. /**
  27. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  28. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  29. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  30. */
  31. /**
  32. * 查看
  33. *
  34. * @return string|Json
  35. * @throws \think\Exception
  36. * @throws DbException
  37. */
  38. public function index()
  39. {
  40. //设置过滤方法
  41. $this->request->filter(['strip_tags', 'trim']);
  42. if (false === $this->request->isAjax()) {
  43. return $this->view->fetch();
  44. }
  45. //如果发送的来源是 Selectpage,则转发到 Selectpage
  46. if ($this->request->request('keyField')) {
  47. return $this->selectpage();
  48. }
  49. [$where, $sort, $order, $offset, $limit] = $this->buildparams();
  50. $list = $this->model->alias('r')
  51. ->join('user u','r.user_id=u.id','LEFT')
  52. ->where($where)
  53. ->field('r.*,u.address')
  54. ->order($sort, $order)
  55. ->paginate($limit);
  56. foreach ($list as $k => $v) {
  57. $list[$k]['address'] = (new UserModel())->getById($v['user_id'])['address'];
  58. }
  59. $result = ['total' => $list->total(), 'rows' => $list->items()];
  60. return json($result);
  61. }
  62. }