浏览代码

语音,视频,私聊扣费接口修改

lizhen_gitee 10 月之前
父节点
当前提交
19b6e06583
共有 1 个文件被更改,包括 24 次插入6 次删除
  1. 24 6
      application/api/controller/Match.php

+ 24 - 6
application/api/controller/Match.php

@@ -99,7 +99,7 @@ class Match extends Api
             //扣分钟数
             $price = 0;
             //补贴给对方0.1金币
-            $money = '0.1';
+            $money = '10';
 
             //下一分钟
             if($user_wallet['video_sec'] > 1){
@@ -141,6 +141,11 @@ class Match extends Api
                 'money' => bcadd($user_match_video_log_info['money'],$money,1),
                 'call_minutes' => $user_match_video_log_info['call_minutes'] + 1
             ];
+            //免费的,补贴
+            if($task_status == 0){
+                $data['free_times'] = $user_match_video_log_info['free_times'] + 1;
+                $data['free_money'] = $user_match_video_log_info['free_money'] + $money;
+            }
 
             $log_id = Db::name('user_match_video_log')->where(['id' => $user_match_video_log_info['id']])->setField($data);
             if (!$log_id) {
@@ -157,7 +162,9 @@ class Match extends Api
                 'to_user_id' => $to_user_id,
                 'money' => $money,
                 'request_id' => $request_id,
-                'call_minutes' => 1
+                'call_minutes' => 1,
+                'free_times' => $task_status == 0 ? 1 : 0, //免费的,补贴
+                'free_money' => $task_status == 0 ? $money : 0, //免费的,补贴
             ];
 
             $log_id = Db::name('user_match_video_log')->insertGetId($data);
@@ -176,7 +183,7 @@ class Match extends Api
                 $this->error('扣除分钟数失败');
             }
             //补贴给对方0.1金币
-            $money = '0.1';
+            $money = '10';
             $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();
@@ -282,7 +289,7 @@ class Match extends Api
             //扣分钟数
             $price = 0;
             //补贴给对方0.1金币
-            $money = '0.1';
+            $money = '10';
 
             //下一分钟
             if($user_wallet['audio_sec'] > 1){
@@ -324,6 +331,11 @@ class Match extends Api
                 'money' => bcadd($user_match_audio_log_info['money'],$money,1),
                 'call_minutes' => $user_match_audio_log_info['call_minutes'] + 1
             ];
+            //免费的,补贴
+            if($task_status == 0){
+                $data['free_times'] = $user_match_audio_log_info['free_times'] + 1;
+                $data['free_money'] = $user_match_audio_log_info['free_money'] + $money;
+            }
 
             $log_id = Db::name('user_match_audio_log')->where(['id' => $user_match_audio_log_info['id']])->setField($data);
             if (!$log_id) {
@@ -340,7 +352,9 @@ class Match extends Api
                 'to_user_id' => $to_user_id,
                 'money' => $money,
                 'request_id' => $request_id,
-                'call_minutes' => 1
+                'call_minutes' => 1,
+                'free_times' => $task_status == 0 ? 1 : 0, //免费的,补贴
+                'free_money' => $task_status == 0 ? $money : 0, //免费的,补贴
             ];
 
             $log_id = Db::name('user_match_audio_log')->insertGetId($data);
@@ -359,7 +373,7 @@ class Match extends Api
                 $this->error('扣除分钟数失败');
             }
             //补贴给对方0.1金币
-            $money = '0.1';
+            $money = '10';
             $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();
@@ -455,6 +469,7 @@ class Match extends Api
         Db::startTrans();
 
         //检查剩余分钟数
+        $task_status = 0;//任务状态
         $next_minute = 0;//默认不足下一分钟
 
         $user_wallet = Db::name('user_wallet')->where('user_id',$this->auth->id)->lock(true)->find();
@@ -475,6 +490,7 @@ class Match extends Api
                 }
             }
         }else{
+            $task_status = 1;
             //需要扣别人的钱,判断钱是否购
             $goldtotal = model('wallet')->getWallettotal($this->auth->id);
             if($price > 0){
@@ -498,6 +514,8 @@ class Match extends Api
             'createtime' => time(),
             'to_user_id' => $to_user_id,
             'money' => $money,
+            'free_times' => $task_status == 0 ? 1 : 0, //免费的,补贴
+            'free_money' => $task_status == 0 ? $money : 0, //免费的,补贴
         ];
 
         $log_id = Db::name('user_match_typing_log')->insertGetId($data);