新需求-活动需求-盲盒转盘-立即竞拍
This commit is contained in:
@@ -39,7 +39,8 @@ class BlindBoxTurntable extends BaseCom
|
||||
$gift_user_ids = input('gift_user_ids',0);
|
||||
$num = input('num',1);
|
||||
$heart_id = input('heart_id',0);
|
||||
$reslut = model('BlindBoxTurntableGiftDraw')->draw_gift($gift_bag_id, $user_id, $gift_user_ids,$num,$room_id,$heart_id);
|
||||
$auction_id = input('auction_id',0);
|
||||
$reslut = model('BlindBoxTurntableGiftDraw')->draw_gift($gift_bag_id, $user_id, $gift_user_ids,$num,$room_id,$heart_id,$auction_id);
|
||||
return v($reslut['code'], $reslut['msg'], $reslut['data']);
|
||||
}
|
||||
/*
|
||||
|
||||
@@ -34,7 +34,7 @@ class BlindBoxTurntableGiftDraw 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. 验证参数并提前处理错误
|
||||
@@ -80,7 +80,8 @@ class BlindBoxTurntableGiftDraw extends Model
|
||||
$precomputedResults,
|
||||
$availableGiftss,
|
||||
$gift_user_ids,
|
||||
$heart_id
|
||||
$heart_id,
|
||||
$auction_id
|
||||
);
|
||||
if ($transactionResult['code'] !== 1) {
|
||||
return $transactionResult;
|
||||
@@ -474,7 +475,7 @@ class BlindBoxTurntableGiftDraw 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;
|
||||
@@ -505,7 +506,7 @@ class BlindBoxTurntableGiftDraw 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']);
|
||||
}
|
||||
@@ -685,7 +686,7 @@ class BlindBoxTurntableGiftDraw 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 = [];
|
||||
@@ -714,18 +715,21 @@ class BlindBoxTurntableGiftDraw 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");
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -109,7 +109,7 @@ class RoomAuction extends Model
|
||||
|
||||
|
||||
//参与竞拍
|
||||
public function room_auction_join($auction_id,$user_id,$gift_id,$num,$type)
|
||||
public function room_auction_join($auction_id,$user_id,$gift_id,$num,$type,$ext=[])
|
||||
{
|
||||
if(!$auction_id){
|
||||
return ['code' => 0, 'msg' => '拍卖已经结束','data' => null];
|
||||
@@ -127,7 +127,7 @@ class RoomAuction extends Model
|
||||
}
|
||||
|
||||
//走送礼流程
|
||||
$ree = model('GiveGift')->give_gift($user_id,$auction['user_id'],$gift_id,$num,2,$type,$auction['room_id'],0,0);
|
||||
$ree = model('GiveGift')->give_gift($user_id,$auction['user_id'],$gift_id,$num,2,$type,$auction['room_id'],0,0,$ext);
|
||||
if($ree['code'] != 1){
|
||||
return ['code' => $ree['code'], 'msg' => $ree['msg'],'data' => null];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user