UserApply.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <?php
  2. /**
  3. *
  4. * @author: xaboy<365615158@qq.com>
  5. * @day: 2017/11/11
  6. */
  7. namespace app\admin\controller\user;
  8. use app\admin\controller\AuthController;
  9. use app\admin\model\user\User;
  10. use crmeb\services\{ExpressService,
  11. JsonService,
  12. JsonService as Json,
  13. MiniProgramService,
  14. PHPExcelService,
  15. WechatService,
  16. FormBuilder as Form,
  17. CacheService,
  18. UtilService as Util};
  19. use think\facade\Route as Url;
  20. use think\facade\Validate;
  21. Use app\admin\model\user\UserApply as model;
  22. /**
  23. * 订单管理控制器 同一个订单表放在一个控制器
  24. * Class StoreOrder
  25. * @package app\admin\controller\store
  26. */
  27. class UserApply extends AuthController
  28. {
  29. /**
  30. * @return mixed
  31. */
  32. public function index()
  33. {
  34. return $this->fetch();
  35. }
  36. public function list()
  37. {
  38. $where = Util::getMore([
  39. ['page', 1],
  40. ['limit', 20],
  41. ['name', ''],
  42. ['status', ''],
  43. ]);
  44. return Json::successlayui(model::list($where));
  45. }
  46. /**
  47. * 显示创建资源表单页.
  48. *
  49. * @return \think\Response
  50. */
  51. public function edit($id = 0)
  52. {
  53. $data = model::find($id);
  54. $f = [];
  55. $f[] = Form::radio('status', '审核', $data['status'] == 0? 1 : $data['status'])->options([['value' => 1, 'label' => '通过'], ['value' => 2, 'label' => '拒绝']])->required();
  56. $f[] = Form::textarea('reason', '拒绝理由', $data['reason']);
  57. $f[] = Form::hidden('id', $id);
  58. $form = Form::make_post_form('操作', $f, Url::buildUrl('update'));
  59. $this->assign(compact('form'));
  60. return $this->fetch('public/form-builder');
  61. }
  62. /**
  63. * 修改
  64. * @return void
  65. * @throws \think\db\exception\DataNotFoundException
  66. * @throws \think\db\exception\DbException
  67. * @throws \think\db\exception\ModelNotFoundException
  68. */
  69. public function update()
  70. {
  71. $model = new model;
  72. $data = Util::postMore([
  73. 'status',
  74. 'reason',
  75. 'id',
  76. ]);
  77. $details = $model->find($data['id']);
  78. if ($details['status'] != 0) return Json::fail('已审核');
  79. if ($data['status'] == 2) return Json::fail('请填写拒绝理由');
  80. $details['status'] = $data['status'];
  81. $details['reason'] = $data['reason'];
  82. if ($details['status'] == 1){
  83. User::where('uid', $details['uid'])->update(['identity' => $details['type'], 'proxy_area' => $details['address'], 'proxy_time' => time()]);
  84. }
  85. $res = $details->save();
  86. if ($res) return Json::successful('成功');
  87. return Json::fail('失败');
  88. }
  89. /**
  90. * 删除
  91. * @param $id
  92. * @return void
  93. * @throws \Exception
  94. */
  95. public function delete($id)
  96. {
  97. if (!$id) Json::fail('删除失败');
  98. $model = new model;
  99. $res = model::destroy($id);
  100. if ($res){
  101. return Json::success('删除成功!');
  102. }else{
  103. return Json::fail($model->getErrorInfo());
  104. }
  105. }
  106. }