1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069 |
- <?php
- namespace app\admin\controller;
- use app\common\model\RensheCode;
- use app\common\model\UserWill;
- use app\admin\BaseController;
- use app\common\model\User as UserModel;
- use app\common\model\UserAuths as UserAuthsModel;
- use app\common\model\UserFollow as UserFollowModel;
- use app\common\model\UserGroups as UserGroupsModel;
- use app\common\model\UserPart as UserPartModel;
- use app\common\model\UserIntegral as UserIntegralModel;
- use app\common\model\UserRank as UserRankModel;
- use app\common\model\UserParam as UserParamModel;
- use app\common\model\ComjobsCate as ComjobsCateModel;
- use app\common\model\Agent as AgentModel;
- use app\common\model\Broker as BrokerModel;
- use app\common\validate\User as UserValidate;
- use think\exception\ValidateException;
- class User extends BaseController
- {
- // 用户跟进记录
- public function follow()
- {
- $userid = input('userid/d');
- $user = UserModel::findOrEmpty($userid);
- $followlist = UserFollowModel::where('userid', $userid)->order('id', 'desc')->limit(100)->select();
- return view('user/follow', [
- 'user' => $user,
- 'followlist' => $followlist,
- ]);
- }
- public function editFollow()
- {
- $userid = input('userid/d', 0);
- $user = UserModel::findOrEmpty($userid);
- if ($user->isEmpty()) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "用户信息不存在。",
- ]));
- }
- UserFollowModel::create([
- 'userid' => $userid,
- 'ftype' => input('ftype/s', ""),
- 'remark' => input('remark/s', ""),
- 'createtime' => time(),
- ]);
- $followstatus = input('followstatus/d', 1);
- $user->save([
- 'followstatus' => $followstatus,
- ]);
- exit(json_encode([
- 'code' => 0,
- ]));
- }
- // 邀请排行榜
- public function rankList()
- {
- return view('user/ranklist');
- }
- public function rankForm()
- {
- $id = input('id/d');
- $rank = UserRankModel::findOrEmpty($id);
- return view('user/rankform', [
- 'rank' => $rank,
- ]);
- }
- public function editRank()
- {
- $id = input('id/d');
- $rank = UserRankModel::findOrEmpty($id);
- $rank->save([
- 'realname' => input('realname/s'),
- 'mobile' => input('mobile/s'),
- 'partnumber' => input('partnumber/d', 0),
- ]);
- exit(json_encode([
- 'code' => 0,
- ]));
- }
- public function fieldRank()
- {
- $id = input('id/d', 0);
- $rank = UserRankModel::findOrEmpty($id);
- if ($rank->isEmpty()) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "信息不存在",
- ]));
- } else {
- $rank->save([
- input('field/s') => input('value'),
- ]);
- }
- exit(json_encode([
- 'code' => 0,
- ]));
- }
- public function listRank()
- {
- $limit = input('limit');
- $page = input('page');
- $map = [];
- $list = UserRankModel::where($map)->order('partnumber', 'desc')->limit($limit)->page($page)->select();
- $count = UserRankModel::where($map)->count();
- if ($count == 0) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "未查询到数据",
- ]));
- }
- exit(json_encode([
- 'code' => 0,
- 'msg' => "",
- 'count' => $count,
- 'data' => $list,
- ]));
- }
- public function delRank()
- {
- $idarr = input('idarr/a');
- UserRankModel::whereIn('id', $idarr)->delete();
- exit(json_encode([
- 'code' => 0,
- 'msg' => "",
- ]));
- }
- // 邀请记录
- public function partList()
- {
- return view('user/partlist');
- }
- public function listPart()
- {
- $limit = input('limit');
- $page = input('page');
- $map = [];
- $keywords = input('keywords/s', "");
- $status = input('status/d', 0);
- if (!empty($status)) {
- $map[] = ['UserPart.status', '=', $status];
- }
- $list = UserPartModel::hasWhere('puser', [['realname|mobile', 'like', '%' . $keywords . '%', 'or']])->with(['puser', 'user'])->where($map)->order('id', 'desc')->limit($limit)->page($page)->append(['status_text'])->select();
- $count = UserPartModel::hasWhere('puser', [['realname|mobile', 'like', '%' . $keywords . '%', 'or']])->where($map)->count();
- if ($count == 0) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "未查询到数据",
- ]));
- }
- exit(json_encode([
- 'code' => 0,
- 'msg' => "",
- 'count' => $count,
- 'data' => $list,
- ]));
- }
- public function exportPart()
- {
- $map = [];
- $keywords = input('keywords/s', "");
- $status = input('status/d', 0);
- if (!empty($status)) {
- $map[] = ['UserPart.status', '=', $status];
- }
- $xlsData = UserPartModel::hasWhere('puser', [['realname|mobile', 'like', '%' . $keywords . '%', 'or']])->with(['puser', 'user'])->where($map)->order('id', 'desc')->select()->toArray();
- $xlsCell = [
- ['id', '表ID'],
- ['puser.nickname', '邀请人昵称'],
- ['puser.realname', '邀请人姓名'],
- ['puser.mobile', '邀请人手机号'],
- ['puser.bankcard.openbank', '邀请人开户行'],
- ['puser.bankcard.account', '邀请人帐户名'],
- ['puser.bankcard.number', '邀请人账户号'],
- ['user.nickname', '被邀请人昵称'],
- ['user.realname', '被邀请人姓名'],
- ['user.mobile', '被邀请人手机号'],
- ['status', '状态', [1 => '未入职', 2 => '已入职', 3 => '已发放']],
- ['redmoney', '奖金金额'],
- ['createtime', '推荐时间'],
- ];
- export_excel("系统用户", $xlsCell, $xlsData);
- }
- public function fieldPart()
- {
- $id = input('id/d', 0);
- $part = UserPartModel::findOrEmpty($id);
- if ($part->isEmpty()) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "信息不存在",
- ]));
- } else {
- $part->save([
- input('field/s') => input('value'),
- ]);
- }
- exit(json_encode([
- 'code' => 0,
- ]));
- }
- public function partForm()
- {
- $id = input('id/d');
- $part = UserPartModel::with(['puser', 'user'])->findOrEmpty($id);
- return view('user/partform', [
- 'part' => $part,
- ]);
- }
- public function editPart()
- {
- $id = input('id/d');
- $part = UserPartModel::findOrEmpty($id);
- $part->save([
- 'status' => input('status/d', 1),
- 'redmoney' => input('redmoney/d', 0),
- ]);
- exit(json_encode([
- 'code' => 0,
- ]));
- }
- public function delPart()
- {
- $idarr = input('idarr/a');
- UserPartModel::whereIn('id', $idarr)->delete();
- exit(json_encode([
- 'code' => 0,
- 'msg' => "",
- ]));
- }
- // 用户积分
- public function integralList()
- {
- return view('user/integrallist');
- }
- public function listIntegral()
- {
- $limit = input('limit');
- $page = input('page');
- $map = [];
- $keywords = input('keywords/s', "");
- $itype = input('itype/d', 0);
- if (!empty($itype)) {
- $map[] = ['itype', '=', $itype];
- }
- $status = input('status/d', 0);
- if (!empty($status)) {
- $map[] = ['status', '=', $status];
- }
- $list = UserIntegralModel::hasWhere('user', [['realname|mobile', 'like', '%' . $keywords . '%', 'or']])->with(['user'])->where($map)->order('id', 'desc')->limit($limit)->page($page)->select()->append(['itype_text', 'status_text']);
- $count = UserIntegralModel::hasWhere('user', [['realname|mobile', 'like', '%' . $keywords . '%', 'or']])->where($map)->count();
- if ($count == 0) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "未查询到数据",
- ]));
- }
- exit(json_encode([
- 'code' => 0,
- 'msg' => "",
- 'count' => $count,
- 'data' => $list,
- ]));
- }
- public function exportIntegral()
- {
- $map = [];
- $keywords = input('keywords/s', "");
- $itype = input('itype/d', 0);
- if (!empty($itype)) {
- $map[] = ['itype', '=', $itype];
- }
- $xlsData = UserIntegralModel::hasWhere('user', [['realname|mobile', 'like', '%' . $keywords . '%', 'or']])->with(['user'])->where($map)->order('id', 'desc')->select()->append(['itype_text', 'status_text'])->toArray();
- $xlsCell = [
- ['id', '表ID'],
- ['user.nickname', '昵称'],
- ['user.realname', '姓名'],
- ['user.mobile', '手机号'],
- ['user.bankcard.openbank', '开户行'],
- ['user.bankcard.account', '帐户名'],
- ['user.bankcard.number', '账户号'],
- ['title', '积分标题'],
- ['itype_text', '类型'],
- ['status_text', '状态'],
- ['intvalue', '积分变更值'],
- ['intmoney', '积分金额'],
- ['remark', '备注'],
- ['createtime', '注册时间'],
- ];
- export_excel("用户积分", $xlsCell, $xlsData);
- }
- public function fieldIntegral()
- {
- $id = input('id/d', 0);
- $integral = UserIntegralModel::findOrEmpty($id);
- if ($integral->isEmpty()) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "信息不存在",
- ]));
- } else {
- $integral->save([
- input('field/s') => input('value'),
- ]);
- }
- exit(json_encode([
- 'code' => 0,
- ]));
- }
- public function integralUpdate()
- {
- $id = input('id/d', 0);
- $integral = UserIntegralModel::with('user')->findOrEmpty($id);
- return view('user/integralupdate', [
- 'integral' => $integral,
- ]);
- }
- public function updateIntegral()
- {
- $id = input('id/d', 0);
- $integral = UserIntegralModel::findOrEmpty($id);
- if ($integral->isEmpty()) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "用户积分记录不存在",
- ]));
- }
- $createtime = input('createtime/s', date("Y-m-d H:i:s"));
- $integral->save([
- 'title' => input('title/s', ""),
- 'intvalue' => input('intvalue/d', 0),
- 'intmoney' => input('intmoney/f', 0.00),
- 'remark' => input('remark/s', ""),
- 'itype' => input('itype/d', 1),
- 'status' => input('status/d', 1),
- 'createtime' => $createtime,
- 'yeartime' => date("Y", strtotime($createtime)),
- 'monthtime' => date("Ym", strtotime($createtime)),
- ]);
- exit(json_encode([
- 'code' => 0,
- ]));
- }
- public function statusIntegral()
- {
- $id = input('id/d');
- $integral = UserIntegralModel::where(['itype' => 3])->find($id);
- if ($integral == null) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "该记录非兑现类型",
- ]));
- } elseif ($integral->status == 1) {
- $integral->save([
- 'status' => 2,
- ]);
- } elseif ($integral->status == 2) {
- $integral->save([
- 'status' => 1,
- ]);
- } else {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "该记录非兑现类型。",
- ]));
- }
- exit(json_encode([
- 'code' => 0,
- ]));
- }
- public function statusIntegralAll()
- {
- $idarr = input('idarr/a');
- UserIntegralModel::update(['status' => 2], ['status' => 1, 'itype' => 3, 'id' => $idarr]);
- exit(json_encode([
- 'code' => 0,
- 'msg' => "",
- ]));
- }
- public function delIntegral()
- {
- $idarr = input('idarr/a');
- UserIntegralModel::whereIn('id', $idarr)->delete();
- exit(json_encode([
- 'code' => 0,
- 'msg' => "",
- ]));
- }
- public function integralForm()
- {
- $userid = input('userid/d');
- $user = UserModel::findOrEmpty($userid);
- return view('user/integralform', [
- 'user' => $user,
- ]);
- }
- public function editIntegral()
- {
- $userid = input('userid/d');
- $user = UserModel::findOrEmpty($userid);
- $intvalue = input('intvalue/d', 0);
- if ($intvalue == 0) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "积分变更值不能为0",
- ]));
- }
- $data = [
- 'userid' => $userid,
- 'title' => input('title/s'),
- 'intvalue' => $intvalue,
- 'intmoney' => input('intmoney/s', 0.00),
- 'onlycontent' => "",
- 'remark' => input('remark/s'),
- 'itype' => input('itype/d'),
- 'status' => 2,
- 'createtime' => input('createtime/s'),
- 'yeartime' => date("Y"),
- 'monthtime' => date("Ym"),
- ];
- UserIntegralModel::create($data);
- $udata = [];
- $udata['integral'] = intval($user->integral) + $intvalue;
- $isinttotal = input('isinttotal/d', 0);
- if ($isinttotal == 1) {
- $udata['inttotal'] = intval($user->inttotal) + $intvalue;
- }
- $user->save($udata);
- exit(json_encode([
- 'code' => 0,
- ]));
- }
- // 用户授权
- public function authsList()
- {
- $userid = input('userid/d');
- return view('user/authslist', [
- 'userid' => $userid,
- ]);
- }
- public function listAuths()
- {
- $userid = input('userid/d');
- $list = UserAuthsModel::where('userid', $userid)->order('id', 'asc')->append(['identitytype_text'])->select();
- $count = UserAuthsModel::where('userid', $userid)->count();
- if ($count == 0) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "未查询到数据",
- ]));
- }
- exit(json_encode([
- 'code' => 0,
- 'msg' => "",
- 'count' => $count,
- 'data' => $list,
- ]));
- }
- public function delAuths()
- {
- $id = input('id/d');
- $auths = UserAuthsModel::find($id);
- if ($auths->identitytype == 'mobile') {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "手机号授权方式不允许删除",
- ]));
- }
- $result = $auths->delete();
- if ($result) {
- exit(json_encode([
- 'code' => 0,
- ]));
- }
- exit(json_encode([
- 'code' => 1,
- 'msg' => "删除失败,请稍后重试",
- ]));
- }
- // 用户
- public function userPublic()
- {
- $groupslist = UserGroupsModel::order(['isdefault' => 'desc', 'id' => 'asc'])->select();
- $agentlist = AgentModel::with('broker')->order(['id' => 'desc'])->select();
- return view('user/userpublic', [
- 'groupslist' => $groupslist,
- 'agentlist' => $agentlist,
- ]);
- }
- public function userList()
- {
- $groupslist = UserGroupsModel::order(['isdefault' => 'desc', 'id' => 'asc'])->select();
- $agentlist = AgentModel::with('broker')->order(['id' => 'desc'])->select();
- return view('user/userlist', [
- 'groupslist' => $groupslist,
- 'agentlist' => $agentlist,
- ]);
- }
- public function userForm()
- {
- $id = input('id/d', 0);
- $user = UserModel::with(['broker'])->findOrEmpty($id);
- $agentlist = AgentModel::with('broker')->order(['id' => 'asc'])->select();
- $groupslist = UserGroupsModel::order(['isdefault' => 'desc', 'id' => 'asc'])->select();
- $willlist = UserWill::select();
- return view('user/userform', [
- 'groupslist' => $groupslist,
- 'willlist' => $willlist,
- 'agentlist' => $agentlist,
- 'user' => $user,
- ]);
- }
- public function fieldUser()
- {
- $id = input('id/d', 0);
- $user = UserModel::findOrEmpty($id);
- if ($user->isEmpty()) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "信息不存在",
- ]));
- } else {
- $user->save([
- input('field/s') => input('value'),
- ]);
- }
- exit(json_encode([
- 'code' => 0,
- ]));
- }
- public function listUser()
- {
- $limit = input('limit');
- $page = input('page');
- $map = [];
- $keywords = input('keywords/s');
- if (!empty($keywords)) {
- $map[] = ['nickname|realname|mobile', 'like', '%' . $keywords . '%', 'or'];
- }
- $groupsid = input('groupsid/d');
- if (!empty($groupsid)) {
- $map[] = ['groupsid', '=', $groupsid];
- }
- $ispublic = input('ispublic/d', 0);
- if ($ispublic == 0) {
- $agentbrokerarr = explode(",", input('agentbroker/s'));
- $agentid = isset($agentbrokerarr[0]) ? $agentbrokerarr[0] : 0;
- if (!empty($agentid)) {
- $brokeridarr = BrokerModel::where('agentid', '=', $agentid)->column('id');
- $map[] = ['brokerid', 'in', $brokeridarr];
- $map[] = ['brokerid', '<>', 0];
- }
- $brokerid = isset($agentbrokerarr[1]) ? $agentbrokerarr[1] : 0;
- if (!empty($brokerid)) {
- $map[] = ['brokerid', '=', $brokerid];
- }
- } else {
- $map[] = ['brokerid', '=', 0];
- }
- $status = input('status/d');
- if (!empty($status)) {
- $map[] = ['status', '=', $status];
- }
- $authstatus = input('authstatus/d');
- if (!empty($authstatus)) {
- $map[] = ['authstatus', '=', $authstatus];
- }
- $followstatus = input('followstatus/d');
- if (!empty($followstatus)) {
- $map[] = ['followstatus', '=', $followstatus];
- }
- $list = UserModel::with(['userGroups', 'broker' => ['agent', 'worker']])->withCount('userPart')->where($map)->order('id', 'desc')->limit($limit)->page($page)->append(['status_text', 'isvip_text', 'authstatus_text', 'followstatus_text', 'education_text', 'worker_text', 'jobintention_text'])->select();
- $count = UserModel::where($map)->count();
- if ($count == 0) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "未查询到数据",
- ]));
- }
- exit(json_encode([
- 'code' => 0,
- 'msg' => "",
- 'count' => $count,
- 'data' => $list,
- ]));
- }
- public function exportUser()
- {
- $map = [];
- $keywords = input('keywords/s');
- if (!empty($keywords)) {
- $map[] = ['nickname|realname|mobile', 'like', '%' . $keywords . '%', 'or'];
- }
- $groupsid = input('groupsid/d');
- if (!empty($groupsid)) {
- $map[] = ['groupsid', '=', $groupsid];
- }
- $agentbrokerarr = explode(",", input('agentbroker/s'));
- $agentid = isset($agentbrokerarr[0]) ? $agentbrokerarr[0] : 0;
- if (!empty($agentid)) {
- $brokeridarr = BrokerModel::where('agentid', '=', $agentid)->column('id');
- $map[] = ['brokerid', 'in', $brokeridarr];
- $map[] = ['brokerid', '<>', 0];
- }
- $brokerid = isset($agentbrokerarr[1]) ? $agentbrokerarr[1] : 0;
- if (!empty($brokerid)) {
- $map[] = ['brokerid', '=', $brokerid];
- }
- $status = input('status/d');
- if (!empty($status)) {
- $map[] = ['status', '=', $status];
- }
- $authstatus = input('authstatus/d');
- if (!empty($authstatus)) {
- $map[] = ['authstatus', '=', $authstatus];
- }
- $followstatus = input('followstatus/d');
- if (!empty($followstatus)) {
- $map[] = ['followstatus', '=', $followstatus];
- }
- $xlsData = UserModel::with(['userGroups', 'broker' => ['agent', 'worker']])->withCount('userPart')->where($map)->order('id', 'desc')->append(['status_text', 'isvip_text', 'authstatus_text', 'followstatus_text'])->select()->toArray();
- $xlsCell = [
- ['id', '表ID'],
- ['nickname', '昵称'],
- ['realname', '姓名'],
- ['mobile', '手机号'],
- ['integral', '可用积分'],
- ['inttotal', '累计积分'],
- ['status_text', '状态'],
- ['isvip_text', '是否VIP'],
- ['authstatus_text', '是否实名认证'],
- ['idcard', '身份证号'],
- ['gender', '性别', [1 => '男', 2 => '女']],
- ['birthday', '出生日期'],
- ['address', '现居住地'],
- ['education', '学历'],
- ['bankcard.openbank', '开户行'],
- ['bankcard.account', '账户名'],
- ['bankcard.number', '账户号'],
- ['followstatus_text', '跟进状态'],
- ['userGroups.title', '用户组'],
- ['broker.worker.title', '劳务公司'],
- ['broker.agent.title', '代理门店'],
- ['broker.title', '职业顾问'],
- ['user_part_count', '推广人数'],
- ['createtime', '注册时间'],
- ];
- export_excel("系统用户", $xlsCell, $xlsData);
- }
- public function setBroker()
- {
- $idarr = input('idarr/a');
- $setagentbroker = explode(",", input('setagentbroker/s'));
- $brokerid = isset($setagentbroker[1]) ? $setagentbroker[1] : 0;
- if (empty($brokerid)) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "请选择职业顾问。",
- ]));
- }
- UserModel::whereIn('id', $idarr)->update(['brokerid' => $brokerid]);
- exit(json_encode([
- 'code' => 0,
- 'msg' => "",
- ]));
- }
- public function delUser()
- {
- $idarr = input('idarr/a');
- UserAuthsModel::whereIn('userid', $idarr)->delete();
- UserModel::destroy($idarr);
- // $result = Db::name('user')->whereIn('id',$idarr)->update(['deletetime'=>time()]);
- exit(json_encode([
- 'code' => 0,
- 'msg' => "",
- ]));
- }
- public function editUser()
- {
- $id = input('id/d');
- $mobile = input('mobile/s');
- $vdata = [
- 'id' => $id,
- 'mobile' => $mobile,
- ];
- try {
- validate(UserValidate::class)->check($vdata);
- } catch (ValidateException $e) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => $e->getError(),
- ]));
- }
- //手机号
- $check_user_where = [['mobile', '=', $mobile]];
- if (!empty($id)) {
- $check_user_where[] = ['id', '<>', $id];
- }
- $check_user = UserModel::where($check_user_where)->find();
- if (!empty($check_user)) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => '手机号已存在',
- ]));
- }
- $address = input('address/s', "");
- $jobintention = input('jobintention/s', "");
- if (!$address) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "请填写居住地址。",
- ]));
- }
- if (!$jobintention) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "请填写意向岗位。",
- ]));
- }
- $agentbrokerarr = explode(",", input('agentbroker/s'));
- $brokerid = isset($agentbrokerarr[1]) ? $agentbrokerarr[1] : 0;
- $data = [
- 'groupsid' => input('groupsid/d', 0),
- 'brokerid' => $brokerid,
- 'nickname' => input('nickname/s', ""),
- 'avatar' => input('avatar/s', ""),
- 'realname' => input('realname/s', ""),
- 'mobile' => $mobile,
- 'inttotal' => input('inttotal/d', 0),
- 'status' => input('status/d', 1),
- 'isvip' => input('isvip/d', 1),
- 'authstatus' => input('authstatus/d', 1),
- 'authremark' => input('authremark/s', ""),
- 'idcardzpic' => input('idcardzpic/s', ""),
- 'idcardfpic' => input('idcardfpic/s', ""),
- 'idcard' => input('idcard/s', ""),
- 'gender' => input('gender/d', 1),
- 'birthday' => input('birthday/s', ""),
- 'address' => $address,
- 'education' => input('education/s', ""),
- 'createtime' => input('createtime/s', ""),
- 'jobintention' => $jobintention,
- 'workexperience' => input('workexperience/s', ""),
- 'eduexperience' => input('eduexperience/s', ""),
- 'followstatus' => input('followstatus/d', 1),
- 'bankcard' => input('bankcard/a', []),
- ];
- $password = input('password/s');
- if (empty($id)) {
- $data['integral'] = 0;
- $data['wxampcode'] = '';
- $user = UserModel::create($data);
- $auths = UserAuthsModel::create([
- 'userid' => $user->id,
- 'identitytype' => "mobile",
- 'identifier' => $mobile,
- 'password' => empty($password) ? md5("123456789") : md5($password),
- 'logintime' => time(),
- 'loginip' => $_SERVER['SERVER_ADDR'],
- 'wxampcode' => "",
- ]);
- } else {
- $data['id'] = $id;
- $user = UserModel::update($data);
- $adata = ['identifier' => $mobile];
- if (!empty($password)) {
- $adata['password'] = md5($password);
- }
- UserAuthsModel::update($adata, ['userid' => $id, 'identitytype' => 'mobile']);
- }
- exit(json_encode([
- 'code' => 0,
- ]));
- }
- // 用户组
- public function groupsList()
- {
- return view('user/groupslist');
- }
- public function groupsForm()
- {
- $id = input('id/d, 0');
- $groups = UserGroupsModel::findOrEmpty($id);
- return view('user/groupsform', [
- 'groups' => $groups,
- ]);
- }
- public function listGroups()
- {
- $limit = input('limit');
- $page = input('page');
- $list = UserGroupsModel::order(['isdefault' => 'desc', 'id' => 'asc'])->limit($limit)->page($page)->append(['isdefault_text'])->select();
- $count = UserGroupsModel::count();
- if ($count == 0) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "未查询到数据",
- ]));
- }
- exit(json_encode([
- 'code' => 0,
- 'msg' => "",
- 'count' => $count,
- 'data' => $list,
- ]));
- }
- public function editGroups()
- {
- $id = input('id/d');
- if (empty($id)) {
- $groups = UserGroupsModel::create([
- 'title' => input('title/s'),
- 'isdefault' => input('isdefault/d') == 2 ? 2 : 1,
- ]);
- } else {
- $administer = UserGroupsModel::find($id);
- $administer->save([
- 'title' => input('title/s'),
- 'isdefault' => input('isdefault/d') == 2 ? 2 : 1,
- ]);
- }
- exit(json_encode([
- 'code' => 0,
- ]));
- }
- public function delGroups()
- {
- $access_admin = session('access_admin');
- $password = input('password');
- if ($access_admin['password'] !== md5($password)) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "操作密码验证失败",
- ]));
- }
- $idarr = input('idarr/a');
- UserGroupsModel::whereIn('id', $idarr)->delete();
- exit(json_encode([
- 'code' => 0,
- 'msg' => "",
- ]));
- }
- // 参数设置
- public function param()
- {
- $param = UserParamModel::where(1)->findOrEmpty();
- return view('user/param', [
- 'param' => $param,
- ]);
- }
- public function editParam()
- {
- $param = UserParamModel::where(1)->findOrEmpty();
- $data = [
- 'redmoney' => input('redmoney/d', 0),
- 'usernumber' => input('usernumber/d', 0),
- 'shareintegral' => input('shareintegral/d', 0),
- 'postintegral' => input('postintegral/d', 0),
- 'inttomoney' => input('inttomoney/d', 0),
- 'minintegral' => input('minintegral/d', 0),
- 'intrecharge' => input('intrecharge/d', 0),
- 'picregworker' => input('picregworker/s', ""),
- 'intregworker' => input('intregworker/d', 0),
- ];
- if ($param->isEmpty()) {
- UserParamModel::create($data);
- } else {
- $data['id'] = $param->id;
- UserParamModel::update($data);
- }
- exit(json_encode([
- 'code' => 0,
- 'msg' => "",
- ]));
- }
- // 用户组
- public function willList()
- {
- return view('user/willlist');
- }
- public function willForm()
- {
- $id = input('id/d, 0');
- $will = UserWill::findOrEmpty($id);
- return view('user/willform', [
- 'will' => $will,
- ]);
- }
- public function listwill()
- {
- $limit = input('limit');
- $page = input('page');
- $list = UserWill::order(['isdefault' => 'desc', 'id' => 'asc'])->limit($limit)->page($page)->append(['isdefault_text'])->select();
- $count = UserWill::count();
- if ($count == 0) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "未查询到数据",
- ]));
- }
- exit(json_encode([
- 'code' => 0,
- 'msg' => "",
- 'count' => $count,
- 'data' => $list,
- ]));
- }
- public function editwill()
- {
- $id = input('id/d');
- if (empty($id)) {
- UserWill::create([
- 'title' => input('title/s'),
- 'isdefault' => input('isdefault/d') == 2 ? 2 : 1,
- ]);
- } else {
- $administer = UserWill::find($id);
- $administer->save([
- 'title' => input('title/s'),
- 'isdefault' => input('isdefault/d') == 2 ? 2 : 1,
- ]);
- }
- exit(json_encode([
- 'code' => 0,
- ]));
- }
- public function delwill()
- {
- $access_admin = session('access_admin');
- $password = input('password');
- if ($access_admin['password'] !== md5($password)) {
- exit(json_encode([
- 'code' => 1,
- 'msg' => "操作密码验证失败",
- ]));
- }
- $idarr = input('idarr/a');
- UserWill::whereIn('id', $idarr)->delete();
- exit(json_encode([
- 'code' => 0,
- 'msg' => "",
- ]));
- }
- public function import()
- {
- $data = ['nickname', 'gender', 'mobile', 'education', 'birthday', 'workexperience', 'jobintention',
- 'com_cate', 'emp_time', 'address', 'eduexperience'];
- $list = importExecl('2.xls', $data, 1);
- $data = [];
- $gender = ['男' => 1, '女' => 2];
- $education = ['初中' => 1, '高中' => 2, '中技' => 3, '中专' => 4, '大专' => 5, '本科' => 6, '硕士' => 7, '博士' => 8];
- $workexperience = ['无经验' => 1, '一年以下' => 2, '1-3年' => 3, '3-5年' => 4, '5-10年' => 5, '10年以上' => 6];
- $jobintention = ['长期工' => 1, '临时工' => 3];
- $rensheCode = RensheCode::where('type', 'emp_time')->column('code', 'name');
- $cateList = ComjobsCateModel::column('id', 'title');
- foreach ($list as $v) {
- $item = [];
- $item['nickname'] = $item['realname'] = $v['nickname'];
- $item['gender'] = $gender[$v['gender']];
- $item['mobile'] = $v['mobile'];
- $item['education'] = $education[$v['education']];
- $item['birthday'] = date('Y-m-d', strtotime($v['birthday']));
- if (empty($workexperience[$v['workexperience']])) {
- halt($v['workexperience']);
- }
- $item['workexperience'] = $workexperience[$v['workexperience']];
- $item['jobintention'] = $jobintention[$v['jobintention']];
- $item['com_cate'] = [];
- if (!empty($v['com_cate'])) {
- $com_cate = explode(',', str_replace(',', ',', $v['com_cate']));
- foreach ($com_cate as $cate) {
- if (!empty($cateList[$cate])) {
- $item['com_cate'][] = $cate;
- }
- }
- }
- $item['emp_time'] = [];
- if (!empty($v['emp_time'])) {
- $emp_time = explode(',', str_replace(',', ',', $v['emp_time']));
- foreach ($emp_time as $time) {
- if (!empty($rensheCode[$time])) {
- $item['emp_time'][] = $time;
- }
- }
- }
- $item['address'] = $v['address'] ?: '';
- $item['eduexperience'] = $v['eduexperience'] ?: '';
- $item['groupsid'] = 2;
- $item['status'] = 2;
- $item['authstatus'] = 3;
- $item['createtime'] = time();
- $data[] = $item;
- }
- foreach ($data as $v) {
- UserModel::create($v);
- }
- return '成功';
- }
- }
|