盲盒转盘代码优化
This commit is contained in:
@@ -71,12 +71,6 @@ class BlindBoxTurntableGiftDraw extends Model
|
||||
$this->recordDrawErrorToRedis($expectedCount, count($precomputedResults), $room_id, $user_id, $gift_bag_id, $num, $gift_user_ids, $precomputedResults);
|
||||
return ['code' => 0, 'msg' => '抽奖结果数量与预期数量不一致,请重试! ', 'data' => null];
|
||||
}
|
||||
|
||||
//兼容送礼判断,主持人比例设置为100% 送礼方法里报错,快速解决,把送礼方法前置,送完礼再处理盲盒转盘记录
|
||||
$result = $this->sendGiftsToRecipients($precomputedResults, $room_id,$user_id);
|
||||
if (isset($result['code']) && $result['code'] !== 1) {
|
||||
return $result;
|
||||
}
|
||||
// 4. 执行抽奖事务(核心操作)
|
||||
$transactionResult = $this->executeDrawTransaction(
|
||||
$bag_data,
|
||||
@@ -507,6 +501,12 @@ class BlindBoxTurntableGiftDraw extends Model
|
||||
// 4. 扣除用户金币
|
||||
$this->deductUserCoins($user_id, $bagGiftPrice, $room_id);
|
||||
|
||||
//发送礼物
|
||||
$result = $this->sendGiftsToRecipients($precomputedResults, $room_id,$user_id);
|
||||
if (isset($result['code']) && $result['code'] !== 1) {
|
||||
throw new \Exception($result['msg']);
|
||||
}
|
||||
|
||||
db::commit();
|
||||
|
||||
// 5. 统计礼物数量
|
||||
@@ -550,7 +550,7 @@ class BlindBoxTurntableGiftDraw extends Model
|
||||
|
||||
if (!$ret) {
|
||||
Log::record('巡乐会更新礼物剩余数量: ' . $room_id."【数据】".var_export($precomputedResults, true),"info");
|
||||
// throw new \Exception('更新礼物剩余数量失败');
|
||||
throw new \Exception('更新礼物剩余数量失败');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -725,11 +725,11 @@ class BlindBoxTurntableGiftDraw extends Model
|
||||
);
|
||||
|
||||
if (isset($res) && $res['code'] != 1) {
|
||||
Log::record('发送礼物失败: ' . $res['msg'].$userGift['gift_user_id'],"info");
|
||||
Log::record('发送礼物失败: ' . $res['msg'] . $userGift['gift_user_id'], "info");
|
||||
return ['code' => 0, 'msg' => $res['msg'], 'data' => null];
|
||||
// \think\facade\Log::error('发送礼物失败: ' . $res['msg']);
|
||||
}
|
||||
}
|
||||
return ['code' => 1, 'msg' => '发送礼物成功', 'data' => null];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user