wqData['uniacid'],'oldWithNew'); if(!$power){ echo json_encode(['code'=>2,'msg'=>'暂无权限']);die; } } //老带新首页 public function actionIndex(){ $userId=$this->wqData['userId']; $uniacid=$this->wqData['uniacid']; $now=time(); $actInfo=(new \yii\db\Query()) ->from('{{%ybwm_old_with_new}}') ->where('uniacid=:uniacid AND display=1 AND deleteAt=0 AND startTime<=:time AND endTime>:time',[':time'=>$now,':uniacid'=>$uniacid])->one();//查看活动 $rewardArr=json_decode($actInfo['rewardArr'],true);//奖励数组 $num=(new \yii\db\Query()) ->from('{{%ybwm_old_with_new_bind}}') ->where('actId=:actId AND state=1 AND userId=:userId',[':actId'=>$actInfo['id'],':userId'=>$userId])->count(); $people=(new \yii\db\Query()) ->from('{{%ybwm_old_with_new_bind}}') ->where('actId=:actId',[':actId'=>$actInfo['id']])->groupBy('userId')->count(); $data['people']=$people?:0; for($i=0;$i=$people){ $rewardArr[$i]['state']=1; } } $data['waitMoney']=0; // print_R($rewardArr);die; for($j=0;$jfrom('{{%ybwm_old_with_new_detailed}}') ->where('actId=:actId AND userId=:userId',[':actId'=>$actInfo['id'],':userId'=>$userId])->sum('money'); $data['num']=$num?:0; $data['rewardArr']=$rewardArr; $data['money']=$money?:0; $data['actinfo']=$actInfo; return $this->result(1, '成功', $data); } public function actionRank(){ $now=time(); $result=axios_request(); $uniacid=$this->wqData['uniacid']; $type=$result['type']; $actInfo=(new \yii\db\Query()) ->from('{{%ybwm_old_with_new}}') ->where('uniacid=:uniacid AND display=1 AND deleteAt=0 AND startTime<=:time AND endTime>:time',[':time'=>$now,':uniacid'=>$uniacid])->one();//查看活动 $date=date('Y-m-d'); //当前日期 $first=1; //$first =1 表示每周星期一为开始日期 0表示每周日为开始日期 $w=date('w',strtotime($date)); //获取当前周的第几天 周日是 0 周一到周六是 1 - 6 $now_start=date('Y-m-d',strtotime("$date -".($w ? $w - $first : 6).' days')); //获取本周开始日期,如果$w是0,则表示周日,减去 6 天 $now_end=date('Y-m-d',strtotime("$now_start +6 days")); //本周结束日期 $last_start=date('Y-m-d',strtotime("$now_start - 7 days")); //上周开始日期 $last_end=date('Y-m-d',strtotime("$now_start - 1 days")); //上周结束日期 $data['weekStart']=$now_start; $data['weekEnd']=$now_end; $data['lastWeekStart']=$last_start; $data['lastWeekEnd']=$last_end; if($type==1){ $startTime=strtotime($now_start); $endTime=strtotime($now_end); }else{ $startTime=strtotime($last_start); $endTime=strtotime($last_end); } $rank=(new \yii\db\Query()) ->select('sum(a.money) money,b.userName,b.portrait,b.userTel') ->from('{{%ybwm_old_with_new_detailed}} as a') ->leftJoin('{{%ybwm_member}} b','a.userId=b.id') ->where('a.actId=:actId AND a.createdAt>=:startTime AND a.createdAt<=:endTime',[':actId'=>$actInfo['id'],':startTime'=>$startTime,':endTime'=>$endTime]) ->groupBy('a.userId') ->orderBy('a.money desc') ->all(); $data['rank']=$rank; return $this->result(1, '成功', $data); } public function actionInvitationList(){ $result=axios_request(); $state=$result['state']?:1; $now=time(); $uniacid=$this->wqData['uniacid']; $userId=$this->wqData['userId']; $actInfo=(new \yii\db\Query()) ->from('{{%ybwm_old_with_new}}') ->where('uniacid=:uniacid AND display=1 AND deleteAt=0 AND startTime<=:time AND endTime>:time',[':time'=>$now,':uniacid'=>$uniacid])->one();//查看活动 $actId=$actInfo['id']; $page=$result['page']?:1; $num=($page-1)*10; $limit=10; $table=(new \yii\db\Query()) ->select('b.userName,b.portrait,a.state,from_unixtime(a.createdAt) createdAt,a.bindId') ->from('{{%ybwm_old_with_new_bind}} as a') ->leftJoin('{{%ybwm_member}} b','a.bindId=b.id') ->where(['a.userId'=>$userId,'a.state'=>$state]); if($actId){ $table->andWhere('a.actId='.$actId); } $list=$table ->offset($num) ->limit($limit) ->orderBy('a.id desc') ->all(); return $this->result(1, '成功',$list); } }