diff --git a/Application/Admin/Common/extend.php b/Application/Admin/Common/extend.php
index 88fa10232..121f5b719 100644
--- a/Application/Admin/Common/extend.php
+++ b/Application/Admin/Common/extend.php
@@ -1511,6 +1511,26 @@ function getMonth() {
return $range;
}
+//开业至今月份
+function getOpenCompanyMonthsList()
+{
+ $start_month = "2019-09";
+
+ $temp = strtotime(date('Y-m-01 00:00:00',strtotime('-1 month')));
+ $end_month = date('Y',$temp)."-".date('m',$temp);
+
+ $time_arr = [];
+ $begin = new \DateTime($start_month);
+ $end = new \DateTime($end_month);
+ $end = $end->modify('+1 month');
+ $interval = new \DateInterval('P1M');
+ $daterange = new \DatePeriod($begin, $interval ,$end);
+ foreach($daterange as $date){
+ $time_arr[] = $date->format("Y-m");
+ }
+ rsort($time_arr);
+ return $time_arr;
+}
function showMonthRange($start, $end)
{
diff --git a/Application/Admin/Controller/GameMarginController.class.php b/Application/Admin/Controller/GameMarginController.class.php
new file mode 100644
index 000000000..143c3c850
--- /dev/null
+++ b/Application/Admin/Controller/GameMarginController.class.php
@@ -0,0 +1,162 @@
+DBModel = M("game_margin","tab_");
+ parent::_initialize();
+ }
+
+ public function lists()
+ {
+ $params = I('get.');
+ $page = $params['p'] ? intval($params['p']) : 1;
+ $row = $params['row'] ? intval($params['row']) : 10;
+ $where = [
+ "_string"=>"1=1"
+ ];
+ if(array_key_exists('count_date',$params)){
+ $m = explode("-",$params['count_date']);
+ $where['count_year']=$m[0];
+ $where['count_month']=$m[1];
+ }
+ $data = $this->DBModel->where($where)->field("margin_info",true)->page($page,$row)->select();
+ // dd($data);
+ $count = $this->DBModel->where($where)->count();
+ $page = set_pagination($count,$row);
+ if($page) {$this->assign('_page', $page);}
+
+ $this->assign("data",$data);
+ $this->display();
+ }
+
+ //查看毛利表
+ public function marginView(){
+ if(!isset($_REQUEST['id'])){
+ $this->error('参数错误');
+ }
+ $id = $_REQUEST['id'];
+ $info = $this->DBModel->where("id = '{$id}'")->find();
+ $this->marginCount($info);
+ $this->assign("year", $info['count_year']);
+ $this->assign("month", $info['count_month']);
+ $this->assign("id", $id);
+ $this->display();
+ }
+ private function marginCount($info)
+ {
+ $marginInfo = json_decode($info['margin_info'],true);
+ $count = [
+ "pay_amount"=>$info['pay_amount'],
+ "margin_ratio"=>$info['margin_ratio'],
+ "margin_amount"=>$info['margin_amount'],
+ "cp_statement_amount"=>0,
+ "cp_ratio"=>0,
+ "cp_rebate_amount"=>0,
+ "cp_other_amount"=>0,
+ "pu_pay_amount"=>0,
+ "pu_statement_amount"=>0,
+ "pu_ratio"=>0,
+ "pu_margin_amount"=>0,
+ "pu_margin_ratio"=>0,
+ "pc_pay_amount"=>0,
+ "pc_statement_amount"=>0,
+ "pc_ratio"=>0,
+ "pc_margin_amount"=>0,
+ "pc_margin_ratio"=>0,
+ "platform_margin_ratio"=>0,
+ "jh_pay_amount"=>0,
+ "jh_statement_amount"=>0,
+ "jh_ratio"=>0,
+ "jh_margin_amount"=>0,
+ "jh_margin_ratio"=>0,
+
+ ];
+ foreach ($marginInfo as $v) {
+ $count['cp_statement_amount'] += $v['cp_statement_amount'];
+ $count['cp_rebate_amount'] += $v['cp_rebate_amount'];
+ $count['cp_other_amount'] += $v['cp_other_amount'];
+
+ $count['pu_pay_amount'] += $v['pu_pay_amount'];
+ $count['pu_statement_amount'] += $v['pu_statement_amount'];
+ $count['pu_margin_amount'] += $v['pu_margin_amount'];
+
+ $count['pc_pay_amount'] += $v['pc_pay_amount'];
+ $count['pc_statement_amount'] += $v['pc_statement_amount'];
+ $count['pc_margin_amount'] += $v['pc_margin_amount'];
+
+ $count['jh_pay_amount'] += $v['jh_pay_amount'];
+ $count['jh_statement_amount'] += $v['jh_statement_amount'];
+ $count['jh_margin_amount'] += $v['jh_margin_amount'];
+
+ }
+ $count['cp_ratio'] = round( $count['cp_statement_amount']/$count['pay_amount'] ,4)*100;
+
+ $count['pu_ratio'] = round( $count['pu_statement_amount']/$count['pu_pay_amount'] ,4)*100;
+ $count['pu_margin_ratio'] = round( $count['pu_margin_amount']/$count['pu_pay_amount'] ,4)*100;
+
+ $count['pc_ratio'] = round( $count['pc_statement_amount']/$count['pc_pay_amount'] ,4)*100;
+ $count['pc_margin_ratio'] = round( $count['pc_margin_amount']/$count['pc_pay_amount'] ,4)*100;
+
+ $count['platform_margin_ratio'] = round(($count['pay_amount']-$count['jh_pay_amount']-$count['cp_statement_amount']-$count['cp_rebate_amount']-$count['cp_other_amount']-$count['pc_statement_amount']-$count['pu_statement_amount'])/($count['pay_amount']-$count['jh_pay_amount']),4)*100;
+
+ $count['jh_ratio'] = round( $count['jh_statement_amount']/$count['jh_pay_amount'] ,4)*100;
+ $count['jh_margin_ratio'] = round( $count['jh_margin_amount']/$count['jh_pay_amount'] ,4)*100;
+ // dd($count);
+ $this->assign("data",$marginInfo);
+ $this->assign("count",$count);
+ }
+ /**
+ * 编辑
+ */
+ public function marginEdit(){
+ ini_set('serialize_precision',14);
+ if(!isset($_REQUEST['id'])){
+ $this->error('参数错误');
+ }
+ $params = I("post.");
+
+ $data = $this->DBModel->where("id='{$params['id']}'")->find();
+ $marginInfo = json_decode($data['margin_info'],true);
+ $item = &$marginInfo[$params['key']];
+ $item['cp_rebate_ratio'] = $params['cp_rebate_ratio'];
+ $item['cp_rebate_amount'] = $params['cp_rebate_amount'];
+ $item['cp_other_amount'] = $params['cp_other_amount'];
+ if($item["pc_pay_amount"] > 0){
+ $item["pc_margin_amount"] = round($item["pc_pay_amount"]*(1-$item['cp_promote_ratio']/100)*(100-$item["cp_ratio"]-$item['cp_rebate_ratio']-$item["pc_ratio"])/100,2);
+ $item["pc_margin_ratio"] = round($item["pc_margin_amount"]/$item['pc_pay_amount'],4)*100;
+ }
+ if ($item["pu_pay_amount"] > 0) {
+ $item["pu_margin_amount"] = round($item["pu_pay_amount"]-$item["pu_pay_amount"]*(1-$item['cp_promote_ratio']/100)*($item["cp_ratio"]+$item['cp_rebate_ratio'])/100-$item["pu_statement_amount"],2);
+ $item["pu_margin_ratio"] = round($item["pu_margin_amount"]/$item['pu_pay_amount'],4)*100;
+ }
+
+ $item['platform_margin_ratio'] = round(($item['pay_amount']-$item['jh_pay_amount']-$item['cp_statement_amount']-$item['cp_rebate_amount']-$item['cp_other_amount']-$item['pc_statement_amount']-$item['pu_statement_amount'])/($item['pay_amount']-$item['jh_pay_amount']),4)*100;
+
+ if($item['jh_pay_amount'] > 0){
+ $item["jh_margin_amount"] = round( $item["jh_statement_amount"]-$item["jh_pay_amount"]*(1-$item['cp_promote_ratio']/100)*($item["cp_ratio"]+$item['cp_rebate_ratio'])/100 ,2);
+ $item["jh_margin_ratio"] = round($item["jh_margin_amount"]/$item['jh_pay_amount'],4)*100;
+ }
+ $margin_amount = 0;
+ //总计
+ foreach ($marginInfo as &$v) {
+ $margin_amount += $v['margin_amount'];
+ }
+ $margin_ratio = round( $margin_amount/$data['pay_amount'] ,4)*100;
+
+ $save = [
+ "margin_ratio"=>$margin_ratio,
+ "margin_amount"=>$margin_amount,
+ "margin_info"=>json_encode($marginInfo,JSON_UNESCAPED_UNICODE)
+ ];
+ $this->DBModel->where("id='{$params['id']}'")->save($save);
+ $this->ajaxReturn(['status'=>1,'msg'=>"修改成功,刷新。。。"]);
+ }
+
+
+
+}
\ No newline at end of file
diff --git a/Application/Admin/View/GameMargin/lists.html b/Application/Admin/View/GameMargin/lists.html
new file mode 100644
index 000000000..5218b864d
--- /dev/null
+++ b/Application/Admin/View/GameMargin/lists.html
@@ -0,0 +1,203 @@
+ 不自动生成,请在每月结算完成后手动生成,如该月结算数据有变动,需重算分析表毛利分析
+
年份 | +月份 | +游戏名 | +流水 | + +成本——上游CP | +上游返点 | + +其他费用 | + +成本——下游内团 | +成本——下游外团(含分发) | + +联运产品毛利率 | + +成本——下游聚合 | +毛利 | +操作 | +|||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
渠道费率 | +分成比例 | +结算金额 | +返点比例 | +返点金额 | +推广流水 | +分成比例 | +结算金额 | +内团毛利额 | +内团毛利率 | +推广流水 | +分成比例 | +结算金额 | +外团毛利额 | +外团毛利率 | +推广流水 | +分成比例 | +结算收入 | +聚合毛利额 | +聚合毛利率 | +毛利率 | +毛利额 | +||||||||||||||||||||||||||||
aOh! 暂时还没有内容! | +|||||||||||||||||||||||||||||||||||||||||||||||||
{$year} | +{$month} | +{$margin["relation_game_name"]} | +{$margin["pay_amount"]} | +{$margin["cp_promote_ratio"]}% | +{$margin["cp_ratio"]}% | +{$margin["cp_statement_amount"]} | +{$margin["cp_rebate_ratio"]}% | +{$margin["cp_rebate_amount"]} | +{$margin["cp_other_amount"]} | +{$margin["pc_pay_amount"]} | +{$margin["pc_ratio"]}% | +{$margin["pc_statement_amount"]} | +{$margin["pc_margin_amount"]} | +{$margin["pc_margin_ratio"]}% | +{$margin["pu_pay_amount"]} | +{$margin["pu_ratio"]}% | +{$margin["pu_statement_amount"]} | +{$margin["pu_margin_amount"]} | +{$margin["pu_margin_ratio"]}% | +{$margin["platform_margin_ratio"]}% | +{$margin["jh_pay_amount"]} | +{$margin["jh_ratio"]}% | +{$margin["jh_statement_amount"]} | +{$margin["jh_margin_amount"]} | +{$margin["jh_margin_ratio"]}% | +{$margin["margin_ratio"]}% | +{$margin["margin_amount"]} | ++ 编辑 + | +|||||||||||||||||||||
{$year} | +{$month} | +小计 | +{$count["pay_amount"]} | ++ | {$count["cp_ratio"]}% | +{$count["cp_statement_amount"]} | ++ | {$count["cp_rebate_amount"]} | +{$count["cp_other_amount"]} | +{$count["pc_pay_amount"]} | +{$count["pc_ratio"]}% | +{$count["pc_statement_amount"]} | +{$count["pc_margin_amount"]} | +{$count["pc_margin_ratio"]}% | +{$count["pu_pay_amount"]} | +{$count["pu_ratio"]}% | +{$count["pu_statement_amount"]} | +{$count["pu_margin_amount"]} | +{$count["pu_margin_ratio"]}% | +{$count["platform_margin_ratio"]}% | +{$count["jh_pay_amount"]} | +{$count["jh_ratio"]}% | +{$count["jh_statement_amount"]} | +{$count["jh_margin_amount"]} | +{$count["jh_margin_ratio"]}% | +{$count["margin_ratio"]}% | +{$count["margin_amount"]}% | ++ |