소스 검색

修改认证到期时间的缓存

刘远航 4 년 전
부모
커밋
10414ec54f
1개의 변경된 파일20개의 추가작업 그리고 8개의 파일을 삭제
  1. 20 8
      app/Console/Commands/overTimeOrder.php

+ 20 - 8
app/Console/Commands/overTimeOrder.php

xqd xqd
@@ -121,10 +121,16 @@ class overTimeOrder extends Command
         $list = DocterOrganization::with('docter','organization')->get();
         if($list){
             foreach ($list as $k=>$v){
-                if ($v['docter']['openid']&& time()>=strtotime($v['authentication_end_time'])){
-                    order_trace(['类型'=>'签约失效提醒','医生openid'=>$v['docter']['openid'],'记录时间'=>date('Ymd His',time())],'info');
-
-                    $send = send_wechatSubscription_message('out_then_reminder',[$v['docter']['openid'],  "pages/index/index", $v['organization']['name'],date('Y-m-d',strtotime($v['authentication_end_time']))]);
+                if (!\Cache::has($v['id'].'-InvalidThenReminder')) {
+                    if ($v['docter']['openid']&& time()>=strtotime($v['authentication_end_time'])){
+                        order_trace(['类型'=>'签约失效提醒','医生openid'=>$v['docter']['openid'],'记录时间'=>date('Ymd His',time())],'info');
+                        $send = send_wechatSubscription_message('out_then_reminder',[$v['docter']['openid'],  "pages/index/index", $v['organization']['name'],date('Y-m-d',strtotime($v['authentication_end_time']))]);
+                        if ($send){
+                            \Cache::forever($v['id'].'-InvalidThenReminder',$v['id']);
+                        }else{
+                            order_trace(['公共方法发送微信模板消息失败', '请求类型' => 'InvalidThenReminder' ?? '', '返回数据' => $send ?? ''], 'error');
+                        }
+                    }
                 }
             }
         }
@@ -141,10 +147,16 @@ class overTimeOrder extends Command
         $list = DocterOrganization::with('docter','organization')->get();
         if($list){
             foreach ($list as $k=>$v){
-                if ($v['docter']['openid']&& (strtotime($v['authentication_end_time'])-strtotime($v['authentication_time']))<=(1*60*60*24)){
-                    order_trace(['类型'=>'认证到期提醒','医生openid'=>$v['docter']['openid'],'记录时间'=>date('Ymd His',time())],'info');
-
-                    $send = send_wechatSubscription_message('out_then_reminder',[$v['docter']['openid'],  "pages/index/index", $v['organization']['name'],date('Y-m-d',strtotime($v['authentication_end_time']))]);
+                if (!\Cache::has($v['id'].'-OutThenReminder')) {
+                    if ($v['docter']['openid']&& (strtotime($v['authentication_end_time'])-strtotime($v['authentication_time']))<=(1*60*60*24)){
+                        order_trace(['类型'=>'认证到期提醒','医生openid'=>$v['docter']['openid'],'记录时间'=>date('Ymd His',time())],'info');
+                        $send = send_wechatSubscription_message('out_then_reminder',[$v['docter']['openid'],  "pages/index/index", $v['organization']['name'],date('Y-m-d',strtotime($v['authentication_end_time']))]);
+                        if ($send){
+                            \Cache::forever($v['id'].'-OutThenReminder',$v['id']); 
+                        }else{
+                            order_trace(['公共方法发送微信模板消息失败', '请求类型' => 'OutThenReminder' ?? '', '返回数据' => $send ?? ''], 'error');
+                        }
+                    }
                 }
             }
         }