diff --git a/Application/Admin/Controller/AjaxController.class.php b/Application/Admin/Controller/AjaxController.class.php index 2d6092dec..5d9edbc81 100644 --- a/Application/Admin/Controller/AjaxController.class.php +++ b/Application/Admin/Controller/AjaxController.class.php @@ -176,6 +176,23 @@ class AjaxController extends ThinkController{ } $this->ajaxReturn(['code'=>1, 'msg'=>'获取成功', 'data'=>(new PromoteModel)->getPromotersByLevel($level)]); } + /** + * 根据公司id获取会长 + */ + public function getPromotersByCompanyid($company_id = -1) + { + $company_id = I('company_id'); + $data = M("Promote","tab_")->field("id,account,nickname,company_id"); + if($company_id == -1){ + $data = $data->where("level = '1'")->select(); + }else{ + $data = $data->where("company_id = '{$company_id}' and level = '1'")->select(); + } + foreach ($data as &$item) { + $item['nickname'] = $item['account'] . ($item['nickname'] ? "({$item['nickname']})" : ""); + } + $this->ajaxReturn(['code'=>1, 'msg'=>'获取成功', 'data'=>$data]); + } public function getPromotersByLevelOther() { diff --git a/Application/Admin/Controller/AutoController.class.php b/Application/Admin/Controller/AutoController.class.php index c704aec94..ff30dda40 100644 --- a/Application/Admin/Controller/AutoController.class.php +++ b/Application/Admin/Controller/AutoController.class.php @@ -1034,4 +1034,94 @@ public function auto_rrdae(){ ]; return $ret; } + + //会长提现 + public function promoteWithdraw() + { + $map['level'] = 1; + $map['ver_status'] = 1; + $promotes = M('promote', 'tab_')->field('id, account, chain')->where($map)->select(); + $success = 0; + $error_withdraw = 0; + $error_spend = 0; + $error_balance = 0; + + if (!empty($promotes)) { + foreach ($promotes as $promote) { + $result = $this->promoteWithdrawByPromote($promote); + switch ($result) { + case -2: + $error_balance++; + break; + case -1: + $error_spend++; + break; + case 0: + $error_withdraw++; + break; + case 1: + $success++; + break; + } + } + } + + echo "success:{$success} error_withdraw:{$error_withdraw} error_spend:{$error_spend} error_balance:{$error_balance}"; + } + + private function promoteWithdrawByPromote($promote) + { + $promoteMap['chain'] = ['like', "{$promote['chain']}{$promote['id']}/%"]; + $promoteIds = M('promote', 'tab_')->where($promoteMap)->getField('id', true); + $promoteIds[] = $promote['id']; + $settlementEndTime = strtotime(date('Y-m-d')) - 1; + + $spendMap['pay_status'] = 1; + $spendMap['selle_status'] = 0; + $spendMap['promote_id'] = ['in', $promoteIds]; + $spendMap['pay_time'] = ['elt', $settlementEndTime]; + $spendModel = M('spend', 'tab_'); + $balance = $spendModel->field("sum(if(selle_ratio > 0, pay_amount * selle_ratio, 0)) as balance") + ->where($spendMap) + ->find()['balance']; + $balance = bcdiv($balance, 100, 2); + if ($balance < 100) { + return -2;//余额不足 + } + + $thisTime = time(); + $add['sum_money'] = $balance; + $add['promote_id'] = $promote['id']; + $add['promote_account'] = $promote['account']; + $add['create_time'] = $thisTime; + $add['status'] = 0; + $add['widthdraw_number'] = D('withdraw')->produceWithdrawNumber(); + $add['settlement_begin_time'] = 0; + $add['settlement_end_time'] = $settlementEndTime; + $add['spend_ids'] = ''; + $add['op_id'] = 0; + $add['op_type'] = 3; + $add['last_op_id'] = $add['op_id']; + $add['last_op_type'] = 3; + + M()->startTrans();//开启事物 + $withdrawId = D('withdraw')->add($add); + if (!$withdrawId) { + M()->rollback();//事物回滚 + return 0;//提现失败 + } + + $save['selle_status'] = 1; + $save['selle_time'] = $thisTime; + $save['withdraw_id'] = $withdrawId; + $res = $spendModel->where($spendMap)->save($save); + if ($res === false) { + D('withdraw')->delete($withdrawId); + M()->rollback();//事物回滚 + return -1; + } + + M()->commit();//事物提交 + return 1; + } } diff --git a/Application/Admin/Controller/BehaviorLogController.class.php b/Application/Admin/Controller/BehaviorLogController.class.php index 82a4ef224..0643ada76 100644 --- a/Application/Admin/Controller/BehaviorLogController.class.php +++ b/Application/Admin/Controller/BehaviorLogController.class.php @@ -111,9 +111,7 @@ class BehaviorLogController extends ThinkController $map['tab_repair_pay.type'] = $params['type']; } - if(isset($params['type'])) { - $map['tab_spend.extend'] = $params['extend']; - } + if(isset($params['pay_order_number'])) { $map['tab_repair_pay.pay_order_number'] = $params['pay_order_number']; diff --git a/Application/Admin/Controller/ConsoleController.class.php b/Application/Admin/Controller/ConsoleController.class.php index 3fd04ec0b..69a182a70 100644 --- a/Application/Admin/Controller/ConsoleController.class.php +++ b/Application/Admin/Controller/ConsoleController.class.php @@ -101,37 +101,58 @@ class ConsoleController extends Think { $this->modifyLogin(strtotime($start_time)); } + public function modifyLoginCheck($start_time=0, $end_time=0) + { + $start_time = $start_time ? strtotime($start_time) : strtotime(date("Y-m-d")); + $end_time = $end_time ? strtotime($end_time) : $start_time; + $this->modifyLogin($start_time, $end_time); + } + /** * 登录校验 */ - private function modifyLogin($start_time=0) + private function modifyLogin($start_time=0, $end_time=0) { - $current_time = strtotime(date("Y-m-d"))-86400; + $current_time = $end_time?: strtotime(date("Y-m-d"))-86400; for ($i=$start_time; $i<=$current_time; $i+=86400) { $end_time = $i+86400; $result = M()->query("SELECT game_id, - FROM_UNIXTIME(login_time, '%Y-%m-%d') create_time, + UNIX_TIMESTAMP(FROM_UNIXTIME(login_time, '%Y-%m-%d')) create_time, user_id, promote_id FROM - tab_user_login_record + tab_user_login_record ulr WHERE login_time >= {$i} and login_time < {$end_time} + AND NOT EXISTS ( + SELECT + id + FROM + tab_login_daily_record ldr + where ldr.create_time >= {$i} and ldr.create_time < {$end_time} and ldr.game_id = ulr.game_id and ldr.user_id = ulr.user_id and ldr.promote_id = ulr.promote_id + ) GROUP BY create_time, game_id, - user_id"); + user_id, + promote_id"); if ($result) { foreach ($result as $index => $item) { - $item['create_time'] = strtotime($item['create_time']); - if ($item['create_time']) { - $res = M("login_daily_record", "tab_")->add($item); - echo "写入{$item['create_time']} $res \n"; + if (is_null($result[$index]['promote_id'])) + { + unset($result[$index]); + } + } + $step = 500; + for ($j=0;;$j+=$step) { + $insData = array_slice($result, $j, $step); + if ($insData) { + $res = M("login_daily_record", 'tab_')->addAll($insData); + echo "写入 $res \n"; } else { - echo "写入{$item['create_time']} error \n"; + break; } - unset($result[$index]); } } else { echo "写入{$item['create_time']} 无 \n"; diff --git a/Application/Admin/Controller/DepositController.class.php b/Application/Admin/Controller/DepositController.class.php index b386cddb7..181ef0ba5 100644 --- a/Application/Admin/Controller/DepositController.class.php +++ b/Application/Admin/Controller/DepositController.class.php @@ -10,7 +10,7 @@ use User\Api\UserApi as UserApi; class DepositController extends ThinkController { const model_name = 'Deposit'; - public function lists(){ + public function lists($p = 1){ if(isset($_REQUEST['user_account'])){ $map['user_account']=array('like','%'.trim($_REQUEST['user_account']).'%'); unset($_REQUEST['user_account']); @@ -38,16 +38,10 @@ class DepositController extends ThinkController { }else if(isset($_REQUEST['promote_id']) && $_REQUEST['promote_id']==0){ $map['promote_id']=array('elt',0); - unset($_REQUEST['promote_id']); - unset($_REQUEST['promote_name']); }elseif(isset($_REQUEST['promote_name'])&&$_REQUEST['promote_id']==-1){ $map['promote_id']=get_promote_id($_REQUEST['promote_name']); - unset($_REQUEST['promote_id']); - unset($_REQUEST['promote_name']); }else{ $map['promote_id']=$_REQUEST['promote_id']; - unset($_REQUEST['promote_id']); - unset($_REQUEST['promote_name']); } if(isset($_REQUEST['time-start'])&&isset($_REQUEST['time-end'])){ $map['create_time'] =array('BETWEEN',array(strtotime($_REQUEST['time-start']),strtotime($_REQUEST['time-end'])+24*60*60-1)); @@ -94,6 +88,47 @@ class DepositController extends ThinkController { $map1=$map; $map1['pay_status']=1; + + if($_REQUEST['promote_id']||$_REQUEST['promote_id']=='0') { + $page = intval($p); + $page = $page ? $page : 1; //默认显示第一页数据 + if(isset($_REQUEST['row'])) {$row = $_REQUEST['row'];}else{$row = 10;} + $map1['order_status'] = 1; + unset($map1['pay_status']); + if ($map['pay_status']) { + $map['order_status']=$map['pay_status']; + } + + $total=null_to_0(D('coin_pay_order')->where($map1)->sum('pay_amount')); + $ttotal=null_to_0(D('coin_pay_order')->where('create_time'.total(1))->where(array('pay_status'=>1))->sum('pay_amount')); + $ytotal=null_to_0(D('coin_pay_order')->where('create_time'.total(5))->where(array('pay_status'=>1))->sum('pay_amount')); + $this->assign('total',$total); + $this->assign('ttotal',$ttotal); + $this->assign('ytotal',$ytotal); + + $data = D('coin_pay_order') + /* 查询指定字段,不指定则查询所有字段 */ + ->field('*,order_status as pay_status') + // 查询条件 + ->where($map) + /* 默认通过id逆序排列 */ + ->order("id desc") + /* 数据分页 */ + ->page($page, $row) + /* 执行查询 */ + ->select(); + + /* 查询记录总数 */ + $count = D('coin_pay_order')->where($map)->count(); + + $page = set_pagination($count,$row); + if($page) {$this->assign('_page', $page);} + + $this->assign('list_data', $data); + $this->meta_title = '平台币充值列表'; + $this->display('lists');die(); + } + $total=null_to_0(D(self::model_name)->where($map1)->sum('pay_amount')); $ttotal=null_to_0(D(self::model_name)->where('create_time'.total(1))->where(array('pay_status'=>1))->sum('pay_amount')); $ytotal=null_to_0(D(self::model_name)->where('create_time'.total(5))->where(array('pay_status'=>1))->sum('pay_amount')); @@ -105,6 +140,7 @@ class DepositController extends ThinkController { $this->assign('commonset',M('Kuaijieicon')->where(['url'=>'Deposit/lists','status'=>1])->find()); $this->assign("is_admin",is_administrator()); + parent::lists(self::model_name,$_GET["p"],$map); } diff --git a/Application/Admin/Controller/ExportController.class.php b/Application/Admin/Controller/ExportController.class.php index 545e588cc..cb51513f8 100644 --- a/Application/Admin/Controller/ExportController.class.php +++ b/Application/Admin/Controller/ExportController.class.php @@ -1235,16 +1235,10 @@ class ExportController extends Controller } else if (isset($_REQUEST['promote_id']) && $_REQUEST['promote_id'] == 0) { $map['promote_id'] = array('elt', 0); - unset($_REQUEST['promote_id']); - unset($_REQUEST['promote_name']); } elseif (isset($_REQUEST['promote_name']) && $_REQUEST['promote_id'] == -1) { $map['promote_id'] = get_promote_id($_REQUEST['promote_name']); - unset($_REQUEST['promote_id']); - unset($_REQUEST['promote_name']); } else { $map['promote_id'] = $_REQUEST['promote_id']; - unset($_REQUEST['promote_id']); - unset($_REQUEST['promote_name']); } if (isset($_REQUEST['time-start']) && isset($_REQUEST['time-end'])) { $map['create_time'] = array('BETWEEN', array(strtotime($_REQUEST['time-start']), strtotime($_REQUEST['time-end']) + 24 * 60 * 60 - 1)); @@ -1266,30 +1260,70 @@ class ExportController extends Controller } $map1 = $map; $map1['pay_status'] = 1; - $total = D('Deposit')->where($map1)->sum('pay_amount'); - if (isset($map['pay_status']) && $map['pay_status'] == 0) { - $total = sprintf("%.2f", 0); + + if($_REQUEST['promote_id']||$_REQUEST['promote_id']=='0') { + + $map1['order_status'] = 1; + unset($map1['pay_status']); + if ($map['pay_status']) { + $map['order_status']=$map['pay_status']; + } + + $total=null_to_0(D('coin_pay_order')->where($map1)->sum('pay_amount')); + + if (isset($map['pay_status']) && $map['pay_status'] == 0) { + $total = sprintf("%.2f", 0); + } else { + $total = sprintf("%.2f", $total); + } + $xlsCell = array( + array('pay_order_number', "订单号"), + array('promote_account', L('Subordinate_channel')), + array('pay_amount', "充值平台币"), + array('pay_way', "充值方式", 'get_pay_way', '*'), + array('create_time', "充值时间"), + array('pay_status', L('Order_status'), 'get_info_status', '*', '9'), + array('', "共计充值{$total}"), + ); + $xlsData = D('coin_pay_order') + /* 查询指定字段,不指定则查询所有字段 */ + ->field('*,order_status as pay_status') + // 查询条件 + ->where($map) + /* 默认通过id逆序排列 */ + ->order("id desc") + /* 执行查询 */ + ->select(); +// var_dump($xlsData);die(); + foreach ($xlsData as $key => $value) { + $xlsData[$key]['create_time'] = date('Y-m-d H:i:s', $value['create_time']); + } } else { - $total = sprintf("%.2f", $total); - } + $total = D('Deposit')->where($map1)->sum('pay_amount'); + if (isset($map['pay_status']) && $map['pay_status'] == 0) { + $total = sprintf("%.2f", 0); + } else { + $total = sprintf("%.2f", $total); + } - $xlsCell = array( - array('pay_order_number', "订单号"), - array('user_account', "玩家账号"), - array('promote_account', L('Subordinate_channel')), - array('pay_amount', "充值平台币"), - array('pay_way', "充值方式", 'get_pay_way', '*'), - array('pay_ip', "充值ip"), - array('create_time', "充值时间"), - array('pay_status', L('Order_status'), 'get_info_status', '*', '9'), - array('', "共计充值{$total}"), - ); - $xlsData = D('Deposit') - ->where($map) - ->order('id DESC') - ->select(); - foreach ($xlsData as $key => $value) { - $xlsData[$key]['create_time'] = date('Y-m-d H:i:s', $value['create_time']); + $xlsCell = array( + array('pay_order_number', "订单号"), + array('user_account', "玩家账号"), + array('promote_account', L('Subordinate_channel')), + array('pay_amount', "充值平台币"), + array('pay_way', "充值方式", 'get_pay_way', '*'), + array('pay_ip', "充值ip"), + array('create_time', "充值时间"), + array('pay_status', L('Order_status'), 'get_info_status', '*', '9'), + array('', "共计充值{$total}"), + ); + $xlsData = D('Deposit') + ->where($map) + ->order('id DESC') + ->select(); + foreach ($xlsData as $key => $value) { + $xlsData[$key]['create_time'] = date('Y-m-d H:i:s', $value['create_time']); + } } // dd($xlsData); break; @@ -2003,7 +2037,7 @@ class ExportController extends Controller foreach($supersign_game as $k => $v) { $arr['game_name'] = $v['game_name']; $re_data = []; - $curl['token'] = $v['token']; + $curl['token'] = $v['supersign_token']; $curl['limit'] = 2000; for ($i = 1;$i > 0;$i++) { if($i != 1) { @@ -2116,7 +2150,7 @@ class ExportController extends Controller $map['game_id'] = $params['game_id']; } $map['supersign_token'] = ['NEQ','']; - $supersign_game = M('game', 'tab_')->field('tab_game.id,tab_game.game_name,tab_game.supersign_token')->join('tab_game_supersign on tab_game_supersign.game_id = tab_game.id')->where($map)->group('tab_game.id')->select(); + $supersign_game = M('game', 'tab_')->field('id,game_name,supersign_token')->where(['supersign_token' => ['NEQ','']])->select(); $supersign_token = array_column($supersign_game, 'supersign_token'); $authorization_all_num = 0; foreach($supersign_token as $k => $v) { @@ -2169,10 +2203,6 @@ class ExportController extends Controller $map['tab_repair_pay.create_time'] = array('BETWEEN', [$startTime, $endTime]); } - if(isset($params['type'])) { - $map['tab_spend.extend'] = $params['extend']; - } - if(isset($params['type'])) { $map['tab_repair_pay.type'] = $params['type']; } diff --git a/Application/Admin/Controller/FinancePromoteController.class.php b/Application/Admin/Controller/FinancePromoteController.class.php index 63409d2dc..9d4a714f3 100644 --- a/Application/Admin/Controller/FinancePromoteController.class.php +++ b/Application/Admin/Controller/FinancePromoteController.class.php @@ -44,9 +44,10 @@ class FinancePromoteController extends AdminController foreach($cash as $k=>$v){ $senddata[$v['p_id']] = $v; } - //内冲 - $inside = self::getJoinPromoteData([],$istimeselect,"promote_coin"); - foreach($inside as $k=>$v){ + + //内冲 + $inside = self::getJoinPromoteData([],$istimeselect,"promote_coin"); + foreach($inside as $k=>$v){ if(array_key_exists($v['p_id'],$senddata)){ $senddata[$v['p_id']]['inside_cash_count']= $v['pay_amount']-$v['back_amount']; }else{ @@ -56,17 +57,43 @@ class FinancePromoteController extends AdminController $senddata[$v['p_id']] = $v; }; } + + //官方渠道单算 + //判断公司 + $gfidlag = true; + $gfgs = true; + if (isset($_REQUEST['company_id'])) { + if($_REQUEST['company_id']!=0){ + $gfgs = false; + } + } + if (isset($_REQUEST['promote_id'])) { + if($_REQUEST['promote_id'] == 0){ + $gfidlag = true; + }else{ + $gfidlag =false; + } + } + if($gfidlag && $gfgs){ + //计算官方渠道 + unset($_REQUEST['company_id']); + $_REQUEST['promote_id'] = 0; + $gfcash = self::getJoinPromoteData([],$istimeselect); + $senddata[0] = $gfcash[0]; + } + if(!empty($senddata)){ if(array_key_exists(0,$senddata) || $_REQUEST['promote_id']==0){ - $pmap['status']=1; - if($istimeselect){ - $pmap['create_time'] = $istimeselect; - } - $admininside = M("provide_user p","tab_")->field("sum(amount) amount")->where($pmap)->find(); - if($admininside['amount'] >0){ - $senddata[0]['inside_cash_count']= $admininside['amount']; + if (empty($_REQUEST['company_id'])) { + $pmap['status']=1; + if($istimeselect){ + $pmap['create_time'] = $istimeselect; + } + $admininside = M("provide_user p","tab_")->field("sum(amount) amount")->where($pmap)->find(); + if($admininside['amount'] >0){ + $senddata[0]['inside_cash_count']= $admininside['amount']; + } } - } } $data = []; @@ -77,8 +104,9 @@ class FinancePromoteController extends AdminController "inside_cash_count"=>0, ); foreach($senddata as $k=>$v){ - + if(empty($v['company_name'])) $v['company_name']= "万盟天下科技"; + if(empty($v['p_id'])) $v['p_id']= "0"; if(!array_key_exists('cash_count',$v)) $v['cash_count']=0; if(!array_key_exists('balance_coin_count',$v)) $v['balance_coin_count']=0; if(!array_key_exists('bind_coin_count',$v)) $v['bind_coin_count']=0; @@ -112,7 +140,6 @@ class FinancePromoteController extends AdminController $size = $row; $data = array_slice($data, ($arraypage - 1) * $size, $size); - $this->assign('list_data', $data); $this->assign('all_count', $count); $this->meta_title = '公会统计'; @@ -122,7 +149,7 @@ class FinancePromoteController extends AdminController private function getJoinPromoteData($map,$istimeselect,$type="spend") { // setPowerPromoteIds($map,"s.promote_id"); - if ($_REQUEST['promote_id'] != '') { + if (isset($_REQUEST['promote_id'])) { if ($_REQUEST['promote_id'] == 0) { $map['s.promote_id'] = 0; } else { @@ -134,7 +161,9 @@ class FinancePromoteController extends AdminController } if (isset($_REQUEST['company_id'])) { $map['promote.company_id'] = $_REQUEST['company_id']; + } + if($type == "spend"){ if (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type'])) { $map["s.game_id"] = array("in",implode(',', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')) ); @@ -142,7 +171,6 @@ class FinancePromoteController extends AdminController if($istimeselect){ $map['s.pay_time']=$istimeselect; } - $map['s.pay_status']=1; $field= "SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END) as cash_count, SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END) as balance_coin_count, @@ -150,28 +178,31 @@ class FinancePromoteController extends AdminController IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='',s.promote_id,substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) p_id, IFNULL(company_id,0) company_id,company_name"; return M() - ->table("tab_spend s") - ->field($field) - ->where($map) - ->join("tab_promote promote ON s.promote_id = promote.id","left") - ->join("tab_promote_company company ON promote.company_id = company.id","left") - ->group('p_id') - ->select(); + ->table("tab_spend s") + ->field($field) + ->where($map) + ->join("tab_promote promote ON s.promote_id = promote.id","left") + ->join("tab_promote_company company ON promote.company_id = company.id","left") + ->group('p_id') + ->select(); }else{ if($istimeselect){ $map['s.create_time']=$istimeselect; } $map['s.status']=1; $map['s.source_id']=0; - $field= "SUM(CASE WHEN s.type = 1 THEN num ELSE 0 END) as pay_amount,SUM(CASE WHEN s.type = 2 THEN num ELSE 0 END) as back_amount,IFNULL(if(substring_index(substring_index(`chain`,'/',2),'/',-1)='',s.promote_id,substring_index(substring_index(`chain`,'/',2),'/',-1)),0) p_id"; + $field= "SUM(CASE WHEN s.type = 1 THEN num ELSE 0 END) as pay_amount,SUM(CASE WHEN s.type = 2 THEN num ELSE 0 END) as back_amount,IFNULL(if(substring_index(substring_index(`chain`,'/',2),'/',-1)='', + s.promote_id,substring_index(substring_index(`chain`,'/',2),'/',-1)),0) p_id, + IFNULL(company_id,0) company_id,company_name"; return M("promote_coin s","tab_") - ->field($field) - ->where($map) - ->join("tab_promote promote ON s.promote_id = promote.id","left") - ->group('p_id') - ->select(); + ->field($field) + ->where($map) + ->join("tab_promote promote ON s.promote_id = promote.id","left") + ->join("tab_promote_company company ON promote.company_id = company.id","left") + ->group('p_id') + ->select(); } - + } //渠道查看 @@ -202,25 +233,27 @@ class FinancePromoteController extends AdminController $senddata[$v['promote_id']] = $v; } $inside = self::promoteUserData([],$istimeselect,"promote_coin"); - foreach($inside as $k=>$v){ + foreach($inside as $k=>$v){ if(array_key_exists($v['promote_id'],$senddata)){ - $senddata[$v['promote_id']]['inside_cash_count']= $v['pay_amount']; + $senddata[$v['promote_id']]['inside_cash_count']= $v['pay_amount']-$v['back_amount']; }else{ - $v['inside_cash_count'] = $v['pay_amount']; + $v['inside_cash_count'] = $v['pay_amount']-$v['back_amount']; unset($v['pay_amount']); $senddata[$v['promote_id']] = $v; }; } - if(array_key_exists(0,$senddata) || $_REQUEST['promote_id']==0){ - $pmap['status']=1; - if($istimeselect){ - $pmap['create_time'] = $istimeselect; - } - $admininside = M("provide_user p","tab_")->field("sum(amount) amount")->where($pmap)->find(); - if($admininside['amount'] >0){ - $senddata[0]['inside_cash_count']= $admininside['amount']; + if(!empty($senddata)){ + if(array_key_exists(0,$senddata) || $_REQUEST['promote_id']==0){ + $pmap['status']=1; + if($istimeselect){ + $pmap['create_time'] = $istimeselect; + } + $admininside = M("provide_user p","tab_")->field("sum(amount) amount")->where($pmap)->find(); + if($admininside['amount'] >0){ + $senddata[0]['inside_cash_count']= $admininside['amount']; + } + } - } $count = count($senddata); if ($_REQUEST['data_order'] != '') { @@ -242,7 +275,7 @@ class FinancePromoteController extends AdminController "inside_cash_count"=>0, ); foreach($senddata as $k=>$v){ - + if(empty($v['company_name'])) $v['company_name']= "万盟天下科技"; if(empty($v['promote_account'])) $v['promote_account']= "官方渠道"; if(!array_key_exists('cash_count',$v)) $v['cash_count']=0; @@ -277,7 +310,7 @@ class FinancePromoteController extends AdminController $this->meta_title = '渠道统计'; $this->display(); // dump($senddata); - + } private function promoteUserData($map,$istimeselect,$type="spend") { @@ -308,27 +341,28 @@ class FinancePromoteController extends AdminController SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as bind_coin_count, IFNULL(company_id,0) company_id,company_name,promote_id,promote.account promote_account"; return M() - ->table("tab_spend s") - ->field($field) - ->where($map) - ->join("tab_promote promote ON s.promote_id = promote.id", "left") - ->join("tab_promote_company company ON promote.company_id = company.id", "left") - ->group('promote_id') - ->select(); + ->table("tab_spend s") + ->field($field) + ->where($map) + ->join("tab_promote promote ON s.promote_id = promote.id", "left") + ->join("tab_promote_company company ON promote.company_id = company.id", "left") + ->group('promote_id') + ->select(); }else{ if($istimeselect){ $map['s.create_time']=$istimeselect; } $map['s.status']=1; $map['s.source_id']=0; - $map['s.type']=1; - $field= "sum(num) pay_amount,promote_id"; + $field= "SUM(CASE WHEN s.type = 1 THEN num ELSE 0 END) as pay_amount,SUM(CASE WHEN s.type = 2 THEN num ELSE 0 END) as back_amount, + IFNULL(company_id,0) company_id,company_name,promote_id,promote.account promote_account"; return M("promote_coin s","tab_") - ->field($field) - ->where($map) - ->join("tab_promote promote ON s.promote_id = promote.id","left") - ->group('promote_id') - ->select(); + ->field($field) + ->where($map) + ->join("tab_promote promote ON s.promote_id = promote.id","left") + ->join("tab_promote_company company ON promote.company_id = company.id", "left") + ->group('promote_id') + ->select(); } # code... } @@ -372,7 +406,7 @@ class FinancePromoteController extends AdminController } $this->assign('promote_level', $level); - //游戏统计列表 + //游戏统计列表 $data =self::gameStatisticsData($map, $row, $p); if(isset($_REQUEST['export'])){ $data =self::gameStatisticsData($map); @@ -425,7 +459,7 @@ class FinancePromoteController extends AdminController public function gameStatisticsDetail($p = 1) { set_time_limit(0); if(isset($_REQUEST['game_id'])){ - + //转化为名称和类型,重新请求 $game = M("game","tab_")->field("relation_game_name,sdk_version")->where(" id = {$_REQUEST['game_id']} ")->find(); if($game === false){ @@ -444,7 +478,7 @@ class FinancePromoteController extends AdminController if (!empty($_REQUEST['pay_order_number'])) { $map['pay_order_number'] = $_REQUEST['pay_order_number']; } - + if (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type']) || isset($_REQUEST['partner_id'])) { $map["game_id"] = array("in",implode(',', array_column(getGameidByPartnerNameType($_REQUEST['partner_id'],$_REQUEST['game_name'], $_REQUEST['game_type']), 'id')) ); } @@ -508,7 +542,7 @@ class FinancePromoteController extends AdminController $data = D('spend')->getSpendData($map,$field,$group,$order); }else { $data = D('spend')->getSpendData($map,$field,$group,$order,$page,$row); - } + } foreach($data as $key => $value) { $data[$key]['pay_way'] = getPayType($value['pay_way']); } @@ -621,7 +655,7 @@ class FinancePromoteController extends AdminController } elseif (isset($_REQUEST['time_end'])) { $map['pay_time'] = ['LT', strtotime($_REQUEST['time_end']) + 86399]; } - + if ($_REQUEST['promote_id'] != '') { if ($_REQUEST['promote_id'] == 0 || $_REQUEST['promote_type'] == 2) { $map['tab_spend.promote_id'] = $_REQUEST['promote_id']; @@ -642,7 +676,7 @@ class FinancePromoteController extends AdminController $row = 10; } $map['pay_status'] = 1; - + if (!empty(I('user_account'))) { $map['tab_spend.user_account'] = array('like','%'.I("user_account").'%'); } @@ -666,8 +700,8 @@ class FinancePromoteController extends AdminController $data = D('spend')->getSpendData($map, $field2, $group, $order,0,0, $join); }else { $data = D('spend')->getSpendData($map, $field2, $group, $order, $page, $row, $join); - } - + } + foreach($data as $key => $value) { $data[$key]['pay_way'] = getPayType($value['pay_way']); } @@ -765,15 +799,15 @@ class FinancePromoteController extends AdminController $total_cost = $admincount["amount"]?:0; if($count >0){ $admininside = M("provide_user p","tab_") - ->field("order_number,user_account,amount,balance,create_time") - ->join("left join tab_user as u on u.id = p.user_id") - ->where($pmap); + ->field("order_number,user_account,amount,balance,create_time") + ->join("left join tab_user as u on u.id = p.user_id") + ->where($pmap); if(isset($_REQUEST['export'])){ $admininside = $admininside->select(); }else { $admininside = $admininside->page($page, $row)->select(); - } + } foreach ($admininside as $k => $v) { $temp = [ @@ -789,7 +823,7 @@ class FinancePromoteController extends AdminController $senddata[] = $temp; } } - + }else{ if($istimeselect){ $map['s.create_time']=$istimeselect; @@ -797,9 +831,9 @@ class FinancePromoteController extends AdminController $map['s.status']=1; $map['s.source_id']=0; $ininsidecount = M("promote_coin s","tab_") - ->field("SUM(CASE WHEN s.type = 1 THEN num ELSE 0 END) as pay_amount,SUM(CASE WHEN s.type = 2 THEN num ELSE 0 END) as back_amount,count(*) count") - ->where($map) - ->find(); + ->field("SUM(CASE WHEN s.type = 1 THEN num ELSE 0 END) as pay_amount,SUM(CASE WHEN s.type = 2 THEN num ELSE 0 END) as back_amount,count(*) count") + ->where($map) + ->find(); $count = $ininsidecount["count"]?:0; $total_cost = ($ininsidecount["pay_amount"]-$ininsidecount["back_amount"]); if ($count >0) { @@ -812,7 +846,7 @@ class FinancePromoteController extends AdminController $ininside = $ininside->select(); }else { $ininside = $ininside->page($page, $row)->select(); - } + } foreach ($ininside as $k => $v) { $temp = [ "sn"=>$v['sn'], @@ -849,7 +883,7 @@ class FinancePromoteController extends AdminController if($page) {$this->assign('_page', $page);} $this->assign('data',$senddata); $this->display(); - + } } \ No newline at end of file diff --git a/Application/Admin/Controller/PromoteController.class.php b/Application/Admin/Controller/PromoteController.class.php index b53e4ffc9..9c3ccbb5a 100644 --- a/Application/Admin/Controller/PromoteController.class.php +++ b/Application/Admin/Controller/PromoteController.class.php @@ -277,21 +277,14 @@ class PromoteController extends ThinkController if (preg_match('/^[a-zA-Z0-9]{6,15}$/', I('post.account'))==false) { $this->error('账号只能是6-15位字母或数字'); } + $promote = M("promote", "tab_")->where(array("id" => $_POST['id']))->field('id, level')->find(); $data['account'] = I('post.account'); - $map1['id'] = array('neq',$_POST['id']); - $map1['account'] = $data['account']; - if ($this->accountExist($data['account'], $_POST['id'])) { $this->error('该账号已存在'); } - if (empty(I('company_id'))) { + if (empty(I('company_id')) && $promote['level'] ==1) { $this->error('请选择推广公司'); } - $pdata = D('Promote')->where($map1)->find(); - - if ($pdata) { - $this->error('渠道账号已存在'); - } empty(I('post.id')) ? : $data['id'] =I('post.id'); empty(I('post.password')) ? : $data['password'] =I('post.password'); empty(I('post.second_pwd')) ? : $data['second_pwd'] =I('post.second_pwd'); @@ -317,12 +310,16 @@ class PromoteController extends ThinkController $ba = new \Admin\Model\BusinessAffairsModel(); $ba->update_child($ba_id['ba_id'], $_REQUEST['ba_id'], $id); } - if (!empty(I('company_id'))) { + if (!empty(I('company_id')) && $promote['level'] ==1) { $data['company_id'] = I('company_id'); } - - $res=M("promote", "tab_")->where(array("id"=>$_POST['id']))->save($data); + $res = M("promote", "tab_")->where(array("id"=>$_POST['id']))->save($data); if ($res !== false) { + if (!empty(I('company_id')) && $promote['level'] ==1) {//修改会长底下推广员的推广公司 + M("promote", "tab_")->where("chain like '%/{$_POST['id']}/%'")->save([ + 'company_id' => I('company_id') + ]); + } $this->success("修改成功", U('lists')); } else { $this->error("修改失败"); diff --git a/Application/Admin/Controller/PromoteGameRatioController.class.php b/Application/Admin/Controller/PromoteGameRatioController.class.php index 7952b4fa2..e362834c7 100644 --- a/Application/Admin/Controller/PromoteGameRatioController.class.php +++ b/Application/Admin/Controller/PromoteGameRatioController.class.php @@ -62,7 +62,7 @@ class PromoteGameRatioController extends ThinkController $thisPromoteAccount = '未知'; $thisPromoteMobilePhone = '未知'; $thisPromoteCreateTime = '未知'; - $thisPromoteStatus = '未知'; + $thisPromoteStatus = '待审核'; $thisPromoteVerStatus = '未知'; $thisGameName = '未知'; $thisGameRatio = '0.00'; @@ -79,9 +79,9 @@ class PromoteGameRatioController extends ThinkController $thisPromoteAccount = $promotes[$thisPromoteId]['account']; $thisPromoteMobilePhone = $promotes[$thisPromoteId]['mobile_phone']; $thisPromoteCreateTime = date('Y-m-d H:i:s', $promotes[$thisPromoteId]['create_time']); - $thisPromoteStatus = get_status_title($promotes[$thisPromoteId]['status']); - $thisPromoteStatus = $thisPromoteStatus ?? '未知'; - $thisPromoteVerStatus = getPromoteVerStatus($promotes[$thisPromoteId]['status'], 2); + $thisPromoteStatus = get_info_status($promotes[$thisPromoteId]['status'], 3); + $thisPromoteStatus = $thisPromoteStatus ?? '待审核'; + $thisPromoteVerStatus = getPromoteVerStatus($promotes[$thisPromoteId]['ver_status'], 2); } if ($issetGame) { $thisGameName = $games[$thisGameId]['game_name']; @@ -146,16 +146,19 @@ class PromoteGameRatioController extends ThinkController if (empty($promoteGameRatio)) { $this->error('参数异常'); } + if ($promoteGameRatio['status'] == -1 || $save['begin_time'] != $promoteGameRatio['begin_time'] || $save['end_time'] != $promoteGameRatio['end_time'] || $save['ratio'] != $promoteGameRatio['ratio'] || $save['remark'] != $promoteGameRatio['remark']) { + $promoteId = $promoteGameRatio['promote_id']; + $this->isWithdraw($promoteId, $save['begin_time']);//是否存在开始时间后已提现数据 - $promoteId = $promoteGameRatio['promote_id']; - $this->isWithdraw($promoteId, $save['begin_time']);//是否存在开始时间后已提现数据 - - if ($promoteGameRatio['status'] == 1) { - $save['last_ratio'] = $promoteGameRatio['ratio']; - $save['last_ratio_status'] = 1; + if ($promoteGameRatio['status'] == 1) { + $save['last_ratio'] = $promoteGameRatio['ratio']; + $save['last_ratio_status'] = 1; + } + $save['id'] = intval($params['id']); + $result = D(self::MODEL_NAME)->save($save); + } else { + $result = true; } - $save['id'] = intval($params['id']); - $result = D(self::MODEL_NAME)->save($save); } else {//新增 if (empty($params['promote_id'])) { $this->error('请选择会长账号'); diff --git a/Application/Admin/Controller/QueryController.class.php b/Application/Admin/Controller/QueryController.class.php index 99a3a3e77..fde9a8bc0 100644 --- a/Application/Admin/Controller/QueryController.class.php +++ b/Application/Admin/Controller/QueryController.class.php @@ -2,7 +2,9 @@ namespace Admin\Controller; +use Home\Controller\FileController; use User\Api\UserApi as UserApi; +use Admin\Model\WithdrawModel; /** * 推广查询控制器 @@ -10,164 +12,369 @@ use User\Api\UserApi as UserApi; */ class QueryController extends ThinkController { - public function settlement($p = 0) + //生成提现单号 + public function produceWithdrawNumber() { + $prefix = 'WD_'; + $number = ''; + while (true) { + $randomNum = rand(10, 99); + $number = $prefix . time() . $randomNum; + $map['widthdraw_number'] = $number; + $res = M('withdraw', 'tab_')->where($map)->getField('id'); + if (!$res) { + break; + } + } + return $number; + } + public function settlement($p = 0) + { + $page = intval(I('p', 1)); //默认显示第一页数据 + $row = intval(I('row', 10)); $group = I('group', 1); $this->assign('group', $group); - if (isset($_REQUEST['total_status'])) { - unset($_REQUEST['total_status']); - } - - $this->m_title = '推广结算'; - $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Query/settlement', 'status' => 1])->find()); + $promoteId = I('promote_id', 0); if ($group == 1) { - if ($_REQUEST['unum'] == 2) { - $order = 'unum'; - $order_type = SORT_ASC; - } else if ($_REQUEST['unum'] == 1) { - $order = 'unum'; - $order_type = SORT_DESC; - } - if ($_REQUEST['spay_amount'] == 2) { - $order = 'spay_amount'; - $order_type = SORT_ASC; - } else if ($_REQUEST['spay_amount'] == 1) { - $order = 'spay_amount'; - $order_type = SORT_DESC; - } - $model = array( - 'title' => '渠道结算', - 'template_list' => 'settlement', - 'order' => $order, - 'order_type' => $order_type//0倒序 1 正序 - ); - $start = $_REQUEST['timestart']; - $end = $_REQUEST['timeend']; - if (I('group') != '') { - if ($start == '' || $end == '' && $_REQUEST['promote_account'] == '') { - $this->error('结算周期、所属渠道不能为空!', '', 1); + if (empty($promoteId)) { + $this->display(); + } else { + $promoteIds = M('promote', 'tab_')->where(['chain' => ['like', "/{$promoteId}/%"]])->getField('id', true); + $promoteIds[] = $promoteId; + $beginTime = I('timestart', get_lastweek_name(7)); + $endTime = I('timeend', get_lastweek_name(1)); + $sortBy = I('sort_by', ''); + $sortColumn = I('sort_column', ''); + $order = 'tab_spend.pay_time'; + $orderType = 'desc'; + + if (in_array($sortColumn, ['user_num', 'sum_amount'])) { + $order = $sortColumn; } - if ($start == '' || $end == '') { - $this->error('请选择结算周期!', '', 1); + if ($sortBy == 1) { + $orderType = 'desc'; + } elseif ($sortBy == 2) { + $orderType = 'asc'; } - if ($_REQUEST['promote_account'] == '') { - $this->error('请选择渠道!', '', 1); + $beginTime = strtotime($beginTime); + $endTime = strtotime($endTime) + 3600 * 24 - 1; + + $spendMap['tab_spend.pay_status'] = 1; + $spendMap['tab_spend.selle_status'] = 0; + $spendMap['tab_spend.pay_time'] = ['between', [$beginTime, $endTime]]; + $spendMap['tab_spend.promote_id'] = ['in', $promoteIds]; + $spendField = 'tab_spend.promote_account, tab_spend.game_name, sum(tab_spend.pay_amount) as sum_amount, tab_spend.selle_ratio, sum(if(tab_spend.selle_ratio > 0, tab_spend.pay_amount * tab_spend.selle_ratio, 0)) as settlement_amount'; + $userMap['tab_user.promote_id'] = ['in', $promoteIds]; + $userMap['_string'] = 'tab_user.promote_id = tab_spend.promote_id'; + $userField = M('user', 'tab_')->field('count(tab_user.id) as user_num') + ->where($userMap) + ->buildSql(); + $field = "{$spendField}, {$userField} as user_num"; + + $query = M('spend', 'tab_')->field($field) + ->where($spendMap) + ->group('tab_spend.selle_ratio, tab_spend.game_id, tab_spend.promote_id') + ->order("{$order} {$orderType}") + ->page($page, $row) + ->buildSql(); + $records = M()->table($query) + ->alias('record') + ->select(); + $countQuery = M('spend', 'tab_')->field('tab_spend.id') + ->where($spendMap) + ->group('tab_spend.selle_ratio, tab_spend.game_id, tab_spend.promote_id') + ->buildSql(); + $count = M()->table($countQuery) + ->alias('tab_spend') + ->count(); + $page = set_pagination($count, $row); + + if (!empty($records)) { + $promote = M('promote', 'tab_')->find($promoteId); + foreach ($records as &$record) { + $record['promote_account'] = $promote['account'] ?? '未知'; + $record['settlement_amount'] = bcdiv($record['settlement_amount'], 100, 2); + } } - } - $smap['tab_spend.pay_status'] = 1; - //判断是否结算绑币 - if ($_REQUEST['bind_coin'] == 0) { - $smap['tab_spend.pay_way'] = array('neq', -1); - } - $this->meta_title = '渠道结算列表'; - $this->assign('setdate', date("Y-m-d", strtotime("-1 day"))); - $this->assign('is_admin', is_administrator()); - if ($start && $end) { - if ((strtotime($end) + 24 * 60 * 60 - 1) < strtotime($start)) { - $this->error('时间选择不正确!', U('Query/settlement'), ''); - } - $umap['register_time'] = array('BETWEEN', array(strtotime($start), strtotime($end) + 24 * 60 * 60 - 1)); - if (isset($_REQUEST['game_name']) && $_REQUEST['game_name'] != '') { - $umap['fgame_id'] = get_game_id($_REQUEST['game_name']); - $smap['tab_spend.game_id'] = get_game_id($_REQUEST['game_name']); + $totalField = 'sum(if(tab_spend.selle_ratio > 0, tab_spend.pay_amount * tab_spend.selle_ratio, 0)) as settlement_amount'; + $total = array_sum(array_column($records, 'settlement_amount'));//当页 + $zTotal = null_to_0(M('spend', 'tab_')->field($totalField)->where($spendMap)->find()['settlement_amount']);//累计 + $zTotal = bcdiv($zTotal, 100 ,2); + unset($spendMap['tab_spend.pay_time']); + $spendMap['_string'] = 'tab_spend.pay_time' . total(1); + $tTotal = null_to_0(M('spend', 'tab_')->field($totalField)->where($spendMap)->find()['settlement_amount']);//今日 + $tTotal = bcdiv($tTotal, 100 ,2); + $spendMap['_string'] = 'tab_spend.pay_time' . total(5); + $yTotal = null_to_0(M('spend', 'tab_')->field($totalField)->where($spendMap)->find()['settlement_amount']);//昨日 + $yTotal = bcdiv($yTotal, 100 ,2); + + if($page) { + $this->assign('_page', $page); } - if (isset($_REQUEST['promote_account']) && $_REQUEST['promote_account'] != '') { - $allid = get_subordinate_promote_($_REQUEST['promote_account']); - $allid[] = $_REQUEST['promote_account']; - $umap['tab_user.promote_account'] = array('in', $allid); - $smap['tab_spend.promote_account'] = array('in', $allid); - } else { - $this->error('未选择渠道!', '', 1); - } - $umap['is_check'] = 1; - $umap['settle_check'] = 0; - $smap['pay_time'] = array('BETWEEN', array(strtotime($start), strtotime($end) + 24 * 60 * 60 - 1)); - $smap['is_check'] = 1; - $smap['settle_check'] = 0; - //为数据权限添加 - setPowerPromoteIds($umap, 'tab_user.promote_id'); - setPowerPromoteIds($smap, 'tab_spend.promote_id'); - $map['umap'] = $umap; - $map['smap'] = $smap; - - $user = A('Settlement', 'Event'); - - - $user->settlement($model, $p, $map); - } else { + $this->assign('records', $records); + $this->assign('total', $total); + $this->assign('tTotal', $tTotal); + $this->assign('yTotal', $yTotal); + $this->assign('zTotal', $zTotal); + $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Query/settlement', 'status' => 1])->find()); + $this->m_title = '推广结算'; $this->display(); } - } - if ($group == 2) { - if (isset($_REQUEST['stimestart']) && isset($_REQUEST['stimeend'])) { - $map['create_time'] = array('BETWEEN', array(strtotime($_REQUEST['stimestart']), strtotime($_REQUEST['stimeend']) + 24 * 60 * 60 - 1)); - } elseif (isset($_REQUEST['stimestart'])) { - $map['create_time'] = array('BETWEEN', array(strtotime($_REQUEST['stimestart']), time())); - } elseif (isset($_REQUEST['stimeend'])) { - $map['create_time'] = array('LT', (strtotime($_REQUEST['stimeend']) + 24 * 60 * 60 - 1)); + } elseif ($group == 2) { + $map['_string'] = '1 = 1'; + $createTime = strtotime(I('create_time', '')); + $withdrawNumber = I('widthdraw_number', ''); + $status = intval(I('status', '')); + $opType = intval(I('op_type', 0)); + if ($createTime) { + $createTimeEnd = $createTime + 3600 * 24 - 1; + $map['create_time'] = ['between', [$createTime, $createTimeEnd]]; } - if (isset($_REQUEST['timestart']) && isset($_REQUEST['timeend'])) { - $map['starttime'] = ['GT', strtotime($_REQUEST['timestart'])]; - $map['endtime'] = ['LT', strtotime($_REQUEST['timeend']) + 24 * 60 * 60]; - } elseif (isset($_REQUEST['timestart'])) { - $map['starttime'] = ['GT', strtotime($_REQUEST['timestart'])]; - } elseif (isset($_REQUEST['timeend'])) { - $map['endtime'] = ['LT', strtotime($_REQUEST['timeend']) + 24 * 60 * 60]; + if ($promoteId) { + $map['promote_id'] = $promoteId; } - if (isset($_REQUEST['game_name'])) { - if ($_REQUEST['game_name'] == '全部') { - unset($_REQUEST['game_name']); - } else { - $map['game_name'] = $_REQUEST['game_name']; - } + if ($withdrawNumber) { + $map['widthdraw_number'] = ['like', "{$withdrawNumber}%"]; } - if (isset($_REQUEST['promote_account'])) { - if ($_REQUEST['promote_account'] == '全部') { - unset($_REQUEST['promote_account']); - } else { - $map['promote_account'] = $_REQUEST['promote_account']; + if (isset($_REQUEST['status'])) { + $map['status'] = $status; + } + if ($opType) { + $map['op_type'] = $opType; + } + + $records = M('withdraw', 'tab_')->field('id, promote_account, widthdraw_number, sum_money, op_id, op_type, last_op_id, last_op_type, settlement_begin_time, settlement_end_time, create_time, status, respond') + ->where($map) + ->order('create_time desc') + ->page($page, $row) + ->select(); + $count = M('withdraw', 'tab_')->field('id, promote_account, widthdraw_number, sum_money, op_id, op_type, last_op_id, last_op_type, settlement_begin_time, settlement_end_time, create_time, status, respond') + ->where($map) + ->count(); + if (!empty($records)) { + foreach ($records as &$record) { + $record['settlement_begin_time'] = $record['settlement_begin_time'] ? date('Y-m-d H:i:s', $record['settlement_begin_time']) : '--'; + $record['settlement_end_time'] = date('Y-m-d H:i:s', $record['settlement_end_time']); + $record['create_time'] = date('Y-m-d H:i:s', $record['create_time']); + $record['status_text'] = promoteWithdrawStatus($record['status']); + if ($record['status'] == -2) { + $record['status_text'] = '' . $record['status_text'] . ''; + } } } - if (!empty($_REQUEST['settlement_number'])) { - $map['settlement_number'] = $_REQUEST['settlement_number']; + + $page = set_pagination($count, $row); + if($page) { + $this->assign('_page', $page); } + $this->assign('records', $records); + $this->display(); + } + } - $map['developers'] = 0; + public function settlementWithdraw() + { + $beginTime = strtotime(I('begin_time', '')); + $endTime = strtotime(I('end_time', '')); + $promoteId = intval(I('promote_id', 0)); + if ($beginTime == 0 || $endTime == 0) { + $data['status'] = 0; + $data['msg'] = '时间参数错误'; + $this->ajaxReturn($data); + } + if ($beginTime > $endTime) { + $data['status'] = 0; + $data['msg'] = '开始时间必须小于等于结束时间'; + $this->ajaxReturn($data); + } + if ($promoteId == 0) { + $data['status'] = 0; + $data['msg'] = '请选择会长账号'; + $this->ajaxReturn($data); + } - $model = array( - 'm_name' => 'settlement', - 'fields' => array( - 'settlement_number', - 'starttime', 'endtime', - 'promote_id', 'promote_account', - 'sum(total_money) as total_money', - 'sum(total_number) as total_number', - 'sum(sum_money) as sum_money', - 'bind_coin_status', - 'create_time'), - 'group' => 'promote_id,starttime,endtime,create_time,bind_coin_status', - 'order' => 'create_time desc ', - 'title' => '结算账单', - 'template_list' => 'settlement', - ); - //为数据权限添加 - setPowerPromoteIds($map); - $map1 = $map; + $promote = M('promote', 'tab_')->find($promoteId); + if (empty($promote)) { + $data['status'] = 0; + $data['msg'] = '数据异常'; + $this->ajaxReturn($data); + } + if ($promote['level'] != 1) { + $data['status'] = 0; + $data['msg'] = '非会长账号,无法执行此操作'; + $this->ajaxReturn($data); + } + if ($promote['ver_status'] != 1) { + $data['status'] = 0; + $data['msg'] = '该会长未通过资质认证审核,暂时无法提现'; + $this->ajaxReturn($data); + } + + $endTime += 3600 * 24 - 1; + $spendModel = M('spend', 'tab_'); + $map['chain'] = ['like', $promote['chain'] . $promote['id'] . '/%']; + $promoteIds = M('promote', 'tab_')->where($map)->getField('id', true); + $promoteIds[] = $promote['id']; + $promoteIds = implode(',', $promoteIds); + + $map = []; + $map['pay_status'] = 1; + $map['selle_status'] = 0; + $map['promote_id'] = ['in', $promoteIds]; + $map['pay_time'] = ['between', [$beginTime, $endTime]]; + $balance = $spendModel->field("sum(pay_amount * selle_ratio) as balance") + ->where($map) + ->find()['balance']; + $balance = bcdiv($balance, 100, 2); + if ($balance < 100) { + $data['status'] = 0; + $data['msg'] = '累计结算低于100元,无法提现!'; + $this->ajaxReturn($data); + } + $spendIds = $spendModel->where($map)->getField('id', true); + if (empty($spendIds)) { + $data['status'] = 0; + $data['msg'] = '数据异常'; + $this->ajaxReturn($data); + } + + $thisTime = time(); + $add['sum_money'] = $balance; + $add['promote_id'] = $promote['id']; + $add['promote_account'] = $promote['account']; + $add['create_time'] = $thisTime; + $add['status'] = 0; + $add['widthdraw_number'] = D('withdraw')->produceWithdrawNumber(); + $add['settlement_begin_time'] = $beginTime; + $add['settlement_end_time'] = $endTime; + $add['spend_ids'] = ''; + $add['op_id'] = is_login(); + $add['op_type'] = 2; + $add['last_op_id'] = $add['op_id']; + $add['last_op_type'] = 2; + + M()->startTrans();//开启事物 + $withdrawId = M('withdraw', 'tab_')->add($add); + if (!$withdrawId) { + M()->rollback();//事物回滚 + $data['status'] = 0; + $data['msg'] = '提现失败'; + $this->ajaxReturn($data); + } + + $map = []; + $map['id'] = ['in', $spendIds]; + $save['selle_status'] = 1; + $save['selle_time'] = $thisTime; + $save['withdraw_id'] = $withdrawId; + $res = $spendModel->where($map)->save($save); + if ($res === false) { + M('withdraw', 'tab_')->delete($withdrawId); + M()->rollback();//事物回滚 + $data['status'] = 0; + $data['msg'] = '提现失败'; + $this->ajaxReturn($data); + } + + M()->commit();//事物提交 + $data['status'] = 1; + $data['msg'] = '提现成功'; + $this->ajaxReturn($data); + } + + public function renewReview() + { + $id = intval(I('id', 0)); + $data = M('withdraw', 'tab_')->find($id); + if (empty($data) || $data['status'] != -1) { + $data['status'] = 0; + $data['msg'] = '数据异常'; + $this->ajaxReturn($data); + } - $ztotal = null_to_0(D('settlement')->where($map1)->sum('sum_money*10000') / 10000); - $this->assign('ztotal', $ztotal); - $ttotal = null_to_0(D('settlement')->where('create_time' . total(1))->sum('sum_money*10000') / 10000); - $this->assign('ttotal', $ttotal); - $ytotal = null_to_0(D('settlement')->where('create_time' . total(5))->sum('sum_money*10000') / 10000); - $this->assign('ytotal', $ytotal); - $user = A('Bill', 'Event'); + $save['id'] = $id; + $save['status'] = 0; + $save['last_up_update_time'] = time(); + $save['last_op_id'] = is_login(); + $save['last_op_type'] = 2; + $res = M('withdraw', 'tab_')->save($save); + if ($res === false) { + $data['status'] = 0; + $data['msg'] = '提交失败'; + } else { + $data['status'] = 1; + $data['msg'] = '提交成功'; + } + $this->ajaxReturn($data); + } - $user->money_list($model, $p, $map); + public function cancelWithdraw() + { + $id = intval(I('id', 0)); + $data = M('withdraw', 'tab_')->find($id); + if (empty($data) || !in_array($data['status'], [-1, 0])) { + $data['status'] = 0; + $data['msg'] = '数据异常'; + $this->ajaxReturn($data); } + $spendMap['withdraw_id'] = $id; + $spendIds = M('Spend', 'tab_')->where($spendMap)->getField('id', true); + if (empty($spendIds)) { + $data['status'] = 0; + $data['msg'] = '数据异常'; + $this->ajaxReturn($data); + } + $spendIds = implode(',', $spendIds); + $time = time(); + $withdrawSave['id'] = $id; + $withdrawSave['status'] = -2; + $withdrawSave['spend_ids'] = $spendIds; + $withdrawSave['last_up_update_time'] = $time; + $withdrawSave['last_op_id'] = is_login(); + $withdrawSave['last_op_type'] = 2; + + M('withdraw', 'tab_')->startTrans();//开启事物 + $withdrawRes = M('withdraw', 'tab_')->save($withdrawSave); + if ($withdrawRes === false) { + M('withdraw', 'tab_')->rollback();//事物回滚 + $data['status'] = 0; + $data['msg'] = '撤销失败'; + $this->ajaxReturn($data); + } + + $spendSave['selle_status'] = 0; + $spendSave['withdraw_id'] = 0; + $spendRes = M('spend', 'tab_')->where($spendMap)->save($spendSave); + if ($spendRes === false) { + M('withdraw', 'tab_')->rollback();//事物回滚 + $data['status'] = 0; + $data['msg'] = '撤销失败'; + } else { + M('withdraw', 'tab_')->commit();//事物提交 + $data['status'] = 1; + $data['msg'] = '撤销成功'; + } + $this->ajaxReturn($data); + } + + public function downloadProve() + { + $id = intval(I('id', 0)); + if ($id) { + $withdraw = M('withdraw', 'tab_')->find($id); + if (empty($withdraw) || $withdraw['status'] != 2 || !$withdraw['transfer_proof']) { + $this->error('网络异常'); + } + + $file = new FileController(); + $file->download($withdraw['transfer_proof']); + } else { + $this->error('参数异常'); + } } public function cpsettlement($p = 0) @@ -664,6 +871,9 @@ class QueryController extends ThinkController if (isset($_REQUEST['ti_status'])) { $map['status'] = $_REQUEST['ti_status']; } + if (isset($_REQUEST['op_type'])) { + $map['op_type'] = $_REQUEST['op_type']; + } if (isset($_REQUEST['promote_account'])) { if ($_REQUEST['promote_account'] == '全部') { unset($_REQUEST['promote_account']); diff --git a/Application/Admin/Model/WithdrawModel.class.php b/Application/Admin/Model/WithdrawModel.class.php index 324bd151c..87d60eb32 100644 --- a/Application/Admin/Model/WithdrawModel.class.php +++ b/Application/Admin/Model/WithdrawModel.class.php @@ -15,6 +15,10 @@ use Think\Model; */ class WithdrawModel extends Model{ + const OP_TYPE_PROMOTE = 1; + const OP_TYPE_ADMIN = 2; + const OP_TYPE_AUTO = 3; + /** * 构造函数 * @param string $name 模型名称 @@ -28,8 +32,11 @@ class WithdrawModel extends Model{ parent::__construct($name, $tablePrefix, $connection); } - - + public static $opTypeList = [ + self::OP_TYPE_PROMOTE => '推广员', + self::OP_TYPE_ADMIN => '管理员', + self::OP_TYPE_AUTO => '自动', + ]; /* * 开发者提现未处理列表 @@ -102,4 +109,20 @@ class WithdrawModel extends Model{ } + //生成提现单号 + public function produceWithdrawNumber() + { + $prefix = 'WD_'; + $number = ''; + while (true) { + $randomNum = rand(10, 99); + $number = $prefix . time() . $randomNum; + $map['widthdraw_number'] = $number; + $res = $this->where($map)->getField('id'); + if (!$res) { + break; + } + } + return $number; + } } diff --git a/Application/Admin/View/Deposit/lists.html b/Application/Admin/View/Deposit/lists.html index 2f11a20f0..fa8e433dd 100644 --- a/Application/Admin/View/Deposit/lists.html +++ b/Application/Admin/View/Deposit/lists.html @@ -78,21 +78,21 @@ - - - - - - - - - - - - - - - +
+ + - +
+
+ +
@@ -112,7 +112,7 @@ 订单号 - 玩家账号 + 玩家账号 所属推广员 @@ -120,14 +120,14 @@ 充值方式 - 充值ip + 充值ip 充值时间 订单状态 - 操作 + 操作 @@ -138,14 +138,14 @@ - {:$data['pay_order_number']} - + {:$data['pay_order_number']} + {$data.user_account} {$data.user_account|encryptStr} - + 官方渠道 @@ -159,8 +159,8 @@ {$data.pay_amount} - {:get_pay_way($data['pay_way'])} - {$data.pay_ip} + {:get_pay_way($data['pay_way'])} + {$data.pay_ip} {:set_show_time($data['create_time'],'','pay')} @@ -169,15 +169,15 @@ {:get_info_status($data['pay_status'],9)} - - + +
通知到账 - +
diff --git a/Application/Admin/View/FinancePromote/index.html b/Application/Admin/View/FinancePromote/index.html index 9f60ea626..e78c19eaa 100644 --- a/Application/Admin/View/FinancePromote/index.html +++ b/Application/Admin/View/FinancePromote/index.html @@ -407,19 +407,24 @@ autoclose: true, pickerPosition: 'bottom-left' }) + var promote_id = "{:I('promote_id')}"; - function getPromotersByLevel() { + var company_id = "{:I('company_id')}"; + function getPromotersByCompanyid() { + var company_id = $("#company_id option:selected").val(); + if(!company_id){ + company_id = -1; + } $.ajax({ - url: "{:U('Ajax/getPromotersByLevel')}", + url: "{:U('Ajax/getPromotersByCompanyid')}", type: "get", - data: { level: 1 }, + data: { company_id:company_id}, dataType: 'json', success: function (response) { - str = ''; - // $.each(response.data, function(index, item){ - // console.log(item.id); - // str += ''; - // }); + str = ''; + if(company_id == 0 || company_id ==-1){ + str +=''; + } data = response.data; for (var i in data) { str += "" @@ -430,7 +435,11 @@ } }) } - getPromotersByLevel(); + getPromotersByCompanyid(); + + $("#company_id").change(function(){ + getPromotersByCompanyid(); + }) }) diff --git a/Application/Admin/View/FinancePromote/promoteUser.html b/Application/Admin/View/FinancePromote/promoteUser.html index 670441488..faee12887 100644 --- a/Application/Admin/View/FinancePromote/promoteUser.html +++ b/Application/Admin/View/FinancePromote/promoteUser.html @@ -382,18 +382,19 @@ pickerPosition: 'bottom-left' }) var promote_id = "{:I('promote_id')}"; - function getPromotersByLevel() { + var company_id = "{:I('company_id')}"; + function getPromotersByCompanyid() { + var company_id = $("#company_id option:selected").val(); + if(!company_id){ + company_id = -1; + } $.ajax({ - url: "{:U('Ajax/getPromotersByLevel')}", + url: "{:U('Ajax/getPromotersByCompanyid')}", type: "get", - data: { level: 1 }, + data: { company_id:company_id}, dataType: 'json', success: function (response) { - str = ''; - // $.each(response.data, function(index, item){ - // console.log(item.id); - // str += ''; - // }); + str = ''; data = response.data; for (var i in data) { str += "" @@ -404,7 +405,11 @@ } }) } - getPromotersByLevel(); + getPromotersByCompanyid(); + + $("#company_id").change(function(){ + getPromotersByCompanyid(); + }) }) diff --git a/Application/Admin/View/Promote/edit.html b/Application/Admin/View/Promote/edit.html index f192e7154..f7eb7fc90 100644 --- a/Application/Admin/View/Promote/edit.html +++ b/Application/Admin/View/Promote/edit.html @@ -180,7 +180,9 @@ 推广公司: - + disabled style="background:#CCCCCC" > diff --git a/Application/Admin/View/Query/settlement.html b/Application/Admin/View/Query/settlement.html index 12512b82d..e704735ff 100644 --- a/Application/Admin/View/Query/settlement.html +++ b/Application/Admin/View/Query/settlement.html @@ -30,98 +30,89 @@ -
- -
-
- 参与结算设置: - -      - -
-
-

注意①:推广结算只结算消费到游戏的所有订单记录。(系统默认全部排除绑币,可视情况自行勾选)

-

注意②:包含绑币勾选请慎重,由于玩家账户部分绑币的来源属于后台发放或者会长代充等,涉及到成本盈亏,是否参与推广员结算请考虑清楚!

-

注意③:推广结算时间请按规律时间统一结算,否则时间不统一容易导致个别游戏在统一时间内无法结算。(结算时间只可选到前一天)

-
-
-
- - - -
- -
-
-
+
+
+ + 提 现 + +
+
+
+
- value="{:get_lastweek_name(7)}" value="{:I('timestart')}" placeholder="结算周期起始时间" /> - - -
- value="{:get_lastweek_name(1)}" value="{:I('timeend')}" placeholder="结算周期结束时间" /> - -
+ + - +
+ + +
-
- - + + +
+
- - - -
- 搜索 -
-
- -
- - - -
- - -
-
- -
- 搜索 -
-
+
+
+ +
+ + + + +
+ 搜索 +
+
+ +
+ +
+
+ +
+
+ +
+
+ 搜索 +
+
- -
@@ -130,21 +121,13 @@ - - - - 结算周期 - 推广员账号 - 游戏名称 - 总充值 - - 总注册 - 结算模式 - 分成比例 - 注册单价 - 结算金额 - 状态 - + 推广员账号 + 游戏名称 + 总充值 + 总注册 + 结算模式 + 分成比例 + 结算金额 @@ -154,211 +137,94 @@ .data-table tbody td{border-right:1px solid #DDDDDD;} .d_list .drop-down ul {z-index:999;} - + aOh! 暂时还没有内容! - - - - - - {:I('timestart')} 至 {:I('timeend')} - {:get_promote_name($data['pid'])} - {:get_game_name($data['game_id'])} - {$data['spay_amount']|default=0} - {$data['unum']|default=0} - -
-
- -
-
- - - {$data.ratio}0% - 修改 - - - {$data.money}0 - 修改 - - - {:round($data['spay_amount'] * $data['ratio']/100,2)} - - - 已结算 - - 可结算 - - + + + {$record.promote_account} + {$record.game_name} + {$record['sum_amount']|default=0} + {$record['user_num']|default=0} + CPS + {$record['selle_ratio']|default=0}% + + {$record['settlement_amount']} + + + + 汇总 + 当页结算:{$total}元 ; 今日结算:{$tTotal}元 ; 昨日结算:{$yTotal}元 ; 累计结算:{$zTotal}元 +
- - - - - - - - - - + + + + + + + + + + + + + - + - - - - - - - - - + + + + + + + + + + + + + - - - -
推广员账号结算周期结算单号总充值总注册结算金额结算范畴结算时间详情推广员账号结算单号结算金额操作人操作人类型最后操作人最后操作人类型结算开始时间结算截止时间提现时间提现状态说明操作
- - {:get_promote_name($data['promote_id'])} - - {:encryptStr(get_promote_name($data['promote_id']))} - - {$data.starttime|date='Y-m-d',###}至{$data.endtime|date='Y-m-d',###}{$data.settlement_number}{$data.total_money}{$data.total_number} - {$data.sum_money} - {:get_bind_coin_status($data['bind_coin_status'])} - {$data.create_time|date='Y-m-d',###} - - 查看 - {$record.promote_account}{$record.widthdraw_number}{$record.sum_money} + + {:get_promote_name($record['op_id'])} + + {:getAdminNickname($record['op_id'])} + + 自动 + + {:getPromoteWithdrawOpType($record['op_type'])} + + {:get_promote_name($record['last_op_id'])} + + {:getAdminNickname($record['last_op_id'])} + + 自动 + + {:getPromoteWithdrawOpType($record['last_op_type'])}{$record.settlement_begin_time}{$record.settlement_end_time}{$record.create_time}{$record.status_text}{$record.respond} + + 汇款证明 + + 重新审核 + + + 撤销提现 + +
汇总当页结算:{$total}元 ; 今日结算:{$ttotal}元 ; 昨日结算:{$ytotal}元 ; 累计结算:{$ztotal}元
@@ -369,7 +235,7 @@ - + diff --git a/Application/Admin/View/Query/withdraw.html b/Application/Admin/View/Query/withdraw.html index 4a3131a7e..c675cae0b 100644 --- a/Application/Admin/View/Query/withdraw.html +++ b/Application/Admin/View/Query/withdraw.html @@ -78,13 +78,21 @@
- $value) :?>
+
+ +
搜索 @@ -106,9 +114,15 @@ 提现单号 - 提现金额 + 提现金额 推广员账号 - 申请时间 + 操作人 + 操作人类型 + 最后操作人 + 最后操作人类型 + 结算开始时间 + 结算截止时间 + 申请时间 提现状态 说明 审核时间 @@ -142,8 +156,30 @@ {:encryptStr(get_promote_name($data['promote_id']))} + + + {:get_promote_name($data['op_id'])} + + {:getAdminNickname($data['op_id'])} + + 自动 + + + {:getPromoteWithdrawOpType($data['op_type'])} + + + {:get_promote_name($data['last_op_id'])} + + {:getAdminNickname($data['last_op_id'])} + + 自动 + + + {:getPromoteWithdrawOpType($data['last_op_type'])} + {$data.settlement_begin_time|date='Y-m-d H:i:s',###}--- + {$data.settlement_end_time|date='Y-m-d H:i:s',###}--- {$data.create_time|date='Y-m-d H:i:s',###}--- - {:promoteWithdrawStatus($data['status'])} + style="color: #999;">{:promoteWithdrawStatus($data['status'])} {$data.respond} {$data.audit_time|date='Y-m-d H:i:s',###}--- @@ -161,7 +197,7 @@ 汇总 - 当页提现:{:null_to_0(array_sum(array_column(arrayPromoteWithdrawStatus('status','',$list_data),'sum_money')))}元 ; 今日提现:{:null_to_0(floor($ttotal*100)/100)}元 ; 昨日提现:{:null_to_0(floor($ytotal*100)/100)}元 ; 累计提现:{:null_to_0(floor($total*100)/100)}元 + 当页提现:{:null_to_0(array_sum(array_column(arrayPromoteWithdrawStatus('status','',$list_data),'sum_money')))}元 ; 今日提现:{:null_to_0(floor($ttotal*100)/100)}元 ; 昨日提现:{:null_to_0(floor($ytotal*100)/100)}元 ; 累计提现:{:null_to_0(floor($total*100)/100)}元 diff --git a/Application/Admin/View/SuperStatistical/index.html b/Application/Admin/View/SuperStatistical/index.html index c90d8f4a2..bede45c48 100644 --- a/Application/Admin/View/SuperStatistical/index.html +++ b/Application/Admin/View/SuperStatistical/index.html @@ -93,9 +93,9 @@ aOh! 暂时还没有内容! - {$data['authorization_all_num']} - {$data['buy_num']} - {$data['money_all']} + {$data['authorization_all_num']} + {$data['buy_num']} + {$data['money_all']} diff --git a/Application/Base/Service/PromoteService.class.php b/Application/Base/Service/PromoteService.class.php index c513618d2..06cf3c2f4 100644 --- a/Application/Base/Service/PromoteService.class.php +++ b/Application/Base/Service/PromoteService.class.php @@ -930,14 +930,14 @@ class PromoteService { 'real_name' => $params['real_name'], 'email' => $params['email'], 'idcard' => $params['idcard'] ?? '', - 'status' => $params['status'], + 'status' => $params['status'] ?? 0, 'mobile_phone' => $params['mobile_phone'], 'bank_name' => $params['bank_name'] ?? '', 'bank_card' => $params['bank_card'], 'parent_id' => $parent ? $parent['id'] : 0, 'parent_name' => $parent ? $parent['account'] : '官方渠道', 'admin_id' => $params['admin_id'] ?? 0, - 'company_id' => $params['company_id'] ?? 0, + 'company_id' => $params['company_id'] ?? 0, 'invite_code' => $params['invite_code'] ?? '', 'create_time' => time(), ]; diff --git a/Application/Common/Common/function.php b/Application/Common/Common/function.php index c7d4909d2..b45da22c6 100644 --- a/Application/Common/Common/function.php +++ b/Application/Common/Common/function.php @@ -1430,6 +1430,7 @@ if (!function_exists('dd')) { function promoteWithdrawStatus($status = null) { $statusData = [ + -2 => '已撤销', -1 => '审核未通过', 0 => '待审核', 1 => '汇款中', @@ -1443,3 +1444,22 @@ function promoteWithdrawStatus($status = null) return $statusData; } +//获取提现操作人类型 +function getPromoteWithdrawOpType($opType = null) +{ + if ($opType) { + return Admin\Model\WithdrawModel::$opTypeList[$opType] ?? '未知'; + } else { + return Admin\Model\WithdrawModel::$opTypeList; + } +} + +//获取管理员账号 +function getAdminNickname($adminId) +{ + $adminId = intval($adminId); + if ($adminId) { + return M('member')->where(array('id' => $adminId))->getField('nickname'); + } + return '未知'; +} diff --git a/Application/Home/Controller/FinanceController.class.php b/Application/Home/Controller/FinanceController.class.php index c0c245b2e..a61cc0b36 100644 --- a/Application/Home/Controller/FinanceController.class.php +++ b/Application/Home/Controller/FinanceController.class.php @@ -284,6 +284,7 @@ class FinanceController extends BaseController //提现 public function withdraw() { + $this->error('无法执行此操作'); //是否是会长 $this->purview(); //验证安全密码 @@ -414,7 +415,7 @@ class FinanceController extends BaseController } } - $data = $model->field('id,widthdraw_number,create_time,settlement_end_time,sum_money,status,respond,transfer_proof') + $data = $model->field('id, widthdraw_number, create_time, settlement_begin_time, settlement_end_time, sum_money, status, respond, transfer_proof, op_id, op_type, last_op_id, last_op_type') ->where($map) ->order('id desc') ->page($page, $row) @@ -426,8 +427,13 @@ class FinanceController extends BaseController if (!empty($data)) { foreach ($data as &$list) { $list['create_time'] = date('Y-m-d H:i:s', $list['create_time']); + $list['settlement_begin_time'] = $list['settlement_begin_time'] ? date('Y-m-d H:i:s', $list['settlement_begin_time']) : '--'; $list['settlement_end_time'] = date('Y-m-d H:i:s', $list['settlement_end_time']); $list['status_name'] = FinanceController::$withdrawStatus[$list['status']]; + $list['op_id'] = $this->getOpIdByType($list['op_id'], $list['op_type']); + $list['last_op_id'] = $this->getOpIdByType($list['last_op_id'], $list['last_op_type']); + $list['op_type'] = getPromoteWithdrawOpType($list['op_type']); + $list['last_op_type'] = getPromoteWithdrawOpType($list['last_op_type']); switch ($list['status']) { case -2: $list['status_name'] = '' . $list['status_name'] . ''; @@ -454,6 +460,23 @@ class FinanceController extends BaseController $this->display(); } + private function getOpIdByType($opId, $opType) + { + switch ($opType) { + case 1: + $opId = get_promote_name($opId); + break; + case 2: + $opId = getAdminNickname($opId); + break; + case 3: + $opId = '自动'; + break; + } + + return $opId; + } + //提现明细 public function withdrawDtl() { @@ -584,6 +607,7 @@ class FinanceController extends BaseController //审核拒绝 重新审核 public function renewReview() { + $this->error('无法执行此操作'); //是否是会长 $this->purview(); //验证安全密码 @@ -624,6 +648,7 @@ class FinanceController extends BaseController //撤销提现 public function cancelWithdraw() { + $this->error('无法执行此操作'); //是否是会长 $this->purview(); //验证安全密码 diff --git a/Application/Home/Controller/PromoteController.class.php b/Application/Home/Controller/PromoteController.class.php index 6b6d5ead8..d43e3250f 100644 --- a/Application/Home/Controller/PromoteController.class.php +++ b/Application/Home/Controller/PromoteController.class.php @@ -985,6 +985,9 @@ class PromoteController extends BaseController } else { $parent = $loginPromote; } + if ($parent) { + $params['company_id'] = $parent['company_id']; + } if (C('PROMOTE_AUTO_AUDIT') == 1) { $params['status'] = 1; } diff --git a/Application/Home/View/default/Finance/index.html b/Application/Home/View/default/Finance/index.html index c85e547f4..39dc54177 100644 --- a/Application/Home/View/default/Finance/index.html +++ b/Application/Home/View/default/Finance/index.html @@ -35,7 +35,7 @@
- +
{$meta_title}
diff --git a/Application/Home/View/default/Finance/withdrawRecord.html b/Application/Home/View/default/Finance/withdrawRecord.html index 6ab8a8c20..7bd43e1ef 100644 --- a/Application/Home/View/default/Finance/withdrawRecord.html +++ b/Application/Home/View/default/Finance/withdrawRecord.html @@ -149,7 +149,12 @@ 提现订单 提现日期 + 结算开始日期 结算截止日期 + 操作人 + 操作人类型 + 最后操作人 + 最后操作人类型 收益金额 实际提现金额 提现状态 @@ -168,7 +173,12 @@ {$vo.widthdraw_number} {$vo.create_time} + {$vo.settlement_begin_time} {$vo.settlement_end_time} + {$vo.op_id} + {$vo.op_type} + {$vo.last_op_id} + {$vo.last_op_type} {$vo.sum_money} {$vo.sum_money} {$vo.status_name} @@ -178,11 +188,11 @@ 汇款证明 - 重新审核 + 结算单 - 撤销提现 + diff --git a/Data/update.sql b/Data/update.sql index 391c988f2..12a8ead50 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -915,4 +915,16 @@ ADD COLUMN `beta_url` varchar(150) NOT NULL DEFAULT '' COMMENT 'Beta链接'; -- 游戏支付方式渠道配置 ALTER TABLE `tab_game` -ADD COLUMN `pay_config` varchar(255) NOT NULL COMMENT '支付渠道 wx 微信 zfb 支付宝 quick 快捷 (gf 官方 sq 双乾'; \ No newline at end of file +ADD COLUMN `pay_config` varchar(255) NOT NULL COMMENT '支付渠道 wx 微信 zfb 支付宝 quick 快捷 (gf 官方 sq 双乾'; + +-- 2019-12-30 +-- 会长管理后台提现 cxj +ALTER TABLE `tab_withdraw` +ADD COLUMN `settlement_begin_time` int(10) NOT NULL DEFAULT 0 COMMENT '结算开始时间' AFTER `old_promote_account`; +ALTER TABLE `tab_withdraw` +ADD COLUMN `op_id` int(11) NOT NULL DEFAULT 0 COMMENT '操作id'; +ALTER TABLE `tab_withdraw` +ADD COLUMN `op_type` tinyint(3) NOT NULL DEFAULT 1 COMMENT '操作人:1-推广员 2-管理员 3-自动'; +ALTER TABLE `tab_withdraw` +ADD COLUMN `last_op_id` int(11) NOT NULL DEFAULT 0 COMMENT '最后操作人id', +ADD COLUMN `last_op_type` tinyint(3) NOT NULL DEFAULT 1 COMMENT '最后操作人:1-推广员 2-管理员 3-自动'; \ No newline at end of file