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

49 lines
1.2 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 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;
}
}
}