优化预警平台

master
chenzhi 3 years ago
parent 80a020e352
commit d8c3fd969c

@ -28,7 +28,9 @@ class StatementWarningSetController extends Controller {
'pc_statement'=>'下游内团',
'pu_statement'=>'下游外团',
'margin_ratio'=>'毛利率',
'profit_ratio'=>'利润率'
'profit_ratio'=>'利润率',
'cost'=>'费用',
'other_income'=>'其他收入'
];
private $statementWarningModel;
@ -66,19 +68,17 @@ class StatementWarningSetController extends Controller {
$count_date = date('Y',time()).'-'.(date('m',time()));
$this->configInit($count_date);
$preMonth = $this->getPreMonth();
$hasdb = $this->statementWarningModel->where([
'count_year'=>$this->year,
'count_month'=>$this->month,
'count_year'=>$preMonth[0],
'count_month'=>$preMonth[1],
"name"=>'wm_platm',
"type"=>1
])->find();
if(!$hasdb){
//第一次生成,同时上一次结扎
$year = date("Y",$this->beginThismonth-1);
$month = date("m",$this->beginThismonth-1);
$preMonth = $year."-".$month;
$params = "php ".SUBSITE_INDEX." StatementWarningSet/setFreeMonth/count_date/{$preMonth}";
$preCountMonth = $preMonth[0]."-".$preMonth[1];
$params = "php ".SUBSITE_INDEX." StatementWarningSet/setFreeMonth/count_date/{$preCountMonth}";
$time = time()+2*3600;
D("CmdTasks")->addScheduleTask("StatementWarningSet",$params,$time);
}
@ -130,13 +130,11 @@ class StatementWarningSetController extends Controller {
*/
private function setCompanyIsWm()
{
$year = date("Y",$this->beginThismonth-1);
$month = date("m",$this->beginThismonth-1);
$preMonth = $this->getPreMonth();
//cp
$preCpMonth = $this->statementWarningInfoModel->where([
'count_year'=>$year,
'count_month'=>$month,
'count_year'=>$preMonth[0],
'count_month'=>$preMonth[1],
'company_belong'=>9
])->getField('company_id,is_wm',true);
@ -157,8 +155,8 @@ class StatementWarningSetController extends Controller {
//下游
$preMonth = $this->statementWarningInfoModel->where([
'count_year'=>$year,
'count_month'=>$month,
'count_year'=>$preMonth[0],
'count_month'=>$preMonth[1],
'company_belong'=>['NEQ',9]
])->getField('company_id,is_wm',true);
@ -188,44 +186,15 @@ class StatementWarningSetController extends Controller {
'payed_time'=>['between',[$this->beginThismonth,$this->endThismonth]],
];
$amout = $this->spendModel->where($where)->getField("sum(pay_amount) amount");
$sWWhere = [
"count_month"=>$this->month,
"count_year"=>$this->year,
"name"=>'wm_platm',
"type"=>1
];
$hasDb = $this->statementWarningModel->where($sWWhere)->find();
$saveData = array_merge(['money'=>$amout,'create_time'=>time()],$sWWhere);
if($hasDb){
$saveData['id'] = $hasDb['id'];
$this->statementWarningModel->save($saveData);
}else{
$this->statementWarningModel->add($saveData);
}
$this->addStatementWarning(1,'wm_platm',$amout);
}
/**
* 添加默认信息
*/
private function setDefaultStatementWarning()
{
$Where = [
"count_month"=>$this->month,
"count_year"=>$this->year,
"name"=>'费用',
"type"=>3
];
$hasDb = $this->statementWarningModel->where($Where)->find();
$saveData = array_merge(['money'=>700000,'create_time'=>time()],$Where);
if(!$hasDb){
$this->statementWarningModel->add($saveData);
}
$Where['name'] = '其他收入';
$hasDb = $this->statementWarningModel->where($Where)->find();
$saveData = array_merge(['money'=>26000,'create_time'=>time()],$Where);
if(!$hasDb){
$this->statementWarningModel->add($saveData);
}
$this->addStatementWarning(3,'cost',700000,false);
$this->addStatementWarning(3,'other_income',26000,false);
}
/**
* 获取上游的结算金额
@ -416,17 +385,19 @@ class StatementWarningSetController extends Controller {
}
private function addStatementWarning($type,$name,$money)
private function addStatementWarning($type,$name,$money,$issave = true)
{
//汇总表差一个月
$preMonth = $this->getPreMonth();
$savedata = [
'type'=>$type,
'name'=>$name,
'count_month'=>$this->month,
'count_year'=>$this->year
'count_year'=>$preMonth[0],
'count_month'=>$preMonth[1]
];
$hasDb = $this->statementWarningModel->where($savedata)->find();
$savedata = array_merge(['money'=>$money,'create_time'=>time()],$savedata);
if($hasDb){
if($hasDb && $issave){
$savedata['id'] = $hasDb['id'];
$this->statementWarningModel->save($savedata);
}else{
@ -485,6 +456,12 @@ class StatementWarningSetController extends Controller {
return 1;
}
private function getPreMonth()
{
return explode('-',date("Y-m",$this->beginThismonth-1));
}

Loading…
Cancel
Save