|
@@ -0,0 +1,112 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\api\controller;
|
|
|
+
|
|
|
+use app\common\controller\Api;
|
|
|
+use think\Db;
|
|
|
+/**
|
|
|
+ * 用户推荐
|
|
|
+ */
|
|
|
+class Userinvite extends Api
|
|
|
+{
|
|
|
+ protected $noNeedLogin = [];
|
|
|
+ protected $noNeedRight = ['*'];
|
|
|
+
|
|
|
+
|
|
|
+ //生成我的视频海报
|
|
|
+ //生成邀请码二维码图片
|
|
|
+ public function inviteimage() {
|
|
|
+ $params['text'] = config('h5register_url') .'?invite_no='. $this->auth->introcode;
|
|
|
+ $qrcode_service = \addons\qrcode\library\Service::qrcode($params);
|
|
|
+
|
|
|
+ $qrcodePath = ROOT_PATH . 'public/uploads/hbplayer/'.date('Ymd');
|
|
|
+ if (!is_dir($qrcodePath)) {
|
|
|
+ @mkdir($qrcodePath);
|
|
|
+ }
|
|
|
+ if (is_really_writable($qrcodePath)) {
|
|
|
+ $filename = 'invite_'.$this->auth->introcode . '.png';
|
|
|
+ $filePath = $qrcodePath .'/'. $filename;
|
|
|
+ $qrcode_service->writeFile($filePath);
|
|
|
+ }
|
|
|
+
|
|
|
+ return '/uploads/hbplayer/'.date('Ymd') .'/'. $filename;
|
|
|
+ }
|
|
|
+
|
|
|
+ //生成视频分享海报
|
|
|
+ public function shareposter() {
|
|
|
+ $inviteimage = $this->inviteimage();
|
|
|
+
|
|
|
+ $data = [
|
|
|
+ [
|
|
|
+ "left"=> "190px",
|
|
|
+ "top"=> "320px",
|
|
|
+ "type"=> "img",
|
|
|
+ "width"=> "110px",
|
|
|
+ "height"=> "110px",
|
|
|
+ "src"=> httpurllocal($inviteimage)//"https://metavision.oss-cn-hongkong.aliyuncs.com/uploads/20220615/f00cb545deb4c4e7296f444239d83e84.jpg"
|
|
|
+ ],
|
|
|
+
|
|
|
+ ];
|
|
|
+
|
|
|
+
|
|
|
+ $data = json_encode($data, 320);
|
|
|
+
|
|
|
+ $poster = [
|
|
|
+ 'id' => $this->auth->id,
|
|
|
+ 'title' => '珍友',
|
|
|
+ 'waittext' => '您的专属海报正在拼命生成中,请等待片刻...',
|
|
|
+ 'bg_image' => '/assets/img/posteruserbg.png',
|
|
|
+ 'data' => $data,
|
|
|
+ 'status' => 'normal',
|
|
|
+ 'weigh' => 0,
|
|
|
+ 'createtime' => 1653993709,
|
|
|
+ 'updatetime' => 1653994259,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $image = new \addons\poster\library\Image();
|
|
|
+ $imgurl = $image->createPosterImage($poster, $this->auth->getUser());
|
|
|
+
|
|
|
+ if (!$imgurl) {
|
|
|
+ $this->error('生成海报出错');
|
|
|
+ }
|
|
|
+ $imgurl = $_SERVER["REQUEST_SCHEME"]."://".$_SERVER["HTTP_HOST"] . '/' . $imgurl;
|
|
|
+
|
|
|
+ //echo '<html><body><img src="'.$imgurl.'"></body></html>';
|
|
|
+
|
|
|
+ $this->success('', $imgurl);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //我邀请的人列表
|
|
|
+ public function myinvite_list(){
|
|
|
+ $list = Db::name('user')->field('id,username,nickname,avatar,createtime')->where('invite_uid',$this->auth->id)->autopage()->select();
|
|
|
+ $list = list_domain_image($list,['avatar']);
|
|
|
+
|
|
|
+ $this->success('success',$list);
|
|
|
+ }
|
|
|
+
|
|
|
+ //邀请页多个信息
|
|
|
+ public function invitesite_info(){
|
|
|
+
|
|
|
+
|
|
|
+ //累计邀请人数
|
|
|
+ $invite_num = Db::name('user')->where('invite_uid',$this->auth->id)->count();
|
|
|
+ //累计收益
|
|
|
+ $money_sum = Db::name('user_gold_log')->where(['user_id'=>$this->auth->id,'log_type'=>['IN','41,42']])->sum('change_value');
|
|
|
+
|
|
|
+ $rs = [
|
|
|
+ 'invitesite_activeinfo' => config('site.invitesite_activeinfo'),
|
|
|
+ 'introsite_introrule' => config('site.introsite_introrule'),
|
|
|
+ 'invite_recharge_rate' => config('site.invite_recharge_rate'),
|
|
|
+ 'invite_takecash_rate' => config('site.invite_takecash_rate'),
|
|
|
+ 'introcode' => $this->auth->introcode,
|
|
|
+ 'money_sum' => $money_sum,
|
|
|
+ 'invite_num' => $invite_num,
|
|
|
+ 'invite_url' => config('h5register_url') .'?invite_no='. $this->auth->introcode,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $this->success('success',$rs);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|