123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- <?php
- /**
- *
- * @author: xaboy<365615158@qq.com>
- * @day: 2017/11/11
- */
- namespace app\admin\controller\user;
- use app\admin\controller\AuthController;
- use app\admin\model\user\User;
- use crmeb\services\{ExpressService,
- JsonService,
- JsonService as Json,
- MiniProgramService,
- PHPExcelService,
- WechatService,
- FormBuilder as Form,
- CacheService,
- UtilService as Util};
- use think\facade\Route as Url;
- use think\facade\Validate;
- Use app\admin\model\user\UserApply as model;
- /**
- * 订单管理控制器 同一个订单表放在一个控制器
- * Class StoreOrder
- * @package app\admin\controller\store
- */
- class UserApply extends AuthController
- {
- /**
- * @return mixed
- */
- public function index()
- {
- return $this->fetch();
- }
- public function list()
- {
- $where = Util::getMore([
- ['page', 1],
- ['limit', 20],
- ['name', ''],
- ['status', ''],
- ]);
- return Json::successlayui(model::list($where));
- }
- /**
- * 显示创建资源表单页.
- *
- * @return \think\Response
- */
- public function edit($id = 0)
- {
- $data = model::find($id);
- $f = [];
- $f[] = Form::radio('status', '审核', $data['status'] == 0? 1 : $data['status'])->options([['value' => 1, 'label' => '通过'], ['value' => 2, 'label' => '拒绝']])->required();
- $f[] = Form::textarea('reason', '拒绝理由', $data['reason']);
- $f[] = Form::hidden('id', $id);
- $form = Form::make_post_form('操作', $f, Url::buildUrl('update'));
- $this->assign(compact('form'));
- return $this->fetch('public/form-builder');
- }
- /**
- * 修改
- * @return void
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public function update()
- {
- $model = new model;
- $data = Util::postMore([
- 'status',
- 'reason',
- 'id',
- ]);
- $details = $model->find($data['id']);
- if ($details['status'] != 0) return Json::fail('已审核');
- if ($data['status'] == 2) return Json::fail('请填写拒绝理由');
- $details['status'] = $data['status'];
- $details['reason'] = $data['reason'];
- if ($details['status'] == 1){
- User::where('uid', $details['uid'])->update(['identity' => $details['type'], 'proxy_area' => $details['address'], 'proxy_time' => time()]);
- }
- $res = $details->save();
- if ($res) return Json::successful('成功');
- return Json::fail('失败');
- }
- /**
- * 删除
- * @param $id
- * @return void
- * @throws \Exception
- */
- public function delete($id)
- {
- if (!$id) Json::fail('删除失败');
- $model = new model;
- $res = model::destroy($id);
- if ($res){
- return Json::success('删除成功!');
- }else{
- return Json::fail($model->getErrorInfo());
- }
- }
- }
|