瀏覽代碼

搭讪与音视频通话扣费,小数点精度

lizhen_gitee 10 月之前
父節點
當前提交
ed5ab1ba1c
共有 1 個文件被更改,包括 14 次插入13 次删除
  1. 14 13
      application/api/controller/Match.php

+ 14 - 13
application/api/controller/Match.php

@@ -86,7 +86,7 @@ class Match extends Api
         //正常价格
         $price = $to_user_info['match_video_price'];  //扣费金币
         $gift_plat_scale = config('site.gift_plat_scale');  //抽成比例
-        $money = bcdiv(bcmul($price,100 - $gift_plat_scale,2),100,2); //抽成后收益
+        $money = bcdiv(bcmul($price,100 - $gift_plat_scale,1),100,1); //抽成后收益
 
         Db::startTrans();
 
@@ -99,7 +99,7 @@ class Match extends Api
             //扣分钟数
             $price = 0;
             //补贴给对方0.1金币
-            $money = 0.1;
+            $money = '0.1';
 
             if($user_wallet['video_sec'] > 1){
                 $next_minute = 1;
@@ -109,7 +109,7 @@ class Match extends Api
             //需要扣别人的钱,判断钱是否足够
             if($price > 0){
                 $goldtotal = model('wallet')->getWallettotal($this->auth->id);
-                if(bccomp($price,$goldtotal) == 1){
+                if(bccomp($price,$goldtotal,1) == 1){
                     Db::rollback();
                     $this->error('金币不足');
                 }
@@ -130,7 +130,7 @@ class Match extends Api
             $data = [
                 'price' => $user_match_video_log_info['price'] + $price,
                 'updatetime' => time(),
-                'money' => $user_match_video_log_info['money'] + $money,
+                'money' => bcadd($user_match_video_log_info['money'],$money,1),
                 'call_minutes' => $user_match_video_log_info['call_minutes'] + 1
             ];
 
@@ -168,7 +168,7 @@ class Match extends Api
                 $this->error('扣除分钟数失败');
             }
             //补贴给对方0.1金币
-            $money = 0.1;
+            $money = '0.1';
             $rs = model('wallet')->lockChangeAccountRemain($to_user_id,'jewel',$money,21,$this->auth->username.'使用免费次数的补贴','user_match_video_log',$log_id);
             if($rs['status'] === false){
                 Db::rollback();
@@ -261,7 +261,7 @@ class Match extends Api
         //正常价格
         $price = $to_user_info['match_audio_price'];  //扣费金币
         $gift_plat_scale = config('site.gift_plat_scale');  //抽成比例
-        $money = bcdiv(bcmul($price,100 - $gift_plat_scale,2),100,2); //抽成后收益
+        $money = bcdiv(bcmul($price,100 - $gift_plat_scale,1),100,1); //抽成后收益
 
         Db::startTrans();
 
@@ -274,7 +274,7 @@ class Match extends Api
             //扣分钟数
             $price = 0;
             //补贴给对方0.1金币
-            $money = 0.1;
+            $money = '0.1';
 
             if($user_wallet['video_sec'] > 1){
                 $next_minute = 1;
@@ -284,7 +284,7 @@ class Match extends Api
             //需要扣别人的钱,判断钱是否购
             if($price > 0){
                 $goldtotal = model('wallet')->getWallettotal($this->auth->id);
-                if(bccomp($price,$goldtotal) == 1){
+                if(bccomp($price,$goldtotal,1) == 1){
                     Db::rollback();
                     $this->error('金币不足');
                 }
@@ -305,7 +305,7 @@ class Match extends Api
             $data = [
                 'price' => $user_match_audio_log_info['price'] + $price,
                 'updatetime' => time(),
-                'money' => $user_match_audio_log_info['money'] + $money,
+                'money' => bcadd($user_match_audio_log_info['money'],$money,1),
                 'call_minutes' => $user_match_audio_log_info['call_minutes'] + 1
             ];
 
@@ -343,6 +343,7 @@ class Match extends Api
                 $this->error('扣除分钟数失败');
             }
             //补贴给对方0.1金币
+            $money = '0.1';
             $rs = model('wallet')->lockChangeAccountRemain($to_user_id,'jewel',$money,22,$this->auth->username.'使用免费次数的补贴','user_match_audio_log',$log_id);
             if($rs['status'] === false){
                 Db::rollback();
@@ -433,7 +434,7 @@ class Match extends Api
         //正常价格
         $price = $to_user_info['match_typing_price'];  //扣费金币
         $gift_plat_scale = config('site.gift_plat_scale');  //抽成比例
-        $money = bcdiv(bcmul($price,100 - $gift_plat_scale,2),100,2); //抽成后收益
+        $money = bcdiv(bcmul($price,100 - $gift_plat_scale,1),100,1); //抽成后收益
 
         Db::startTrans();
 
@@ -445,7 +446,7 @@ class Match extends Api
             //扣分钟数
             $price = 0;
             //补贴给对方0.1金币
-            $money = 0.1;
+            $money = '0.1';
 
             if($user_wallet['video_sec'] > 1){
                 $next_minute = 1;
@@ -454,7 +455,7 @@ class Match extends Api
             //需要扣别人的钱,判断钱是否购
             if($price > 0){
                 $goldtotal = model('wallet')->getWallettotal($this->auth->id);
-                if(bccomp($price,$goldtotal) == 1){
+                if(bccomp($price,$goldtotal,1) == 1){
                     Db::rollback();
                     $this->error('金币不足');
                 }
@@ -490,7 +491,7 @@ class Match extends Api
                 $this->error('扣除免费次数失败');
             }
             //补贴给对方0.1金币
-            $money = 0.1;
+            $money = '0.1';
             $rs = model('wallet')->lockChangeAccountRemain($to_user_id,'jewel',$money,23,$this->auth->username.'使用免费次数的补贴','user_match_typing_log',$log_id);
             if($rs['status'] === false){
                 Db::rollback();