Lists.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?php
  2. namespace app\admin\controller\enterprise;
  3. use app\admin\controller\AuthController;
  4. use app\admin\model\enterprise\EnterCategory as ArticleCategoryModel;
  5. use crmeb\traits\CurdControllerTrait;
  6. use app\admin\model\enterprise\EnterPriseUser as UserModel;
  7. use app\admin\model\user\User as User;
  8. use app\admin\model\article\Article;
  9. use app\admin\model\system\SystemAdmin;
  10. use crmeb\services\{JsonService as Json, UtilService, JsonService, UtilService as Util};
  11. /**
  12. * 会员设置
  13. * Class UserLevel
  14. * @package app\admin\controller\user
  15. */
  16. class Lists extends AuthController
  17. {
  18. use CurdControllerTrait;
  19. /*
  20. * 企业列表
  21. * */
  22. public function index()
  23. {
  24. return $this->fetch();
  25. }
  26. /*
  27. * 获取列表
  28. * @param int page
  29. * @param int limit
  30. * */
  31. public function get_system_user_list()
  32. {
  33. $where = UtilService::getMore([
  34. ['page', 1],
  35. ['limit', 20],
  36. ['is_auth', 0]
  37. ]);
  38. return JsonService::successlayui(UserModel::lists($where));
  39. }
  40. //推荐企业
  41. public static function isput($id, $type)
  42. {
  43. $res1 = UserModel::where(['id' => $id])->find();
  44. $a = 1;
  45. if ($res1[$type] == 1) {
  46. $a = 0;
  47. }
  48. $res = UserModel::where(['id' => $id])->update([$type => $a]);
  49. if ($type == 'is_dle') {
  50. // 查找该企业下的文章进行删除
  51. $wz = Article::where('mer_id', $id)->update(['status' => 0]);
  52. // 冻结后台登录权限
  53. $st = SystemAdmin::where('mer_id', $id)->update(['status' => 0]);
  54. }
  55. if ($res) {
  56. return JsonService::successful('成功');
  57. } else {
  58. return JsonService::fail('失败');
  59. }
  60. return JsonService::fail('参数错误!');
  61. }
  62. /**
  63. * 添加第三方企业
  64. * */
  65. public function create()
  66. {
  67. $cid = $this->request->param('cid');
  68. $all = [];
  69. $select = 0;
  70. if ($cid && in_array($cid, \app\admin\model\article\ArticleCategory::getArticleCategoryInfo(0, 'id'))) {
  71. $all = ArticleCategoryModel::getArticleCategoryInfo($cid);
  72. $select = 1;
  73. }
  74. if (!$select) {
  75. $list = ArticleCategoryModel::getTierLists();
  76. foreach ($list as $menu) {
  77. $all[$menu['id']] = $menu['html'] . $menu['title'];
  78. }
  79. }
  80. $a = [];
  81. $list = User::select();
  82. foreach ($list as $menu) {
  83. $a[$menu['uid']] = $menu['nickname'];
  84. }
  85. $this->assign('all', $all);
  86. $this->assign('uid', $a);
  87. $this->assign('cid', $cid);
  88. $this->assign('select', $select);
  89. $this->assign('jobList', app('JobLogic')->getList([]));
  90. return $this->fetch();
  91. }
  92. /**
  93. * 保存第三方企业
  94. * */
  95. public function add_mer()
  96. {
  97. $data = Util::postMore([
  98. 'name',
  99. 'contacts',
  100. 'post',
  101. 'phone',
  102. 'password',
  103. 'introduce',
  104. 'contacts',
  105. ['uid', 0],
  106. 'headimg',
  107. ['type', 0],
  108. ['is_auth', 1],
  109. ['is_third', 1],
  110. ['is_put', 0],
  111. ['reason', "审核中"],
  112. ]);
  113. if (!empty($data['post'])) {
  114. $arr = explode(',', $data['post']);
  115. $data['post'] = $arr[1];
  116. $data['post_id'] = $arr[0];
  117. }
  118. $data['password'] = md5($data['password']);
  119. $data['user'] = $data['phone'];
  120. // $data['type'] = $data['cid'];
  121. // 查询该用户是否绑定其他企业
  122. $mer = UserModel::where(['uid' => $data['uid']])->count();
  123. $findUser = User::get($data['uid']);
  124. if (empty($findUser)) {
  125. return JsonService::fail('找不到用户');
  126. }
  127. if ($mer > 0 || !empty($findUser['mer_id'])) {
  128. return JsonService::fail('该用户已绑定其他企业!请重新选择');
  129. }
  130. $res = UserModel::insert($data);
  131. if ($res) {
  132. return Json::successful('添加成功!');
  133. }
  134. return JsonService::fail('添加失败!');
  135. }
  136. public function employeList($mer_id)
  137. {
  138. $this->assign('mer_id', $mer_id);
  139. return $this->fetch('employe');
  140. }
  141. public function delEmploye($uid)
  142. {
  143. $updateUser = [];
  144. $updateUser['mer_id'] = '';
  145. if (!User::edit($updateUser, $uid)) {
  146. return Json::fail('删除失败!');
  147. }
  148. return Json::successful('删除成功!');
  149. }
  150. public function employeData()
  151. {
  152. $where = UtilService::getMore([
  153. ['page', 1],
  154. ['limit', 20],
  155. ['audit_status', -1],
  156. ['apply_user_name', ''],
  157. ['mer_id', ''],
  158. ]);
  159. return app('ApplyLogic')->getEmployeeList($where);
  160. }
  161. }