CP 相关
This commit is contained in:
@@ -551,6 +551,8 @@ class GiveGift extends Model
|
||||
//直播间送礼物 每日任务
|
||||
model('DailyTasks')->tasks_complete($uid,3);
|
||||
}
|
||||
//cp检测
|
||||
model('api/UserCp')->checkGift($uid, $give_gift, $to_id, $from_id);
|
||||
}
|
||||
|
||||
//增加房间火热值hot_value
|
||||
@@ -859,6 +861,8 @@ class GiveGift extends Model
|
||||
//直播间送礼物 每日任务
|
||||
model('DailyTasks')->tasks_complete($uid,3);
|
||||
}
|
||||
//cp检测
|
||||
model('api/UserCp')->checkGift($uid, $give_gift, $to_id, $from_id);
|
||||
}
|
||||
|
||||
//增加房间火热值hot_value
|
||||
|
||||
@@ -69,6 +69,11 @@ class SingerSong extends Model
|
||||
*/
|
||||
public function singerAddSong($user_id, $song_name, $gift_id, $gift_num)
|
||||
{
|
||||
//查询是否是认证歌手
|
||||
$res = db::name('vs_singer')->where(['user_id' => $user_id])->find();
|
||||
if (!$res || $res['status'] != 1) {
|
||||
return ['code' => 0, 'msg' => '请先认证歌手', 'data' => null];
|
||||
}
|
||||
//查询是否提交过歌曲
|
||||
$res = db::name('vs_singer_song')->where(['user_id' => $user_id, 'song_name' => $song_name])->find();
|
||||
if ($res) {
|
||||
@@ -233,7 +238,7 @@ class SingerSong extends Model
|
||||
$exp_coin = round($coin / get_system_config_value('singer_coin_exp'), 2);
|
||||
$exps = $exp + $exp_coin;
|
||||
//查询等级
|
||||
$level = db::name('vs_singer_level')->where(['exp' => ['<=', $exps]])->order('exp desc')->find();
|
||||
$level = db::name('vs_singer_level')->where(['change_value' => ['<=', $exps]])->order('exp desc')->find();
|
||||
if ($level) {
|
||||
db::name('vs_singer')->where(['id' => $is_singer['id']])->update(['exp' => $exps,'level' => $level['level']]);
|
||||
}
|
||||
|
||||
@@ -2,13 +2,144 @@
|
||||
|
||||
namespace app\api\model;
|
||||
|
||||
use think\Db;
|
||||
use think\Model;
|
||||
|
||||
class UserCp extends Model
|
||||
{
|
||||
//用户关系卡(亲密拍)、关系位(真爱拍 ->有电影房)
|
||||
public function user_cp_list($uid,$user_id)
|
||||
{
|
||||
|
||||
/*
|
||||
* 检测是否赠送的Cp礼物
|
||||
* @param $from_user_id 送礼用户ID
|
||||
* @param $gift_id 礼物ID
|
||||
* @param $to_user_id 接收用户ID
|
||||
* @param $room_id 房间ID
|
||||
*/
|
||||
public function checkGift($from_user_id, $gift_id, $to_user_id, $room_id)
|
||||
{
|
||||
$cp_gift_id = explode(',', get_system_config_value('cp_gift_id'));
|
||||
if(!in_array($gift_id, $cp_gift_id)){
|
||||
return false;
|
||||
}
|
||||
|
||||
$rees = Db::name('user_cp_zone')->where(['user_id1' => $from_user_id,'user_id2' => $to_user_id,'status' => 1])->find();
|
||||
if(!$rees){
|
||||
$rees = Db::name('user_cp_zone')->where(['user_id1' => $to_user_id,'user_id2' => $from_user_id,'status' => 1])->find();
|
||||
}
|
||||
if($rees){
|
||||
$this->addCpLevel($from_user_id, $to_user_id, $room_id, $gift_id, $rees['id']);
|
||||
return true;
|
||||
}
|
||||
|
||||
//查询收礼人有没有给送礼人送过cp礼物
|
||||
$res = Db::name('user_cp_find')->where(['from_user_id' => $to_user_id, 'to_user_id' => $from_user_id,'status' => 0])->find();
|
||||
if($res){
|
||||
//创建推送信息1:回应送礼 并创建Cp空间,
|
||||
$data = [
|
||||
'from_user_id' => $from_user_id,
|
||||
'to_user_id' => $to_user_id,
|
||||
'gift_id' => $gift_id,
|
||||
'createtime' => time(),
|
||||
'status' => 1
|
||||
];
|
||||
Db::name('user_cp_find')->insert($data);
|
||||
//修改状态
|
||||
Db::name('user_cp_find')->where(['id' => $res['id']])->update(['status' => 1]);
|
||||
//创建Cp空间
|
||||
|
||||
$data = [
|
||||
'user_id1' => $from_user_id,
|
||||
'user_id2' => $to_user_id,
|
||||
'createtime' => time(),
|
||||
'status' => 1,//1-已建立Cp空间,2-已取消
|
||||
'level' => 1,
|
||||
//经验值
|
||||
'exp' => 0,
|
||||
];
|
||||
Db::name('user_cp_zone')->insert($data);
|
||||
|
||||
//给前端推送
|
||||
$text = [
|
||||
'text' => '组建Cp'
|
||||
];
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1081,$room_id,$text);
|
||||
}else{//创建推送信息2:表达心动信号
|
||||
//查询是否有相应的Cp空间
|
||||
$ress = Db::name('user_cp_find')
|
||||
->where(['status' => ['in',[0,1]]])
|
||||
->whereOr(['from_user_id' => $from_user_id])
|
||||
->whereOr(['to_user_id' => $from_user_id])
|
||||
->select();
|
||||
if($ress){
|
||||
//把状态改为2 status:0-待回应,1-建交成功,2-已取消,
|
||||
foreach ($ress as $v){
|
||||
Db::name('user_cp_find')->where(['id' => $v['id']])->update(['status' => 2]);
|
||||
}
|
||||
}
|
||||
$rees = Db::name('user_cp_zone')->where(['user_id1' => $from_user_id,'user_id2' => $to_user_id,'status' => 1])->find();
|
||||
if(!$rees){
|
||||
$rees = Db::name('user_cp_zone')->where(['user_id1' => $to_user_id,'user_id2' => $from_user_id,'status' => 1])->find();
|
||||
}
|
||||
if($rees){
|
||||
//修改状态
|
||||
Db::name('user_cp_zone')->where(['id' => $rees['id']])->update(['status' => 2]);
|
||||
}
|
||||
|
||||
$data = [
|
||||
'from_user_id' => $from_user_id,
|
||||
'to_user_id' => $to_user_id,
|
||||
'gift_id' => $gift_id,
|
||||
'createtime' => time(),
|
||||
];
|
||||
Db::name('user_cp_find')->insert($data);
|
||||
//给前端推送
|
||||
$text = [
|
||||
'text' => '有心动信号'
|
||||
];
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1080,$room_id,$text);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 送Cp礼物 增加Cp 经验 判断是否升级
|
||||
* @param $from_user_id 送礼用户ID
|
||||
* @param $to_user_id 接收用户ID
|
||||
* @param $gift_id 礼物ID
|
||||
* @param $room_id 房间ID
|
||||
* @param $cp_zone_id Cp空间ID
|
||||
*/
|
||||
public function addCpLevel($from_user_id, $to_user_id, $room_id, $gift_id, $cp_zone_id)
|
||||
{
|
||||
$jinbi_arr = explode(',', get_system_config_value('cp_exp_rate'));
|
||||
$jinbi = $jinbi_arr[0];
|
||||
$jinyan = $jinbi_arr[1];
|
||||
$exp = round(db::name('vs_gift')->where(['gid' => $gift_id])->value('gift_price') / $jinbi * $jinyan, 2);
|
||||
$yuan_exp = Db::name('user_cp_zone')->where(['id' => $cp_zone_id])->value('exp');
|
||||
|
||||
//添加一个记录
|
||||
$datas = [
|
||||
'room_id' => $room_id,
|
||||
'from_user_id' => $from_user_id,
|
||||
'to_user_id' => $to_user_id,
|
||||
'gift_id' => $gift_id,
|
||||
'cp_zone_id' => $cp_zone_id,
|
||||
'exp' => $exp,
|
||||
'exp_total' => $yuan_exp + $exp,
|
||||
'createtime' => time(),
|
||||
];
|
||||
Db::name('user_cp_gift_log')->insert($datas);
|
||||
//判断是否升级
|
||||
$level = Db::name('user_cp_level')->where(['exp' => ['<=', $yuan_exp + $exp]])->order('exp desc')->value('level');
|
||||
if($level){
|
||||
//修改Cp空间等级
|
||||
$data['level'] = $level;
|
||||
}
|
||||
$data['exp'] = $yuan_exp + $exp;
|
||||
Db::name('user_cp_zone')->where(['id' => $cp_zone_id])->update($data);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user