AI Assistant 6 mesi fa
parent
commit
7ecbbf2fe0

+ 1 - 1
app/Module/Fund/Logic/Log.php

@@ -146,7 +146,7 @@ class Log
      * @param FundLogModel $pre_log
      * @return bool
      */
-    public static function create_log(int $user_id, $fund_id, int $amount, string $remark, $later_balance, $before_balance, $operate_id, $operate_type,  $pre_log): bool
+    public static function create_log(int $user_id, $fund_id, float $amount, string $remark, $later_balance, $before_balance, $operate_id, $operate_type,  $pre_log): bool
     {
         $log                 = new FundLogModel();
         $log->user_id        = $user_id;

+ 2 - 2
app/Module/Fund/Logic/User.php

@@ -84,7 +84,7 @@ class User
         $beforeBalance = $data_Model->balance;
 
         # 预先验证余额是否充足(在扣除之前检查)
-        $afterBalance = $data_Model->balance + $amount;
+        $afterBalance =bcadd($data_Model->balance , $amount,10);
         if ($afterBalance < 0) {
             // 可用资金不足,拒绝操作
             Logger::error("fund -handle $user_id - $fund_id insufficient funds: current={$data_Model->balance}, amount=$amount, after=$afterBalance");
@@ -195,7 +195,7 @@ class User
     ) {
         // 读取最新的余额信息
 
-        $later_balance = $data_Model->balance + $amount;
+        $later_balance = bcadd($data_Model->balance, $amount,10);
         $before_balance = $data_Model->balance;
         # 读取最后一条记录进行验证
 

+ 2 - 0
app/Module/Fund/Services/FundService.php

@@ -17,6 +17,7 @@ use App\Module\Fund\Logic\Transfer;
 use App\Module\Fund\Logic\User;
 use Illuminate\Support\Facades\DB;
 use UCore\Db\Helper;
+use UCore\Helper\Logger;
 
 
 class FundService
@@ -77,6 +78,7 @@ class FundService
         if(bccomp(0, $formattedAmount,10) == 0){
             return '数值错误,数值丢失';
         }
+        Logger::debug(" jine  $amount , $formattedAmount");
 
 
         # 实例化操作对象

+ 23 - 0
app/Module/ThirdParty/Tests/Test1.php

@@ -0,0 +1,23 @@
+<?php
+
+
+use App\Module\ThirdParty\Services\WebhookDispatchService;
+use Illuminate\Support\Facades\Request;
+use Tests\TestCase;
+
+/**
+ *
+ * ./vendor/bin/phpunit app/Module/ThirdParty/Tests/TestChongzhi.php
+ */
+class Test1 extends TestCase
+{
+
+    public function testA()
+    {
+        dump(0.2588);
+        dump((float)'0.2588');
+
+
+    }
+
+}

+ 1 - 1
app/Module/Transfer/Validations/TransferOutThirdPartyValidation.php

@@ -30,7 +30,7 @@ class TransferOutThirdPartyValidation extends ValidationCore
             [ 'transfer_app_id,user_id', 'integer', 'min' => 1 ],
             [ 'amount', 'required' ],
             [ 'amount', 'string' ], // 第三方应用金额作为字符串处理,避免精度问题
-            ['amount', 'float', 'min' => 0.1, 'max' => 10000000], // 限制最大金额为1000万,防止异常大金额
+            ['amount', 'float', 'min' =>10, 'max' => 10000000], // 限制最大金额为1000万,防止异常大金额
             // 余额验证:确保用户余额充足
             [ 'amount', new TransferBalanceValidator($this), 'msg' => '用户余额不足' ],
             // 注意:这里不要求password字段,因为第三方应用不需要密码验证

+ 1 - 1
app/Module/Transfer/Validations/TransferOutValidation.php

@@ -25,7 +25,7 @@ class TransferOutValidation extends ValidationCore
             ['transfer_app_id,user_id', 'required'],
             ['transfer_app_id,user_id', 'integer', 'min' => 1],
             ['amount', 'required'],
-            ['amount', 'float', 'min' => 0.01, 'max' => 10000000], // 限制最大金额为1000万,防止异常大金额
+            ['amount', 'float', 'min' => 10, 'max' => 10000000], // 限制最大金额为1000万,防止异常大金额
             ['password', 'required', 'string', 'min' => 6],
             ['google_code', 'string', 'size' => 6],
             ['out_user_id', 'string', 'max' => 50],