From ba392a04c1b720fcb854ce73b8102dbbd2e237b9 Mon Sep 17 00:00:00 2001 From: wangxiaowei Date: Tue, 18 Jun 2024 17:43:24 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AE=A2=E9=98=85=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=B5=8B=E8=AF=95=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/Notice.php | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/app/api/controller/Notice.php b/app/api/controller/Notice.php index 4eef652d..6b1a0adf 100644 --- a/app/api/controller/Notice.php +++ b/app/api/controller/Notice.php @@ -22,7 +22,11 @@ namespace app\api\controller; use app\common\basics\Api; use app\common\logic\SystemNoticeLogic; +use app\common\model\Client_; +use app\common\model\user\UserAuth; use app\common\server\JsonServer; +use app\common\server\WeChatServer; +use EasyWeChat\Factory; class Notice extends Api { @@ -49,4 +53,39 @@ class Notice extends Api return JsonServer::success('获取成功', $lists); } + /** + * @notes 本地生活消息订阅模板ID,需要将template_id放在配置文件中 + */ + public function getLocalLifeTemplateId() + { + return JsonServer::success('获取成功', ['id' => ['w6LVw0dwdmBWBlj06j-A-s34NZSdFC5xkasFhZbYSfM']]); + } + + /** + * @notes 将template_id放在配置文件中 + */ + public function sendMsg() + { + $config = WeChatServer::getMnpConfig(); + $app = Factory::miniProgram($config); + $user = UserAuth::where(['user_id' => $this->user_id, 'client' => Client_::mnp])->find(); + + $data = [ + 'template_id' => 'w6LVw0dwdmBWBlj06j-A-s34NZSdFC5xkasFhZbYSfM', // 所需下发的订阅模板id + 'touser' => $user['openid'], // 接收者(用户)的 openid + 'page' => '/pages/goods_cate/goods_cate', // 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。 + 'data' => [ // 模板内容,格式形如 { "key1": { "value": any }, "key2": { "value": any } } + 'thing1' => [ + 'value' => '我的店铺', + ], + 'thing4' => [ + 'value' => '您的店铺审核成功', + ], + 'phrase5' => [ + 'value' => '审核成功' + ] + ], + ]; + $app->subscribe_message->send($data); + } } \ No newline at end of file