现在下游外团分析

master
chenzhi 4 years ago
parent f07b29714b
commit c7c4b52c89

@ -16,7 +16,7 @@ class GameMarginSetController extends Controller {
private $month;//月份
private $year;//年份
private $adddata;//要添加的数据
// public $taskid=false;
private $inSideCompanyIds;
// public $result='';
/**
* 更新某月数据
@ -58,14 +58,27 @@ class GameMarginSetController extends Controller {
private function setGameMargin()
{
$this->getInsideCompanyid();
$this->getAllGameSpend();
// $this->getJuheStatement();
// $this->getPuStatement();
//上游
$this->getCpStatement();
$this->getJuheStatement();
$this->getPuStatement();
$this->getPcStatement();
dd($this->adddata);
}
/**
* 内部公司
*/
private function getInsideCompanyid()
{
$res = M("PromoteCompany","tab_")->where("is_inside = 1")->field("id")->select();
if($res){
$res = array_column($res,"id");
$res[] = 0;
}else{
$res = [0];
}
$this->inSideCompanyIds = implode(",",$res);
}
//获取期间所有有流水的游戏
private function getAllGameSpend()
@ -326,10 +339,8 @@ class GameMarginSetController extends Controller {
foreach ($res as $v) {
$sinfo = json_decode($v['statement_info'],true);
foreach ($sinfo as $val) {
var_dump($val['game_name']);
//获取真实游戏名
$games = $this->OPName2GName($val['game_name'],$v['company_id']);
var_dump($games);
$games = $this->cpOPName2GName($val['game_name'],$v['company_id']);
foreach ($games as $game) {
if( !array_key_exists($game,$this->adddata) ){
continue;
@ -345,9 +356,8 @@ class GameMarginSetController extends Controller {
}
}
}
//原包名还原游戏名
private function OPName2GName($OPName,$company_id)
//结算包名还原游戏名
private function cpOPName2GName($OPName,$company_id)
{
$where = [
"partner_id"=>$company_id,
@ -355,11 +365,40 @@ class GameMarginSetController extends Controller {
];
$game = M("Game","tab_")->field("relation_game_name")->where($where)->group("relation_game_name")->select();
if($game){
return array_column($game,"relation_game_name");
return array_column($game,"relation_game_name");
}else{
return [$OPName];
}
}
//获取下游内团
private function getPcStatement()
{
$where = [
"company_belong"=>0,
"withdraw_type"=>1,
"statement_begin_time"=>$this->beginThismonth,
"statement_end_time"=>$this->endThismonth,
"company_id"=>["NOT IN",$this->inSideCompanyIds]
];
$res = M("company_statement","tab_")->where($where)->select();
if($res){
foreach ($res as $v) {
$sinfo = json_decode($v['statement_info'],true);
foreach ($sinfo as $val) {
//奖罚不算
if( !array_key_exists($val['game_name'],$this->adddata) ){
continue;
}
if( array_key_exists("pc_pay_amount",$this->adddata[$val['game_name']]) ){
$this->adddata[$val['game_name']]['pc_pay_amount'] += $val['pay_amount'];
$this->adddata[$val['game_name']]['pc_statement_amount'] += $val['sum_money'];
}else{
$this->adddata[$val['game_name']]['pc_pay_amount'] = $val['pay_amount'];
$this->adddata[$val['game_name']]['pc_statement_amount'] = $val['sum_money'];
}
}
}
}
}
}

Loading…
Cancel
Save