瀏覽代碼

互动收费和收益改动

lizhen_gitee 3 年之前
父節點
當前提交
f9345bf431
共有 2 個文件被更改,包括 26 次插入14 次删除
  1. 19 7
      application/api/controller/Usercenter.php
  2. 7 7
      application/extra/wallet.php

+ 19 - 7
application/api/controller/Usercenter.php

@@ -225,6 +225,10 @@ class Usercenter extends Api
     //女性不收费,互关不收费,设置不收费的也不收费
     public function video_onemin(){
         $to_user_id = input_post('to_user_id');
+        $to_user_info = Db::name('user')->field('id,gender,free_video,free_audio,free_typing')->where('id',$to_user_id)->find();
+        if(!$to_user_info){
+            $this->error('不存在的用户');
+        }
 
         //先检查今天免费的一分钟
         $start = strtotime(date('Y-m-d'));
@@ -261,7 +265,7 @@ class Usercenter extends Api
         }
 
         //扣费
-        if($price > 0){
+        if($price > 0 && $this->auth->gender == 1){
             $rs = model('wallet')->lockChangeAccountRemain($this->auth->id,'gold',-$price,11,'','user_match_video_log',$log_id);
             if($rs['status'] === false){
                 Db::rollback();
@@ -269,7 +273,7 @@ class Usercenter extends Api
             }
         }
         //另一方加钱
-        if($money > 0){
+        if($money > 0 && $to_user_info['gender'] == 0 && $to_user_info['free_video'] == 0){
             $rs = model('wallet')->lockChangeAccountRemain($to_user_id,'money',$money,21,'','user_match_video_log',$log_id);
             if($rs['status'] === false){
                 Db::rollback();
@@ -283,6 +287,10 @@ class Usercenter extends Api
     //语音通话每分钟调用一次
     public function audio_onemin(){
         $to_user_id = input_post('to_user_id');
+        $to_user_info = Db::name('user')->field('id,gender,free_video,free_audio,free_typing')->where('id',$to_user_id)->find();
+        if(!$to_user_info){
+            $this->error('不存在的用户');
+        }
 
         //先检查今天免费的一分钟
         $start = strtotime(date('Y-m-d'));
@@ -319,7 +327,7 @@ class Usercenter extends Api
         }
 
         //扣费
-        if($price > 0){
+        if($price > 0 && $this->auth->gender == 1){
             $rs = model('wallet')->lockChangeAccountRemain($this->auth->id,'gold',-$price,12,'','user_match_audio_log',$log_id);
             if($rs['status'] === false){
                 Db::rollback();
@@ -327,7 +335,7 @@ class Usercenter extends Api
             }
         }
         //另一方加钱
-        if($money > 0){
+        if($money > 0 && $to_user_info['gender'] == 0 && $to_user_info['free_audio'] == 0){
             $rs = model('wallet')->lockChangeAccountRemain($to_user_id,'money',$money,22,'','user_match_audio_log',$log_id);
             if($rs['status'] === false){
                 Db::rollback();
@@ -341,6 +349,10 @@ class Usercenter extends Api
     //打字聊天每句话调用一次
     public function typing_once(){
         $to_user_id = input_post('to_user_id');
+        $to_user_info = Db::name('user')->field('id,gender,free_video,free_audio,free_typing')->where('id',$to_user_id)->find();
+        if(!$to_user_info){
+            $this->error('不存在的用户');
+        }
 
 
         //设置价格
@@ -366,15 +378,15 @@ class Usercenter extends Api
         }
 
         //扣费
-        if($price > 0){
+        if($price > 0 && $this->auth->gender == 1){
             $rs = model('wallet')->lockChangeAccountRemain($this->auth->id,'gold',-$price,13,'','user_match_typing_log',$log_id);
             if($rs['status'] === false){
                 Db::rollback();
                 $this->error($rs['msg']);
             }
         }
-        //另一方加钱
-        if($money > 0){
+        //另一方加钱,设置不免费
+        if($money > 0 && $to_user_info['gender'] == 0 && $to_user_info['free_typing'] == 0){
             $rs = model('wallet')->lockChangeAccountRemain($to_user_id,'money',$money,23,'','user_match_typing_log',$log_id);
             if($rs['status'] === false){
                 Db::rollback();

+ 7 - 7
application/extra/wallet.php

@@ -13,25 +13,25 @@ return [
         13 => '文字聊天消费',
         14 => '金币首充赠送',
 
-        21 => '视频通话收益',
-        22 => '语音通话收益',
-        23 => '文字聊天收益',
+        21 => '视频通话收益',//money
+        22 => '语音通话收益',//money
+        23 => '文字聊天收益',//money
 
         31 => '购买装扮消费',
         41 => '签到赠送金币',
 
         51 => '语聊间赠送礼物',
-        52 => '语聊间获得礼物',
+        52 => '语聊间获得礼物',//money
 
         53 => '聊天赠送礼物',
-        54 => '聊天获得礼物',
+        54 => '聊天获得礼物',//money
 
         55 => '直播赠送礼物',
-        56 => '直播获得礼物',
+        56 => '直播获得礼物',//money
 
         61 => '完成个人任务',
         62 => '解锁喜欢我的人',
-        63 => '邀请注册奖励',
+        63 => '邀请注册奖励',//money
     ],
     'moneyname' => [
         'money'    => '余额',