Browse Source

保留二位小数

shish 10 months ago
parent
commit
e599804701
1 changed files with 6 additions and 2 deletions
  1. 6 2
      app-hd/controllers/CustomRechargeController.php

+ 6 - 2
app-hd/controllers/CustomRechargeController.php

@@ -25,8 +25,12 @@ class CustomRechargeController extends BaseController
     {
         ini_set('date.timezone', 'Asia/Shanghai');
         $post = Yii::$app->request->post();
-        $payWay = isset($post['payWay']) ? $post['payWay'] : 0;
+        $payWay = $post['payWay'] ?? 0;
         $actPrice = $post['actPrice'] ?? 0;
+        if ($actPrice <= 0) {
+            util::fail('请输入数值');
+        }
+        $actPrice = floor($actPrice * 100) / 100;//只保留2位小数
         $totalFee = $actPrice;
         $ghsId = $post['ghsId'] ?? 0;
         $salt = $post['salt'] ?? '';
@@ -171,7 +175,7 @@ class CustomRechargeController extends BaseController
             $response = $laResource->driveWxPay($wxParams);
             if (isset($response['code']) == false || $response['code'] != 'BBS00000') {
                 $errMsg = $response['msg'] ?? '';
-                noticeUtil::push('编号19881507:' . $errMsg .' | '. $ghsName .' | '. $customName.' | '. $actPrice, '15280215347');
+                noticeUtil::push('编号19881507:' . $errMsg . ' | ' . $ghsName . ' | ' . $customName . ' | ' . $actPrice, '15280215347');
                 util::fail('支付失败');
             }
             $newParams = isset($response['resp_data']['acc_resp_fields']) ? $response['resp_data']['acc_resp_fields'] : [];