123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- <?php
- namespace app\cron;
- use app\common\model\Config;
- use app\common\util\AppMsg;
- use think\Db;
- use yunwuxin\cron\Task;
- class Complain extends Task
- {
- public function configure()
- {
- $this->everyMinute(); //每分钟执行一次
- }
- /**
- * 执行任务
- * @return mixed
- */
- protected function execute()
- {
- try{
- $this->complain();
- }catch (\Exception $e){
- trace($e->getMessage());
- }
- trace('attendance');
- }
- public function complain(){
- $lists = Db::name('config_org')
- ->alias('a')
- ->join('config b','a.config_id = b.id')
- ->where('b.name','org_complain_hour')
- ->field('a.org_id,a.value')
- ->select();
- $lists = $lists?$lists:[];
- foreach ($lists as $k=>$v){
- if($v['value'] > 0){
- // 获取当前组织是否设置人员,设置人员才发送超时提醒
- $users = (new Config())->getConfig('org_complain_user',$v['org_id']);
- if($users){
- $uids = Db::name('user')->where('id','in',$users)->where('del',0)->where('enable')->column('id');
- if($uids){
- // 检查是否有超时未处理投诉
- $map = [];
- $endTime = date('Y-m-d H:i:s',time() - $v['value']*60*60);
- $map[] = ['create_time','<',$endTime];
- $map[] = ['status','=',0];
- $map[] = ['org_id','=',$v['org_id']];
- $map[] = ['del','=',0];
- $ret = Db::name('complain')
- ->where($map)
- ->field('id,content,create_time,status,order_id')
- ->find();
- if($ret){
- send_jpush($uids,AppMsg::PUSH_COMPLAIN_TIMEOUT);
- }
- }
- }
- }
- }
- }
- }
|