zilong 4 yıl önce
ebeveyn
işleme
b4009d64ed
2 değiştirilmiş dosya ile 159 ekleme ve 24 silme
  1. 5 14
      app/Helpers/functions.php
  2. 154 10
      config/config.php

+ 5 - 14
app/Helpers/functions.php

xqd
@@ -533,23 +533,14 @@ if (!function_exists('numDays')){
 
 //发送微信订阅消息
 if (!function_exists('send_wechat_message')) {
-    function send_wechat_message($user_id, $type)
+    function send_wechat_message($type, $arr)
     {
         try {
             $app = Factory::miniProgram(config('config.wechat_small_program'));
-            $data = [
-                'template_id' => 'bDmywsp2oEHjwAadTGKkUJ-eJEiMiOf7H-dZ7wjdw80', // 所需下发的订阅模板id
-                'touser' => 'oSyZp5OBNPBRhG-7BVgWxbiNZm',     // 接收者(用户)的 openid
-                'page' => '',       // 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。
-                'data' => [         // 模板内容,格式形如 { "key1": { "value": any }, "key2": { "value": any } }
-                    'date01' => [
-                        'value' => '2019-12-01',
-                    ],
-                    'number01' => [
-                        'value' => 10,
-                    ],
-                ],
-            ];
+            $data = config('config.wechat_subscribe_message_template')[$type];
+            $json = json_encode($data, JSON_UNESCAPED_UNICODE);
+            $json = vsprintf($json, $arr);
+            $data = json_decode($json, true);
 
             $ret = $app->subscribe_message->send($data);
         } catch (Exception $e) {

+ 154 - 10
config/config.php

xqd
@@ -74,17 +74,161 @@ return [
     'pack_label_map' => [1 => '图文', 2 => '电话', 3 => '门诊', 4 => '计免', 5 => '儿保'],
 
     'wechat_subscribe_message_template' => [
-        // 用户下单提醒(图文咨询/电话咨询)
+        //图文咨询/电话咨询
         1 => [
-            'template_id' => 'bDmywsp2oEHjwAadTGKkUJ-eJEiMiOf7H-dZ7wjdw80', // 所需下发的订阅模板id
-            'touser' => 'oSyZp5OBNPBRhG-7BVgWxbiNZm',     // 接收者(用户)的 openid
-            'page' => '',       // 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。
-            'data' => [         // 模板内容,格式形如 { "key1": { "value": any }, "key2": { "value": any } }
-                'date01' => [
-                    'value' => '2019-12-01',
-                ],
-                'number01' => [
-                    'value' => 10,
+            'template_id' => 'M9b6PPKtD7PEqLsSnQ453iTIHtIZZpixOBjUj',
+            'touser' => '%s',
+            'page' => '%s',
+            'data' => [
+                'phrase1' => [
+                    'value' => '%s',
+                ],
+                'name3' => [
+                    'value' => '%s',
+                ],
+                'date4' => [
+                    'value' => '%s',
+                ],
+                'thing8' => [
+                    'value' => '你有一笔%s咨询订单已成功下单,请耐心等待',
+                ],
+                'amount10' => [
+                    'value' => '%s',
+                ],
+            ],
+        ],
+        //门诊预约
+        2 => [
+            'template_id' => 'phcsQ7ZbsJapfmx3NMCha0MrHCqFrgN7BWVneE5OffI',
+            'touser' => '%s',
+            'page' => '%s',
+            'data' => [
+                'name1' => [
+                    'value' => '%s',
+                ],
+                'thing3' => [
+                    'value' => '%s',
+                ],
+                'name5' => [
+                    'value' => '%s',
+                ],
+                'time2' => [
+                    'value' => '%s',
+                ],
+                'thing7' => [
+                    'value' => '你的门诊预约已下单成功,请按时前往就诊',
+                ],
+            ],
+        ],
+        //计免预约 / 儿保预约
+        3 => [
+            'template_id' => 'phcsQ7ZbsJapfmx3NMChaxepR9tJFiqbO25P9tujErI',
+            'touser' => '%s',
+            'page' => '%s',
+            'data' => [
+                'name1' => [
+                    'value' => '%s',
+                ],
+                'thing10' => [
+                    'value' => '%s',
+                ],
+                'thing3' => [
+                    'value' => '%s',
+                ],
+                'time2' => [
+                    'value' => '%s',
+                ],
+                'thing7' => [
+                    'value' => '你的%s已下单成功,请按时前往就诊',
+                ],
+            ],
+        ],
+        //咨询订单接单提醒
+        4 => [
+            'template_id' => '7tnOphwuX8aYenJd-m-LN0jxQm3gkF0HJc1nDX13VMw',
+            'touser' => '%s',
+            'page' => '%s',
+            'data' => [
+                'character_string6' => [
+                    'value' => '%s',
+                ],
+                'thing2' => [
+                    'value' => '%s',
+                ],
+                'thing7' => [
+                    'value' => '%s',
+                ],
+                'time8' => [
+                    'value' => '%s',
+                ],
+                'thing9' => [
+                    'value' => '%s',
+                ],
+            ],
+        ],
+        //图文消息回复提醒
+        5 => [
+            'template_id' => 'WCkfvW9NkV_oQgLsJJuwoVMF-G0ss9y4SkIgCObZwWA',
+            'touser' => '%s',
+            'page' => '%s',
+            'data' => [
+                'name1' => [
+                    'value' => '%s',
+                ],
+                'thing3' => [
+                    'value' => '%s',
+                ],
+                'thing6' => [
+                    'value' => '%s',
+                ],
+                'thing5' => [
+                    'value' => '%s',
+                ],
+                'time4' => [
+                    'value' => '%s',
+                ],
+            ],
+        ],
+        //订单取消提醒
+        6 => [
+            'template_id' => 'bjZ-r79i8sl7zEtdttAtcCPZLkCgFSYHTNWnNVd1cG0',
+            'touser' => '%s',
+            'page' => '%s',
+            'data' => [
+                'character_string1' => [
+                    'value' => '%s',
+                ],
+                'name5' => [
+                    'value' => '%s',
+                ],
+                'thing4' => [
+                    'value' => '%s',
+                ],
+                'thing7' => [
+                    'value' => '%s',
+                ],
+            ],
+        ],
+        //服务包消息配置
+        7 => [
+            'template_id' => 'obCFv2gAnl_RaW-OlnZkjCfi6teT3LUaHxxInUkwLbw',
+            'touser' => '%s',
+            'page' => '%s',
+            'data' => [
+                'thing1' => [
+                    'value' => '%s',
+                ],
+                'date2' => [
+                    'value' => '%s',
+                ],
+                'thing4' => [
+                    'value' => '%s',
+                ],
+                'phrase5' => [
+                    'value' => '%s',
+                ],
+                'thing3' => [
+                    'value' => '%s',
                 ],
             ],
         ],