11月功能提交

master
zhengyongxing 4 years ago
parent 4eff2f0aaa
commit 1626640066

@ -2360,7 +2360,7 @@ function getGameCpRadio($game_id,$amount,$type) {
*/
function getGamePromoteCompanyRadio($company_id,$relation_game_id,$endtime,$amount,$type,$company_belong=false) {
//判断是否有生效
$rwhere = "(end_time = 0 OR end_time >= '{$endtime}') and company_id='{$company_id}' and relation_game_id='{$relation_game_id}'";
$rwhere = "(end_time = 0 OR end_time >= '{$endtime}') and company_id='{$company_id}' and relation_game_id='{$relation_game_id}' and company_belong = {$company_belong} ";
$cgr_res = M("CompanyGameRatio","tab_")->where($rwhere)->find();
// dump( M("CompanyGameRatio","tab_")->where($rwhere)->select(false));
if(empty($cgr_res)){

@ -682,7 +682,7 @@ class CompanyGameRatioController extends AdminController
$this->error('默认分成比例不能为空');
}
//查询
$y = M("company_game_ratio_log","tab_")->where("id='{$params['id']}'")->find();
$y = M("company_game_ratio","tab_")->where("id='{$params['id']}'")->find();
$save['turnover_ratio'] = $this->setTurnoverRatio($params);
$save['ratio'] = $params['ratio'] ?? 0;
$save['last_turnover_ratio'] = $params['last_turnover_ratio'];
@ -695,6 +695,7 @@ class CompanyGameRatioController extends AdminController
$save['turnover_type'] = $params['turnover_type'] ?? 1;
$save['status'] = 0;
$save['verify_log']=json_encode(["create_user"=>$this->admininfo["username"],"create_time"=>date("Y-m-d H:i:s")]);
$save['company_belong'] = $y['company_belong'] ?? 0;
if($y['ratio'] != $save['ratio'] || $y['turnover_ratio'] != $save['turnover_ratio'] || $y['begin_time'] != $save['begin_time'] || $y['end_time'] != $save['end_time']){
$save['status'] = 0;
@ -754,6 +755,7 @@ class CompanyGameRatioController extends AdminController
$save['end_time'] = $params['end_time'] ? strtotime($params['end_time'])+86399 : 0;
$save['remark'] = $params['remark'] ?? '';
$save['turnover_type'] = $params['turnover_type'] ?? 1;
$save['company_belong'] = $y['company_belong'] ?? 0;
if($y['ratio'] != $save['ratio'] || $y['turnover_ratio'] != $save['turnover_ratio'] || $y['begin_time'] != $save['begin_time'] || $y['end_time'] != $save['end_time'] || $y['turnover_type'] != $save['turnover_type']){
$save['status'] = 0;
$save['verify_log'] = json_encode(["create_user"=>$this->admininfo["username"],"create_time"=>date("Y-m-d H:i:s")]);

@ -737,11 +737,19 @@ class CompanyStatementSetController extends Controller {
if($type == 1){
$tratio =$this->getTurnoverRatio($game_all_payment,$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']);
$tratio += $company_ratio;
// if ($add_data['company_id'] == 12&&$game['relation_game_id'] == 191) {
// dump($tratio);
// dump($game_all_payment);
// dump($tmp_game_ratio);
// dump($company_ratio);
// }
}elseif($type == 0){
// $tratio = $tmp_game_ratio['ratio'];
$turnover_type = $this->getTurnoverType($t_game_id,$k,$begintime,$endtime);
if ($turnover_type == 2) {
if ($turnover_type == 2 || $turnover_type == 4) {
$tratio =$this->getTurnoverRatio($game_all_payment,$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']);
} else {
$tratio = $tmp_game_ratio['ratio'];
@ -749,7 +757,7 @@ class CompanyStatementSetController extends Controller {
}else{
//补点
$turnover_type = $this->getTurnoverType($t_game_id,$k,$begintime,$endtime);
if ($turnover_type == 2) {
if ($turnover_type == 2 || $turnover_type == 4) {
continue;
}
$tratio1 =$this->getTurnoverRatio($game_all_payment,$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']);
@ -787,14 +795,14 @@ class CompanyStatementSetController extends Controller {
// $tratio = $t_game_ratio['ratio'];
$turnover_type = $this->getTurnoverType($t_game_id,$k,$begintime,$endtime);
if ($turnover_type == 2) {
if ($turnover_type == 2 || $turnover_type == 4) {
$tratio =$this->getTurnoverRatio($game_all_payment,$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']);
} else {
$tratio = $tmp_game_ratio['ratio'];
}
}else{
$turnover_type = $this->getTurnoverType($t_game_id,$k,$begintime,$endtime);
if ($turnover_type == 2) {
if ($turnover_type == 2 || $turnover_type == 4) {
continue;
}
//补点
@ -929,6 +937,8 @@ class CompanyStatementSetController extends Controller {
public function getPromoteCompanySpend(&$pcList,$idarr,$begintime,$endtime){
$res = [];
$all_res = [];
$cp_res = [];
$cp_all_res = [];
//获取推广员
if(count($idarr) == 0){return $res;}
$Promote = M("Promote","tab_");
@ -937,6 +947,20 @@ class CompanyStatementSetController extends Controller {
"s.pay_status"=>1,
"s.payed_time"=>['between', [$begintime,$endtime]],
];
// dump($spenMap);
$cpSpendList = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount,s.game_id,g.relation_game_id,g.relation_game_name game_name')->where($spenMap)->group('game_id')
->join("left join tab_game g on s.game_id = g.id")
->select();
$cpAllMap = $spenMap;
$cpAllMap["s.payed_time"] = ['elt',$endtime];
// unset($cpAllMap["s.payed_time"]);
$cpAllSpendList = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount,s.game_id,g.relation_game_id,g.relation_game_name game_name')->where($cpAllMap)->group('game_id')
->join("left join tab_game g on s.game_id = g.id")
->select();
for ($i=0; $i <count($idarr); $i++) {
$company_id = $idarr[$i];
@ -970,6 +994,36 @@ class CompanyStatementSetController extends Controller {
}
}
foreach($cpSpendList as $k=>$v){
try {
$cp_res[$company_id]["pay_amount"] += $v['pay_amount'];
} catch (\Throwable $th) {
$cp_res[$company_id]["pay_amount"] = $v['pay_amount'];
}
if(isset($cp_res[$company_id][$v['relation_game_id']])){
//
$cp_res[$company_id][$v['relation_game_id']]['pay_amount'] += $v['pay_amount'];
}else{
unset($v['game_id']);
$cp_res[$company_id][$v['relation_game_id']]= $v;
}
}
foreach($cpAllSpendList as $k=>$v){
try {
$cp_all_res[$company_id]["pay_amount"] += $v['pay_amount'];
} catch (\Throwable $th) {
$cp_all_res[$company_id]["pay_amount"] = $v['pay_amount'];
}
if(isset($cp_all_res[$company_id][$v['relation_game_id']])){
//
$cp_all_res[$company_id][$v['relation_game_id']]['pay_amount'] += $v['pay_amount'];
}else{
unset($v['game_id']);
$cp_all_res[$company_id][$v['relation_game_id']]= $v;
}
}
if(empty($list)){continue;}
foreach($list as $k=>$v){
@ -1013,6 +1067,16 @@ class CompanyStatementSetController extends Controller {
if ($turnover_type == 2) {
$res[$company_id][$v[$j]]['ratio_pay_amount'] = $all_res[$company_id][$v[$j]]['pay_amount'];
$temp += $all_res[$company_id][$v[$j]]['pay_amount'];
} elseif($turnover_type == 3){
$res[$company_id][$v[$j]]['ratio_pay_amount'] = $cp_res[$company_id][$v[$j]]['pay_amount'];
$temp += $cp_res[$company_id][$v[$j]]['pay_amount'];
} elseif($turnover_type == 4){
$res[$company_id][$v[$j]]['ratio_pay_amount'] = $cp_all_res[$company_id][$v[$j]]['pay_amount'];
$temp += $cp_all_res[$company_id][$v[$j]]['pay_amount'];
} else {
// $res[$company_id][$v[$j]]['ratio_pay_amount'] = $res[$company_id][$v[$j]]['pay_amount'];
$temp += $res[$company_id][$v[$j]]['pay_amount'];
@ -1039,6 +1103,10 @@ class CompanyStatementSetController extends Controller {
$turnover_type = $this->getTurnoverType($k,$key,$begintime,$endtime);
if ($turnover_type == 2) {
$res[$key][$k]['ratio_pay_amount'] = $all_res[$key][$k]['pay_amount'];
} elseif($turnover_type == 3){
$res[$key][$k]['ratio_pay_amount'] = $cp_res[$key][$k]['pay_amount'];
} elseif($turnover_type == 4){
$res[$key][$k]['ratio_pay_amount'] = $cp_all_res[$key][$k]['pay_amount'];
}
}
@ -1059,6 +1127,11 @@ class CompanyStatementSetController extends Controller {
*/
public function getTurnoverType($relation_game_id = 0, $company_id = 0, $begin_time = 0, $end_time = 0){
$company_belong = M("promote_company","tab_")->field("company_belong")->where(['id'=>$company_id])->find();
if (!$company_belong) {
return 0;
}
$turnover_where = [
"company_belong"=>$company_belong['company_belong'],
"relation_game_id"=>$relation_game_id,
@ -1105,6 +1178,19 @@ class CompanyStatementSetController extends Controller {
"s.pay_status"=>1,
"s.payed_time"=>['between', [$begintime,$endtime]],
];
$cpSpendList = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount,s.game_id,g.relation_game_id,g.relation_game_name game_name')->where($spenMap)->group('game_id')
->join("left join tab_game g on s.game_id = g.id")
->select();
$cpAllMap = $spenMap;
$cpAllMap["s.payed_time"] = ['elt',$endtime];
// unset($cpAllMap["s.payed_time"]);
$cpAllSpendList = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount,s.game_id,g.relation_game_id,g.relation_game_name game_name')->where($cpAllMap)->group('game_id')
->join("left join tab_game g on s.game_id = g.id")
->select();
for ($i=0; $i <count($idarr); $i++) {
$company_id = $idarr[$i];
@ -1161,6 +1247,24 @@ class CompanyStatementSetController extends Controller {
}
}
$cpgame = [];
foreach($cpSpendList as $k=>$v){
if(isset($cpgame[$v['relation_game_id']])){
$cpgame[$v['relation_game_id']]['pay_amount'] += $v['pay_amount'];
}else{
$cpgame[$v['relation_game_id']]['pay_amount'] = $v['pay_amount'];
}
}
$cpallgame = [];
foreach($cpAllSpendList as $k=>$v){
if(isset($cpallgame[$v['relation_game_id']])){
$cpallgame[$v['relation_game_id']]['pay_amount'] += $v['pay_amount'];
}else{
$cpallgame[$v['relation_game_id']]['pay_amount'] = $v['pay_amount'];
}
}
//同cp同一个原包名的共享总流水分成
$game_ids = implode(",",array_keys($game));
$game_ids = $this->getModuleRatioGame($company_id,$game_ids,$begintime,$endtime);
@ -1173,6 +1277,10 @@ class CompanyStatementSetController extends Controller {
$turnover_type = $this->getTurnoverType($v[$j],$company_id,$begintime,$endtime);
if ($turnover_type == 2) {
$temp += $allgame[$v[$j]]['pay_amount'];
} elseif($turnover_type == 3) {
$temp += $cpgame[$v[$j]]['pay_amount'];
} elseif($turnover_type == 4) {
$temp += $cpallgame[$v[$j]]['pay_amount'];
} else {
// $res[$company_id][$v[$j]]['ratio_pay_amount'] = $res[$company_id][$v[$j]]['pay_amount'];
$temp += $game[$v[$j]]['pay_amount'];
@ -1207,6 +1315,10 @@ class CompanyStatementSetController extends Controller {
if ($turnover_type == 2) {
// $temp += $allgame[$v[$j]]['pay_amount'];
$res[$company_id][$p_account][$v['relation_game_id']]['all_pay_amount']= $allgame[$v['relation_game_id']]['pay_amount'];
} elseif($turnover_type == 3) {
$res[$company_id][$p_account][$v['relation_game_id']]['all_pay_amount']= $cpgame[$v['relation_game_id']]['pay_amount'];
} elseif($turnover_type == 4) {
$res[$company_id][$p_account][$v['relation_game_id']]['all_pay_amount']= $cpallgame[$v['relation_game_id']]['pay_amount'];
} else {
// $res[$company_id][$v[$j]]['ratio_pay_amount'] = $res[$company_id][$v[$j]]['pay_amount'];
$res[$company_id][$p_account][$v['relation_game_id']]['all_pay_amount']= $game[$v['relation_game_id']]['pay_amount'];
@ -1418,14 +1530,14 @@ class CompanyStatementSetController extends Controller {
// $tratio = $tmp_game_ratio['ratio'];
$turnover_type = $this->getTurnoverType($p_info['relation_game_id'],$k,$begintime,$endtime);
if ($turnover_type == 2) {
if ($turnover_type == 2||$turnover_type == 4) {
$tratio =$this->getTurnoverRatio($p_info['all_pay_amount'],$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']);
} else {
$tratio = $tmp_game_ratio['ratio'];
}
}else{
$turnover_type = $this->getTurnoverType($p_info['relation_game_id'],$k,$begintime,$endtime);
if ($turnover_type == 2) {
if ($turnover_type == 2||$turnover_type == 4) {
continue;
}
//补点
@ -1489,7 +1601,7 @@ class CompanyStatementSetController extends Controller {
$turnover_type = $this->getTurnoverType($p_info['relation_game_id'],$k,$begintime,$endtime);
if ($turnover_type == 2) {
if ($turnover_type == 2 || $turnover_type == 4) {
$tratio =$this->getTurnoverRatio($p_info['all_pay_amount'],$tmp_game_ratio['ratio'],$tmp_game_ratio['turnover_ratio']);
} else {
$tratio = $tmp_game_ratio['ratio'];
@ -1498,7 +1610,7 @@ class CompanyStatementSetController extends Controller {
}else{
$turnover_type = $this->getTurnoverType($p_info['relation_game_id'],$k,$begintime,$endtime);
if ($turnover_type == 2) {
if ($turnover_type == 2 || $turnover_type == 4) {
continue;
}
//补点
@ -1931,7 +2043,15 @@ class CompanyStatementSetController extends Controller {
* return string "148,157"
*/
protected function getModuleRatioGame($company_id,$relation_game_ids,$begintime,$endtime){
$company_belong = M("promote_company","tab_")->field("company_belong")->where(['id'=>$company_id])->find();
if(empty($company_belong)){
return $relation_game_ids;
}
$where = [
"company_belong"=>$company_belong['company_belong'],
"relation_game_id"=>["in",$relation_game_ids],
"company_id"=>$company_id,
"_string"=>"begin_time <={$endtime} AND ( end_time = 0 OR end_time >= {$begintime})"

@ -100,6 +100,9 @@ class CompanyGameRatioModel extends Model
}
} else {
// if ($company_id == 12&&$game_id == 191) {
// dump(2);
// }
$game_ratio[$game_id] = $this->getGameRadio($company_id,$game_id,$company_belong,$begintime,$endtime);
}
@ -114,9 +117,12 @@ class CompanyGameRatioModel extends Model
$map = [
"company_id"=>$company_id,
"relation_game_id"=>$game_id,
"_string"=>"begin_time <={$endtime} AND ( end_time = 0 OR end_time >= {$begintime})"
"_string"=>"begin_time <={$endtime} AND ( end_time = 0 OR end_time >= {$begintime})",
"company_belong"=>$company_belong,
];
$res = $this->where($map)->order("begin_time asc")->select();
$data = [];
if(empty($res)){
$this->getGameMouldRadio($data,$game_id,$company_belong,$begintime,$endtime);

@ -162,7 +162,7 @@
<th>原包名</th>
<th>现包名</th>
<th>产品类型</th>
<th>游戏比例生效时间</th>
<th>结算时间</th>
<th colspan="2">游戏分成比例</th>
<th style="width:10%;min-width:150px;">操作</th>
</tr>

Loading…
Cancel
Save