123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- <?php
- namespace app\admin\controller\enterprise;
- use app\admin\controller\AuthController;
- use app\admin\model\enterprise\EnterCategory as ArticleCategoryModel;
- use crmeb\traits\CurdControllerTrait;
- use app\admin\model\enterprise\EnterPriseUser as UserModel;
- use app\admin\model\user\User as User;
- use app\admin\model\article\Article;
- use app\admin\model\system\SystemAdmin;
- use crmeb\services\{JsonService as Json, UtilService, JsonService, UtilService as Util};
- /**
- * 会员设置
- * Class UserLevel
- * @package app\admin\controller\user
- */
- class Lists extends AuthController
- {
- use CurdControllerTrait;
- /*
- * 企业列表
- * */
- public function index()
- {
- return $this->fetch();
- }
- /*
- * 获取列表
- * @param int page
- * @param int limit
- * */
- public function get_system_user_list()
- {
- $where = UtilService::getMore([
- ['page', 1],
- ['limit', 20],
- ['is_auth', 0]
- ]);
- return JsonService::successlayui(UserModel::lists($where));
- }
- //推荐企业
- public static function isput($id, $type)
- {
- $res1 = UserModel::where(['id' => $id])->find();
- $a = 1;
- if ($res1[$type] == 1) {
- $a = 0;
- }
- $res = UserModel::where(['id' => $id])->update([$type => $a]);
- if ($type == 'is_dle') {
- // 查找该企业下的文章进行删除
- $wz = Article::where('mer_id', $id)->update(['status' => 0]);
- // 冻结后台登录权限
- $st = SystemAdmin::where('mer_id', $id)->update(['status' => 0]);
- }
- if ($res) {
- return JsonService::successful('成功');
- } else {
- return JsonService::fail('失败');
- }
- return JsonService::fail('参数错误!');
- }
- /**
- * 添加第三方企业
- * */
- public function create()
- {
- $cid = $this->request->param('cid');
- $all = [];
- $select = 0;
- if ($cid && in_array($cid, \app\admin\model\article\ArticleCategory::getArticleCategoryInfo(0, 'id'))) {
- $all = ArticleCategoryModel::getArticleCategoryInfo($cid);
- $select = 1;
- }
- if (!$select) {
- $list = ArticleCategoryModel::getTierLists();
- foreach ($list as $menu) {
- $all[$menu['id']] = $menu['html'] . $menu['title'];
- }
- }
- $a = [];
- $list = User::select();
- foreach ($list as $menu) {
- $a[$menu['uid']] = $menu['nickname'];
- }
- $this->assign('all', $all);
- $this->assign('uid', $a);
- $this->assign('cid', $cid);
- $this->assign('select', $select);
- $this->assign('jobList', app('JobLogic')->getList([]));
- return $this->fetch();
- }
- /**
- * 保存第三方企业
- * */
- public function add_mer()
- {
- $data = Util::postMore([
- 'name',
- 'contacts',
- 'post',
- 'phone',
- 'password',
- 'introduce',
- 'contacts',
- ['uid', 0],
- 'headimg',
- ['type', 0],
- ['is_auth', 1],
- ['is_third', 1],
- ['is_put', 0],
- ['reason', "审核中"],
- ]);
- if (!empty($data['post'])) {
- $arr = explode(',', $data['post']);
- $data['post'] = $arr[1];
- $data['post_id'] = $arr[0];
- }
- $data['password'] = md5($data['password']);
- $data['user'] = $data['phone'];
- // $data['type'] = $data['cid'];
- // 查询该用户是否绑定其他企业
- $mer = UserModel::where(['uid' => $data['uid']])->count();
- $findUser = User::get($data['uid']);
- if (empty($findUser)) {
- return JsonService::fail('找不到用户');
- }
- if ($mer > 0 || !empty($findUser['mer_id'])) {
- return JsonService::fail('该用户已绑定其他企业!请重新选择');
- }
- $res = UserModel::insert($data);
- if ($res) {
- return Json::successful('添加成功!');
- }
- return JsonService::fail('添加失败!');
- }
- public function employeList($mer_id)
- {
- $this->assign('mer_id', $mer_id);
- return $this->fetch('employe');
- }
- public function delEmploye($uid)
- {
- $updateUser = [];
- $updateUser['mer_id'] = '';
- if (!User::edit($updateUser, $uid)) {
- return Json::fail('删除失败!');
- }
- return Json::successful('删除成功!');
- }
- public function employeData()
- {
- $where = UtilService::getMore([
- ['page', 1],
- ['limit', 20],
- ['audit_status', -1],
- ['apply_user_name', ''],
- ['mer_id', ''],
- ]);
- return app('ApplyLogic')->getEmployeeList($where);
- }
- }
|