送盲盒
This commit is contained in:
@@ -270,6 +270,7 @@ class SendGift extends Model
|
||||
$receive_gift_total = 0;//收礼人收到的礼物总值
|
||||
$gift_box = [];//开出的盲盒
|
||||
$gift_box_str = '';
|
||||
$gift_box_map = [];
|
||||
|
||||
//查询礼物是否是盲盒
|
||||
if($gift_info['label'] == 2){//趣味礼物(盲盒)
|
||||
@@ -281,17 +282,36 @@ class SendGift extends Model
|
||||
return ['code' => 0, 'msg' => '网络错误-3', 'data' => null];
|
||||
}
|
||||
$gift_box[$i] = $gift_box1[$i]['data'];
|
||||
|
||||
//礼物整合
|
||||
$gift_box_str .= $gift_box[$i]['gift_name'] . 'x' . $gift_box[$i]['num'].'/';
|
||||
$gift_id = $gift_box[$i]['gift_id'];
|
||||
$gift_name = $gift_box[$i]['gift_name'];
|
||||
|
||||
if(isset($gift_box_map[$gift_id])){
|
||||
// 如果礼物ID已存在,数量加1
|
||||
$gift_box_map[$gift_id]['count']++;
|
||||
}else{
|
||||
// 如果礼物ID不存在,添加新项
|
||||
$gift_box_map[$gift_id] = [
|
||||
'name' => $gift_name,
|
||||
'count' => 1
|
||||
];
|
||||
}
|
||||
|
||||
//开出的礼物价值
|
||||
$receive_gift_total += $gift_box[$i]['gift_price'];
|
||||
|
||||
Log::record("送礼开出盲盒礼物信息:".json_encode($gift_box1),"info");
|
||||
}
|
||||
$gift_box_str = substr($gift_box_str,0,-1);//去掉最后一个/
|
||||
if(!empty($gift_box_map)){
|
||||
//拼接礼物字符串 (娃哈哈 * 2 / 娃哈哈1 * 1)这种格式
|
||||
$gift_box_str_parts = [];
|
||||
foreach($gift_box_map as $gift_id => $gift_info_data){
|
||||
$gift_box_str_parts[] = $gift_info_data['name'] . ' * ' . $gift_info_data['count'];
|
||||
}
|
||||
$gift_box_str = implode(' / ', $gift_box_str_parts);
|
||||
}
|
||||
|
||||
}else{
|
||||
$receive_gift_total = $gift_price;
|
||||
|
||||
}
|
||||
|
||||
//计算收礼人得益 //1聊天送礼物 2房间语聊送礼 3直播送礼 4动态打赏 99房主收益 98主持人收益
|
||||
@@ -769,7 +789,6 @@ class SendGift extends Model
|
||||
$gift_user_data[]['user_id'] = $to_uid;
|
||||
$receive_gift_total = 0;//收礼人收到的礼物总值
|
||||
$gift_box = [];//开出的盲盒
|
||||
$give_gift = 0;//送礼记录表ID(雪花ID)
|
||||
//送礼 开启事务
|
||||
Db::startTrans();
|
||||
|
||||
@@ -801,12 +820,30 @@ class SendGift extends Model
|
||||
$gift_box[$i] = $gift_box1[$i]['data'];
|
||||
//开出的礼物价值
|
||||
$receive_gift_total += $gift_box[$i]['gift_price'];
|
||||
|
||||
//礼物整合
|
||||
$gift_box_str .= $gift_box[$i]['gift_name'] . 'x' . $gift_box[$i]['num'].'/';
|
||||
Log::record("送礼开出盲盒礼物信息:".json_encode($gift_box1),"info");
|
||||
$gift_id = $gift_box[$i]['gift_id'];
|
||||
$gift_name = $gift_box[$i]['gift_name'];
|
||||
|
||||
if(isset($gift_box_map[$gift_id])){
|
||||
// 如果礼物ID已存在,数量加1
|
||||
$gift_box_map[$gift_id]['count']++;
|
||||
}else{
|
||||
// 如果礼物ID不存在,添加新项
|
||||
$gift_box_map[$gift_id] = [
|
||||
'name' => $gift_name,
|
||||
'count' => 1
|
||||
];
|
||||
}
|
||||
}
|
||||
if(!empty($gift_box_map)){
|
||||
//拼接礼物字符串 (娃哈哈 * 2 / 娃哈哈1 * 1)这种格式
|
||||
$gift_box_str_parts = [];
|
||||
foreach($gift_box_map as $gift_id => $gift_info_data){
|
||||
$gift_box_str_parts[] = $gift_info_data['name'] . ' * ' . $gift_info_data['count'];
|
||||
}
|
||||
$gift_box_str = implode(' / ', $gift_box_str_parts);
|
||||
}
|
||||
//去掉最后一个/
|
||||
$gift_box_str = substr($gift_box_str,0,strlen($gift_box_str)-1);
|
||||
}else{
|
||||
$receive_gift_total = $gift_price;
|
||||
}
|
||||
@@ -1418,6 +1455,7 @@ class SendGift extends Model
|
||||
$result_data = [
|
||||
'gift_id'=>$gift_bag_detail['foreign_id'],
|
||||
'gift_price'=>$gift['gift_price'],
|
||||
'gift_name'=>$gift['gift_name'],
|
||||
'is_public_screen'=>$gift['is_public_screen'],
|
||||
];
|
||||
return ['code' => 1, 'msg' => '成功', 'data' => $result_data];
|
||||
|
||||
Reference in New Issue
Block a user