cp空间
This commit is contained in:
@@ -82,42 +82,21 @@ class UserCp extends Model
|
||||
//修改状态
|
||||
Db::name('user_cp_zone')->where(['id' => $rees['id']])->update(['status' => 2]);
|
||||
}
|
||||
//给两个用户给CP装扮
|
||||
|
||||
// 给两个用户添加CP装扮
|
||||
$pendant_ids = Db::name('user_cp_level')->where(['deletetime' => 0])->order('level asc')->value('pendant_id');
|
||||
$pendant_id = Db::name('vs_decorate_price')->where(['id' => $pendant_ids])->value('did');
|
||||
// 给两个用户添加CP装扮
|
||||
//先检查该用户是否已有该装扮
|
||||
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装扮类型
|
||||
}
|
||||
|
||||
$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);
|
||||
// 给两个用户添加CP特效
|
||||
$rights_icon_ids = Db::name('user_cp_level')->where(['deletetime' => 0])->order('level asc')->value('rights_icon_id');
|
||||
$rights_icon_id = Db::name('vs_decorate_price')->where(['id' => $rights_icon_ids])->value('did');
|
||||
if($rights_icon_id){
|
||||
$this->assignCpDecoration([$from_user_id, $to_user_id], 10, $rights_icon_id); // 10为CP特效类型
|
||||
}
|
||||
|
||||
//给前端推送
|
||||
return 2;
|
||||
}else{//创建推送信息2:表达心动信号
|
||||
@@ -146,6 +125,49 @@ class UserCp extends Model
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 为CP用户分配装扮或特效
|
||||
* @param array $user_ids 用户ID数组
|
||||
* @param int $type 装扮类型(10-特效, 11-装扮)
|
||||
* @param int $did 装扮ID
|
||||
*/
|
||||
private function assignCpDecoration($user_ids, $type, $did)
|
||||
{
|
||||
// 先检查用户是否已有该装扮,如果有则设为未使用
|
||||
foreach ($user_ids as $user_id) {
|
||||
$existing_decoration = Db::name('vs_user_decorate')
|
||||
->where([
|
||||
'user_id' => $user_id,
|
||||
'type' => $type,
|
||||
'did' => $did,
|
||||
'is_using' => 1
|
||||
])
|
||||
->find();
|
||||
|
||||
if ($existing_decoration) {
|
||||
Db::name('vs_user_decorate')
|
||||
->where(['id' => $existing_decoration['id']])
|
||||
->update(['is_using' => 2]);
|
||||
}
|
||||
}
|
||||
|
||||
// 给用户添加新装扮
|
||||
$decorate_data = [
|
||||
'type' => $type,
|
||||
'did' => $did,
|
||||
'is_using' => 1,
|
||||
'end_time' => 0,
|
||||
'is_perpetual' => 1,
|
||||
'createtime' => time(),
|
||||
];
|
||||
|
||||
foreach ($user_ids as $user_id) {
|
||||
$insert_data = array_merge(['user_id' => $user_id], $decorate_data);
|
||||
Db::name('vs_user_decorate')->insert($insert_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* 送Cp礼物 增加Cp 经验 判断是否升级
|
||||
|
||||
Reference in New Issue
Block a user