diff --git a/Application/Admin/Controller/FinancePromoteController.class.php b/Application/Admin/Controller/FinancePromoteController.class.php
index b38e6f4c0..0e4ae43b1 100644
--- a/Application/Admin/Controller/FinancePromoteController.class.php
+++ b/Application/Admin/Controller/FinancePromoteController.class.php
@@ -47,6 +47,13 @@ class FinancePromoteController extends AdminController
$senddata[$v['p_id']] = $v;
}
+ $unsenddata = [];
+ $uncash = self::getJoinUnPayPromoteData([],$istimeselect);
+ foreach($uncash as $k=>$v){
+ $unsenddata[$v['p_id']] = $v;
+ }
+
+
//内冲
$inside = self::getJoinPromoteData([],$istimeselect,"promote_coin");
foreach($inside as $k=>$v){
@@ -152,11 +159,13 @@ class FinancePromoteController extends AdminController
$v['develop_type_text'] = getCompanyDevelopTypeText($v['develop_type']);
$v['inside_cash_count'] = number_format($v['inside_cash_count'],2,'.','');
$v['allcount'] = number_format($v['cash_count']-0+$v['balance_coin_count']+$v['bind_coin_count'],2,'.','');
+ $v['unallcount'] = $unsenddata[$k]['cash_count']?$unsenddata[$k]['cash_count']:'0.00';
$count['cash_count'] += $v['cash_count'];
$count['balance_coin_count'] += $v['balance_coin_count'];
$count['bind_coin_count'] += $v['bind_coin_count'];
$count['inside_cash_count'] += $v['inside_cash_count'];
$count['all_count'] += $v['allcount'];
+ $count['unallcount'] += $v['unallcount'];
$data[] = $v;
}
$data = my_sort($data, $data_order_type, (int)$data_order);
@@ -176,10 +185,11 @@ class FinancePromoteController extends AdminController
"balance_coin_count"=>"平台币直充支出",
"bind_coin_count"=>"内充支出",
"inside_cash_count"=>"平台币内充",
- "allcount"=>"渠道游戏内充值合计"
+ "allcount"=>"渠道游戏内充值合计",
+ "unallcount"=>"渠道游戏内不结算充值合计",
));
}
-
+// dump($data);die();
$pagecount = count($data);
$page = set_pagination($pagecount, $row);
if ($page) {
@@ -221,6 +231,91 @@ class FinancePromoteController extends AdminController
$this->meta_title = '公会统计';
$this->display();
}
+
+ private function getJoinUnPayPromoteData($map,$istimeselect,$type="spend")
+ {
+ // setPowerPromoteIds($map,"s.promote_id");
+ //推广员相关检索
+ if (isset($_REQUEST['promote_id'])) {
+ if ($_REQUEST['promote_id'] == 0) {
+ $map['s.promote_id'] = 0;
+ } else {
+ $promoter_ids = D("Promote")->where("chain like '%/{$_REQUEST['promote_id']}/%' or id={$_REQUEST['promote_id']}")->field('id')->select();
+ if ($promoter_ids) {
+ $map['s.promote_id'] = ['in', implode(',', array_column($promoter_ids, 'id'))];
+ }
+ }
+ }
+ if (isset($_REQUEST['company_id'])) {
+ $map['promote.company_id'] = $_REQUEST['company_id'];
+
+ }
+ if (isset($_REQUEST['company_belong'])) {
+ $map['promote.company_belong'] = $_REQUEST['company_belong'];
+
+ }
+ $isMarketLeader = isMarketLeader();
+ if ($isMarketLeader) {
+ $map['promote.admin_id'] = ['gt', 0];
+ }
+
+ if (!empty(I('develop_type'))) {
+ $map['company.develop_type'] = ['in',I('develop_type')];
+ }
+
+ $adminId = 0;
+ // $havingPids = [];
+ $isMarketAdmin = isMarketAdmin();
+ if ($isMarketAdmin) {
+ $userAuth = session('user_auth');
+ $adminId = $userAuth['uid'];
+ } else {
+ if (!empty(I('admin_id'))) {
+ $adminId = I('admin_id');
+ }
+ }
+ /* if ($adminId > 0) {
+ $havingPids = M('promote', 'tab_')->where(['admin_id' => $adminId])->getField('id', true);
+ $havingPids = count($havingPids) > 0 ? $havingPids : [0];
+ } */
+
+ if($type == "spend"){
+ if (isset($_REQUEST['game_name']) || isset($_REQUEST['game_type'])) {
+ $map["s.game_id"] = array("in",implode(',', array_column(getGameByName($_REQUEST['game_name'], $_REQUEST['game_type']), 'id')) );
+ }
+ if($istimeselect){
+ $map['s.payed_time']=$istimeselect;
+ }
+ if ($isMarketLeader) {
+ $map['s.market_admin_id'] = ['gt', 0];
+ }
+ if ($adminId > 0) {
+ $map['s.market_admin_id'] = $adminId;
+ }
+ $map['s.pay_status']=1;
+ $map['s.is_check']=2;
+ $field= "SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END) as cash_count,
+ SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END) as balance_coin_count,
+ SUM(CASE WHEN pay_way = -1 THEN pay_amount ELSE 0 END) as bind_coin_count,
+ IFNULL(if(substring_index(substring_index(promote.`chain`,'/',2),'/',-1)='',s.promote_id,substring_index(substring_index(promote.`chain`,'/',2),'/',-1)),0) p_id,
+ IFNULL(company_id,0) company_id,company_name,develop_type,IFNULL(promote.company_belong,0) company_belong";
+ $query = M()
+ ->table("tab_spend s use index(promote_time)")
+ ->field($field)
+ ->where($map)
+ ->join("tab_promote promote ON s.promote_id = promote.id","left")
+ ->join("tab_promote_company company ON promote.company_id = company.id","left")
+ ->group('p_id');
+ /* if (count($havingPids) > 0) {
+ $query->having('p_id in (' . implode(',', $havingPids) . ')');
+ } */
+ return $query->select();
+ }else {
+ return [];
+ }
+
+ }
+
private function getJoinPromoteData($map,$istimeselect,$type="spend")
{
// setPowerPromoteIds($map,"s.promote_id");
diff --git a/Application/Admin/Controller/FinancialSummarySetController.class.php b/Application/Admin/Controller/FinancialSummarySetController.class.php
index 2720c987e..b2af3c6b7 100644
--- a/Application/Admin/Controller/FinancialSummarySetController.class.php
+++ b/Application/Admin/Controller/FinancialSummarySetController.class.php
@@ -132,7 +132,8 @@ class FinancialSummarySetController extends \Think\Controller
$map = array(
"payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
- "pay_status"=>1
+ "pay_status"=>1,
+ 'is_check'=>['neq',2],
);
$res = $this->SpendModel
->field("IFNULL(SUM(CASE WHEN pay_way > 0 THEN pay_amount ELSE 0 END),0) as cash_count,IFNULL(SUM(CASE WHEN pay_way = 0 THEN pay_amount ELSE 0 END),0) as balance_coin_count")
@@ -265,7 +266,8 @@ class FinancialSummarySetController extends \Think\Controller
{
$map = array(
"payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
- "pay_status"=>1
+ "pay_status"=>1,
+ 'is_check'=>['neq',2],
);
$res = $this->SpendModel
->alias('s')
@@ -451,7 +453,8 @@ class FinancialSummarySetController extends \Think\Controller
$map = array(
"s.payed_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth)),
"s.pay_status"=>1,
- "s.merchant_id"=>["GT","0"]
+ "s.merchant_id"=>["GT","0"],
+ 'is_check'=>['neq',2],
);
$spres=$this->SpendModel
->alias("s")
@@ -544,7 +547,7 @@ class FinancialSummarySetController extends \Think\Controller
payed_time,game_id,main_name,merchant_way,merchant.account")
->join("left join tab_test_white_list on tab_spend.user_id=tab_test_white_list.user_id")
->join("left join tab_payment_merchant merchant on merchant.id=tab_spend.merchant_id")
- ->where(['pay_status'=>1,'tab_spend.pay_way'=>['egt',1],'merchant.status'=>1,'merchant.type'=>1])
+ ->where(['pay_status'=>1,'tab_spend.pay_way'=>['egt',1],'merchant.status'=>1,'merchant.type'=>1,'is_check'=>['neq',2]])
->where($map)
->group("merchant_id")
->select(false);
diff --git a/Application/Admin/Controller/PlatformController.class.php b/Application/Admin/Controller/PlatformController.class.php
index 599f86fee..a5195ed65 100644
--- a/Application/Admin/Controller/PlatformController.class.php
+++ b/Application/Admin/Controller/PlatformController.class.php
@@ -44,7 +44,7 @@ class PlatformController extends ThinkController
if($isExport){
$data = $data->select();
//生成头
- $fp = $this->setPromotePoolTitle($year,"game");
+ $fp = $this->setGamePoolTitle($year,"game");
}else{
$data = $data->page($page,$row)->select();
$countTable = $gameDb->where($gameMap)->group("relation_game_id")->select(false);
@@ -55,14 +55,14 @@ class PlatformController extends ThinkController
$sendData = [];
foreach($data as $k=>$v){
- $list = self::setYearList($year);
+ $list = self::setGameYearList($year);
$this->getGameRegisterCount($list,$v['game_id'],$yearMap);
$this->getGamePayamountCount($list,$v['game_id'],$yearMap);
$v["list"] = $list;
$sendData[] = $v;
if($isExport){
unset($v['game_id'],$v['relation_game_id']);
- $fp = $this->setCsvData($fp,$v);
+ $fp = $this->setGameCsvData($fp,$v);
}
}
if($isExport){
@@ -71,7 +71,7 @@ class PlatformController extends ThinkController
exit();
}
- $th = array_keys(self::setYearList($year));
+ $th = array_keys(self::setGameYearList($year));
$this->assign('th', $th);
$this->assign('list_data', $sendData);
$this->assign("companyList",D("PromoteCompany")->getList());
@@ -170,6 +170,7 @@ class PlatformController extends ThinkController
$list = self::setYearList($year);
$this->getRegisterCount($list,$promoteIds,$yearMap);
$this->getPayamountCount($list,$promoteIds,$yearMap);
+// $this->getunPayamountCount($list,$promoteIds,$yearMap);
$v["list"] = $list;
$v["company_belong"] = getCompanyBlongOther($v["company_belong"]);
$sendData[] = $v;
@@ -182,6 +183,8 @@ class PlatformController extends ThinkController
exit();
}
+// dump($sendData);die();
+
$th = array_keys(self::setYearList($year));
$this->assign('th', $th);
$this->assign('list_data', $sendData);
@@ -197,6 +200,23 @@ class PlatformController extends ThinkController
}
+ //获取游戏公司每个月的注册及充值金额
+ private static function setGameYearList($year)
+ {
+ $range = [];
+ $i = 1;
+ do {
+ if($i < 10){
+ $month = "0".$i;
+ }else{
+ $month = $i;
+ }
+ $range[$year."-".$month] = ["register"=>0,"payamount"=>0];
+ $i++;
+ } while ($i<13);
+ return $range;
+ }
+
//获取公司每个月的注册及充值金额
private static function setYearList($year)
{
@@ -208,7 +228,7 @@ class PlatformController extends ThinkController
}else{
$month = $i;
}
- $range[$year."-".$month] = ["register"=>0,"payamount"=>0];
+ $range[$year."-".$month] = ["register"=>0,"payamount"=>0,"unpay_amount"=>0];
$i++;
} while ($i<13);
return $range;
@@ -234,10 +254,25 @@ class PlatformController extends ThinkController
"pay_time"=>["between",$yearMap],
"pay_status"=>1
];
- $Payamount = M("Spend","tab_")->field("sum(pay_amount) pay_amount,FROM_UNIXTIME(`pay_time`, '%Y-%m') paytime")->where($map)->group("paytime")->select();
+ $Payamount = M("Spend","tab_")->field("sum(pay_amount) pay_amount,IFNULL(sum(IF(is_check=2,pay_amount,0)),0) unpay_amount,FROM_UNIXTIME(`pay_time`, '%Y-%m') paytime")->where($map)->group("paytime")->select();
if(empty($Payamount)) return ;
foreach ($Payamount as $v) {
$list[$v['paytime']]['payamount'] = $v['pay_amount'];
+ $list[$v['paytime']]['unpay_amount'] = $v['unpay_amount'];
+ }
+ }
+ //获取未结算流水
+ protected function getunPayamountCount(&$list,$promoteIds,$yearMap)
+ {
+ $map = [
+ "promote_id"=>["in",$promoteIds],
+ "pay_time"=>["between",$yearMap],
+ "pay_status"=>1
+ ];
+ $Payamount = M("Spend","tab_")->field("sum(IF(is_check=2,pay_amount,0)) pay_amount,FROM_UNIXTIME(`pay_time`, '%Y-%m') paytime")->where($map)->group("paytime")->select();
+ if(empty($Payamount)) return ;
+ foreach ($Payamount as $v) {
+ $list[$v['paytime']]['unpayamount'] = $v['pay_amount'];
}
}
//获取所有年分
@@ -255,6 +290,44 @@ class PlatformController extends ThinkController
}
$this->assign('YearList', $list);
}
+
+ //获取导出头
+ private static function setGamePoolTitle($year,$type="promote")
+ {
+ if($type =="promote"){
+ $range = ["推广公司","内外团归属"];
+ $csvFileName = '推广公司汇总.csv';
+ }else{
+ $range = ["游戏名称"];
+ $csvFileName = '游戏汇总.csv';
+ }
+
+ $i = 1;
+ do {
+ if($i < 10){
+ $month = "0".$i;
+ }else{
+ $month = $i;
+ }
+ $range[] = $year."年".$month."月注册数";
+ $range[] = $year."年".$month."月充值流水";
+ $i++;
+ } while ($i<13);
+
+ //设置好告诉浏览器要下载excel文件的headers
+ header('Content-Description: File Transfer');
+ header('Content-Type: application/vnd.ms-excel');
+ header('Content-Disposition: attachment; filename="'. $csvFileName .'"');
+ header('Expires: 0');
+ header('Cache-Control: must-revalidate');
+ header('Pragma: public');
+ $fp = fopen('php://output', 'a');//打开output流
+ mb_convert_variables('GBK', 'UTF-8', $range);
+ fputcsv($fp, $range);//将数据格式化为CSV格式并写入到output流中
+
+ return $fp;
+ }
+
//获取导出头
private static function setPromotePoolTitle($year,$type="promote")
{
@@ -275,6 +348,7 @@ class PlatformController extends ThinkController
}
$range[] = $year."年".$month."月注册数";
$range[] = $year."年".$month."月充值流水";
+ $range[] = $year."年".$month."月不结算充值流水";
$i++;
} while ($i<13);
@@ -291,6 +365,28 @@ class PlatformController extends ThinkController
return $fp;
}
+
+ //获取导出头
+ private static function setGameCsvData($fp,$data)
+ {
+ unset($data['id']);
+ $sendData = [];
+ foreach ($data as $key => $value) {
+ if($key != "list"){
+ $sendData[] = $value;
+ }
+ }
+ foreach ($data['list'] as $key => $value) {
+ $sendData[] = $value['register'];
+ $sendData[] = $value['payamount'];
+ }
+ mb_convert_variables('GBK', 'UTF-8', $sendData);
+ fputcsv($fp, $sendData);//将数据格式化为CSV格式并写入到output流中
+ ob_flush();
+ flush();
+ return $fp;
+ }
+
//获取导出头
private static function setCsvData($fp,$data)
{
@@ -304,6 +400,7 @@ class PlatformController extends ThinkController
foreach ($data['list'] as $key => $value) {
$sendData[] = $value['register'];
$sendData[] = $value['payamount'];
+ $sendData[] = $value['unpay_amount'];
}
mb_convert_variables('GBK', 'UTF-8', $sendData);
fputcsv($fp, $sendData);//将数据格式化为CSV格式并写入到output流中
@@ -1073,7 +1170,7 @@ class PlatformController extends ThinkController
$data = M('promote', 'tab_')->alias('tp1')
->field('tp1.account as promote_account,tp1.id,g.relation_game_id,g.relation_game_name,
- floor(sum(pay_amount)*100) as count')
+ floor(sum(pay_amount)*100) as count,IFNULL(sum(IF(is_check=2,pay_amount,0)),0) unpay_count')
->join("tab_promote AS tp2 ON tp2.`chain` LIKE CONCAT('%/', tp1.id, '/%') OR tp2.id = tp1.id", 'left')
->join("tab_spend as s use INDEX(search) on tp2.id = s.promote_id", 'left')
->join("tab_game as g on g.id = s.game_id", 'left')
@@ -1146,7 +1243,7 @@ class PlatformController extends ThinkController
if ($user_auth_promote_ids == 'all' || in_array('0', explode(",", $user_auth_promote_ids))) {
//官方渠道数据添加
$authorityData = M('spend', 'tab_')->alias('s')
- ->field('floor(sum(pay_amount)*100) as count')
+ ->field('floor(sum(pay_amount)*100) as count,IFNULL(sum(IF(is_check=2,pay_amount,0)),0) unpay_count')
->where($map)
->find();
$tauthorityData = M('spend', 'tab_')->alias('s')
@@ -1168,6 +1265,9 @@ class PlatformController extends ThinkController
array_push($data, $authorityData);
}
}
+
+// dump($data);die();
+
//数据排序
$last_names = array_column($data,'count');
array_multisort($last_names,SORT_DESC,$data);
diff --git a/Application/Admin/Controller/StatementMangementController.class.php b/Application/Admin/Controller/StatementMangementController.class.php
index 4f72beed3..5948cf2e9 100644
--- a/Application/Admin/Controller/StatementMangementController.class.php
+++ b/Application/Admin/Controller/StatementMangementController.class.php
@@ -328,6 +328,7 @@ class StatementMangementController extends ThinkController
->join('tab_reward_detail as rd on rd.record_id = r.id', 'LEFT')
->where($map)
->group('r.id')
+// ->order('create_time DESC')
->select();
if ($result) {
@@ -349,7 +350,9 @@ class StatementMangementController extends ThinkController
rd.id as rid, rd.type as detail_type, rd.company_type as detail_company_type, rd.company_id as detail_company_id , rd.company_name as detail_company_name, rd.settlement_type as detail_settlement_type, rd.promote_account as detail_promote_account,rd.amount as detail_amount
')
->where($map)
- ->join('tab_reward_detail as rd on rd.record_id = r.id', 'LEFT')->select();
+ ->join('tab_reward_detail as rd on rd.record_id = r.id', 'LEFT')
+ ->order('create_time DESC')
+ ->select();
if ($list) {
$record = [];
foreach ($list as $item) {
@@ -397,7 +400,7 @@ class StatementMangementController extends ThinkController
if ($page) {
$this->assign('_page', $page);
}
- ksort($record);
+// ksort($record);
$this->assign('list', $record);
$this->assign('promoters', array_column(M('promote', 'tab_')->where(['level'=>1])->field('id, nickname, account')->select(), null, 'id'));
@@ -505,9 +508,9 @@ class StatementMangementController extends ThinkController
}
//dd($settlment_info);
// 更新结算信息
- if ($id) {
- M('reward_detail', 'tab_')->where(['record_id'=>$id])->delete();
- }
+// if ($id) {
+// M('reward_detail', 'tab_')->where(['record_id'=>$id])->delete();
+// }
if (!empty($settlment_info[RewardModel::REWARD_TYPE_REWARD]) && !empty($settlment_info[RewardModel::REWARD_TYPE_PUNISH])) {
$data['reward_type'] = RewardModel::REWARD_TYPE_ALL;
} else if (!empty($settlment_info[RewardModel::REWARD_TYPE_REWARD])) {
diff --git a/Application/Admin/Controller/TimingController.class.php b/Application/Admin/Controller/TimingController.class.php
index 71a83319e..c85bebd81 100644
--- a/Application/Admin/Controller/TimingController.class.php
+++ b/Application/Admin/Controller/TimingController.class.php
@@ -1089,7 +1089,7 @@ class TimingController extends AdminController {
$spend = M("spend","tab_")
->field("sum(pay_amount) as pay_amount,FROM_UNIXTIME(pay_time,'%Y-%m') pay_time,
substring_index(substring_index(tab_spend.game_name,'(',1),'(',-1) game_name,game_id,relation_game_id,tab_spend.sdk_version,
- CASE WHEN substring_index(substring_index(`chain`,'/',2),'/',-1) !='' THEN substring_index(substring_index(`chain`,'/',2),'/',-1) ELSE promote_id END promote_id,pay_way,market_admin_id,0 is_settlement")
+ CASE WHEN substring_index(substring_index(`chain`,'/',2),'/',-1) !='' THEN substring_index(substring_index(`chain`,'/',2),'/',-1) ELSE promote_id END promote_id,pay_way,market_admin_id,0 is_settlement,is_check")
->join("left join tab_promote on tab_spend.promote_id = tab_promote.id")
->join("left join tab_game game on game.id=tab_spend.game_id")
->where(['tab_spend.pay_status'=>1,'pay_way'=>['egt',0]])
@@ -1111,7 +1111,7 @@ class TimingController extends AdminController {
$unsettlement_spend = M("spend","tab_")
->field("sum(pay_amount) as pay_amount,FROM_UNIXTIME(pay_time,'%Y-%m') pay_time,
substring_index(substring_index(tab_spend.game_name,'(',1),'(',-1) game_name,game_id,relation_game_id,tab_spend.sdk_version,
- CASE WHEN substring_index(substring_index(`chain`,'/',2),'/',-1) !='' THEN substring_index(substring_index(`chain`,'/',2),'/',-1) ELSE promote_id END promote_id,pay_way,market_admin_id,1 is_settlement")
+ CASE WHEN substring_index(substring_index(`chain`,'/',2),'/',-1) !='' THEN substring_index(substring_index(`chain`,'/',2),'/',-1) ELSE promote_id END promote_id,pay_way,market_admin_id,1 is_settlement,is_check")
->join("left join tab_promote on tab_spend.promote_id = tab_promote.id")
->join("left join tab_game game on game.id=tab_spend.game_id")
->where(['tab_spend.pay_status'=>1,'pay_way'=>['egt',0]])
@@ -1123,6 +1123,7 @@ class TimingController extends AdminController {
$payway_spend = M()->table("({$spend}) spend")
->field("sum(pay_amount) as pay_amount,pay_time,promote_id,game_name,game_id,relation_game_id,pay_way,sdk_version,market_admin_id,is_settlement")
+ ->where(['is_check'=>['neq',2]])
->where($map)
->group("pay_time,promote_id,game_name,pay_way,market_admin_id,is_settlement")
->select();
@@ -1189,6 +1190,7 @@ class TimingController extends AdminController {
$spend = M()->table("({$spend}) spend")
->field("sum(pay_amount) as pay_amount,pay_time,promote_id,game_name,game_id,relation_game_id,sdk_version,market_admin_id,is_settlement")
+ ->where(['is_check'=>['neq',2]])
->where($map)
->group("pay_time,promote_id,game_name,market_admin_id,is_settlement")
->select(false);
diff --git a/Application/Admin/View/FinancePromote/index.html b/Application/Admin/View/FinancePromote/index.html
index 49216715f..a5f4f39aa 100644
--- a/Application/Admin/View/FinancePromote/index.html
+++ b/Application/Admin/View/FinancePromote/index.html
@@ -220,7 +220,8 @@