From 36cacbaf78e510713002fcd5e3d61cece2e01421 Mon Sep 17 00:00:00 2001
From: quanwei <419654421@qq.com>
Date: Tue, 28 Oct 2025 18:43:26 +0800
Subject: [PATCH] 名片模板

---
 admin/app/common/service/qrcode/Base.php |   75 +++++++++++++++++++++++++++++++++++++
 1 files changed, 75 insertions(+), 0 deletions(-)

diff --git a/admin/app/common/service/qrcode/Base.php b/admin/app/common/service/qrcode/Base.php
index 3abf855..1ec1d4b 100644
--- a/admin/app/common/service/qrcode/Base.php
+++ b/admin/app/common/service/qrcode/Base.php
@@ -120,4 +120,79 @@
         return true;
     }
 
+    /**
+     * 保存小程序码到文件
+     */
+    protected function saveBranchQrcodeToDir($app_id, $page, $savePath, $branch_id)
+    {
+        // 小程序配置信息
+        $app = AppWx::getApp($app_id);
+        // 小程序码参数
+        $scene = "branch_id:{$branch_id}";
+        // 文件名称
+        $fileName = 'qrcode_' . md5($app_id . $scene . $page) . '.png';
+        // 请求api获取小程序码
+        $response = $app->app_code->getUnlimit($scene, [
+            'page' => $page,
+            'width' => 430
+        ]);
+        // 保存小程序码到文件
+        if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
+            $response->saveAs($savePath, $fileName);
+        }
+        return true;
+    }
+
+    /**
+     * 保存二维码码到文件
+     */
+    protected function saveBranchMpQrcodeToDir($page, $savePath, $branch_id, $app_id)
+    {
+        $qrcode = new QrCode(base_url() . $page . '?app_id=' . $app_id . '&branch_id=' . $branch_id);
+        $scene = "branch_id:{$branch_id}";
+        // 文件名称
+        $fileName = 'qrcode_' . md5($app_id . $scene) . '.png';
+        // 保存二维码到文件
+        $path = "{$savePath}{$fileName}";
+        $qrcode->writeFile($path);
+        return true;
+    }
+
+    /**
+     * 保存二维码码到文件
+     */
+    protected function saveBranchActivityQrcodeToDir($app_id, $page, $savePath, $scene)
+    {
+        // 小程序配置信息
+        $app = AppWx::getApp($app_id);
+        // 文件名称
+        $fileName = 'qrcode_' . md5($app_id . $scene . $page) . '.png';
+        // 请求api获取小程序码
+        $response = $app->app_code->getUnlimit($scene, [
+            'page' => $page,
+            'width' => 430
+        ]);
+        // 保存小程序码到文件
+        if ($response instanceof \EasyWeChat\Kernel\Http\StreamResponse) {
+            $response->saveAs($savePath, $fileName);
+        }
+
+        return $savePath . $fileName;
+    }
+
+    /**
+     * 保存二维码码到文件
+     */
+    protected function saveBranchActivityVerifyMpQrcodeToDir($page, $savePath, $activity_id, $app_id)
+    {
+        $qrcode = new QrCode(base_url() . $page . '?app_id=' . $app_id . '&activity_id=' . $activity_id. '&user_verify=1');
+        $scene = "activity_id:{$activity_id}";
+        // 文件名称
+        $fileName = 'qrcode_' . md5($app_id . $scene) . '.png';
+        // 保存二维码到文件
+        $path = "{$savePath}{$fileName}";
+        $qrcode->writeFile($path);
+        return $savePath .'/'. $fileName;;
+    }
+
 }
\ No newline at end of file

--
Gitblit v1.9.2