<?php

namespace app\agent\controller;

use app\agent\BaseController;
use app\common\model\OutCode as OutCodeModel;

class Outjob extends BaseController
{
    public function print()
    {
        return view('outjob/print');
    }

    /**
     * 推广码
     */
    public function qrcode()
    {
        error_reporting(E_ERROR);
        $code = uniqid();
        $url  = 'https://linggong.jinjianghc.com/applet/outactivity/index?code=' . $code;
        OutCodeModel::create([
            'code'        => $code,
            'create_time' => time(),
            'agentid'    => $this->access_agent['id'],
            'workerid'    => $this->access_agent['workerid'],
        ]);
        header('Content-Type: image/png');
        ob_clean();
        $errorCorrectionLevel = "L"; // 纠错级别：L、M、Q、H
        $matrixPointSize      = "4"; //生成图片大小 ：1到10
        \phpqrcode\QRcode::png($url, false, $errorCorrectionLevel, $matrixPointSize);
        exit();
    }
}
