优化结算

master
chenzhi 4 years ago
parent 6aeb73b759
commit 19f7406298

@ -256,7 +256,6 @@ class CompanyStatementSetController extends Controller {
$verify_log=json_encode(["create_user"=>"system","create_time"=>date("Y-m-d H:i:s")]); $verify_log=json_encode(["create_user"=>"system","create_time"=>date("Y-m-d H:i:s")]);
$GameDb = M("Game","tab_"); $GameDb = M("Game","tab_");
$StatementDb = SM("CompanyStatement","tab_"); $StatementDb = SM("CompanyStatement","tab_");
dump($cpList);
$statement_begin_time = date("Y.m.d",$begintime); $statement_begin_time = date("Y.m.d",$begintime);
$statement_end_time = date("Y.m.d",$endtime); $statement_end_time = date("Y.m.d",$endtime);
foreach($cpList as $k=>$v){ foreach($cpList as $k=>$v){
@ -425,7 +424,6 @@ class CompanyStatementSetController extends Controller {
//非重算 //非重算
return $add_data; return $add_data;
} }
dump($add_data);
$StatementDb->add($add_data); $StatementDb->add($add_data);
} }
@ -452,7 +450,8 @@ class CompanyStatementSetController extends Controller {
"payed_time"=>["BETWEEN",[$begintime,$endtime]], "payed_time"=>["BETWEEN",[$begintime,$endtime]],
"game_id"=>["in",$gmstr] "game_id"=>["in",$gmstr]
]; ];
$paydb = SM('spend','tab_'); D("Spend")->addSubsiteWhere($paywhere);
$paydb = M('spend','tab_');
$paylist = $paydb->field("game_id,SUM(pay_amount) pay_amount")->where($paywhere)->group("game_id")->select(); $paylist = $paydb->field("game_id,SUM(pay_amount) pay_amount")->where($paywhere)->group("game_id")->select();
if(empty($paylist)){ if(empty($paylist)){
return []; return [];
@ -536,6 +535,7 @@ class CompanyStatementSetController extends Controller {
"s.payed_time"=>['between', [$begintime,$endtime]], "s.payed_time"=>['between', [$begintime,$endtime]],
"s.promote_id"=>0 "s.promote_id"=>0
]; ];
D("Spend")->addSubsiteWhere($spenMap,"s");
$list = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount,g.relation_game_id,g.relation_game_name game_name')->where($spenMap)->group('relation_game_id') $list = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount,g.relation_game_id,g.relation_game_name game_name')->where($spenMap)->group('relation_game_id')
->join("left join tab_game g on s.game_id = g.id") ->join("left join tab_game g on s.game_id = g.id")
->select(); ->select();
@ -560,7 +560,7 @@ class CompanyStatementSetController extends Controller {
//非重算 //非重算
return $add_data; return $add_data;
} }
M("CompanyStatement","tab_")->add($add_data); SM("CompanyStatement","tab_")->add($add_data);
} }
/** /**
@ -654,7 +654,7 @@ class CompanyStatementSetController extends Controller {
//数据整合 //数据整合
$verify_log=json_encode(["create_user"=>"system","create_time"=>date("Y-m-d H:i:s")]); $verify_log=json_encode(["create_user"=>"system","create_time"=>date("Y-m-d H:i:s")]);
$StatementDb = M("CompanyStatement","tab_"); $StatementDb = SM("CompanyStatement","tab_");
$statement_begin_time = date("Y.m.d",$begintime); $statement_begin_time = date("Y.m.d",$begintime);
$statement_end_time = date("Y.m.d",$endtime); $statement_end_time = date("Y.m.d",$endtime);
@ -955,14 +955,17 @@ class CompanyStatementSetController extends Controller {
"s.payed_time"=>['between', [$begintime,$endtime]], "s.payed_time"=>['between', [$begintime,$endtime]],
"s.is_check"=>1 "s.is_check"=>1
]; ];
D("Spend")->addSubsiteWhere($spenMap);
$cpMap = [ $cpMap = [
"s.pay_status"=>1, "s.pay_status"=>1,
"s.payed_time"=>['between', [$begintime,$endtime]] "s.payed_time"=>['between', [$begintime,$endtime]]
]; ];
D("Spend")->addSubsiteWhere($cpMap);
$cpAllMap =[ $cpAllMap =[
"s.pay_status"=>1, "s.pay_status"=>1,
"s.payed_time"=>['elt',$endtime] "s.payed_time"=>['elt',$endtime]
]; ];
D("Spend")->addSubsiteWhere($cpAllMap);
for ($i=0; $i <count($idarr); $i++) { for ($i=0; $i <count($idarr); $i++) {
$company_id = $idarr[$i]; $company_id = $idarr[$i];
@ -1262,17 +1265,19 @@ class CompanyStatementSetController extends Controller {
"s.payed_time"=>['between', [$begintime,$endtime]], "s.payed_time"=>['between', [$begintime,$endtime]],
"s.is_check"=>1 "s.is_check"=>1
]; ];
D("Spend")->addSubsiteWhere($spenMap,"s");
$cpallgame = []; $cpallgame = [];
$cpgame = []; $cpgame = [];
$cpMap = [ $cpMap = [
"s.pay_status"=>1, "s.pay_status"=>1,
"s.payed_time"=>['between', [$begintime,$endtime]] "s.payed_time"=>['between', [$begintime,$endtime]]
]; ];
D("Spend")->addSubsiteWhere($cpMap,"s");
$cpAllMap = [ $cpAllMap = [
"s.pay_status"=>1, "s.pay_status"=>1,
"s.payed_time"=>['elt',$endtime] "s.payed_time"=>['elt',$endtime]
]; ];
D("Spend")->addSubsiteWhere($cpAllMap,"s");
// unset($cpAllMap["s.payed_time"]); // unset($cpAllMap["s.payed_time"]);
for ($i=0; $i <count($idarr); $i++) { for ($i=0; $i <count($idarr); $i++) {
@ -1967,14 +1972,14 @@ class CompanyStatementSetController extends Controller {
$data['del_lack_ids'] = implode(",",$data['del_lack_ids']); $data['del_lack_ids'] = implode(",",$data['del_lack_ids']);
$info = implode(",",$data['info_ids']); $info = implode(",",$data['info_ids']);
unset($data['info_ids']); unset($data['info_ids']);
$id = M("company_statement_pool","tab_")->add($data); $id = SM("company_statement_pool","tab_")->add($data);
//回写 //回写
if(!empty($info)){ if(!empty($info)){
$save["pool_id"]=$id; $save["pool_id"]=$id;
M("company_statement_info","tab_")->where("id in ({$info})")->save($save); SM("company_statement_info","tab_")->where("id in ({$info})")->save($save);
} }
if(!empty($data['del_lack_ids'])){ if(!empty($data['del_lack_ids'])){
M("company_lack_statement_info","tab_")->where("id in ({$data['del_lack_ids']})")->save(["is_pool"=>1]); SM("company_lack_statement_info","tab_")->where("id in ({$data['del_lack_ids']})")->save(["is_pool"=>1]);
} }
} }
@ -2150,6 +2155,7 @@ class CompanyStatementSetController extends Controller {
$game_id = D("Game")->changeRelationGameidToGameid($relation_game_id); $game_id = D("Game")->changeRelationGameidToGameid($relation_game_id);
// dd($game_id); // dd($game_id);
$spenMap['s.game_id'] =['in',$game_id]; $spenMap['s.game_id'] =['in',$game_id];
D("Spend")->addSubsiteWhere($spenMap);
//获取支付记录 //获取支付记录
$pay_amount = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount')->where($spenMap)->find(); $pay_amount = $Spend->alias('s')->field('sum(s.pay_amount) pay_amount')->where($spenMap)->find();
return $pay_amount['pay_amount'] ?? 0; return $pay_amount['pay_amount'] ?? 0;
@ -2166,6 +2172,7 @@ class CompanyStatementSetController extends Controller {
"s.payed_time"=>['between', [$begintime,$endtime]], "s.payed_time"=>['between', [$begintime,$endtime]],
"s.is_check"=>1 "s.is_check"=>1
]; ];
D("Spend")->addSubsiteWhere($spenMap);
$Pmap = [ $Pmap = [
"chain"=>["LIKE","%/{$promote_id}/%"], "chain"=>["LIKE","%/{$promote_id}/%"],
@ -2306,7 +2313,7 @@ class CompanyStatementSetController extends Controller {
public function updateCompanyStatementData($id,$admin_user='system') public function updateCompanyStatementData($id,$admin_user='system')
{ {
//获取数据 //获取数据
$StatementDb = M("CompanyStatement","tab_"); $StatementDb = SM("CompanyStatement","tab_");
$dbres = $StatementDb->where("id='{$id}'")->find(); $dbres = $StatementDb->where("id='{$id}'")->find();
//获取时间 //获取时间
$stime = $dbres['statement_end_time']-0+1; $stime = $dbres['statement_end_time']-0+1;

Loading…
Cancel
Save