LedgerTeacChange.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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变动明细管理
  12. *
  13. * @icon fa fa-circle-o
  14. */
  15. class LedgerTeacChange extends Backend
  16. {
  17. /**
  18. * LedgerPowerChange模型对象
  19. * @var \app\admin\model\LedgerPowerChange
  20. */
  21. protected $model = null;
  22. public function _initialize()
  23. {
  24. parent::_initialize();
  25. $this->model = new \app\common\model\LedgerTeacChangeModel;
  26. }
  27. /**
  28. * 查看
  29. *
  30. * @return string|Json
  31. * @throws \think\Exception
  32. * @throws DbException
  33. */
  34. public function index()
  35. {
  36. //设置过滤方法
  37. $this->request->filter(['strip_tags', 'trim']);
  38. if (false === $this->request->isAjax()) {
  39. return $this->view->fetch();
  40. }
  41. //如果发送的来源是 Selectpage,则转发到 Selectpage
  42. if ($this->request->request('keyField')) {
  43. return $this->selectpage();
  44. }
  45. [$where, $sort, $order, $offset, $limit] = $this->buildparams();
  46. $list = $this->model->alias('r')
  47. ->join('user u','r.user_id=u.id','LEFT')
  48. ->where($where)
  49. ->field('r.*,u.address')
  50. ->order($sort, $order)
  51. ->paginate($limit);
  52. foreach ($list as $k => $v) {
  53. $list[$k]['address'] = (new UserModel())->getById($v['user_id'])['address'];
  54. }
  55. $result = ['total' => $list->total(), 'rows' => $list->items()];
  56. return json($result);
  57. }
  58. }