From b4b4e7bc00a65456d7134d2b17998165349f8ceb Mon Sep 17 00:00:00 2001 From: chenzhi <“chenzhi063@qq.com> Date: Fri, 1 Nov 2019 10:16:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BC=BA=E5=88=B6=E9=87=8D?= =?UTF-8?q?=E6=96=B0=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SpendCountSetController.class.php | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Application/Admin/Controller/SpendCountSetController.class.php b/Application/Admin/Controller/SpendCountSetController.class.php index 33aedc6ec..881c9f03c 100644 --- a/Application/Admin/Controller/SpendCountSetController.class.php +++ b/Application/Admin/Controller/SpendCountSetController.class.php @@ -17,11 +17,13 @@ class SpendCountSetController extends \Think\Controller 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('t'),date('Y'))-1; + $this->endThismonth = mktime(0,0,0,date('m'),1,date('Y'))-1; $this->date = date('Y')."-".((date('m')-1) > 9 ? (date('m')-1) : "0".(date('m')-1)); $this->nowdata =time(); $this->model =M("spend_count",'tab_'); $this->usermodel =M("spend_user_count",'tab_'); + $this->monthmodel =M("spend_month_count",'tab_'); + } /** * TODO:仅供测试,测试结束后删除 @@ -36,9 +38,28 @@ class SpendCountSetController extends \Think\Controller $tarry = explode('-',$month); $this->beginThismonth=mktime(0,0,0,$tarry[1],1,$tarry[0]); $this->endThismonth=mktime(0,0,0,$tarry[1]-0+1,1,$tarry[0])-1; - + $this->reCount(); $this->setSpendCount(); } + /** + * 强制重新聚合 + */ + public function reCount() + { + $recount = I("recount"); + if(empty($recount) || $recount != 1){return ;} + # code... + //清理之前的聚合 + $temp =array( + "count_date"=>$this->date + ); + + $this->model->where($temp)->delete(); + $this->usermodel->where($temp)->delete(); + $this->monthmodel->where($temp)->delete(); + echo "重置成功执行重新生成:"; + } + /** * 每个月的统计接口 @@ -608,6 +629,7 @@ class SpendCountSetController extends \Think\Controller ); $add = M("provide","tab_")->field("sum(amount) amount")->where($map)->find()['amount']; $add || $add=0; + $jq = M("deduct_bind_record","tab_")->field("sum(quantity) quantity")->where(array( "create_time"=> array('BETWEEN',array($this->beginThismonth, $this->endThismonth))