有奖活动--给今天生日会员发送生日祝福(本活动可重复执行)
有没有人用过啊,为什么发了祝福却不能完成任务啊???
<?php
/*
[UCenter Home] (C) 2007-2008 Comsenz Inc.
*/
if(!defined('IN_UCHOME')) {
exit('Access Denied');
}
//要求发送的祝福数
$maxbless = 10;
$currTime = $_SGLOBAL['timestamp'];
$currMonth = intval(date("m",$currTime));
$currDay = intval(date("d",$currTime));
$currYear = intval(date("Y",$currTime));
$today = mktime(0,0,0,$currMonth,$currDay,$currYear);
//今天过生日的会员数
$birthdaysql = "SELECT count(sf.uid) FROM ".tname('spacefield')." sf
WHERE sf.birthmonth = $currMonth AND sf.birthday = $currDay
LIMIT 0,1";
$birthdayquery = $_SGLOBAL['db']->query($birthdaysql);
$birthdaycount = $_SGLOBAL['db']->result($birthdayquery);
//发过短信的生日会员数
$pmsql = "SELECT count(sf.uid) FROM ".tname('spacefield')." sf
WHERE sf.birthmonth = $currMonth AND sf.birthday = $currDay
AND sf.uid IN (SELECT p.msgtoid FROM ucenter.uc_pms p WHERE p.msgfromid = ".$_SGLOBAL['supe_uid']." AND (p.dateline BETWEEN $today AND $today+86400))
LIMIT 0,1";
$pmquery = $_SGLOBAL['db']->query($pmsql);
$pmcount = $_SGLOBAL['db']->result($pmquery);
if($birthdaycount && ($pmcount==$birthdaycount || $pmcount>=$maxbless)) {
$task['done'] = 1;//活动完成
if($space['birthmonth']==0 || $space['birthday']==0) {
$task['result'] ='
→将个人资料补充完整,以便其他会员能够给我发送生日祝福!
';
}
} else {
if($birthdaycount==0) {
//今天没有会员过生日
$task['guide'] = '今天没有会员过生日。
';
} else {
$birthdaylist = array();
$query = $_SGLOBAL['db']->query("SELECT s.uid,s.username,s.name,s.namestatus FROM ".tname('spacefield')." sf
LEFT JOIN ".tname('space')." s ON s.uid=sf.uid
WHERE sf.birthmonth = $currMonth AND sf.birthday = $currDay
ORDER BY rand()
LIMIT 0,$maxbless");
while ($value = $_SGLOBAL['db']->fetch_array($query)) {
realname_set($value['uid'], $value['username'], $value['name'], $value['namestatus']);
$birthdaylist[] = $value;
}
if($birthdaylist) {
$task['guide'] .= '以下会员今天过生日,请为他们送上生日祝福吧:
';
$task['guide'] .= '';
}
}
$birthdaylist = array();
$query = $_SGLOBAL['db']->query("SELECT s.uid,s.username,s.name,s.namestatus,sf.birthmonth,sf.birthday FROM ".tname('spacefield')." sf
LEFT JOIN ".tname('space')." s ON s.uid=sf.uid
WHERE sf.birthmonth = $currMonth AND sf.birthday >= $currDay+1
ORDER BY sf.birthday ASC
LIMIT 0,100");
while ($value = $_SGLOBAL['db']->fetch_array($query)) {
realname_set($value['uid'], $value['username'], $value['name'], $value['namestatus']);
$birthdaylist[] = $value;
}
if($birthdaylist) {
$task['guide'] .= '本月还有以下会员过生日,欢迎届时为他们送上生日祝福:
';
$task['guide'] .= '';
} else {
$task['guide'] .= '明天起至月底前,没有会员过生日。欢迎下月继续参加本活动。
';
}
if($space['birthmonth']==0 || $space['birthday']==0) {
$task['guide'] .='→将个人资料补充完整,以便其他会员能够给我发送生日祝福!
';
}
}
?> |