43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace app\common\command;
|
|
use app\common\model\finance\UserFinance;
|
|
|
|
use think\console\{Command,Output,Input};
|
|
use think\facade\{Db,Log};
|
|
|
|
class UnfreezeFunds extends Command
|
|
{
|
|
protected function configure()
|
|
{
|
|
$this->setName('unfreeze_funds')
|
|
->setDescription('用户资金释放');
|
|
}
|
|
|
|
|
|
protected function execute(Input $input, Output $output)
|
|
{
|
|
Db::startTrans();
|
|
try {
|
|
$nowTime = time();
|
|
|
|
$lists = UserFinance::where(['frozen' => 1])
|
|
->where("thaw_time < $nowTime")
|
|
->order(['id' => 'desc'])
|
|
->select()
|
|
->toArray();
|
|
foreach ($lists as &$item) {
|
|
UserFinance::update([
|
|
'id' => $item['id'],
|
|
'frozen' => 0,
|
|
]);
|
|
}
|
|
|
|
Db::commit();
|
|
} catch (\Exception $e) {
|
|
Db::rollback();
|
|
Log::write('失败原因:' . $e->getMessage());
|
|
return false;
|
|
}
|
|
}
|
|
} |