diff --git a/app/Controller/Recharge/RechargeController.php b/app/Controller/Recharge/RechargeController.php
index 22c64dc..009ecbd 100644
--- a/app/Controller/Recharge/RechargeController.php
+++ b/app/Controller/Recharge/RechargeController.php
@@ -37,6 +37,7 @@ class RechargeController extends AbstractController
'cardNo' => $user->card_no ?? '',
'mobile' => $user->mobile ?? '',
'bankCardNo' => $bankCard->bank_card_no ?? '',
+ 'amount' => intval($prePayLog->amount / 100),
];
}
return $this->success([
@@ -51,15 +52,19 @@ class RechargeController extends AbstractController
throw new BusinessException('请输入姓名');
}
$amount = $request->input('amount');
- if (empty($amount)) {
- throw new BusinessException('请输入金额');
- }
- if (!is_numeric($amount)) {
- throw new BusinessException('请输入金额');
- }
- if ($amount <= 0) {
- throw new BusinessException('金额需大于0');
+ if ($prePayLog->amount == 0) {
+ $amount = $request->input('amount');
+ if (empty($amount)) {
+ throw new BusinessException('请输入金额');
+ }
+ if (!is_numeric($amount)) {
+ throw new BusinessException('请输入金额');
+ }
+ if ($amount <= 0) {
+ throw new BusinessException('金额需大于0');
+ }
}
+
$cardNo = $request->input('cardNo');
if (empty($cardNo)) {
throw new BusinessException('请输入身份证号');
@@ -86,7 +91,8 @@ class RechargeController extends AbstractController
if ($bankCard) {
$outOrderNo = $prePayLog->out_order_no;
$nextStep = 'confirm-pay';
- $bizData = $this->paymentService->protocolPayPreRequest($this->buildPrepayParams($prePayLog->out_member_id, $outOrderNo, $bankCard->protocol, intval($amount * 100), $app));
+ $amount = $prePayLog->amount > 0 ? $prePayLog->amount : intval($amount * 100);
+ $bizData = $this->paymentService->protocolPayPreRequest($this->buildPrepayParams($prePayLog->out_member_id, $outOrderNo, $bankCard->protocol, $amount, $app));
} else {
$mchOrderNo = StringHelper::generateBankCardOrderNo();
$nextStep = 'confirm-bind';
diff --git a/app/Service/PaymentService.php b/app/Service/PaymentService.php
index 2da558e..c108f48 100644
--- a/app/Service/PaymentService.php
+++ b/app/Service/PaymentService.php
@@ -340,6 +340,16 @@ class PaymentService extends AbstractService
if (!$reqData['outMemberId']) {
throw new BusinessException('用户ID不能为空');
}
+
+ if (isset($reqData['amount']) {
+ if (!is_numeric($reqData['amount'])) {
+ throw new BusinessException('请输入金额');
+ }
+ if ($reqData['amount'] <= 100 || $reqData['amount'] > 300000) {
+ throw new BusinessException('充值金额必须为100~300000');
+ }
+ }
+
if (!$reqData['notifyUrl']) {
throw new BusinessException('通知地址不能为空');
}
@@ -355,6 +365,7 @@ class PaymentService extends AbstractService
$log = new PrePayLog();
$log->app_id = $app->app_id;
$log->out_order_no = $reqData['outOrderNo'];
+ $log->amount = $reqData['amount'] ?: 0;
$log->out_member_id = $reqData['outMemberId'];
$log->notify_url = $reqData['notifyUrl'];
$log->redirect_url = $reqData['redirectUrl'] ?? '';
diff --git a/public/payment.html b/public/payment.html
index 338e0c3..4760894 100644
--- a/public/payment.html
+++ b/public/payment.html
@@ -27,7 +27,7 @@
-
+
@@ -98,7 +98,8 @@
bankCardNo: '',
amount: 1,
remark: ''
- }
+ },
+ amountReadonly: false
}
},
created() {
@@ -204,6 +205,10 @@
this.form.cardNo = result.user.cardNo;
this.form.mobile = result.user.mobile;
this.form.bankCardNo = result.user.bankCardNo;
+ if (this.form.amount > 0) {
+ this.form.amount = result.user.amount;
+ this.amountReadonly = true;
+ }
}
})
.catch((error) => {