@ -150,7 +150,7 @@ class CompanyStatementController extends ThinkController
$data = M("company_statement","tab_")
->field("id,withdraw_type,company_name,company_belong,statement_begin_time,statement_end_time,statement_money,platform_amount,verify_status,verify_log,confirm_status,confirm_log,op_time,remark")
->where($map)
->order("FIELD(verify_status,0,1,-1,2,3,-2,-3) ,id desc")->page($page,$row)->select();
->order("statement_begin_time desc ,id desc")->page($page,$row)->select();
foreach($data as $k => & $v) {
@ -372,7 +372,16 @@ class CompanyStatementController extends ThinkController
public function delStatement(){
if(!isset($_REQUEST['ids'])) $this->error("参数错误");
$ids = $_REQUEST['ids'];
$dbres = $this->DBModel->where("id in ({$ids}) and verify_status = 0")->delete();
// $dbres = $this->DBModel->where("id in ({$ids}) and verify_status = 0")->delete();
$dbres = $this->DBModel->where("id in ({$ids})")->select();
foreach ($dbres as $key=>$value) {
if($value['withdraw_type'] !=3) {
$this->DBModel->where("id = {$value['id']} and verify_status = 0")->delete();
} else {
$this->DBModel->where("id = {$value['id']} and verify_status != 2")->delete();
}
}
addOperationLog(['op_type'=>2,'key'=>$ids,"op_name"=>"删除结算单",'url'=>U('lists')]);
$this->ajaxReturn(array(
'status' => 1,
@ -578,7 +587,7 @@ class CompanyStatementController extends ThinkController
$cline = $line+1;
if($is_export){
$v['statement_money'] = "=";
$v['statement_money'] = "=ROUND( ";
}
$row = 0;
@ -598,9 +607,9 @@ class CompanyStatementController extends ThinkController
if($is_export){
if($v['withdraw_type'] != 3) {
$val['sum_money'] = "=K{$line}*(L{$line}+M{$line})";
$val['sum_money'] = "=ROUND( K{$line}*(L{$line}+M{$line}),2 )";
} else {
$val['sum_money'] = "=K{$line}*(M{$line})";
$val['sum_money'] = "=ROUND( K{$line}*(M{$line}),2 )";
}
// $val['sum_money'] = "=J{$line}*(K{$line}+L{$line})";
$v['statement_money'] .= "N{$line}+";
@ -625,17 +634,17 @@ class CompanyStatementController extends ThinkController
if($is_export){
if($v['withdraw_type'] != 3) {
$v['statement_money'] .="N{$cline}-O{$cline}";
$v['statement_money'] .="N{$cline}-O{$cline},2) ";
} else {
$v['statement_money'] = substr($v['statement_money'],0,strlen($v['statement_money'])-1);
$v['statement_money'] = substr($v['statement_money'],0,strlen($v['statement_money'])-1).",2)" ;
}
// dump($v['statement_money']);die();
}
}
if($is_export){
$count["platform_amount"] = "=SUM(K2:K".$line.")";
$count["sum_money"] = "=SUM(Q2:Q".$line.")";
$count["platform_amount"] = "=ROUND( SUM(K2:K".$line."),2 )";
$count["sum_money"] = "=ROUND( SUM(Q2:Q".$line."),2 )";
}
$this->assign("data",$infolist);
$this->assign("count",$count);
@ -1385,14 +1394,16 @@ class CompanyStatementController extends ThinkController
$statement_data = [];
M()->startTrans();
foreach ($data as $key => $value) {
$begin_time = 99999999999;
$end_time = 0;
$statement_data = [];
$company_data = M("promote_company","tab_")->where(['id'=>$value['company_id']])->find();
$company_type = M("company_relation","tab_")->where("first_company_id={$value['company_id']} or second_company_id={$value['company_id']}")->find();
$insert['is_payment'] = $company_type['is_payment'];
$insert['statement_begin_time'] = strtotime($value['statement_begin_time']);
$insert['statement_end_time'] = strtotime($value['statement_end_time']);
// $insert['statement_begin_time'] = strtotime($value['statement_begin_time']);
// $insert['statement_end_time'] = strtotime($value['statement_end_time']);
$insert['withdraw_type'] = $withdraw_type;
$insert['company_belong'] = $company_data['company_belong'];
$insert['company_name'] = $company_data['company_name'];
@ -1487,12 +1498,23 @@ class CompanyStatementController extends ThinkController
$amount_time['pay_way'] = ['egt',0];
foreach ($statement_info as $k => $v) {
$statement_begin_time = strtotime(str_replace('.','-',$v['statement_begin_time']));
$statement_end_time = strtotime(str_replace('.','-',$v['statement_end_time']))+86399;
if ($statement_begin_time< $begin_time) {
$begin_time = $statement_begin_time;
}
if ($statement_end_time>$end_time) {
$end_time = $statement_end_time;
}
$amount_time['_string'] = "payed_time between {$statement_begin_time} and {$statement_end_time} and relation_game_id={$v['relation_game_id']}";
$dataAmount = M("spend","tab_")
->field("pay_amount,relation_game_id,relation_game_name,payed_time,game_type_name,substring_index(substring_index(promote.`chain`,'/',2),'/',-1) promote_id,chain,admin_id")
->field("pay_amount,relation_game_id,relation_game_name,payed_time,game_type_name,
CASE WHEN substring_index(substring_index(`chain`,'/',2),'/',-1) !='' THEN substring_index(substring_index(`chain`,'/',2),'/',-1) ELSE promote_id END promote_id,chain,admin_id")
->join("left join tab_promote promote on tab_spend.promote_id=promote.id")
->join("left join tab_game game on tab_spend.game_id=game.id")
->where($amount_time)
@ -1542,9 +1564,25 @@ class CompanyStatementController extends ThinkController
$insert['statement_info'] = json_encode($statement_insert);
} else {
$insert['statement_info'] = json_encode($statement_info);
foreach ($statement_info as $k => $v) {
$statement_begin_time = strtotime(str_replace('.','-',$v['statement_begin_time']));
$statement_end_time = strtotime(str_replace('.','-',$v['statement_end_time']))+86399;
if ($statement_begin_time< $begin_time) {
$begin_time = $statement_begin_time;
}
if ($statement_end_time>$end_time) {
$end_time = $statement_end_time;
}
}
}
$insert['statement_begin_time'] = $begin_time;
$insert['statement_end_time'] = $end_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);