public function indexAction() { $tTime = time(); $tH = date('H', $tTime); $tRedis = Cache_Redis::instance(); $tMO = new OrdinarydialysistimeModel(); $tODDMO = new OrdinarydialysisdateModel(); $tUMO = new UserModel(); $tUDMO = new UserdidModel(); $tUAMO = new UserassessmentModel(); $tCMO = new CenterModel(); if ($tH >= 7 && $tH <= 11) { #今日提醒 $tWeek = date('w', $tTime); $tDate = date('Y-m-d', $tTime); $tWhere = ' time_code in (2,3)'; $tDatas = $tMO->field('uid,time_code,time')->where($tWhere . ' and week like \'%' . $tWeek . '%\'')->fList(); foreach ($tDatas as $tRow) { #透析中心信息 $tUARow = $tUAMO->field('medical_id')->where('uid = ' . $tRow['uid'])->fRow(); if (!count($tUARow)) { continue; } $tCRow = $tCMO->field('today_weather,name')->where('id = ' . $tUARow['medical_id'])->fRow(); if (!count($tCRow)) { continue; } $tTitle = '透析提醒'; $tTimecodestr = $tRow['time_code'] == 2 ? '下午' : '晚上'; $tTimecodestr .= $tRow['time']; $tTpl_val = '#timecodestr#=今日' . $tTimecodestr . '&#name#=' . $tCRow['name'] . '&#weather#=今日天气' . $tCRow['today_weather']; $tContent = '您#timecodestr#在#name#透析,请准时参加,祝透析顺利。#weather#'; #用户信息 $tURow = $tUMO->field('phone')->where('id = ' . $tRow['uid'])->fRow(); if (!count($tURow)) { continue; } $tRedis->lpush('dakang_sms', serialize(array('content' => $tContent, 'phone' => $tURow['phone'], 'tpl_val' => $tTpl_val, 'type' => 'tx'))); #设备信息 $tSql = 'select cid,devicetoken from (select did from user_did where uid=' . $tRow['uid'] . ') ud,getui where ud.did = getui.did'; $tUDDatas = $tUDMO->query($tSql); $tTimecodestr = date('m月d日', $tTime) . $tTimecodestr; $tContent = '您' . $tTimecodestr . '在' . $tCRow['name'] . '透析,请准时参加,祝透析顺利。明日天气' . $tCRow['today_weather']; foreach ($tUDDatas as $tR) { $tRes = serialize(array_merge(array('title' => $tTitle, 'content' => $tContent, 'type' => 'tx', 'id' => ''), $tR)); $tRedis->lpush('dakang_getui', $tRes); } $tODDRow = $tODDMO->field('count(0) c')->where('uid = ' . $tRow['uid'] . ' and date = \'' . $tDate . '\'')->fRow(); if (!empty($tODDRow['c'])) { continue; } #添加透析日期 $tData = array('date' => $tDate, 'uid' => $tRow['uid'], 'time_code' => $tRow['time_code'], 'created' => $tTime); $tODDMO->insert($tData); } } elseif ($tH >= 13 && $tH <= 21) { #第二天上午 $tWeek = date('w', $tTime + 86400); $tDate = date('Y-m-d', $tTime + 86400); $tWhere = ' time_code = 1'; $tDatas = $tMO->field('uid,time_code,time')->where($tWhere . ' and week like \'%' . $tWeek . '%\'')->fList(); foreach ($tDatas as $tRow) { #透析中心信息 $tUARow = $tUAMO->field('medical_id')->where('uid = ' . $tRow['uid'])->fRow(); if (!count($tUARow)) { continue; } $tCRow = $tCMO->field('tomorrow_weather,name')->where('id = ' . $tUARow['medical_id'])->fRow(); if (!count($tCRow)) { continue; } $tTitle = '透析提醒'; $tTimecodestr = '上午' . $tRow['time']; $tTpl_val = '#timecodestr#=明日' . $tTimecodestr . '&#name#=' . $tCRow['name'] . '&#weather#=今日天气' . $tCRow['tomorrow_weather']; $tContent = '您#timecodestr#在#name#透析,请准时参加,祝透析顺利。#weather#'; #用户信息 $tURow = $tUMO->field('phone')->where('id = ' . $tRow['uid'])->fRow(); if (!count($tURow)) { continue; } $tRedis->lpush('dakang_sms', serialize(array('content' => $tContent, 'phone' => $tURow['phone'], 'tpl_val' => $tTpl_val, 'type' => 'tx'))); #设备信息 $tSql = 'select cid,devicetoken from (select did from user_did where uid=' . $tRow['uid'] . ') ud,getui where ud.did = getui.did'; $tUDDatas = $tUDMO->query($tSql); $tTimecodestr = date('m月d日', $tTime + 86400) . '上午' . $tRow['time']; $tContent = '您' . $tTimecodestr . '在' . $tCRow['name'] . '透析,请准时参加,祝透析顺利。明日天气' . $tCRow['tomorrow_weather']; foreach ($tUDDatas as $tR) { $tRes = serialize(array_merge(array('title' => $tTitle, 'content' => $tContent, 'type' => 'tx', 'id' => ''), $tR)); $tRedis->lpush('dakang_getui', $tRes); } #添加透析日期 $tODDRow = $tODDMO->field('count(0) c')->where('uid = ' . $tRow['uid'] . ' and date = \'' . $tDate . '\'')->fRow(); if (!empty($tODDRow['c'])) { continue; } $tData = array('date' => $tDate, 'uid' => $tRow['uid'], 'time_code' => $tRow['time_code'], 'created' => $tTime); $tODDMO->insert($tData); } } exit; }
public function indexAction() { $tTime = time(); $tH = date('H', $tTime); $tMO = new BqeschedulingdetailModel(); $tUMO = new UserModel(); $tUDMO = new UserdidModel(); $tUAMO = new UserassessmentModel(); $tCMO = new CenterModel(); $tRedis = Cache_Redis::instance(); echo '<pre>'; if ($tH >= 7 && $tH <= 11) { #今日提醒 $tDatas = $tMO->field('uid,time_code')->where('scheduling_date = \'' . date('Y-m-d', $tTime) . '\' and time_code in(2,3) and uid <> 0')->fList(); foreach ($tDatas as $tRow) { #透析中心信息 $tUARow = $tUAMO->field('medical_id')->where('uid = ' . $tRow['uid'])->fRow(); if (!count($tUARow)) { continue; } $tCRow = $tCMO->field('today_weather,name')->where('id = ' . $tUARow['medical_id'])->fRow(); if (!count($tCRow)) { continue; } $tTitle = '透析提醒'; $tTitle = '透析提醒'; $tTimecodestr = $tRow['time_code'] == 2 ? '下午' : '晚上'; $tTpl_val = '#timecodestr#=今日' . $tTimecodestr . '&#name#=' . $tCRow['name'] . '&#weather#=今日天气' . $tCRow['today_weather']; $tContent = '您#timecodestr#在#name#透析,请准时参加,祝透析顺利。#weather#'; #用户信息 $tURow = $tUMO->field('phone')->where('id = ' . $tRow['uid'])->fRow(); if (!count($tURow)) { continue; } $tRedis->lpush('dakang_sms', serialize(array('content' => $tContent, 'phone' => $tURow['phone'], 'tpl_val' => $tTpl_val, 'type' => 'tx'))); #设备信息 $tSql = 'select cid,devicetoken from (select did from user_did where uid=' . $tRow['uid'] . ') ud,getui where ud.did = getui.did'; $tUDDatas = $tUDMO->query($tSql); $tTimecodestr = date('m月d日', $tTime) . $tTimecodestr; $tContent = '您' . $tTimecodestr . '在' . $tCRow['name'] . '透析,请准时参加,祝透析顺利。明日天气' . $tCRow['today_weather']; foreach ($tUDDatas as $tR) { $tRes = serialize(array_merge(array('title' => $tTitle, 'content' => $tContent, 'type' => 'tx', 'id' => ''), $tR)); $tRedis->lpush('dakang_getui', $tRes); } } } elseif ($tH >= 19 && $tH <= 21) { $tTimeCode = 1; #第二天上午 $tDatas = $tMO->field('uid')->where('scheduling_date = \'' . date('Y-m-d', $tTime + 86400) . '\' and time_code = ' . $tTimeCode)->fList(); foreach ($tDatas as $tRow) { #透析中心信息 $tUARow = $tUAMO->field('medical_id')->where('uid = ' . $tRow['uid'])->fRow(); if (!count($tUARow)) { continue; } $tCRow = $tCMO->field('tomorrow_weather,name')->where('id = ' . $tUARow['medical_id'])->fRow(); if (!count($tCRow)) { continue; } $tTitle = '透析提醒'; $tTimecodestr = '上午'; $tTpl_val = '#timecodestr#=明日' . $tTimecodestr . '&#name#=' . $tCRow['name'] . '&#weather#=明日天气' . $tCRow['tomorrow_weather']; $tContent = '您#timecodestr#在#name#透析,请准时参加,祝透析顺利。#weather#'; #用户信息 $tURow = $tUMO->field('phone')->where('id = ' . $tRow['uid'])->fRow(); if (!count($tURow)) { continue; } $tRedis->lpush('dakang_sms', serialize(array('content' => $tContent, 'phone' => $tURow['phone']))); #设备信息 $tSql = 'select cid,devicetoken from (select did from user_did where uid=' . $tRow['uid'] . ') ud,getui where ud.did = getui.did'; $tUDDatas = $tUDMO->query($tSql); $tTimecodestr = date('m月d日', $tTime + 86400) . '上午' . $tRow['time']; $tContent = '您' . $tTimecodestr . '在' . $tCRow['name'] . '透析,请准时参加,祝透析顺利。明日天气' . $tCRow['tomorrow_weather']; foreach ($tUDDatas as $tR) { $tRes = serialize(array_merge(array('title' => $tTitle, 'content' => $tContent, 'type' => 'tx', 'id' => ''), $tR)); $tRedis->lpush('dakang_getui', $tRes); } } } }