|
|
|
@ -18,8 +18,14 @@ class StatementController extends ThinkController
|
|
|
|
|
$first_party_info = json_decode($dbres['first_party_info'],true);
|
|
|
|
|
$second_party_info = json_decode($dbres['second_party_info'],true);
|
|
|
|
|
$statement_info = json_decode($dbres['statement_info'],true);
|
|
|
|
|
$fine = array_pop($statement_info);
|
|
|
|
|
if($dbres['company_name'] == $first_party_info['partner']){
|
|
|
|
|
$first_partner_type=0;
|
|
|
|
|
}else{
|
|
|
|
|
$first_partner_type=1;
|
|
|
|
|
}
|
|
|
|
|
// $fine = array_pop($statement_info);
|
|
|
|
|
$senddata = array(
|
|
|
|
|
"first_partner_type"=>$first_partner_type,
|
|
|
|
|
"first_part_company"=>$first_party_info['partner'],
|
|
|
|
|
"second_part_company"=>$second_party_info['partner'],
|
|
|
|
|
"statement_type"=>$_REQUEST['pay_type'] == 0 ? 1 :0,
|
|
|
|
@ -27,13 +33,13 @@ class StatementController extends ThinkController
|
|
|
|
|
"second_party_info"=>$second_party_info,
|
|
|
|
|
"statement_info"=>$statement_info,
|
|
|
|
|
"statement_count"=>array("sum_money"=>$dbres['statement_money'],"pay_amount"=>$dbres['pay_amount']),
|
|
|
|
|
"fine"=>$fine['sum_money'],
|
|
|
|
|
"fine"=>0,
|
|
|
|
|
"statement_begin_time"=>date("Y-m-d",$dbres['statement_begin_time']),
|
|
|
|
|
"statement_end_time"=>date("Y-m-d",$dbres['statement_end_time'])
|
|
|
|
|
);
|
|
|
|
|
$this->assign("data",$senddata);
|
|
|
|
|
if($_REQUEST['pay_type'] == 0){
|
|
|
|
|
$this->assign("company",$dbres['company_name']);
|
|
|
|
|
$this->assign("company",$second_party_info['partner']);
|
|
|
|
|
}else{
|
|
|
|
|
$this->assign("company",$first_party_info['partner']);
|
|
|
|
|
}
|
|
|
|
@ -56,15 +62,20 @@ class StatementController extends ThinkController
|
|
|
|
|
$this->ajaxReturn(array("error"=>"database error","code"=>2000));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public function getCompanyList()
|
|
|
|
|
{
|
|
|
|
|
$data = array();
|
|
|
|
|
$data['ptCompany']= M("CompanyInfo","tab_")->field('id,partner')->select();
|
|
|
|
|
$data['cpCompany']= getPartner();
|
|
|
|
|
$this->ajaxReturn(array("success"=>$data,"code"=>2000));
|
|
|
|
|
}
|
|
|
|
|
//获取推广公司基础信息
|
|
|
|
|
public function getCpCompanyInfo()
|
|
|
|
|
{
|
|
|
|
|
$CompanyId = $_REQUEST['company_id'];
|
|
|
|
|
if($CompanyId == 0){
|
|
|
|
|
$mycompany = M("tool","tab_")->field("config")->where("name='company_info'")->find();
|
|
|
|
|
$info = json_decode($mycompany['config'],true);
|
|
|
|
|
$info['id'] = 0;
|
|
|
|
|
unset($info['status']);
|
|
|
|
|
$company_type = $_REQUEST['company_type'];
|
|
|
|
|
if($company_type == 'pt'){
|
|
|
|
|
$info = M("CompanyInfo","tab_")->field("id,partner,link_man,link_phone,address,company_tax_no,payee_name,bank_account,opening_bank")->where("id = '{$CompanyId}'")->find();
|
|
|
|
|
}else{
|
|
|
|
|
$info = M("partner","tab_")->field("id,partner,link_man,link_phone,address,company_tax_no,payee_name,bank_account,opening_bank")->where("id = '{$CompanyId}'")->find();
|
|
|
|
|
}
|
|
|
|
@ -81,7 +92,8 @@ class StatementController extends ThinkController
|
|
|
|
|
$map["pay_status"] = 1;
|
|
|
|
|
|
|
|
|
|
$CompanyId = $_REQUEST['company_id']; //对账公司id
|
|
|
|
|
$statement_type = $_REQUEST['statement_type'];
|
|
|
|
|
$statement_type = $_REQUEST['statement_type'];//付款方
|
|
|
|
|
$first_partner_type = $_REQUEST['first_partner_type'];//甲方类型:0cp,1pt
|
|
|
|
|
|
|
|
|
|
$is_month = false;//是否是月结判断,非月结无需梯度计算
|
|
|
|
|
if (isset($_REQUEST['time_start']) && isset($_REQUEST['time_end'])) {
|
|
|
|
@ -164,8 +176,14 @@ class StatementController extends ThinkController
|
|
|
|
|
// $redio = $ratiores[0]['ratio'];
|
|
|
|
|
// }
|
|
|
|
|
$redio = getGameCpRadio($v['game_id'],$v['pay_amount'],$is_month);//获取分成比例
|
|
|
|
|
$v['second_ratio'] = $redio;
|
|
|
|
|
$v['first_ratio'] = (100-$redio);
|
|
|
|
|
if($first_partner_type==0){
|
|
|
|
|
//甲方cp
|
|
|
|
|
$v['first_ratio'] = round($redio,2);
|
|
|
|
|
$v['second_ratio'] = round((100-$redio),2);
|
|
|
|
|
}else{
|
|
|
|
|
$v['second_ratio'] = round($redio,2);
|
|
|
|
|
$v['first_ratio'] = round((100-$redio),2);
|
|
|
|
|
}
|
|
|
|
|
if($statement_type == 0){
|
|
|
|
|
$v['sum_money'] = round($v['pay_amount']*$v['first_ratio']/100,2);
|
|
|
|
|
}else{
|
|
|
|
@ -180,6 +198,41 @@ class StatementController extends ThinkController
|
|
|
|
|
$v['statement_end_time']=$_REQUEST['time_end'];
|
|
|
|
|
$v['statement_type']=0;
|
|
|
|
|
}
|
|
|
|
|
//获取奖罚
|
|
|
|
|
$rrmap = array(
|
|
|
|
|
"reward_time" => ['between', [strtotime($_REQUEST['time_start']), strtotime($_REQUEST['time_end']) + 86399]],
|
|
|
|
|
);
|
|
|
|
|
$rfres = M("RewardRecord","tab_")
|
|
|
|
|
->field("
|
|
|
|
|
IFNULL(SUM(CASE WHEN reward_type = 1 THEN money ELSE 0 END),0) as reward_count,
|
|
|
|
|
IFNULL(SUM(CASE WHEN reward_type = 2 THEN money ELSE 0 END),0) as fine_count
|
|
|
|
|
")
|
|
|
|
|
->where($rrmap)->find();
|
|
|
|
|
if($rfres['reward_count'] > 0){
|
|
|
|
|
$list[] = array(
|
|
|
|
|
"statement_begin_time"=>$_REQUEST['time_start'],
|
|
|
|
|
"statement_end_time"=>$_REQUEST['time_end'],
|
|
|
|
|
'statement_type'=>2,
|
|
|
|
|
"game_name"=>"奖励",
|
|
|
|
|
'pay_amount'=>$rfres['reward_count'],
|
|
|
|
|
'sum_money'=>$rfres['reward_count'],
|
|
|
|
|
);
|
|
|
|
|
$countarr['pay_amount'] +=$rfres['reward_count'];
|
|
|
|
|
$countarr['sum_money']+=$rfres['reward_count'];
|
|
|
|
|
}
|
|
|
|
|
if($rfres['fine_count'] > 0){
|
|
|
|
|
$list[] = array(
|
|
|
|
|
"statement_begin_time"=>$_REQUEST['time_start'],
|
|
|
|
|
"statement_end_time"=>$_REQUEST['time_end'],
|
|
|
|
|
'statement_type'=>1,
|
|
|
|
|
"game_name"=>"罚款",
|
|
|
|
|
'pay_amount'=>$rfres['fine_count'],
|
|
|
|
|
'sum_money'=>$rfres['fine_count'],
|
|
|
|
|
);
|
|
|
|
|
$countarr['pay_amount'] -= $rfres['fine_count'];
|
|
|
|
|
$countarr['sum_money'] -= $rfres['fine_count'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$countarr['pay_amount'] = round($countarr['pay_amount'],2);
|
|
|
|
|
$countarr['sum_money'] = round($countarr['sum_money'],2);
|
|
|
|
|
|
|
|
|
@ -188,19 +241,26 @@ class StatementController extends ThinkController
|
|
|
|
|
}
|
|
|
|
|
//添加数据
|
|
|
|
|
public function doAddCpStatement($id = 0){
|
|
|
|
|
$first_partner_type = $_REQUEST['first_partner_type'];
|
|
|
|
|
if($first_partner_type == 0){
|
|
|
|
|
//甲方cp
|
|
|
|
|
$company = $_REQUEST['first_party_info'];
|
|
|
|
|
}else{
|
|
|
|
|
$company =$_REQUEST['second_party_info'];
|
|
|
|
|
}
|
|
|
|
|
$second_party_info = $_REQUEST['second_party_info'];
|
|
|
|
|
$statement_info = $_REQUEST['statement_info'];
|
|
|
|
|
$statement_info[] = array(
|
|
|
|
|
"sum_money"=>$_REQUEST['fine'],
|
|
|
|
|
"type_name"=>"罚款",
|
|
|
|
|
"statement_type"=>1
|
|
|
|
|
);
|
|
|
|
|
// $statement_info[] = array(
|
|
|
|
|
// "sum_money"=>$_REQUEST['fine'],
|
|
|
|
|
// "type_name"=>"罚款",
|
|
|
|
|
// "statement_type"=>1
|
|
|
|
|
// );
|
|
|
|
|
//拼凑数据
|
|
|
|
|
$adddata = array(
|
|
|
|
|
"statement_type"=>0,
|
|
|
|
|
"company_id"=>$second_party_info['id'],
|
|
|
|
|
"company_name"=>$second_party_info['partner'],
|
|
|
|
|
"link_phone"=>$second_party_info['link_phone'],
|
|
|
|
|
"company_id"=>$company['id'],
|
|
|
|
|
"company_name"=>$company['partner'],
|
|
|
|
|
"link_phone"=>$company['link_phone'],
|
|
|
|
|
"statement_begin_time"=>strtotime($_REQUEST['statement_begin_time']),
|
|
|
|
|
"statement_end_time"=>strtotime($_REQUEST['statement_end_time']),
|
|
|
|
|
'create_time'=>time(),
|
|
|
|
|