修改了已知问题
This commit is contained in:
@@ -3,12 +3,13 @@
|
||||
namespace extend\chat\model;
|
||||
|
||||
use ba\Random;
|
||||
use EasyWeChat\Factory;
|
||||
use support\Redis;
|
||||
|
||||
class Business
|
||||
{
|
||||
// 存消息
|
||||
public static function setRedisMessage($uid, $user_type, $data)
|
||||
public static function setRedisMessage($uid, $user_type, $data, $open_id = '')
|
||||
{
|
||||
$str_uid = Base::getUid($uid, $user_type);
|
||||
$rand_msg_str = $str_uid . Random::build();
|
||||
@@ -23,6 +24,37 @@ class Business
|
||||
Redis::set($set_str, json_encode([$set_info_str]));
|
||||
}
|
||||
Redis::set($set_info_str, json_encode($data));
|
||||
|
||||
|
||||
if($open_id) {
|
||||
|
||||
// 保存的同时发送模版消息通知用户有未读消息
|
||||
$config = [
|
||||
'app_id' => config('cons.app_id'),
|
||||
'secret' => config('cons.secret'),
|
||||
'response_type' => 'array',
|
||||
];
|
||||
$app = Factory::officialAccount($config);
|
||||
$acc_token = Redis::get('wx:ac:AccessToken');
|
||||
if($acc_token) {
|
||||
$app['access_token']->setToken($acc_token);
|
||||
}
|
||||
$wechat_res = $app->template_message->send([
|
||||
'touser' => $open_id,
|
||||
'template_id' => 'hGsUGZlWqWC9TMm4ZGZuz0OwE4gwSmvgbr5ecmTDvq4',
|
||||
'miniprogram' => [
|
||||
'appid' => 'wxd88fffa983758a30', // 零点八零
|
||||
'pagepath' => 'pages/index/index', // 零点八零
|
||||
],
|
||||
'data' => [
|
||||
'thing7' => $record['shop_name'],
|
||||
'thing14' => $record['activity_detail'],
|
||||
'time3' => $record['activity_time'],
|
||||
'thing16' => $record['address'],
|
||||
],
|
||||
]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// 拉消息
|
||||
|
||||
Reference in New Issue
Block a user