fetch(); } /** * 讲师列表获取 * @return * */ public function lecturer_merchant_list() { $where = parent::getMore([ ['page', 1], ['limit', 20], ['title', ''], ]); return JsonService::successlayui(MerchantModel::getLecturerMerchantList($where)); } /** * 删除讲师后台 * @param int $id 修改的主键 * @return json * */ public function delete($id = 0) { if (!$id) return JsonService::fail('缺少参数'); $merchant = MerchantModel::get($id); if (!$merchant) return JsonService::fail('讲师后台不存在'); if (MerchantModel::delMerchant($id)) { Lecturer::where('mer_id', $id)->update(['is_del' => 1]); User::where('uid', $merchant['uid'])->update(['business' => 0]); return JsonService::successful('删除成功'); } else return JsonService::fail(UserEnterModel::getErrorInfo('删除失败')); } /**编辑讲师信息 * @param $id * @return mixed */ public function edit($id) { $role = MerchantModel::get($id); $merchant = Db::name('lecturer')->where('mer_id',$id)->value('entry_type'); if($merchant == 1){ $menus = json(MerchantMenus::ruleList())->getContent(); }else{ $menus = json(InstitutionMenus::ruleList())->getContent(); } $this->assign(['title' => '编辑讲师后台', 'roles' => $role->toJson(), 'menus' => $menus, 'action' => Url::build('update', array('id' => $id))]); return $this->fetch('edit'); } public function insedit($id) { $role = MerchantModel::get($id); $merchant = Db::name('lecturer')->where('mer_id',$id)->value('entry_type'); if($merchant == 1){ $menus = json(MerchantMenus::ruleList())->getContent(); }else{ $menus = json(InstitutionMenus::ruleList())->getContent(); } $this->assign(['title' => '编辑讲师后台', 'roles' => $role->toJson(), 'menus' => $menus, 'action' => Url::build('update', array('id' => $id))]); return $this->fetch('insedit'); } /** * 修改状态 * @param $id * @return \think\response\Json */ public function modify($id, $status) { if (!$id) return JsonService::fail('数据错误'); $merchantInfo = MerchantModel::where('id', $id)->where('is_del', 0)->find(); if (!$merchantInfo) return JsonService::fail('数据错误'); $data['status'] = $status; if (!MerchantModel::edit($data, $id)) { return JsonService::fail(MerchantModel::getErrorInfo('修改失败,请稍候再试!')); } else { $dat['is_show'] = $status; Lecturer::edit($dat, $merchantInfo['lecturer_id'], 'id'); return JsonService::successful('修改成功!'); } } /**登录 * @param $id * @throws \think\Exception * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function login($id) { $agentInfo = AgentUserModel::where('id', $id)->where('is_del', 0)->find(); if (!$agentInfo) return $this->failed('登陆的机构后台不存在!'); AgentUserAdminModel::setLoginInfo($agentInfo->toArray()); AgentUserAdminModel::setMerchantInfo($agentInfo->toArray()); return $this->redirect(Url::build('/agent/index/index')); } /**重置密码 * @param $id */ public function reset_pwd($id) { if (!$id) return JsonService::fail('参数错误失败!'); $pwd = 1234567; // var_dump($id); $adminPwd = AgentUserModel::where('id', $id)->value('pwd'); if ($pwd == $adminPwd) return JsonService::fail('您的密码无需重置!'); if (AgentUserModel::where('id', $id)->update(['pwd' => 1234567])) return JsonService::successful('重置成功!'); else return JsonService::fail('重置失败!'); } }