<?php
/**
* Created by PhpStorm.
* User: 1435223839@qq.com
* NickName: He199501
* Date: 2018/09/20 16:34
*/
namespace app\app\controller;
use think\Db;
use think\Log;
use think\Request;
class Index extends Base
{
//签到
public function sign()
{
$data["uid"] = $_REQUEST["id"];
$data["dates"] = date("Y-m-d");
$nowtime = date("Y-m-d");
//判断用户今天是否已经签到过了
if (db("sign")->where("uid", $data["uid"])->where('dates', $nowtime)->find()) {
ajaxmsg('false', 0);
} else {
Db::name('sign')->insertGetId($data);
}
//返回今天签到的日期
return date("d");
}
//签到列表
public function sign_list()
{
$userid = $_REQUEST["id"];
//查询本人这个月 有那些天签到了
$a = date("Y-m");//获取本月份
$b = strtotime("+1 months");//获取下一个月份
$b = date("Y-m", $b);//用来查询 本月的所有天数 大于本月 小于下一个月
$data = db("sign")->where("uid", $userid)->where("dates", ">=", $a)->where("dates", "<=", $b)->select();
$arr = [];
foreach ($data as $key => $value) {
$arr['list'][] = substr($value["dates"], 8, 2);
}
$arr['count'] = db("sign")->where("uid", $userid)->where("dates", ">=", $a)->where("dates", "<=", $b)->count();
ajaxmsg('true', 1, $arr);
}
}