WxPush.php 1.5 KB

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