|
|
|
@ -102,16 +102,41 @@ class CompanyStatementSetController extends Controller {
|
|
|
|
|
}
|
|
|
|
|
//获取哪些要结算
|
|
|
|
|
if($type == 1){
|
|
|
|
|
$cpDbRes = M("Partner","tab_")->where("settlement_type = 2")->select();
|
|
|
|
|
$cpDbRes = M("CompanyRelation","tab_")->where("settlement_type = 2 AND (first_company_type = '1' OR second_company_type = '1')")->select();
|
|
|
|
|
}else{
|
|
|
|
|
$cpDbRes = M("Partner","tab_")->where("settlement_type = 1")->select();
|
|
|
|
|
$cpDbRes = M("CompanyRelation","tab_")->where("settlement_type = 1 AND (first_company_type = '1' OR second_company_type = '1')")->select();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$cpList=[];
|
|
|
|
|
$js_id = [];//己方公司
|
|
|
|
|
foreach ($cpDbRes as $k => $v) {
|
|
|
|
|
$cpList[$v['id']] =$v;
|
|
|
|
|
if($v['first_company_type'] == 1){
|
|
|
|
|
$cpList[$v['first_company_id']] =$v;
|
|
|
|
|
$js_id[] =$v['second_company_id'];
|
|
|
|
|
}else{
|
|
|
|
|
$cpList[$v['second_company_id']] =$v;
|
|
|
|
|
$js_id[] =$v['first_company_id'];
|
|
|
|
|
}
|
|
|
|
|
$cp_id = implode(",",array_flip(array_flip(array_column($cpDbRes,'id'))));
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
$cp_id = implode(",",array_flip(array_flip(array_keys($cpList))));
|
|
|
|
|
$js_id = implode(",",array_unique($js_id));
|
|
|
|
|
//获取cp公司
|
|
|
|
|
$tmpp = M("Partner","tab_")->field("id,partner,link_man,link_phone,address,company_tax_no,payee_name,bank_account,opening_bank")->where(["id"=>['in',$cp_id]])->select();
|
|
|
|
|
$cp =[];
|
|
|
|
|
foreach ($tmpp as $v) {
|
|
|
|
|
$cp[$v['id']]=$v;
|
|
|
|
|
}
|
|
|
|
|
unset($tmpp);
|
|
|
|
|
//获取己方公司
|
|
|
|
|
$our = [];
|
|
|
|
|
$tmpp = M("CompanyInfo","tab_")->field("id,partner,link_man,link_phone,address,company_tax_no,payee_name,bank_account,opening_bank")->where(["id"=>['in',$js_id]])->select();
|
|
|
|
|
foreach ($tmpp as $v) {
|
|
|
|
|
$our[$v['id']]=$v;
|
|
|
|
|
}
|
|
|
|
|
unset($tmpp);
|
|
|
|
|
unset($js_id);
|
|
|
|
|
//获取本地数据
|
|
|
|
|
$locals = $this->getLocalStatementData($begintime,$endtime,$cp_id);
|
|
|
|
|
//获取聚合数据
|
|
|
|
@ -154,8 +179,79 @@ class CompanyStatementSetController extends Controller {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//比例计算及保存
|
|
|
|
|
foreach($cpList as $v){
|
|
|
|
|
// TODO:此处不判断现游戏名=原包名,但却不是同一款游戏
|
|
|
|
|
$verify_log=json_encode(["create_user"=>$_SESSION['onethink_admin']['user_auth']["username"],"create_time"=>date("Y-m-d H:i:s")]);
|
|
|
|
|
$GameDb = M("Game","tab_");
|
|
|
|
|
$statement_begin_time = date("Y-m-d",$begintime);
|
|
|
|
|
$statement_end_time = date("Y-m-d",$endtime);
|
|
|
|
|
foreach($cpList as $k=>$v){
|
|
|
|
|
$add_data=[];
|
|
|
|
|
|
|
|
|
|
//1.获取甲乙方信息
|
|
|
|
|
if($v['first_company_type'] == 1){
|
|
|
|
|
//甲方上游
|
|
|
|
|
$add_data['first_party_info'] = json_encode($cp[$v['first_company_id']],JSON_UNESCAPED_UNICODE);
|
|
|
|
|
$add_data['second_party_info'] = json_encode($our[$v['second_company_id']],JSON_UNESCAPED_UNICODE);
|
|
|
|
|
$add_data['company_id'] = $v['first_company_id'];
|
|
|
|
|
$add_data['company_name'] = $v['first_company_name'];
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
//乙方上游
|
|
|
|
|
$add_data['first_party_info'] = json_encode($our[$v['first_company_id']],JSON_UNESCAPED_UNICODE);
|
|
|
|
|
$add_data['second_party_info'] = json_encode($cp[$v['second_company_id']],JSON_UNESCAPED_UNICODE);
|
|
|
|
|
$add_data['company_id'] = $v['second_company_id'];
|
|
|
|
|
$add_data['company_name'] = $v['second_company_name'];
|
|
|
|
|
}
|
|
|
|
|
$add_data['pay_type'] = $v['collection'];
|
|
|
|
|
$add_data['withdraw_type'] = $type;
|
|
|
|
|
$add_data['statement_begin_time'] = $begintime;
|
|
|
|
|
$add_data['statement_end_time'] = $endtime;
|
|
|
|
|
$add_data['statement_money'] = 0;
|
|
|
|
|
$add_data['pay_amount'] = 0;
|
|
|
|
|
$add_data['verify_log'] = $verify_log;
|
|
|
|
|
$add_data['op_time'] =time();
|
|
|
|
|
foreach($v['list'] as $ke=>$va){
|
|
|
|
|
$game =[];
|
|
|
|
|
$game['pay_amount'] =$va['pay_money'];
|
|
|
|
|
//获取游戏id及比例
|
|
|
|
|
$game_id = $GameDb->where("game_name='{$ke}' OR relation_game_name='{$ke}'")->field("id")->find();
|
|
|
|
|
if(empty($game_id)){
|
|
|
|
|
$game['id']=0;
|
|
|
|
|
// $game['sum_money']=0;
|
|
|
|
|
$tratio = 0;
|
|
|
|
|
}else{
|
|
|
|
|
//获取比例
|
|
|
|
|
$game['id']=$game_id['id'];
|
|
|
|
|
if($type > 0){
|
|
|
|
|
$tratio = getGameCpRadio($game_id['id'],$va['pay_money'],true);
|
|
|
|
|
}else{
|
|
|
|
|
$tratio = getGameCpRadio($game_id['id'],$va['pay_money'],false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($v['first_company_type'] == 1){
|
|
|
|
|
$game['first_ratio']=$tratio;
|
|
|
|
|
$game['second_ratio']=100-$tratio;
|
|
|
|
|
}else{
|
|
|
|
|
$game['first_ratio']=100-$tratio;
|
|
|
|
|
$game['second_ratio']=$tratio;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$game['sum_money']=round($va['pay_money']*$tratio/100,2);
|
|
|
|
|
|
|
|
|
|
$game['fax_ratio']=0;
|
|
|
|
|
$game['promote_ratio']=0;
|
|
|
|
|
$game['statement_begin_time']=$statement_begin_time;
|
|
|
|
|
$game['statement_end_time']=$statement_end_time;
|
|
|
|
|
$game['statement_type']=0;
|
|
|
|
|
dump($game);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
dd($v['list']);
|
|
|
|
|
dd($v);
|
|
|
|
|
//获取游戏比例
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# code...
|
|
|
|
|