From cccbc3bfa802d4b86582a9cee572bce9512e14ed Mon Sep 17 00:00:00 2001 From: chenzhi Date: Thu, 9 Jan 2020 16:23:54 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=96=B0=E5=A2=9Ecp=E7=BB=93=E7=AE=97?= =?UTF-8?q?=E5=8D=95=E5=88=A4=E6=96=AD=E6=98=AF=E5=90=A6=E5=B7=B2=E7=BB=8F?= =?UTF-8?q?=E6=9C=89=E4=BA=A4=E5=8F=89=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/StatementController.class.php | 57 ++++++++++++++----- .../View/Statement/createCpStatement.html | 16 ++++-- 2 files changed, 53 insertions(+), 20 deletions(-) diff --git a/Application/Admin/Controller/StatementController.class.php b/Application/Admin/Controller/StatementController.class.php index 4219e588f..0dfa30d70 100644 --- a/Application/Admin/Controller/StatementController.class.php +++ b/Application/Admin/Controller/StatementController.class.php @@ -6,34 +6,22 @@ namespace Admin\Controller; */ class StatementController extends ThinkController { - public $mycompany = array( - "id" => 0, - "partner" => "海南万盟天下科技有限公司", - "link_man" => "雷丽华", - "link_phone" => "13067391751", - "address" => "福建省福州市鼓楼区福大怡山创业园区11号103", - "company_tax_no" => "1243245", - "payee_name" => "雷丽华", - "bank_account" => "1654654564364635456", - "opening_bank" => "福州市福大分行" - ); //创建 public function createCpStatement() { $this->display(); - //获取cp推广公司 - } //获取推广公司基础信息 public function getCpCompanyInfo() { $CompanyId = $_REQUEST['company_id']; if($CompanyId == 0){ - $info = $this->mycompany; + $mycompany = M("tool","tab_")->field("config")->where("name='company_info'")->find(); + $info = json_decode($mycompany['config'],true); + $info['id'] = 0; }else{ $info = M("partner","tab_")->where("id = '{$CompanyId}'")->find(); } - if(empty($info)){ $this->ajaxReturn(array("error"=>"no find","code"=>2000)); }else{ @@ -60,6 +48,45 @@ class StatementController extends ThinkController } $map['pay_time'] = ['between', [strtotime($_REQUEST['time_start']), strtotime($_REQUEST['time_end']) + 86399]]; } + //判断是否有重叠时间 + $Statement = M("statement","tab_"); + $repart =false; + $errorstr = ''; + //开始时间被重叠部分 + $checkmap = array( + "statement_begin_time"=>array("ELT",strtotime($_REQUEST['time_start'])), + "statement_end_time"=>array("EGT",strtotime($_REQUEST['time_start'])), + "company_id"=>$CompanyId + ); + $bres = $Statement->field("statement_begin_time,statement_end_time")->where($checkmap)->find(); + if($bres){ + $repart=true; + $begin = $_REQUEST['time_start']; + //统计相交时间 + if(strtotime($_REQUEST['time_end']) > $bres["statement_end_time"]){ + $end = date("Y-m-d",$bres["statement_end_time"]); + }else{ + $end = $_REQUEST['time_end']; + } + $errorstr .= ($begin."到".$end."期间的数据已经结算过
"); + } + //结束被重复的部分 + $checkmap = array( + "statement_begin_time"=>array("ELT",strtotime($_REQUEST['time_end'])), + "statement_end_time"=>array("EGT",strtotime($_REQUEST['time_end'])), + "company_id"=>$CompanyId + ); + $bres = $Statement->field("statement_begin_time,statement_end_time")->where($checkmap)->find(); + if($bres){ + $repart=true; + $begin = date("Y-m-d",$bres["statement_begin_time"]); + //统计相交时间 + $end = $_REQUEST['time_end']; + $errorstr .= ($begin."到".$end."期间的数据已经结算过
"); + } + if($repart){ + $this->ajaxReturn(array("error"=>$errorstr,"code"=>2001)); + } //获取对应cp公司的游戏 $game_list = M("game","tab_")->field("id")->where("partner_id = '{$CompanyId}'")->select(); diff --git a/Application/Admin/View/Statement/createCpStatement.html b/Application/Admin/View/Statement/createCpStatement.html index 64af44166..6dbc23016 100644 --- a/Application/Admin/View/Statement/createCpStatement.html +++ b/Application/Admin/View/Statement/createCpStatement.html @@ -513,11 +513,17 @@ } var url = "{:U('getSpendStatement')}"; PUBLIC.postData(url,selectData,function(data){ - DATAOBJ.statement_begin_time = time_start; - DATAOBJ.statement_end_time = time_end; - DATAOBJ.statement_info = data.success; - DATAOBJ.statement_count = data.count; - TPLSHOW.showStatementList(true); + if(data.code > 0){ + layer.alert(data.error); + return false; + }else{ + DATAOBJ.statement_begin_time = time_start; + DATAOBJ.statement_end_time = time_end; + DATAOBJ.statement_info = data.success; + DATAOBJ.statement_count = data.count; + TPLSHOW.showStatementList(true); + } + }) From dddd640f9fccf211ebb1b04e6626d55490b43488 Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Thu, 9 Jan 2020 16:30:49 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E7=BB=93=E7=AE=97=E5=8D=95=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=88=97=E8=A1=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/View/StatementMangement/lists.html | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Application/Admin/View/StatementMangement/lists.html b/Application/Admin/View/StatementMangement/lists.html index 35e12c5ba..41331fdfb 100644 --- a/Application/Admin/View/StatementMangement/lists.html +++ b/Application/Admin/View/StatementMangement/lists.html @@ -130,7 +130,7 @@ {$data.statement_money} {$data.is_confirm} 撤销 - 编辑 + 编辑 @@ -214,10 +214,9 @@ }); }); - $("#statement_edit").click(function () { + $(".statement_edit").click(function () { - var id = $(this).attr('edit-id'); - console.log(id) + var id = $(this).attr('ext_field'); layer.open({ type: 2, @@ -225,7 +224,7 @@ shadeClose: true, shade: 0.8, area: ['70%', '80%'], - content: ['/admin.php?s=/Member/role_list/' , 'no'] + content: '/admin.php?s=/StatementMangement/editDownstreamOrder/ext_field/'+id }); }); From eb114b33b354cbc2d5d881ddf7f18d5cfd0a3052 Mon Sep 17 00:00:00 2001 From: zhengchanglong Date: Thu, 9 Jan 2020 16:32:42 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=B8=B8=E6=88=8F=E5=88=86=E6=88=90?= =?UTF-8?q?=E6=AF=94=E4=BE=8B=E8=AE=BE=E5=AE=9A=E4=BD=93=E9=AA=8C=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Controller/GameController.class.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Application/Admin/Controller/GameController.class.php b/Application/Admin/Controller/GameController.class.php index 0e6fe84f4..6531fbd53 100644 --- a/Application/Admin/Controller/GameController.class.php +++ b/Application/Admin/Controller/GameController.class.php @@ -771,8 +771,12 @@ class GameController extends ThinkController if($data['data_id']==0 || $data['data_id']==""){ //查询初始分成比例信息 $initial_info = M('cp_game_ratio', 'tab_')->where("game_id=%d and begin_total_amount=0 and is_del=0",$data['game_id'])->find(); } + if(!is_numeric($data['game_ratio']) || $data['game_ratio']<0 || $data['game_ratio']>100){ + die(json_encode(array("result"=>"0","desc"=>"分成比例为0~100之间"))); + } if($data['data_type']=='initial'){ //CP初始分成比例 + if($data['data_id']>0){ //修改初始CP分成比例 $where = array(); $where['is_del'] = "0"; @@ -795,6 +799,10 @@ class GameController extends ThinkController } } }else{ //CP阶梯分成档位 + if(!is_numeric($data['total_amount']) || $data['total_amount']<=0){ + die(json_encode(array("result"=>"0","desc"=>"流水金额应大于0"))); + } + if($data['data_id']>0) { //修改阶梯分成 $where = array(); $where['game_id']= $data['game_id']; From 4286817dea974f1ea96183182bccd8862ce38132 Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Thu, 9 Jan 2020 16:45:16 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E6=8F=90=E7=8E=B0--?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/QueryController.class.php | 18 +++-- .../Admin/Model/WithdrawModel.class.php | 68 +++++++++++++++++++ Application/Admin/View/Query/settlement.html | 8 ++- .../Admin/View/Query/withdrawDetails.html | 14 +++- 4 files changed, 97 insertions(+), 11 deletions(-) diff --git a/Application/Admin/Controller/QueryController.class.php b/Application/Admin/Controller/QueryController.class.php index 61be9974b..0db76311e 100644 --- a/Application/Admin/Controller/QueryController.class.php +++ b/Application/Admin/Controller/QueryController.class.php @@ -139,14 +139,14 @@ class QueryController extends ThinkController } } - if ($settlementType == 3) { + if ($settlementType != 3) { $totalField = 'sum(if(tab_spend.selle_ratio > 0, tab_spend.pay_amount * tab_spend.selle_ratio, 0)) as settlement_amount'; $zTotal = null_to_0(M('spend', 'tab_')->field($totalField)->where($spendMap)->find()['settlement_amount']);//累计 + $zTotal = bcdiv($zTotal, 100 ,2); } else { $totalField = 'sum(tab_spend.pay_amount) as sum_amount'; $zTotal = null_to_0(M('spend', 'tab_')->field($totalField)->where($spendMap)->find()['sum_amount']);//累计 } - $zTotal = bcdiv($zTotal, 100 ,2); if(I('export', 0) == 1) { $data = []; @@ -1354,6 +1354,7 @@ class QueryController extends ThinkController 'settlement_time' => "{$list['begin_time']} - {$list['end_time']}", 'game_name' => $gameName ?? '未知', 'sum_amount' => $list['sum_amount'], + 'default_ratio' => $list['default_ratio'] ? $list['default_ratio'] . '%' : '未知', 'ratio' => $list['selle_ratio'] . '%', 'settlement_amount' => bcdiv(bcmul($list['sum_amount'], $list['selle_ratio'], 2), 100, 2), ]; @@ -1361,6 +1362,7 @@ class QueryController extends ThinkController } } + $this->assign('settlementType', $withdraw['settlement_type']); $this->assign('records', $records); $this->display(); } @@ -1455,26 +1457,30 @@ class QueryController extends ThinkController $this->ajaxReturn(['settlement_type' => $settlementType]); } - public function getRecoupAmount() + public function getAmountBySettlementType() { $withdrawModel = new WithdrawModel(); $promoteId = intval(I('promote_id', 0)); $settlementType = intval(I('settlement_type', 0)); $time = I('time', ''); - if (empty($promoteId) || $settlementType != 3) { + if (empty($promoteId) || !in_array($settlementType, [2, 3])) { $this->ajaxReturn(['balance' => 0]); } $promote = M('promote', 'tab_')->find($promoteId); - if (empty($promote) || $promote['level'] != 1 || $promote['ver_status'] != 1 || $promote['settlement_type'] != 1 || empty($time)) { + if (empty($promote) || $promote['level'] != 1 || $promote['ver_status'] != 1 || empty($time)) { $this->ajaxReturn(['balance' => 0]); } $data['begin_time'] = strtotime($time); $data['end_time'] = strtotime('+1 month', $data['begin_time']) - 1; - $balance = $withdrawModel->getRecoupAmount($promote, $data); + if ($settlementType == 2) { + $balance = $withdrawModel->getMonthAmount($promote, $data); + } else { + $balance = $withdrawModel->getRecoupAmount($promote, $data); + } $this->ajaxReturn(['balance' => $balance]); } } diff --git a/Application/Admin/Model/WithdrawModel.class.php b/Application/Admin/Model/WithdrawModel.class.php index 7cb4ac54a..ea73951c1 100644 --- a/Application/Admin/Model/WithdrawModel.class.php +++ b/Application/Admin/Model/WithdrawModel.class.php @@ -294,6 +294,7 @@ class WithdrawModel extends Model{ $gameRatios[$promoteGameRatio['game_id']] = []; $gameRatios[$promoteGameRatio['game_id']][] = [ 'selle_ratio' => $ratio, + 'default_ratio' => $promoteGameRatio['ratio'], 'sum_amount' => $sumAmount, 'begin_time' => $beginTime, 'end_time' => $endTime, @@ -412,6 +413,7 @@ class WithdrawModel extends Model{ $gameRatios[$promoteGameRatio['game_id']][] = [ 'selle_ratio' => $ratio, + 'default_ratio' => $promoteGameRatio['ratio'], 'sum_amount' => $sumAmount, 'begin_time' => date('Y-m-d', $settlementBeginTime), 'end_time' => date('Y-m-d', $settlementEndTime), @@ -501,6 +503,72 @@ class WithdrawModel extends Model{ return $balance; } + public function getMonthAmount($promote, $data = []) + { + $promoteIds = $this->getPromoteChildren($promote); + $settlementBeginTime = $data['begin_time'] ?? strtotime(date('Y-m', strtotime('-1 month', time()))); + $settlementEndTime = $data['end_time'] ?? strtotime(date('Y-m')) - 1; + + $spendMap['pay_status'] = 1; + $spendMap['selle_status'] = 0; + $spendMap['promote_id'] = ['in', $promoteIds]; + $spendMap['pay_time'] = ['between', [$settlementBeginTime, $settlementEndTime]]; + $spendWhere = $spendMap; + $spendModel = M('spend', 'tab_'); + + $promoteGameRatioMap['status'] = 1; + $promoteGameRatioMap['promote_id'] = $promote['id']; + $promoteGameRatios = D('promote_game_ratio')->field('game_id, ratio, turnover_ratio, begin_time, end_time') + ->where($promoteGameRatioMap) + ->order('update_time desc') + ->select(); + + if (empty($promoteGameRatios)) { + $balance = $spendModel->field("sum(if(selle_ratio > 0, pay_amount * selle_ratio, 0)) as balance") + ->where($spendMap) + ->find()['balance']; + $balance = $balance ?? 0; + } else { + $balance = 0; + $notInGameIds = [-1]; + foreach ($promoteGameRatios as $promoteGameRatio) { + $spendWhere['game_id'] = $promoteGameRatio['game_id']; + if (!empty($promoteGameRatio['turnover_ratio']) && $promoteGameRatio['begin_time'] <= $settlementBeginTime && (empty($promoteGameRatio['end_time']) || $promoteGameRatio['end_time'] >= $settlementEndTime)) { + $notInGameIds[] = $promoteGameRatio['game_id']; + $ratio = $promoteGameRatio['ratio']; + $promoteGameRatio['turnover_ratio'] = json_decode($promoteGameRatio['turnover_ratio'], true); + $turnoverRatios = array_reverse($promoteGameRatio['turnover_ratio']); + $sumAmount = $spendModel->field("sum(pay_amount) as sum_amount") + ->where($spendWhere) + ->find()['sum_amount']; + $sumAmount = $sumAmount ?? 0; + foreach ($turnoverRatios as $turnoverRatio) { + if ($sumAmount >= $turnoverRatio['turnover']) { + $ratio = $turnoverRatio['ratio']; + break; + } + } + + $thisBalance = $spendModel->field("sum(pay_amount * {$ratio}) as balance") + ->where($spendWhere) + ->find()['balance']; + $thisBalance = $thisBalance ?? 0; + $balance = bcadd($balance, $thisBalance, 2); + } + } + + $spendWhere['game_id'] = ['not in', $notInGameIds]; + $otherBalance = $spendModel->field("sum(if(selle_ratio > 0, pay_amount * selle_ratio, 0)) as balance") + ->where($spendWhere) + ->find()['balance']; + $otherBalance = $otherBalance ?? 0; + $balance = bcadd($balance, $otherBalance, 2); + } + + $balance = bcdiv($balance, 100, 2); + return $balance; + } + private function getSpendMessageByGame($map) { $field = 'game_id, selle_ratio, sum(pay_amount) as sum_amount, pay_time'; diff --git a/Application/Admin/View/Query/settlement.html b/Application/Admin/View/Query/settlement.html index b8557b413..4f1e6ad94 100644 --- a/Application/Admin/View/Query/settlement.html +++ b/Application/Admin/View/Query/settlement.html @@ -433,7 +433,9 @@ msg += "收益结算时间:" + time; msg += "
"; if (settlementType == 3) { - msg += "补点金额:" + getRecoupAmount(promoteId, settlementType, time); + msg += "补点金额:" + getAmountBySettlementType(promoteId, settlementType, time) + '元'; + } else if (settlementType == 2) { + msg += "实际提现金额:" + getAmountBySettlementType(promoteId, settlementType, time) + '元'; } else { msg += "提现金额:{$zTotal}元"; } @@ -577,11 +579,11 @@ } }); - function getRecoupAmount(promoteId, settlementType, time) { + function getAmountBySettlementType(promoteId, settlementType, time) { var balance = 0; $.ajax({ type: 'post', - url: '{:U("getRecoupAmount")}', + url: '{:U("getAmountBySettlementType")}', dataType: 'json', async: false, data: {'promote_id': promoteId, 'settlement_type': settlementType, 'time': time}, diff --git a/Application/Admin/View/Query/withdrawDetails.html b/Application/Admin/View/Query/withdrawDetails.html index 9babaf3e5..9951bf619 100644 --- a/Application/Admin/View/Query/withdrawDetails.html +++ b/Application/Admin/View/Query/withdrawDetails.html @@ -35,7 +35,12 @@ body{ padding: 0px; } 结算时间 游戏名称 流水总额 - 分成比例 + + 默认分成比例 + 补点分成比例 + + 分成比例 + 结算总额 @@ -47,7 +52,12 @@ body{ padding: 0px; } {$record.settlement_time} {$record.game_name} {$record.sum_amount} - {$record.ratio} + + {$record.default_ratio} + {$record.ratio} + + {$record.ratio} + {$record.settlement_amount} From 843c54ced526afd7a7dd2b57ea32e4a8fbfbfcc9 Mon Sep 17 00:00:00 2001 From: chenxiaojun <956334972@qq.com> Date: Thu, 9 Jan 2020 17:03:04 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=8E=A8=E5=B9=BF=E6=8F=90=E7=8E=B0--?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Admin/Controller/PromoteGameRatioController.class.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Application/Admin/Controller/PromoteGameRatioController.class.php b/Application/Admin/Controller/PromoteGameRatioController.class.php index 6b5793357..63d8a2aa0 100644 --- a/Application/Admin/Controller/PromoteGameRatioController.class.php +++ b/Application/Admin/Controller/PromoteGameRatioController.class.php @@ -175,7 +175,7 @@ class PromoteGameRatioController extends ThinkController if (!isset($params['ratio']) || $params['ratio'] === '') { $this->error('默认分成比例不能为空'); } - $save['turnover_ratio'] = ''; + $save['turnover_ratio'] = []; if (!empty(array_filter($params['turnover'])) || !empty(array_filter($params['turnover_ratio']))) { if (is_array($params['turnover']) && is_array($params['turnover_ratio'])) { foreach ($params['turnover'] as $turnover) { @@ -205,7 +205,6 @@ class PromoteGameRatioController extends ThinkController $this->error('月流水分成比例必须以正序的方式填写,且必须大于上一个月流水分成比例'); } - $save['turnover_ratio'] = []; foreach ($params['turnover'] as $key => $turnover) { $save['turnover_ratio'][] = [ 'turnover' => bcdiv($turnover, 1, 2), @@ -227,7 +226,7 @@ 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']) { + if ($promoteGameRatio['status'] == -1 || $save['begin_time'] != $promoteGameRatio['begin_time'] || $save['end_time'] != $promoteGameRatio['end_time'] || $save['ratio'] != $promoteGameRatio['ratio'] || $save['remark'] != $promoteGameRatio['remark'] || $save['turnover_ratio'] != $promoteGameRatio['turnover_ratio']) { $promoteId = $promoteGameRatio['promote_id']; $this->isWithdraw($promoteId, $save['begin_time']);//是否存在开始时间后已提现数据