作者 潘浩文
1 个管道 的构建 通过 耗费 1 秒

接口

@@ -156,8 +156,6 @@ class SignController extends RestBaseController @@ -156,8 +156,6 @@ class SignController extends RestBaseController
156 public function daySignPost(){ 156 public function daySignPost(){
157 $param=$this->request->param(); 157 $param=$this->request->param();
158 $user=Db::name('user')->where('id',$this->getUserId())->find(); 158 $user=Db::name('user')->where('id',$this->getUserId())->find();
159 - $config=[];  
160 - $music=[];  
161 //是否需要进入每日一签页面 159 //是否需要进入每日一签页面
162 $day_sign=0; 160 $day_sign=0;
163 //根据签到种类判断增加积分数 161 //根据签到种类判断增加积分数
@@ -217,7 +215,6 @@ class SignController extends RestBaseController @@ -217,7 +215,6 @@ class SignController extends RestBaseController
217 Db::name('user_score_log')->insert(['score'=>$score,'create_time'=>time(),'action'=>'打卡','user_id'=>$user['id'],'now_score'=>$user['score']+$score]); 215 Db::name('user_score_log')->insert(['score'=>$score,'create_time'=>time(),'action'=>'打卡','user_id'=>$user['id'],'now_score'=>$user['score']+$score]);
218 216
219 217
220 -  
221 //返回 218 //返回
222 $this->success('日打卡提交结果',array( 219 $this->success('日打卡提交结果',array(
223 'day_sign'=>$day_sign, 220 'day_sign'=>$day_sign,
@@ -253,7 +250,6 @@ class SignController extends RestBaseController @@ -253,7 +250,6 @@ class SignController extends RestBaseController
253 $score=$score['sleep_sign_score']; 250 $score=$score['sleep_sign_score'];
254 } 251 }
255 252
256 -  
257 $date=date("w",time()); //这个可以获取数字星期比如123,注意0是星期日 253 $date=date("w",time()); //这个可以获取数字星期比如123,注意0是星期日
258 $config=Db::name('sign_image')->where('date',$date)->find(); 254 $config=Db::name('sign_image')->where('date',$date)->find();
259 $music=json_decode($config['music'],true); 255 $music=json_decode($config['music'],true);
@@ -279,10 +275,16 @@ class SignController extends RestBaseController @@ -279,10 +275,16 @@ class SignController extends RestBaseController
279 public function share() 275 public function share()
280 { 276 {
281 //用户信息 277 //用户信息
282 - $config = Db::name('config')->where('id', 1)->find();  
283 - Db::name('user')->where('id',$this->getUserId())->setInc('score',$config['share_score']);  
284 $user= Db::name('user')->where('id',$this->getUserId())->find(); 278 $user= Db::name('user')->where('id',$this->getUserId())->find();
285 - Db::name('user_score_log')->insert(['user_id'=>$this->getUserId(),'score'=>$config['share_score'],'now_score'=>$user['score']]); 279 + $config = Db::name('config')->where('id', 1)->find();
  280 + $beginToday=mktime(0,0,0,date('m'),date('d'),date('Y'));
  281 + $endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
  282 + $re=Db::name('user_score_log')->where(['user_id'=>$user['id'],'action'=>'分享','create_time'=>[ 'between time', [$beginToday,$endToday]]])->find();
  283 + if ($re){
  284 + $this->error('您今天已经分享过了');
  285 + }
  286 + Db::name('user')->where('id',$user['id'])->setInc('score',$config['share_score']);
  287 + Db::name('user_score_log')->insert(['user_id'=>$user['id'],'score'=>$config['share_score'],'now_score'=>($user['score']+$config['share_score'])]);
286 $this->success('分享成功'); 288 $this->success('分享成功');
287 } 289 }
288 290