Commit ab4af143 authored by houyadong's avatar houyadong

全民赛场-成员交易页面修改

parent 284673cc
<?php
/**
* 炼股赛控制器
*/
class PkTopAction extends IdentityAction{
* 炼股赛控制器
*/
class PkTopAction extends IdentityAction
{
public $GID = PRIZE_GROUP_2021;
//测试时有2020-02
// public $MONTH =array('2022-05'=>'5月','2022-04'=>'4月','2022-03'=>'3月','2022-02'=>'2月','2022-01'=>'1月',
// '2021-12'=>'12月','2021-11'=>'11月','2021-10'=>'10月','2021-09'=>'9月','2021-08'=>'8月','2021-07'=>'7月',
// '2021-06'=>'6月','2021-05'=>'5月','2021-04'=>'4月','2021-03'=>'3月');
public $MONTH =array('2023-04'=>'2023-04','2023-03'=>'2023-03','2023-02'=>'2023-02','2023-01'=>'2023-01',
'2022-12'=>'2022-12','2022-11'=>'2022-11','2022-10'=>'2022-10','2022-09'=>'2022-09');
public $STATUS_TXT =array('1'=>'未开赛','2'=>'进行中','3'=>'已结束');
public $MONTH = array('2023-04' => '2023-04', '2023-03' => '2023-03', '2023-02' => '2023-02', '2023-01' => '2023-01', '2022-12' => '2022-12', '2022-11' => '2022-11', '2022-10' => '2022-10', '2022-09' => '2022-09');
public $STATUS_TXT = array('1' => '未开赛', '2' => '进行中', '3' => '已结束');
public function _initialize() {
public function _initialize()
{
parent::_initialize();
$userId = $this->user['userID'];
$ids = D('Group')->getGroupCache($userId);
......@@ -21,16 +20,14 @@ class PkTopAction extends IdentityAction{
$this->assign('joinStatus', 1);
}
//设置进入交易的参数
if(in_array(ACTION_NAME,['index','choujiang','phbWeek','phbOther','phbTrade'])){
$groupId =$this->GID;
if (in_array(ACTION_NAME, ['index', 'choujiang', 'phbWeek', 'phbOther', 'phbTrade'])) {
$groupId = $this->GID;
$groupInfo = M('Group')->field('group_id,web_id,category,name,startTime,endTime,member_quantity')
->where(['group_id' => $groupId])->find();
$groupInfo = M('Group')->field('group_id,web_id,category,name,startTime,endTime,member_quantity')->where(['group_id' => $groupId])->find();
$groupStatus = $this->getGroupStatus($groupInfo);
$share = ['groupId' => $groupId, 'groupStatus' => $groupStatus, 'viewPage' => 2, 'statusInt' => $groupStatus,
'close_tips' => '','zhuangtai' => $this->STATUS_TXT[$groupStatus]];
$share['userID']=$userId?$userId:'';
$share = ['groupId' => $groupId, 'groupStatus' => $groupStatus, 'viewPage' => 2, 'statusInt' => $groupStatus, 'close_tips' => '', 'zhuangtai' => $this->STATUS_TXT[$groupStatus]];
$share['userID'] = $userId ? $userId : '';
$groupInfo = array_merge($groupInfo, $share);
$this->assign('groupInfo', json_encode($groupInfo));
......@@ -43,502 +40,195 @@ class PkTopAction extends IdentityAction{
$this->assign('weixin', $weixin);
$this->assign('weixinUrl', 'https://eturl.cn/Rhq2wA?is_head=1');
//重置卡个数
if($userId){
$leftNum=M('MagicboxCard')->where(['user_id'=>$userId,'card_type'=>2,'use_time'=>0])->count();
}else{
$leftNum=0;
if ($userId) {
$leftNum = M('MagicboxCard')->where(['user_id' => $userId, 'card_type' => 2, 'use_time' => 0])->count();
} else {
$leftNum = 0;
}
$this->assign('resetLeftNum',$leftNum);
$this->assign('resetLeftNum', $leftNum);
}
}
//首页
// public function indexOld() {
// //首页的排行榜等切换
// if(!I('viewPage')){
// header('location:'.M_URL.'/Match/jiang');
// exit;
//
// }
//
// $userIdParam = I('user_id', '', intval);
// $isapp = I('isapp');
// if ($isapp) {
// $userId = substr($isapp, strpos($isapp, '=') + 1);
// if ($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')) {
// $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();
// }
//加入炼股赛
private function getGroupStatus($groupInfo)
{
if (is_end($groupInfo['endTime']) == true) {
$groupStatus = 3;
// $zhuangtai='已结束';
} elseif ($groupInfo['startTime'] > time()) {
$groupStatus = 1;
// $zhuangtai='未开赛';
} else {
$groupStatus = 2;
// $zhuangtai='进行中';
}
return $groupStatus;
}
//大赛排行榜的当前排行页面
// public function rankNow($caller='',$gid=0){
// $gid=$gid?$gid:$this->GID;
// $order=I('order','lastmonthup');
// $p=I('p', 1);
//// $pageSize=10;
// $pageSize=$gid==$this->GID?10:200;
// //分表归档
// $suffix = D('Userinfo')->getTable($gid);
// $table =$suffix?'mncg_archive.userinfo'.$suffix:'mncg.userinfo';
// $where=array('sex'=>$gid,'new_phb'=>array('gt',0),'zt'=>1);
// //测试时不用缓存->cache(true,cacheTime())
// $userNowList = M($table, " ", C('DB_CONFIG_MNCG3'))->where($where)->order($order.' desc')->page($p.','.$pageSize)->select();
//// var_dump($gid);exit;
// $userids = array();
// $usertranids = [];
// foreach ($userNowList as $key => &$rankV) {
// $userIDs = explode("X", $rankV['uid']);
// $rankV['user_id'] = $userIDs[1];
//// $rankV['userUrl'] = tradeDetailLink($this->GID,3,$userIDs[1]);
// $userids[] = $userIDs[1];
// $usertranids[] = $rankV['uid'];
// }
//
// $nick_name_arry =getUser($userids,'nick');////
// $robot_user = [];
// if(!empty($usertranids)){
// $robot_user = D('Robot')->groupRobotTranUserList($usertranids);
// }
// foreach ($userNowList as $key => &$value) {
// $nick_name = $nick_name_arry[$value['user_id']];
// //$value['user_name'] = $nick_name?$nick_name:$value['username'];
// $value['user_name'] = $nick_name;
//
// $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_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();
// if($caller=='local'){
// if($gid==$this->GID){
// $return['userList']=$userNowList;
// $return['order']=$order;
// $return['totalCount']=$totalCount;
// $return['pages']=ceil($totalCount/$pageSize);
// }else{
// $return['finalList']=$userNowList;
// $return['order']=$order;
//// $return['totalCount']=$totalCount;
//// $return['pages']=$totalCount/10;
//检查是否参加了大赛
public function setShare($userId, $cfrom = 0)
{
//app内的分享,参数名不能改
// $shareTitle='您的好友邀请您参加「全民炼股」争霸赛';
// $shareDesc='红包周周有,万元大奖月月送';
$shareTitle = '您的好友邀请您参加全民炼股争霸赛-全民分赛场';
$shareDesc = '每周评奖,正盈利即可瓜分奖金!!!';
$shareUrl = M_URL . "/PkTop?inviterId=" . $userId . '&cfrom=' . $cfrom;
$appShareInfo['shareTitle'] = $shareTitle;
$appShareInfo['shareContent'] = $shareDesc;
$appShareInfo['shareUrl'] = $shareUrl;
// $this->assign('appShareTitle',$shareTitle);
// $this->assign('appShareContent',$shareDesc);
// $this->assign('appShareUrl',$shareUrl);
$this->assign('appShareInfo', json_encode($appShareInfo));
// $this->assign('h5ShareTitle',$shareTitle);
// $this->assign('h5ShareDesc',$shareDesc);
// $this->assign('h5ShareUrl',$shareUrl);
//定义在微信分享的显示
$signPackage = D('Share')->getSignPackage();
$this->assign('signPackage', $signPackage);
$appParam['url'] = $shareUrl;
$appParam['name'] = $shareTitle;
$appParam['introduction'] = $shareDesc;
$this->assign('appParam', json_encode($appParam));
//定义在微信分享的显示
$signPackage = D('Share')->getSignPackage();
$this->assign('signPackage', json_encode($signPackage));
return $appShareInfo;
}
//月赛前10名用户的挑战情况
// private function formatTop10(){
// $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();
// $top10UserIds=array();
// foreach ($top10 as $k => $v) {
// $top10UserIds[]=$v['user_id'];
// }
//
// return $return;
// }else{
// $this->assign(array('order'=>$order,'userList'=>$userNowList,'p'=>$p));
// if($gid==$this->GID){
// $content = $this->fetch('itemNow');
// }else{
// $content = $this->fetch('finalList');
// $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;
// //敌人头像列表
// $v['enemy']=$enemyIds[$v['user_id']];
// }
// $content = $this->fetch('itemNow');
// $this->ajaxReturn(array(
// 'status' => 1,'count' =>$totalCount,'data' => $content ));
//// var_dump($top10);exit;
// return $top10;
// }
// }
// public function getMingrentangData($myPkUserId){
// $lastMonth=date('Y-m',strtotime(date('Y-m-01') . "-1 month"));
// //名人堂的月份下拉框
// $selectMonth1=$selectMonth2=array();
// foreach ($this->MONTH as $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;
//// }
// }
// $mingrentang=array('selectMonth1'=>$selectMonth1,'selectMonth2'=>$selectMonth2,
// 'selectMonthStart1'=>current($selectMonth1),'selectMonthStart2'=>current($selectMonth2));
//
// $nowTop10UserIds=array();
// //名人堂的月排行榜,默认显示当前月的前10名
// $monthUsers=M('PktopUserphb')->where(array('month'=>date('Y-m')))->order('monthup desc')->select();
// foreach ($monthUsers as $k => &$v4) {
// $v4['pkStatus']=in_array($v4['user_id'],$myPkUserId)?1:0;
// $nowTop10UserIds[]=$v4['user_id'];
// }
// $enemyIds=$this->getEnemy($nowTop10UserIds);
//
// $zongupData=$this->getZongup();
// foreach ($monthUsers as $k => &$v4) {
// $v4['enemyNum']=count($enemyIds[$v4['user_id']]);
// $v4['enemy']=$enemyIds[$v4['user_id']];
// $v4['zongup']=$zongupData[$v4['user_id']];
// public function getEnemy($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();
// $enemyIds=array();
// foreach ($enemy as $k => $v) {
// $enemyIds[$v['passive_id']][]=$v['active_id'];
// }
//
// //名人堂数据的决赛名单,只包括pk胜利者,现在用不到
//// $finalUsers=M('PktopUser')->where(array('month'=>$lastMonth,'active_money'=>array('gt',0)))->order('monthup desc')->select();
//// $mingrentang['finalUsers']=$finalUsers;
//
// $mingrentang['userList']=$monthUsers;
// $mingrentang['type']='nowMonth';
// return $mingrentang;
// return $enemyIds;
// }
//加入炼股赛
public function join(){
public function join()
{
// $code_type = 35;
$code_type = 32;
$mfrom = I('mfrom',0);
$mfrom = I('mfrom', 0);
//报名大赛
$mobile = I('mobile', '');
$smsCode = I('smsCode', '');
$referer = I('referer', '');
$inviterId = I('inviterId', '',intval);
$inviterId = I('inviterId', '', intval);
$targetUrl = I('targetUrl', '');
//app外打开
if($mobile){
if(!$smsCode) {
if ($mobile) {
if (!$smsCode) {
$this->ajaxReturn(['status' => 0, 'info' => '请输入手机验证码!']);
}
$param = ['mobile'=>$mobile,'code'=>$smsCode,'type'=>$code_type];
if(!D('Sms')->checkCode($param)){
$param = ['mobile' => $mobile, 'code' => $smsCode, 'type' => $code_type];
if (!D('Sms')->checkCode($param)) {
$this->ajaxReturn(['status' => 0, 'info' => '对不起!手机验证码错误或已过期!']);
}
$ucUser = uc_get_user(['token' => $mobile]);
//没有该用户,开始注册,status0有该用户,111表示用户不存在
if($ucUser['status']==111){
$ucData=$this->reg2020($mobile,$inviterId);
}else{
$ucData=$ucUser['data'];
if ($ucUser['status'] == 111) {
$ucData = $this->reg2020($mobile, $inviterId);
} else {
$ucData = $ucUser['data'];
}
}else{
$groupInfo=M('Group')->field('group_id,web_id,category,name,startTime,endTime')->where(array('group_id'=>$this->GID))->find();
$groupStatus=$this->getGroupStatus($groupInfo);
if ($groupStatus==3) {
} else {
$groupInfo = M('Group')->field('group_id,web_id,category,name,startTime,endTime')->where(array('group_id' => $this->GID))->find();
$groupStatus = $this->getGroupStatus($groupInfo);
if ($groupStatus == 3) {
$this->ajaxReturn(['status' => 0, 'info' => '大赛已经结束,不能报名!']);
}
if($mfrom==1||$mfrom==2){
$userId = I('userId', '',intval);
if($mfrom==1){
$referer=$referer?$referer:(I('place')?I('place'):'ios_banner');
if ($mfrom == 1 || $mfrom == 2) {
$userId = I('userId', '', intval);
if ($mfrom == 1) {
$referer = $referer ? $referer : (I('place') ? I('place') : 'ios_banner');
}
if($mfrom==2){
$referer=$referer?$referer:(I('place')?I('place'):'android_banner');
if ($mfrom == 2) {
$referer = $referer ? $referer : (I('place') ? I('place') : 'android_banner');
}
}else{
} else {
$userId = $this->user['userID'];
}
if(!$userId){
if (!$userId) {
$this->ajaxReturn(['status' => 0, 'info' => '请登录!']);
}
$uc = uc_get_user(['userId' => $userId,'type' => 3]);
$uc = uc_get_user(['userId' => $userId, 'type' => 3]);
$ucData = $uc['data'];
$mobile=$ucData['mobile'];
$mobile = $ucData['mobile'];
}
//自动登录
$this->setLogin(array('userID'=>$ucData['user_id'],'userName'=>$ucData['user_name'],'nick'=>$ucData['nick']));
$this->setLogin(array('userID' => $ucData['user_id'], 'userName' => $ucData['user_name'], 'nick' => $ucData['nick']));
//同步登陆
require_once './uc_client_php/client.php';
uc_user_synlogin(array('userId'=>$ucData['user_id'],'userName'=>$ucData['user_name'],'nick'=>$ucData['nick'],'webId'=>$ucData['web_id']));
uc_user_synlogin(array('userId' => $ucData['user_id'], 'userName' => $ucData['user_name'], 'nick' => $ucData['nick'], 'webId' => $ucData['web_id']));
if($targetUrl){
return array('status'=>11,'info'=>'');
if ($targetUrl) {
return array('status' => 11, 'info' => '');
}
//加入大赛
// $cfrom=I('cfrom');
// $place=$cfrom?$cfrom:I('hfrom');
$place='';
$return=$this->joinUserGroup($ucData['user_id'],$ucData['user_name'],$this->GID,$inviterId,$referer,$place,$mobile);
$place = '';
$return = $this->joinUserGroup($ucData['user_id'], $ucData['user_name'], $this->GID, $inviterId, $referer, $place, $mobile);
$this->ajaxReturn($return);
}
//检查是否参加了大赛
public function checkJoin(){
$userId = I('userId', '');
$groupId=I('groupId',0,intval);
if($userId){
$ids = D('Group')->getGroupCache($userId);
$joinStatus=in_array($groupId,$ids)?1:0;
}
$this->ajaxReturn(array('status' => 1,'joinStatus' =>$joinStatus,'userId'=>$userId));
}
//月赛前10名用户的挑战情况
// private function formatTop10(){
// $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();
// $top10UserIds=array();
// foreach ($top10 as $k => $v) {
// $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;
// //敌人头像列表
// $v['enemy']=$enemyIds[$v['user_id']];
// }
//// var_dump($top10);exit;
// return $top10;
// }
// public function getEnemy($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();
// $enemyIds=array();
// foreach ($enemy as $k => $v) {
// $enemyIds[$v['passive_id']][]=$v['active_id'];
// }
// return $enemyIds;
// }
public function sendMessage()
public function reg2020($mobile, $inviterId)
{
$mobile = I('mobile');
$verify_data = I('verify_data');
if (empty($verify_data)) {
$this->ajaxReturn(array('status' => 0, 'info' => '验证失败'));
} else {
$check_code = D('Ali')->checkVerify($verify_data);
if ($check_code != 200) {
$this->ajaxReturn(array('status' => 0, 'info' => '验证失败,请刷新重试'));
}
}
$type=32;
//手机发送短信验证码
$code = randString(6,1);
$tpl =C('WWW_SMS_TPL');
$content= cplang($tpl[$type]['content'],[$code]);
$data= array('mobile' => $mobile,'content' => $content, 'type' => $type,'id'=>time(),'code'=>$code);
$result = D('Sms')->send($data,true,true );
if($result){
session('mobileCode',md5(strtolower($mobile.$code)));
$this->ajaxReturn(array('status' => 1,'info' => '短信验证码已发送,请等待...' ));
}else{
$this->ajaxReturn(array('status' => 0,'info' => '发送失败'));
}
}
public function reg2020($mobile,$inviterId){
$username = randUsername('股神',$mobile);
$password = '1Aa'.substr(md5($username), 18);
$regData=['userName' => $username, 'password' => $password, 'ip' => get_client_ip(),
'inviteFrom' => 'web', 'mobile' => $mobile,'mobile_status' => 1,'psourse' =>'m'];
$regData['sourse']=$inviterId?'zcyaoqing':'zcguanfang';
$username = randUsername('股神', $mobile);
$password = '1Aa' . substr(md5($username), 18);
$regData = ['userName' => $username, 'password' => $password, 'ip' => get_client_ip(), 'inviteFrom' => 'web', 'mobile' => $mobile, 'mobile_status' => 1, 'psourse' => 'm'];
$regData['sourse'] = $inviterId ? 'zcyaoqing' : 'zcguanfang';
$uc = uc_user_register($regData);
// var_dump($uc);exit;
//status0是注册成功
if ($uc['status']) {
$this->ajaxReturn(array('status' => 0, 'info' => '注册失败!','debug'=>json_encode($uc)));
$this->ajaxReturn(array('status' => 0, 'info' => '注册失败!', 'debug' => json_encode($uc)));
}
//注册成功
$ucData = $uc['data'];
$info = array('user_id'=>$ucData['user_id'],'user_name'=>$ucData['user_name'],'mobile'=>$mobile,'mobile_status'=>1);
$info = array('user_id' => $ucData['user_id'], 'user_name' => $ucData['user_name'], 'mobile' => $mobile, 'mobile_status' => 1);
$res = D('Userinfo')->_addUser($info);
if ($res <= 0) {
......@@ -546,510 +236,215 @@ class PkTopAction extends IdentityAction{
} else {
//注册后不用让其自动登录
uc_user_synlogin(array('userId' => $info['user_id'], 'userName' => $info['user_name'], 'nick' => '', 'webId' => ''));
$this->setLogin(array('userID'=>$info['user_id'],'userName'=>$info[' user_name'],'nick'=>''));
$this->setLogin(array('userID' => $info['user_id'], 'userName' => $info[' user_name'], 'nick' => ''));
}
//新用户注册送150富币
D('CofCoin')->addMoneyForNewUser($info['user_id'],$info['user_name'],$mobile);
D('CofCoin')->addMoneyForNewUser($info['user_id'], $info['user_name'], $mobile);
return $info;
}
public function setLogin($userInfo){
public function setLogin($userInfo)
{
//清空cookie
cookie('_userID', $userInfo['userID']);
cookie('_userName',$userInfo['userName']);
cookie('_userName', $userInfo['userName']);
// cookie('_nick',$userInfo['nick']);
cookie('_auth',null);
cookie('_auth', think_encrypt($userInfo['userName']."\t".$userInfo['userID']."\t".$userInfo['nick']),86400*30);
cookie('_auth', null);
cookie('_auth', think_encrypt($userInfo['userName'] . "\t" . $userInfo['userID'] . "\t" . $userInfo['nick']), 86400 * 30);
}
//参加大赛
public function joinUserGroup($userId,$userName,$groupId,$inviterId,$referer,$place,$mobile){
public function joinUserGroup($userId, $userName, $groupId, $inviterId, $referer, $place, $mobile)
{
// $field='group_id,name,question_privacy,reg_answer,type,web_id,capital,teamid,category,is_open';
// $group =M('Group')->where(array('group_id'=>$groupId))->field($field)->find();
$field='a.group_id,a.name,question_privacy,reg_answer,a.type,a.web_id,a.capital,a.teamid,a.category,is_open,wechat';
$group=M('Group a')->join('left join cofool_group_info b on a.group_id=b.group_id')
->field($field)->where(['a.group_id'=>$groupId])->find();
$field = 'a.group_id,a.name,question_privacy,reg_answer,a.type,a.web_id,a.capital,a.teamid,a.category,is_open,wechat';
$group = M('Group a')->join('left join cofool_group_info b on a.group_id=b.group_id')->field($field)->where(['a.group_id' => $groupId])->find();
// $bmContent='您正在报名全民争霸赛,请添加陪伴老师微信加入【大赛高手交流群】,老师微信号:'.$group['wechat'];
// $bmContent='您正在报名全民争霸赛,请添加陪伴老师微信加入【大赛高手交流群】,老师微信号:19144412198';
$bmContent='您正在报名全民炼股争霸赛,请下载简投APP联系官方客服,领取参赛福利。';
$bmContent = '您正在报名全民炼股争霸赛,请下载简投APP联系官方客服,领取参赛福利。';
if($group['is_open']==0){
return array('status'=>0,'info'=>'当前大赛不允许加入!');
if ($group['is_open'] == 0) {
return array('status' => 0, 'info' => '当前大赛不允许加入!');
}
//有grade,不改成user_group缓存
$row = M('UserGroup')->where(array('user_id'=>$userId,'group_id'=>$groupId))->find();
if(empty($row)){
$initData=array('user_id'=>$userId,'user_name'=>$userName,'group_id'=>$groupId,'grade'=>0,'teamid'=>$groupId,'add_time'=>NOW_TIME);
$u_data=array('u_web_id'=>$group['web_id'],'u_name'=>$group['name'],'u_category'=>$group['category'],'u_capital'=>$group['capital']);
$result = M('UserGroup')->add(array_merge($initData,$u_data));
$row = M('UserGroup')->where(array('user_id' => $userId, 'group_id' => $groupId))->find();
if (empty($row)) {
$initData = array('user_id' => $userId, 'user_name' => $userName, 'group_id' => $groupId, 'grade' => 0, 'teamid' => $groupId, 'add_time' => NOW_TIME);
$u_data = array('u_web_id' => $group['web_id'], 'u_name' => $group['name'], 'u_category' => $group['category'], 'u_capital' => $group['capital']);
$result = M('UserGroup')->add(array_merge($initData, $u_data));
//增加人数
M('Group')->where(array('group_id'=>$groupId))->setInc('member_quantity');
}else{
M('Group')->where(array('group_id' => $groupId))->setInc('member_quantity');
} else {
//如果被踢出则恢复
if($row['grade'] == -2){
M('UserGroup')->where(['user_id'=>$userId,'group_id'=>$groupId])->save(['grade'=>0,'add_time'=>time()]);
}else{
if ($row['grade'] == -2) {
M('UserGroup')->where(['user_id' => $userId, 'group_id' => $groupId])->save(['grade' => 0, 'add_time' => time()]);
} else {
// return ['status'=>0,'info'=>'您已经参加过该大赛','debug'=>$userId,'flag'=>1];
return ['status'=>0,'info'=>'登录成功','debug'=>$userId,'flag'=>1];
return ['status' => 0, 'info' => '登录成功', 'debug' => $userId, 'flag' => 1];
}
}
//加入炼股赛用户表
$exist=M('PktopUser')->where(array('user_id'=>$userId))->find();
if(empty($exist)){
$inviterId=$inviterId?$inviterId:cookie('aid');
$inviterId=$inviterId?$inviterId:5420972;
$userData=array('user_id'=>$userId,'user_name'=>$userName,'inviter_id'=>$inviterId,
'referer'=>$referer,'add_time'=>time(),'device'=>$place?$place:'m');
$exist = M('PktopUser')->where(array('user_id' => $userId))->find();
if (empty($exist)) {
$inviterId = $inviterId ? $inviterId : cookie('aid');
$inviterId = $inviterId ? $inviterId : 5420972;
$userData = array('user_id' => $userId, 'user_name' => $userName, 'inviter_id' => $inviterId, 'referer' => $referer, 'add_time' => time(), 'device' => $place ? $place : 'm');
//ur里面有user_id时,判断不出是自己的还是邀请人的
if($userId==$inviterId){
$userData['inviter_id']='';
if ($userId == $inviterId) {
$userData['inviter_id'] = '';
}
M('PktopUser')->add($userData);
}
//清user_group缓存
D('Group')->clearGroupCache($userId);
//普通大赛
$db = getModel($group['web_id']);
$uid = $groupId.'X'.$userId;
$row = M('userinfo', " ", C('DB_CONFIG_MNCG3'))->where(array('uid'=>$uid))->count();
if(!empty($row)){
M('userinfo', " ", C('DB_CONFIG_MNCG3'))->where(array('uid'=>$uid))->data(array('zt'=>1))->save();
}else{
$initData=['stock_balance'=>0,'all_cjl'=>0,'new_phb'=>0,'old_phb'=>0,'zt'=>1,'XinyongED'=>6];
$initData['uid']=$uid;
$initData['username']=$userName;
$initData['balance']=$initData['frozen_balance']=$initData['all_balance']=$group['capital'];
$initData['sex']=$group['teamid'];
$initData['regdate']=date('Y-m-d H:i:s',NOW_TIME);
$uid = $groupId . 'X' . $userId;
$row = M('userinfo', " ", C('DB_CONFIG_MNCG3'))->where(array('uid' => $uid))->count();
if (!empty($row)) {
M('userinfo', " ", C('DB_CONFIG_MNCG3'))->where(array('uid' => $uid))->data(array('zt' => 1))->save();
} else {
$initData = ['stock_balance' => 0, 'all_cjl' => 0, 'new_phb' => 0, 'old_phb' => 0, 'zt' => 1, 'XinyongED' => 6];
$initData['uid'] = $uid;
$initData['username'] = $userName;
$initData['balance'] = $initData['frozen_balance'] = $initData['all_balance'] = $group['capital'];
$initData['sex'] = $group['teamid'];
$initData['regdate'] = date('Y-m-d H:i:s', NOW_TIME);
M('userinfo', " ", C('DB_CONFIG_MNCG3'))->add($initData);
}
D('User')->addInvite($userId,$userName);
D('User')->addInvite($userId, $userName);
//完成勋章
D('User')->finishXunzhang($userId,$userName,$mobile,'cansai');
D('User')->finishXunzhang($userId, $userName, $mobile, 'cansai');
D('Sms')->send(['mobile'=>$mobile,'content' =>$bmContent,'type'=>46],true,true);
D('Sms')->send(['mobile' => $mobile, 'content' => $bmContent, 'type' => 46], true, true);
#富币任务-全民邀请参赛
$aid=cookie('aid')?cookie('aid'):5420972;
$result = D('CofCoin')->addMoneyForQmJoin($userId,$aid);
if(cookie('aid')){
cookie('aid',null);
$aid = cookie('aid') ? cookie('aid') : 5420972;
$result = D('CofCoin')->addMoneyForQmJoin($userId, $aid);
if (cookie('aid')) {
cookie('aid', null);
}
return ['status' => 1, 'info' => '参赛成功', 'debug' => $userId, 'is_coin' => $result];
}
//我的邀请列表
// public function myInvite(){
// $userId = $this->user['userID'];
// $cfrom=I('cfrom', '');
// $key=I('key', '');
// if($cfrom=='pcInvitation'){
// $userIdParam=I('user_id', '',intval);
//// echo md5('user_id='.$userIdParam.'abcd4321');exit;
// if(md5('user_id='.$userIdParam.C('login_user_id_salt'))==$key){
// $this->setUcLogin($userIdParam);
// $userId=$userIdParam;
// }else{
// //校验不对
// $userId=-1;
// }
// }
//// $userId=4825940;
// $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)))
// ->order('lastmonthup desc,regdate asc')->cache(true,300)->select();
// foreach ($mncgData as $k => $value) {
// $guestId=str_replace($this->GID.'X','',$value['uid']);
// //有交易数据
// if(!empty($guests[$guestId])){
// $guests[$guestId]['order']=$k+1;
// $guests[$guestId]['lastmonthup']=$value['lastmonthup'];
// }
// }
////var_dump($mncgData);exit;
// $shareInfo=$this->setShare($userId,$cfrom);
//
// $return=array('guests'=>$guests,'guestNum'=>count($guests));
//
// //点分享按钮时调用app的分享
// $appParam['url'] = $shareInfo['shareUrl'];
// $appParam['name'] = $shareInfo['shareTitle'];
// $appParam['introduction'] = $shareInfo['shareContent'];
// ;
// $this->assign('appParam',json_encode($appParam));
// $this->assign($return);
//
// $this->display();
// }
//取大赛的状态
private function getGroupStatus($groupInfo){
if(is_end($groupInfo['endTime'])==true){
$groupStatus=3;
// $zhuangtai='已结束';
}elseif($groupInfo['startTime']>time()){
$groupStatus=1;
// $zhuangtai='未开赛';
}else{
$groupStatus=2;
// $zhuangtai='进行中';
}
return $groupStatus;
public function checkJoin()
{
$userId = I('userId', '');
$groupId = I('groupId', 0, intval);
if ($userId) {
$ids = D('Group')->getGroupCache($userId);
$joinStatus = in_array($groupId, $ids) ? 1 : 0;
}
$this->ajaxReturn(array('status' => 1, 'joinStatus' => $joinStatus, 'userId' => $userId));
}
//我的未结束的挑战
// private function getMyPkUserId($userId){
// $where=array('pk_end_time'=>array('egt',date('Y-m-d')),
// '_complex'=>array('active_id'=>$userId,'passive_id'=>$userId,'_logic'=>'or'));
//
// $myPks=M('PktopData')->where($where)->order('add_time desc')->select();
//
// $myPkUserId=array();
// foreach ($myPks as $k => $value) {
// //取我主动挑战的人
// if($value['active_id']==$userId){
// $myPkUserId[]=$value['passive_id'];
// }
// }
// return $myPkUserId;
// }
//点首页名人堂的年度精英赛和月排行榜的下拉框月份请求后台
// public function getMonthData(){
// $type = I('type', '');
// $month = I('month', '');
// //年度精英赛,month字段有值,证明可以参加年度的精英赛
// if($type=='final'){
// $top10UserIds=array();
// //对应月份的前10名
// $monthUsers=M('PktopUserphb')->where(array('month'=>$month))->order('monthup desc')->select();
// foreach ($monthUsers as $k => &$v4) {
// $top10UserIds[]=$v4['user_id'];
// }
//
// $finalUsers=M('PktopUser')->where(array('month'=>$month,'active_money'=>array('gt',0)))->order('monthup desc')->select();
// foreach ($finalUsers as $k => &$v3) {
// $v3['isTop10']=in_array($v3['user_id'],$top10UserIds)?1:0;
// }
// $count=count($finalUsers);
// $this->assign('finalUsers',$finalUsers);
// $content = $this->fetch('itemPass');
// }
// if($type=='month'||$type=='all'){
// $userId=$this->user['userID'];
// //月排行榜的旧月份和上个月份的页面显示不一样,改成显示一样
// $nowMonth=date('Y-m');
// $monthUsers=M('PktopUserphb')->where(['month'=>$month])->order('monthup desc')->select();
// $myPkUserId=$this->getMyPkUserId($userId);
// $monthIds=array();
// foreach ($monthUsers as $k => &$v) {
// $v['pkStatus']=in_array($v['user_id'],$myPkUserId)?1:0;
// $monthIds[]=$v['user_id'];
// }
//
// $enemyIds=$this->getEnemy($monthIds);
//
// $nickList =getUser($monthIds,'nick');////
//
// foreach ($monthUsers as $k => &$v4) {
// $v4['enemyNum']=count($enemyIds[$v4['user_id']]);
// $v4['enemy']=$enemyIds[$v4['user_id']];
//
// $nick = $nickList[$v4['user_id']];////
// $v4['user_name'] = $nick;//?$nick:$v4['user_name'];////
// }
//
// $count=count($monthUsers);
// if($month==$nowMonth){
// $type='nowMonth';
// }
// $this->assign(array('type'=>$type,'userList'=>$monthUsers));
// $content = $this->fetch('item2');
// }
//
// $this->ajaxReturn(array(
// 'status' => 1,'count' =>$count,'type' =>$type,'data' => $content
// ));
// }
//用户列表,包括最新挑战榜,人气挑战榜等页面
// public function userList(){
// $userId=$this->user['userID'];
// $type = I('type', 'new');
//
// $lastMonth=date('Y-m',strtotime(date('Y-m-01') . "-1 month"));
//
// if($type=='new'){
// $userList=$this->formatTop10();
// }
// if($type=='hot'){
// //所有月份的
// $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();
// }
// if($type=='all'){
// $month = I('month',$lastMonth,intval);
// $userList=M('PktopUserphb')->where(array('month'=>$month))->order('monthup desc')->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';
// }
// $myPkUserId=$this->getMyPkUserId($userId);
// $userIds=array();
// foreach ($userList as $k => &$v) {
// $v['pkStatus']=in_array($v['user_id'],$myPkUserId)?1:0;
// $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']];
// $v4['user_name']=$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,'lastMonth'=>$lastMonth
// ,'pkTime'=>$pkTime));
// $this->display();
// }
public function login() {
$userId=I('user_id', '',intval);
if($userId&&$this->user['userName']==''){
$user_data = uc_get_user(array('userName' => '', 'webId' => 0, 'userId' => $userId));
$ucData=$user_data['data'];
$userName = $ucData['user_name'];
uc_user_synlogin(array('userId'=>$userId,'userName'=>$userName,'nick'=>'','webId'=>$ucData['web_id']));
$this->assign(array(
'user'=>array('userID'=>$userId,'userName'=>$userName)
));
public function sendMessage()
{
$mobile = I('mobile');
$verify_data = I('verify_data');
if (empty($verify_data)) {
$this->ajaxReturn(array('status' => 0, 'info' => '验证失败'));
} else {
$check_code = D('Ali')->checkVerify($verify_data);
if ($check_code != 200) {
$this->ajaxReturn(array('status' => 0, 'info' => '验证失败,请刷新重试'));
}
}
$type = 32;
//手机发送短信验证码
$code = randString(6, 1);
$tpl = C('WWW_SMS_TPL');
$content = cplang($tpl[$type]['content'], [$code]);
$data = array('mobile' => $mobile, 'content' => $content, 'type' => $type, 'id' => time(), 'code' => $code);
$result = D('Sms')->send($data, true, true);
if ($result) {
session('mobileCode', md5(strtolower($mobile . $code)));
$this->ajaxReturn(array('status' => 1, 'info' => '短信验证码已发送,请等待...'));
} else {
$this->ajaxReturn(array('status' => 0, 'info' => '发送失败'));
}
//首页滚动的公告
public function getGonggao() {
// $gonggao=M('pktop_gonggao','cofool_', C('DB_CONFIG_DEMO'))->where(array('view_flag'=>1))->order('add_time desc')->limit(5)->select();
$gonggao=M('Gonggao')->where(['group_id'=>PRIZE_GROUP_2021,'view_flag'=>1])->order('add_time desc')->limit(5)->select();
return $gonggao;
}
//首页滚动的公告
public function setUcLogin($userId) {
$user_data = uc_get_user(array('userName' => '', 'webId' => 0, 'userId' => $userId));
$ucData=$user_data['data'];
$userName = $ucData['user_name'];
// var_dump($userId);exit;
uc_user_synlogin(array('userId'=>$userId,'userName'=>$userName,'nick'=>'','webId'=>$ucData['web_id']));
$this->setLogin(array('userId'=>$userId,'userName'=>$userName));
$this->assign(array(
'user'=>['userID'=>$userId,'userName'=>$userName,'nick'=>$ucData['nick']]
));
}
public function setShare($userId,$cfrom=0) {
//app内的分享,参数名不能改
// $shareTitle='您的好友邀请您参加「全民炼股」争霸赛';
// $shareDesc='红包周周有,万元大奖月月送';
$shareTitle='您的好友邀请您参加全民炼股争霸赛-全民分赛场';
$shareDesc='每周评奖,正盈利即可瓜分奖金!!!';
$shareUrl=M_URL."/PkTop?inviterId=".$userId.'&cfrom='.$cfrom;
$appShareInfo['shareTitle']=$shareTitle;
$appShareInfo['shareContent']=$shareDesc;
$appShareInfo['shareUrl']=$shareUrl;
// $this->assign('appShareTitle',$shareTitle);
// $this->assign('appShareContent',$shareDesc);
// $this->assign('appShareUrl',$shareUrl);
$this->assign('appShareInfo',json_encode($appShareInfo));
// $this->assign('h5ShareTitle',$shareTitle);
// $this->assign('h5ShareDesc',$shareDesc);
// $this->assign('h5ShareUrl',$shareUrl);
//定义在微信分享的显示
$signPackage=D('Share')->getSignPackage();
$this->assign('signPackage',$signPackage);
$appParam['url'] = $shareUrl;
$appParam['name'] = $shareTitle;
$appParam['introduction'] = $shareDesc;
;
$this->assign('appParam',json_encode($appParam));
//定义在微信分享的显示
$signPackage=D('Share')->getSignPackage();
$this->assign('signPackage',json_encode($signPackage));
return $appShareInfo;
public function login()
{
$userId = I('user_id', '', intval);
if ($userId && $this->user['userName'] == '') {
$user_data = uc_get_user(array('userName' => '', 'webId' => 0, 'userId' => $userId));
$ucData = $user_data['data'];
$userName = $ucData['user_name'];
uc_user_synlogin(array('userId' => $userId, 'userName' => $userName, 'nick' => '', 'webId' => $ucData['web_id']));
$this->assign(array('user' => array('userID' => $userId, 'userName' => $userName)));
}
}
//提现页面
// 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();
// if (IS_GET) {
// $cashout_log = M('pktop_cashout_log')->where(['user_id' => $userID])->order('id desc')->find();
// $money=$user['active_money']+$user['passive_money']-$user['already_withdraw_money'];
// $this->assign(array('flag'=>1,'money'=>$money,'cashout_log'=>$cashout_log));
// $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) {
// $result=array();
// $tmp=array();
// foreach($data as $k=>&$val) {
//// $val['userUrl'] = tradeDetailLink($this->GID,3,$val['active_id']);
// $tmp[$k/$num][]=$val;
// $result=$tmp;
// }
// return $result;
// }
//记录分享的日志
public function shareLog() {
public function shareLog()
{
$userID = $this->user['userID'];
M('PktopShare')->add(array('user_id'=>$userID,'add_time'=>time(),'device'=>'m'));
M('PktopShare')->add(array('user_id' => $userID, 'add_time' => time(), 'device' => 'm'));
$this->ajaxReturn(array('status' => 0, 'info' => ''));
}
// public function setGoTrade($userId) {
// //进入交易需要的参数
// $groupInfo=M('Group')->field('group_id,web_id,category,name,startTime,endTime')->where(array('group_id'=>$this->GID))->find();
//
// $zhuangtai=$this->getGroupStatus($groupInfo);
// $groupInfo['userID']=$userId;
//
// $groupInfo['close_tips']='';
// $groupInfo['zhuangtai'] = $zhuangtai;
// $groupInfo['viewPage'] = 2;
// //跳到交易区
// $groupInfo['jump'] = 1;
//// $groupInfo['title'] = '『全民炼股』争霸赛(2020赛季)';
//// $groupInfo['desc'] = $groupInfo['shareContent']='红包周周有,万元大奖月月送,精英还可赢PK奖';
//
// $this->assign('groupInfo',json_encode($groupInfo));
// }
//进入交易需要的参数,可能跳转到他人主页
public function getGoTradeInfo() {
$userId = I('userId', '',intval);
public function getGoTradeInfo()
{
$userId = I('userId', '', intval);
$userName = I('userName', '');
$gid=I('gid',$this->GID,intval);
if(!$userId){
$this->ajaxReturn(['status' =>0,'info'=>'非法参数']);
$gid = I('gid', $this->GID, intval);
if (!$userId) {
$this->ajaxReturn(['status' => 0, 'info' => '非法参数']);
}
$gInfo=M('Group')->field('group_id,web_id,category,name,startTime,endTime')->where(['group_id'=>$gid])->find();
$gInfo = M('Group')->field('group_id,web_id,category,name,startTime,endTime')->where(['group_id' => $gid])->find();
$goTradeInfo=['group_id'=>$gInfo['group_id'],'web_id'=>$gInfo['web_id'],'category'=>$gInfo['category'],'name'=>$gInfo['name']];
$goTradeInfo['groupStatus'] = $gInfo['startTime']>time()?'1': (is_end($gInfo['endTime'])?'3':'2');
$goTradeInfo['zhuangtai'] = $gInfo['startTime']>time()?'未开始': (is_end($gInfo['endTime'])?'已结束':'进行中');
$goTradeInfo = ['group_id' => $gInfo['group_id'], 'web_id' => $gInfo['web_id'], 'category' => $gInfo['category'], 'name' => $gInfo['name']];
$goTradeInfo['groupStatus'] = $gInfo['startTime'] > time() ? '1' : (is_end($gInfo['endTime']) ? '3' : '2');
$goTradeInfo['zhuangtai'] = $gInfo['startTime'] > time() ? '未开始' : (is_end($gInfo['endTime']) ? '已结束' : '进行中');
$goTradeInfo['userID']=$userId;
$goTradeInfo['userName']=$userName;
$goTradeInfo['userID'] = $userId;
$goTradeInfo['userName'] = $userName;
$goTradeInfo['jump']=$this->user['userID']==$userId?1:2;
$goTradeInfo['jump'] = $this->user['userID'] == $userId ? 1 : 2;
$this->ajaxReturn(['status' => 1,'data'=>json_encode($goTradeInfo)]);
$this->ajaxReturn(['status' => 1, 'data' => json_encode($goTradeInfo)]);
}
//取总盈利率
private function getZongup(){
$db = getModel(102);
$suffix = D('Userinfo')->getTable($this->GID);
$table =$suffix?'mncg_archive.userinfo'.$suffix:'mncg.userinfo';
// var_dump($table);exit;
// $userInfoData = $db->table($table)->where(array('sex' => $this->GID))->getField('uid,zongup');
$userInfoData = M($table, " ", C('DB_CONFIG_MNCG3'))->where(array('sex' => $this->GID))->getField('uid,zongup');
// var_dump($userInfoData);exit;
$zongupData=array();
foreach ($userInfoData as $k => $v1) {
$tmpId=str_replace($this->GID.'X','',$k);
$zongupData[$tmpId]=$v1;
//记录分享的日志
public function dianjiLog()
{
$gid = $this->GID;
$userId = $this->user['userID'];
if ($userId) {
$where = ['user_id' => $userId, 'add_time' => ['egt', strtotime('today')], 'model' => MODULE_NAME, 'action' => 'moreDs', 'param1' => $gid];
$count = M('ClickLog')->where($where)->count();
if (!$count) {
$data = ['user_id' => $userId, 'user_name' => $this->user['userName'], 'model' => MODULE_NAME, 'action' => 'moreDs', 'add_time' => time(), 'client' => getSys(), 'day' => date('Ymd', time()), 'param1' => $gid];
M('ClickLog')->add($data);
}
return $zongupData;
}
$this->ajaxReturn(['status' => 1, 'debug' => '用户id:' . $userId . ',旧数据条数' . $count]);
}
public function dianjiLog(){
$gid=$this->GID;
$userId=$this->user['userID'];
if($userId){
$where=['user_id'=>$userId,'add_time'=>['egt',strtotime('today')],'model'=>MODULE_NAME,'action'=>'moreDs','param1'=>$gid];
$count = M('ClickLog')->where($where)->count();
if(!$count){
$data=['user_id'=>$userId,'user_name'=>$this->user['userName'],'model'=>MODULE_NAME,'action'=>'moreDs',
'add_time'=>time(),'client'=>getSys(),'day'=>date('Ymd',time()),'param1'=>$gid];
M('ClickLog')->add($data);
}
}
$this->ajaxReturn(['status'=>1,'debug'=>'用户id:'.$userId.',旧数据条数'.$count]);
}
//新首页
//进入交易需要的参数,可能跳转到他人主页
public function index()
{
//邀请人id
if(I('aid')){
cookie('aid',I('aid'));
if (I('aid')) {
cookie('aid', I('aid'));
}
$userIdParam = I('user_id', '', intval);
$key = I('key', '');
......@@ -1067,7 +462,7 @@ class PkTopAction extends IdentityAction{
}
} else {
//第二次请求
if (md5($userIdParam . 'abcd4321') == $key2 || md5('user_id=' . $userIdParam .'abcd4321') == $key) {
if (md5($userIdParam . 'abcd4321') == $key2 || md5('user_id=' . $userIdParam . 'abcd4321') == $key) {
$userId = $userIdParam;
}
}
......@@ -1081,9 +476,8 @@ class PkTopAction extends IdentityAction{
$groupStatus = $this->getGroupStatus($groupInfo);
$member_quantity = $groupInfo['member_quantity'];
$share = ['groupId' => $groupId, 'groupStatus' => $groupStatus, 'viewPage' => 2, 'statusInt' => $groupStatus,
'close_tips' => '','zhuangtai' => $this->STATUS_TXT[$groupStatus]];
$share['userID']=$userId?$userId:'';
$share = ['groupId' => $groupId, 'groupStatus' => $groupStatus, 'viewPage' => 2, 'statusInt' => $groupStatus, 'close_tips' => '', 'zhuangtai' => $this->STATUS_TXT[$groupStatus]];
$share['userID'] = $userId ? $userId : '';
$this->assign('groupInfo', json_encode(array_merge($groupInfo, $share)));
......@@ -1093,37 +487,20 @@ class PkTopAction extends IdentityAction{
if (in_array($groupId, $ids)) {
$this->assign('joinStatus', 1);
}
if(!in_array($groupId, $ids)){
if (!in_array($groupId, $ids)) {
$this->assign('is_auto_join', I('aid') ? 1 : 0);
}
//滚动消息,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);
$lastMonth = date('Y-m', strtotime(date('Y-m-01') . "-1 month"));
$lastMonthInt = intval(date('m', strtotime(date('Y-m-01') . "-1 month")));
// $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();
$popData=null;
//第一个页面显示的数据,公告,心得等
$firstPageData = [
// 'popType' => $popData['popType'], 'popPkUserName' => $popData['popPkUserName'],
'thinks' => $thinks, 'gonggao' => $gonggao];
'thinks' => $thinks, 'gonggao' => $gonggao
];
$this->assign($firstPageData);
......@@ -1150,14 +527,11 @@ class PkTopAction extends IdentityAction{
$referer = I('hFrom');
} elseif (I('from')) {
$referer = I('from');
}elseif (I('place')) {
} elseif (I('place')) {
$referer = I('place');
} else {
$referer = $_SERVER['HTTP_REFERER'];
}
// //这个月剩余的抽奖机会
// $leftCjNum = $this->getLeftCjNum();
// $this->assign('leftCjNum', $leftCjNum);
//大赛状态
$gInfo['gStatus'] = is_end($groupInfo['endTime']) ? '3' : ($groupInfo['startTime'] > time() ? '1' : '2');
$this->assign('gInfo', $gInfo);
......@@ -1168,55 +542,119 @@ class PkTopAction extends IdentityAction{
//我的成绩
$this->setMyData();
$this->setMyData();
//重置卡个数
if($userId){
$leftNum=M()->db(10, C('DB_CONFIG_DEMO'))->table('cofool_magicbox_card')->where(['user_id'=>$userId,'card_type'=>2,'use_time'=>0])->count();
}else{
$leftNum=0;
if ($userId) {
$leftNum = M()->db(10, C('DB_CONFIG_DEMO'))->table('cofool_magicbox_card')->where(['user_id' => $userId, 'card_type' => 2, 'use_time' => 0])->count();
} else {
$leftNum = 0;
}
$this->assign('resetLeftNum',$leftNum);
$this->assign('resetLeftNum', $leftNum);
$this->display();
}
public function choujiang() {
//这个月剩余的抽奖机会
$leftCjNum = A('Vip/Public')->getLeftCjNum();
$this->assign('leftCjNum', $leftCjNum);
$this->display();
//取总盈利率
private function setUcLogin($userId)
{
$user_data = uc_get_user(array('userName' => '', 'webId' => 0, 'userId' => $userId));
$ucData = $user_data['data'];
$userName = $ucData['user_name'];
uc_user_synlogin(array('userId' => $userId, 'userName' => $userName, 'nick' => '', 'webId' => $ucData['web_id']));
$this->setLogin(array('userId' => $userId, 'userName' => $userName));
$this->assign(array('user' => ['userID' => $userId, 'userName' => $userName, 'nick' => $ucData['nick']]));
}
private function getGonggao()
{
$gonggao = M('Gonggao')->where(['group_id' => PRIZE_GROUP_2021, 'view_flag' => 1])->order('add_time desc')->limit(5)->select();
return $gonggao;
}
//新首页
private function setMyData()
{
$userId = $this->user['userID'];
if ($userId) {
$myData = ['userId' => $userId, 'userName' => $this->user['userName'], 'nick' => $this->user['nick']];
$tid = $this->GID . 'X' . $userId;
//->cache(true,300)
$tData = M("userinfo", " ", C('DB_CONFIG_MNCG3'))->where(['uid' => $tid])->find();
if (!empty($tData)) {
$myData['lastweekup'] = $tData['lastweekup'];
$myData['monthzzl'] = $tData['monthzzl'];
$where = ['sex' => $this->GID, 'monthzzl' => ['gt', 0], 'lastweekup' => ['gt', 0], 'zt' => 1];
$weekData = M("userinfo", " ", C('DB_CONFIG_MNCG3'))->where($where)->order('lastweekup desc')->cache(true, 300)->select();
foreach ($weekData as $k => $v) {
if ($v['uid'] == $tid) {
$myData['weekPhb'] = $k + 1;
break;
}
}
}
$this->assign('myData', $myData);
}
}
public function choujiang()
{
//这个月剩余的抽奖机会
$leftCjNum = A('Vip/Public')->getLeftCjNum();
$this->assign('leftCjNum', $leftCjNum);
$this->display();
}
//周奖榜单页
public function phbWeek()
{
$p = I('p', 1);
$pageSize = 10;
$order = I('order', 'lastweekup');
$this->assign('order', $order);
$phb = $this->getPhb($p, $pageSize, $order);
$this->assign('weekPhb', $phb[0]);
$this->assign(['p' => $p, 'pageSize' => $pageSize, 'pages' => ceil($phb[1] / $pageSize), 'count' => $phb[1]]);
//大赛排行榜的当前排行页面
public function getPhb($p,$pageSize=10,$order){
$gid=$this->GID;
// $order=I('order','lastweekup');
// $pageSize=10;
// $pageSize=$gid==$this->GID?10:200;
if (IS_GET) {
//我的排名
$this->setMyData();
$this->display();
} else {
$content = $this->fetch('itemWeek');
$this->ajaxReturn(['status' => 1, 'count' => $phb[1], 'data' => $content]);
}
}
private function getPhb($p, $pageSize = 10, $order = '')
{
$gid = $this->GID;
//分表归档
$suffix = D('Userinfo')->getTable($gid);
$table =$suffix?'mncg_archive.userinfo'.$suffix:'mncg.userinfo';
$table = $suffix ? 'mncg_archive.userinfo' . $suffix : 'mncg.userinfo';
$where=['sex'=>$gid,'zt'=>1,'new_phb'=>['gt',0]];
if($order=='lastweekup'){
$where['lastweekup']=['gt',0];
$where['monthzzl']=['gt',0];
$where = ['sex' => $gid, 'zt' => 1, 'new_phb' => ['gt', 0]];
if ($order == 'lastweekup') {
$where['lastweekup'] = ['gt', 0];
$where['monthzzl'] = ['gt', 0];
}
//->cache(true,300)
$tDataList = M($table, " ", C('DB_CONFIG_MNCG3'))->field('uid,lastweekup,monthzzl,successup,zongup,lastdayup,lastmonthup')
->where($where)->order($order.' desc')->page($p.','.$pageSize)->select();
// var_dump(M($table, " ", C('DB_CONFIG_MNCG3'))->getLastSql());exit;
$uids =[];
$tDataList = M($table, " ", C('DB_CONFIG_MNCG3'))->field('uid,lastweekup,monthzzl,successup,zongup,lastdayup,lastmonthup')->where($where)->order($order . ' desc')->page($p . ',' . $pageSize)->select();
$uids = [];
foreach ($tDataList as $key => &$rankV) {
$userIDs = explode("X", $rankV['uid']);
$rankV['user_id'] = $userIDs[1];
$uids[] = $userIDs[1];
}
$nick_name_arry =getUser($uids,'nick');////
$nick_name_arry = getUser($uids, 'nick');
foreach ($tDataList as $key => &$value) {
$nick_name = $nick_name_arry[$value['user_id']];
......@@ -1224,182 +662,160 @@ class PkTopAction extends IdentityAction{
}
//总数目
$totalCount = M($table, " ", C('DB_CONFIG_MNCG3'))->where($where)->cache(true,300)->count();
return [$tDataList,$totalCount];
$totalCount = M($table, " ", C('DB_CONFIG_MNCG3'))->where($where)->cache(true, 300)->count();
return [$tDataList, $totalCount];
}
public function phbWeek() {
$p=I('p', 1);
$pageSize=10;
$order=I('order','lastweekup');
$this->assign('order',$order);
$phb=$this->getPhb($p,$pageSize,$order);
$this->assign('weekPhb',$phb[0]);
$this->assign(['p'=>$p,'pageSize'=>$pageSize,'pages'=>ceil($phb[1]/$pageSize),'count'=>$phb[1]]);
if(IS_GET){
//我的排名
$this->setMyData();
$this->display();
}else{
$content = $this->fetch('itemWeek');
$this->ajaxReturn(['status' => 1,'count' =>$phb[1],'data' => $content]);
}
}
public function phbOther() {
$p=I('p', 1);
$pageSize=10;
$order=I('order','zongup');
$this->assign('order',$order);
//盈利排行榜页
public function phbOther()
{
$p = I('p', 1);
$pageSize = 10;
$order = I('order', 'zongup');
$this->assign('order', $order);
$phb=$this->getPhb($p,$pageSize,$order);
$this->assign('otherPhb',$phb[0]);
$phb = $this->getPhb($p, $pageSize, $order);
$this->assign('otherPhb', $phb[0]);
$this->assign(['p'=>$p,'pageSize'=>$pageSize,'pages'=>ceil($phb[1]/$pageSize),'count'=>$phb[1]]);
$this->assign(['p' => $p, 'pageSize' => $pageSize, 'pages' => ceil($phb[1] / $pageSize), 'count' => $phb[1]]);
if(IS_GET){
if (IS_GET) {
//我的排名
$this->setMyData();
$this->display();
}else{
} else {
$content = $this->fetch('itemOther');
$this->ajaxReturn(['status' => 1,'count' =>$phb[1],'data' => $content]);
$this->ajaxReturn(['status' => 1, 'count' => $phb[1], 'data' => $content]);
}
}
//成员交易页面
public function phbTrade()
{
$p = I('p', 1);
$pageSize = 10;
$order = I('order', 0);
$gInfo = D('Group')->getGroup($this->GID);
public function setMyData(){
$userId = $this->user['userID'];
if($userId){
$myData=['userId'=>$userId,'userName'=>$this->user['userName'],'nick'=>$this->user['nick']];
$tid=$this->GID.'X'.$userId;
//->cache(true,300)
$tData = M("userinfo", " ", C('DB_CONFIG_MNCG3'))->where(['uid'=>$tid])->find();
if(!empty($tData)){
$myData['lastweekup']=$tData['lastweekup'];
$myData['monthzzl']=$tData['monthzzl'];
$where=['sex'=>$this->GID,'monthzzl'=>['gt',0],'lastweekup'=>['gt',0],'zt'=>1];
$weekData = M("userinfo", " ", C('DB_CONFIG_MNCG3'))->where($where)->order('lastweekup desc')->cache(true,300)->select();
foreach ($weekData as $k=>$v) {
if($v['uid']==$tid){
$myData['weekPhb']=$k+1;
break;
}
}
}
$this->assign('myData',$myData);
}
//查看前n名
$uids = [];
if ($order == 1) {
$phb = $this->getPhb(1, 1, 'lastweekup');
$uids = array_column($phb[0], 'uid');
}
//委托列表
public function phbTrade() {
$p=I('p', 1);
$pageSize=10;
$gInfo = D('Group')->getGroup($this->GID);
$phb=D('User')->getWtList($gInfo,$p,$pageSize);
$phb = D('User')->getWtList($gInfo, $p, $pageSize, $uids);
$wtList=$phb[0];
$wtList = $phb[0];
//取最新价
$stockHq=[];
$stockCodes=array_column($wtList,'stock_code');
$res = D('Stock')->stockQuotation(implode(',',$stockCodes),['type'=>1]);
$stockHq = [];
$stockCodes = array_column($wtList, 'stock_code');
$res = D('Stock')->stockQuotation(implode(',', $stockCodes), ['type' => 1]);
if (count($stockCodes) == 1) {
$typeCode=strtolower($wtList[0]['stock_type'].$stockCodes);
$stockHq[$typeCode]=$res;
}else{
$typeCode = strtolower($wtList[0]['stock_type'] . $stockCodes);
$stockHq[$typeCode] = $res;
} else {
$stockHq = $res;
}
foreach ($wtList as &$e) {
$stockCodeType = strtolower($e['stock_type'] . $e['stock_code']);
$quo = $stockHq[$stockCodeType];
if($quo){
$nowPrice=formatPrice(($quo['nowprice']>0?$quo['nowprice']:$quo['closePrice']));
$e['now_price'] =$nowPrice;
$e['zd'] =formatPrice(($nowPrice-$e['cj_price'])/$e['cj_price']*100,2).'%';
if ($quo) {
$nowPrice = formatPrice(($quo['nowprice'] > 0 ? $quo['nowprice'] : $quo['closePrice']));
$e['now_price'] = $nowPrice;
$e['zd'] = formatPrice(($nowPrice - $e['cj_price']) / $e['cj_price'] * 100, 2) . '%';
}
}
$nick_name_arry =getUser(array_column($wtList,'CD'),'nick');
$tids =array_column($wtList,'userid');
$tInfo = M("userinfo", " ", C('DB_CONFIG_MNCG3'))->where(['uid'=>['in',$tids]])->cache(true,60)->getField('uid,new_phb,zongup');
$nick_name_arry = getUser(array_column($wtList, 'CD'), 'nick');
$tids = array_column($wtList, 'userid');
$tInfo = M("userinfo", " ", C('DB_CONFIG_MNCG3'))->where(['uid' => ['in', $tids]])->cache(true, 60)->getField('uid,new_phb,zongup');
foreach ($wtList as &$n) {
$nick_name = $nick_name_arry[$n['CD']];
$n['username'] = $nick_name;
$n['cj_time']=substr($n['cj_time'],11,8);
$n['entrust_bs']=$n['entrust_bs']=='r'?'买入':'卖出';
$n['price'] =number_format($n['price'],2,'.','');
$n['cj_price'] =number_format($n['cj_price'],2,'.','');
$n['cj_time'] = substr($n['cj_time'], 11, 8);
$n['entrust_bs'] = $n['entrust_bs'] == 'r' ? '买入' : '卖出';
$n['price'] = number_format($n['price'], 2, '.', '');
$n['cj_price'] = number_format($n['cj_price'], 2, '.', '');
//大赛排名和总盈利率
$n['phb']=$tInfo[$n['userid']]['new_phb'];
$n['zongup']=$tInfo[$n['userid']]['zongup'];
$n['phb'] = $tInfo[$n['userid']]['new_phb'];
$n['zongup'] = $tInfo[$n['userid']]['zongup'];
//点击用户名和股票名跳转需要的参数
$n['goTradeInfo'] =$this->setGoTrade($gInfo,$n['CD'],$nick_name,2);
$n['StockTrade'] = json_encode(['name'=>$n['stock_name'],'code'=>$n['stock_code'],
'market'=>$n['stock_type'],'zqlb'=>$n['zqlb']]);
}
$this->assign('wtList',$wtList);
$this->assign(['p'=>$p,'pageSize'=>$pageSize,'pages'=>ceil($phb[1]/$pageSize),'count'=>$phb[1]]);
if(IS_GET){
$n['goTradeInfo'] = $this->setGoTrade($gInfo, $n['CD'], $nick_name, 2);
$n['StockTrade'] = json_encode(['name' => $n['stock_name'], 'code' => $n['stock_code'], 'market' => $n['stock_type'], 'zqlb' => $n['zqlb']]);
}
$this->assign([
'p' => $p,
'pageSize' => $pageSize,
'pages' => ceil($phb[1] / $pageSize),
'count' => $phb[1],
'order' => $order,
'wtList'=> $wtList
]);
if (IS_GET) {
//我的排名
$this->setMyData();
$this->display();
}else{
} else {
$content = $this->fetch('itemTrade');
$this->ajaxReturn(['status' => 1,'count' =>$phb[1],'data' => $content]);
$this->ajaxReturn(['status' => 1, 'count' => $phb[1], 'data' => $content]);
}
}
//进入交易需要的参数,可能跳转到他人主页
public function setGoTrade($gInfo,$userId,$userName,$jump) {
//委托列表
public function setGoTrade($gInfo, $userId, $userName, $jump)
{
//非特殊大赛
if($gInfo['type']!=1){
$goTradeInfo=['group_id'=>$gInfo['group_id'],'web_id'=>$gInfo['web_id'],'category'=>$gInfo['category'],
'name'=>$gInfo['name']];
$groupStatus=$gInfo['startTime']>time()?'1': (is_end($gInfo['endTime'])?'3':'2');
if ($gInfo['type'] != 1) {
$goTradeInfo = ['group_id' => $gInfo['group_id'], 'web_id' => $gInfo['web_id'], 'category' => $gInfo['category'], 'name' => $gInfo['name']];
$groupStatus = $gInfo['startTime'] > time() ? '1' : (is_end($gInfo['endTime']) ? '3' : '2');
$goTradeInfo['groupStatus'] = $groupStatus;
$goTradeInfo['zhuangtai'] = $gInfo['startTime']>time()?'未开始': (is_end($gInfo['endTime'])?'已结束':'进行中');
$goTradeInfo['statusInt'] =$groupStatus;
$goTradeInfo['zhuangtai'] = $gInfo['startTime'] > time() ? '未开始' : (is_end($gInfo['endTime']) ? '已结束' : '进行中');
$goTradeInfo['statusInt'] = $groupStatus;
}
$goTradeInfo['userID']=$userId;
$goTradeInfo['userName']=$userName;
$goTradeInfo['userID'] = $userId;
$goTradeInfo['userName'] = $userName;
if(in_array($gInfo["category"],[1,9])){
$goTradeInfo['viewPage']=1;
if (in_array($gInfo["category"], [1, 9])) {
$goTradeInfo['viewPage'] = 1;
}
if(in_array($gInfo["category"],[3,4,6,7])){
$goTradeInfo['viewPage']=2;
if (in_array($gInfo["category"], [3, 4, 6, 7])) {
$goTradeInfo['viewPage'] = 2;
}
if(in_array($gInfo["category"],[2,5])){
$goTradeInfo['viewPage']=3;
if (in_array($gInfo["category"], [2, 5])) {
$goTradeInfo['viewPage'] = 3;
}
if(in_array($gInfo["category"],[8])){
$user_agent = explode('cofool/',$_SERVER['HTTP_USER_AGENT']);
$version = $user_agent[1];
$goTradeInfo['viewPage']=checkVersion('>=','3.7.1',$version,'' )?1:2;
if (in_array($gInfo["category"], [8])) {
$user_agent = explode('cofool/', $_SERVER['HTTP_USER_AGENT']);
$version = $user_agent[1];
$goTradeInfo['viewPage'] = checkVersion('>=', '3.7.1', $version, '') ? 1 : 2;
}
//2到个人主页,1是交易区
$goTradeInfo['jump']=$jump;
$goTradeInfo['jump'] = $jump;
return json_encode($goTradeInfo);
// $this->assign('goTradeInfo',json_encode($goTradeInfo));
}
//进入交易需要的参数,可能跳转到他人主页
private function getZongup()
{
$suffix = D('Userinfo')->getTable($this->GID);
$table = $suffix ? 'mncg_archive.userinfo' . $suffix : 'mncg.userinfo';
$userInfoData = M($table, " ", C('DB_CONFIG_MNCG3'))->where(array('sex' => $this->GID))->getField('uid,zongup');
$zongupData = array();
foreach ($userInfoData as $k => $v1) {
$tmpId = str_replace($this->GID . 'X', '', $k);
$zongupData[$tmpId] = $v1;
}
return $zongupData;
}
}
?>
......
<?php
class UserModel extends Model{
//默认表
public $trueTableName = "cofool_user";
//切换表
public function selTable($table = 'user'){
$TableName = "cofool_".$table;
$this->trueTableName = $TableName;
}
//获取用户基本信息
public function getUserInfo($where = '',$field = "*",$table = 'cofool_user',$limit = ''){
$this->trueTableName = $table;
if(!$where){
$userInfo = $this->field($field)->limit($limit)->order('rand()')->select();
}else{
$userInfo = $this->field($field)->where($where)->limit($limit)->order('rand()')->select();
}
return $userInfo;
}
//获取用户基本信息
public function getUserFind($where = '',$field = "*",$table = 'cofool_user'){
$this->trueTableName = $table;
if(!$where){
$userInfo = $this->field($field)->find();
}else{
$userInfo = $this->field($field)->where($where)->find();
}
return $userInfo;
}
public function isMyFriend($userID,$user_id){
if(!$userID || !$user_id){
return false;
}
$r = M('Friend')->where(array('user_id'=>$userID,'friend_user_id'=>$user_id))->find();
return !empty($r) ? 1 : 0;
}
public function isMyConcern($userID,$user_id){
if(!$userID || !$user_id){
return false;
}
$r = M('Concern')->where(array('concern_user_id'=>$userID,'user_id'=>$user_id))->find();
return !empty($r) ? $r['concern_user_id'] : 0;
}
class UserModel extends Model
{
//默认表
public $trueTableName = "cofool_user";
//切换表
public function selTable($table = 'user')
{
$TableName = "cofool_" . $table;
$this->trueTableName = $TableName;
}
//获取用户基本信息
public function getUserInfo($where = '', $field = "*", $table = 'cofool_user', $limit = '')
{
$this->trueTableName = $table;
if (!$where) {
$userInfo = $this->field($field)->limit($limit)->order('rand()')->select();
} else {
$userInfo = $this->field($field)->where($where)->limit($limit)->order('rand()')->select();
}
return $userInfo;
}
//获取用户基本信息
public function getUserFind($where = '', $field = "*", $table = 'cofool_user')
{
$this->trueTableName = $table;
if (!$where) {
$userInfo = $this->field($field)->find();
} else {
$userInfo = $this->field($field)->where($where)->find();
}
return $userInfo;
}
public function isMyFriend($userID, $user_id)
{
if (!$userID || !$user_id) {
return false;
}
$r = M('Friend')->where(array('user_id' => $userID, 'friend_user_id' => $user_id))->find();
return !empty($r) ? 1 : 0;
}
public function isMyConcern($userID, $user_id)
{
if (!$userID || !$user_id) {
return false;
}
$r = M('Concern')->where(array('concern_user_id' => $userID, 'user_id' => $user_id))->find();
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);
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'=>'【全民分赛场】报名奖励红包'];
$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');
$aid=$aid?$aid:5420972;
if($aid){
$ucA = uc_get_user(['userId' => $aid,'type' => 3]);
public function addInvite($userIdB, $userNameB)
{
$aid = cookie('aid');
$aid = $aid ? $aid : 5420972;
if ($aid) {
$ucA = uc_get_user(['userId' => $aid, 'type' => 3]);
$ucDataA = $ucA['data'];
$userNameA=$ucDataA['user_name'];
$userNameA = $ucDataA['user_name'];
//检查被邀请人是否被邀请过
$oldB=M('WalletInvite')->where(['user_id_b'=>$userIdB,'status'=>1])->count();
if($oldB){
$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{
M('WalletInvite')->where(['user_id_b'=>$userIdB,'status'=>0])->delete();
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 {
M('WalletInvite')->where(['user_id_b' => $userIdB, 'status' => 0])->delete();
//status0报名未审核,1审核通过已报名状态
M('WalletInvite')->add(['user_id_a'=>$aid,'user_name_a'=>$userNameA,'user_id_b'=>$userIdB,
'user_name_b'=>$userNameB,'status'=>0,'add_time'=>time(),'group_id'=>PRIZE_GROUP_2021]);
M('WalletInvite')->add(['user_id_a' => $aid, 'user_name_a' => $userNameA, 'user_id_b' => $userIdB, 'user_name_b' => $userNameB, 'status' => 0, 'add_time' => time(), 'group_id' => PRIZE_GROUP_2021]);
//邀请人加1.88元
//被邀请人有交易后再加1.88元
......@@ -103,93 +111,98 @@ class UserModel extends Model{
}
//从委托表和历史委托表取委托数据
public function getWtList($gInfo,$p=1,$pageSize=10) {
public function getWtList($gInfo, $p = 1, $pageSize = 10, $uids = [])
{
// if($userList===0){
// $userList=$this->getUserList($gInfo);
// }
$gid=$gInfo['teamid'];
$gid = $gInfo['teamid'];
// $phbs=array_column($userList,'new_phb','uid');
// var_dump($userList);;
// var_dump($phbs);exit;
$db=M()->db(11,getModel($gInfo['web_id']));
$where=['bz'=>$gid,'status'=>'已成'];
$db = M()->db(11, getModel($gInfo['web_id']));
$where = ['bz' => $gid, 'status' => '已成'];
if (!empty($uids)) {
$where['userid'] = ['in', $uids];
}
$suffix = D('Userinfo')->getTable($gid);
$hisTable=$suffix?'mncg_archive.hisentrust'.$suffix:'mncg.hisentrust';
if($suffix){
$entrustList = $db->table($hisTable)->where($where)->order('cj_time desc')->cache(true,3600)->page($p.','.$pageSize)->select();
$total= $db->table($hisTable)->where($where)->cache(true,3600)->count();
$hisTable = $suffix ? 'mncg_archive.hisentrust' . $suffix : 'mncg.hisentrust';
if ($suffix) {
$entrustList = $db->table($hisTable)->where($where)->order('cj_time desc')->cache(true, 3600)->page($p . ',' . $pageSize)->select();
$total = $db->table($hisTable)->where($where)->cache(true, 3600)->count();
// $userNum = $db->table($hisTable)->where($where)->cache(true,3600)->count('distinct userid');
}else{
if($p == 1){
} else {
if ($p == 1) {
$count = $db->table('entrust')->where($where)->count();
$page = ceil($count/$pageSize);
$limit = $count%$pageSize;
$memcache_data = ['count'=>$count,'page'=>max($page,1),'limit'=>$limit];
S($gid.'_part_page',$memcache_data,7200);
$page = ceil($count / $pageSize);
$limit = $count % $pageSize;
$memcache_data = ['count' => $count, 'page' => max($page, 1), 'limit' => $limit];
S($gid . '_part_page', $memcache_data, 7200);
}
// var_dump('a'.$page);exit;
$cache = S($gid.'_part_page');
if(isset($cache['count'])){
$cache = S($gid . '_part_page');
if (isset($cache['count'])) {
$page = intval($cache['page']);
$limit = intval($cache['limit']);
// $count = intval($cache['count']);
// var_dump($page);exit;
if($p<$page){
$entrustList = $db->table('entrust')->where($where)->order('cj_time desc')->cache(true,60)->page($p.','.$pageSize)->select();
if ($p < $page) {
$entrustList = $db->table('entrust')->where($where)->order('cj_time desc')->cache(true, 60)->page($p . ',' . $pageSize)->select();
}
if($p==$page){
$entrustList = $db->table('entrust')->where($where)->order('cj_time desc')->cache(true,60)->page($p.','.$pageSize)->select();
if(empty($entrustList)){
$entrustList = $db->table($hisTable)->where($where)->order('cj_time desc')->cache(true,60)->page($p.','.$pageSize)->select();
}else{
if($limit){
$start=0;
$pageSize= $pageSize-$limit;
$hisList = $db->table($hisTable)->where($where)->order('cj_time desc')->cache(true,60)->limit($start.','.$pageSize)->select();
if(!empty($hisList)){
$entrustList = array_merge((array)$entrustList,$hisList);
if ($p == $page) {
$entrustList = $db->table('entrust')->where($where)->order('cj_time desc')->cache(true, 60)->page($p . ',' . $pageSize)->select();
if (empty($entrustList)) {
$entrustList = $db->table($hisTable)->where($where)->order('cj_time desc')->cache(true, 60)->page($p . ',' . $pageSize)->select();
} else {
if ($limit) {
$start = 0;
$pageSize = $pageSize - $limit;
$hisList = $db->table($hisTable)->where($where)->order('cj_time desc')->cache(true, 60)->limit($start . ',' . $pageSize)->select();
if (!empty($hisList)) {
$entrustList = array_merge((array)$entrustList, $hisList);
}
}
}
}
if($p>$page){
$start=($p-$page)*$pageSize-$limit;
$entrustList = $db->table($hisTable)->where($where)->order('cj_time desc')->cache(true,60)->limit($start.','.$pageSize)->select();
if ($p > $page) {
$start = ($p - $page) * $pageSize - $limit;
$entrustList = $db->table($hisTable)->where($where)->order('cj_time desc')->cache(true, 60)->limit($start . ',' . $pageSize)->select();
}
$total= $db->table('entrust')->where($where)->count();
$hisTotal= $db->table($hisTable)->where($where)->cache(true,60)->count();
$total=intval($total)+intval($hisTotal);
$total = $db->table('entrust')->where($where)->count();
$hisTotal = $db->table($hisTable)->where($where)->cache(true, 60)->count();
$total = intval($total) + intval($hisTotal);
}
}
return [$entrustList,$total?$total:0];
return [$entrustList, $total ? $total : 0];
}
//完成勋章,只有参赛勋章
public function finishXunzhang($userId,$userName,$mobile,$xzType) {
$level=M('XunzhangLevel')->where(['user_id'=>$userId])->getField('level');
if(!$level){
public function finishXunzhang($userId, $userName, $mobile, $xzType)
{
$level = M('XunzhangLevel')->where(['user_id' => $userId])->getField('level');
if (!$level) {
return;
}
$xzData=M('Xunzhang')->where(['xz_type'=>$xzType])->find();
$xzid=$xzData['xz_id'];
if($level!=$xzData['xz_level']){
$xzData = M('Xunzhang')->where(['xz_type' => $xzType])->find();
$xzid = $xzData['xz_id'];
if ($level != $xzData['xz_level']) {
return;
}
$old=M('XunzhangUser')->where(['user_id'=>$userId,'xz_id'=>$xzid])->count();
if(!$old){
$addData=['user_id'=>$userId,'user_name'=>$userName,'xz_id'=>$xzid,'mobile'=>$mobile];
$addData['add_time']=$addData['finish1_time']=$addData['finish2_time']=time();
$old = M('XunzhangUser')->where(['user_id' => $userId, 'xz_id' => $xzid])->count();
if (!$old) {
$addData = ['user_id' => $userId, 'user_name' => $userName, 'xz_id' => $xzid, 'mobile' => $mobile];
$addData['add_time'] = $addData['finish1_time'] = $addData['finish2_time'] = time();
//直接打开百宝箱,防止重复领取1.88元
$addData['openbox_time']=time();
$addData['openbox_time'] = time();
M('XunzhangUser')->add($addData);
}
}
}
?>
\ No newline at end of file
......@@ -53,19 +53,18 @@
<include file="myItem"/>
<div class="award-cont">
<div class="award-tab-btn">
<div class="btn "><a href="/PkTop/phbWeek">周奖榜单</a></div>
<div class="btn"><a href="/PkTop/phbWeek">周奖榜单</a></div>
<div class="btn"><a href="/PkTop/phbOther">其它排行</a></div>
<div class="btn active"><a href="/PkTop/phbTrade">成员交易</a></div>
</div>
<div class="award-tab-panel" >
<div class="award-tab-panel">
<div class="item-filter">
<span class="">全部</span><span class="active">只看前100名</span>
<span class="<eq name="order" value="0">active</eq>"><a href="/PkTop/phbTrade?order=0">全部</a></span>
<span class="<eq name="order" value="1">active</eq>"><a href="/PkTop/phbTrade?order=1">只看前100名</a></span>
</div>
<div class="panel-item" id="container" >
<include file="itemTrade"/>
</div>
<gt name="count" value="2">
<div style="padding: 10px 15px 0px;text-align:center;font-size: 14px;"
currPage="1" totalPage='{$pages}' id="loadBtn">
......@@ -74,16 +73,10 @@
<p class="loading l_3" style="display: none;" id="no_content"><span class="txt">没有更多用户了</span></p>
</div>
</gt>
</div>
</div>
</div>
</div>
</div>
<include file="bottom"/>
......@@ -121,7 +114,6 @@
//点加载更多按钮
$(".loading.l_2").click(function(){
// $(".l_2").hide();
var totalPage = $("#loadBtn").attr("totalPage");
var currPage = $("#loadBtn").attr("currPage");
......@@ -132,18 +124,14 @@
$(".l_2").hide();
$(".l_3").show();
return;
} else {
}
order='{$order}';
$.post('/PkTop/phbTrade',{p:nextPage,'order':order,'debug':'scroll'},function(e){
$(".l_1").hide();
if(nextPage>=parseInt(totalPage)) {
// $(".l_2").hide();
$(".l_3").show();
lastPage = 1;
} else {
// $(".l_2").show();
$(".l_1").show();
}
if(e.status == 0) {layer.alert(e.info, 8);return false;}
......@@ -156,8 +144,8 @@
$('.item-filter span').each(function(i,obj){
$(obj).click(function(){
$(this).siblings().removeClass('active');
$(this).addClass('active');
$(this).siblings().removeClass('active')
$(this).addClass('active')
})
})
});
......
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