Task.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\model\LabelMessage;
  4. use app\common\model\User;
  5. use app\common\model\UserMessage;
  6. /**
  7. * @title 定时任务
  8. * Class Task
  9. * @controller Task
  10. * @group base
  11. */
  12. class Task extends Base
  13. {
  14. // 会员消息推送
  15. public function taskUserMessage(){
  16. $list = UserMessage::field('id,user_id,content')->where('jg_type',1)->where('jg_status',0)->limit(0,50)->order('id')->select();
  17. foreach ($list as $v) {
  18. UserMessage::where(['id'=>$v['id']])->update(['jg_status'=>1]);
  19. Jpush($v['user_id'],$v['content']);
  20. }
  21. }
  22. /**
  23. * @title 标签推送[根据标签id]
  24. * @desc 标签推送
  25. * @author qc
  26. * @url /api/Task/taskLabelMessage
  27. */
  28. //按照标签推送
  29. public function taskLabelMessage()
  30. {
  31. $list = LabelMessage::where('jg_status',0)->where('is_deleted',0)->select()->toArray();
  32. foreach ($list as $v) {
  33. LabelMessage::where(['id'=>$v['id']])->update(['jg_status'=>1]);
  34. $user_list = User::field('id')
  35. ->where('label','like','%|'.$v['label_id'].'|%')
  36. ->where('status','=',1)
  37. ->where('type','=',1)
  38. ->where('is_deleted','=',0)->select()->toArray();;
  39. foreach ($user_list as $user_info) {
  40. $res = Jpush($user_info['id'],$v['content']);
  41. }
  42. }
  43. }
  44. }