first commit
This commit is contained in:
43
app/common/command/UnfreezeFunds.php
Normal file
43
app/common/command/UnfreezeFunds.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user