From e15460b08f5db047b888fd77ed49064b46a8b43c Mon Sep 17 00:00:00 2001 From: liuweiwen <529520975@qq.com> Date: Fri, 14 Feb 2020 17:11:27 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E4=BD=9C=E6=96=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controller/PartnerController.class.php | 202 +++++++----------- Application/Admin/View/Partner/add.html | 16 +- Application/Admin/View/Partner/edit.html | 17 +- Application/Admin/View/Partner/export.html | 202 ++++++++++++++++++ Application/Admin/View/Partner/lists.html | 105 +++++++-- Data/update.sql | 2 + Public/static/table2excel.js | 1 + 7 files changed, 394 insertions(+), 151 deletions(-) create mode 100644 Application/Admin/View/Partner/export.html create mode 100644 Public/static/table2excel.js diff --git a/Application/Admin/Controller/PartnerController.class.php b/Application/Admin/Controller/PartnerController.class.php index 896b5ab8f..ec4e0583d 100644 --- a/Application/Admin/Controller/PartnerController.class.php +++ b/Application/Admin/Controller/PartnerController.class.php @@ -31,44 +31,81 @@ class PartnerController extends ThinkController $map['tab_partner.status'] = $status; $parameter['status'] = $status; } + if (!empty(I('company_type'))) { + $map['company_type'] = I('company_type'); + } + if (!empty(I('partner'))) { + $map['partner'] = ['like', '%' . I('partner') . '%']; + } + if (!empty(I('timestart'))) { + $timestart = strtotime(I('timestart')); + $map['_string'] = "contract_start_time >= {$timestart}"; + } + if (!empty(I('timeend'))) { + $timeend = strtotime(I('timeend') . ' 23:59:59'); + if (!empty($map['_string'])) { + $map['_string'] .= " and "; + } + $map['_string'] .= " contract_end_time < {$timeend}"; + } $page = intval(I('get.p', 0)); $page = $page ? $page : 1; //默认显示第一页数据 $row = intval(I('row', 0)); $row = empty($row) ? 10 : $row;//每页条数 + $is_export= false; + if (isset($_REQUEST['export']) && $_REQUEST['export']==1){ + $is_export = true; + } + //获取分页数据 - $partners = $model->alias('p') + $query = $model->alias('p') ->field("p.partner,p.matche_platform,p.invoice_rate,p.settlement_type,p.bank_account, p.opening_bank,p.id,p.contract_start_time,p.contract_end_time,p.remark") ->where($map) - ->order("id desc") - ->page($page,$row) - ->select(); + ->order("id desc"); + if($is_export){ + $partners = $query + ->select(); + }else{ + $partners = $query + ->page($page,$row) + ->select(); + } //获取公司id $partner_ids = array_column($partners, 'id'); + $partner_ids = $partner_ids ? $partner_ids : [0]; $game_map['partner_id'] = ["in",$partner_ids]; $games = M("game","tab_")->alias('g') - ->field("g.game_type_name,g.relation_game_name,g.original_package_name,g.partner_id,g.id") + ->field("g.game_type_name,g.relation_game_name,g.original_package_name,g.partner_id,g.relation_game_id as id") ->where($game_map) + ->group('relation_game_id') ->select(); $game_ids = array_column($games, 'id'); + $game_ids = $game_ids ? $game_ids : [0]; $cp_game_ratio_map['game_id'] = ["in", $game_ids]; $cp_game_ratio_map['is_del'] = '0'; //获取游戏比例 $gameradiores = M("cp_game_ratio","tab_") ->alias("cg") + ->join("tab_game ga ON cg.game_id = ga.id") ->field("cg.ratio,cg.instanceof,cg.game_id,cg.begin_total_amount") ->where($cp_game_ratio_map) + ->group('relation_game_id,begin_total_amount') ->select(); // dd($cp_game_ratio_map); $parseGameRadiores = array(); foreach ($gameradiores as $key =>$val) { + $val['row'] = 1; if ($val['begin_total_amount'] == 0) { $val['name'] = '默认比例'; + if (isset($parseGameRadiores[$val['game_id']])) { + $parseGameRadiores[$val['game_id']] = []; + } } else { if($val['instanceof']=='1'){ $val['name']="月流水≥".$val['begin_total_amount']; @@ -76,7 +113,6 @@ class PartnerController extends ThinkController $val['name']="月流水>".$val['begin_total_amount']; } } - $val['row'] = 1; $parseGameRadiores[$val['game_id']][] = $val; } // dd($parseGameRadiores); @@ -117,128 +153,16 @@ class PartnerController extends ThinkController } $parseData = array_values($parseData); - - - /* 查询记录总数 */ - $count = $model - ->where($map) - ->count(); - //分页 - $parameter['p'] = $page; - $parameter['row'] = $row; - $page = set_pagination($count, $row, $parameter); - if ($page) { - $this->assign('_page', $page); - } -// dd($parseData[0]); - $this->assign('listData', $parseData[0]); - $this->assign('count', $count); - $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Partner/lists'])->find()); - $this->meta_title = '合作方管理'; - $this->display(); - } - - //列表 - public function lists2() - { - $model = M($this->modelName, 'tab_'); - $map = []; - $id = intval(I('id', 0)); - if (!empty($id)) { - $map['tab_partner.id'] = $id; - $parameter['id'] = $id; - } - - if (isset($_REQUEST['status']) && $_REQUEST['status'] !== '') { - $status = intval($_REQUEST['status']); - $map['tab_partner.status'] = $status; - $parameter['status'] = $status; + if($is_export){ + $this->assign('listData', $parseData[0]); + $this->display("export"); + die(); } - $page = intval(I('get.p', 0)); - $page = $page ? $page : 1; //默认显示第一页数据 - $row = intval(I('row', 0)); - $row = empty($row) ? 10 : $row;//每页条数 - - //获取分页数据 - $partners = $model->alias('p') - ->field("p.partner,p.matche_platform,p.invoice_rate,p.settlement_type,p.bank_account, - p.opening_bank,p.id,p.contract_start_time,p.contract_end_time,p.remark") - ->where($map) - ->order("id desc") - ->page($page,$row) - ->select(); - - //获取公司id - $partner_ids = implode(',', array_column($partners, 'id')); - $game_map['partner_id'] = ["in",$partner_ids]; - $games = M("game","tab_")->alias('g') - ->field("g.game_type_name,g.relation_game_name,g.original_package_name,g.partner_id,g.id") - ->where($game_map) - ->select(); - - $game_ids = implode(',', array_column($games, 'id')); - $cp_game_ratio_map['game_id'] = ["in",$game_ids]; - //获取游戏比例 - $gameradiores = M("cp_game_ratio","tab_") - ->alias("cg") - ->field("cg.ratio,cg.instanceof,cg.game_id") - ->join("tab_game ga ON cg.game_id = ga.id") - ->where($cp_game_ratio_map) - ->where(['is_del' => 0]) - ->group("game_id") - ->select(); - - $parseGameRadiores = array(); - foreach ($gameradiores as $key =>$val) { - $val['row'] = 1; - $parseGameRadiores[$val['game_id']][] = $val; - } - - $parseGames = array(); - - foreach ($games as $key =>$val) { - $val['game_ratio'] = $parseGameRadiores[$val['id']]; - if(array_key_exists($val['id'],$parseGameRadiores)){//游戏有比例 - $row = array_sum(array_column($val['game_ratio'], 'row')) ; - $val['row'] = empty($row) ? 1: $row; - } else { - $val["row"] = 1; - } - - $parseGames[$val['partner_id']][] = $val; - } - - - - $parseData = array(); - foreach ($partners as $key =>$value) { - $value['game'] = $parseGames[$value['id']]; - $value['has_game_evidence'] = $parseGames['has_game_evidence'] ? '有' : '没有'; - $value['is_sign_contract'] = $parseGames['is_sign_contract'] ? '是' : '否'; - if ($value['settlement_type'] == 0) { - $value['settlement_type'] = '未配置'; - } elseif ($value['settlement_type'] == 1) { - $value['settlement_type'] = '周结'; - } elseif ($value['settlement_type'] == 2) { - $value['settlement_type'] = '月结'; - } - - $value['contract_time'] = time_format($value['contract_start_time'], 'Y/m/d') . '-' . - time_format($value['contract_end_time'], 'Y/m/d'); - $row = array_sum(array_column($value['game'], 'row')) ; - $value['row'] = empty($row) ? 1: $row; - $parseData[$value['partner_id']][] = $value; - } - $parseData = array_values($parseData); - -// dd($parseData); - /* 查询记录总数 */ $count = $model ->where($map) ->count(); - //分页 $parameter['p'] = $page; $parameter['row'] = $row; @@ -246,7 +170,7 @@ class PartnerController extends ThinkController if ($page) { $this->assign('_page', $page); } - +// dd($parseData[0]); $this->assign('listData', $parseData[0]); $this->assign('count', $count); $this->assign('commonset', M('Kuaijieicon')->where(['url' => 'Partner/lists'])->find()); @@ -264,15 +188,26 @@ class PartnerController extends ThinkController if (empty($partner)) { $this->error('请输入合作方名称'); } + if (!strlen(I('is_sign_contract'))) { + $this->error('请选择是否签署合同'); + } + if (empty(I('settlement_type'))) { + $this->error('请选择结算方式'); + } + if (empty(I('company_type'))) { + $this->error('请输入公司性质'); + } + if (!strlen(I('has_game_evidence'))) { + $this->error('请选择是否有游戏资质'); + } if (empty(I('link_man'))) { $this->error('请输入联系人'); } if (empty(I('link_phone'))) { $this->error('请输入联系电话'); } - if (!in_array($status, [0, 1])) { - $this->error('参数异常'); - } + + $model = M($this->modelName, 'tab_'); $map['partner'] = $partner; @@ -308,6 +243,7 @@ class PartnerController extends ThinkController $save['is_sign_contract'] = I('is_sign_contract'); $save['settlement_type'] = I('settlement_type'); $save['has_game_evidence'] = I('has_game_evidence'); + $save['company_type'] = I('company_type'); $save['remark'] = I('remark'); if (!empty(I('file_info'))) { $save['file_info'] = I('file_info'); @@ -344,6 +280,18 @@ class PartnerController extends ThinkController if (empty($partner)) { $this->error('请输入合作方名称'); } + if (!strlen(I('is_sign_contract'))) { + $this->error('请选择是否签署合同'); + } + if (empty(I('settlement_type'))) { + $this->error('请选择结算方式'); + } + if (empty(I('company_type'))) { + $this->error('请输入公司性质'); + } + if (!strlen(I('has_game_evidence'))) { + $this->error('请选择是否有游戏资质'); + } if (empty(I('link_man'))) { $this->error('请输入联系人'); } @@ -360,7 +308,6 @@ class PartnerController extends ThinkController $map['partner'] = $partner; $res = $model->where($map)->getField('id'); - dd($res); if ($res && $res != $id) { $this->error('合作方已存在'); } @@ -396,6 +343,7 @@ class PartnerController extends ThinkController $save['is_sign_contract'] = I('is_sign_contract'); $save['settlement_type'] = I('settlement_type'); $save['has_game_evidence'] = I('has_game_evidence'); + $save['company_type'] = I('company_type'); $save['remark'] = I('remark'); if (!empty(I('file_info'))) { $save['file_info'] = I('file_info'); diff --git a/Application/Admin/View/Partner/add.html b/Application/Admin/View/Partner/add.html index 0ab77b6c2..f5c1eee72 100644 --- a/Application/Admin/View/Partner/add.html +++ b/Application/Admin/View/Partner/add.html @@ -90,7 +90,18 @@
操作 | +合同合作方名称 | +对应平台 | +合同期限 | +开票税点 | +结算周期 | +银行账号 | +开户行 | +备注 | + +是否有游戏资质 | +是否签署合同 | + +产品类型 | +原包名 | +现包名 | +合作方分成比例 | + +aOh! 暂时还没有内容! | +||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
+ 编辑 + 查看 + 删除 + | +{$data.partner} | +{$data.matche_platform} | +{$data.contract_time} | +{$data.invoice_rate}% | +{$data.settlement_type} | +{$data.bank_account} | +{$data.opening_bank} | +{$data.remark} | +{$data.has_game_evidence} | +{$data.is_sign_contract} | + +|||||||||||||||||||||||
{$game['game_type_name']} | +{$game['original_package_name']} | +{$game['relation_game_name']} | +|||||||||||||||||||||||||||||||
{$ratio['name']} | +{$ratio['ratio']} | +{$ratio['name']} | +{$ratio['ratio']} | +- | +- | +{$game['game_type_name']} | +{$game['original_package_name']} | +{$game['relation_game_name']} | + +|||||||||||||||||||||||||
{$ratio['name']} | +{$ratio['ratio']} | +{$ratio['name']} | +{$ratio['ratio']} | +- | +- | +- | +- | +- | +- | +- | +