新需求-活动需求-盲盒转盘-立即竞拍
This commit is contained in:
@@ -34,7 +34,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
||||
/**
|
||||
* 重构后的抽奖方法 - 优化响应速度
|
||||
*/
|
||||
public function draw_gift($gift_bag_id, $user_id, $gift_user_ids, $num = 1, $room_id = 0, $heart_id = 0)
|
||||
public function draw_gift($gift_bag_id, $user_id, $gift_user_ids, $num = 1, $room_id = 0, $heart_id = 0,$auction_id = 0)
|
||||
{
|
||||
try {
|
||||
// 1. 验证参数并提前处理错误
|
||||
@@ -79,7 +79,8 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
||||
$precomputedResults,
|
||||
$availableGiftss,
|
||||
$gift_user_ids,
|
||||
$heart_id
|
||||
$heart_id,
|
||||
$auction_id
|
||||
);
|
||||
if ($transactionResult['code'] !== 1) {
|
||||
return $transactionResult;
|
||||
@@ -442,7 +443,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
||||
/**
|
||||
* 执行抽奖事务(核心操作)
|
||||
*/
|
||||
private function executeDrawTransaction($bag_data, $user_id, $room_id, $num, $precomputedResults,$availableGiftss,$gift_user_ids,$heart_id)
|
||||
private function executeDrawTransaction($bag_data, $user_id, $room_id, $num, $precomputedResults,$availableGiftss,$gift_user_ids,$heart_id,$auction_id)
|
||||
{
|
||||
$gift_user_num = count(explode(',', $gift_user_ids)); //人数
|
||||
$bagGiftPrice = $bag_data['gift_price'] * $num * $gift_user_num;
|
||||
@@ -473,7 +474,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
||||
$this->deductUserCoins($user_id, $bagGiftPrice, $room_id);
|
||||
|
||||
//发送礼物
|
||||
$result = $this->sendGiftsToRecipients($precomputedResults, $room_id,$user_id,$heart_id);
|
||||
$result = $this->sendGiftsToRecipients($precomputedResults, $room_id,$user_id,$heart_id,$auction_id);
|
||||
if (isset($result['code']) && $result['code'] !== 1) {
|
||||
throw new \Exception($result['msg']);
|
||||
}
|
||||
@@ -642,7 +643,7 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
||||
/**
|
||||
* 发送礼物给接收者
|
||||
*/
|
||||
private function sendGiftsToRecipients($precomputedResults, $room_id,$user_id,$heart_id)
|
||||
private function sendGiftsToRecipients($precomputedResults, $room_id,$user_id,$heart_id,$auction_id)
|
||||
{
|
||||
// 统计每个用户每个礼物的数量
|
||||
$giftUserCounts = [];
|
||||
@@ -671,19 +672,21 @@ class BlindBoxTurntableGiftDrawWorld extends Model
|
||||
'all_gift_price' => $userGift['gift_price'] * $userGift['count'],
|
||||
'is_draw_gift' => 1
|
||||
];
|
||||
|
||||
$res = model('Room')->room_gift(
|
||||
$user_id,
|
||||
$userGift['gift_user_id'],
|
||||
$userGift['gift_id'],
|
||||
$userGift['count'],
|
||||
1,
|
||||
$room_id,
|
||||
0,
|
||||
$heart_id,
|
||||
$giveGiftExt
|
||||
);
|
||||
|
||||
if(!empty($auction_id)){
|
||||
model('RoomAuction')->room_auction_join($auction_id,$user_id,$userGift['gift_id'],$userGift['count'],2,$giveGiftExt);
|
||||
}else{
|
||||
$res = model('Room')->room_gift(
|
||||
$user_id,
|
||||
$userGift['gift_user_id'],
|
||||
$userGift['gift_id'],
|
||||
$userGift['count'],
|
||||
1,
|
||||
$room_id,
|
||||
0,
|
||||
$heart_id,
|
||||
$giveGiftExt
|
||||
);
|
||||
}
|
||||
if (isset($res) && $res['code'] != 1) {
|
||||
Log::record('发送礼物失败: ' . $res['msg'] . $userGift['gift_user_id'], "info");
|
||||
return ['code' => 0, 'msg' => $res['msg'], 'data' => null];
|
||||
|
||||
Reference in New Issue
Block a user