新增强制重新更新

master
chenzhi 5 years ago
parent c547d43330
commit b4b4e7bc00

@ -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))

Loading…
Cancel
Save