作者 何书鹏
1 个管道 的构建 通过 耗费 0 秒

二维码邀请

... ... @@ -19,6 +19,7 @@ use app\mobile\model\UserJob;
use app\mobile\model\CompanyJobResume;
use app\mobile\model\UserJobDownload;
use addons\epay\library\Service;
use Endroid\QrCode\QrCode;
/**
* 我的(企业)接口
... ... @@ -317,6 +318,54 @@ class Company extends Api
}
/**
* @ApiWeigh (85)
* @ApiTitle (企业成员管理-二维码邀请)
* @ApiSummary (企业成员管理-二维码邀请)
* @ApiMethod (POST)
*
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1600167441",
"data": {
"invite_qrcode": "http://www.enterprise.top/qrcode/20201017/52b77af2efe121e124c1b26d4d0d7f43.png", //二维码地址
}
})
*/
public function inviteQrcode()
{
$company = $this->model->get($this->company_id);
if(empty($company['invite_qrcode'])){
$qrCode = new QrCode();
$qrCode
->setText($this->company_id)
->setSize(300)
->setPadding(10)
->setErrorCorrection('high')
->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0])
->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0])
->setLabelFontSize(16)
->setImageType(QrCode::IMAGE_TYPE_PNG)
;
$dir = 'qrcode/'.date('Ymd');
if (!file_exists($dir)){
mkdir($dir,0777,true);
}
$url = $dir.'/'.md5(microtime(true)).'.png';
// save it to a file
$qrCode->save($url);
$company->save([
'invite_qrcode' => '/'.$url
]);
}
$this->success('成功',[
'invite_qrcode' => $company->invite_qrcode
]);
}
/**
* @ApiWeigh (83)
* @ApiTitle (企业套餐)
* @ApiSummary (企业套餐)
... ...
... ... @@ -6,6 +6,7 @@ use app\mobile\model\IndexBanner;
use app\mobile\model\News;
use app\mobile\model\Exam;
use app\mobile\model\UserExam;
use app\mobile\model\CompanyUser;
/**
* 首页接口
... ... @@ -206,4 +207,46 @@ class Index extends Api
News::where('id',$news_id)->setInc('read_num_real');
$this->success('成功',$info);
}
/**
* @ApiTitle (扫描企业二维码-加入企业)
* @ApiSummary (扫描企业二维码-加入企业)
* @ApiMethod (POST)
*
* @ApiParams (name="company_id", type="int", required=true, description="公司ID")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1599026840",
"data": null
})
*/
public function joinCompanyInviteQrcode()
{
$user = $this->auth->getUser();
$company_id = $this->request->param('company_id');
// 验证申请状态
$company_user = CompanyUser::where('company_id',$company_id)
->where('user_id',$user['id'])
->field('status')
->find();
if($company_user){
if($company_user['status'] == '0'){
$company_user->status = '1';
$company_user->save();
}
if($company_user['status'] == '1'){
$this->error('加入企业成功,请勿重复提交申请');
}
}
CompanyUser::create([
'user_id' => $this->auth->id,
'company_id' => $company_id,
'name' => $user['nickname'],
'mobile' => $user['mobile'],
'status' => '1'
]);
$this->success('加入企业成功');
}
}
\ No newline at end of file
... ...
... ... @@ -12,4 +12,9 @@ class Company extends Model
// 定义时间戳字段名
protected $createTime = 'createtime';
protected $updateTime = 'updatetime';
// 格式化二维码
public function getInviteQrcodeAttr($value){
return !empty($value) ? request()->domain().$value : '';
}
}
\ No newline at end of file
... ...
此 diff 太大无法显示。