|
@@ -17,7 +17,7 @@ class SignController extends RestBaseController |
|
@@ -17,7 +17,7 @@ class SignController extends RestBaseController |
17
|
* @url /portal/Sign/index
|
17
|
* @url /portal/Sign/index
|
18
|
* @method POST
|
18
|
* @method POST
|
19
|
* @header name:XX-Token require:1 default: desc:token
|
19
|
* @header name:XX-Token require:1 default: desc:token
|
20
|
- * @return sign:1是早打卡,2是午打卡,3是晚打卡,4是睡前打卡,0是当前不在打卡时间
|
20
|
+ * @return sign:1是早打卡,2是午打卡,3是晚打卡,4是睡前打卡,0不能打卡
|
21
|
* @return slogan:口号
|
21
|
* @return slogan:口号
|
22
|
*/
|
22
|
*/
|
23
|
public function index()
|
23
|
public function index()
|
|
@@ -137,14 +137,18 @@ class SignController extends RestBaseController |
|
@@ -137,14 +137,18 @@ class SignController extends RestBaseController |
137
|
*/
|
137
|
*/
|
138
|
public function daySignPost(){
|
138
|
public function daySignPost(){
|
139
|
$param=$this->request->param();
|
139
|
$param=$this->request->param();
|
140
|
- //根据星期判断music,image
|
140
|
+ $user=Db::name('user')->where('id',$this->getUserId())->find();
|
|
|
141
|
+ $config=[];
|
|
|
142
|
+ $music=[];
|
|
|
143
|
+ //根据签到种类判断增加积分数
|
|
|
144
|
+ $score=Db::name('config')->where('id',1)->find();
|
|
|
145
|
+ if ($param['status']==1){
|
|
|
146
|
+ //根据星期判断music,image(只有早签到)
|
141
|
$date=date("w",time()); //这个可以获取数字星期比如123,注意0是星期日
|
147
|
$date=date("w",time()); //这个可以获取数字星期比如123,注意0是星期日
|
142
|
$config=Db::name('sign_image')->where('date',$date)->find();
|
148
|
$config=Db::name('sign_image')->where('date',$date)->find();
|
143
|
$music=json_decode($config['music'],true);
|
149
|
$music=json_decode($config['music'],true);
|
144
|
$music=$music[rand(0,count($music,0)-1)];
|
150
|
$music=$music[rand(0,count($music,0)-1)];
|
145
|
- //根据签到种类判断增加积分数
|
|
|
146
|
- $score=Db::name('config')->where('id',1)->find();
|
|
|
147
|
- if ($param['status']==1){
|
151
|
+ //早签到积分
|
148
|
$score=$score['morning_sign_score'];
|
152
|
$score=$score['morning_sign_score'];
|
149
|
$type='morning';
|
153
|
$type='morning';
|
150
|
}elseif ($param['status']==2){
|
154
|
}elseif ($param['status']==2){
|
|
@@ -172,7 +176,7 @@ class SignController extends RestBaseController |
|
@@ -172,7 +176,7 @@ class SignController extends RestBaseController |
172
|
Db::name('user')->where('id',$this->getUserId())->setInc('all_sign_day',1);
|
176
|
Db::name('user')->where('id',$this->getUserId())->setInc('all_sign_day',1);
|
173
|
//判断是否为连续打卡
|
177
|
//判断是否为连续打卡
|
174
|
$last=Db::name('user_sign')->where(['user_id'=>$this->getUserId(),'status'=>1,'create_time'=>[ 'between time', [$yesterday,$beginToday]]])->find();
|
178
|
$last=Db::name('user_sign')->where(['user_id'=>$this->getUserId(),'status'=>1,'create_time'=>[ 'between time', [$yesterday,$beginToday]]])->find();
|
175
|
- $user=Db::name('user')->where('id',$this->getUserId())->find();
|
179
|
+
|
176
|
if ($user['stay_sign_day']==0||$last)
|
180
|
if ($user['stay_sign_day']==0||$last)
|
177
|
{
|
181
|
{
|
178
|
Db::name('user')->where('id',$this->getUserId())->setInc('all_sign_day',1);
|
182
|
Db::name('user')->where('id',$this->getUserId())->setInc('all_sign_day',1);
|
|
@@ -189,12 +193,10 @@ class SignController extends RestBaseController |
|
@@ -189,12 +193,10 @@ class SignController extends RestBaseController |
189
|
}
|
193
|
}
|
190
|
//记录打卡积分
|
194
|
//记录打卡积分
|
191
|
Db::name('user')->where('id',$this->getUserId())->setInc('score',$score);
|
195
|
Db::name('user')->where('id',$this->getUserId())->setInc('score',$score);
|
192
|
- 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']]);
|
196
|
+ Db::name('user_score_log')->insert(['score'=>$score,'create_time'=>time(),'action'=>'打卡','user_id'=>$this->getUserId(),'now_score'=>$user['score']+$score]);
|
193
|
|
197
|
|
194
|
//判断是否需要进行周打卡
|
198
|
//判断是否需要进行周打卡
|
195
|
- if (!Db::name('user_week_sign')->where('user_id',$this->getUserId())->find()){
|
|
|
196
|
- $is_week=1;
|
|
|
197
|
- }elseif (Db::name('user_week_sign')->where(['user_id'=>$this->getUserId(),'create_time'=>[ '<', $beginToday-($score['week_sign']*24*60*60)]])->find()){
|
199
|
+ if (Db::name('user_week_sign')->where(['user_id'=>$this->getUserId(),'create_time'=>[ '<', $beginToday-($score['week_sign']*24*60*60)]])->find()){
|
198
|
$is_week=1;
|
200
|
$is_week=1;
|
199
|
}else{
|
201
|
}else{
|
200
|
$is_week=0;
|
202
|
$is_week=0;
|