|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace App\Jobs\WechatPlatform;
|
|
|
|
|
|
+use App\Service\Util\Support\Http\HttpRequestService;
|
|
|
use App\Service\Util\Support\Trace\TraceContext;
|
|
|
use App\Service\WechatPlatform\GZHSendKFMessageService;
|
|
|
use App\Service\WechatPlatform\WechatPlatform;
|
|
@@ -89,12 +90,20 @@ class GZHSendKFMessage implements ShouldQueue
|
|
|
// GZHSendKFMessageService::sendText($officialAccount, $opid, $messageStr, $this->traceContext);
|
|
|
dump($opid);
|
|
|
}
|
|
|
- $next_openid = $info['next_openid'];
|
|
|
+ $next_openid = $info['next_openid'] ?? '';
|
|
|
if(!$next_openid) {
|
|
|
break;
|
|
|
}
|
|
|
} elseif (2 == $message->u_type) {
|
|
|
- // todo, 从人群包中获取.
|
|
|
+ $info = $this->getUsersFromUG($gzh->id, $message->ug_id, $next_openid);
|
|
|
+ foreach (($info['data']['openid'] ?? []) as $opid) {
|
|
|
+ // GZHSendKFMessageService::sendText($officialAccount, $opid, $messageStr, $this->traceContext);
|
|
|
+ dump($opid);
|
|
|
+ }
|
|
|
+ $next_openid = $info['data']['next_uid'] ?? '';
|
|
|
+ if(!$next_openid) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -134,6 +143,24 @@ class GZHSendKFMessage implements ShouldQueue
|
|
|
return $result;
|
|
|
}
|
|
|
|
|
|
+ private function getUsersFromUG($gzhId, $ugId, $nextUid) {
|
|
|
+ $url = config('wechat.ug.url.listUser');
|
|
|
+ $signKey = config('wechat.ug.signKey');
|
|
|
+ $now = time();
|
|
|
+ $res = HttpRequestService::simpleGet($url, [
|
|
|
+ 'timestamp' => $now,
|
|
|
+ 'sign' => md5($signKey.$now),
|
|
|
+ 'gzhId' => $gzhId,
|
|
|
+ 'ugId' => $ugId,
|
|
|
+ 'nextUid' => $nextUid,
|
|
|
+ 'limit' => 1000
|
|
|
+ ]);
|
|
|
+ if($res && (0 != ($res['code'] ?? 0))) {
|
|
|
+ return $res;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取公众号调用对象
|
|
|
* @param $gzh
|
|
@@ -168,7 +195,8 @@ class GZHSendKFMessage implements ShouldQueue
|
|
|
['a.id', '=', $this->info['gzhId']],
|
|
|
['a.is_enabled', '=', 1],
|
|
|
['b.is_enabled', '=', 1]
|
|
|
- ])->select('a.authorizer_appid', 'a.authorizer_refresh_token', 'b.app_id', 'b.secret', 'b.token', 'b.aes_key')
|
|
|
+ ])->select('a.id', 'a.authorizer_appid', 'a.authorizer_refresh_token',
|
|
|
+ 'b.app_id', 'b.secret', 'b.token', 'b.aes_key')
|
|
|
->first();
|
|
|
if(!$gzh) {
|
|
|
myLog('KFMessageSend')->error('公众号不可用', [
|