UserApply.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace app\admin\controller\user;
  3. use app\admin\controller\AuthController;
  4. use crmeb\services\{FormBuilder as Form, UtilService as Util, JsonService as Json};
  5. use crmeb\services\JsonService;
  6. use think\facade\Route as Url;
  7. use app\admin\model\user\UserNotice as UserNoticeModel;
  8. use app\admin\model\user\UserNoticeSee as UserNoticeSeeModel;
  9. use app\admin\model\wechat\WechatUser as UserModel;
  10. Use app\admin\model\user\UserApply as model;
  11. /**
  12. * 用户通知
  13. * Class UserNotice
  14. * @package app\admin\controller\user
  15. */
  16. class UserApply extends AuthController
  17. {
  18. /**
  19. * 显示资源列表
  20. *
  21. * @return \think\Response
  22. */
  23. public function index($type)
  24. {
  25. $this->assign('type', $type);
  26. return $this->fetch();
  27. }
  28. public function indexs($type)
  29. {
  30. $this->assign('type', $type);
  31. return $this->fetch();
  32. }
  33. public function list()
  34. {
  35. $where = Util::getMore([
  36. ['status', ''],
  37. ['page', 1],
  38. ['limit', 20],
  39. ['name', ''],
  40. ['type', ''],
  41. ['status', ''],
  42. ]);
  43. return Json::successlayui(model::list($where));
  44. }
  45. public function tg($id,$type)
  46. {
  47. $data = model::find($id);
  48. if (!$data) return Json::fail('数据不存在');
  49. $data['status'] = 1;
  50. //老师
  51. if ($type == 1){
  52. $res = \app\admin\model\user\User::where('uid', $data['uid'])->update(['alliance' => 1]) && $data->save();
  53. }elseif($type == 2) {
  54. // 点击
  55. $res = \app\admin\model\user\User::where('uid', $data['uid'])->update(['shopkeeper' => 1]) && $data->save();
  56. }
  57. if ($res) return Json::successful('成功');
  58. return Json::fail('失败');
  59. }
  60. public function btg($id,$type)
  61. {
  62. $data = model::find($id);
  63. if (!$data) return Json::fail('数据不存在');
  64. $data['status'] = -1;
  65. $res = $data->save();
  66. if ($res) return Json::successful('成功');
  67. return Json::fail('失败');
  68. }
  69. /**
  70. * 删除指定资源
  71. *
  72. * @param int $id
  73. * @return \think\Response
  74. */
  75. public function delete($id)
  76. {
  77. if (!model::del($id))
  78. return Json::fail(UserNoticeModel::getErrorInfo('删除失败,请稍候再试!'));
  79. else
  80. return Json::successful('删除成功!');
  81. }
  82. }