|
@@ -5,7 +5,7 @@ namespace app\bug\listener;
|
|
|
|
|
|
use app\bug\model\Note;
|
|
|
use app\bug\model\Talk;use app\user\model\User;
|
|
|
-use think\facade\Log;
|
|
|
+use think\facade\Cache;use think\facade\Log;
|
|
|
class WxPush
|
|
|
{
|
|
|
protected $appid;
|
|
@@ -32,7 +32,6 @@ class WxPush
|
|
|
}
|
|
|
$data = $event['data'];
|
|
|
$this->uid = Talk::$talkUid;
|
|
|
-
|
|
|
try {
|
|
|
switch ($event['type']) {
|
|
|
case 'bug':
|
|
@@ -128,50 +127,34 @@ class WxPush
|
|
|
];
|
|
|
break;
|
|
|
}
|
|
|
- $add=[];
|
|
|
foreach ($openidArr as $item){
|
|
|
- if(empty($item['openId'])){
|
|
|
- $add[]=[
|
|
|
- 'bugNo'=>$data['bugNo'],
|
|
|
- 'template_id'=>$template_id,
|
|
|
- 'template_name'=>$template_name,
|
|
|
- 'content'=>json_encode($temp,JSON_UNESCAPED_UNICODE),
|
|
|
- 'push_id'=>$item['account_id'],
|
|
|
- 'pusher'=>$item['nickname'],
|
|
|
- 'status'=>0,
|
|
|
- 'remark'=>"openId 不存在"
|
|
|
- ];
|
|
|
- continue;
|
|
|
- };
|
|
|
- $res=$this->pushMessage($item['openId'],$template_id,$temp);
|
|
|
- $add[]=[
|
|
|
- "bugNo"=>$data['bugNo'],
|
|
|
+ $temps=[
|
|
|
+ "code"=>$data['bugNo'],
|
|
|
+ "belong"=>4,
|
|
|
+ "openId"=>$item['openId'],
|
|
|
"template_id"=>$template_id,
|
|
|
"template_name"=>$template_name,
|
|
|
- "content"=>json_encode($temp,JSON_UNESCAPED_UNICODE),
|
|
|
- "push_id"=>$item['account_id'],
|
|
|
- "pusher"=>$item['nickname'],
|
|
|
- "status"=>$res?1:0,
|
|
|
- "remark"=>$res?"":$this->wechat->errMsg
|
|
|
+ "action_name"=>'工单推送',
|
|
|
+ "template_data"=>$temp,
|
|
|
+ "uid"=>$item['account_id'],
|
|
|
+ "uname"=>$item['nickname'],
|
|
|
];
|
|
|
- }
|
|
|
- if(!empty($add)){
|
|
|
- (new \app\bug\model\WechatPush)->saveAll($add);
|
|
|
+ Cache::store('redis')->handler()->lpush('wxpush_queue',json_encode($temps,JSON_UNESCAPED_UNICODE));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public function pushMessage($openId,$template_id,$data){
|
|
|
- $temp=[];
|
|
|
- $temp['touser'] =$openId;
|
|
|
- $temp['template_id'] = $template_id;
|
|
|
- $temp['data']=$data;
|
|
|
- $res= $this->wechat->sendTemplateMessage($temp);
|
|
|
- if($res==false && $this->wechat->errCode==40001){
|
|
|
- $this->wechat->resetAuth(env("WECHAT.APPID"));
|
|
|
- $this->wechat->sendTemplateMessage($temp);
|
|
|
- }
|
|
|
- Log::write('data:'.json_encode($temp,JSON_UNESCAPED_UNICODE),'event');
|
|
|
- Log::write('data:'.json_encode($res,JSON_UNESCAPED_UNICODE),'event');
|
|
|
- return $res;
|
|
|
- }
|
|
|
+// public function pushMessage($openId,$template_id,$data){
|
|
|
+// $temp=[];
|
|
|
+// $temp['touser'] =$openId;
|
|
|
+// $temp['template_id'] = $template_id;
|
|
|
+// $temp['data']=$data;
|
|
|
+// $res= $this->wechat->sendTemplateMessage($temp);
|
|
|
+// if($res==false && $this->wechat->errCode==40001){
|
|
|
+// $this->wechat->resetAuth(env("WECHAT.APPID"));
|
|
|
+// $this->wechat->sendTemplateMessage($temp);
|
|
|
+// }
|
|
|
+// Log::write('data:'.json_encode($temp,JSON_UNESCAPED_UNICODE),'event');
|
|
|
+// Log::write('data:'.json_encode($res,JSON_UNESCAPED_UNICODE),'event');
|
|
|
+// return $res;
|
|
|
+// }
|
|
|
}
|