You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
244 lines
10 KiB
244 lines
10 KiB
<?php
|
|
defined('IN_IA') or exit('Access Denied');
|
|
class CertifiedModuleUniapp extends Uniapp
|
|
{
|
|
|
|
public function initApplyCertified()
|
|
{
|
|
global $_W , $_GPC;
|
|
|
|
$validate = Member::validateMemberIdentity($_W['mid'],false);
|
|
if (!$validate['status']) $this->renderError($validate['msg']);
|
|
|
|
$this->renderSuccess('成功');
|
|
}
|
|
|
|
/**
|
|
* 企业商户认证申请(商务合作)
|
|
* @return void
|
|
*/
|
|
public function applyMerchantCertified() {
|
|
global $_W , $_GPC;
|
|
|
|
$type = $_GPC['type'] ?: 'get'; // get 获取数据 | set 创建申请
|
|
$storeid = $_GPC['storeid']; // 商户id
|
|
|
|
# 验证是否有申请条件
|
|
$validate = Member::validateMemberIdentity($_W['mid'],false);
|
|
if (!$validate['status']) $this->renderError($validate['msg']);
|
|
|
|
$identity_id = pdo_getcolumn(PDO_NAME . 'member',['id' => $_W['mid']],'identity_id');
|
|
if ($identity_id != 5) $this->renderError('非企业身份,禁止申请商户合作');
|
|
|
|
# 创建申请
|
|
if ($type == 'set') {
|
|
$mobile = $_GPC['mobile']; // 手机号
|
|
$position = $_GPC['position']; // 职务
|
|
$name = $_GPC['name']; // 姓名
|
|
$code = $_GPC['code']; // 短信验证码
|
|
|
|
if (empty($storeid) || !is_numeric($storeid)) $this->renderError('缺少商户id');
|
|
if (empty($name)) $this->renderError('请输入姓名');
|
|
if (empty($position)) $this->renderError('请输入职务');
|
|
if (empty($mobile)) $this->renderError('请输入手机号');
|
|
if (!preg_match("/^1[3-9]\d{9}$/",$mobile)) $this->renderError('请输入正确的手机号');
|
|
|
|
$nameRes = Filter::init($name,$_W['source'],1);
|
|
if ($nameRes['errno'] == 0) $this->renderError('姓名'.$nameRes['message']);
|
|
$positionRes = Filter::init($position,$_W['source'],1);
|
|
if ($positionRes['errno'] == 0) $this->renderError('职务'.$positionRes['message']);
|
|
|
|
|
|
$this->checkCode($mobile,$code);
|
|
|
|
$queryRes = pdo_get(PDO_NAME . 'merchant_certified',['storeid'=>$storeid,'status' => [0,1]],'status');
|
|
if ($queryRes) {
|
|
$this->renderError($queryRes['status'] == 1 ? '商务合作认证申请已通过,请勿重复申请' : '商户合作认证申请信息已提交,请勿重复申请');
|
|
}
|
|
|
|
$data = [
|
|
'uniacid' => $_W['uniacid'],
|
|
'storeid' => $storeid,
|
|
'name' => trim($name),
|
|
'position' => trim($position),
|
|
'mobile' => $mobile,
|
|
'create_time' => time()
|
|
];
|
|
|
|
$insertRes = pdo_insert(PDO_NAME . 'merchant_certified',$data);
|
|
if (!$insertRes) $this->renderError('认证申请失败');
|
|
$this->renderSuccess('已提交申请');
|
|
} else {
|
|
if (empty($storeid)) $storeid = pdo_getcolumn(PDO_NAME . 'merchantuser',['mid' => $_W['mid']],'storeid');
|
|
|
|
$list = ['name' => '', 'position' => '', 'mobile' => '', 'remark' => '', 'status' => 0];
|
|
# 获取上次审核数据
|
|
$lastRes = pdo_getall(PDO_NAME . 'merchant_certified',['storeid' => $storeid],array_keys($list),'',' check_time desc',1);
|
|
foreach ($lastRes as $lastRow) {
|
|
$list = $lastRow;
|
|
}
|
|
|
|
$list['reject'] = $list['remark'];
|
|
unset($list['remark']);
|
|
|
|
$this->renderSuccess('数据返回成功',$list);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 教师认证申请
|
|
* @return void
|
|
*/
|
|
public function applyTeacherCertified() {
|
|
|
|
global $_W , $_GPC;
|
|
|
|
$type = $_GPC['type'] ?: 'get'; // get 获取上次申请数据 set 创建申请
|
|
|
|
$validate = Member::validateMemberIdentity($_W['mid']);
|
|
if (!$validate['status']) $this->renderError($validate['msg']);
|
|
|
|
if ($type == 'set') {
|
|
$name = $_GPC['name']; // 姓名
|
|
$mobile = $_GPC['mobile']; // 手机号
|
|
$code = $_GPC['code']; // 短信验证码
|
|
$school_name = $_GPC['school_name']; // 学校名称
|
|
$faculty = $_GPC['faculty']; // 院系
|
|
$documents = $_GPC['documents']; // 教师工作证件
|
|
|
|
if (empty($name)) $this->renderError('请输入姓名');
|
|
if (empty($mobile)) $this->renderError('请输入手机号');
|
|
if (!preg_match("/^1[3-9]\d{9}$/",$mobile)) $this->renderError('请输入正确的手机号');
|
|
if (empty($school_name)) $this->renderError('请输入学校名称');
|
|
if (empty($faculty)) $this->renderError('请输入院系');
|
|
if (empty($documents)) $this->renderError('请上传教师工作证件');
|
|
|
|
|
|
$nameRes = Filter::init($name,$_W['source'],1);
|
|
if ($nameRes['errno'] == 0) $this->renderError('姓名'.$nameRes['message']);
|
|
$school_nameRes = Filter::init($school_name,$_W['source'],1);
|
|
if ($school_nameRes['errno'] == 0) $this->renderError('学校名称'.$school_nameRes['message']);
|
|
$facultyRes = Filter::init($faculty,$_W['source'],1);
|
|
if ($facultyRes['errno'] == 0) $this->renderError('院系'.$facultyRes['message']);
|
|
$documentsRes = Filter::init($documents,$_W['source'],2);
|
|
if($documentsRes['errno'] == 0) $this->renderError('教师工作证件'.$documentsRes['message']);
|
|
|
|
$this->checkCode($mobile,$code);
|
|
|
|
$queryRes = pdo_get(PDO_NAME . 'member_teacher_certified',['mid'=>$_W['mid'],'status' => [0,1]],'status');
|
|
if ($queryRes) {
|
|
$this->renderError($queryRes['status'] == 1 ? '教师认证申请已通过,请勿重复申请' : '教师认证申请信息已提交,请勿重复申请');
|
|
}
|
|
|
|
$data = [
|
|
'uniacid' => $_W['uniacid'],
|
|
'mid' => $_W['mid'],
|
|
'name' => trim($name),
|
|
'mobile' => trim($mobile),
|
|
'school_name' => trim($school_name),
|
|
'faculty' => trim($faculty),
|
|
'documents' => trim($documents),
|
|
'create_time' => time()
|
|
];
|
|
|
|
$insertRes = pdo_insert(PDO_NAME . 'member_teacher_certified',$data);
|
|
if (!$insertRes) $this->renderError('认证申请失败');
|
|
$this->renderSuccess('已提交申请');
|
|
} else {
|
|
|
|
$list = ['name' => '', 'mobile' => '', 'school_name' => '', 'faculty' => '', 'documents' => '', 'remark' => '', 'status' => 0];
|
|
# 获取上次审核数据
|
|
$lastRes = pdo_getall(PDO_NAME . 'member_teacher_certified',['mid' => $_W['mid']],array_keys($list),'',' certified_time desc',1);
|
|
foreach ($lastRes as $lastRow) {
|
|
$lastRow['documents'] = tomedia($lastRow['documents']);
|
|
$list = $lastRow;
|
|
}
|
|
$list['reject'] = $list['remark'];
|
|
unset($list['remark']);
|
|
|
|
$this->renderSuccess('数据返回成功',$list);
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
* 达人认证申请
|
|
* @return void
|
|
*/
|
|
public function applyBloggerCertified() {
|
|
|
|
global $_W , $_GPC;
|
|
|
|
$type = $_GPC['type'] ?: 'get'; // get 获取上次申请数据 set 创建申请
|
|
|
|
$validate = Member::validateMemberIdentity($_W['mid']);
|
|
if (!$validate['status']) $this->renderError($validate['msg']);
|
|
|
|
if ($type == 'set') {
|
|
$name = $_GPC['name']; // 姓名/昵称
|
|
$mobile = $_GPC['mobile']; // 联系电话
|
|
$code = $_GPC['code']; // 短信验证码
|
|
$screenshot = $_GPC['screenshot']; // 请上传其他平台粉丝截图
|
|
|
|
if (empty($name)) $this->renderError('请输入姓名');
|
|
if (empty($mobile)) $this->renderError('请输入手机号');
|
|
if (!preg_match("/^1[3-9]\d{9}$/",$mobile)) $this->renderError('请输入正确的手机号');
|
|
if (empty($screenshot)) $this->renderError('请上传其他平台粉丝截图');
|
|
|
|
$nameRes = Filter::init($name,$_W['source'],1);
|
|
if ($nameRes['errno'] == 0) $this->renderError('姓名'.$nameRes['message']);
|
|
$screenshotRes = Filter::init($screenshot,$_W['source'],2);
|
|
if($screenshotRes['errno'] == 0) $this->renderError('其他平台粉丝截图'.$screenshotRes['message']);
|
|
|
|
$this->checkCode($mobile,$code);
|
|
|
|
$queryRes = pdo_get(PDO_NAME . 'member_daren_certified',['mid'=>$_W['mid'],'status' => [0,1]],'status');
|
|
if ($queryRes) {
|
|
$this->renderError($queryRes['status'] == 1 ? '达人认证申请已通过,请勿重复申请' : '达人认证申请信息已提交,请勿重复申请');
|
|
}
|
|
|
|
$data = [
|
|
'uniacid' => $_W['uniacid'],
|
|
'mid' => $_W['mid'],
|
|
'name' => trim($name),
|
|
'mobile' => $mobile,
|
|
'screenshot' => $screenshot,
|
|
'create_time' => time()
|
|
];
|
|
|
|
$insertRes = pdo_insert(PDO_NAME . 'member_daren_certified',$data);
|
|
if (!$insertRes) $this->renderError('认证申请失败');
|
|
$this->renderSuccess('已提交申请');
|
|
} else {
|
|
|
|
$list = ['name' => '', 'mobile' => '', 'screenshot' => '', 'remark' => '', 'status' => 0];
|
|
# 获取上次审核数据
|
|
$lastRes = pdo_getall(PDO_NAME . 'member_daren_certified',['mid' => $_W['mid']],array_keys($list),'',' certified_time desc',1);
|
|
foreach ($lastRes as $lastRow) {
|
|
$lastRow['screenshot'] = tomedia($lastRow['screenshot']);
|
|
$list = $lastRow;
|
|
}
|
|
$list['reject'] = $list['remark'];
|
|
unset($list['remark']);
|
|
|
|
$this->renderSuccess('数据返回成功',$list);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 短信验证码验证
|
|
* @param $mobile
|
|
* @param $code
|
|
* @return void
|
|
*/
|
|
private function checkCode($mobile,$code) {
|
|
$pin_info = pdo_get('wlmerchant_pincode' , ['mobile' => $mobile]);
|
|
if (empty($pin_info)) {
|
|
$this->renderError('验证码错误');
|
|
}
|
|
if ($pin_info['time'] < time() - 300) {
|
|
$this->renderError('验证码已过期,请重新获取');
|
|
}
|
|
if ($code != $pin_info['code']) $this->renderError('验证码错误');
|
|
}
|
|
}
|