From b797c69cc1c71c410b0fb5fb2c73820fbdb182e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E5=8D=8E=E6=B8=85?= <18691022700@163.com> Date: Sat, 22 Nov 2025 18:23:55 +0800 Subject: [PATCH] =?UTF-8?q?cp=20=E7=AD=89=E7=BA=A7=E5=8D=87=E7=BA=A7=20?= =?UTF-8?q?=E8=A3=85=E6=89=AE=E6=8C=82=E4=BB=B6=E5=92=8C=E7=89=B9=E6=95=88?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/model/UserCp.php | 55 +++++++++++++------------------- 1 file changed, 23 insertions(+), 32 deletions(-) diff --git a/application/api/model/UserCp.php b/application/api/model/UserCp.php index 136ed75..ff72baf 100644 --- a/application/api/model/UserCp.php +++ b/application/api/model/UserCp.php @@ -203,46 +203,19 @@ class UserCp extends Model Db::name('user_cp_gift_log')->insert($datas); //判断是否升级 $level = Db::name('user_cp_level')->where(['change_value' => ['<=', $yuan_exp + $exp],'deletetime' => 0]) - ->order('change_value desc')->field('level,pendant_id')->find(); + ->order('change_value desc')->field('level,pendant_id,rights_icon_id')->find(); if($level['level'] != $zone_level){//登记不一致 (升级) //修改Cp空间等级 $data['level'] = $level['level']; //给用户修改Cp装扮 if($level['pendant_id']){ - //先检查该用户是否已有该装扮 + //先检查是否已有该装扮 $pendant_id = Db::name('vs_decorate_price')->where(['id' => $level['pendant_id']])->value('did'); - foreach ([$from_user_id, $to_user_id] as $user_id) { - $zhuangban = Db::name('vs_user_decorate') - ->where([ - 'user_id' => $user_id, - 'type' => 11, - 'did' => $pendant_id, - 'is_using' => 1 - ]) - ->find(); - - if ($zhuangban) { - // 修改状态为未使用 - Db::name('vs_user_decorate') - ->where(['id' => $zhuangban['id']]) - ->update(['is_using' => 2]); - } + if($pendant_id){ + $this->assignCpDecoration([$from_user_id, $to_user_id], 11, $pendant_id); // 11为CP装扮类型 } - // 给两个用户添加CP装扮 - $decorate_data = [ - 'type' => 11, // 装扮类型11-cp装扮 - 'did' => $pendant_id, - 'is_using' => 1, // 1-使用中,2-未使用 - 'end_time' => 0, // 0-永久 - 'is_perpetual' => 1, // 1-永久,2-限时 - 'createtime' => time(), - ]; - foreach ([$from_user_id, $to_user_id] as $user_id) { - $insert_data = array_merge(['user_id' => $user_id], $decorate_data); - Db::name('vs_user_decorate')->insert($insert_data); - } - }else{//把原有的装扮取消掉 + }else{//当前等级没有装扮挂件把原有的装扮取消掉 $decorate_data = [ 'type' => 11, // 装扮类型11-cp装扮 'is_using' => 2, // 1-使用中,2-未使用 @@ -254,6 +227,24 @@ class UserCp extends Model } } + //给用户修改Cp特效 + if($level['rights_icon_id']){ + //先检查是否已有该特效 + $rights_icon_id = Db::name('vs_decorate_price')->where(['id' => $level['rights_icon_id']])->value('did'); + if($rights_icon_id){ + $this->assignCpDecoration([$from_user_id, $to_user_id], 10, $rights_icon_id); // 10为CP特效类型 + } + }else{//当前等级没有特效挂件把原有的特效取消掉 + $decorate_data = [ + 'type' => 10, // 装扮类型10-cp特效 + 'is_using' => 2, // 1-使用中,2-未使用 + 'updatetime' => time(), + ]; + foreach ([$from_user_id, $to_user_id] as $user_id) { + $insert_data = array_merge(['user_id' => $user_id], $decorate_data); + Db::name('vs_user_decorate')->where(['type' => 10])->update($insert_data); + } + } //添加一个记录 $pendant = db::name('vs_decorate_price')->where('id',$level['pendant_id'])->field('did,day')->find();