diff --git a/Application/Admin/Controller/FinancialSummarySetController.class.php b/Application/Admin/Controller/FinancialSummarySetController.class.php index b00f4a819..bb342eb10 100644 --- a/Application/Admin/Controller/FinancialSummarySetController.class.php +++ b/Application/Admin/Controller/FinancialSummarySetController.class.php @@ -17,6 +17,7 @@ class FinancialSummarySetController extends \Think\Controller //数据库 public $FinancialSummaryModel; public function _initialize(){ + //初始化 $this->beginThismonth = mktime(0,0,0,date('m')-1,1,date('Y')); $this->endThismonth = mktime(0,0,0,date('m'),1,date('Y'))-1; @@ -25,7 +26,7 @@ class FinancialSummarySetController extends \Think\Controller $this->month= date('m',$temp); $this->date = $this->year."-".$this->month; $this->nowdata =time(); - + $this->FinancialSummaryModel =M("FinancialSummary",'tab_'); $this->DepositModel =M("Deposit",'tab_'); $this->SpendModel = M("Spend",'tab_'); @@ -37,11 +38,12 @@ class FinancialSummarySetController extends \Think\Controller /** * 更新某月数据 */ - public function setMonthFinancialSummary() + public function setMonthFinancialSummary($count_date) { - $month = I("count_date"); + $month = $count_date; if(empty($month)) die("参数错误"); + $this->adddata = [];//置空否者会脚本进来会重复计算 $this->date = $month; $tarry = explode('-',$month); $this->year= $tarry[0]; @@ -94,7 +96,7 @@ class FinancialSummarySetController extends \Think\Controller $this->addDb(); $t2 = microtime(true); - die("success runtime:".round($t2-$t1,3).'s'); + echo ("success {$this->date}:ok runtime:".round($t2-$t1,3).'s'.PHP_EOL); } /** * 获取类型为1的数据,按收入类型 @@ -430,6 +432,8 @@ class FinancialSummarySetController extends \Think\Controller $res = $this->FinancialSummaryModel->addAll($this->adddata); if(!$res){ echo "DB save error"; + }else{ + } } diff --git a/Application/Admin/Controller/OldCountController.class.php b/Application/Admin/Controller/OldCountController.class.php index 37283c3ce..30e95b003 100644 --- a/Application/Admin/Controller/OldCountController.class.php +++ b/Application/Admin/Controller/OldCountController.class.php @@ -1,4 +1,5 @@ execute($sql); + echo "tab_financial_summary 清空成功".PHP_EOL; + //获取19年9月到上个月的所有月份 + $monthList = $this->getMonthsList(); + $Financial = new FinancialSummarySetController(); + foreach ($monthList as $k => $v) { + $Financial->setMonthFinancialSummary($v); + } + } //超级签订单新增识别微信或者支付宝2019-12-11 public function gameSupersignPaywayInit() { @@ -87,5 +102,25 @@ class OldCountController extends \Think\Controller } die("init ok"); } + //获取公司月结所需要的所有月份截止至上个月 + public function getMonthsList() + { + $start_month = "2019-09"; + + $temp = strtotime(date('Y-m-01 00:00:00',strtotime('-1 month'))); + $end_month = date('Y',$temp)."-".date('m',$temp); + + $time_arr = []; + $begin = new \DateTime($start_month); + $end = new \DateTime($end_month); + $end = $end->modify('+1 month'); + $interval = new \DateInterval('P1M'); + $daterange = new \DatePeriod($begin, $interval ,$end); + foreach($daterange as $date){ + $time_arr[] = $date->format("Y-m"); + } + return $time_arr; + } + }