2019-09-06 23:53:10 +08:00

86 lines
2.5 KiB
PHP
Executable File

<?php
namespace wstmart\common\model;
use think\Db;
/**
* ============================================================================
* 验证处理类
*/
class Auth extends Base{
protected $table = '';
public function __construct(){
parent::__construct();
$this->table = Db::name('auth_personal');
}
public function setTable($tableName='auth_company'){
$this->table = Db::name($tableName);
}
public function getStatusTextAttr($value,$data){
$status = [-1=>'已拒绝',0=>'待审核',1=>'已通过'];
return $status[$data['status']];
}
/**
* 获取单条信息
* @param [type] $where [description]
* @param string $field [description]
* @return [type] [description]
*/
public function getInfo($where,$field='*'){
return $this->table->where($where)->field($field)->find();
}
/**
* 获取单条信息
* @param [type] $where [description]
* @param string $field [description]
* @return [type] [description]
*/
public function getField($where,$field='id'){
return $this->table->where($where)->value($field);
}
/**
* 插入单条信息
* @param string $data [description]
* @return [type] [description]
*/
public function insertInfo($data){
$data['createTime'] = time();
return $this->table->insert($data);
}
/**
* 更新单条信息
* @param [type] $where [description]
* @param string $data [description]
* @return [type] [description]
*/
public function updateInfo($where,$data){
return $this->table->where($where)->update($data);
}
/**
* 根据手机号获取单条信息
* @param [type] $where [description]
* @param string $data [description]
* @return [type] [description]
*/
public function getAuthInfoByMobile($userPhone){
$where['userPhone']=$userPhone;
$where['dataFlag'] = 1;
$userInfo = getUserInfo($where,'userId,authType');
if(!$userInfo) return WSTReturn('手机号不存在');
if(1 == $userInfo['authType']){//个人认证
$field = 'householdName uName,householdIdCard idCard';
}elseif(0 == $userInfo['authType']){
return WSTReturn('请联系该用户实名认证');
}elseif(2 == $userInfo['authType']){
$this->setTable('auth_company');
$field = 'trueName uName,idCard';
//return WSTReturn('合作账号不可亲人认证');
}
$rs = $this->getInfo(['userId'=>$userInfo['userId']],$field);
if($rs){
return WSTReturn('成功',1,$rs);
}
return WSTReturn('获取失败,状态异常');
}
}