WxPush.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\txx\listener;
  4. use app\txx\model\Act;
  5. use think\facade\Cache;
  6. use think\facade\Log;
  7. class WxPush
  8. {
  9. public function handle($event)
  10. {
  11. if($event==null)return;
  12. if($event['status']==3){
  13. $act = Act::where(['actCode'=>$event['actCode']])->findOrEmpty();
  14. if(!$act->isEmpty()){
  15. $this->push($act->toArray());
  16. }
  17. }
  18. }
  19. public function push($data){
  20. $temps=[
  21. 'code'=>$data['actCode'],
  22. 'belong'=>1,
  23. 'openId'=>'oOpc26OhvWzdO0JlL9Q37rXyu69I',
  24. 'template_id'=>'oUFsgOfVNqavIzQKS9bT1as1miFNJ5-Q-h68eFiiQ0Q',
  25. 'template_name'=>'系统单据处理通知',
  26. 'action_name'=>'泰行销活动审批推送',
  27. 'template_data'=>['thing8' => ['value' => '泰行销直播'],
  28. 'thing4' => ['value' => $data['actCode']],
  29. 'thing5' =>['value' => Act::$statusCn[$data['status']]??'未知'],
  30. 'thing17' =>['value' => $data['contactor']],
  31. 'thing20' =>['value' => $data['depart']]
  32. ],
  33. 'uid'=>106,
  34. 'uname'=>'魏莉',
  35. ];
  36. Log::info("推送数据".json_encode($temps,JSON_UNESCAPED_UNICODE));
  37. Cache::store('redis')->handler()->lPush('wxpush_queue',json_encode($temps));
  38. }
  39. }