基于tp的每日签到

// 每日签到
public function dailySign(){
// 获取用户签到信息
m e r A r r = M ( ′ m e r c h a n t ′ ) − > w h e r e ( " M e r I D = ′ merArr = M('merchant') -> where("MerID = ' merArr=M(merchant)>where("MerID=this->UserId’") -> find();
// 判断是否为注册后第一次签到
if($merArr[‘totalTime’] == 0 && $merArr[‘totalnum’] == 0){
// 获取签到设置
$signArr = M(‘sign’) -> where(“num = 1”) -> find();
$Yunbi = $signArr[‘yun’];
$score[‘Mertotal’] = array(‘exp’,“Mertotal + $Yunbi”);
$score[‘totalnum’] = 1;
$score[‘totalTime’] = time();
r e s u l t = M ( ′ m e r c h a n t ′ ) − > w h e r e ( " M e r I D = ′ result = M('merchant') -> where("MerID = ' result=M(merchant)>where("MerID=this->UserId’") -> save( s c o r e ) ; i f ( score); if( score);if(result > 0){
echo “签到成功”;
}else{
echo “签到失败”;
}
}else{
// 获取登录用户签到信息
$totalTime = $merArr[‘totalTime’]; // 签到时间
$totalnum = $merArr[‘totalnum’]; // 签到次数
s i g n T i m e = d a t e ( ′ y − m − d ′ , signTime = date('y-m-d', signTime=date(ymd,totalTime); // 格式化签到时间
// 判断今天是否已经签到
if($signTime == date(‘y-m-d’,time())){
echo “已签到”;
exit;
}else{
// 判断是否错过连续签到时间
if(time() - $totalTime > 606024){
// 获取签到设置
$signArr = M(‘sign’) -> where(“num = 1”) -> find();
$Yunbi = $signArr[‘yun’];
$score[‘Mertotal’] = array(‘exp’,“Mertotal + $Yunbi”);
$score[‘totalnum’] = 1;
$score[‘totalTime’] = time();
r e s u l t = M ( ′ m e r c h a n t ′ ) − > w h e r e ( " M e r I D = ′ result = M('merchant') -> where("MerID = ' result=M(merchant)>where("MerID=this->UserId’") -> save( s c o r e ) ; i f ( score); if( score);if(result > 0){
echo “签到成功”;
}else{
echo “签到失败”;
}
}else{
// 获取签到设置
$signArr = M(‘sign’) -> where(“num = t o t a l n u m + 1 " ) − > f i n d ( ) ; i f ( totalnum + 1") -> find(); if( totalnum+1")>find();if(signArr != null){
$Yunbi = $signArr[‘yun’];
}else{
$maxYun = M(‘sign’) -> Max(‘num’);
$signArr = M(‘sign’) -> where(“num = $maxYun”) -> find();
$Yunbi = $signArr[‘yun’];
}
$score[‘Mertotal’] = array(‘exp’,“Mertotal + $Yunbi”);
$score[‘totalnum’] = $totalnum + 1;
$score[‘totalTime’] = time();
r e s u l t = M ( ′ m e r c h a n t ′ ) − > w h e r e ( " M e r I D = ′ result = M('merchant') -> where("MerID = ' result=M(merchant)>where("MerID=this->UserId’”) -> save( s c o r e ) ; i f ( score); if( score);if(result > 0){
echo “签到成功”;
}else{
echo “签到失败”;
}
}
}
}
}

– 表的结构 web_sign

CREATE TABLE IF NOT EXISTS web_sign (
id int(11) NOT NULL AUTO_INCREMENT,
num tinyint(4) NOT NULL,
yun int(11) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT=‘签到表’ AUTO_INCREMENT=3 ;

– 转存表中的数据 web_sign

INSERT INTO web_sign (id, num, yun) VALUES
(1, 1, 20),
(2, 2, 40);

你可能感兴趣的:(php)