改进 返回用户组价格

This commit is contained in:
iVampireSP.com 2023-02-13 01:06:40 +08:00
parent 1dbf28e048
commit 5fc80dfe60
No known key found for this signature in database
GPG Key ID: 2F7B001CA27A8132
2 changed files with 39 additions and 14 deletions

View File

@ -162,6 +162,18 @@ public function startTransfer(self $to, string $amount, string|null $description
return $this->balance; return $this->balance;
} }
public function getCostPrice(string $price): string
{
$this->load('user_group');
if (!$this->user_group) {
return $price;
}
return $this->user_group->getCostPrice($price);
}
/** /**
* 扣除费用 * 扣除费用
* *
@ -169,6 +181,7 @@ public function startTransfer(self $to, string $amount, string|null $description
* @param string $description * @param string $description
* @param bool $fail * @param bool $fail
* @param array $options * @param array $options
*
* @return string * @return string
*/ */
public function reduce(string|null $amount = '0', string $description = '消费', bool $fail = false, array $options = []): string public function reduce(string|null $amount = '0', string $description = '消费', bool $fail = false, array $options = []): string
@ -214,6 +227,7 @@ public function reduce(string|null $amount = '0', string $description = '消费'
* @param string $payment * @param string $payment
* @param string $description * @param string $description
* @param array $options * @param array $options
*
* @return string * @return string
*/ */
public function charge(string|null $amount = '0', string $payment = 'console', string $description = '充值', array $options = []): string public function charge(string|null $amount = '0', string $payment = 'console', string $description = '充值', array $options = []): string

View File

@ -60,4 +60,15 @@ public function setTempGroup(User $user, self $group, Carbon $expired_at): User
return $user; return $user;
} }
public function getCostPrice(string $price): string
{
if ($this->exempt) {
return '0';
} else if ($this->discount !== 100 && $this->discount !== null) {
$price = bcmul($price, bcdiv($this->discount, '100', 4), 4);
}
return $price;
}
} }