|
|
|
@ -487,6 +487,22 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
if(!isset($_REQUEST['ids'])) $this->error("参数错误");
|
|
|
|
|
$ids = $_REQUEST['ids'];
|
|
|
|
|
$dbres = $this->DBModel->field("*")->where("id in ({$ids})")->select();
|
|
|
|
|
|
|
|
|
|
$check = [];
|
|
|
|
|
$is_complement = 0;
|
|
|
|
|
foreach($dbres as $key => $value) {
|
|
|
|
|
|
|
|
|
|
$check[$value['withdraw_type']] = 1;
|
|
|
|
|
if ($value['withdraw_type'] == 3) {
|
|
|
|
|
$is_complement = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (count($check)>1&&$is_complement) {
|
|
|
|
|
$this->error("特殊补点不能与其他结算单一起汇总");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//分单
|
|
|
|
|
$basedata = [
|
|
|
|
|
"pay_amount"=>0,
|
|
|
|
@ -507,7 +523,7 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
"op_time"=>time(),
|
|
|
|
|
"company_list"=>[]
|
|
|
|
|
];
|
|
|
|
|
$datas = ["up","down"];
|
|
|
|
|
$datas = ["up","down","complement_down","complement_user"];
|
|
|
|
|
//初始化数据
|
|
|
|
|
foreach($datas as $k=>$v){
|
|
|
|
|
if($v =="up"){
|
|
|
|
@ -518,6 +534,14 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
$basedata['company_type']=1;
|
|
|
|
|
$basedata['is_payment']=1;
|
|
|
|
|
}
|
|
|
|
|
if($v =="complement_down") {
|
|
|
|
|
$basedata['company_type']=1;
|
|
|
|
|
$basedata['is_payment']=1;
|
|
|
|
|
}
|
|
|
|
|
if($v =="complement_user") {
|
|
|
|
|
$basedata['company_type']=2;
|
|
|
|
|
$basedata['is_payment']=1;
|
|
|
|
|
}
|
|
|
|
|
$datas[$v]=$basedata;
|
|
|
|
|
unset($datas[$k]);
|
|
|
|
|
}
|
|
|
|
@ -527,10 +551,15 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
if($v['company_belong'] == 9){
|
|
|
|
|
//上游
|
|
|
|
|
$this->setDf($datas['up'],$v);
|
|
|
|
|
}else{
|
|
|
|
|
} elseif($v['withdraw_type'] == 3&&$v['company_type']==1){
|
|
|
|
|
$this->setDf($datas['complement_down'],$v);
|
|
|
|
|
} elseif($v['withdraw_type'] == 3&&$v['company_type']==2){
|
|
|
|
|
$this->setDf($datas['complement_user'],$v);
|
|
|
|
|
} else {
|
|
|
|
|
$this->setDf($datas['down'],$v);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$Pool = M("company_statement_pool","tab_");
|
|
|
|
|
$Statemen = M("company_statement","tab_");
|
|
|
|
|
foreach ($datas as $k => $v) {
|
|
|
|
@ -561,6 +590,11 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
}else{
|
|
|
|
|
$v["withdraw_type"] = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($is_complement) {
|
|
|
|
|
$v["withdraw_type"] = 3;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$pool_id = $Pool->add($v);
|
|
|
|
|
if($pool_id == false){
|
|
|
|
|
$this->ajaxReturn(array('status' => 0,"info"=>"汇总失败"));
|
|
|
|
@ -599,6 +633,9 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
protected function addStatementInfo($va,$k,&$v){
|
|
|
|
|
$StatementInfo = M("company_statement_info","tab_");
|
|
|
|
|
$company_info = $va['company_info'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$LackStatement = M("company_lack_statement_info","tab_");
|
|
|
|
|
$no_pool_money = 300;
|
|
|
|
|
//统一比例字段
|
|
|
|
@ -621,9 +658,10 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
$is_payment = 2;
|
|
|
|
|
$verify_status = 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//创建基础未满基础信息
|
|
|
|
|
if($va['platform_amount'] < $no_pool_money){
|
|
|
|
|
if($va['platform_amount'] < $no_pool_money && $va['withdraw_type']!=3){
|
|
|
|
|
$lackcompany =[
|
|
|
|
|
"company_id"=>$company_info['id'],
|
|
|
|
|
"company_type"=>$v['company_type'],
|
|
|
|
@ -642,8 +680,15 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
//整合数据
|
|
|
|
|
$lsres = $LackStatement->where("company_id={$company_info['id']} and is_pool = 0")->select();
|
|
|
|
|
|
|
|
|
|
if ($k!='complement_down' && $k != 'complement_user') {
|
|
|
|
|
$lsres = $LackStatement->where("company_id={$company_info['id']} and is_pool = 0")->select();
|
|
|
|
|
} else {
|
|
|
|
|
$lsres = $LackStatement->where("company_id={$company_info['id']} and is_pool = 0 and withdraw_type = 3")->select();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$del_lack_ids = [];
|
|
|
|
|
|
|
|
|
|
if(count($lsres) > 0){
|
|
|
|
|
//进行聚合
|
|
|
|
|
foreach($lsres as $key=>$val){
|
|
|
|
@ -658,14 +703,18 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
array_multisort($last_names,SORT_DESC,SORT_STRING,$va['statement_info']);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($va['platform_amount'] < $no_pool_money){
|
|
|
|
|
//依旧小于不结算金额存旧版
|
|
|
|
|
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'];
|
|
|
|
|
if (($k!='complement_down' && $k != 'complement_user')) {
|
|
|
|
|
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){
|
|
|
|
|
//存成功
|
|
|
|
@ -680,13 +729,14 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
"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'],
|
|
|
|
|
"verify_status"=>$verify_status
|
|
|
|
|
"verify_status"=>$verify_status,
|
|
|
|
|
"withdraw_type"=>$va['withdraw_type'],
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
$companyid = $StatementInfo->add($company);
|
|
|
|
|
$v['info_ids'][] =$companyid;
|
|
|
|
|
$v['del_lack_ids'] =array_merge($v['del_lack_ids'],$del_lack_ids);
|
|
|
|
@ -720,24 +770,43 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(isset($savedata['company_list'][$v['company_id']])){
|
|
|
|
|
//存在游戏合并
|
|
|
|
|
$a = &$savedata['company_list'][$v['company_id']];
|
|
|
|
|
$a['fine'] += $fine;
|
|
|
|
|
$a['reward'] += $reward;
|
|
|
|
|
$a['statement_info'] = array_merge($a['statement_info'],$v['statement_info']);
|
|
|
|
|
// dump($a['statement_info']);
|
|
|
|
|
$a['platform_amount'] += $v['platform_amount'];
|
|
|
|
|
$a['pay_amount'] += $v['pay_amount'];
|
|
|
|
|
$a['statement_money'] += $v['statement_money'];
|
|
|
|
|
//存在游戏合并
|
|
|
|
|
$a = &$savedata['company_list'][$v['company_id']];
|
|
|
|
|
$a['fine'] += $fine;
|
|
|
|
|
$a['reward'] += $reward;
|
|
|
|
|
$a['statement_info'] = array_merge($a['statement_info'],$v['statement_info']);
|
|
|
|
|
// dump($a['statement_info']);
|
|
|
|
|
$a['platform_amount'] += $v['platform_amount'];
|
|
|
|
|
$a['pay_amount'] += $v['pay_amount'];
|
|
|
|
|
$a['statement_money'] += $v['statement_money'];
|
|
|
|
|
}else{
|
|
|
|
|
if($v['pay_type'] == 2){
|
|
|
|
|
//乙方收款
|
|
|
|
|
$v['company_info'] =json_decode($v['second_party_info'],ture);
|
|
|
|
|
$v['company_info'] =json_decode($v['second_party_info'],true);
|
|
|
|
|
$v['company_info']['pay_type'] = 2;
|
|
|
|
|
}else{
|
|
|
|
|
$v['company_info'] = json_decode($v['first_party_info'],ture);
|
|
|
|
|
$v['company_info'] = json_decode($v['first_party_info'],true);
|
|
|
|
|
$v['company_info']['pay_type'] = 1;
|
|
|
|
|
}
|
|
|
|
|
if (isset($v['company_info']['company_type'])) {
|
|
|
|
|
if($v['company_info']['company_type'] == 1) {
|
|
|
|
|
$v['company_info']['company_type_str'] = '公司';
|
|
|
|
|
} elseif($v['company_info']['company_type'] == 2){
|
|
|
|
|
$v['company_info']['company_type_str'] = '个人';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (isset($v['company_info']['company_belong'])) {
|
|
|
|
|
if($v['company_info']['company_belong'] == '0') {
|
|
|
|
|
$v['company_info']['company_relation_str'] = '内团';
|
|
|
|
|
} elseif($v['company_info']['company_belong'] == '1') {
|
|
|
|
|
$v['company_info']['company_relation_str'] = '外团';
|
|
|
|
|
}elseif($v['company_info']['company_belong'] == '2') {
|
|
|
|
|
$v['company_info']['company_relation_str'] = '分发联盟';
|
|
|
|
|
}elseif($v['company_info']['company_belong'] == '3') {
|
|
|
|
|
$v['company_info']['company_relation_str'] = '无';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//先分配好订单号,防止重复提交
|
|
|
|
|
$tdata = [
|
|
|
|
|
"company_info"=>$v['company_info'],
|
|
|
|
@ -749,10 +818,12 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
"reward"=>$reward,
|
|
|
|
|
"statement_info"=>$v['statement_info'],
|
|
|
|
|
"statement_num"=>"JS_".date('Ymd').date('His').$v['company_id'].sp_random_string(5),
|
|
|
|
|
"is_payment"=>$v['is_payment']
|
|
|
|
|
"is_payment"=>$v['is_payment'],
|
|
|
|
|
"withdraw_type"=>$v['withdraw_type'],
|
|
|
|
|
];
|
|
|
|
|
$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'];
|
|
|
|
@ -1065,9 +1136,10 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
->where($amount_time)
|
|
|
|
|
->find();
|
|
|
|
|
|
|
|
|
|
$handleData[$key]['pay_amount'][$k] = $pay_amount['pay_amount']?$pay_amount['pay_amount']:0;
|
|
|
|
|
$handleData[$key]['pay_amount'][$k] = $pay_amount['pay_amount']?$pay_amount['pay_amount']:"0.00";
|
|
|
|
|
|
|
|
|
|
$handleData[$key]['withdraw_amount'][$k] = number_format($pay_amount['pay_amount'] * (((int)$value['ratio'][$k])/100),2,'.','');
|
|
|
|
|
// $handleData[$key]['withdraw_amount'][$k] = number_format($pay_amount['pay_amount'] * (((int)$value['ratio'][$k])/100),2,'.','');
|
|
|
|
|
$handleData[$key]['withdraw_amount'][$k] = "0.00";
|
|
|
|
|
|
|
|
|
|
foreach($turnover_ratio as $ke=>$va){
|
|
|
|
|
|
|
|
|
@ -1076,15 +1148,18 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
|
|
|
|
|
if($va['instanceof']=='1'&&$pay_amount['pay_amount']>=$va['turnover']){
|
|
|
|
|
$handleData[$key]['ratio'] = $va["ratio"];
|
|
|
|
|
$handleData[$key]['withdraw_amount'][$k] = number_format($pay_amount['pay_amount'] * ($va["ratio"]/100),2,'.','');
|
|
|
|
|
// $handleData[$key]['withdraw_amount'][$k] = number_format($pay_amount['pay_amount'] * ($va["ratio"]/100),2,'.','');
|
|
|
|
|
$handleData[$key]['withdraw_amount'][$k] = "0.00";
|
|
|
|
|
}elseif($pay_amount['pay_amount']>$va['turnover']){
|
|
|
|
|
$handleData[$key]['ratio'] = $va["ratio"];
|
|
|
|
|
$handleData[$key]['withdraw_amount'][$k] = number_format($pay_amount['pay_amount'] * ($va["ratio"]/100),2,'.','');
|
|
|
|
|
// $handleData[$key]['withdraw_amount'][$k] = number_format($pay_amount['pay_amount'] * ($va["ratio"]/100),2,'.','');
|
|
|
|
|
$handleData[$key]['withdraw_amount'][$k] = "0.00";
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
if ($pay_amount['pay_amount']>=$va['turnover']) {
|
|
|
|
|
$handleData[$key]['ratio'] = $va["ratio"];
|
|
|
|
|
$handleData[$key]['withdraw_amount'][$k] = number_format($pay_amount['pay_amount'] * ($va["ratio"]/100),2,'.','');
|
|
|
|
|
// $handleData[$key]['withdraw_amount'][$k] = number_format($pay_amount['pay_amount'] * ($va["ratio"]/100),2,'.','');
|
|
|
|
|
$handleData[$key]['withdraw_amount'][$k] = "0.00";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -1184,14 +1259,6 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
$insert['statement_money'] = $statement_money;
|
|
|
|
|
$insert['op_time'] = time();
|
|
|
|
|
|
|
|
|
|
if ($company_type['first_company_id'] == $value['company_id']) {
|
|
|
|
|
$insert['first_party_info'] = json_encode($proCompany_info);
|
|
|
|
|
$insert['second_party_info'] = json_encode($secord_info);
|
|
|
|
|
} elseif ($company_type['second_company_id'] == $value['company_id']) {
|
|
|
|
|
$insert['second_party_info'] = json_encode($proCompany_info);
|
|
|
|
|
$insert['first_party_info'] = json_encode($secord_info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach($statement_info as $k => $v) {
|
|
|
|
|
|
|
|
|
|
$statement_info[$k]['statement_type'] = 0;
|
|
|
|
@ -1240,12 +1307,12 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
$game_list['pay_amount'] = $aval['pay_amount'];
|
|
|
|
|
$game_list['relation_game_id'] = $aval['relation_game_id'];
|
|
|
|
|
$game_list['game_name'] = $aval['relation_game_name'];
|
|
|
|
|
$game_list['game_type_name'] = $aval['relation_game_id'];
|
|
|
|
|
$game_list['game_type_name'] = $aval['game_type_name'];
|
|
|
|
|
|
|
|
|
|
$game_list['ratio'] = $v['ratio'];
|
|
|
|
|
$game_list['fax_ratio'] = $company_data['fax_ratio'];
|
|
|
|
|
$game_list['sum_money'] = number_format(($aval['pay_amount']*($v['ratio']+$v['increment_ratio']))/100,2,'.','');
|
|
|
|
|
$game_list['increment_ratio'] = $v['increment_ratio'];
|
|
|
|
|
$game_list['sum_money'] = number_format(($aval['pay_amount']*($v['increment_ratio']))/100,2,'.','');
|
|
|
|
|
$game_list['increment_ratio'] = number_format($v['increment_ratio'],2,'.','');
|
|
|
|
|
$game_list['statement_begin_time'] = $v['statement_begin_time'];
|
|
|
|
|
$game_list['statement_end_time'] = $v['statement_end_time'];
|
|
|
|
|
$game_list['statement_type'] = '0';
|
|
|
|
@ -1253,13 +1320,12 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
$statement_data[$aval['account']."-".$aval['real_name']][] = $game_list;
|
|
|
|
|
// $statement_insert[] = $statement_data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ($statement_data as $k => $v) {
|
|
|
|
|
|
|
|
|
|
$strKey = explode('-',$k);
|
|
|
|
|
|
|
|
|
|
$proCompany_info['nickname'] = $strKey[1];
|
|
|
|
|
$statement['account'] = $strKey[0];
|
|
|
|
|
$statement['real_name'] = $strKey[1];
|
|
|
|
|
$statement['game_list'] = $v;
|
|
|
|
@ -1271,11 +1337,18 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$insert['statement_info'] = json_encode($statement_insert);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
$insert['statement_info'] = json_encode($statement_info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($company_type['first_company_id'] == $value['company_id']) {
|
|
|
|
|
$insert['first_party_info'] = json_encode($proCompany_info);
|
|
|
|
|
$insert['second_party_info'] = json_encode($secord_info);
|
|
|
|
|
} elseif ($company_type['second_company_id'] == $value['company_id']) {
|
|
|
|
|
$insert['second_party_info'] = json_encode($proCompany_info);
|
|
|
|
|
$insert['first_party_info'] = json_encode($secord_info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$is_save = M('company_statement','tab_')->add($insert);
|
|
|
|
|
if (!$is_save) {
|
|
|
|
|
M()->rollback();
|
|
|
|
@ -1329,7 +1402,7 @@ class CompanyStatementController extends ThinkController
|
|
|
|
|
if ($withdraw_type == 3) {
|
|
|
|
|
$optist = array_diff($optist, ["editStatement"]);
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
$resarr = [];
|
|
|
|
|
foreach ($optist as $k => $v) {
|
|
|
|
|
if(IS_ROOT){
|
|
|
|
|