From a00834e4e51016f568d57fd463e0a8f3f9a4fda3 Mon Sep 17 00:00:00 2001 From: zhengyongxing Date: Fri, 23 Oct 2020 14:15:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=96=E5=9B=A2=E6=8E=A8=E5=B9=BF=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=B8=8D=E7=BB=93=E7=AE=97=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MarketPercentageController.class.php | 229 ++++++++++++++++-- .../Controller/TimingController.class.php | 16 +- .../addcompanybelonggame.html | 21 +- .../editcompanybelonggame.html | 21 +- Data/update.sql | 5 +- 5 files changed, 246 insertions(+), 46 deletions(-) diff --git a/Application/Admin/Controller/MarketPercentageController.class.php b/Application/Admin/Controller/MarketPercentageController.class.php index ee34a249a..b8a719adb 100644 --- a/Application/Admin/Controller/MarketPercentageController.class.php +++ b/Application/Admin/Controller/MarketPercentageController.class.php @@ -24,6 +24,185 @@ class MarketPercentageController extends ThinkController $admin_id = $_SESSION['onethink_admin']['user_auth']['uid']; $map['admin_id'] = $admin_id; + $map['is_settlement'] = 1; + if(is_administrator()||session('user_group_id') == 15||session('user_group_id') == 14||session('user_group_id') == 19||session('user_group_id') == 23) { + unset($map['admin_id']); + $admin_data = M("member") + ->field("access.uid admin_id") + ->join("left join sys_auth_group_access access on sys_member.uid = access.uid") + ->join("left join sys_auth_group auth on access.group_id=auth.id") + ->where(['group_id'=>['in','11,12,21']]) + ->select(); + if ($admin_data) { + $map['admin_id'] = ['in',array_column($admin_data,'admin_id')]; + } + $_REQUEST['admin_id']?($map['admin_id'] = $_REQUEST['admin_id']):''; + } + + $search_date = []; + if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) { + + $end = $_REQUEST['time_end']; + $start = $_REQUEST['time_start']; + $i = 0; + do { + $date = date('Y-m', strtotime($start . ' + ' . $i . ' month')); + $search_date[] = $date; + $i++; + }while ($date < date('Y-m', strtotime("{$end}"))); + + if ($search_date) { + $map['pay_time'] = ['in', $search_date]; + } + + } elseif (isset($_REQUEST['time_start'])) { + + $end = date("Y-m",time()); + $start = $_REQUEST['time_start']; + $i = 0; + do { + $date = date('Y-m', strtotime($start . ' + ' . $i . ' month')); + $search_date[] = $date; + $i++; + }while ($date < date('Y-m', strtotime("{$end}"))); + + if ($search_date) { + $map['pay_time'] = ['in', $search_date]; + } + + } elseif (isset($_REQUEST['time_end'])) { + + $end = $_REQUEST['time_end']; + $start = '2019-08'; + $i = 0; + do { + $date = date('Y-m', strtotime($start . ' + ' . $i . ' month')); + $search_date[] = $date; + $i++; + }while ($date < date('Y-m', strtotime("{$end}"))); + + if ($search_date) { + $map['pay_time'] = ['in', $search_date]; + } + } +// dump($map);die(); +// var_dump($map);die(); + + $data = M("settleup_marketorder","tab_") + ->field("pay_time,promote_account,company_name,company_belong,member.real_name,develop_type,game_name, + sum(pay_amount) pay_amount,sum(cp_amount) cp_amount,sum(promote_amount) promote_amount, + sum(channel_amount) channel_amount, sum(company_tax) company_tax,sum(company_profit) company_profit") + ->join("left join sys_member member on member.uid=admin_id"); + + if ($_REQUEST['export']) { + $data = $data->where($map) + ->group("promote_id,game_name,pay_time,admin_id") + ->order("pay_time DESC") + ->select(); + } else { + $data = $data->page($p, $row) + ->where($map) + ->group("promote_id,game_name,pay_time,admin_id") + ->order("pay_time DESC") + ->select(); + } + + $sum = M("settleup_marketorder","tab_") + ->field("pay_time,promote_account,company_belong,real_name,develop_type,game_name, + sum(pay_amount) pay_amount,sum(cp_amount) cp_amount,sum(promote_amount) promote_amount, + sum(channel_amount) channel_amount, sum(company_tax) company_tax,sum(company_profit) company_profit") + ->where($map) + ->find(); + + $this->assign("sum",$sum); + + foreach ($data as $key => $value) { + + if ($value['company_belong'] == 0) { + $data[$key]['company_belong'] = '内团'; + } else if ($value['company_belong'] == 1) { + $data[$key]['company_belong'] = '外团'; + } else if ($value['company_belong'] == 2) { + $data[$key]['company_belong'] = '外团-分发联盟'; + } else { + $data[$key]['company_belong'] = '无'; + } + + if ($value['develop_type'] == 1) { + $data[$key]['develop_type'] = '自主开发'; + } else if ($value['develop_type'] == 2) { + $data[$key]['develop_type'] = '自主开发及维护'; + } else if ($value['develop_type'] == 3) { + $data[$key]['develop_type'] = '只维护'; + } else { + $data[$key]['develop_type'] = '无'; + } + } + + if ($_REQUEST['export']) { + + $title = ['pay_time' => '时间', + 'company_name'=>'公司名称', + 'promote_account' => '会长账号', + 'company_belong' => '内外团', + 'real_name' => '所属市场专员', + 'develop_type' => '类型', + 'game_name' => '游戏名称', + 'pay_amount' => '总流水', + 'cp_amount' => '上游结算流水', + 'promote_amount' => '下游结算流水', + 'channel_amount' => '支付渠道费用', + 'company_tax' => '公司税费', + 'company_profit' => '税后毛利额']; + + foreach ($data as $key => $value) { + $data[$key]['pay_time'] = '`'.$data[$key]['pay_time']; + } + + $sum['pay_time'] = ''; + $sum['promote_account'] = ''; + $sum['company_belong'] = '合计'; + $sum['real_name'] = ''; + $sum['develop_type'] = ''; + $sum['game_name'] = ''; + + $data = array_merge($data,[$sum]); + + data2csv($data,'市场毛利统计',$title); + } + + $count = M("settleup_marketorder","tab_") + ->where($map) + ->group("promote_id,game_name,pay_time,admin_id") + ->select(false); + + $count = M()->table("({$count}) count")->count(); + + $page = set_pagination($count, $row); + if ($page) { + $this->assign('_page', $page); + } + $this->checkListOrCountAuthRestMap($map,[]); + + $this->assign("list_data",$data); + $this->display(); + + } + + public function indexuncaculate($row = 10, $p = 1){ + + $map = []; + +// $_REQUEST['pay_time']?($map['pay_time'] = $_REQUEST['pay_time']):''; + $_REQUEST['promote_id']?($map['promote_id'] = $_REQUEST['promote_id']):''; + $_REQUEST['relation_game_id']?($map['relation_game_id'] = $_REQUEST['relation_game_id']):''; + $_REQUEST['sdk_version']?($map['sdk_version'] = $_REQUEST['sdk_version']):''; + $_REQUEST['admin_id']?($map['admin_id'] = $_REQUEST['admin_id']):''; + ($_REQUEST['company_id']||$_REQUEST['company_id']=='0')?($map['company_id'] = $_REQUEST['company_id']):''; + + $admin_id = $_SESSION['onethink_admin']['user_auth']['uid']; + $map['admin_id'] = $admin_id; + $map['is_settlement'] = 0; if(is_administrator()||session('user_group_id') == 15||session('user_group_id') == 14||session('user_group_id') == 19||session('user_group_id') == 23) { unset($map['admin_id']); $admin_data = M("member") @@ -1262,15 +1441,15 @@ class MarketPercentageController extends ThinkController foreach ($data as $key => $value) { - $data[$key]["begin_time"] = date("Y-m-d",$value['begin_time']); - $data[$key]["end_time"] = date("Y-m-d",$value['end_time']); + $data[$key]["begin_time"] = date("Y-m-01",strtotime($value['time'])); + $data[$key]["end_time"] = date("Y-m-t",strtotime($value['time'])); $where_game = $value['game_ids']; if ($_REQUEST['relation_game_id']) { $where_game = $_REQUEST['relation_game_id']; } -// dump($where_game);die(); + $game = []; if ($where_game) { $game = M("game","tab_") @@ -1307,12 +1486,8 @@ class MarketPercentageController extends ThinkController $data = $_POST; - if (!$data['begin_time']) { - $this->ajaxReturn(['msg'=>"请填写开始时间","status"=>0]); - } - - if (!$data['end_time']) { - $this->ajaxReturn(['msg'=>"请填写截止时间","status"=>0]); + if (!$data['time']) { + $this->ajaxReturn(['msg'=>"请填写生效月份","status"=>0]); } if (!$data['game_ids']) { @@ -1322,25 +1497,22 @@ class MarketPercentageController extends ThinkController $data['game_ids'] = array_merge([''],$data['game_ids'],['']); $data['game_ids'] = implode(',',$data['game_ids']); -// $data['game_ids'] = json_encode($data['game_ids']); - - $data['begin_time'] = strtotime($data['begin_time']); - $data['end_time'] = strtotime($data['end_time']); +// $data['time'] = strtotime($data['time']); +// $data['end_time'] = strtotime($data['end_time']); $belong_game = M("company_belong_game","tab_") - ->where("(begin_time<={$data['begin_time']} and end_time >={$data['begin_time']}) or (begin_time<={$data['end_time']} and end_time >={$data['end_time']})") + ->where("time='{$data['time']}'") ->select(); if ($belong_game) { - $this->ajaxReturn(['msg'=>"时间段重叠,不能增加已经相交的时间段","status"=>0]); + $this->ajaxReturn(['msg'=>"已添加月份,请勿重复添加","status"=>0]); } M("company_belong_game","tab_")->add($data); $this->ajaxReturn(['msg'=>"添加成功","status"=>1]); - } else { $this->display(); } @@ -1355,12 +1527,8 @@ class MarketPercentageController extends ThinkController if (IS_POST) { $data = $_POST; - if (!$data['begin_time']) { - $this->ajaxReturn(['msg'=>"请填写开始时间","status"=>0]); - } - - if (!$data['end_time']) { - $this->ajaxReturn(['msg'=>"请填写截止时间","status"=>0]); + if (!$data['time']) { + $this->ajaxReturn(['msg'=>"请填写生效月份","status"=>0]); } if (!$data['game_ids']) { @@ -1369,18 +1537,27 @@ class MarketPercentageController extends ThinkController // $data['game_ids'] = json_encode($data['game_ids']); + $data['game_ids'] = explode(',',$data['game_ids']); + foreach ($data['game_ids'] as $key => $value) { + if ($value == "0") { + unset($data['game_ids'][$key]); + } + } + + $data['game_ids'] = array_merge([''],$data['game_ids'],['']); + $data['game_ids'] = implode(',',$data['game_ids']); - $data['begin_time'] = strtotime($data['begin_time']); - $data['end_time'] = strtotime($data['end_time']); +// $data['begin_time'] = strtotime($data['begin_time']); +// $data['end_time'] = strtotime($data['end_time']); $belong_game = M("company_belong_game","tab_") - ->where("((begin_time<={$data['begin_time']} and end_time >={$data['begin_time']}) or (begin_time<={$data['end_time']} and end_time >={$data['end_time']})) and id != {$id}") + ->where("time='{$data['time']}' and id != {$id}") ->select(); if ($belong_game) { - $this->ajaxReturn(['msg'=>"时间段重叠,不能修改成已经相交的时间段","status"=>0]); + $this->ajaxReturn(['msg'=>"已添加月份,请勿重复添加","status"=>0]); } // dump($data);die(); M("company_belong_game","tab_")->where(['id'=>$id])->save($data); diff --git a/Application/Admin/Controller/TimingController.class.php b/Application/Admin/Controller/TimingController.class.php index ce71f40f4..3c26e6d88 100644 --- a/Application/Admin/Controller/TimingController.class.php +++ b/Application/Admin/Controller/TimingController.class.php @@ -1138,14 +1138,11 @@ class TimingController extends AdminController { //下游流水 // $promote_data[$key]['promote_amount'] = $value['pay_amount'] * ($promote_radio * 0.01); - - //特殊补点 $specialPayAmount[$value['pay_time']] = $this->getSpecialComplement(strtotime(date("Y-m-1",strtotime($value['pay_time']))),strtotime(date("Y-m-t",strtotime($value['pay_time'])))+86399,$value['promote_id']); $specialAmount = $specialPayAmount[$value['pay_time']][$value['company_id']."-".$value['promote_id']."-".$value['relation_game_id']]?$specialPayAmount[$value['pay_time']][$value['company_id']."-".$value['promote_id']."-".$value['relation_game_id']]:0; - //渠道费用 $promote_data[$key]['channel_amount'] = $channel_fee[$value['pay_time'].$value['promote_id'].$value['game_name'].$value['admin_id']]; $tax = 0; @@ -1156,6 +1153,17 @@ class TimingController extends AdminController { } } + $belong_game = M("company_belong_game","tab_") + ->field("game_ids") + ->where("time='{$value['pay_time']}'") + ->find(); + + $belong_game = array_values(explode(",",$belong_game['game_ids'])); + + if ((in_array($value['relation_game_id'],$belong_game) && $value['company_belong'] ==1) || $value['company_belong'] !=1) { + $promote_data[$key]['is_settlement']=1; + } + $promote_data[$key]['company_tax'] = ($value['pay_amount']-$promote_data[$key]['cp_amount']- $promote_data[$key]['promote_amount'])*($tax/100); //毛利 @@ -1253,6 +1261,8 @@ class TimingController extends AdminController { $this->insertAllUserBonus($pay_time); } + $map['is_settlement'] = 1; + $all_data = M("settleup_marketorder","tab_") ->field("tab_settleup_marketorder.id,pay_time,promote_account,company_belong,tab_settleup_marketorder.real_name,develop_type,game_name, sum(pay_amount) pay_amount,sum(company_profit) company_profit,group_id,market_percentage,nickname,admin_id, diff --git a/Application/Admin/View/MarketPercentage/addcompanybelonggame.html b/Application/Admin/View/MarketPercentage/addcompanybelonggame.html index 02301f913..3e9ed3648 100644 --- a/Application/Admin/View/MarketPercentage/addcompanybelonggame.html +++ b/Application/Admin/View/MarketPercentage/addcompanybelonggame.html @@ -90,7 +90,7 @@ } @@ -107,9 +107,7 @@ *生效期限:
- - - - +
@@ -225,10 +223,17 @@ $(function(){ $('.time').datetimepicker({ - format: 'yyyy-mm-dd', - language: "zh-CN", - minView: 2, - autoclose: true + format: 'yyyy-mm', + language:"zh-CN", + // minView:2, + weekStart: 1, + todayBtn: true, + todayHighlight: false, + startView: 3, + minView: 3, + forceParse: 0, + autoclose:true, + pickerPosition:'bottom-left' }); $('#submit').click(function (e) { diff --git a/Application/Admin/View/MarketPercentage/editcompanybelonggame.html b/Application/Admin/View/MarketPercentage/editcompanybelonggame.html index 990adbf7f..2aceabcda 100644 --- a/Application/Admin/View/MarketPercentage/editcompanybelonggame.html +++ b/Application/Admin/View/MarketPercentage/editcompanybelonggame.html @@ -90,7 +90,7 @@ } @@ -107,9 +107,7 @@ *生效期限:
- - - - +
@@ -226,10 +224,17 @@ $(function(){ $('.time').datetimepicker({ - format: 'yyyy-mm-dd', - language: "zh-CN", - minView: 2, - autoclose: true + format: 'yyyy-mm', + language:"zh-CN", + // minView:2, + weekStart: 1, + todayBtn: true, + todayHighlight: false, + startView: 3, + minView: 3, + forceParse: 0, + autoclose:true, + pickerPosition:'bottom-left' }); $('#submit').click(function (e) { diff --git a/Data/update.sql b/Data/update.sql index 47d11d3a0..522f88d98 100644 --- a/Data/update.sql +++ b/Data/update.sql @@ -2673,4 +2673,7 @@ ALTER TABLE `tab_game_ratio_mould` ADD COLUMN `turnover_type` tinyint(2) NULL DEFAULT 0 COMMENT '结算流水类型' AFTER `end_time`; ALTER TABLE `tab_company_game_ratio_log` -ADD COLUMN `turnover_type` tinyint(2) NULL DEFAULT 0 COMMENT '结算流水类型 1 月流水 2 历史流水' AFTER `end_time`; \ No newline at end of file +ADD COLUMN `turnover_type` tinyint(2) NULL DEFAULT 0 COMMENT '结算流水类型 1 月流水 2 历史流水' AFTER `end_time`; + +ALTER TABLE `tab_settleup_marketorder` +ADD COLUMN `is_settlement` tinyint(2) NULL DEFAULT 0 COMMENT '是否结算' AFTER `company_profit`; \ No newline at end of file