| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 | 
							- <?php
 
- namespace app\api\controller;
 
- use app\common\controller\Api;
 
- use think\Db;
 
- /**
 
-  * 用户推荐
 
-  */
 
- class Userintro extends Api
 
- {
 
-     protected $noNeedLogin = [];
 
-     protected $noNeedRight = ['*'];
 
-     //生成我的视频海报
 
-     //生成邀请码二维码图片
 
-     public function inviteimage() {
 
-         $params['text'] = config('app_download_url') . '/index/appdownload';
 
-         $qrcode_service = \addons\qrcode\library\Service::qrcode($params);
 
- //        $mimetype = 'image/png';
 
- //        $response = Response::create()->header("Content-Type", $mimetype);
 
-         // 直接显示二维码
 
- //        header('Content-Type: ' . $qrcode_service->getContentType());
 
- //        $response->content($qrcode_service->writeString());
 
-         $qrcodePath = ROOT_PATH . 'public/uploads/qrcode/';
 
-         if (!is_dir($qrcodePath)) {
 
-             @mkdir($qrcodePath);
 
-         }
 
-         if (is_really_writable($qrcodePath)) {
 
-             $filename = md5(implode('', $params)) . '.png';
 
-             $filePath = $qrcodePath . $filename;
 
-             $qrcode_service->writeFile($filePath);
 
-         }
 
-         return '/uploads/qrcode/' . $filename;
 
-     }
 
-     //生成视频分享海报
 
-     public function shareposter() {
 
-         $inviteimage = $this->inviteimage($this->auth->introcode);
 
-         $data = [
 
-             [
 
-                 "left"=> "140px",
 
-                 "top"=> "120px",
 
-                 "type"=> "img",
 
-                 "width"=> "50px",
 
-                 "height"=> "50px",
 
-                 "src"=> localpath_to_netpath($this->auth->avatar)//"https://metavision.oss-cn-hongkong.aliyuncs.com/uploads/20220615/f00cb545deb4c4e7296f444239d83e84.jpg"
 
-             ],
 
-             [
 
-                 "left"=> "95px",
 
-                 "top"=> "190px",
 
-                 "type"=> "nickname",
 
-                 "width"=> "166px",
 
-                 "height"=> "38px",
 
-                 "size"=> "11px",
 
-                 "color"=> "#FFFFFF",
 
-                 "content" => '这里真心不错,推荐你来',
 
-             ],
 
-             [
 
-                 "left"=> "105px",
 
-                 "top"=> "400px",
 
-                 "type"=> "nickname",
 
-                 "width"=> "166px",
 
-                 "height"=> "38px",
 
-                 "size"=> "11px",
 
-                 "color"=> "#333333",
 
-                 "content" => '邀请码:'.$this->auth->introcode,
 
-             ],
 
-             [
 
-                 "left"=> "100px",
 
-                 "top"=> "265px",
 
-                 "type"=> "img",
 
-                 "width"=> "130px",
 
-                 "height"=> "130px",
 
-                 "src"=> httpurllocal($inviteimage)//"https://metavision.oss-cn-hongkong.aliyuncs.com/uploads/20220615/f00cb545deb4c4e7296f444239d83e84.jpg"
 
-             ],
 
-         ];
 
-         $data = json_encode($data, 320);
 
-         $poster = [
 
-             'id' => 1,
 
-             '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 myprofit(){
 
-         //今日
 
-         $start = strtotime(date('Y-m-d'));
 
-         $end   = $start + 86399;
 
-         //收益type
 
-         $profit_type = [21,22,23,52,54,56];
 
-         //今日收益
 
-         $map = [
 
-             'log_type' => ['IN',$profit_type],
 
-             'user_id' => $this->auth->id,
 
-             'createtime' => ['between',[$start,$end]],
 
-         ];
 
-         $today_profit = Db::name('user_money_log')->where($map)->sum('change_value');
 
-         //今日视频时长
 
-         $map = [
 
-             'user_id|to_user_id' => $this->auth->id,
 
-             'createtime' => ['between',[$start,$end]],
 
-         ];
 
-         $today_video_min = Db::name('user_match_video_log')->where($map)->count();
 
-         //今日语音时长
 
-         $map = [
 
-             'user_id|to_user_id' => $this->auth->id,
 
-             'createtime' => ['between',[$start,$end]],
 
-         ];
 
-         $today_audio_min = Db::name('user_match_audio_log')->where($map)->count();
 
-         //本周收益
 
-         $week_start = strtotime(date('Y-m-d')) - ((date('w')==0?7:date('w'))-1)*86400;
 
-         $week_end   = $week_start + 604799;
 
-         $map = [
 
-             'log_type' => ['IN',$profit_type],
 
-             'user_id' => $this->auth->id,
 
-             'createtime' => ['between',[$week_start,$week_end]],
 
-         ];
 
-         $week_profit = Db::name('user_money_log')->where($map)->sum('change_value');
 
-         //我的累计收益
 
-         $map = [
 
-             'log_type' => ['IN',$profit_type],
 
-             'user_id' => $this->auth->id,
 
-         ];
 
-         $all_profit = Db::name('user_money_log')->where($map)->sum('change_value');
 
-         //我的邀请
 
-         $my_intro_number = Db::name('user')->where('intro_uid',$this->auth->id)->count('id');
 
-         $result = [
 
-             'avatar' => $this->auth->avatar,
 
-             'nickname' => $this->auth->nickname,
 
-             'username' => $this->auth->username,
 
-             'today_profit' => $today_profit,
 
-             'today_video_min' => $today_video_min,
 
-             'today_audio_min' => $today_audio_min,
 
-             'week_profit' => $week_profit,
 
-             'all_profit' => $all_profit,
 
-             'my_intro_number' => $my_intro_number,
 
-         ];
 
-         $this->success('success',$result);
 
-     }
 
-     //我邀请的,成员今日收益
 
-     public function myintro(){
 
-         $map = [
 
-             'intro_uid' => $this->auth->id,
 
-         ];
 
-         $list = Db::name('user')->field('id,nickname,username,avatar')->where($map)->page($this->page,$this->listrow)->select();
 
-         $rs = [];
 
-         foreach($list as $key => $user){
 
-             $rs[] = $this->profit($user);
 
-         }
 
-         //dump($rs);
 
-         $this->success('success',$rs);
 
-     }
 
-     //收益数据
 
-     private function profit($userinfo){
 
-         $uid = $userinfo['id'];
 
-         //今日
 
-         $start = strtotime(date('Y-m-d'));
 
-         $end   = $start + 86399;
 
-         //收益type
 
-         $profit_type = [21,22,23,52,54,56];
 
-         //今日收益
 
-         $map = [
 
-             'log_type' => ['IN',$profit_type],
 
-             'user_id' => $uid,
 
-             'createtime' => ['between',[$start,$end]],
 
-         ];
 
-         $today_profit = Db::name('user_money_log')->where($map)->sum('change_value');
 
-         //今日视频时长
 
-         $map = [
 
-             'user_id|to_user_id' => $uid,
 
-             'createtime' => ['between',[$start,$end]],
 
-         ];
 
-         $today_video_min = Db::name('user_match_video_log')->where($map)->count('id');
 
-         //今日语音时长
 
-         $map = [
 
-             'user_id|to_user_id' => $uid,
 
-             'createtime' => ['between',[$start,$end]],
 
-         ];
 
-         $today_audio_min = Db::name('user_match_audio_log')->where($map)->count('id');
 
-         //本周收益
 
-         $week_start = strtotime(date('Y-m-d')) - ((date('w')==0?7:date('w'))-1)*86400;
 
-         $week_end   = $week_start + 604799;
 
-         $map = [
 
-             'log_type' => ['IN',$profit_type],
 
-             'user_id' => $uid,
 
-             'createtime' => ['between',[$week_start,$week_end]],
 
-         ];
 
-         $week_profit = Db::name('user_money_log')->where($map)->sum('change_value');
 
-         $result = [
 
-             'today_profit' => $today_profit,
 
-             'today_video_min' => $today_video_min,
 
-             'today_audio_min' => $today_audio_min,
 
-             'week_profit' => $week_profit,
 
-         ];
 
-         $result = array_merge($result,$userinfo);
 
-         return $result;
 
-     }
 
- }
 
 
  |