Mongyout.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <?php
  2. namespace app\admin\controller\trade;
  3. use think\Db;
  4. use Exception;
  5. use think\exception\DbException;
  6. use think\exception\PDOException;
  7. use app\common\controller\Backend;
  8. use think\exception\ValidateException;
  9. /**
  10. * 提现记录管理
  11. *
  12. * @icon fa fa-circle-o
  13. */
  14. class Mongyout extends Backend
  15. {
  16. /**
  17. * Mongyout模型对象
  18. * @var \app\admin\model\trade\Mongyout
  19. */
  20. protected $model = null;
  21. protected $mapType = null;
  22. public function _initialize()
  23. {
  24. parent::_initialize();
  25. $this->mapType = array();
  26. $this->model = new \app\common\model\Mongyout;
  27. $this->assign('typeList', $this->model->getTypeList());
  28. }
  29. /**
  30. * 查看
  31. * @return string|Json
  32. * @throws \think\Exception
  33. * @throws DbException
  34. */
  35. public function index()
  36. {
  37. //设置过滤方法
  38. $this->request->filter(['strip_tags', 'trim']);
  39. if (false === $this->request->isAjax()) {
  40. return $this->view->fetch();
  41. }
  42. //如果发送的来源是 Selectpage,则转发到 Selectpage
  43. if ($this->request->request('keyField')) {
  44. return $this->selectpage();
  45. }
  46. [$where, $sort, $order, $offset, $limit] = $this->buildparams();
  47. //tab
  48. $type = $this->request->param('order_type/d');
  49. if($type > 0) $this->mapType['order_type'] = $type;
  50. $list = $this->model->with('users,admins')
  51. ->where($where)
  52. ->where($this->mapType)
  53. ->order($sort, $order)
  54. ->paginate($limit);
  55. $result = ['total' => $list->total(), 'rows' => $list->items()];
  56. return json($result);
  57. }
  58. /**
  59. * 审核
  60. * @param $ids
  61. * @return string
  62. * @throws DbException
  63. * @throws \think\Exception
  64. */
  65. public function review($ids = null, $status= 0)
  66. {
  67. $row = $this->model->get($ids);
  68. if (!$row) {
  69. $this->error(__('No Results were found'));
  70. }
  71. $result = false;
  72. try {
  73. $result = $row->allowField(true)->save(['status'=>$status]);
  74. } catch (ValidateException|PDOException|Exception $e) {
  75. $this->error($e->getMessage());
  76. }
  77. if (false === $result) {
  78. $this->error(__('No rows were updated'));
  79. }
  80. $this->success();
  81. }
  82. }