|
@@ -14,7 +14,52 @@ class Piaoliuping extends Api
|
|
|
|
|
|
//捡一个
|
|
|
public function getone(){
|
|
|
- $rs = Db::name('piaoliuping')->where('user_id','NEQ',$this->auth->id)->orderRaw('rand()')->find();
|
|
|
+
|
|
|
+ //判断vip身份,限制每日捡的个数
|
|
|
+ $vip_endtime = model('wallet')->getWallet($this->auth->id,'vip_endtime');
|
|
|
+ if($vip_endtime < time()){
|
|
|
+
|
|
|
+ $plp_unvip_daysnum = config('site.plp_unvip_daysnum');
|
|
|
+ if($plp_unvip_daysnum > -1){
|
|
|
+
|
|
|
+ $starttime = strtotime(date('Y-m-d'));
|
|
|
+ $endtime = $starttime + 86399;
|
|
|
+
|
|
|
+ $where = [
|
|
|
+ 'user_id' => $this->auth->id,
|
|
|
+ 'createtime' => ['BETWEEN',[$starttime,$endtime]],
|
|
|
+ ];
|
|
|
+ $count = Db::name('piaoliuping_log')->where($where)->count('id');
|
|
|
+ if($count >= $plp_unvip_daysnum){
|
|
|
+ $this->error('非vip每天只能捡3个');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //不能是自己发的
|
|
|
+ $map = [
|
|
|
+ 'user_id' => ['NEQ',$this->auth->id],
|
|
|
+ ];
|
|
|
+
|
|
|
+ //不能重复
|
|
|
+ $log_list = Db::name('piaoliuping_log')->where('user_id',$this->auth->id)->column('plp_id');
|
|
|
+ if(!empty($log_list)){
|
|
|
+ $map['id'] = ['NOTIN',$log_list];
|
|
|
+ }
|
|
|
+
|
|
|
+ $rs = Db::name('piaoliuping')->where($map)->orderRaw('rand()')->find();
|
|
|
+
|
|
|
+ //记录查看记录
|
|
|
+ if(!empty($rs)){
|
|
|
+ $log_data = [
|
|
|
+ 'user_id' => $this->auth->id,
|
|
|
+ 'plp_id' => $rs['id'],
|
|
|
+ 'createtime' => time(),
|
|
|
+ ];
|
|
|
+ Db::name('piaoliuping_log')->insertGetId($log_data);
|
|
|
+ }
|
|
|
+
|
|
|
$this->success('success',$rs);
|
|
|
}
|
|
|
|