|
|
|
@ -406,8 +406,13 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
$basedata = [
|
|
|
|
|
"pay_amount"=>0,
|
|
|
|
|
"statement_money"=>0,
|
|
|
|
|
"lack_statement_money"=>0,
|
|
|
|
|
"platform_amount"=>0,
|
|
|
|
|
"lack_platform_amount"=>0,
|
|
|
|
|
"create_lack_ids"=>[],
|
|
|
|
|
"del_lack_ids"=>[],
|
|
|
|
|
"statement_ids"=>[],
|
|
|
|
|
"info_ids"=>[],
|
|
|
|
|
"statement_begin_time"=>0,
|
|
|
|
|
"statement_end_time"=>0,
|
|
|
|
|
"fine"=>0,
|
|
|
|
@ -462,18 +467,32 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
$Pool = M("company_statement_pool","tab_");
|
|
|
|
|
$Statemen = M("company_statement","tab_");
|
|
|
|
|
foreach ($datas as $k => $v) {
|
|
|
|
|
if($v['platform_amount'] <= 0){continue;}
|
|
|
|
|
//执行
|
|
|
|
|
if(count($v['company_list']) <= 0){continue;}
|
|
|
|
|
|
|
|
|
|
//保存公司信息
|
|
|
|
|
$company_list = $v['company_list'];
|
|
|
|
|
foreach ($company_list as $ke => $va) {
|
|
|
|
|
$this->addStatementInfo($va,$k,$v);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(empty($v['create_lack_ids']) && empty($v['del_lack_ids']) && empty($v['info_ids'])){ continue;}
|
|
|
|
|
$v['statement_ids'] = implode(",",$v['statement_ids']);
|
|
|
|
|
$v['statement_num'] = "PL_".date('Ymd').date('His').sp_random_num(3);
|
|
|
|
|
$company_list = $v['company_list'];
|
|
|
|
|
$v['create_lack_ids'] = implode(",",$v['create_lack_ids']);
|
|
|
|
|
$v['del_lack_ids'] = implode(",",$v['del_lack_ids']);
|
|
|
|
|
$info = implode(",",$v['info_ids']);
|
|
|
|
|
unset($v['info_ids']);
|
|
|
|
|
unset($v['company_list']);
|
|
|
|
|
$pool_id = $Pool->add($v);
|
|
|
|
|
if($pool_id == false){
|
|
|
|
|
$this->ajaxReturn(array('status' => 0,"info"=>"汇总失败"));
|
|
|
|
|
}
|
|
|
|
|
foreach ($company_list as $ke => $va) {
|
|
|
|
|
$this->addStatementInfo($pool_id,$va,$k,$v);
|
|
|
|
|
if(!empty($info)){
|
|
|
|
|
$save["pool_id"]=$pool_id;
|
|
|
|
|
M("company_statement_info","tab_")->where("id in ({$info})")->save($save);
|
|
|
|
|
}
|
|
|
|
|
if(!empty($data['del_lack_ids'])){
|
|
|
|
|
M("company_lack_statement_info","tab_")->where("id in ({$v['del_lack_ids']})")->save(["is_pool"=>1]);
|
|
|
|
|
}
|
|
|
|
|
//修改结算单规则
|
|
|
|
|
$this->updatePoolVerifyStatus($v['statement_ids'],3,4,"pool",$v['statement_num']);
|
|
|
|
@ -498,9 +517,10 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//保存
|
|
|
|
|
protected function addStatementInfo($pool_id,$va,$k,$v){
|
|
|
|
|
protected function addStatementInfo($va,$k,&$v){
|
|
|
|
|
$StatementInfo = M("company_statement_info","tab_");
|
|
|
|
|
$company_info = $va['company_info'];
|
|
|
|
|
$LackStatement = M("company_lack_statement_info","tab_");
|
|
|
|
|
//统一比例字段
|
|
|
|
|
if($k == "up" || $k=="ups"){
|
|
|
|
|
foreach ($va['statement_info'] as $key => &$value) {
|
|
|
|
@ -513,26 +533,78 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
unset($value["second_ratio"]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$adddata=[
|
|
|
|
|
"pool_id"=>$pool_id,
|
|
|
|
|
"company_id"=>$company_info['id'],
|
|
|
|
|
"company_type"=>$v['company_type'],
|
|
|
|
|
"company_name"=>$company_info['partner'],
|
|
|
|
|
"ali_user"=>$company_info['ali_user'],
|
|
|
|
|
"ali_account"=>$company_info['ali_account'],
|
|
|
|
|
"fine"=>$va['fine'],
|
|
|
|
|
"reward"=>$va['reward'],
|
|
|
|
|
"statement_money"=>$va['statement_money'],
|
|
|
|
|
"pay_amount"=>$va['pay_amount'],
|
|
|
|
|
"platform_amount"=>$va['platform_amount'],
|
|
|
|
|
"statement_money"=>$va['statement_money'],
|
|
|
|
|
"statement_begin_time"=>$v['statement_begin_time'],
|
|
|
|
|
"statement_end_time"=>$v['statement_end_time'],
|
|
|
|
|
"statement_info"=>json_encode($va['statement_info'],JSON_UNESCAPED_UNICODE),
|
|
|
|
|
"statement_num"=>$va['statement_num']
|
|
|
|
|
];
|
|
|
|
|
//保存
|
|
|
|
|
return $StatementInfo->add($adddata);
|
|
|
|
|
//创建基础未满基础信息
|
|
|
|
|
if($va['statement_money'] < 300){
|
|
|
|
|
$lackcompany =[
|
|
|
|
|
"company_id"=>$company_info['id'],
|
|
|
|
|
"company_type"=>$v['company_type'],
|
|
|
|
|
"company_name"=>$company_info['partner'],
|
|
|
|
|
"company_info"=>json_encode($company_info,JSON_UNESCAPED_UNICODE),
|
|
|
|
|
"statement_money"=>$va['statement_money'],
|
|
|
|
|
"pay_amount"=>$va['pay_amount'],
|
|
|
|
|
"platform_amount"=>$va['platform_amount'],
|
|
|
|
|
"fine"=>$va['fine'],
|
|
|
|
|
"reward"=>$va['reward'],
|
|
|
|
|
"statement_begin_time"=>$v['statement_begin_time'],
|
|
|
|
|
"statement_end_time"=>$v['statement_end_time'],
|
|
|
|
|
"statement_info"=>json_encode($va['statement_info'],JSON_UNESCAPED_UNICODE),
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
//整合数据
|
|
|
|
|
$lsres = $LackStatement->where("company_id={$company_info['id']} and is_pool = 0")->select();
|
|
|
|
|
$del_lack_ids = [];
|
|
|
|
|
if(count($lsres) > 0){
|
|
|
|
|
//进行聚合
|
|
|
|
|
foreach($lsres as $key=>$val){
|
|
|
|
|
$del_lack_ids[] = $val['id'];
|
|
|
|
|
$va['statement_money'] += $val['statement_money'];
|
|
|
|
|
$va['pay_amount'] += $val['pay_amount'];
|
|
|
|
|
$va['fine'] += $val['fine'];
|
|
|
|
|
$va['reward'] += $val['reward'];
|
|
|
|
|
$va['platform_amount'] += $val['platform_amount'];
|
|
|
|
|
$va['statement_info'] = array_merge($va['statement_info'],json_decode($val['statement_info'],true));
|
|
|
|
|
$last_names = array_column($va['statement_info'],'game_name');
|
|
|
|
|
array_multisort($last_names,SORT_DESC,SORT_STRING,$va['statement_info']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if($va['statement_money'] < 300){
|
|
|
|
|
//依旧小于300存旧版
|
|
|
|
|
if($lackcompany['pay_amount'] > 0){
|
|
|
|
|
$lask_id = $LackStatement->add($lackcompany);
|
|
|
|
|
$v['create_lack_ids'][] =$lask_id;
|
|
|
|
|
$v['lack_statement_money'] +=$lackcompany['statement_money'];
|
|
|
|
|
$v['lack_platform_amount'] +=$lackcompany['platform_amount'];
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
if($va['pay_amount'] > 0){
|
|
|
|
|
//存成功
|
|
|
|
|
$company =[
|
|
|
|
|
"pool_id"=>0,
|
|
|
|
|
"company_id"=>$company_info['id'],
|
|
|
|
|
"company_type"=>$v['company_type'],
|
|
|
|
|
"company_name"=>$company_info['partner'],
|
|
|
|
|
"company_info"=>json_encode($company_info,JSON_UNESCAPED_UNICODE),
|
|
|
|
|
"fine"=>$va['fine'],
|
|
|
|
|
"reward"=>$va['reward'],
|
|
|
|
|
"statement_money"=>$va['statement_money'],
|
|
|
|
|
"pay_amount"=>$va['pay_amount'],
|
|
|
|
|
"platform_amount"=>$va['platform_amount'],
|
|
|
|
|
"statement_money"=>$va['statement_money'],
|
|
|
|
|
"statement_begin_time"=>$v['statement_begin_time'],
|
|
|
|
|
"statement_end_time"=>$v['statement_end_time'],
|
|
|
|
|
"statement_info"=>json_encode($va['statement_info'],JSON_UNESCAPED_UNICODE),
|
|
|
|
|
"statement_num"=>$va['statement_num']
|
|
|
|
|
];
|
|
|
|
|
$companyid = $StatementInfo->add($company);
|
|
|
|
|
$v['info_ids'][] =$companyid;
|
|
|
|
|
$v['del_lack_ids'] =array_merge($v['del_lack_ids'],$del_lack_ids);
|
|
|
|
|
$v['statement_money'] +=$va['statement_money'];
|
|
|
|
|
$v['pay_amount'] +=$va['pay_amount'];
|
|
|
|
|
$v['platform_amount'] +=$va['platform_amount'];
|
|
|
|
|
$v['fine'] +=$va['fine'];
|
|
|
|
|
$v['reward'] +=$va['reward'];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//设定组合的子操作
|
|
|
|
|
protected function setDf(&$savedata,$v)
|
|
|
|
@ -546,11 +618,11 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
foreach($v['statement_info'] as $ka=>$va){
|
|
|
|
|
if($va['statement_type'] == 2){
|
|
|
|
|
//奖励
|
|
|
|
|
$savedata['reward'] += $va['sum_money'];
|
|
|
|
|
// $savedata['reward'] += $va['sum_money'];
|
|
|
|
|
$reward += $va['sum_money'];
|
|
|
|
|
unset($v['statement_info'][$ka]);
|
|
|
|
|
}else if($va['statement_type'] == 1){
|
|
|
|
|
$savedata['fine'] += $va['sum_money'];
|
|
|
|
|
// $savedata['fine'] += $va['sum_money'];
|
|
|
|
|
$fine += $va['sum_money'];
|
|
|
|
|
unset($v['statement_info'][$ka]);
|
|
|
|
|
}
|
|
|
|
@ -588,9 +660,9 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
];
|
|
|
|
|
$savedata['company_list'][$v['company_id']] = $tdata;
|
|
|
|
|
}
|
|
|
|
|
$savedata['pay_amount'] += $v['pay_amount'];
|
|
|
|
|
$savedata['statement_money'] += $v['statement_money'];
|
|
|
|
|
$savedata['platform_amount'] += $v['platform_amount'];
|
|
|
|
|
// $savedata['pay_amount'] += $v['pay_amount'];
|
|
|
|
|
// $savedata['statement_money'] += $v['statement_money'];
|
|
|
|
|
// $savedata['platform_amount'] += $v['platform_amount'];
|
|
|
|
|
if($savedata['statement_begin_time'] == 0){
|
|
|
|
|
$savedata['statement_begin_time'] = $v['statement_begin_time'];
|
|
|
|
|
}elseif($v['statement_begin_time'] < $savedata['statement_begin_time']){
|
|
|
|
|