$data['type'] == 1 ? get_config_content('lecturer_entry') : get_config_content('institution_entry'), 'title' => $data['type'] == 1 ? '机构入驻协议' : '机构入驻协议', 'uid' => $this->uid ]); } /**机构申请 * @return mixed */ public function index() { $this->assign([ 'content' => get_config_content('lecturer_entry'), 'title' => '机构入驻协议' ]); return $this->fetch(); } /**机构信息 * @return mixed */ public function info($mer_id) { if (!$mer_id) $this->failed('参数有误!'); $business = isset($this->userInfo['business']) ? $this->userInfo['business'] : 0; if (!$business) $this->failed('您不是机构,请先申请!'); $merchant = InstitutionModel::where(['id' => $mer_id, 'uid' => $this->uid, 'status' => 1, 'is_del' => 0, 'estate' => 1])->field('id,uid,status,is_del,estate,mer_special_divide,mer_store_divide,mer_event_divide,mer_data_divide,mer_test_divide,gold_divide')->find(); $admin = InstitutionAdminModel::where(['mer_id' => $mer_id, 'uid' => $this->uid, 'status' => 1, 'is_del' => 0, 'level' => 0])->field('mer_id,uid,account,level,status,is_del')->find(); if (!$merchant) $this->failed('机构信息有误!'); if (!$admin) $this->failed('登录账号不存在!'); $this->assign([ 'mer_id' => $mer_id, 'url' => SystemConfigService::get('site_url') . '/merchant/login/index', 'merchant' => $merchant, 'admin' => $admin, ]); return $this->fetch(); } public function info_api($mer_id) { if (!$mer_id) $this->failed('参数有误!'); $business = isset($this->userInfo['business']) ? $this->userInfo['business'] : 0; if (!$business) $this->failed('您不是机构,请先申请!'); $merchant = InstitutionModel::where(['id' => $mer_id, 'uid' => $this->uid, 'status' => 1, 'is_del' => 0, 'estate' => 1])->field('id,uid,status,is_del,estate,mer_special_divide,mer_store_divide,mer_event_divide,mer_data_divide,mer_test_divide,gold_divide')->find(); $admin = InstitutionAdminModel::where(['mer_id' => $mer_id, 'uid' => $this->uid, 'status' => 1, 'is_del' => 0, 'level' => 0])->field('mer_id,uid,account,level,status,is_del')->find(); if (!$merchant) $this->failed('机构信息有误!'); if (!$admin) $this->failed('登录账号不存在!'); return JsonService::successful([ 'mer_id' => $mer_id, 'url' => SystemConfigService::get('site_url') . '/institution/login/index', 'merchant' => $merchant, 'admin' => $admin, ]); } /**机构明细 * @return mixed */ public function income() { return $this->fetch(); } /** * 机构详情 * @return mixed */ public function teacher_detail($id = 0) { $business = isset($this->userInfo['business']) ? $this->userInfo['business'] : 0; $mer_id = 0; if ($business) { $data = InstitutionModel::where(['status' => 1, 'is_del' => 0, 'estate' => 1, 'uid' => $this->uid])->field('id,lecturer_id')->find(); if (!$data && !$id) $this->failed('请检查您的机构后台状态是否关闭!'); $mer_id = $data ? $data['id'] : 0; $lecturer_id = $data ? $data['lecturer_id'] : 0; } $id = $id ? $id : $lecturer_id; if (!$id) $this->failed('您不是机构,请先申请!'); $lecturer = Lecturer::details($id); if (!$lecturer) $this->failed('机构信息无法访问!'); $this->assign(['lecturer' => $lecturer, 'mer_id' => $mer_id]); return $this->fetch(); } public function teacher_detail_api($id = 0) { $business = isset($this->userInfo['business']) ? $this->userInfo['business'] : 0; $mer_id = 0; if ($business) { $data = InstitutionModel::where(['status' => 1, 'is_del' => 0, 'estate' => 1, 'uid' => $this->uid])->field('id,lecturer_id')->find(); if (!$data && !$id) $this->failed('请检查您的机构后台状态是否关闭!'); $mer_id = $data ? $data['id'] : 0; $lecturer_id = $data ? $data['lecturer_id'] : 0; } $id = $id ? $id : $lecturer_id; if (!$id) $this->failed('您不是机构,请先申请!'); $lecturer = Lecturer::details($id); if (!$lecturer) $this->failed('机构信息无法访问!'); return JsonService::successful([ 'lecturer' => $lecturer, 'mer_id' => $mer_id, 'business' => $business ]); } /**收益及提现统计 * @param int $mer_id */ public function lecturer_income($mer_id = 0) { $data = InstitutionFlowingWater::get_merchant_data($mer_id); $data['extract'] = UserExtract::userMerExtractTotalPrice($mer_id); $data['gold'] = InstitutionBill::userMerGoldPrice($mer_id); return JsonService::successful($data); } /** * 机构列表 * @return mixed */ public function teacher_list() { return $this->fetch(); } /** * 机构列表 */ public function get_lecturer_list() { list($page, $limit, $search) = UtilService::getMore([ ['page', 1], ['limit', 10], ['search', ''] ], $this->request, true); $uid = $this->uid ? $this->uid : 0; $list = Lecturer::getLecturerList($uid, $page, $limit, $search); return JsonService::successful($list); } /** * 机构名下课程 */ public function lecturer_special_list() { list($mer_id, $page, $limit) = UtilService::postMore([ ['mer_id', 0], ['page', 1], ['limit', 10] ], $this->request, true); $mer_id = $this->institution; $list = SpecialModel::getLecturerSpecialList($mer_id, $page, $limit, 1); return JsonService::successful($list); } /** * 机构名下资料 */ public function lecturer_download_list() { list($mer_id, $page, $limit) = UtilService::postMore([ ['mer_id', 0], ['page', 1], ['limit', 10] ], $this->request, true); $mer_id = $this->institution; $list = DataDownload::getLecturerDataDownloadList($mer_id, $page, $limit, 1); return JsonService::successful($list); } /** * 机构名下活动 */ public function lecturer_event_list() { list($mer_id, $page, $limit) = UtilService::postMore([ ['mer_id', 0], ['page', 1], ['limit', 10] ], $this->request, true); $mer_id = $this->institution; $list = EventRegistration::getLecturerEventList($mer_id, $page, $limit, 1); return JsonService::successful($list); } /** * 机构名下商品 */ public function lecturer_store_list() { list($mer_id, $page, $limit) = UtilService::postMore([ ['mer_id', 0], ['page', 1], ['limit', 10] ], $this->request, true); $mer_id = $this->institution; $list = StoreProduct::getLecturerStoreList($mer_id, $page, $limit, 1); return JsonService::successful($list); } /** * 机构名下试卷 */ public function lecturer_test_list() { list($mer_id, $type, $page, $limit) = UtilService::postMore([ ['mer_id', 0], ['type', 1], ['page', 1], ['limit', 10] ], $this->request, true); $mer_id = $this->institution; $list = TestPaper::getMerTestPaperList($mer_id, $type, $page, $limit, 1); return JsonService::successful($list); } /**机构流水明细 * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\ModelNotFoundException * @throws \think\exception\DbException */ public function get_flowing_water_list() { $where = UtilService::getMore([ ['category', 'now_money'], ['is_extract', 0], ['page', 1], ['limit', 10] ]); $where['mer_id'] = InstitutionModel::getMerId($this->uid); return JsonService::successful(InstitutionBill::get_user_flowing_water_list($where)); } // 法人实名认证 public function apply_verify() { $data = UtilService::getMore([ ['uid', 0], ['cert_name', ''], ['cert_no', ''], ['type', ''], ]); if (!$data['uid']) return JsonService::fail('用户不存在'); if (!$data['cert_name']) return JsonService::fail('姓名不能为空'); if (!$data['cert_no']) return JsonService::fail('身份证号不存在'); $res = AlipayTradeWapService::init()->applyVerify($data); echo $res; } /** * 机构/机构申请 * */ public function apply() { $data = UtilService::postMore([ ['province', ''], ['city', ''], ['district', ''], ['address', ''], ['merchant_name', ''], ['link_tel', ''], ['code', ''], ['charter', []], ['merchant_head', ''], ['label', []], ['explain', ''], ['introduction', ''], ['view', []], ]); $data['label'] = $data['view']; if (!$data['code']) return JsonService::fail('请输入验证码'); $code = md5('is_phone_code' . $data['code']); if (!SmsCode::CheckCode($data['link_tel'], $code)) return JsonService::fail('验证码验证失败'); SmsCode::setCodeInvalid($data['link_tel'], $code); unset($data['view']); $res = UserInstitution::setUserEnter($data, $this->uid); if ($res) return JsonService::successful('提交成功!'); else return JsonService::fail('提交失败!'); } public function InstitutionApply() { $data = UtilService::postMore([ ['province', ''], ['city', ''], ['district', ''], ['address', ''], ['merchant_name', ''], ['link_tel', ''], ['code', ''], ['charter', []], ['merchant_head', ''], ['label', []], ['explain', ''], ['introduction', ''], ['view', []], // 企业信息 ['emial', ''], ['business_license', ''], ['corporate_name', ''], ['credit_code', ''], ['business_term', ''], ['card_straight', ''], ['card_side', ''], ['card_id', ''], ['entry_type', 1], ['cert_id', 0], ['certificate', ''], ]); if (!$data['business_term']) { !$data['business_term'] = "长期"; } $data['label'] = $data['view']; if (!$data['code']) return JsonService::fail('请输入验证码'); $code = md5('is_phone_code' . $data['code']); if (!SmsCode::CheckCode($data['link_tel'], $code)) return JsonService::fail('验证码验证失败'); SmsCode::setCodeInvalid($data['link_tel'], $code); unset($data['view']); $res = UserInstitution::setUserEnter($data, $this->uid); if ($res) return JsonService::successful('提交成功!'); else return JsonService::fail('提交失败!'); } public function del_verify() { $data = UtilService::getMore([ ['type', ''], ]); User::where('uid', $this->uid)->update([ 'certify_id' => $data['type'] ]); } /** * 检查是否提交申请 */ public function is_apply() { $data = UserInstitution::inspectStatus($this->uid); return JsonService::successful($data); } /** * 检查是否认证成功 */ public function is_verify() { $res = AlipayTradeWapService::init()->applyQuery($this->uid); return JsonService::successful($res); } /** * 获得申请数据 */ public function apply_data() { $apply = UserInstitution::inspectUserEnter($this->uid); $apply['certificate'] = json_decode($apply['certificate'], true); return JsonService::successful($apply); } /**是否关注 * @param $mer_id */ public function is_follow($mer_id) { if (!$mer_id) return JsonService::fail('参数错误'); $res = InstitutionFollow::isFollow($this->uid, $mer_id); return JsonService::successful($res); } /**用户关注 取消关注 机构 * @param $mer_id * @param $is_follow 0 =取消关注 1= 关注 */ public function user_follow($mer_id, $is_follow) { if (!$mer_id) return JsonService::fail('参数错误'); $res = InstitutionFollow::user_merchant_follow($this->uid, $mer_id, $is_follow); return JsonService::successful($res); } /**机构关注列表 * @param int $page * @param int $limit */ public function get_user_follow_list($page = 1, $limit = 20) { $data = InstitutionFollow::get_user_merchant_follow_list($this->uid, $page, $limit); return JsonService::successful($data); } // 资质 public function institution() { $data = EducationModel::field('id,title')->select()->toArray(); return JsonService::successful($data); } // 获取某一条资质的详情 public function institutiondetails() { $params = UtilService::getMore([ ['id', ''], ]); $data = EducationModel::where('id', $params['id'])->find(); $qualifications = json_decode($data['qualifications'], true); return JsonService::successful($qualifications); } }