fix
This commit is contained in:
parent
0be5144254
commit
6d75d872ce
@ -68,6 +68,12 @@ public function usages()
|
|||||||
$month_cache_key = 'user_' . auth()->id() . '_month_' . $month . '_hosts_drops';
|
$month_cache_key = 'user_' . auth()->id() . '_month_' . $month . '_hosts_drops';
|
||||||
$hosts_drops = Cache::get($month_cache_key, []);
|
$hosts_drops = Cache::get($month_cache_key, []);
|
||||||
|
|
||||||
return $this->success($hosts_drops);
|
$month_cache_key = 'user_' . auth()->id() . '_month_' . $month . '_hosts_balances';
|
||||||
|
$hosts_balances = Cache::get($month_cache_key, []);
|
||||||
|
|
||||||
|
return $this->success([
|
||||||
|
'drops' => $hosts_drops,
|
||||||
|
'balances' => $hosts_balances
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -157,6 +157,20 @@ public function costBalance($amount = 1)
|
|||||||
{
|
{
|
||||||
$transaction = new Transaction();
|
$transaction = new Transaction();
|
||||||
|
|
||||||
|
$month = now()->month;
|
||||||
|
|
||||||
|
$month_cache_key = 'user_' . $this->user_id . '_month_' . $month . '_hosts_balances';
|
||||||
|
$hosts_drops = Cache::get($month_cache_key, []);
|
||||||
|
|
||||||
|
// 统计 Host 消耗的 Drops
|
||||||
|
if (isset($hosts_drops[$this->id])) {
|
||||||
|
$hosts_drops[$this->id] += $amount;
|
||||||
|
} else {
|
||||||
|
$hosts_drops[$this->id] = $amount;
|
||||||
|
}
|
||||||
|
|
||||||
|
Cache::put($month_cache_key, $hosts_drops, 604800);
|
||||||
|
|
||||||
$left = $transaction->reduceAmount($this->user_id, $amount);
|
$left = $transaction->reduceAmount($this->user_id, $amount);
|
||||||
|
|
||||||
broadcast(new UserEvent($this->user_id, 'balances.amount.reduced', $this->user));
|
broadcast(new UserEvent($this->user_id, 'balances.amount.reduced', $this->user));
|
||||||
|
Loading…
Reference in New Issue
Block a user