改进 Drops 补充逻辑

This commit is contained in:
iVampireSP.com 2022-09-08 01:55:07 +08:00
parent a0b75d42cf
commit 074a68ffec
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132

View File

@ -101,7 +101,13 @@ public function cost($price = null)
// if drops <= price
if ($drops < $this->price) {
try {
$this->user->toDrops($amount);
// 算出需要补充多少 Drops
$need = $this->price - $drops;
// 算出需要补充多少余额
$need_amount = $need / Cache::get('drops_rate', 100) + 1;
$this->user->toDrops($amount + $need_amount);
} catch (BalanceNotEnoughException) {
$this->update([
'status' => 'suspended',