作者 xiaohu thinkpad

统计学时问题修复

@@ -406,10 +406,16 @@ class YuyueController extends UserBaseController @@ -406,10 +406,16 @@ class YuyueController extends UserBaseController
406 ->select() 406 ->select()
407 ->toArray(); 407 ->toArray();
408 408
  409 +// $yyxs = Db::name('yuyue')
  410 +// ->where(['uid' => $id, 'status' => 3])
  411 +// ->count();
  412 +// $yyxs = $yyxs ? $yyxs : 0;
  413 +
409 $yyxs = Db::name('yuyue') 414 $yyxs = Db::name('yuyue')
410 ->where(['uid' => $id, 'status' => 3]) 415 ->where(['uid' => $id, 'status' => 3])
411 - ->count();  
412 - $yyxs = $yyxs ? $yyxs : 0; 416 + ->field(' SUM(yuyue_end - yuyue_begin) as yyxs ')
  417 + ->select()->toArray();
  418 + $yyxs = $yyxs ? $yyxs[0]['yyxs'] : '0';
413 419
414 $this->assign("data", $data); 420 $this->assign("data", $data);
415 $this->assign("yyxs", $yyxs); 421 $this->assign("yyxs", $yyxs);
@@ -483,10 +489,16 @@ class YuyueController extends UserBaseController @@ -483,10 +489,16 @@ class YuyueController extends UserBaseController
483 ->select() 489 ->select()
484 ->toArray(); 490 ->toArray();
485 491
486 - $yjxs = Db::name('yuyue') 492 +// $yjxs = Db::name('yuyue')
  493 +// ->where(['teach_id' => $id, 'status' => 3])
  494 +// ->count();
  495 +// $yjxs = $yjxs ? $yjxs : 0;
  496 +
  497 + $yyxs = Db::name('yuyue')
487 ->where(['teach_id' => $id, 'status' => 3]) 498 ->where(['teach_id' => $id, 'status' => 3])
488 - ->count();  
489 - $yjxs = $yjxs ? $yjxs : 0; 499 + ->field(' SUM(yuyue_end - yuyue_begin) as yyxs ')
  500 + ->select()->toArray();
  501 + $yjxs = $yyxs ? $yyxs[0]['yyxs'] : '0';
490 502
491 $this->assign("data", $data); 503 $this->assign("data", $data);
492 $this->assign("data1", $data1); 504 $this->assign("data1", $data1);