From 955a1917b3eb3c06f364ca1a65de9140fed6fdca Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Wed, 12 Feb 2020 14:54:54 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E6=88=90=E4=B8=AA=E4=BA=BA=E7=BB=93?= =?UTF-8?q?=E7=AE=97=E5=8D=95=E7=9A=84=E5=8A=9F=E8=83=BD=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Application/Admin/Common/extend.php | 3 +- .../StatementMangementController.class.php | 293 +++++++++++++++++- .../StatementMangement/PersonOrderList.html | 90 ++++-- .../Admin/View/StatementMangement/lists.html | 10 +- Data/update.sql | 4 + 5 files changed, 364 insertions(+), 36 deletions(-) diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php index 33f054e5d..147b92662 100644 --- a/Application/Admin/Common/extend.php +++ b/Application/Admin/Common/extend.php @@ -2008,8 +2008,9 @@ function getWithdrawNumber() { $data = M('withdraw',"tab_") ->field("widthdraw_number") + ->join('left join tab_promote_belong on tab_withdraw.promote_id=tab_promote_belong.promote_id') ->join("left join tab_statement as statement on tab_withdraw.widthdraw_number = statement.ext_field") - ->where("ext_field is null") + ->where("ext_field is null and tab_promote_belong.company_type!=2") ->select(); return $data; diff --git a/Application/Admin/Controller/StatementMangementController.class.php b/Application/Admin/Controller/StatementMangementController.class.php index 29ea0a276..07fadb420 100644 --- a/Application/Admin/Controller/StatementMangementController.class.php +++ b/Application/Admin/Controller/StatementMangementController.class.php @@ -374,11 +374,38 @@ class StatementMangementController extends ThinkController ->where($withdrawMap) ->select(); + $statement = M('statement','tab_') + ->field('ext_field') + ->where(['ext_field'=>['like','%,%']]) + ->select(); + + $withdrawData = []; + + foreach($statement as $key => $value) { + + $handleData = explode(',',$value['ext_field']); + + foreach ($handleData as $hk => $hv) { + array_push($withdrawData,$hv); + } + + } + + foreach ($data as $key => $value) { + $data[$key]['settlement_begin_time'] = date("Y-m-d H:i:s", $data[$key]['settlement_begin_time']); + $data[$key]['settlement_end_time'] = date("Y-m-d H:i:s", $data[$key]['settlement_end_time']); + + if (in_array($value['widthdraw_number'],$withdrawData)) { + unset($data[$key]); + } + + } + $this->assign('withdraw_data',$data); } - if ($_REQUEST['withdraw']) { + if ($_REQUEST['withdraw']&&$data) { $map = []; @@ -497,8 +524,272 @@ class StatementMangementController extends ThinkController public function savePersonOrder() { +// dump($_POST); + + + + $data['statement_info'] = $_POST['statement_info']; + $data['first_party_info'] = json_encode([]); + $data['second_party_info'] = $_POST['second_party_info']; + $data['statement_begin_time'] = strtotime($_POST['time_start']); + $data['statement_end_time'] = strtotime($_POST['time_end']); + $data['create_time'] = time(); + $data['statement_money'] = 0; + $data['pay_amount'] = 0; + $data['ext_field'] = ''; + $data['company_name'] = '个人结账单'; + $data['statement_type'] = 2; + + if($data['second_party_info'] == '[]' || $data['statement_info'] == '[]') { + $this->ajaxReturn(['status'=>1,'msg'=>'数据错误']); + } + + + $statement_info = json_decode($data['statement_info'],true); + + foreach($statement_info as $key => $value) { + $data['statement_money'] += $value['sum_amount']; + $data['pay_amount'] += $value['real_amount']; + } + + $second_party_info = json_decode($data['second_party_info'],true); + + foreach($second_party_info as $key => $value) { + $data['ext_field'] = $data['ext_field'].$value['widthdraw_number'].','; + } + + $is_exist = M('statement','tab_')->where(['ext_field'=>$data['ext_field'],'statement_type'=>2])->find(); + if ($is_exist) { + $this->ajaxReturn(['status'=>0,'msg'=>'请勿重复添加']); + } + + $is_save = M('statement','tab_')->add($data); + + if ($is_save) { + $this->ajaxReturn(['status'=>1,'msg'=>'生成成功']); + } else { + $this->ajaxReturn(['status'=>0,'msg'=>'生成失败']); + } + + } + + public function PersonOrderEdit() { + + if ($_REQUEST['time_start'] || $_REQUEST['time_end'] ) { + $withdrawMap = []; + if ($_REQUEST['time_start']&&!$_REQUEST['time_end']) { + $withdrawMap['settlement_begin_time'] = ['egt',strtotime($_REQUEST['time_start'])]; + } + + if (!$_REQUEST['time_start']&&$_REQUEST['time_end']) { + $withdrawMap['settlement_end_time'] = ['elt',strtotime($_REQUEST['time_end'])]; + } + + if ($_REQUEST['time_start']&&$_REQUEST['time_end']) { + $withdrawMap['settlement_begin_time'] = ['egt',strtotime($_REQUEST['time_start'])]; + $withdrawMap['settlement_end_time'] = ['elt',strtotime($_REQUEST['time_end'])]; + } + + $data = M('withdraw',"tab_") + ->field("widthdraw_number,settlement_begin_time,settlement_end_time,settlement_type,promote_account") + ->join('left join tab_promote_belong on tab_withdraw.promote_id=tab_promote_belong.promote_id') + ->join("left join tab_statement as statement on tab_withdraw.widthdraw_number = statement.ext_field") + ->where("tab_promote_belong.company_type=2") + ->where($withdrawMap) + ->select(); +// dump($data);die(); + +// $statement = M('statement','tab_') +// ->field('ext_field') +// ->where(['ext_field'=>['like','%,%']]) +// ->select(); +// +// $withdrawData = []; +// +// foreach($statement as $key => $value) { +// +// $handleData = explode(',',$value['ext_field']); +// +// foreach ($handleData as $hk => $hv) { +// array_push($withdrawData,$hv); +// } +// +// } +// +// foreach ($data as $key => $value) { +// $data[$key]['settlement_begin_time'] = date("Y-m-d H:i:s", $data[$key]['settlement_begin_time']); +// $data[$key]['settlement_end_time'] = date("Y-m-d H:i:s", $data[$key]['settlement_end_time']); +// +// if (in_array($value['widthdraw_number'],$withdrawData)) { +// unset($data[$key]); +// } +// +// } +// +// foreach ($data as $key => $value) { +// $data[$key]['settlement_begin_time'] = date("Y-m-d H:i:s", $data[$key]['settlement_begin_time']); +// $data[$key]['settlement_end_time'] = date("Y-m-d H:i:s", $data[$key]['settlement_end_time']); +// +// } + + $this->assign('withdraw_data',$data); + + } + + if ($_REQUEST['withdraw']&&$data) { + + $map = []; + + $map['widthdraw_number'] = ['in',$_REQUEST['withdraw']]; + + $data = M('withdraw','tab_') + ->field("tab_withdraw.id,pc.company_name,pc.id as cid,tab_withdraw.promote_id,tab_withdraw.promote_account,username,'个人' as type,game_ratio + ,mobile_phone,real_name,tab_promote.bank_card,account_openin,tab_promote.address,bank_account") + ->join('left join tab_promote_belong on tab_withdraw.promote_id=tab_promote_belong.promote_id') + ->join("left join tab_statement as statement on tab_withdraw.widthdraw_number = statement.ext_field") + ->join("left join tab_promote on tab_promote.id=tab_promote_belong.promote_id") + ->join("left join tab_promote_company as pc on pc.id = tab_promote.company_id") + ->join("left join sys_ucenter_member on sys_ucenter_member.id=tab_promote.admin_id") + ->where("tab_promote_belong.company_type=2") + ->where($map) + ->select(); + + + $game_ratio = []; + foreach($data as $dkey => &$dval) { + $gameStr = []; + + $rowspan = 0; + $dval['rowspan'] = 0; + + $dval['game_ratio'] = json_decode($dval['game_ratio'],true); + + if (is_array($dval['game_ratio'])) { + foreach ($dval['game_ratio'] as $key => &$value) { + + foreach ($value as $k => &$v) { + +// $v['game_id'] = $key; + + $v['game_name'] = substr(get_gamename($key),0,strpos(get_gamename($key), '(')); + + if (!in_array($v['game_name'],$gameStr)) { + array_push($gameStr,$v['game_name']); + + } else { +// var_dump($key); + if (!$game_ratio[$v['game_name']]) { + $game_ratio[$v['game_name']] = $v; + } + else { + $game_ratio[$v['game_name']]['sum_amount'] += $v['sum_amount']; + } + unset($value[$k]); + } +// + } + if (!$value) { + unset($dval['game_ratio'][$key]); + } + + } + + foreach ($dval['game_ratio'] as $key => $val) { + + $val[0]['reward'] = 0; + $val[0]['forfeit'] = 0; + $startTime = strtotime($val[0]['begin_time']); + $endTime = strtotime($val[0]['end_time']); + + $rewardData = M('reward_record','tab_') + ->field("sum(tab_reward_record.money) as money,reward_type,relation_game_name") + ->join("left join (select * from tab_game group by relation_game_id)tab_game on tab_reward_record.relation_game_id=tab_game.relation_game_id") + ->where(['company_type'=>2,'relation_game_name'=>['like',"%{$val[0]['game_name']}%"],'reward_time'=>['between',[$startTime,$endTime]]]) + ->group('reward_type') + ->select(); + + foreach ($rewardData as $rk => $rv) { + + if ($rv['reward_type'] == 1) { + $val[0]['reward'] = $rv['money']; + } else { + $val[0]['forfeit'] = $rv['money']; + } + + } + + foreach ($val as $k => &$v) { + + if ($game_ratio[$v['game_name']]) { + + $v['sum_amount'] = number_format($v['sum_amount'] + $game_ratio[$v['game_name']]['sum_amount'],2,'.',''); + + } + //计算结算金额 + $val[0]['real_amount'] = number_format($val[0]['sum_amount'] * ($val[0]['selle_ratio']/100)+$val[0]['reward']-$val[0]['forfeit'],2,'.',''); + } + + $rowspan++; + unset($dval['game_ratio'][$key]); + array_push($dval['game_ratio'],$val[0]); + } + + $dval['rowspan'] = $rowspan; + + } + } + + $this->assign('data',$data); + + } + $this->display(); } + public function savePersonOrderEdit() { + + $data['statement_info'] = $_POST['statement_info']; + $data['first_party_info'] = json_encode([]); + $data['second_party_info'] = $_POST['second_party_info']; + $data['statement_begin_time'] = strtotime($_POST['time_start']); + $data['statement_end_time'] = strtotime($_POST['time_end']); + $data['create_time'] = time(); + $data['statement_money'] = 0; + $data['pay_amount'] = 0; + $data['ext_field'] = ''; + $data['company_name'] = '个人结账单'; + $data['statement_type'] = 2; + + + if($data['second_party_info'] == '[]' || $data['statement_info'] == '[]') { + $this->ajaxReturn(['status'=>1,'msg'=>'数据错误']); + } + + + $statement_info = json_decode($data['statement_info'],true); + + foreach($statement_info as $key => $value) { + $data['statement_money'] += $value['sum_amount']; + $data['pay_amount'] += $value['real_amount']; + } + + $second_party_info = json_decode($data['second_party_info'],true); + + foreach($second_party_info as $key => $value) { + $data['ext_field'] = $data['ext_field'].$value['widthdraw_number'].','; + } + $data['ext_field'] = rtrim($data['ext_field'], ","); + + $is_save = M('statement','tab_')->where(['id'=>$_REQUEST['withdraw_id']])->save($data); + + if ($is_save) { + $this->ajaxReturn(['status'=>1,'msg'=>'修改成功']); + } else { + $this->ajaxReturn(['status'=>0,'msg'=>'修改失败']); + } + + } + + } diff --git a/Application/Admin/View/StatementMangement/PersonOrderList.html b/Application/Admin/View/StatementMangement/PersonOrderList.html index 82b51871f..255b38669 100644 --- a/Application/Admin/View/StatementMangement/PersonOrderList.html +++ b/Application/Admin/View/StatementMangement/PersonOrderList.html @@ -112,7 +112,7 @@ - + aOh! 暂时还没有内容! @@ -121,17 +121,12 @@ - checked="checked" > {$withdraw_data.widthdraw_number} {$withdraw_data.settlement_begin_time} - {$withdraw_data.settlement_end_time} - - 周结 - 月结 - 补点 - - + 周结月结补点 {$withdraw_data.promote_account} @@ -143,15 +138,15 @@ -
- -
-
- 预览 -
-
+ + + + + + + -
+ @@ -196,13 +191,13 @@ {$data.username} {$data.type} - 空 - 空 - 空 - 空 - 空 - 空 - 空 + 无 + - + 0 + 0 + 0 + 0 + 0 {$data.bank_account} {$data.bank_card} @@ -311,9 +306,9 @@ } $("#confirm").click(function() { - var set = []; + var withdraw_datas = []; $('.withdraw_datas tr').each(function() { - var row = []; + var row = {}; $(this).find('td').each(function(index) { @@ -351,13 +346,47 @@ }); - set.push(row); + withdraw_datas.push(row); + }); + var setData = []; + $('.setData tr').each(function() { + var row = {}; + var checked = $(this).find('input').is(":checked"); + + if (checked) { + $(this).find('td').each(function(index) { + // console.log($(this).text());return; + if (index == 1) { + row['widthdraw_number'] = $(this).text(); + } else if (index == 2) { + row['time'] = $(this).text(); + }else if (index == 3) { + row['settlement_type'] = $(this).text(); + }else if (index == 4) { + row['promote_account'] = $(this).text(); + } + + }); + + setData.push(row); + } + }); - setTimeout(function(){ - window.parent.reload(); - },1500); - console.log(set); + $.ajax({ + url: "{:U('StatementMangement/savePersonOrder')}", + type: "post", + data: {"second_party_info": JSON.stringify(setData),"statement_info":JSON.stringify(withdraw_datas),"time_start":start,"time_end":end}, + dataType: 'json', + success: function (data) { + layer.msg(data.msg); + setTimeout(function(){ + window.parent.reload(); + },1500); + } + }); + console.log(JSON.stringify(withdraw_datas)); + console.log(setData); } ); @@ -368,6 +397,7 @@ //全选的实现 $(".check-all").click(function(){ $('.ids').prop("checked", this.checked); + shenhe(); }); $(".ids").click(function(){ var option = $(".ids"); diff --git a/Application/Admin/View/StatementMangement/lists.html b/Application/Admin/View/StatementMangement/lists.html index 59ddf2c8b..402fd98f8 100644 --- a/Application/Admin/View/StatementMangement/lists.html +++ b/Application/Admin/View/StatementMangement/lists.html @@ -125,7 +125,7 @@ - 上游对账单下游对账单下游补点对账单 + 上游对账单下游对账单下游补点对账单下游个人结算单 {$data.create_time} {$data.company_name} {$data.statement_begin_time}-{$data.statement_end_time} @@ -134,13 +134,13 @@ 查看 - 编辑 + 编辑 撤销 - 合计公司对账金额合计:{$sum[1]}     cp对账金额合计:{$sum[0]} + 合计公司对账金额合计:{$sum[1]}     cp对账金额合计:{$sum[0]+$sum[2]} @@ -242,8 +242,10 @@ var ext_field = $(this).attr('ext_field'); if(edit.type == 0){ var url = "/admin.php?s=/Statement/editCpStatement/id/"+edit.id; - }else{ + }else if(edit.type == 1){ var url = "/admin.php?s=/StatementMangement/editDownstreamOrder/id/"+edit.id+"/ext_field/"+ext_field; + }else if(edit.type == 2){ + var url = "/admin.php?s=/StatementMangement/PersonOrderEdit/id/"+edit.id+"/withdraw/"+ext_field+"/time_start/"+edit.start+"/time_end/"+edit.end; } layer.open({ diff --git a/Data/update.sql b/Data/update.sql index eadbd10d7..e7ba32fdc 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -1157,3 +1157,7 @@ ADD COLUMN `company_type` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '工 -- 2020-02-10 cxj 推广提现--新增审核模式 ALTER TABLE `tab_withdraw` ADD COLUMN `review_type` tinyint(3) NOT NULL DEFAULT 1 COMMENT '审核模式:1-人工审核 2-自动审核'; + +-- 2020-02-12 zyx 推广提现--新增审核模式 +ALTER TABLE `tab_statement` +MODIFY COLUMN `ext_field` longtext CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '扩展字段,如果是下游为提现单号' AFTER `pay_type`;