新增重算接口

master
chenzhi 5 years ago
parent e80d4eb539
commit 1d92fdb1db

@ -87,23 +87,32 @@ class CompanyStatementSetController extends Controller {
} }
} }
/** /**
* TODO:渠道费未进行计算
* 上游结算 * 上游结算
* @param [string] $type 0:周结 1:月结 2周结补点 * @param [string] $type 0:周结 1:月结 2周结补点
*/ */
public function cpStatement($type,$stime) public function cpStatement($type,$stime,$company_id=false)
{ {
$t = $this->setBeginAndEndTime($type,$stime);; $t = $this->setBeginAndEndTime($type,$stime);;
$begintime = $t[0]; $begintime = $t[0];
$endtime = $t[1]; $endtime = $t[1];
if($company_id === false){
//非重算
$where = [
"_string"=>"first_company_type = '1' OR second_company_type = '1'"
];
}else{
$where = [
"_string"=>"(first_company_type = '1' AND first_company_id = '{$company_id}') OR (second_company_type = '1' AND second_company_id = '{$company_id}')"
];
}
//获取哪些要结算 //获取哪些要结算
if($type == 1){ if($type == 1){
$cpDbRes = M("CompanyRelation","tab_")->where("settlement_type = 2 AND (first_company_type = '1' OR second_company_type = '1')")->select(); $where['settlement_type']=2;
$cpDbRes = M("CompanyRelation","tab_")->where($where)->select();
}else{ }else{
$cpDbRes = M("CompanyRelation","tab_")->where("settlement_type = 1 AND (first_company_type = '1' OR second_company_type = '1')")->select(); $where['settlement_type']=1;
$cpDbRes = M("CompanyRelation","tab_")->where($where)->select();
} }
$cpList=[]; $cpList=[];
$js_id = [];//己方公司 $js_id = [];//己方公司
@ -318,7 +327,13 @@ class CompanyStatementSetController extends Controller {
continue; continue;
} }
//添加 //添加
$StatementDb->add($add_data); if($company_id === false){
//非重算
$StatementDb->add($add_data);
}else{
return $add_data;
}
} }
} }
@ -374,17 +389,30 @@ class CompanyStatementSetController extends Controller {
/** /**
* 下游结算 * 下游结算
*/ */
public function promoteCompanyStatement($type,$stime) public function promoteCompanyStatement($type,$stime,$company_id=false)
{ {
$t = $this->setBeginAndEndTime($type,$stime); $t = $this->setBeginAndEndTime($type,$stime);
$begintime = $t[0]; $begintime = $t[0];
$endtime = $t[1]; $endtime = $t[1];
if($company_id === false){
//非重算
$where = [
"_string"=>"first_company_type = '2' OR second_company_type = '2'"
];
}else{
$where = [
"_string"=>"(first_company_type = '2' AND first_company_id = '{$company_id}') OR (second_company_type = '2' AND second_company_id = '{$company_id}')"
];
}
//获取哪些要结算 //获取哪些要结算
if($type == 1){ if($type == 1){
$pcDbRes = M("CompanyRelation","tab_")->where("settlement_type = 2 AND (first_company_type = '2' OR second_company_type = '2')")->select(); $where['settlement_type']=2;
$pcDbRes = M("CompanyRelation","tab_")->where($where)->select();
}else{ }else{
$pcDbRes = M("CompanyRelation","tab_")->where("settlement_type = 1 AND (first_company_type = '2' OR second_company_type = '2')")->select(); $where['settlement_type']=1;
$pcDbRes = M("CompanyRelation","tab_")->where($where)->select();
} }
$pcList=[]; $pcList=[];
@ -550,7 +578,12 @@ class CompanyStatementSetController extends Controller {
continue; continue;
} }
//添加 //添加
$StatementDb->add($add_data); if($company_id === false){
//非重算
$StatementDb->add($add_data);
}else{
return $add_data;
}
} }
} }
//设定开始结束时间 //设定开始结束时间
@ -610,4 +643,31 @@ class CompanyStatementSetController extends Controller {
$pcList[$k]['list'] = $v; $pcList[$k]['list'] = $v;
} }
} }
/**
* 重算接口
* 不进行结算方式重算
* @param [type] $id 原数据id
* @param string $admin_user 操作用户
* @return void bool
*/
public function updateCompanyStatementData($id,$admin_user='system')
{
//获取数据
$StatementDb = M("CompanyStatement","tab_");
$dbres = $StatementDb->where("id='{$id}'")->find();
//获取时间
$stime = $dbres['statement_end_time']-0+1;
$company_id = $dbres['company_id'];
if($dbres['company_belong'] == 9){
//上游
$savedata = $this->cpStatement($dbres['withdraw_type'],$stime,$company_id);
}else{
$savedata = $this->promoteCompanyStatement($dbres['withdraw_type'],$stime,$company_id);
}
//重写用户
$savedata['verify_log'] = json_encode(["create_user"=>$admin_user,"create_time"=>date("Y-m-d H:i:s")]);
$savedata['id'] = $dbres['id'];
return $StatementDb->save($savedata);
}
} }

Loading…
Cancel
Save