改进
This commit is contained in:
parent
dae507198d
commit
41d6ee55de
@ -112,13 +112,17 @@ public function update(Request $request, Host $host)
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param Host $host
|
||||
* @param $host
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Host $host)
|
||||
public function destroy($host)
|
||||
{
|
||||
//
|
||||
$host->delete();
|
||||
|
||||
$host = Host::where('id', $host)->first($host);
|
||||
|
||||
if ($host) {
|
||||
$host->delete();
|
||||
}
|
||||
|
||||
return $this->deleted($host);
|
||||
}
|
||||
|
@ -96,18 +96,18 @@ public function cost($price = null, $auto = true)
|
||||
$drops = $transaction->getDrops($this->user_id);
|
||||
|
||||
if ($price !== null) {
|
||||
$this->price = $price;
|
||||
$real_price = $price;
|
||||
}
|
||||
|
||||
$this->price = round($this->price, 8);
|
||||
$real_price = round($real_price, 8);
|
||||
|
||||
$amount = $price / config('drops.rate') + 1;
|
||||
|
||||
// if drops <= price
|
||||
if ($drops < $this->price) {
|
||||
if ($drops < $real_price) {
|
||||
try {
|
||||
// 算出需要补充多少 Drops
|
||||
$need = $this->price - $drops;
|
||||
$need = $real_price - $drops;
|
||||
|
||||
// 算出需要补充多少余额
|
||||
$need_amount = $need / config('drops.rate') + 1;
|
||||
@ -133,14 +133,14 @@ public function cost($price = null, $auto = true)
|
||||
|
||||
// 统计 Host 消耗的 Drops
|
||||
if (isset($hosts_drops[$this->id])) {
|
||||
$hosts_drops[$this->id] += $this->price;
|
||||
$hosts_drops[$this->id] += $real_price;
|
||||
} else {
|
||||
$hosts_drops[$this->id] = $this->price;
|
||||
$hosts_drops[$this->id] = $real_price;
|
||||
}
|
||||
|
||||
Cache::put($month_cache_key, $hosts_drops, 604800);
|
||||
|
||||
$transaction->reduceDrops($this->user_id, $this->id, $this->module_id, $auto, $this->price);
|
||||
$transaction->reduceDrops($this->user_id, $this->id, $this->module_id, $auto, $real_price);
|
||||
|
||||
broadcast(new UserEvent($this->user_id, 'balances.drops.reduced', $this->user));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user