From 48970d21179ea39020c18e19e3c157923ebc95b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Fri, 28 Nov 2025 18:04:39 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=8C=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/model/Sign.php | 76 ++++++++++++++++++++++++---------- 1 file changed, 53 insertions(+), 23 deletions(-) diff --git a/application/api/model/Sign.php b/application/api/model/Sign.php index fb7fe81..d6c86a0 100644 --- a/application/api/model/Sign.php +++ b/application/api/model/Sign.php @@ -214,20 +214,35 @@ class Sign extends Model db::startTrans(); //修改他的状态 $result = db::name('vs_user_sign_auction')->where(['id' => $max_sign_user['id']])->update(['type' => 1,'signtime' => time()]); - //签约 - $data = [ - 'parent_user_id' => $max_sign_user['user_id'], - 'sign_user_id' => $max_sign_user['sign_user_id'], - 'sign_user_type' => $sign_user_type, - 'sign_times' => $sign_times*24*60*60, - 'end_time' => time() + $sign_times*24*60*60, - 'createtime' => time(), - ]; - $result1 = db::name('vs_user_sign')->insert($data); - if(!$result || !$result1){ + if(!$result){ db::rollback(); return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null]; } + //签约 + if($sign_user_type == 2 && $before_sign_user == $max_sign_user['user_id']){ + $resultt = db::name('vs_user_sign') + ->where(['id' => $is_sign['id']]) + ->update(['end_time' => time() + $sign_times*24*60*60,'sign_user_type' => $sign_user_type,'type'=>3]); + if(!$resultt){ + db::rollback(); + return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null]; + } + }else{ + $data = [ + 'parent_user_id' => $max_sign_user['user_id'], + 'sign_user_id' => $max_sign_user['sign_user_id'], + 'sign_user_type' => $sign_user_type, + 'sign_times' => $sign_times*24*60*60, + 'end_time' => time() + $sign_times*24*60*60, + 'createtime' => time(), + ]; + $result1 = db::name('vs_user_sign')->insert($data); + if(!$result1){ + db::rollback(); + return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null]; + } + } + //查看当前出价用户是否创建家族 $is_create_family = db::name('vs_family')->where(['user_id' => $max_sign_user['user_id'],'type' => 1])->find(); if($is_create_family){ @@ -276,7 +291,7 @@ class Sign extends Model //减去平台抽成 剩余的给相应的人 $sign_user_cion = $max_sign_user['sign_value'] * (100 - $sign_app_ratio) / 100;//金币数 //计算收益 - $shouyizs = coin_earning($sign_user_cion,100 - $sign_app_ratio); + $shouyizs = coin_earning($sign_user_cion,100); if($sign_user_type == 0){ //首次签约 给被签约的人 $result4 = model('api/GiveGift') -> change_user_cion_or_earnings_log($max_sign_user['sign_user_id'],$shouyizs,$room_id,2,52,'被首次签约成功收入'); @@ -303,20 +318,35 @@ class Sign extends Model } } }elseif ($sign_user_type == 2){ - //签过没过期 给上任签约者 - $result4 = model('api/GiveGift') -> change_user_cion_or_earnings_log($before_sign_user,$shouyizs,$room_id,2,54,'解约补偿'); - if(!$result4){ - db::rollback(); - return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null]; - } - //上任签约信息修改 - if($is_sign){ - $result5 = db::name('vs_user_sign')->where(['id' => $is_sign['id']]) - ->update(['end_time' => time(),'type' => 3]); - if(!$result5){ + ////签过没过期 本次签的还是上次的师傅 + if($before_sign_user == $max_sign_user['user_id']){ + //这里需要确定给徒弟给多少 + + + + $sign_user_c = $max_sign_user['sign_value'] * (100 - get_system_config_value('first_sign_app_ratio')) / 100;//金币数 + $money = coin_earning($sign_user_c,100); + $result4 = model('api/GiveGift') -> change_user_cion_or_earnings_log($max_sign_user['sign_user_id'],$money,$room_id,2,54,'解约补偿'); + if(!$result4){ db::rollback(); return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null]; } + }else{ + //签过没过期 给上任签约者 + $result4 = model('api/GiveGift') -> change_user_cion_or_earnings_log($before_sign_user,$shouyizs,$room_id,2,54,'解约补偿'); + if(!$result4){ + db::rollback(); + return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null]; + } + //上任签约信息修改 + if($is_sign){ + $result5 = db::name('vs_user_sign')->where(['id' => $is_sign['id']]) + ->update(['end_time' => time(),'type' => 3]); + if(!$result5){ + db::rollback(); + return ['code' => 0, 'msg' => '网络错误,请重试', 'data' => null]; + } + } } } //修改房间信息