Cp礼物送礼处理
This commit is contained in:
@@ -14,24 +14,25 @@ class UserCp extends Model
|
||||
* @param $gift_id 礼物ID
|
||||
* @param $to_user_id 接收用户ID
|
||||
* @param $room_id 房间ID
|
||||
* @return int 0-无,1-等待回应,2-已建立Cp空间
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
//查询是否已经存在Cp空间
|
||||
$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;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//查询收礼人有没有给送礼人送过cp礼物
|
||||
$cp_gift_id = explode(',', get_system_config_value('cp_gift_id'));
|
||||
if(!in_array($gift_id, $cp_gift_id)){
|
||||
return 0;
|
||||
}
|
||||
//查询收礼人有没有给送礼人送过cp礼物 status:0-待回应,1-建交成功,2-已取消
|
||||
$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空间,
|
||||
@@ -45,8 +46,8 @@ class UserCp extends Model
|
||||
Db::name('user_cp_find')->insert($data);
|
||||
//修改状态
|
||||
Db::name('user_cp_find')->where(['id' => $res['id']])->update(['status' => 1]);
|
||||
//创建Cp空间
|
||||
|
||||
//创建Cp空间
|
||||
$data = [
|
||||
'user_id1' => $from_user_id,
|
||||
'user_id2' => $to_user_id,
|
||||
@@ -59,11 +60,7 @@ class UserCp extends Model
|
||||
Db::name('user_cp_zone')->insert($data);
|
||||
|
||||
//给前端推送
|
||||
$text = [
|
||||
'text' => '组建Cp'
|
||||
];
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1081,$room_id,$text);
|
||||
return 2;
|
||||
}else{//创建推送信息2:表达心动信号
|
||||
//查询是否有相应的Cp空间
|
||||
$ress = Db::name('user_cp_find')
|
||||
@@ -94,13 +91,8 @@ class UserCp extends Model
|
||||
];
|
||||
Db::name('user_cp_find')->insert($data);
|
||||
//给前端推送
|
||||
$text = [
|
||||
'text' => '有心动信号'
|
||||
];
|
||||
//聊天室推送系统消息
|
||||
model('Chat')->sendMsg(1080,$room_id,$text);
|
||||
return 1;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user