Files
weipan02_server/application/akszadmin/model/Item.php
你的名字 0483b4b364 1
2025-07-14 10:22:40 +08:00

54 lines
1.5 KiB
PHP
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
namespace app\akszadmin\model;
use think\Model;
use think\Db;
class Item extends Model
{
protected $item_table = 'LcItem';
protected $invest_table = 'LcInvest';
/**
* @description获取项目进度
* @date: 2020/5/12 0012
* @param $id
* @return float|int|mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function getProjectPercent($id){
$item = Db::name($this->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;
}
}