123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657 |
- <?php
- namespace app\api\controller;
- use app\common\model\LabelMessage;
- use app\common\model\User;
- use app\common\model\UserMessage;
- /**
- * @title 定时任务
- * Class Task
- * @controller Task
- * @group base
- */
- class Task extends Base
- {
- // 会员消息推送
- public function taskUserMessage(){
- $list = UserMessage::field('id,user_id,content')->where('jg_type',1)->where('jg_status',0)->limit(0,50)->order('id')->select();
- foreach ($list as $v) {
- UserMessage::where(['id'=>$v['id']])->update(['jg_status'=>1]);
- Jpush($v['user_id'],$v['content']);
- }
- }
- /**
- * @title 标签推送[根据标签id]
- * @desc 标签推送
- * @author qc
- * @url /api/Task/taskLabelMessage
- */
- //按照标签推送
- public function taskLabelMessage()
- {
- $list = LabelMessage::where('jg_status',0)->where('is_deleted',0)->select()->toArray();
- foreach ($list as $v) {
- LabelMessage::where(['id'=>$v['id']])->update(['jg_status'=>1]);
- $user_list = User::field('id')
- ->where('label','like','%|'.$v['label_id'].'|%')
- ->where('status','=',1)
- ->where('type','=',1)
- ->where('is_deleted','=',0)->select()->toArray();;
- foreach ($user_list as $user_info) {
- $res = Jpush($user_info['id'],$v['content']);
- }
- }
- }
- }
|