|
|
@@ -79,8 +79,13 @@ class Wallet extends Controller
|
|
|
$memberId = request()->input('member_id');
|
|
|
$amount = request()->input('amount');
|
|
|
$remark = request()->input('remark');
|
|
|
-
|
|
|
-
|
|
|
+ $key = 'api_request_' . md5($memberId . json_encode([
|
|
|
+ 'amount' => $amount,
|
|
|
+ 'remark' => $remark,
|
|
|
+ 'action' => "wallet/topUp"
|
|
|
+ ]));
|
|
|
+ if (Cache::has($key)) throw new Exception("请求太频繁,请稍后再试。", HttpStatus::CUSTOM_ERROR);
|
|
|
+ Cache::put($key, true, 3);
|
|
|
$wallet = WalletModel::where('member_id', $memberId)->first();
|
|
|
if (!$wallet) throw new Exception('用户不存在', HttpStatus::CUSTOM_ERROR);
|
|
|
$availableBalance = bcadd($wallet->available_balance, $amount, 10);
|
|
|
@@ -89,18 +94,6 @@ class Wallet extends Controller
|
|
|
BalanceLogService::addLog($memberId, $amount, $wallet->available_balance, $availableBalance, $changeType, null, $remark);
|
|
|
$wallet->available_balance = $availableBalance;
|
|
|
$wallet->save();
|
|
|
- $key = 'api_request_' . md5($memberId . json_encode([
|
|
|
- 'amount' => $amount,
|
|
|
- 'remark' => $remark,
|
|
|
- 'change_type' => $changeType,
|
|
|
- 'action' => "wallet/topUp"
|
|
|
- ]));
|
|
|
- if (Cache::has($key)) {
|
|
|
- throw new Exception("请求太频繁,请稍后再试。", HttpStatus::CUSTOM_ERROR);
|
|
|
- }
|
|
|
- Cache::put($key, true, 3);
|
|
|
-
|
|
|
-
|
|
|
DB::commit();
|
|
|
} catch (ValidationException $e) {
|
|
|
DB::rollBack();
|