diff --git a/Application/Home/Controller/DownloadController.class.php b/Application/Home/Controller/DownloadController.class.php index a271b502a..8ffbd1820 100644 --- a/Application/Home/Controller/DownloadController.class.php +++ b/Application/Home/Controller/DownloadController.class.php @@ -2774,23 +2774,29 @@ class DownloadController extends BaseController { ->buildSql(); unset($map['begintime']); unset($map['endtime']); - $roles = M('user_play_info', 'tab_') - ->field("*,$sqlCost as cost,$sqlCount as count,$sqlTodayCost as today_cost") - ->where($map) - ->order('play_time desc') - ->select(); - foreach ($roles as $role) { + $subQuery = M('user_play_info', 'tab_') + ->field("*,$sqlCost as recharge_cost,$sqlCount as recharge_count,$sqlTodayCost as recharge_cost_today") + ->where($map) + ->having('recharge_cost > 0') + ->order('play_time desc') + ->buildSql(); + $roles = M()->field(' * ') + ->table($subQuery) + ->alias('a') + ->order('play_time desc') + ->select(); + foreach ($roles as $role) { $records[] = [ - 'user_account' => $role['user_account'], + 'user_account' => encryption($role['user_account']), 'game_name' => $role['game_name'], 'role_name' => $role['role_name'], 'role_id' => $role['role_id'], 'role_level' => $role['role_level'], 'server_id' => $role['server_id'], 'server_name' => $role['server_name'], - 'recharge_cost' => $role['cost'], - 'recharge_count' => $role['count'], - 'recharge_cost_today' => $role['cost_today'], + 'recharge_cost' => empty($role['recharge_cost']) ? 0 : $role['recharge_cost'], + 'recharge_count' => empty($role['recharge_count']) ? 0 : $role['recharge_count'], + 'recharge_cost_today' => empty($role['recharge_cost_today']) ? 0 : $role['recharge_cost_today'], 'play_time' => $role['play_time'], 'play_ip' => $role['play_ip'], 'promote_id' => $role['promote_id'], diff --git a/Application/Home/Controller/PromoteController.class.php b/Application/Home/Controller/PromoteController.class.php index d3858aa4b..0335835b6 100644 --- a/Application/Home/Controller/PromoteController.class.php +++ b/Application/Home/Controller/PromoteController.class.php @@ -180,14 +180,14 @@ class PromoteController extends BaseController $month_add_user_money = $this->pay_total(3, 1, $promoteId); $yesterday_start = mktime(0, 0, 0, date('m'), date('d') - 1, date('Y')); - $yesterday_end = mktime(0, 0, 0, date('m'), date('d'), date('Y')); + $yesterday_end = mktime(0, 0, 0, date('m'), date('d'), date('Y'))-1; //计算昨天用户的统计数据,当日用户充值数据 $pay_time = " between {$yesterday_start} and {$yesterday_end}"; $createTime = ['between', array($yesterday_start, $yesterday_end - 1)]; - $yesterdaySpendData = $this->caculateSpend($pay_time, [], $createTime); +// $yesterdaySpendData = $this->caculateSpend($pay_time, []); +// var_dump($yesterdaySpendData);die(); $todayAddSpendData = $this->caculateSpend($pay_time, [], [], 1); -// var_dump($todayAddSpendData);die(); $mounthAddSpendData = $this->caculateSpend($pay_time, [], [], 2); @@ -209,7 +209,7 @@ class PromoteController extends BaseController $this->assign('data', $data); // $this->assign('yesterdayData',$yesterdayData); $this->assign('spendData', $spendData); - $this->assign('yesterdaySpendData', $yesterdaySpendData); +// $this->assign('yesterdaySpendData', $yesterdaySpendData); $this->assign('todayAddSpendData', $todayAddSpendData); $this->assign('mounthAddSpendData', $mounthAddSpendData); @@ -240,99 +240,131 @@ class PromoteController extends BaseController private function caculateSpend($pay_time, $condition, $create = [], $type = 0) { + $map1['promote_id'] = $map['promote_id'] = array('egt', 0); $spend = M('Spend', 'tab_'); + $map1['pay_status'] = $map['pay_status'] = 1; $today = total(1); + $yesterday = total(5); $week = total(2); $mounth = total(3); - $yesterday = total(5); + unset( $map['create_time']); - $map1['promote_id'] = $map['promote_id'] = array('gt', 0); - $map1['pay_status'] = $map['pay_status'] = 1; - $map1['pay_way'] = $map['pay_way'] = array('gt', 0); - $userId = []; - $this->getLoginPromote(); + $promote_id = get_pid(); $promoteId = M("promote", "tab_") - ->where(array('chain' => ['like', $this->loginPromote['chain'] . $this->loginPromote['id'] . '/%'])) - ->getField('id', true); - $promoteId[] = $this->loginPromote['id']; + ->field("id") + ->where(array('chain' => ['like', '/'.$promote_id . '/%'],'id'=>$promote_id,'_logic'=>'or')) + ->select(); + $promoteId = implode(',',array_column($promoteId,'id')); + $whereUser['promote_id'] = ['IN', $promoteId]; if ($type == 1) { + $pay_time = total(1); $start = mktime(0, 0, 0, date('m'), date('d'), date('Y')); $end = mktime(0, 0, 0, date('m'), date('d') + 1, date('Y')) - 1; $whereUser['register_time'] = ['between', array($start, $end - 1)]; $userId = M('user', 'tab_')->field('id')->where($whereUser)->select(); } else if ($type == 2) { + $pay_time = total(3); $start = mktime(0, 0, 0, date('m'), 1, date('Y')); $end = mktime(0, 0, 0, date('m') + 1, 1, date('Y')) - 1; $whereUser['register_time'] = ['between', array($start, $end - 1)]; $userId = M('user', 'tab_')->field('id')->where($whereUser)->select(); } +// if ($userId) { +// var_dump($userId); +// } - $userId = implode(',', array_column($userId, 'id')); if ($userId) { + + $userId = implode(',', array_column($userId, 'id')); +// var_dump($userId); $map1['user_id'] = $map['user_id'] = ['IN', $userId]; } else if (!$userId && $type != 0) { - return array('today' => 0, 'mounth' => 0); - } - - if ($create) { - $map['create_time'] = $create; - } - - - $bindrecharge_data = M('bind_recharge', 'tab_') - ->field('max(id) as id,promote_account,promote_id,create_time as ordertime,date_format(FROM_UNIXTIME(create_time),"%Y-%m-%d") AS time, - floor(sum(IF(create_time ' . $pay_time . ',real_amount,0))*100) as scount, - floor(sum(IF(create_time ' . $today . ',real_amount,0))*100) as today, - floor(sum(IF(create_time ' . $week . ',real_amount,0))*100) as week, - floor(sum(IF(create_time ' . $mounth . ',real_amount,0))*100) as mounth') - ->where($map1) - ->group('promote_id') - ->select(false); - - $deposit_data = M('deposit', 'tab_') - ->field('max(id) as id,promote_account,promote_id,create_time as ordertime,date_format(FROM_UNIXTIME(create_time),"%Y-%m-%d") AS time, - floor(sum(IF(create_time ' . $pay_time . ',pay_amount,0))*100) as scount, - floor(sum(IF(create_time ' . $today . ',pay_amount,0))*100) as today, - floor(sum(IF(create_time ' . $week . ',pay_amount,0))*100) as week, - floor(sum(IF(create_time ' . $mounth . ',pay_amount,0))*100) as mounth') - ->where($map1) - ->group('promote_id') - ->select(false); - - $spendData = $spend - ->field('max(id) as id,promote_account,promote_id,pay_time as ordertime,date_format(FROM_UNIXTIME(pay_time),"%Y-%m-%d") AS time, - floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as scount, - floor(sum(IF(pay_time ' . $today . ',pay_amount,0))*100) as today, - floor(sum(IF(pay_time ' . $week . ',pay_amount,0))*100) as week, - floor(sum(IF(pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') - ->where($map) - ->union(' (' . $bindrecharge_data . ') ') - ->union(' (' . $deposit_data . ') ') - ->group('promote_id') - ->select(false); + return array('sum_mounth' => 0, 'sum_today' => 0); + } - $promote_id = get_pid(); - $promote_map = "tp1.`id` = {$promote_id}"; + //获取所有会长 + $promote_map = "`chain` = '%/{$promote_id}/%' OR id = {$promote_id}"; - $data = $spend->field('sum(a.scount) AS count,sum(a.today) AS today,sum(a. WEEK) AS WEEK,sum(a.mounth) AS mounth') - ->join("INNER JOIN (SELECT tp2.*, tp1.id AS pid, tp1.account as promote_account FROM tab_promote tp1 LEFT JOIN tab_promote tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp1.id = tp2.id where $promote_map ) AS t ON promote_id = t.id") - ->where($condition)->table('(' . $spendData . ') as a')->group()->order('count desc,a.ordertime')->find(); + $promote = M("promote","tab_")->field("id,account")->where($promote_map)->select(); + $data =array(); + for ($i=0; $i < count($promote); $i++) { + # code... + $proid = M("promote","tab_")->field("id")->where("`chain` like '%/{$promote[$i]['id']}/%'")->select(); + $str = ''; + for($k=0; $kfield(' + floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as count, + floor(sum(IF(pay_time ' . $today . ',pay_amount,0))*100) as today, + floor(sum(IF(pay_time ' . $yesterday . ',pay_amount,0))*100) as yesterday, + floor(sum(IF(pay_time ' . $week . ',pay_amount,0))*100) as week, + floor(sum(IF(pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') + ->where($map) + ->where("pay_time".$pay_time) + ->find(); + $dbdata['promote_account'] = $promote[$i]['account']; + } else { + $dbdata = $spend + ->field(' + floor(sum(IF(pay_time ' . $pay_time . ',pay_amount,0))*100) as count, + floor(sum(IF(pay_time ' . $today . ',pay_amount,0))*100) as today, + floor(sum(IF(pay_time ' . $yesterday . ',pay_amount,0))*100) as yesterday, + floor(sum(IF(pay_time ' . $week . ',pay_amount,0))*100) as week, + floor(sum(IF(pay_time ' . $mounth . ',pay_amount,0))*100) as mounth') + ->where($map) + ->where("pay_time".$pay_time) + ->find(); + $dbdata['promote_account'] = $promote[$i]['account']; + } + $data[] = $dbdata; + } +// if ($userId) { +// echo $spend->_sql();die(); +// } + foreach ($data as $key => $value) { + $value['count'] ?: 0; + $value['today'] ?: 0; + $value['week'] ?: 0; + $value['mounth'] ?: 0; + static $i = 0; + $i++; + $data[$key]['rand'] = $i; + $data[$key]['count'] = $value['count'] / 100; + $data[$key]['today'] = $value['today'] / 100; + $data[$key]['yesterday'] = $value['yesterday'] / 100; + $data[$key]['week'] = $value['week'] / 100; + $data[$key]['mounth'] = $value['mounth'] / 100; + } + $total = $this->data_total($data); - $spendData1 = $spend->field('sum(a.scount) AS count,sum(a.today) AS today,sum(a. WEEK) AS WEEK,sum(a.mounth) AS mounth') -// ->join("INNER JOIN (SELECT tp2.*, tp1.id AS pid, tp1.account as promote_account FROM tab_promote tp1 LEFT JOIN tab_promote tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') ) AS t ON promote_id = t.id") - ->where($condition)->table('(' . $spendData . ') as a')->group()->order('count desc,a.ordertime')->find(); + return $total; +// - $data['rand'] = 1; - $data['count'] = $data['count'] / 100; - $data['today'] = $spendData1['today'] / 100; - $data['week'] = $spendData1['week'] / 100; - $data['mounth'] = $spendData1['mounth'] / 100; + } - return $data; + public function data_total($data) + { + $total['sum_count'] = array_sum(array_column($data, 'count')); + $total['sum_today'] = array_sum(array_column($data, 'today')); + $total['yesterday'] = array_sum(array_column($data, 'yesterday')); + $total['sum_week'] = array_sum(array_column($data, 'week')); + $total['sum_mounth'] = array_sum(array_column($data, 'mounth')); + return $total; } private function pay_total($type = 0, $newadd = 1, $promoteId = "") diff --git a/Application/Home/Controller/SafeController.class.php b/Application/Home/Controller/SafeController.class.php index f411f529a..260dc2c8c 100644 --- a/Application/Home/Controller/SafeController.class.php +++ b/Application/Home/Controller/SafeController.class.php @@ -443,38 +443,13 @@ class SafeController extends BaseController{ public function safeDocument() { $time = time(); - $today = date('Y-m-d'); - $username = $_REQUEST['username']; - $tsession =S($today); - if(S($username)) { - $code = S($username); - }else { - if(!empty($tsession)) { - $num = $tsession + 1; - }else { - $num = 1; - } - $promoteRs = M('promote','tab_')->where(['account'=>$username])->getField('create_time',true); - $code = date('Ymd',$promoteRs[0])."_".$num; - } + $loginPromote = $this->getLoginPromote(); + $sn = date('Ymd') . '-' . strtoupper(substr(md5($loginPromote['id']), 8, 16)); $endTime = date('Y-m-d',strtotime('+1 year')); $this->assign('time',date('Y-m-d',$time)); $this->assign('endTime',$endTime); - $this->assign('code',$code); - $this->assign('username',$username); + $this->assign('sn',$sn); $this->display(); } - - public function ajaxAgree() { - $username = $_REQUEST['username']; - $code = $_REQUEST['code']; - $today = date('Y-m-d'); - if(empty(S($username))) { - S($username, $code); - $t = S($today); - S($today,$t+1); - } - $this->ajaxReturn(['code'=>10000]); - } } \ No newline at end of file diff --git a/Application/Home/View/default/Promote/index.html b/Application/Home/View/default/Promote/index.html index eeeb5b479..0c550f33c 100644 --- a/Application/Home/View/default/Promote/index.html +++ b/Application/Home/View/default/Promote/index.html @@ -6,15 +6,15 @@
diff --git a/Application/Home/View/default/Safe/safeDocument.html b/Application/Home/View/default/Safe/safeDocument.html index a2f05aaf3..3395e8ae0 100644 --- a/Application/Home/View/default/Safe/safeDocument.html +++ b/Application/Home/View/default/Safe/safeDocument.html @@ -51,7 +51,7 @@ and open the template in the editor.

游戏推广服务框架协议

本协议由以下双方于{$time}签订:

-

合同编号:{$code}

+

合同编号:{$sn}

甲方:海南万盟天下科技有限公司

注册地址:海南省海口市南海大道26号海口国家高新区创业孵化中心A楼5层A1-1268室

联系电话:13067391751

@@ -237,8 +237,6 @@ and open the template in the editor.
- -







@@ -247,20 +245,10 @@ and open the template in the editor. $(function() { - var username = document.getElementById('us').value; - var code = document.getElementById('code').value; $("#ag").on('click',function(event) { - $.ajax({ - type:"POST", - url:"{:U('Safe/ajaxAgree')}", - data:{'username':username,'code':code}, - dataType:'json', - success:function(res) { - window.localStorage.setItem('checked','checked'); - window.history.back(-1); - } - }); - }) + window.localStorage.setItem('checked','checked'); + window.location.href = "/index.php?s=/Home/Safe/modifyBaseInfo.html" + }); }) diff --git a/Data/update.sql b/Data/update.sql index ceea135f4..c12879640 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -536,7 +536,7 @@ CREATE TABLE `tab_idcard_log` ( `id_card` varchar(20) NOT NULL COMMENT '身份证号码', `user_id` int(11) NOT NULL COMMENT '用户id', `ip` varchar(40) DEFAULT '0' COMMENT 'ip地址', - `num` int(11) DEFAULT '1' COMMENT '错误次数', + `num` int(11) DEFAULT '1' COMMENT '认证次数', `status` tinyint(2) DEFAULT '0' COMMENT '0 认证失败 1 认证成功', `create_time` int(11) DEFAULT '0' COMMENT '创建时间', PRIMARY KEY (`id`)