Commit 5f11fdb3 authored by houdong's avatar houdong

邀请功能

parent 9c13ab9e
...@@ -466,16 +466,19 @@ class IndexAction extends IdentityAction { ...@@ -466,16 +466,19 @@ class IndexAction extends IdentityAction {
//钱包 //钱包
$userId=$ucData['user_id']; $userId=$ucData['user_id'];
$wallet=M('Wallet')->where(['user_id'=>$userId])->find(); // $wallet=M('Wallet')->where(['user_id'=>$userId])->find();
if(empty($wallet)){ // if(empty($wallet)){
M('Wallet')->add(['user_id'=>$userId,'user_name'=>$ucData['user_name'],'add_time'=>time(),'money'=>1.88]); // M('Wallet')->add(['user_id'=>$userId,'user_name'=>$ucData['user_name'],'add_time'=>time(),'money'=>1.88]);
}else{ // }else{
M('Wallet')->where(['user_id'=>$userId])->setInc('money',1.88); // M('Wallet')->where(['user_id'=>$userId])->setInc('money',1.88);
} // }
//
// $addData=['user_id'=>$userId,'user_name'=>$ucData['user_name'],'mobile'=>$mobile,
// 'item_money'=>1.88,'item_time'=>time(),'group_id'=>$groupId,'status'=>1,'note'=>'【全民分赛场】报名成功'];
// M('WalletItem')->add($addData);
$addData=['user_id'=>$userId,'user_name'=>$ucData['user_name'],'mobile'=>$mobile, D('User')->addMoney($userId,$ucData['user_name'],$ucData['mobile']);
'item_money'=>1.88,'item_time'=>time(),'group_id'=>$groupId,'status'=>1,'note'=>'【全民分赛场】报名成功']; D('User')->addInvite($userId,$ucData['user_name']);
M('WalletItem')->add($addData);
//用户未加入大赛或已加入,但不在cofool_allex_user表,需要添加 //用户未加入大赛或已加入,但不在cofool_allex_user表,需要添加
if($joinRes['status']==0||$joinRes['joinStatus']==1){ if($joinRes['status']==0||$joinRes['joinStatus']==1){
...@@ -558,33 +561,33 @@ class IndexAction extends IdentityAction { ...@@ -558,33 +561,33 @@ class IndexAction extends IdentityAction {
return false; return false;
} }
} }
public function formatTop10(){ // public function formatTop10(){
//月赛前10名用户的挑战情况 // //月赛前10名用户的挑战情况
$month=date('Y-m',strtotime(date('Y-m-01') . "-1 month")); // $month=date('Y-m',strtotime(date('Y-m-01') . "-1 month"));
$top10=M('PktopUserphb')->where(array('month'=>$month))->order('month desc,monthup desc')->limit(10)->select(); // $top10=M('PktopUserphb')->where(array('month'=>$month))->order('month desc,monthup desc')->limit(10)->select();
$top10UserId=array(); // $top10UserId=array();
foreach ($top10 as $k => &$v) { // foreach ($top10 as $k => &$v) {
$top10UserId[]=$v['user_id']; // $top10UserId[]=$v['user_id'];
$v['userUrl'] = tradeDetailLink($this->GID,3,$v['user_id']); // $v['userUrl'] = tradeDetailLink($this->GID,3,$v['user_id']);
} // }
//取被挑战者的挑战人员 // //取被挑战者的挑战人员
// $enemyNum=M('PkData')->where(array('pk_end_time'=>array('egt',date('Y-m-d'))))->group('passive_id')->getField('passive_id,count(*) num',true); //// $enemyNum=M('PkData')->where(array('pk_end_time'=>array('egt',date('Y-m-d'))))->group('passive_id')->getField('passive_id,count(*) num',true);
$enemy=M('PkData')->where(array('passive_id'=>array('in',$top10UserId)))->select(); // $enemy=M('PkData')->where(array('passive_id'=>array('in',$top10UserId)))->select();
$enemyId=array(); // $enemyId=array();
foreach ($enemy as $k => $v1) { // foreach ($enemy as $k => $v1) {
$enemyId[$v1['passive_id']][]=$v1['active_id']; // $enemyId[$v1['passive_id']][]=$v1['active_id'];
//
} // }
foreach ($top10 as $k => &$v2) { // foreach ($top10 as $k => &$v2) {
$v2['enemyNum']=count($enemyId[$v2['user_id']]); // $v2['enemyNum']=count($enemyId[$v2['user_id']]);
// $v['pkStatus']=in_array($v['user_id'],$myPkUserId)?1:0; //// $v['pkStatus']=in_array($v['user_id'],$myPkUserId)?1:0;
//敌人头像列表 // //敌人头像列表
$v2['enemy']=$enemyId[$v2['user_id']]; // $v2['enemy']=$enemyId[$v2['user_id']];
// $v['head_img'] = getPortraitPath($value['user_id'], 'small', true); //// $v['head_img'] = getPortraitPath($value['user_id'], 'small', true);
//
} // }
return $top10; // return $top10;
} // }
//我的挑战列表 //我的挑战列表
// public function myPkList(){ // public function myPkList(){
// $userId = I('userId', ''); // $userId = I('userId', '');
...@@ -681,7 +684,7 @@ class IndexAction extends IdentityAction { ...@@ -681,7 +684,7 @@ class IndexAction extends IdentityAction {
$lastMonth=date('Y-m',strtotime(date('Y-m-01') . "-1 month")); $lastMonth=date('Y-m',strtotime(date('Y-m-01') . "-1 month"));
$monthUsers=M('PktopUserphb')->where(array('month'=>$month))->order('monthup desc')->select(); $monthUsers=M('PktopUserphb')->where(array('month'=>$month))->order('monthup desc')->select();
$myPkUserId=$this->getMyPkUserId($userId); // $myPkUserId=$this->getMyPkUserId($userId);
$userIds=[]; $userIds=[];
foreach ($monthUsers as $key => $value) { foreach ($monthUsers as $key => $value) {
...@@ -767,74 +770,70 @@ class IndexAction extends IdentityAction { ...@@ -767,74 +770,70 @@ class IndexAction extends IdentityAction {
} }
//用户列表,包括最新挑战榜,人气挑战榜等页面 //用户列表,包括最新挑战榜,人气挑战榜等页面
public function userList(){ // public function userList(){
//
$userId=$this->user['userID']; // $userId=$this->user['userID'];
$type = I('type', 'new'); // $type = I('type', 'new');
$p=I('p',1); // $p=I('p',1);
$pageSize = 10; // $pageSize = 10;
$lastMonth=date('Y-m',strtotime(date('Y-m-01') . "-1 month")); // $lastMonth=date('Y-m',strtotime(date('Y-m-01') . "-1 month"));
$lastMonthInt=intval(date('m',strtotime(date('Y-m-01') . "-1 month"))); // $lastMonthInt=intval(date('m',strtotime(date('Y-m-01') . "-1 month")));
//
if($type=='new'){ // if($type=='new'){
$userList=$this->formatTop10(); // $userList=$this->formatTop10();
$count=10; // $count=10;
}
if($type=='hot'){
//所有月份的去掉where(array('month'=>$lastMonth))
$passiveIds=M('PkData')->group('passive_id')->order('count(*) desc')->getField('passive_id',true);
$where=array('user_id'=>array('in',$passiveIds));
$userList=M('PktopUserphb')->where($where)->order('field(user_id,'.implode(',',$passiveIds).')')->page($p.','.$pageSize)->select();
$count = M('PktopUserphb')->where($where)->count();
}
if($type=='all'){
$month = I('month',$lastMonth);
$where=array('month'=>$month);
$userList=M('PktopUserphb')->where($where)->order('monthup desc')->page($p.','.$pageSize)->select();
$selectMonth=array();
foreach ($this->MONTH as $k => $value) {
$nowMonth=date('Y-m',strtotime(date('Y-m-01')));
if($k<$nowMonth){
$selectMonth[$k]=$value;
}
}
// $type='lastMonth';
$count = M('PktopUserphb')->where($where)->count();
}
$myPkUserId=$this->getMyPkUserId($userId);
$userIds=array();
foreach ($userList as $k => &$v) {
$v['pkStatus']=in_array($v['user_id'],$myPkUserId)?1:0;
$v['userUrl'] = tradeDetailLink($this->GID,3,$v['user_id']);
$userIds[]=$v['user_id'];
}
// $enemyIds=$this->getEnemy($userIds);
// foreach ($userList as $k => &$v4) {
// $v4['enemyNum']=count($enemyIds[$v4['user_id']]);
// $v4['enemy']=$enemyIds[$v4['user_id']];
// } // }
// if($type=='hot'){
// //所有月份的去掉where(array('month'=>$lastMonth))
// var_dump($userList);exit; // $passiveIds=M('PkData')->group('passive_id')->order('count(*) desc')->getField('passive_id',true);
$pkTime=date('n月j日',strtotime('next Monday')).'-'.date('n月j日',strtotime('next Monday')+4*3600*24); // $where=array('user_id'=>array('in',$passiveIds));
$this->assign(array('type'=>$type,'userList'=>$userList,'selectMonth'=>$selectMonth,'lastMonthInt'=>$lastMonthInt //
,'pkTime'=>$pkTime)); // $userList=M('PktopUserphb')->where($where)->order('field(user_id,'.implode(',',$passiveIds).')')->page($p.','.$pageSize)->select();
// $count = M('PktopUserphb')->where($where)->count();
// }
if($count){ // if($type=='all'){
import("ORG.Util.Page"); // $month = I('month',$lastMonth);
$page = new Page($count,$pageSize,'','index/userList/type/'.$type.'/p'); // $where=array('month'=>$month);
$this->assign('_page', $page->show()); // $userList=M('PktopUserphb')->where($where)->order('monthup desc')->page($p.','.$pageSize)->select();
} // $selectMonth=array();
$this->setValue($userId); // foreach ($this->MONTH as $k => $value) {
$this->display(); // $nowMonth=date('Y-m',strtotime(date('Y-m-01')));
} // if($k<$nowMonth){
// $selectMonth[$k]=$value;
// }
// }
//// $type='lastMonth';
// $count = M('PktopUserphb')->where($where)->count();
// }
//
// $myPkUserId=$this->getMyPkUserId($userId);
// $userIds=array();
// foreach ($userList as $k => &$v) {
// $v['pkStatus']=in_array($v['user_id'],$myPkUserId)?1:0;
// $v['userUrl'] = tradeDetailLink($this->GID,3,$v['user_id']);
// $userIds[]=$v['user_id'];
// }
//// $enemyIds=$this->getEnemy($userIds);
//// foreach ($userList as $k => &$v4) {
//// $v4['enemyNum']=count($enemyIds[$v4['user_id']]);
//// $v4['enemy']=$enemyIds[$v4['user_id']];
//// }
//
//
//// var_dump($userList);exit;
// $pkTime=date('n月j日',strtotime('next Monday')).'-'.date('n月j日',strtotime('next Monday')+4*3600*24);
// $this->assign(array('type'=>$type,'userList'=>$userList,'selectMonth'=>$selectMonth,'lastMonthInt'=>$lastMonthInt
// ,'pkTime'=>$pkTime));
//
//
// if($count){
// import("ORG.Util.Page");
// $page = new Page($count,$pageSize,'','index/userList/type/'.$type.'/p');
// $this->assign('_page', $page->show());
// }
// $this->setValue($userId);
// $this->display();
// }
// private function formatPassUsers($data,$num=7) { // private function formatPassUsers($data,$num=7) {
// $result=array(); // $result=array();
...@@ -886,21 +885,21 @@ class IndexAction extends IdentityAction { ...@@ -886,21 +885,21 @@ class IndexAction extends IdentityAction {
// } // }
//我的未结束的挑战 //我的未结束的挑战
private function getMyPkUserId($userId){ // private function getMyPkUserId($userId){
$where=array('pk_end_time'=>array('egt',date('Y-m-d')), // $where=array('pk_end_time'=>array('egt',date('Y-m-d')),
'_complex'=>array('active_id'=>$userId,'passive_id'=>$userId,'_logic'=>'or')); // '_complex'=>array('active_id'=>$userId,'passive_id'=>$userId,'_logic'=>'or'));
//
$myPks=M('PkData')->where($where)->order('add_time desc')->select(); // $myPks=M('PkData')->where($where)->order('add_time desc')->select();
//
$myPkUserId=array(); // $myPkUserId=array();
foreach ($myPks as $k => $value) { // foreach ($myPks as $k => $value) {
//取我主动挑战的人 // //取我主动挑战的人
if($value['active_id']==$userId){ // if($value['active_id']==$userId){
$myPkUserId[]=$value['passive_id']; // $myPkUserId[]=$value['passive_id'];
} // }
} // }
return $myPkUserId; // return $myPkUserId;
} // }
public function check_user_login_redirect() { public function check_user_login_redirect() {
......
...@@ -51,330 +51,328 @@ class PkTopAction extends IdentityAction{ ...@@ -51,330 +51,328 @@ class PkTopAction extends IdentityAction{
} }
//首页 //首页
public function indexOld() { // public function indexOld() {
//首页的排行榜等切换 // //首页的排行榜等切换
if(!I('viewPage')){ // if(!I('viewPage')){
header('location:'.M_URL.'/Match/jiang'); // header('location:'.M_URL.'/Match/jiang');
exit; // exit;
//
} // }
//
$userIdParam = I('user_id', '', intval); // $userIdParam = I('user_id', '', intval);
$isapp = I('isapp'); // $isapp = I('isapp');
if ($isapp) { // if ($isapp) {
$userId = substr($isapp, strpos($isapp, '=') + 1); // $userId = substr($isapp, strpos($isapp, '=') + 1);
if ($userId) { // if ($userId) {
$userIdParam = $userId; // $userIdParam = $userId;
}
}
$key = I('key', '');
$key2 = I('key2', '');
if ($userIdParam == '') {
if ($this->user['userID'] == '') {
//有了第二次请求,不再请求第三次
if ($key2 == '') {
$this->assign('refresh', 1);
$this->assign('viewPage', I('viewPage', '1'));
}
} else {
$userId = $this->user['userID'];
}
} else {
//第二次请求
if (md5($userIdParam . 'abcd4321') == $key2 || md5('user_id=' . $userIdParam .'abcd4321') == $key) {
$userId = $userIdParam;
}
}
//echo $userId;exit;
//app从过来可能没有userName
if ($userId && $this->user['userName'] == '') {
$this->setUcLogin($userId);
}
// $gid = I('gid', 0, intval);
// $gid = $gid ? $gid : $this->GID;
$gid = $this->GID;
$groupId = I('groupId', $gid);
// var_dump($groupId);exit;
$groupInfo = M('Group')->field('group_id,web_id,category,name,startTime,endTime,member_quantity')->where(['group_id' => $groupId])->find();
$groupStatus = $this->getGroupStatus($groupInfo);
$member_quantity = $groupInfo['member_quantity'];
//用到
$ids = D('Group')->getGroupCache($userId);
if (in_array($groupId, $ids)) {
$this->assign('joinStatus', 1);
}
//滚动消息,1pk付款,2发起pk,3pk胜利,4pk失败,5胜利退钱,6失败钱归passive,7买重置卡
$msg1 = M('PktopNews')->where(['type' => ['in', '2']])->order('add_time desc')->limit(5)->select();
$msg2 = M('PktopNews')->where(['type' => ['in', '3']])->order('add_time desc')->limit(5)->select();
$msg = empty($msg2) ? $msg1 : array_merge($msg2, $msg1);
//pk通关榜,1挑战者胜利,2被挑战者胜利
$allPassUsers = M('PktopData')->field('distinct active_id,active_name')->where(['pk_status' => 1])->order('add_time desc')->select();
$passUsers = $this->formatPassUsers($allPassUsers);
//我的未结束的挑战
$where = ['pk_end_time' => ['egt', date('Y-m-d')], '_complex' => ['active_id' => $userId, 'passive_id' => $userId, '_logic' => 'or']];
$myPks = M('PktopData')->where($where)->order('add_time desc')->select();
if (!empty($myPks)) {
$myPk = $myPks[0];
$myPk['pk_begin_time'] = date('m月d日', strtotime($myPk['pk_begin_time']));
$myPk['pk_end_time'] = date('m月d日', strtotime($myPk['pk_end_time']));
}
$myPkUserId = [];
foreach ($myPks as $k => $value) {
//取我主动挑战的人
if ($value['active_id'] == $userId) {
$myPkUserId[] = $value['passive_id'];
}
}
//最新挑战榜,每个月top10,不需要了
// $top10=$this->formatTop10();
// foreach ($top10 as $k => &$v) {
// $v['pkStatus']=in_array($v['user_id'],$myPkUserId)?1:0;
// } // }
//我的所有的挑战数,不需要了
// $myAllPkCount=M('PktopData')->where(array('active_id'=>$userId,'passive_id'=>$userId,'_logic'=>'or'))->count();
$lastMonth = date('Y-m', strtotime(date('Y-m-01') . "-1 month"));
$lastMonthInt = intval(date('m', strtotime(date('Y-m-01') . "-1 month")));
$mingrentang = $this->getMingrentangData($myPkUserId);
$rankNow = $this->rankNow('local');
//弹窗里面的pk时间段
$pkTime = date('n月j日', strtotime('next Monday')) . '-' . date('n月j日', strtotime('next Monday') + 4 * 3600 * 24);
$gonggao = $this->getGonggao();
//获奖心得
$where = ['think' => ['exp', 'is not null and think != ""']];
$thinks = M('PktopUserphb')->where($where)->order('month desc')->limit(10)->select();
//刷新页面后获取弹出的消息
//没有pk,不需要弹窗了
// $popData = $this->getPopData($userId);
$popData=null;
//第一个页面显示的数据,公告,心得等
$firstPageData = ['popType' => $popData['popType'], 'popPkUserName' => $popData['popPkUserName'], 'thinks' => $thinks, 'gonggao' => $gonggao];
$return = ['msg' => $msg, 'myPk' => $myPk, 'myPkCount' => count($myPks), 'passUsers' => $passUsers,
'passUserCount' => count($allPassUsers) + 5, 'top10' => $top10, 'pkTime' => $pkTime,
'lastMonthInt' => $lastMonthInt, 'myAllPkCount' => $myAllPkCount];
$this->assign($firstPageData);
$this->assign($mingrentang);
$this->assign($rankNow);
$this->assign($return);
//总决赛列表
$_GET['order'] = 'zongup';
$finalList = $this->rankNow('local', $this->GID);
// var_dump(DB_USER);exit;
$this->assign('finalList', $finalList['finalList']);
// $share=array('groupId'=>$groupId,'groupStatus'=>$groupStatus,'viewPage'=>2,
// 'close_tips'=>'','userID'=>'XXXXXX','zhuangtai'=>$this->STATUS_TXT[$groupStatus]);
$share = array('groupId' => $groupId, 'groupStatus' => $groupStatus, 'viewPage' => 2, 'statusInt' => $groupStatus,
'close_tips' => '', 'userID' => $userId, 'zhuangtai' => $this->STATUS_TXT[$groupStatus]);
$groupInfo = array_merge($groupInfo, $share);
$this->assign('groupInfo', json_encode($groupInfo));
$this->setShare($userId, I('cfrom'));
//朋友圈,微信群,好友分享,分享后自己的id,作为邀请人的id,pc扫码后没有from参数
$inviterId = I('inviterId', '');
if (in_array(I('from'), array('timeline', 'groupmessage', 'singlemessage'))) {
if ($inviterId == '') {
$inviterId = I('user_id', '', intval);
if ($inviterId == '') {
$isapp = I('isapp', '');
$inviterId = substr($isapp, strpos($isapp, '=') + 1);
}
}
}
$this->assign('inviterId', $inviterId);
//记录页面访问来源,cfrom可能是cofoolwx
// if(I('cfrom')){
// $referer=I('cfrom');
// }else{
// $referer=$_SERVER['HTTP_REFERER']?$_SERVER['HTTP_REFERER']:I('from','');
// } // }
if (I('cfrom')) { // $key = I('key', '');
$referer = I('cfrom'); // $key2 = I('key2', '');
} elseif (I('hFrom')) { //
$referer = I('hFrom'); // if ($userIdParam == '') {
} elseif (I('from')) { // if ($this->user['userID'] == '') {
$referer = I('from'); // //有了第二次请求,不再请求第三次
} else { // if ($key2 == '') {
$referer = $_SERVER['HTTP_REFERER']; // $this->assign('refresh', 1);
} // $this->assign('viewPage', I('viewPage', '1'));
//获奖人员 // }
$luckydogs = M('PktopLuckydog')->where($where)->order('add_time desc')->limit(10)->select(); // } else {
$this->assign('luckydogs', $luckydogs); // $userId = $this->user['userID'];
//这个月剩余的抽奖机会 // }
$leftCjNum = A('Public')->getLeftCjNum(); // } else {
$this->assign('leftCjNum', $leftCjNum); // //第二次请求
//大赛状态 // if (md5($userIdParam . 'abcd4321') == $key2 || md5('user_id=' . $userIdParam .'abcd4321') == $key) {
$gInfo['gStatus'] = is_end($groupInfo['endTime']) ? '3' : ($groupInfo['startTime'] > time() ? '1' : '2'); // $userId = $userIdParam;
$this->assign('gInfo', $gInfo); // }
// }
$this->assign('referer', $referer); ////echo $userId;exit;
$this->assign('member_quantity', $member_quantity); // //app从过来可能没有userName
$this->assign('p', 1); // if ($userId && $this->user['userName'] == '') {
//取微信 // $this->setUcLogin($userId);
$weixin = M('GroupInfo')->where(['group_id' => $groupId])->getField('wechat'); // }
$this->assign('weixin', $weixin); //
$this->assign('weixinUrl', 'https://eturl.cn/Rhq2wA?is_head=1'); //
//// $gid = I('gid', 0, intval);
//// $gid = $gid ? $gid : $this->GID;
$ua = strtolower($_SERVER['HTTP_USER_AGENT']); //
$hideShiPan=0; // $gid = $this->GID;
// $tj=strpos($ua, 'oppo')||strpos($ua, 'huawei_jt')||strpos($ua, 'xiaomi'); // $groupId = I('groupId', $gid);
$tj=strpos($ua, 'vivo'); //
if($tj){ //
$hideShiPan=1; //// var_dump($groupId);exit;
} //
if(I('channel')=='tencent_new_simplify'&&I('version')<'A3.7.9R'){ // $groupInfo = M('Group')->field('group_id,web_id,category,name,startTime,endTime,member_quantity')->where(['group_id' => $groupId])->find();
$hideShiPan=1; // $groupStatus = $this->getGroupStatus($groupInfo);
} // $member_quantity = $groupInfo['member_quantity'];
$this->assign('hideShiPan',$hideShiPan); // //用到
// $ids = D('Group')->getGroupCache($userId);
//更多大赛 // if (in_array($groupId, $ids)) {
$gList=D('Niu')->getMoreDs($userId); // $this->assign('joinStatus', 1);
$this->assign('gList',$gList); // }
$this->assign('gid',$gid); //
$this->display(); // //滚动消息,1pk付款,2发起pk,3pk胜利,4pk失败,5胜利退钱,6失败钱归passive,7买重置卡
} // $msg1 = M('PktopNews')->where(['type' => ['in', '2']])->order('add_time desc')->limit(5)->select();
// $msg2 = M('PktopNews')->where(['type' => ['in', '3']])->order('add_time desc')->limit(5)->select();
// $msg = empty($msg2) ? $msg1 : array_merge($msg2, $msg1);
//
// //pk通关榜,1挑战者胜利,2被挑战者胜利
// $allPassUsers = M('PktopData')->field('distinct active_id,active_name')->where(['pk_status' => 1])->order('add_time desc')->select();
//
// $passUsers = $this->formatPassUsers($allPassUsers);
// //我的未结束的挑战
// $where = ['pk_end_time' => ['egt', date('Y-m-d')], '_complex' => ['active_id' => $userId, 'passive_id' => $userId, '_logic' => 'or']];
//
// $myPks = M('PktopData')->where($where)->order('add_time desc')->select();
// if (!empty($myPks)) {
// $myPk = $myPks[0];
// $myPk['pk_begin_time'] = date('m月d日', strtotime($myPk['pk_begin_time']));
// $myPk['pk_end_time'] = date('m月d日', strtotime($myPk['pk_end_time']));
// }
// $myPkUserId = [];
// foreach ($myPks as $k => $value) {
// //取我主动挑战的人
// if ($value['active_id'] == $userId) {
// $myPkUserId[] = $value['passive_id'];
// }
// }
//
// //最新挑战榜,每个月top10,不需要了
//// $top10=$this->formatTop10();
//// foreach ($top10 as $k => &$v) {
//// $v['pkStatus']=in_array($v['user_id'],$myPkUserId)?1:0;
//// }
// //我的所有的挑战数,不需要了
//// $myAllPkCount=M('PktopData')->where(array('active_id'=>$userId,'passive_id'=>$userId,'_logic'=>'or'))->count();
//
// $lastMonth = date('Y-m', strtotime(date('Y-m-01') . "-1 month"));
// $lastMonthInt = intval(date('m', strtotime(date('Y-m-01') . "-1 month")));
//
// $mingrentang = $this->getMingrentangData($myPkUserId);
// $rankNow = $this->rankNow('local');
//
// //弹窗里面的pk时间段
// $pkTime = date('n月j日', strtotime('next Monday')) . '-' . date('n月j日', strtotime('next Monday') + 4 * 3600 * 24);
//
// $gonggao = $this->getGonggao();
//
// //获奖心得
// $where = ['think' => ['exp', 'is not null and think != ""']];
// $thinks = M('PktopUserphb')->where($where)->order('month desc')->limit(10)->select();
//
// //刷新页面后获取弹出的消息
// //没有pk,不需要弹窗了
//// $popData = $this->getPopData($userId);
// $popData=null;
// //第一个页面显示的数据,公告,心得等
// $firstPageData = ['popType' => $popData['popType'], 'popPkUserName' => $popData['popPkUserName'], 'thinks' => $thinks, 'gonggao' => $gonggao];
//
// $return = ['msg' => $msg, 'myPk' => $myPk, 'myPkCount' => count($myPks), 'passUsers' => $passUsers,
// 'passUserCount' => count($allPassUsers) + 5, 'top10' => $top10, 'pkTime' => $pkTime,
// 'lastMonthInt' => $lastMonthInt, 'myAllPkCount' => $myAllPkCount];
//
// $this->assign($firstPageData);
// $this->assign($mingrentang);
// $this->assign($rankNow);
// $this->assign($return);
//
// //总决赛列表
// $_GET['order'] = 'zongup';
// $finalList = $this->rankNow('local', $this->GID);
//// var_dump(DB_USER);exit;
// $this->assign('finalList', $finalList['finalList']);
//
//// $share=array('groupId'=>$groupId,'groupStatus'=>$groupStatus,'viewPage'=>2,
//// 'close_tips'=>'','userID'=>'XXXXXX','zhuangtai'=>$this->STATUS_TXT[$groupStatus]);
// $share = array('groupId' => $groupId, 'groupStatus' => $groupStatus, 'viewPage' => 2, 'statusInt' => $groupStatus,
// 'close_tips' => '', 'userID' => $userId, 'zhuangtai' => $this->STATUS_TXT[$groupStatus]);
//
// $groupInfo = array_merge($groupInfo, $share);
//
// $this->assign('groupInfo', json_encode($groupInfo));
//
// $this->setShare($userId, I('cfrom'));
//
// //朋友圈,微信群,好友分享,分享后自己的id,作为邀请人的id,pc扫码后没有from参数
// $inviterId = I('inviterId', '');
// if (in_array(I('from'), array('timeline', 'groupmessage', 'singlemessage'))) {
// if ($inviterId == '') {
// $inviterId = I('user_id', '', intval);
// if ($inviterId == '') {
// $isapp = I('isapp', '');
// $inviterId = substr($isapp, strpos($isapp, '=') + 1);
// }
// }
// }
// $this->assign('inviterId', $inviterId);
//
// //记录页面访问来源,cfrom可能是cofoolwx
//// if(I('cfrom')){
//// $referer=I('cfrom');
//// }else{
//// $referer=$_SERVER['HTTP_REFERER']?$_SERVER['HTTP_REFERER']:I('from','');
//// }
// if (I('cfrom')) {
// $referer = I('cfrom');
// } elseif (I('hFrom')) {
// $referer = I('hFrom');
// } elseif (I('from')) {
// $referer = I('from');
// } else {
// $referer = $_SERVER['HTTP_REFERER'];
// }
// //获奖人员
// $luckydogs = M('PktopLuckydog')->where($where)->order('add_time desc')->limit(10)->select();
// $this->assign('luckydogs', $luckydogs);
// //这个月剩余的抽奖机会
// $leftCjNum = A('Public')->getLeftCjNum();
// $this->assign('leftCjNum', $leftCjNum);
// //大赛状态
// $gInfo['gStatus'] = is_end($groupInfo['endTime']) ? '3' : ($groupInfo['startTime'] > time() ? '1' : '2');
// $this->assign('gInfo', $gInfo);
//
// $this->assign('referer', $referer);
// $this->assign('member_quantity', $member_quantity);
// $this->assign('p', 1);
// //取微信
// $weixin = M('GroupInfo')->where(['group_id' => $groupId])->getField('wechat');
// $this->assign('weixin', $weixin);
// $this->assign('weixinUrl', 'https://eturl.cn/Rhq2wA?is_head=1');
//
//
// $ua = strtolower($_SERVER['HTTP_USER_AGENT']);
// $hideShiPan=0;
//// $tj=strpos($ua, 'oppo')||strpos($ua, 'huawei_jt')||strpos($ua, 'xiaomi');
// $tj=strpos($ua, 'vivo');
// if($tj){
// $hideShiPan=1;
// }
// if(I('channel')=='tencent_new_simplify'&&I('version')<'A3.7.9R'){
// $hideShiPan=1;
// }
// $this->assign('hideShiPan',$hideShiPan);
//
// //更多大赛
// $gList=D('Niu')->getMoreDs($userId);
// $this->assign('gList',$gList);
// $this->assign('gid',$gid);
// $this->display();
// }
//大赛排行榜的当前排行页面 //大赛排行榜的当前排行页面
public function rankNow($caller='',$gid=0){ // public function rankNow($caller='',$gid=0){
$gid=$gid?$gid:$this->GID; // $gid=$gid?$gid:$this->GID;
$order=I('order','lastmonthup'); // $order=I('order','lastmonthup');
$p=I('p', 1); // $p=I('p', 1);
// $pageSize=10; //// $pageSize=10;
$pageSize=$gid==$this->GID?10:200; // $pageSize=$gid==$this->GID?10:200;
//分表归档 // //分表归档
$suffix = D('Userinfo')->getTable($gid); // $suffix = D('Userinfo')->getTable($gid);
$table =$suffix?'mncg_archive.userinfo'.$suffix:'mncg.userinfo'; // $table =$suffix?'mncg_archive.userinfo'.$suffix:'mncg.userinfo';
$where=array('sex'=>$gid,'new_phb'=>array('gt',0),'zt'=>1); // $where=array('sex'=>$gid,'new_phb'=>array('gt',0),'zt'=>1);
//测试时不用缓存->cache(true,cacheTime()) // //测试时不用缓存->cache(true,cacheTime())
$userNowList = M($table, " ", C('DB_CONFIG_MNCG3'))->where($where)->order($order.' desc')->page($p.','.$pageSize)->select(); // $userNowList = M($table, " ", C('DB_CONFIG_MNCG3'))->where($where)->order($order.' desc')->page($p.','.$pageSize)->select();
// var_dump($gid);exit; //// var_dump($gid);exit;
$userids = array(); // $userids = array();
$usertranids = []; // $usertranids = [];
foreach ($userNowList as $key => &$rankV) { // foreach ($userNowList as $key => &$rankV) {
$userIDs = explode("X", $rankV['uid']); // $userIDs = explode("X", $rankV['uid']);
$rankV['user_id'] = $userIDs[1]; // $rankV['user_id'] = $userIDs[1];
// $rankV['userUrl'] = tradeDetailLink($this->GID,3,$userIDs[1]); //// $rankV['userUrl'] = tradeDetailLink($this->GID,3,$userIDs[1]);
$userids[] = $userIDs[1]; // $userids[] = $userIDs[1];
$usertranids[] = $rankV['uid']; // $usertranids[] = $rankV['uid'];
} // }
//
$nick_name_arry =getUser($userids,'nick');//// // $nick_name_arry =getUser($userids,'nick');////
$robot_user = []; // $robot_user = [];
if(!empty($usertranids)){ // if(!empty($usertranids)){
$robot_user = D('Robot')->groupRobotTranUserList($usertranids); // $robot_user = D('Robot')->groupRobotTranUserList($usertranids);
} // }
foreach ($userNowList as $key => &$value) { // foreach ($userNowList as $key => &$value) {
$nick_name = $nick_name_arry[$value['user_id']]; // $nick_name = $nick_name_arry[$value['user_id']];
//$value['user_name'] = $nick_name?$nick_name:$value['username']; // //$value['user_name'] = $nick_name?$nick_name:$value['username'];
$value['user_name'] = $nick_name; // $value['user_name'] = $nick_name;
//
$robot_flag_show = D('Robot')->robot_flag_show($value['user_id']); // $robot_flag_show = D('Robot')->robot_flag_show($value['user_id']);
$value['robot_user'] = in_array($value['user_id'],$robot_user) && $robot_flag_show == 1 ? 1 : 0; // $value['robot_user'] = in_array($value['user_id'],$robot_user) && $robot_flag_show == 1 ? 1 : 0;
$value['robot_url'] = in_array($value['user_id'],$robot_user) && $robot_flag_show == 1 ? M_URL.'/Robot' : ''; // $value['robot_url'] = in_array($value['user_id'],$robot_user) && $robot_flag_show == 1 ? M_URL.'/Robot' : '';
//
} // }
//总数目 // //总数目
$totalCount = M($table, " ", C('DB_CONFIG_MNCG3'))->where($where)->count(); // $totalCount = M($table, " ", C('DB_CONFIG_MNCG3'))->where($where)->count();
if($caller=='local'){ // if($caller=='local'){
if($gid==$this->GID){ // if($gid==$this->GID){
$return['userList']=$userNowList; // $return['userList']=$userNowList;
$return['order']=$order; // $return['order']=$order;
$return['totalCount']=$totalCount;
$return['pages']=ceil($totalCount/$pageSize);
}else{
$return['finalList']=$userNowList;
$return['order']=$order;
// $return['totalCount']=$totalCount; // $return['totalCount']=$totalCount;
// $return['pages']=$totalCount/10; // $return['pages']=ceil($totalCount/$pageSize);
} // }else{
// $return['finalList']=$userNowList;
return $return; // $return['order']=$order;
}else{ //// $return['totalCount']=$totalCount;
$this->assign(array('order'=>$order,'userList'=>$userNowList,'p'=>$p)); //// $return['pages']=$totalCount/10;
if($gid==$this->GID){ // }
$content = $this->fetch('itemNow'); //
}else{ // return $return;
$content = $this->fetch('finalList'); // }else{
} // $this->assign(array('order'=>$order,'userList'=>$userNowList,'p'=>$p));
$content = $this->fetch('itemNow'); // if($gid==$this->GID){
$this->ajaxReturn(array( // $content = $this->fetch('itemNow');
'status' => 1,'count' =>$totalCount,'data' => $content )); // }else{
} // $content = $this->fetch('finalList');
// }
// $content = $this->fetch('itemNow');
} // $this->ajaxReturn(array(
// 'status' => 1,'count' =>$totalCount,'data' => $content ));
public function getMingrentangData($myPkUserId){ // }
$lastMonth=date('Y-m',strtotime(date('Y-m-01') . "-1 month")); // }
//名人堂的月份下拉框
$selectMonth1=$selectMonth2=array(); // public function getMingrentangData($myPkUserId){
foreach ($this->MONTH as $k => $value) { // $lastMonth=date('Y-m',strtotime(date('Y-m-01') . "-1 month"));
$nowMonth=date('Y-m',strtotime(date('Y-m-01'))); // //名人堂的月份下拉框
// $selectMonth1=$selectMonth2=array();
// if($k<$nowMonth){ // foreach ($this->MONTH as $k => $value) {
$selectMonth1[$k]=$selectMonth2[$k]=$value; // $nowMonth=date('Y-m',strtotime(date('Y-m-01')));
// } //
//// if($k<$nowMonth){
//月排行榜显示当前的月份 // $selectMonth1[$k]=$selectMonth2[$k]=$value;
// if($k==$nowMonth){ //// }
// $selectMonth2[$k]=$value; //
// } // //月排行榜显示当前的月份
} //// if($k==$nowMonth){
$mingrentang=array('selectMonth1'=>$selectMonth1,'selectMonth2'=>$selectMonth2, //// $selectMonth2[$k]=$value;
'selectMonthStart1'=>current($selectMonth1),'selectMonthStart2'=>current($selectMonth2)); //// }
// }
$nowTop10UserIds=array(); // $mingrentang=array('selectMonth1'=>$selectMonth1,'selectMonth2'=>$selectMonth2,
//名人堂的月排行榜,默认显示当前月的前10名 // 'selectMonthStart1'=>current($selectMonth1),'selectMonthStart2'=>current($selectMonth2));
$monthUsers=M('PktopUserphb')->where(array('month'=>date('Y-m')))->order('monthup desc')->select(); //
foreach ($monthUsers as $k => &$v4) { // $nowTop10UserIds=array();
$v4['pkStatus']=in_array($v4['user_id'],$myPkUserId)?1:0; // //名人堂的月排行榜,默认显示当前月的前10名
$nowTop10UserIds[]=$v4['user_id']; // $monthUsers=M('PktopUserphb')->where(array('month'=>date('Y-m')))->order('monthup desc')->select();
} // foreach ($monthUsers as $k => &$v4) {
$enemyIds=$this->getEnemy($nowTop10UserIds); // $v4['pkStatus']=in_array($v4['user_id'],$myPkUserId)?1:0;
// $nowTop10UserIds[]=$v4['user_id'];
$zongupData=$this->getZongup(); // }
foreach ($monthUsers as $k => &$v4) { // $enemyIds=$this->getEnemy($nowTop10UserIds);
$v4['enemyNum']=count($enemyIds[$v4['user_id']]); //
$v4['enemy']=$enemyIds[$v4['user_id']]; // $zongupData=$this->getZongup();
$v4['zongup']=$zongupData[$v4['user_id']]; // foreach ($monthUsers as $k => &$v4) {
} // $v4['enemyNum']=count($enemyIds[$v4['user_id']]);
// $v4['enemy']=$enemyIds[$v4['user_id']];
//名人堂数据的决赛名单,只包括pk胜利者,现在用不到 // $v4['zongup']=$zongupData[$v4['user_id']];
// $finalUsers=M('PktopUser')->where(array('month'=>$lastMonth,'active_money'=>array('gt',0)))->order('monthup desc')->select(); // }
// $mingrentang['finalUsers']=$finalUsers; //
// //名人堂数据的决赛名单,只包括pk胜利者,现在用不到
$mingrentang['userList']=$monthUsers; //// $finalUsers=M('PktopUser')->where(array('month'=>$lastMonth,'active_money'=>array('gt',0)))->order('monthup desc')->select();
$mingrentang['type']='nowMonth'; //// $mingrentang['finalUsers']=$finalUsers;
return $mingrentang; //
} // $mingrentang['userList']=$monthUsers;
// $mingrentang['type']='nowMonth';
// return $mingrentang;
// }
//加入炼股赛 //加入炼股赛
public function join(){ public function join(){
...@@ -394,9 +392,6 @@ class PkTopAction extends IdentityAction{ ...@@ -394,9 +392,6 @@ class PkTopAction extends IdentityAction{
if (!$smsCode) { if (!$smsCode) {
$this->ajaxReturn(['status' => 0, 'info' => '请输入手机验证码!']); $this->ajaxReturn(['status' => 0, 'info' => '请输入手机验证码!']);
} }
// if (S('tel:'. $mobile . ':'.$code_type) != $smsCode) {
// $this->ajaxReturn(array('status' => 0, 'info' => '对不起!手机验证码错误或已过期!'));
// }
$param = ['mobile'=>$mobile,'code'=>$smsCode,'type'=>$code_type]; $param = ['mobile'=>$mobile,'code'=>$smsCode,'type'=>$code_type];
if(D('Sms')->checkCode($param)){ if(D('Sms')->checkCode($param)){
...@@ -474,38 +469,34 @@ class PkTopAction extends IdentityAction{ ...@@ -474,38 +469,34 @@ class PkTopAction extends IdentityAction{
//月赛前10名用户的挑战情况 //月赛前10名用户的挑战情况
private function formatTop10(){ // private function formatTop10(){
$month=date('Y-m',strtotime(date('Y-m-01') . "-1 month")); // $month=date('Y-m',strtotime(date('Y-m-01') . "-1 month"));
$top10=M('PktopUserphb')->where(array('month'=>$month))->order('month desc,monthup desc')->limit(10)->select(); // $top10=M('PktopUserphb')->where(array('month'=>$month))->order('month desc,monthup desc')->limit(10)->select();
$top10UserIds=array(); // $top10UserIds=array();
foreach ($top10 as $k => $v) { // foreach ($top10 as $k => $v) {
$top10UserIds[]=$v['user_id']; // $top10UserIds[]=$v['user_id'];
} // }
//
// $enemyIds=$this->getEnemy($top10UserIds);
// foreach ($top10 as $k => &$v) {
// $v['enemyNum']=count($enemyIds[$v['user_id']]);
//// $v['pkStatus']=in_array($v['user_id'],$myPkUserId)?1:0;
$enemyIds=$this->getEnemy($top10UserIds); // //敌人头像列表
foreach ($top10 as $k => &$v) { // $v['enemy']=$enemyIds[$v['user_id']];
$v['enemyNum']=count($enemyIds[$v['user_id']]); // }
// $v['pkStatus']=in_array($v['user_id'],$myPkUserId)?1:0; //// var_dump($top10);exit;
//敌人头像列表 // return $top10;
$v['enemy']=$enemyIds[$v['user_id']]; // }
}
// var_dump($top10);exit;
return $top10;
}
public function getEnemy($passiveIds) { // public function getEnemy($passiveIds) {
//取被挑战者的挑战人员array('pk_end_time'=>array('egt',date('Y-m-d')),'passive_id'=>array('in',$passiveIds)) // //取被挑战者的挑战人员array('pk_end_time'=>array('egt',date('Y-m-d')),'passive_id'=>array('in',$passiveIds))
$enemy=M('PktopData')->where(array('passive_id'=>array('in',$passiveIds)))->select(); // $enemy=M('PktopData')->where(array('passive_id'=>array('in',$passiveIds)))->select();
$enemyIds=array(); // $enemyIds=array();
foreach ($enemy as $k => $v) { // foreach ($enemy as $k => $v) {
$enemyIds[$v['passive_id']][]=$v['active_id']; // $enemyIds[$v['passive_id']][]=$v['active_id'];
} // }
return $enemyIds; // return $enemyIds;
} // }
public function sendMessage() { public function sendMessage() {
$mobile = I('mobile'); $mobile = I('mobile');
...@@ -632,15 +623,18 @@ class PkTopAction extends IdentityAction{ ...@@ -632,15 +623,18 @@ class PkTopAction extends IdentityAction{
D('Sms')->send(['mobile'=>$mobile,'content' =>$bmContent,'type'=>46],true,true); D('Sms')->send(['mobile'=>$mobile,'content' =>$bmContent,'type'=>46],true,true);
//钱包 //钱包
$wallet=M('Wallet')->where(['user_id'=>$userId])->find(); // $wallet=M('Wallet')->where(['user_id'=>$userId])->find();
if(empty($wallet)){ // if(empty($wallet)){
M('Wallet')->add(['user_id'=>$userId,'user_name'=>$userName,'add_time'=>time(),'money'=>1.88]); // M('Wallet')->add(['user_id'=>$userId,'user_name'=>$userName,'add_time'=>time(),'money'=>1.88]);
}else{ // }else{
M('Wallet')->where(['user_id'=>$userId])->setInc('money',1.88); // M('Wallet')->where(['user_id'=>$userId])->setInc('money',1.88);
} // }
$addData=['user_id'=>$userId,'user_name'=>$userName,'mobile'=>$mobile, // $addData=['user_id'=>$userId,'user_name'=>$userName,'mobile'=>$mobile,
'item_money'=>1.88,'item_time'=>time(),'group_id'=>$groupId,'status'=>1,'note'=>'【全民分赛场】报名成功']; // 'item_money'=>1.88,'item_time'=>time(),'group_id'=>$groupId,'status'=>1,'note'=>'【全民分赛场】报名成功'];
M('WalletItem')->add($addData); // M('WalletItem')->add($addData);
D('User')->addMoney($userId,$userName,$mobile);
D('User')->addInvite($userId,$userName);
return ['status'=>1,'info'=>'参赛成功','debug'=>$userId]; return ['status'=>1,'info'=>'参赛成功','debug'=>$userId];
...@@ -649,48 +643,48 @@ class PkTopAction extends IdentityAction{ ...@@ -649,48 +643,48 @@ class PkTopAction extends IdentityAction{
//我的邀请列表 //我的邀请列表
public function myInvite(){ // public function myInvite(){
$userId = $this->user['userID']; // $userId = $this->user['userID'];
$cfrom=I('cfrom', ''); // $cfrom=I('cfrom', '');
$key=I('key', ''); // $key=I('key', '');
if($cfrom=='pcInvitation'){ // if($cfrom=='pcInvitation'){
$userIdParam=I('user_id', '',intval); // $userIdParam=I('user_id', '',intval);
// echo md5('user_id='.$userIdParam.'abcd4321');exit; //// echo md5('user_id='.$userIdParam.'abcd4321');exit;
if(md5('user_id='.$userIdParam.C('login_user_id_salt'))==$key){ // if(md5('user_id='.$userIdParam.C('login_user_id_salt'))==$key){
$this->setUcLogin($userIdParam); // $this->setUcLogin($userIdParam);
$userId=$userIdParam; // $userId=$userIdParam;
}else{ // }else{
//校验不对 // //校验不对
$userId=-1; // $userId=-1;
} // }
} // }
// $userId=4825940; //// $userId=4825940;
$guests=M('PktopUser')->where(array('inviter_id'=>$userId))->getField('user_id,user_id,user_name',true); // $guests=M('PktopUser')->where(array('inviter_id'=>$userId))->getField('user_id,user_id,user_name',true);
$mncgData = M("userinfo", " ", C('DB_CONFIG_MNCG3'))->field('uid,lastmonthup')->where(array('sex'=>$this->GID,'new_phb'=>array('gt',0))) // $mncgData = M("userinfo", " ", C('DB_CONFIG_MNCG3'))->field('uid,lastmonthup')->where(array('sex'=>$this->GID,'new_phb'=>array('gt',0)))
->order('lastmonthup desc,regdate asc')->cache(true,300)->select(); // ->order('lastmonthup desc,regdate asc')->cache(true,300)->select();
foreach ($mncgData as $k => $value) { // foreach ($mncgData as $k => $value) {
$guestId=str_replace($this->GID.'X','',$value['uid']); // $guestId=str_replace($this->GID.'X','',$value['uid']);
//有交易数据 // //有交易数据
if(!empty($guests[$guestId])){ // if(!empty($guests[$guestId])){
$guests[$guestId]['order']=$k+1; // $guests[$guestId]['order']=$k+1;
$guests[$guestId]['lastmonthup']=$value['lastmonthup']; // $guests[$guestId]['lastmonthup']=$value['lastmonthup'];
} // }
} // }
//var_dump($mncgData);exit; ////var_dump($mncgData);exit;
$shareInfo=$this->setShare($userId,$cfrom); // $shareInfo=$this->setShare($userId,$cfrom);
//
$return=array('guests'=>$guests,'guestNum'=>count($guests)); // $return=array('guests'=>$guests,'guestNum'=>count($guests));
//
//点分享按钮时调用app的分享 // //点分享按钮时调用app的分享
$appParam['url'] = $shareInfo['shareUrl']; // $appParam['url'] = $shareInfo['shareUrl'];
$appParam['name'] = $shareInfo['shareTitle']; // $appParam['name'] = $shareInfo['shareTitle'];
$appParam['introduction'] = $shareInfo['shareContent']; // $appParam['introduction'] = $shareInfo['shareContent'];
; // ;
$this->assign('appParam',json_encode($appParam)); // $this->assign('appParam',json_encode($appParam));
$this->assign($return); // $this->assign($return);
//
$this->display(); // $this->display();
} // }
//取大赛的状态 //取大赛的状态
private function getGroupStatus($groupInfo){ private function getGroupStatus($groupInfo){
...@@ -708,126 +702,126 @@ class PkTopAction extends IdentityAction{ ...@@ -708,126 +702,126 @@ class PkTopAction extends IdentityAction{
} }
//我的未结束的挑战 //我的未结束的挑战
private function getMyPkUserId($userId){ // private function getMyPkUserId($userId){
$where=array('pk_end_time'=>array('egt',date('Y-m-d')), // $where=array('pk_end_time'=>array('egt',date('Y-m-d')),
'_complex'=>array('active_id'=>$userId,'passive_id'=>$userId,'_logic'=>'or')); // '_complex'=>array('active_id'=>$userId,'passive_id'=>$userId,'_logic'=>'or'));
//
$myPks=M('PktopData')->where($where)->order('add_time desc')->select(); // $myPks=M('PktopData')->where($where)->order('add_time desc')->select();
//
$myPkUserId=array(); // $myPkUserId=array();
foreach ($myPks as $k => $value) { // foreach ($myPks as $k => $value) {
//取我主动挑战的人 // //取我主动挑战的人
if($value['active_id']==$userId){ // if($value['active_id']==$userId){
$myPkUserId[]=$value['passive_id']; // $myPkUserId[]=$value['passive_id'];
} // }
} // }
return $myPkUserId; // return $myPkUserId;
} // }
//点首页名人堂的年度精英赛和月排行榜的下拉框月份请求后台 //点首页名人堂的年度精英赛和月排行榜的下拉框月份请求后台
public function getMonthData(){ // public function getMonthData(){
$type = I('type', ''); // $type = I('type', '');
$month = I('month', ''); // $month = I('month', '');
//年度精英赛,month字段有值,证明可以参加年度的精英赛 // //年度精英赛,month字段有值,证明可以参加年度的精英赛
if($type=='final'){ // if($type=='final'){
$top10UserIds=array(); // $top10UserIds=array();
//对应月份的前10名 // //对应月份的前10名
$monthUsers=M('PktopUserphb')->where(array('month'=>$month))->order('monthup desc')->select(); // $monthUsers=M('PktopUserphb')->where(array('month'=>$month))->order('monthup desc')->select();
foreach ($monthUsers as $k => &$v4) { // foreach ($monthUsers as $k => &$v4) {
$top10UserIds[]=$v4['user_id']; // $top10UserIds[]=$v4['user_id'];
} // }
//
$finalUsers=M('PktopUser')->where(array('month'=>$month,'active_money'=>array('gt',0)))->order('monthup desc')->select(); // $finalUsers=M('PktopUser')->where(array('month'=>$month,'active_money'=>array('gt',0)))->order('monthup desc')->select();
foreach ($finalUsers as $k => &$v3) { // foreach ($finalUsers as $k => &$v3) {
$v3['isTop10']=in_array($v3['user_id'],$top10UserIds)?1:0; // $v3['isTop10']=in_array($v3['user_id'],$top10UserIds)?1:0;
} // }
$count=count($finalUsers); // $count=count($finalUsers);
$this->assign('finalUsers',$finalUsers); // $this->assign('finalUsers',$finalUsers);
$content = $this->fetch('itemPass'); // $content = $this->fetch('itemPass');
} // }
if($type=='month'||$type=='all'){ // if($type=='month'||$type=='all'){
$userId=$this->user['userID']; // $userId=$this->user['userID'];
//月排行榜的旧月份和上个月份的页面显示不一样,改成显示一样 // //月排行榜的旧月份和上个月份的页面显示不一样,改成显示一样
$nowMonth=date('Y-m'); // $nowMonth=date('Y-m');
$monthUsers=M('PktopUserphb')->where(['month'=>$month])->order('monthup desc')->select(); // $monthUsers=M('PktopUserphb')->where(['month'=>$month])->order('monthup desc')->select();
$myPkUserId=$this->getMyPkUserId($userId); // $myPkUserId=$this->getMyPkUserId($userId);
$monthIds=array(); // $monthIds=array();
foreach ($monthUsers as $k => &$v) { // foreach ($monthUsers as $k => &$v) {
$v['pkStatus']=in_array($v['user_id'],$myPkUserId)?1:0; // $v['pkStatus']=in_array($v['user_id'],$myPkUserId)?1:0;
$monthIds[]=$v['user_id']; // $monthIds[]=$v['user_id'];
} // }
//
$enemyIds=$this->getEnemy($monthIds); // $enemyIds=$this->getEnemy($monthIds);
//
$nickList =getUser($monthIds,'nick');//// // $nickList =getUser($monthIds,'nick');////
//
foreach ($monthUsers as $k => &$v4) { // foreach ($monthUsers as $k => &$v4) {
$v4['enemyNum']=count($enemyIds[$v4['user_id']]); // $v4['enemyNum']=count($enemyIds[$v4['user_id']]);
$v4['enemy']=$enemyIds[$v4['user_id']]; // $v4['enemy']=$enemyIds[$v4['user_id']];
//
$nick = $nickList[$v4['user_id']];//// // $nick = $nickList[$v4['user_id']];////
$v4['user_name'] = $nick;//?$nick:$v4['user_name'];//// // $v4['user_name'] = $nick;//?$nick:$v4['user_name'];////
} // }
//
$count=count($monthUsers); // $count=count($monthUsers);
if($month==$nowMonth){ // if($month==$nowMonth){
$type='nowMonth'; // $type='nowMonth';
} // }
$this->assign(array('type'=>$type,'userList'=>$monthUsers)); // $this->assign(array('type'=>$type,'userList'=>$monthUsers));
$content = $this->fetch('item2'); // $content = $this->fetch('item2');
} // }
//
$this->ajaxReturn(array( // $this->ajaxReturn(array(
'status' => 1,'count' =>$count,'type' =>$type,'data' => $content // 'status' => 1,'count' =>$count,'type' =>$type,'data' => $content
)); // ));
} // }
//用户列表,包括最新挑战榜,人气挑战榜等页面 //用户列表,包括最新挑战榜,人气挑战榜等页面
public function userList(){ // public function userList(){
$userId=$this->user['userID']; // $userId=$this->user['userID'];
$type = I('type', 'new'); // $type = I('type', 'new');
//
$lastMonth=date('Y-m',strtotime(date('Y-m-01') . "-1 month")); // $lastMonth=date('Y-m',strtotime(date('Y-m-01') . "-1 month"));
//
if($type=='new'){ // if($type=='new'){
$userList=$this->formatTop10(); // $userList=$this->formatTop10();
} // }
if($type=='hot'){ // if($type=='hot'){
//所有月份的 // //所有月份的
$passiveIds=M('PktopData')->group('passive_id')->order('count(*) desc')->getField('passive_id',true); // $passiveIds=M('PktopData')->group('passive_id')->order('count(*) desc')->getField('passive_id',true);
$userList=M('PktopUserphb')->where(array('user_id'=>array('in',$passiveIds)))->order('field(user_id,'.implode(',',$passiveIds).')')->select(); // $userList=M('PktopUserphb')->where(array('user_id'=>array('in',$passiveIds)))->order('field(user_id,'.implode(',',$passiveIds).')')->select();
} // }
if($type=='all'){ // if($type=='all'){
$month = I('month',$lastMonth,intval); // $month = I('month',$lastMonth,intval);
$userList=M('PktopUserphb')->where(array('month'=>$month))->order('monthup desc')->select(); // $userList=M('PktopUserphb')->where(array('month'=>$month))->order('monthup desc')->select();
$selectMonth=array(); // $selectMonth=array();
foreach ($this->MONTH as $k => $value) { // foreach ($this->MONTH as $k => $value) {
$nowMonth=date('Y-m',strtotime(date('Y-m-01'))); // $nowMonth=date('Y-m',strtotime(date('Y-m-01')));
if($k<$nowMonth){ // if($k<$nowMonth){
$selectMonth[$k]=$value; // $selectMonth[$k]=$value;
} // }
} // }
// $type='lastMonth'; //// $type='lastMonth';
} // }
$myPkUserId=$this->getMyPkUserId($userId); // $myPkUserId=$this->getMyPkUserId($userId);
$userIds=array(); // $userIds=array();
foreach ($userList as $k => &$v) { // foreach ($userList as $k => &$v) {
$v['pkStatus']=in_array($v['user_id'],$myPkUserId)?1:0; // $v['pkStatus']=in_array($v['user_id'],$myPkUserId)?1:0;
$userIds[]=$v['user_id']; // $userIds[]=$v['user_id'];
} // }
$enemyIds=$this->getEnemy($userIds); // $enemyIds=$this->getEnemy($userIds);
foreach ($userList as $k => &$v4) { // foreach ($userList as $k => &$v4) {
$v4['enemyNum']=count($enemyIds[$v4['user_id']]); // $v4['enemyNum']=count($enemyIds[$v4['user_id']]);
$v4['enemy']=$enemyIds[$v4['user_id']]; // $v4['enemy']=$enemyIds[$v4['user_id']];
$v4['user_name']=$v4['user_id']; // $v4['user_name']=$v4['user_id'];
} // }
//
// var_dump($userList);exit; //// var_dump($userList);exit;
$pkTime=date('n月j日',strtotime('next Monday')).'-'.date('n月j日',strtotime('next Monday')+4*3600*24); // $pkTime=date('n月j日',strtotime('next Monday')).'-'.date('n月j日',strtotime('next Monday')+4*3600*24);
$this->assign(array('type'=>$type,'userList'=>$userList,'selectMonth'=>$selectMonth,'lastMonth'=>$lastMonth // $this->assign(array('type'=>$type,'userList'=>$userList,'selectMonth'=>$selectMonth,'lastMonth'=>$lastMonth
,'pkTime'=>$pkTime)); // ,'pkTime'=>$pkTime));
$this->display(); // $this->display();
} // }
public function login() { public function login() {
$userId=I('user_id', '',intval); $userId=I('user_id', '',intval);
...@@ -893,54 +887,55 @@ class PkTopAction extends IdentityAction{ ...@@ -893,54 +887,55 @@ class PkTopAction extends IdentityAction{
return $appShareInfo; return $appShareInfo;
} }
//提现页面
public function withdraw() {
$userID = $this->user['userID'];
$userName = $this->user['userName'];
if (!$userID) {
header("Location:/Passport/login/type/1.html?refer=/Pktop/withdraw");
}
//flag1提现,2挑战金记录
$flag=I('flag',0,intval);
if($flag==2){
//1pk付款,2发起pk,3pk胜利,4pk失败,5胜利退钱,6失败钱归passive,7买重置卡
$moneyList = M('PktopNews')->where(['user_id' => $userID,'type'=>['in','1,5,6,8']])->order('add_time desc')->select();
$this->assign(array('flag'=>2,'moneyList'=>$moneyList));
$this->display();
exit;
}
if($flag==1){ //提现页面
$user = M('PktopUser')->where(array('user_id' => $userID))->find(); // public function withdraw() {
if (IS_GET) { // $userID = $this->user['userID'];
$cashout_log = M('pktop_cashout_log')->where(['user_id' => $userID])->order('id desc')->find(); // $userName = $this->user['userName'];
$money=$user['active_money']+$user['passive_money']-$user['already_withdraw_money']; // if (!$userID) {
$this->assign(array('flag'=>1,'money'=>$money,'cashout_log'=>$cashout_log)); // header("Location:/Passport/login/type/1.html?refer=/Pktop/withdraw");
$this->display('/Pktop/withdraw'); // }
exit; //
}else{ // //flag1提现,2挑战金记录
//插入流水表 // $flag=I('flag',0,intval);
$alipayAccount = I('alipayAccount'); // if($flag==2){
$money = I('money', '', 'float'); // //1pk付款,2发起pk,3pk胜利,4pk失败,5胜利退钱,6失败钱归passive,7买重置卡
$data = ['user_id' => $userID, 'user_name' => $userName, 'Alipay' => $alipayAccount, // $moneyList = M('PktopNews')->where(['user_id' => $userID,'type'=>['in','1,5,6,8']])->order('add_time desc')->select();
'apply_cashout' => $money, 'time_cashout' => time()]; // $this->assign(array('flag'=>2,'moneyList'=>$moneyList));
// $this->display();
$id = M('PktopCashoutLog')->add($data); // exit;
if ($id) { // }
$this->ajaxReturn(array( //
'status' => 1, // if($flag==1){
'info' => '' // $user = M('PktopUser')->where(array('user_id' => $userID))->find();
)); // if (IS_GET) {
} else { // $cashout_log = M('pktop_cashout_log')->where(['user_id' => $userID])->order('id desc')->find();
$this->ajaxReturn(array( // $money=$user['active_money']+$user['passive_money']-$user['already_withdraw_money'];
'status' => 3, // $this->assign(array('flag'=>1,'money'=>$money,'cashout_log'=>$cashout_log));
'info' => '数据有误,请联系客服人员' // $this->display('/Pktop/withdraw');
)); // exit;
} // }else{
} // //插入流水表
} // $alipayAccount = I('alipayAccount');
} // $money = I('money', '', 'float');
// $data = ['user_id' => $userID, 'user_name' => $userName, 'Alipay' => $alipayAccount,
// 'apply_cashout' => $money, 'time_cashout' => time()];
//
// $id = M('PktopCashoutLog')->add($data);
// if ($id) {
// $this->ajaxReturn(array(
// 'status' => 1,
// 'info' => ''
// ));
// } else {
// $this->ajaxReturn(array(
// 'status' => 3,
// 'info' => '数据有误,请联系客服人员'
// ));
// }
// }
// }
// }
private function formatPassUsers($data,$num=3) { private function formatPassUsers($data,$num=3) {
$result=array(); $result=array();
...@@ -1042,7 +1037,10 @@ class PkTopAction extends IdentityAction{ ...@@ -1042,7 +1037,10 @@ class PkTopAction extends IdentityAction{
// header('location:'.M_URL.'/Match/jiang'); // header('location:'.M_URL.'/Match/jiang');
// exit; // exit;
// } // }
//邀请人id
if(I('aid')){
cookie('aid',I('aid'));
}
$userIdParam = I('user_id', '', intval); $userIdParam = I('user_id', '', intval);
// $isapp = I('isapp'); // $isapp = I('isapp');
// if ($isapp) { // if ($isapp) {
......
...@@ -55,6 +55,48 @@ class UserModel extends Model{ ...@@ -55,6 +55,48 @@ class UserModel extends Model{
return !empty($r) ? $r['concern_user_id'] : 0; return !empty($r) ? $r['concern_user_id'] : 0;
} }
//参赛送1.88元
public function addMoney($userId,$userName,$mobile){
$wallet=M('Wallet')->where(['user_id'=>$userId])->find();
if(empty($wallet)){
M('Wallet')->add(['user_id'=>$userId,'user_name'=>$userName,'add_time'=>time(),'money'=>1.88]);
}else{
M('Wallet')->where(['user_id'=>$userId])->setInc('money',1.88);
}
$addData=['user_id'=>$userId,'user_name'=>$userName,'mobile'=>$mobile,
'item_money'=>1.88,'item_time'=>time(),'group_id'=>PRIZE_GROUP_2021,'status'=>1,'note'=>'【全民分赛场】报名奖励红包'];
M('WalletItem')->add($addData);
}
//加入邀请表
public function addInvite($userIdB,$userNameB){
$aid=cookie('aid');
if($aid){
$ucA = uc_get_user(['userId' => $aid,'type' => 3]);
$ucDataA = $ucA['data'];
$userNameA=$ucDataA['user_name'];
//检查被邀请人是否被邀请过
$oldB=M('WalletInvite')->where(['user_id_b'=>$userIdB,'status'=>1])->count();
if($oldB){
//-1不显示在界面上
M('WalletInvite')->add(['user_id_a'=>$aid,'user_name_a'=>$userNameA,'user_id_b'=>$userIdB,
'user_name_b'=>$userNameB,'status'=>-1,'add_time'=>time(),'group_id'=>PRIZE_GROUP_2021]);
}else{
//status0报名未审核,1审核通过已报名状态
M('WalletInvite')->add(['user_id_a'=>$aid,'user_name_a'=>$userNameA,'user_id_b'=>$userIdB,
'user_name_b'=>$userNameB,'status'=>1,'money'=>1.88,'add_time'=>time(),'group_id'=>PRIZE_GROUP_2021]);
//邀请人加1.88元
M('Wallet')->where(['user_id'=>$aid])->setInc('money',1.88);
$addData=['user_id'=>$aid,'user_name'=>$userNameA,'mobile'=>$ucDataA['mobile'],
'item_money'=>1.88,'item_time'=>time(),'group_id'=>PRIZE_GROUP_2021,'status'=>1,'note'=>'邀请好友'];
M('WalletItem')->add($addData);
}
}
}
} }
?> ?>
\ No newline at end of file
...@@ -112,7 +112,7 @@ ...@@ -112,7 +112,7 @@
<a name="4"></a> <a name="4"></a>
<div class="new-quanmin marginB20"> <div class="new-quanmin marginB20">
<p class="bot-title">实盘赛场</p> <p class="bot-title">实盘赛场</p>
<div class="item-cont item2" url="{:M_URL}/True" style="cursor: pointer" > <div class="item-cont item2" url="{:M_URL}/True?aid={$Think.cookie.aid}" style="cursor: pointer" >
<div class="item-cont-logo"> <div class="item-cont-logo">
<img src="__PUBLIC__/Home/images/g2023/shipan.png" alt=""> <img src="__PUBLIC__/Home/images/g2023/shipan.png" alt="">
</div> </div>
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
<a name="1"></a> <a name="1"></a>
<div class="new-quanshang marginB20"> <div class="new-quanshang marginB20">
<p class="bot-title">券商专场</p> <p class="bot-title">券商专场</p>
<div class="item-cont" url="{:WWW_URL}/Zjds" style="cursor: pointer"> <div class="item-cont" url="{:WWW_URL}/Zjds?aid={$Think.cookie.aid}" style="cursor: pointer">
<img class="gjj" src="__PUBLIC__/Home/images/g2023/gjj-img.png" alt=""> <img class="gjj" src="__PUBLIC__/Home/images/g2023/gjj-img.png" alt="">
<div class="item-cont-logo"> <div class="item-cont-logo">
<img src="__PUBLIC__/Home/images/g2023/quanshang.png" alt=""> <img src="__PUBLIC__/Home/images/g2023/quanshang.png" alt="">
...@@ -150,7 +150,7 @@ ...@@ -150,7 +150,7 @@
<eq name="dsStatus.zjStatus" value="1"> <eq name="dsStatus.zjStatus" value="1">
<div class="enter-btn goTradeBtn " gid="{:ZHONGJIN_GROUP}" >交易</div> <div class="enter-btn goTradeBtn " gid="{:ZHONGJIN_GROUP}" >交易</div>
<else/> <else/>
<div class="enter-btn baoming" url="{:WWW_URL}/Zjds?clickFlag=1">报名参赛</div> <div class="enter-btn baoming" url="{:WWW_URL}/Zjds?clickFlag=1&aid={$Think.cookie.aid}">报名参赛</div>
</eq> </eq>
</div> </div>
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment