正在显示
5 个修改的文件
包含
50 行增加
和
0 行删除
@@ -474,6 +474,15 @@ class Hot extends Api | @@ -474,6 +474,15 @@ class Hot extends Api | ||
474 | $insert['is_read_user'] = 1; | 474 | $insert['is_read_user'] = 1; |
475 | $res_msg = $msg_model->add($insert); | 475 | $res_msg = $msg_model->add($insert); |
476 | } | 476 | } |
477 | + // 发送模板消息 | ||
478 | +// $send_data = array( | ||
479 | +// "first" => '', | ||
480 | +// 'keyword1' => '', | ||
481 | +// "keyword2" => '', | ||
482 | +// "keyword3" => date('Y-m-s',time()), | ||
483 | +// "remark" => '', | ||
484 | +// ); | ||
485 | +// $this->wxsendmessage('','',''); | ||
477 | Db::commit(); | 486 | Db::commit(); |
478 | } catch (PDOException $e) { | 487 | } catch (PDOException $e) { |
479 | Db::rollback(); | 488 | Db::rollback(); |
@@ -1227,6 +1227,15 @@ class Store extends Api | @@ -1227,6 +1227,15 @@ class Store extends Api | ||
1227 | 'is_read_object' => 1, | 1227 | 'is_read_object' => 1, |
1228 | ]; | 1228 | ]; |
1229 | $res_msg = $msg_model->edit($update); | 1229 | $res_msg = $msg_model->edit($update); |
1230 | + // 发送模板消息 | ||
1231 | +// $send_data = array( | ||
1232 | +// "first" => '', | ||
1233 | +// 'keyword1' => '', | ||
1234 | +// "keyword2" => '', | ||
1235 | +// "keyword3" => date('Y-m-s',time()), | ||
1236 | +// "remark" => '', | ||
1237 | +// ); | ||
1238 | +// $this->wxsendmessage('','',''); | ||
1230 | Db::commit(); | 1239 | Db::commit(); |
1231 | } catch (PDOException $e) { | 1240 | } catch (PDOException $e) { |
1232 | Db::rollback(); | 1241 | Db::rollback(); |
@@ -640,6 +640,15 @@ class User extends Api | @@ -640,6 +640,15 @@ class User extends Api | ||
640 | 'is_read_object' => 2, | 640 | 'is_read_object' => 2, |
641 | ]; | 641 | ]; |
642 | $res_msg = $msg_model->edit($update); | 642 | $res_msg = $msg_model->edit($update); |
643 | + // 发送模板消息 | ||
644 | +// $send_data = array( | ||
645 | +// "first" => '', | ||
646 | +// 'keyword1' => '', | ||
647 | +// "keyword2" => '', | ||
648 | +// "keyword3" => date('Y-m-s',time()), | ||
649 | +// "remark" => '', | ||
650 | +// ); | ||
651 | +// $this->wxsendmessage('','',''); | ||
643 | Db::commit(); | 652 | Db::commit(); |
644 | } catch (PDOException $e) { | 653 | } catch (PDOException $e) { |
645 | Db::rollback(); | 654 | Db::rollback(); |
@@ -3,6 +3,7 @@ | @@ -3,6 +3,7 @@ | ||
3 | namespace app\common\controller; | 3 | namespace app\common\controller; |
4 | 4 | ||
5 | use app\common\library\Auth; | 5 | use app\common\library\Auth; |
6 | +use EasyWeChat\Foundation\Application; | ||
6 | use think\Config; | 7 | use think\Config; |
7 | use think\exception\HttpResponseException; | 8 | use think\exception\HttpResponseException; |
8 | use think\exception\ValidateException; | 9 | use think\exception\ValidateException; |
@@ -320,4 +321,25 @@ class Api | @@ -320,4 +321,25 @@ class Api | ||
320 | 321 | ||
321 | return true; | 322 | return true; |
322 | } | 323 | } |
324 | + | ||
325 | + /** | ||
326 | + * 发送模板消息 | ||
327 | + * @param string $open_id 用户openid | ||
328 | + * @param array $data 模板消息内容 | ||
329 | + * @param string $templateId 模板消息id | ||
330 | + * @return bool | ||
331 | + */ | ||
332 | + public function wxsendmessage($open_id, $data, $templateId) | ||
333 | + { | ||
334 | + if (empty($open_id) || empty($data) || empty($templateId)) { | ||
335 | + return false; | ||
336 | + } | ||
337 | + $options = get_addon_config('wechat'); | ||
338 | + $app = new Application($options); | ||
339 | + $notice = $app->notice; | ||
340 | + $userId = $open_id; | ||
341 | + $url = config('option.vue_url').'/index/order/index.html'; | ||
342 | + $notice->uses($templateId)->withUrl($url)->andData($data)->andReceiver($userId)->send(); | ||
343 | + return true; | ||
344 | + } | ||
323 | } | 345 | } |
-
请 注册 或 登录 后发表评论