Auth.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. namespace app\admin\controller\enterprise;
  3. use app\admin\controller\AuthController;
  4. use think\facade\Route as Url;
  5. use crmeb\traits\CurdControllerTrait;
  6. use app\admin\model\enterprise\EnterPriseUser as UserModel;
  7. use app\admin\model\user\UserBill as UserBillAdmin;
  8. use app\admin\model\system\SystemAdmin as Admin;
  9. use app\admin\model\system\{SystemUserLevel,SystemUserTask};
  10. use crmeb\services\{UtilService,JsonService,FormBuilder as Form};
  11. /**
  12. * 会员设置
  13. * Class UserLevel
  14. * @package app\admin\controller\user
  15. */
  16. class Auth extends AuthController
  17. {
  18. use CurdControllerTrait;
  19. /*
  20. * 审核展示
  21. * */
  22. public function index()
  23. {
  24. return $this->fetch();
  25. }
  26. /*
  27. * 创建form表单
  28. * */
  29. public function create($uid =0)
  30. {
  31. if ($uid) $vipinfo = UserModel::get($uid);
  32. $field[] = Form::input('off', '拒绝理由', isset($vipinfo) ? $vipinfo->off: '')->col(Form::col(24));
  33. $form = Form::make_post_form('添加拒绝理由', $field, Url::buildUrl('save', ['uid' => $uid]), 2);
  34. $this->assign(compact('form'));
  35. return $this->fetch('public/form-builder');
  36. }
  37. /*
  38. * 审核/拒绝
  39. * @param $uid 审核的用户uid
  40. * @return json
  41. * */
  42. public function save($uid = 0)
  43. {
  44. $data = UtilService::postMore([
  45. ['off', ''],
  46. ]);
  47. if (!$data['off']) return JsonService::fail('请输入拒绝理由');
  48. if($data['off']){
  49. // 查询是否已审核
  50. $res1=UserModel::where(['uid' => $uid])->find();
  51. if($res1['is_auth']==0||$res1['is_auth']==2){
  52. return JsonService::fail('该信息已审核!不可操作');
  53. }
  54. $res=UserModel::where(['uid' => $uid])->update(['reason' =>$data['off'],'is_auth'=>"0"]);
  55. if($res>0){
  56. return JsonService::successful('审核成功');
  57. }else{
  58. return JsonService::fail('该信息已审核!不可重复');
  59. }
  60. }
  61. }
  62. /*
  63. * 审核通过
  64. * @param int $id
  65. * */
  66. //9db06bcff9248837f86d1a6bcf41c9e75c5b46740f277f2c87dd023e960c5cfc
  67. public function pass($uid = 0,$id,$name){
  68. if($uid){
  69. // 查询是否已审核
  70. $res1=UserModel::where(['uid' => $uid])->find();
  71. if($res1['is_auth']==0||$res1['is_auth']==2){
  72. return JsonService::fail('该信息已审核!不可操作');
  73. }
  74. $res=UserModel::where(['uid' => $uid])->update(['is_auth' =>2,'reason'=>'审核通过']);
  75. if($res>0){
  76. // 取出用户名和密码放到后台管理员中
  77. $salt= substr(md5(rand(1, 999999)), 0, 6);
  78. $pwd= md5($res1['password'] . md5($salt));
  79. $data = ['account' =>$res1['user'], 'pwd' =>$pwd,'salt'=>$salt,'status'=>1,'mer_id'=>$id,'roles'=>7,'real_name'=>$name,'add_time'=>time(),'level'=>2];
  80. $rslut=Admin::insert($data);
  81. if($rslut){
  82. return JsonService::successful('审核成功');
  83. }
  84. }else{
  85. return JsonService::fail('审核失败');
  86. }
  87. }
  88. return JsonService::fail('参数错误!');
  89. }
  90. /*
  91. * 获取列表
  92. * @param int page
  93. * @param int limit
  94. * */
  95. public function get_system_user_list()
  96. {
  97. $where =UtilService::getMore([
  98. ['page', 1],
  99. ['limit', 20],
  100. ['is_auth',0]
  101. ]);
  102. return JsonService::successlayui(UserModel::authlist($where));
  103. }
  104. }