item_table)->find($id); if($item['auto']>0){ $xc=$this->diffBetweenTwoDays($item['time'],date('Y-m-d H:i:s')); if($xc>$item['auto']){ $total=100; }else{ $total= round($xc/$item['auto']*100); } }else{ $pid = $item['id']; $percent = $item['percent']; $investMoney = Db::name($this->invest_table)->where('pid', $pid)->sum('money'); $actual = $investMoney / ($item['total'] * 10000) * 100; $total = $actual + $percent; } if (100 < $total) return 100; return $total; } public function diffBetweenTwoDays ($day1, $day2) { $second1 = strtotime($day1); $second2 = strtotime($day2); if ($second1 < $second2) { $tmp = $second2; $second2 = $second1; $second1 = $tmp; } return ($second1 - $second2) / 86400; } }