LedgerTeacAngelChange.php 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. * Teac-天使变动明细管理 ledger_teac_angel_change
  12. *
  13. * @icon fa fa-circle-o
  14. */
  15. class LedgerTeacAngelChange 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\LedgerTeacAngelChangeModel();
  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. }