优化脚本

master
chenzhi 4 years ago
parent 70e00eb378
commit 7a248e44d4

@ -58,6 +58,30 @@ class StatementWarningSetController extends Controller {
$this->isInit = true;
}
public function run()
{
$count_date = date('Y',time()).'-'.(date('m',time()));
$this->configInit($count_date);
$hasdb = $this->statementWarningModel->where([
'count_year'=>$this->year,
'count_month'=>$this->month,
"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}";
$time = time()+2*3600;
D("CmdTasks")->addScheduleTask("StatementWarningSet",$params,$time);
}
$this->setStatementWarning();
}
/**
* 更新某月毛利数据
*/
@ -75,9 +99,9 @@ class StatementWarningSetController extends Controller {
$this->getInsideCompanyid();
$this->setCompanyIsWm();
// $this->getAllWmAmount();
// $this->cpStatement();
// $this->pcStatement();
$this->getAllWmAmount();
$this->cpStatement();
$this->pcStatement();
$this->puStatement();
@ -107,39 +131,46 @@ class StatementWarningSetController extends Controller {
$month = date("m",$this->beginThismonth-1);
//cp
$preCpMonth = $this->statementWarningInfoModel->where([
'year'=>$year,
'month'=>$month,
'count_year'=>$year,
'count_month'=>$month,
'company_belong'=>9
])->getField('company_id,is_wm',true);
$selfCpMonth = $this->statementWarningInfoModel->where([
'year'=>$this->year,
'month'=>$this->month,
'count_year'=>$this->year,
'count_month'=>$this->month,
'company_belong'=>9
])->getField('company_id,is_wm',true);
if(!$preCpMonth) $preCpMonth = [];
if(!$selfCpMonth) $selfCpMonth = [];
$this->cpCompanyIsWm = array_merge($preCpMonth,$selfCpMonth);
$this->cpCompanyIsWm = $preCpMonth;
foreach ($selfCpMonth as $key => $value) {
$this->cpCompanyIsWm[$key] = $value;
}
//下游
$preMonth = $this->statementWarningInfoModel->where([
'year'=>$year,
'month'=>$month,
'count_year'=>$year,
'count_month'=>$month,
'company_belong'=>['NEQ',9]
])->getField('company_id,is_wm',true);
$selfMonth = $this->statementWarningInfoModel->where([
'year'=>$this->year,
'month'=>$this->month,
'count_year'=>$this->year,
'count_month'=>$this->month,
'company_belong'=>['NEQ',9]
])->getField('company_id,is_wm',true);
if(!$preMonth) $preMonth = [];
if(!$selfMonth) $selfMonth = [];
$this->promoteCompanyIsWm = array_merge($preMonth,$selfMonth);
$this->promoteCompanyIsWm = $preMonth;
foreach ($selfMonth as $key => $value) {
$this->promoteCompanyIsWm[$key] = $value;
}
}
/**

Loading…
Cancel
Save