Commit 9285b85a authored by suntengda's avatar suntengda

update 发送订阅通知消息格式修改

parent 80cad87e
...@@ -11,7 +11,8 @@ use Api\PhpServices\Wechat\Msg; ...@@ -11,7 +11,8 @@ use Api\PhpServices\Wechat\Msg;
class Pindan implements DaemonServiceInterface class Pindan implements DaemonServiceInterface
{ {
const DEFAULT_DESC = '9.9元吃午餐开始预定啦,戳这里点餐吧';
public function run() public function run()
{ {
//只在16:40执行逻辑 //只在16:40执行逻辑
...@@ -41,9 +42,9 @@ class Pindan implements DaemonServiceInterface ...@@ -41,9 +42,9 @@ class Pindan implements DaemonServiceInterface
$type = 2; // 1 公众号 2 小程序 $type = 2; // 1 公众号 2 小程序
//活动信息 //活动信息
$params = [ $params = [
$list['result'][0]['marketing_name'], self::emojiFilter($list['result'][0]['marketing_name']),
$list['result'][0]['create_time'], $list['result'][0]['create_time'],
$list['result'][0]['pindan_desc'] $list['result'][0]['pindan_desc'] ?: self::DEFAULT_DESC
]; ];
//发送消息 //发送消息
Msg::send(999, $app_id, $template_id, $page_url, $type, $params); Msg::send(999, $app_id, $template_id, $page_url, $type, $params);
...@@ -60,5 +61,16 @@ class Pindan implements DaemonServiceInterface ...@@ -60,5 +61,16 @@ class Pindan implements DaemonServiceInterface
} }
} }
/**
* 过滤emoji表情
* @param string $str
* @return string
*/
private function emojiFilter($str) {
$str = preg_replace_callback('/./u',function(array $match){
return strlen($match[0]) >= 4 ? '' : $match[0];
},$str);
return $str;
}
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment