From 0443871173f07aab1ac54a15b2205148c1d0c2a6 Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Mon, 2 Mar 2020 14:13:04 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E5=8E=BB=E9=99=A4=E9=87=8D=E5=A4=8D=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/MemberController.class.php | 53 ++++++++++++++++--- Application/Admin/View/Member/user_info.html | 9 ++-- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/Application/Admin/Controller/MemberController.class.php b/Application/Admin/Controller/MemberController.class.php index e72abb880..fdc499589 100644 --- a/Application/Admin/Controller/MemberController.class.php +++ b/Application/Admin/Controller/MemberController.class.php @@ -132,14 +132,12 @@ class MemberController extends ThinkController //计算用户列表 $data = M("user","tab_") - ->field("tab_user.id,`device_number`,`age_status`,`account`,`balance`,`gold_coin`,`alipay`,tab_user.promote_id,`register_type`,tab_user.promote_account,`register_time`,`lock_status`,lock_remark,`register_way`,`register_ip`,`login_time`,`check_status`,IFNULL(sum(ss.pay_amount), 0) AS recharge_total") + ->field("tab_user.id,`device_number`,count(`device_number`) as device_count,`age_status`,`account`,`balance`,`gold_coin`,`alipay`,tab_user.promote_id,`register_type`,tab_user.promote_account,`register_time`,`lock_status`,lock_remark,`register_way`,`register_ip`,`login_time`,`check_status`,IFNULL(sum(ss.pay_amount), 0) AS recharge_total") ->where($map) - ->group("tab_user.id") + ->group("tab_user.id,device_number,tab_user.promote_id") // ->page($page, $row) ->order($order); - if(!isset($_REQUEST['export'])){ - $data ->page($page, $row); - } + if($havs){ $data->having($havs); } @@ -158,7 +156,50 @@ class MemberController extends ThinkController }else{ $data->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1","left"); } + + $data = $data->select(false); + + $data = M()->table('(' . $data . ') as a ')->where(['device_count'=>['elt',1]]); + + if(!isset($_REQUEST['export'])){ + $data ->page($page, $row); + } + $data = $data->select(); +// var_dump($data);die(); + + //计算用户列表重复数量 + $userRepeat = M("user","tab_") + ->field("count(`device_number`) as device_count") + ->where($map) + ->group("tab_user.id,device_number,tab_user.promote_id") + // ->page($page, $row) + ->order($order); + + if($havs){ + $userRepeat->having($havs); + } + if($gameplay){ + $userRepeat->join(" + (select user_id from tab_user_play where 1 $gameplay group by tab_user_play.user_id) a ON a.user_id = tab_user.id + "); + } + if($game_map){ + $userRepeat->join(" + (select user_id from tab_user_play_info where 1 $game_map group by tab_user_play_info.user_id) a ON a.user_id = tab_user.id + "); + } + if($promoterSelect){ + $userRepeat->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1".$spendprom,"left"); + }else{ + $userRepeat->join("tab_spend AS ss ON ss.user_id = tab_user.id AND ss.pay_status = 1","left"); + } + + $userRepeat = $userRepeat->select(false); + $userRepeat = M()->table('(' . $userRepeat . ') as a ')->where(['device_count'=>['gt',1]])->count(); + + $this->assign('device_count',$userRepeat); + if(isset($_REQUEST['export'])){ $isadmin = is_administrator(); //获取等级 @@ -309,7 +350,7 @@ class MemberController extends ThinkController $this->assign('user_count',$user_count); $this->assign('now_count', $now_count?:0); - $page = set_pagination($user_count, $row); + $page = set_pagination($user_count-$userRepeat, $row); if ($page) { $this->assign('_page', $page); } diff --git a/Application/Admin/View/Member/user_info.html b/Application/Admin/View/Member/user_info.html index 5b9d6eb37..4d78b4460 100644 --- a/Application/Admin/View/Member/user_info.html +++ b/Application/Admin/View/Member/user_info.html @@ -348,15 +348,18 @@ 当前用户累计充值:{$now_count}    历史累计充值:{$history_count}   - 用户数:{$user_count} + 用户数:{$user_count}   + 去充用户数:{$device_count} 当前用户累计充值: 当前属于该推广员的用户的充值累计(不含用户换绑前记录)  /   - 历史累计充值: 历史中属于该推广员的用户的充值累计(含用户换绑前记录) + 历史累计充值: 历史中属于该推广员的用户的充值累计(含用户换绑前记录)   + 去充用户数:{$device_count} - 当前用户累计充值:{$now_count}  用户数:{$user_count} + 当前用户累计充值:{$now_count}  用户数:{$user_count}   + 去充用户数:{$device_count} From f840a59ce21ea38a9d27fc747d0da1bc4ab95ac0 Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Mon, 2 Mar 2020 18:21:12 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=93=8D=E4=BD=9Cbug?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/extend.php | 36 +++++++++++++++++++ .../Controller/MemberController.class.php | 6 ++-- .../TestResourceController.class.php | 5 ++- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 9573b6724..f805affa4 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -2316,4 +2316,40 @@ function getrelationGameName($id) { } +/** + * 操作日志 + * uid=>用户id, + * radio=>游戏比例, + */ + +function getAvailableBalance($uid,$radio=0) { + + if (!$uid) { + return 0; + } + + $promoteId = M('user','tab_')->field('promote_id')->where(['id'=>$uid])->find()['promote_id']; + +// $spendData = M('spend','tab_') +// ->field("date_format(FROM_UNIXTIME( pay_time),'%Y-%m-%d') AS time,sum(`pay_amount`)*{$radio} as pay_amount") +// ->where(['promote_id'=>$promoteId,'pay_status'=>1,'pay_way'=>['egt',1]]) +// ->group('time') +// ->select(); + + $spend = M('spend','tab_') + ->field("sum(`pay_amount`)*{$radio} as pay_amount") + ->where(['promote_id'=>$promoteId,'pay_status'=>1,'pay_way'=>['egt',1]]) + ->find()['pay_amount']; + + $applyResource = M('test_resource','tab_') + ->field('sum(`apply_resource`) as apply_resource') + ->where(['promote_id'=>$promoteId,'apply_status'=>2]) + ->find()['apply_resource']; + + + return ($spend?$spend:0)-($applyResource?$applyResource:0); + +} + + ?> diff --git a/Application/Admin/Controller/MemberController.class.php b/Application/Admin/Controller/MemberController.class.php index fdc499589..2c71e7f53 100644 --- a/Application/Admin/Controller/MemberController.class.php +++ b/Application/Admin/Controller/MemberController.class.php @@ -14,6 +14,8 @@ class MemberController extends ThinkController *玩家列表信息 */ public function user_info($p=0){ + + getAvailableBalance(34,0.5); //设定默认时间 // if(!array_key_exists("time_start",$_REQUEST) && I('type') != 2){ // $this->redirect(ACTION_NAME, array('time_start' => date('Y-m-d',strtotime('-30 day')),"time_end"=>date('Y-m-d'))); @@ -134,7 +136,7 @@ class MemberController extends ThinkController $data = M("user","tab_") ->field("tab_user.id,`device_number`,count(`device_number`) as device_count,`age_status`,`account`,`balance`,`gold_coin`,`alipay`,tab_user.promote_id,`register_type`,tab_user.promote_account,`register_time`,`lock_status`,lock_remark,`register_way`,`register_ip`,`login_time`,`check_status`,IFNULL(sum(ss.pay_amount), 0) AS recharge_total") ->where($map) - ->group("tab_user.id,device_number,tab_user.promote_id") + ->group("tab_user.id,device_number,tab_user.promote_id,tab_user.login_ip") // ->page($page, $row) ->order($order); @@ -172,7 +174,7 @@ class MemberController extends ThinkController $userRepeat = M("user","tab_") ->field("count(`device_number`) as device_count") ->where($map) - ->group("tab_user.id,device_number,tab_user.promote_id") + ->group("tab_user.id,device_number,tab_user.promote_id,tab_user.login_ip") // ->page($page, $row) ->order($order); diff --git a/Application/Home/Controller/TestResourceController.class.php b/Application/Home/Controller/TestResourceController.class.php index e6dc2f37f..23888a063 100644 --- a/Application/Home/Controller/TestResourceController.class.php +++ b/Application/Home/Controller/TestResourceController.class.php @@ -479,6 +479,9 @@ class TestResourceController extends BaseController $data['is_new'] = 1; } } else {//非新用户 + + $availableBalance = getAvailableBalance($data['user_id'],$config['old_value_ratio']); + $promoteAllRecharge = sum_promote_total_money($data['promote_id']);//总充值量 $allVerifyValue = $promoteAllRecharge * $config['old_value_ratio'];//可充值总量 //已用资源(申请通过的) @@ -493,7 +496,7 @@ class TestResourceController extends BaseController $used_resource = $used_resource ?: 0; $usable_resource = $allVerifyValue - $used_resource;//小于等于这个值自动审核 $usable_resource -= $resource; - if ($data['apply_resource'] <= $usable_resource) { + if ($data['apply_resource'] <= $usable_resource&&$data['apply_resource']<$availableBalance) { $data['verify_remark'] = '自动审核'; $data['verify_resource']= $data['apply_resource']; $data['verify_time'] = time(); From d6db0d37895f23c25e05922c5751016109ce1c89 Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Tue, 3 Mar 2020 14:59:49 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E5=8F=AF=E7=94=A8=E4=BD=99=E9=A2=9D=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E9=AA=8C=E8=AF=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/extend.php | 34 +++------ .../Controller/MemberController.class.php | 2 - .../TestResourceController.class.php | 74 ++++++++++++++++++- .../Controller/TimingController.class.php | 62 ++++++++++++++++ Application/Home/Common/function.php | 21 ++++++ .../TestResourceController.class.php | 11 ++- 6 files changed, 173 insertions(+), 31 deletions(-) diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index f805affa4..59106887a 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -2317,37 +2317,23 @@ function getrelationGameName($id) { } /** - * 操作日志 - * uid=>用户id, - * radio=>游戏比例, + * 获取测试资源可用余额 + * promote_id=>推广员id, + * game_id=>游戏id, */ -function getAvailableBalance($uid,$radio=0) { +function getAvailableBalance($promote_id=0,$game_id=0) { - if (!$uid) { + if (!$promote_id||!$game_id) { return 0; } - $promoteId = M('user','tab_')->field('promote_id')->where(['id'=>$uid])->find()['promote_id']; - -// $spendData = M('spend','tab_') -// ->field("date_format(FROM_UNIXTIME( pay_time),'%Y-%m-%d') AS time,sum(`pay_amount`)*{$radio} as pay_amount") -// ->where(['promote_id'=>$promoteId,'pay_status'=>1,'pay_way'=>['egt',1]]) -// ->group('time') -// ->select(); - - $spend = M('spend','tab_') - ->field("sum(`pay_amount`)*{$radio} as pay_amount") - ->where(['promote_id'=>$promoteId,'pay_status'=>1,'pay_way'=>['egt',1]]) - ->find()['pay_amount']; - - $applyResource = M('test_resource','tab_') - ->field('sum(`apply_resource`) as apply_resource') - ->where(['promote_id'=>$promoteId,'apply_status'=>2]) - ->find()['apply_resource']; - + $availableBalanceData = M('promote_game_available_balance','tab_') + ->field('available_balance') + ->where(['promote_id'=>$promote_id,'game_id'=>$game_id]) + ->find(); - return ($spend?$spend:0)-($applyResource?$applyResource:0); + return $availableBalanceData['available_balance']?$availableBalanceData['available_balance']:0; } diff --git a/Application/Admin/Controller/MemberController.class.php b/Application/Admin/Controller/MemberController.class.php index 2c71e7f53..5bd172959 100644 --- a/Application/Admin/Controller/MemberController.class.php +++ b/Application/Admin/Controller/MemberController.class.php @@ -14,8 +14,6 @@ class MemberController extends ThinkController *玩家列表信息 */ public function user_info($p=0){ - - getAvailableBalance(34,0.5); //设定默认时间 // if(!array_key_exists("time_start",$_REQUEST) && I('type') != 2){ // $this->redirect(ACTION_NAME, array('time_start' => date('Y-m-d',strtotime('-30 day')),"time_end"=>date('Y-m-d'))); diff --git a/Application/Admin/Controller/TestResourceController.class.php b/Application/Admin/Controller/TestResourceController.class.php index 8ac8ffc67..ff8a89268 100644 --- a/Application/Admin/Controller/TestResourceController.class.php +++ b/Application/Admin/Controller/TestResourceController.class.php @@ -352,7 +352,9 @@ class TestResourceController extends ThinkController session('apply_status', 0); (empty(I('server_id')) || I('server_id')<1) && $this->error('请选择区服!');; - M('test_resource', 'tab_')->startTrans(); //事物 + M()->startTrans(); //事物 + + $resource = 0; for ($i=0; $i < $count ; $i++) { $i_account=I('user_account')[$i]; if (!empty($i_account)) { @@ -430,7 +432,10 @@ class TestResourceController extends ThinkController $data['create_time']=time(); $data['apply_type']=0; + $data = $this->checkAutoVerify($data, $resource, $i); + $model = M('test_resource', 'tab_')->add($data); + $resource += $data['apply_resource']; if ($model) { session('apply_status', 1); } @@ -457,6 +462,68 @@ class TestResourceController extends ThinkController } } + /** + *判断申请资源是否自动审核 + * @param $data array 新增数据 + * @param $resource int 此次已申请资源 + * @param $thisCount int 批量申请的第几次 + */ + private function checkAutoVerify($data, $resource = 0, $thisCount = 0) + { + $config = M('resource_verify_config', 'tab_') + ->where(['game_id' => $data['game_id'], 'status' => 1]) + ->find(); + if ($config) {//已存在该游戏的资源审核配置 +// var_dump($config);die(); + $count = M('test_resource', 'tab_') + ->where(['user_id' => $data['user_id'], 'game_id' => $data['game_id']]) + ->count(); + $count += $thisCount; + if ($count < $config['new_apply_count']) {//新用户 + //申请资源数量在最低额度和最高额度之间,自动审核 + if ($data['apply_resource'] >= $config['new_low_value'] && $data['apply_resource'] <= $config['new_high_value']) { + $data['verify_remark'] = '自动审核'; + $data['verify_resource']= $data['apply_resource']; + $data['verify_time'] = time(); + $data['apply_status'] = 2; + $data['is_new'] = 1; + } + } else {//非新用户 + + $availableBalance = getAvailableBalance($data['promote_id'],$data['game_id']); +// var_dump($availableBalance);die(); + + $promoteAllRecharge = sum_promote_total_money($data['promote_id']);//总充值量 + $allVerifyValue = $promoteAllRecharge * $config['old_value_ratio'];//可充值总量 + //已用资源(申请通过的) + $used_resource = M('test_resource', 'tab_') + ->where([ + 'promote_id' => $data['promote_id'], + 'game_id' => $data['game_id'], + 'apply_status' => 2, + 'is_new' => 2, + ]) + ->getField('SUM(verify_resource) as used_resource'); + $used_resource = $used_resource ?: 0; + $usable_resource = $allVerifyValue - $used_resource;//小于等于这个值自动审核 + $usable_resource -= $resource; + if ($data['apply_resource'] <= $usable_resource&&$data['apply_resource']<$availableBalance) { + $data['verify_remark'] = '自动审核'; + $data['verify_resource']= $data['apply_resource']; + $data['verify_time'] = time(); + $data['apply_status'] = 2; + $data['is_new'] = 2; + + M('promote_game_available_balance','tab_') + ->where(['promote_id'=>$data['promote_id'],'game_id'=>$data['game_id']]) + ->setDec('available_balance',$data['apply_resource']); + } + } + } + + return $data; + } + public function edit() { $id = I('id'); @@ -519,7 +586,8 @@ class TestResourceController extends ThinkController public function batch_apply(){ $ids = explode(',', I('id')); - M('test_resource','tab_')->startTrans(); //事物 + M()->startTrans(); //事物 + $resource = 0; foreach ($ids as $key => $value) { $map['id']=$value; @@ -575,8 +643,10 @@ class TestResourceController extends ThinkController $data['create_time']=time(); $data['apply_type']=1; + $data = $this->checkAutoVerify($data, $resource, $key); // $model = M('test_resource','tab_')->add($data); + $resource += $data['apply_resource']; if($model===false){ M('test_resource','tab_')->rollback();//回滚 $this->error('申请失败'); diff --git a/Application/Admin/Controller/TimingController.class.php b/Application/Admin/Controller/TimingController.class.php index 438a28079..213a2e238 100644 --- a/Application/Admin/Controller/TimingController.class.php +++ b/Application/Admin/Controller/TimingController.class.php @@ -261,4 +261,66 @@ class TimingController extends AdminController { return $mid; } + //格式 starttime 20200229 endtime 20200230 + public function setAvailableBalance() { + + if (strtotime($_GET['endtime'])field("sum(`pay_amount`) as pay_amount,promote_id,promote_account,tab_spend.game_id,tab_spend.game_name,CASE WHEN old_value_ratio is NULL THEN 0 ELSE sum(`pay_amount`) * old_value_ratio END as available_balance") + ->join('left join tab_resource_verify_config as config on tab_spend.game_id = config.game_id') + ->where(['pay_status'=>1,'pay_way'=>['egt',1],'pay_time'=>['between',[$start,$start+86399]]]) + ->group('promote_id,game_id') + ->select(); +// var_dump($data);die(); + + foreach ($data as $key => $value) { + + $insert['promote_id'] = $value['promote_id']; + $insert['promote_account'] = $value['promote_account']; + $insert['game_id'] = $value['game_id']; + $insert['game_name'] = $value['game_name']; + $insert['available_balance'] = $value['available_balance']; + + $availableBalanceData = M('promote_game_available_balance','tab_') + ->where(['promote_id'=>$value['promote_id'],'game_id'=>$value['game_id']]) + ->find(); + + if (round($value['available_balance'],0) > 0 && !$availableBalanceData) { + M('promote_game_available_balance','tab_')->add($insert); + } else if (round($value['available_balance'],0) > 0 && $availableBalanceData) { + M('promote_game_available_balance','tab_') + ->where(['promote_id'=>$value['promote_id'],'game_id'=>$value['game_id']]) + ->setInc('available_balance',round($value['available_balance'],0)); + } +// dump(round($value['available_balance'],0)); + + } + + } + + echo '执行成功'; + + + } + } diff --git a/Application/Home/Common/function.php b/Application/Home/Common/function.php index e52beea47..7b8f902f9 100644 --- a/Application/Home/Common/function.php +++ b/Application/Home/Common/function.php @@ -1301,3 +1301,24 @@ function recordPromoteLogs($module,$action_type) { M('promote_action_logs','tab_')->add($promoteLogsData); } + +/** + * 获取测试资源可用余额 + * promote_id=>推广员id, + * game_id=>游戏id, + */ + +function getAvailableBalance($promote_id=0,$game_id=0) { + + if (!$promote_id||!$game_id) { + return 0; + } + + $availableBalanceData = M('promote_game_available_balance','tab_') + ->field('available_balance') + ->where(['promote_id'=>$promote_id,'game_id'=>$game_id]) + ->find(); + + return $availableBalanceData['available_balance']?$availableBalanceData['available_balance']:0; + +} diff --git a/Application/Home/Controller/TestResourceController.class.php b/Application/Home/Controller/TestResourceController.class.php index 23888a063..00d56d7b1 100644 --- a/Application/Home/Controller/TestResourceController.class.php +++ b/Application/Home/Controller/TestResourceController.class.php @@ -352,7 +352,7 @@ class TestResourceController extends BaseController $count=count(I('user_account')); session('apply_status', 0); (empty(I('server_id')) || I('server_id')<1) && $this->ajaxReturn(['msg'=>$i_account.'请选择区服' ,'status'=>0]); - M('test_resource', 'tab_')->startTrans(); //事物 + M()->startTrans(); //事物 $resource = 0; for ($i=0; $i < $count ; $i++) { $data = array(); @@ -480,7 +480,7 @@ class TestResourceController extends BaseController } } else {//非新用户 - $availableBalance = getAvailableBalance($data['user_id'],$config['old_value_ratio']); + $availableBalance = getAvailableBalance($data['promote_id'],$data['game_id']); $promoteAllRecharge = sum_promote_total_money($data['promote_id']);//总充值量 $allVerifyValue = $promoteAllRecharge * $config['old_value_ratio'];//可充值总量 @@ -502,6 +502,11 @@ class TestResourceController extends BaseController $data['verify_time'] = time(); $data['apply_status'] = 2; $data['is_new'] = 2; + + M('promote_game_available_balance','tab_') + ->where(['promote_id'=>$data['promote_id'],'game_id'=>$data['game_id']]) + ->setDec('available_balance',$data['apply_resource']); + } } } @@ -545,7 +550,7 @@ class TestResourceController extends BaseController public function batch_apply(){ $ids = explode(',', I('apply_id')); - M('test_resource','tab_')->startTrans(); //事物 + M()->startTrans(); //事物 $resource = 0; foreach ($ids as $key => $value) { $data = array(); From 800680c6c0ae38770e1e635e777ca7599f108ace Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Tue, 3 Mar 2020 17:44:19 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E7=94=B3=E8=AF=B7=E5=AE=A1=E6=A0=B8=E9=AA=8C=E8=AF=81=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=8C=BA=E6=9C=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/extend.php | 6 +++--- .../Controller/TestResourceController.class.php | 6 +++--- .../Admin/Controller/TimingController.class.php | 12 +++++++----- Application/Home/Common/function.php | 6 +++--- .../Home/Controller/TestResourceController.class.php | 6 +++--- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 59106887a..19de23562 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -2322,15 +2322,15 @@ function getrelationGameName($id) { * game_id=>游戏id, */ -function getAvailableBalance($promote_id=0,$game_id=0) { +function getAvailableBalance($promote_id=0,$game_id=0,$server_id=0) { - if (!$promote_id||!$game_id) { + if (!$promote_id||!$game_id||!$server_id) { return 0; } $availableBalanceData = M('promote_game_available_balance','tab_') ->field('available_balance') - ->where(['promote_id'=>$promote_id,'game_id'=>$game_id]) + ->where(['promote_id'=>$promote_id,'game_id'=>$game_id,'server_id'=>$server_id]) ->find(); return $availableBalanceData['available_balance']?$availableBalanceData['available_balance']:0; diff --git a/Application/Admin/Controller/TestResourceController.class.php b/Application/Admin/Controller/TestResourceController.class.php index ff8a89268..6ac905d6a 100644 --- a/Application/Admin/Controller/TestResourceController.class.php +++ b/Application/Admin/Controller/TestResourceController.class.php @@ -432,7 +432,7 @@ class TestResourceController extends ThinkController $data['create_time']=time(); $data['apply_type']=0; - $data = $this->checkAutoVerify($data, $resource, $i); + $data = $this->checkAutoVerify($data, $resource, 0); $model = M('test_resource', 'tab_')->add($data); $resource += $data['apply_resource']; @@ -490,7 +490,7 @@ class TestResourceController extends ThinkController } } else {//非新用户 - $availableBalance = getAvailableBalance($data['promote_id'],$data['game_id']); + $availableBalance = getAvailableBalance($data['promote_id'],$data['game_id'],$data['server_id']); // var_dump($availableBalance);die(); $promoteAllRecharge = sum_promote_total_money($data['promote_id']);//总充值量 @@ -515,7 +515,7 @@ class TestResourceController extends ThinkController $data['is_new'] = 2; M('promote_game_available_balance','tab_') - ->where(['promote_id'=>$data['promote_id'],'game_id'=>$data['game_id']]) + ->where(['promote_id'=>$data['promote_id'],'game_id'=>$data['game_id'],'server_id'=>$data['server_id']]) ->setDec('available_balance',$data['apply_resource']); } } diff --git a/Application/Admin/Controller/TimingController.class.php b/Application/Admin/Controller/TimingController.class.php index 213a2e238..137324bfc 100644 --- a/Application/Admin/Controller/TimingController.class.php +++ b/Application/Admin/Controller/TimingController.class.php @@ -286,10 +286,10 @@ class TimingController extends AdminController { // var_dump($starttime);die(); $data = M('spend','tab_') - ->field("sum(`pay_amount`) as pay_amount,promote_id,promote_account,tab_spend.game_id,tab_spend.game_name,CASE WHEN old_value_ratio is NULL THEN 0 ELSE sum(`pay_amount`) * old_value_ratio END as available_balance") + ->field("sum(`pay_amount`) as pay_amount,promote_id,promote_account,tab_spend.game_id,tab_spend.game_name,tab_spend.server_id,tab_spend.server_name,CASE WHEN old_value_ratio is NULL THEN 0 ELSE sum(`pay_amount`) * old_value_ratio END as available_balance") ->join('left join tab_resource_verify_config as config on tab_spend.game_id = config.game_id') ->where(['pay_status'=>1,'pay_way'=>['egt',1],'pay_time'=>['between',[$start,$start+86399]]]) - ->group('promote_id,game_id') + ->group('promote_id,game_id,server_id') ->select(); // var_dump($data);die(); @@ -299,17 +299,19 @@ class TimingController extends AdminController { $insert['promote_account'] = $value['promote_account']; $insert['game_id'] = $value['game_id']; $insert['game_name'] = $value['game_name']; - $insert['available_balance'] = $value['available_balance']; + $insert['available_balance'] = round($value['available_balance'],0); + $insert['server_id'] = $value['server_id']; + $insert['server_name'] = $value['server_name']; $availableBalanceData = M('promote_game_available_balance','tab_') - ->where(['promote_id'=>$value['promote_id'],'game_id'=>$value['game_id']]) + ->where(['promote_id'=>$value['promote_id'],'game_id'=>$value['game_id'],'server_id'=>$value['server_id']]) ->find(); if (round($value['available_balance'],0) > 0 && !$availableBalanceData) { M('promote_game_available_balance','tab_')->add($insert); } else if (round($value['available_balance'],0) > 0 && $availableBalanceData) { M('promote_game_available_balance','tab_') - ->where(['promote_id'=>$value['promote_id'],'game_id'=>$value['game_id']]) + ->where(['promote_id'=>$value['promote_id'],'game_id'=>$value['game_id'],'server_id'=>$value['server_id']]) ->setInc('available_balance',round($value['available_balance'],0)); } // dump(round($value['available_balance'],0)); diff --git a/Application/Home/Common/function.php b/Application/Home/Common/function.php index 7b8f902f9..6a43b98fc 100644 --- a/Application/Home/Common/function.php +++ b/Application/Home/Common/function.php @@ -1308,15 +1308,15 @@ function recordPromoteLogs($module,$action_type) { * game_id=>游戏id, */ -function getAvailableBalance($promote_id=0,$game_id=0) { +function getAvailableBalance($promote_id=0,$game_id=0,$server_id=0) { - if (!$promote_id||!$game_id) { + if (!$promote_id||!$game_id||!$server_id) { return 0; } $availableBalanceData = M('promote_game_available_balance','tab_') ->field('available_balance') - ->where(['promote_id'=>$promote_id,'game_id'=>$game_id]) + ->where(['promote_id'=>$promote_id,'game_id'=>$game_id,'server_id'=>$server_id]) ->find(); return $availableBalanceData['available_balance']?$availableBalanceData['available_balance']:0; diff --git a/Application/Home/Controller/TestResourceController.class.php b/Application/Home/Controller/TestResourceController.class.php index 00d56d7b1..cae0bb858 100644 --- a/Application/Home/Controller/TestResourceController.class.php +++ b/Application/Home/Controller/TestResourceController.class.php @@ -428,7 +428,7 @@ class TestResourceController extends BaseController $data['create_time']=time(); $data['apply_type']=0; - $data = $this->checkAutoVerify($data, $resource, $i); + $data = $this->checkAutoVerify($data, $resource, 0); $model = M('test_resource', 'tab_')->add($data); $resource += $data['apply_resource']; if ($model) { @@ -480,7 +480,7 @@ class TestResourceController extends BaseController } } else {//非新用户 - $availableBalance = getAvailableBalance($data['promote_id'],$data['game_id']); + $availableBalance = getAvailableBalance($data['promote_id'],$data['game_id'],$data['server_id']); $promoteAllRecharge = sum_promote_total_money($data['promote_id']);//总充值量 $allVerifyValue = $promoteAllRecharge * $config['old_value_ratio'];//可充值总量 @@ -504,7 +504,7 @@ class TestResourceController extends BaseController $data['is_new'] = 2; M('promote_game_available_balance','tab_') - ->where(['promote_id'=>$data['promote_id'],'game_id'=>$data['game_id']]) + ->where(['promote_id'=>$data['promote_id'],'game_id'=>$data['game_id'],'server_id'=>$data['server_id']]) ->setDec('available_balance',$data['apply_resource']); }