...
|
...
|
@@ -27,7 +27,9 @@ use app\mobile\model\TopicAppraise; |
|
|
use app\mobile\model\TopicAppraiseGood;
|
|
|
use app\mobile\model\UserJob;
|
|
|
use app\mobile\model\CompanyJob;
|
|
|
use app\mobile\model\Statistic;
|
|
|
use addons\epay\library\Service;
|
|
|
use Endroid\QrCode\QrCode;
|
|
|
|
|
|
/**
|
|
|
* 我的接口
|
...
|
...
|
@@ -64,12 +66,35 @@ class User extends Api |
|
|
$ret = Sms::check($mobile, $code, 'register');
|
|
|
!$ret && $this->error('验证码不正确');
|
|
|
|
|
|
$ret = $this->auth->register($username=get_order_sn(), $password, $email='', $mobile, []);
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
$ret = $this->auth->register($username=get_order_sn(), $password, $email='', $mobile, []);
|
|
|
// 记录每日注册数量
|
|
|
$statistic = Statistic::where('today',date('Y-m-d'))->find();
|
|
|
if($statistic){
|
|
|
$statistic->save(['register_times' => $statistic->register_times+1]);
|
|
|
}else{
|
|
|
(new Statistic)->save([
|
|
|
'register_times' => 1,
|
|
|
'today' => date('Y-m-d')
|
|
|
]);
|
|
|
}
|
|
|
Db::commit();
|
|
|
} catch (PDOException $e) {
|
|
|
Db::rollback();
|
|
|
$this->auth->logout();
|
|
|
$this->error($e->getMessage());
|
|
|
} catch (Exception $e) {
|
|
|
Db::rollback();
|
|
|
$this->auth->logout();
|
|
|
$this->error($e->getMessage());
|
|
|
}
|
|
|
if ($ret) {
|
|
|
$this->auth->setAllowFields(['id', 'mobile', 'group_id']);
|
|
|
$data = ['userinfo' => $this->auth->getUserinfo()];
|
|
|
$this->success('注册成功', $data);
|
|
|
} else {
|
|
|
Db::rollback();
|
|
|
$this->error($this->auth->getError());
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -129,9 +154,6 @@ class User extends Api |
|
|
Db::startTrans();
|
|
|
try {
|
|
|
$ret = $this->auth->register($username=get_order_sn(), $password, $email='', $mobile, []);
|
|
|
if (!$ret) {
|
|
|
$this->error($this->auth->getError());
|
|
|
}
|
|
|
$company = Company::create([
|
|
|
'user_id' => $this->auth->id,
|
|
|
'name' => $name,
|
...
|
...
|
@@ -141,6 +163,16 @@ class User extends Api |
|
|
]);
|
|
|
// 添加企业邀请码
|
|
|
$this->setInviteCode($company['id']);
|
|
|
// 记录每日注册数量
|
|
|
$statistic = Statistic::where('today',date('Y-m-d'))->find();
|
|
|
if($statistic){
|
|
|
$statistic->save(['register_times' => $statistic->register_times+1]);
|
|
|
}else{
|
|
|
(new Statistic)->save([
|
|
|
'register_times' => 1,
|
|
|
'today' => date('Y-m-d')
|
|
|
]);
|
|
|
}
|
|
|
Db::commit();
|
|
|
} catch (PDOException $e) {
|
|
|
Db::rollback();
|
...
|
...
|
@@ -151,8 +183,14 @@ class User extends Api |
|
|
$this->auth->logout();
|
|
|
$this->error($e->getMessage());
|
|
|
}
|
|
|
$this->auth->setAllowFields(['id', 'mobile', 'group_id']);
|
|
|
$this->success('注册成功', ['userinfo' => $this->auth->getUserinfo()]);
|
|
|
if($ret){
|
|
|
$this->auth->setAllowFields(['id', 'mobile', 'group_id']);
|
|
|
$data = ['userinfo' => $this->auth->getUserInfo()];
|
|
|
}else{
|
|
|
Db::rollback();
|
|
|
$this->error($this->auth->getError());
|
|
|
}
|
|
|
$this->success('注册成功', $data);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -210,12 +248,35 @@ class User extends Api |
|
|
empty($password) && $this->error('请输入密码');
|
|
|
!Validate::regex($mobile, "^1\d{10}$") && $this->error('手机号格式不正确');
|
|
|
|
|
|
$ret = $this->auth->login($mobile, $password);
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
$ret = $this->auth->login($mobile, $password);
|
|
|
// 记录日活
|
|
|
$statistic = Statistic::where('today',date('Y-m-d'))->find();
|
|
|
if($statistic){
|
|
|
$statistic->save(['active_times' => $statistic->active_times+1]);
|
|
|
}else{
|
|
|
(new Statistic)->save([
|
|
|
'active_times' => 1,
|
|
|
'today' => date('Y-m-d')
|
|
|
]);
|
|
|
}
|
|
|
Db::commit();
|
|
|
} catch (PDOException $e) {
|
|
|
Db::rollback();
|
|
|
$this->auth->logout();
|
|
|
$this->error($e->getMessage());
|
|
|
} catch (Exception $e) {
|
|
|
Db::rollback();
|
|
|
$this->auth->logout();
|
|
|
$this->error($e->getMessage());
|
|
|
}
|
|
|
if ($ret) {
|
|
|
$this->auth->setAllowFields(['id', 'mobile', 'group_id']);
|
|
|
$data = ['userinfo' => $this->auth->getUserInfo()];
|
|
|
$this->success('登录成功', $data);
|
|
|
} else {
|
|
|
Db::rollback();
|
|
|
$this->error($this->auth->getError());
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -1809,4 +1870,68 @@ class User extends Api |
|
|
empty($info) && $this->error('问题不存在');
|
|
|
$this->success('成功', $info);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @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 poster()
|
|
|
{
|
|
|
$user = \app\mobile\model\User::get($this->auth->id);
|
|
|
empty($user['image']) && $this->error('请先上传用户头像');
|
|
|
//将用户的头像保存到本地
|
|
|
$user_dir = 'uploads/user';
|
|
|
if (!file_exists($user_dir)){
|
|
|
mkdir($user_dir,0777,true);
|
|
|
}
|
|
|
$user_image = $user_dir.'/'.$user['id'].'.png';
|
|
|
file_put_contents($user_image,file_get_contents($user['image']));
|
|
|
createRoundImg($user_image);
|
|
|
\think\Image::open($user_image)->thumb(73,73,\think\Image::THUMB_CENTER)->save($user_image);
|
|
|
|
|
|
$image = \think\Image::open(ROOT_PATH.'public/assets/img/poster_qr_bg1.png');
|
|
|
$path_ttf = ROOT_PATH.'public/assets/fonts/PingFang.ttf';
|
|
|
// 我的二维码
|
|
|
$qrCode = new QrCode();
|
|
|
$qrCode
|
|
|
->setText($user['id'])
|
|
|
->setSize(210)
|
|
|
->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);
|
|
|
$user_code = $user_dir.'/qrcode_'.$user['id'].'.png';
|
|
|
// save it to a file
|
|
|
$qrCode->save($user_code);
|
|
|
$user_poster = $user_dir.'/poster_'.$user['id'].'.png';
|
|
|
$desc = "我正在“精工筑匠”\n学习“一级建造师资格证考试”\n来和我一起学习吧!";
|
|
|
$image->text('我的海报',$path_ttf,14,'#ffffff',[150,54])
|
|
|
->water(ROOT_PATH.'public/assets/img/poster_qr_bg2.png',[11,158])
|
|
|
->water(ROOT_PATH.'public/'.$user_code,[73,242])
|
|
|
->text('扫描二维码下载APP',$path_ttf,12,'#06121F',[120,486])
|
|
|
->text($desc,$path_ttf,12,'#ffffff',[45,594])
|
|
|
->water($user_image,[260,590])
|
|
|
->save($user_poster);
|
|
|
// 删除头像
|
|
|
is_file($user_image) && @unlink($user_image);
|
|
|
// 删除二维码
|
|
|
is_file($user_code) && @unlink($user_code);
|
|
|
$url = request()->domain().'/'.$user_poster;
|
|
|
$this->success('成功',compact('url'));
|
|
|
}
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|