...
|
...
|
@@ -17,7 +17,7 @@ class SignController extends RestBaseController |
|
|
* @url /portal/Sign/index
|
|
|
* @method POST
|
|
|
* @header name:XX-Token require:1 default: desc:token
|
|
|
* @return sign:1是早打卡,2是午打卡,3是晚打卡,4是睡前打卡,0是当前不在打卡时间
|
|
|
* @return sign:1是早打卡,2是午打卡,3是晚打卡,4是睡前打卡,0不能打卡
|
|
|
* @return slogan:口号
|
|
|
*/
|
|
|
public function index()
|
...
|
...
|
@@ -137,14 +137,18 @@ class SignController extends RestBaseController |
|
|
*/
|
|
|
public function daySignPost(){
|
|
|
$param=$this->request->param();
|
|
|
//根据星期判断music,image
|
|
|
$date=date("w",time()); //这个可以获取数字星期比如123,注意0是星期日
|
|
|
$config=Db::name('sign_image')->where('date',$date)->find();
|
|
|
$music=json_decode($config['music'],true);
|
|
|
$music=$music[rand(0,count($music,0)-1)];
|
|
|
$user=Db::name('user')->where('id',$this->getUserId())->find();
|
|
|
$config=[];
|
|
|
$music=[];
|
|
|
//根据签到种类判断增加积分数
|
|
|
$score=Db::name('config')->where('id',1)->find();
|
|
|
if ($param['status']==1){
|
|
|
//根据星期判断music,image(只有早签到)
|
|
|
$date=date("w",time()); //这个可以获取数字星期比如123,注意0是星期日
|
|
|
$config=Db::name('sign_image')->where('date',$date)->find();
|
|
|
$music=json_decode($config['music'],true);
|
|
|
$music=$music[rand(0,count($music,0)-1)];
|
|
|
//早签到积分
|
|
|
$score=$score['morning_sign_score'];
|
|
|
$type='morning';
|
|
|
}elseif ($param['status']==2){
|
...
|
...
|
@@ -172,7 +176,7 @@ class SignController extends RestBaseController |
|
|
Db::name('user')->where('id',$this->getUserId())->setInc('all_sign_day',1);
|
|
|
//判断是否为连续打卡
|
|
|
$last=Db::name('user_sign')->where(['user_id'=>$this->getUserId(),'status'=>1,'create_time'=>[ 'between time', [$yesterday,$beginToday]]])->find();
|
|
|
$user=Db::name('user')->where('id',$this->getUserId())->find();
|
|
|
|
|
|
if ($user['stay_sign_day']==0||$last)
|
|
|
{
|
|
|
Db::name('user')->where('id',$this->getUserId())->setInc('all_sign_day',1);
|
...
|
...
|
@@ -189,12 +193,10 @@ class SignController extends RestBaseController |
|
|
}
|
|
|
//记录打卡积分
|
|
|
Db::name('user')->where('id',$this->getUserId())->setInc('score',$score);
|
|
|
Db::name('user_score_log')->insert(['score'=>$score,'create_time'=>time(),'action'=>'打卡','user_id'=>$this->getUserId(),'now_score'=>Db::name('user')->where('id',$this->getUserId())->find()['score']]);
|
|
|
Db::name('user_score_log')->insert(['score'=>$score,'create_time'=>time(),'action'=>'打卡','user_id'=>$this->getUserId(),'now_score'=>$user['score']+$score]);
|
|
|
|
|
|
//判断是否需要进行周打卡
|
|
|
if (!Db::name('user_week_sign')->where('user_id',$this->getUserId())->find()){
|
|
|
$is_week=1;
|
|
|
}elseif (Db::name('user_week_sign')->where(['user_id'=>$this->getUserId(),'create_time'=>[ '<', $beginToday-($score['week_sign']*24*60*60)]])->find()){
|
|
|
if (Db::name('user_week_sign')->where(['user_id'=>$this->getUserId(),'create_time'=>[ '<', $beginToday-($score['week_sign']*24*60*60)]])->find()){
|
|
|
$is_week=1;
|
|
|
}else{
|
|
|
$is_week=0;
|
...
|
...
|
|