This commit is contained in:
你的名字
2025-07-14 10:22:40 +08:00
commit 0483b4b364
1388 changed files with 219353 additions and 0 deletions

View File

@ -0,0 +1,53 @@
<?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;
}
}

View File

@ -0,0 +1,48 @@
<?php
namespace app\akszadmin\model;
use think\Model;
use think\Db;
class Users extends Model
{
protected $user_table = 'LcUser';
protected $finance_table = 'LcFinance';
/**
* @description添加流水
* @date: 2020/5/12 0012
* @param $uid
* @param $money
* @param $type
* @param $reason
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
*/
public function addFinance($uid,$money,$type,$reason){
$user = Db::name($this->user_table)->find($uid);
if($user['money']<0) return false;
if(!$user) return false;
$data = array(
'uid' => $uid,
'money' => $money,
'type' => $type,
'reason' => $reason,
'before' => $user['money'],
'time' => date('Y-m-d H:i:s')
);
Db::startTrans();
$re = Db::name($this->finance_table)->insert($data);
if($re){
Db::commit();
return true;
}else{
Db::rollback();
return false;
}
}
}