|
@@ -20,13 +20,14 @@ class WxPush extends Command
|
|
|
|
|
|
protected function execute(Input $input, Output $output)
|
|
protected function execute(Input $input, Output $output)
|
|
{
|
|
{
|
|
- $appid = env('WECHAT.APPID');
|
|
|
|
- $appsecret = env('WECHAT.APPSECRET');
|
|
|
|
- $wechat = new \Wechat(['appid' => $appid, 'appsecret' => $appsecret]);
|
|
|
|
- $bool=True;
|
|
|
|
- while ($bool){
|
|
|
|
- $que= Cache::store('redis')->handler()->lpop('wxpush_queue');
|
|
|
|
- if ($que){
|
|
|
|
|
|
+ $lockKey= Cache::set('wxpush_lock',1,600);
|
|
|
|
+ try{
|
|
|
|
+ $appid = env('WECHAT.APPID');
|
|
|
|
+ $appsecret = env('WECHAT.APPSECRET');
|
|
|
|
+ $wechat = new \Wechat(['appid' => $appid, 'appsecret' => $appsecret]);
|
|
|
|
+ $que= Cache::store('redis')->handler()->lpop('wxpush_queue');
|
|
|
|
+ $output->writeln($que);
|
|
|
|
+ while ($que){
|
|
$data=json_decode($que,true);
|
|
$data=json_decode($que,true);
|
|
$temp=[];
|
|
$temp=[];
|
|
$res=false;
|
|
$res=false;
|
|
@@ -43,7 +44,7 @@ class WxPush extends Command
|
|
|
|
|
|
$add= [
|
|
$add= [
|
|
'bugNo'=>$data['code'],
|
|
'bugNo'=>$data['code'],
|
|
- "belong"=>$data['belong'],
|
|
|
|
|
|
+ 'belong'=>$data['belong'],
|
|
'action_name'=>$data['action_name'],
|
|
'action_name'=>$data['action_name'],
|
|
'template_id'=>$data['template_id'],
|
|
'template_id'=>$data['template_id'],
|
|
'template_name'=>$data['template_name'],
|
|
'template_name'=>$data['template_name'],
|
|
@@ -54,11 +55,16 @@ class WxPush extends Command
|
|
'remark'=>$res?'':$wechat->errMsg
|
|
'remark'=>$res?'':$wechat->errMsg
|
|
];
|
|
];
|
|
WeChatPush::create($add);
|
|
WeChatPush::create($add);
|
|
- Log::write('data:'.json_encode($temp,JSON_UNESCAPED_UNICODE),'info');
|
|
|
|
- }else{
|
|
|
|
- $bool=false;
|
|
|
|
- }
|
|
|
|
|
|
+ Log::write('data:'.json_encode($add,JSON_UNESCAPED_UNICODE),'info');
|
|
|
|
+ $output->writeln(json_encode($add,JSON_UNESCAPED_UNICODE));
|
|
|
|
+ $que= Cache::store('redis')->handler()->lpop('wxpush_queue');
|
|
|
|
+ $output->writeln($que);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ }catch (\Exception $e){
|
|
|
|
+ Log::write('wxpush:'.$e->getMessage(),'error');
|
|
|
|
+ $output->writeln($e->getMessage());
|
|
|
|
+ }
|
|
|
|
+ Cache::delete('wxpush_lock');
|
|
}
|
|
}
|
|
}
|
|
}
|