首先每个活动生成不同的二维码
$hecode = $this->codes($insert_id);
$result = Db::table('')->where("activity_id='$insert_id'")->update(["cancel_code" => $hecode]);
codes的代码如下:
public function codes($goods_id)
{
$redirect_url = urlencode('http://' . $_SERVER['SERVER_NAME'] . '/codes?goods_id=' . $goods_id);
$url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=xxx&redirect_uri=" . $redirect_url . "&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect";
$errorCorrectionLevel = 'H';//容错级别
$matrixPointSize = 3;//图片大小慢慢自己调整,只要是int就行
$path = 'uploads/qrcode/'; //上传位置
if (!file_exists($path)) {
mkdir($path);
}