[接口]优化新增购买抽奖券时记录DicePlayerTicketRecord
This commit is contained in:
@@ -8,6 +8,7 @@ use app\api\service\LotteryService;
|
||||
use app\dice\model\lottery_config\DiceLotteryConfig;
|
||||
use app\dice\model\play_record\DicePlayRecord;
|
||||
use app\dice\model\player\DicePlayer;
|
||||
use app\dice\model\player_ticket_record\DicePlayerTicketRecord;
|
||||
use app\dice\model\player_wallet_record\DicePlayerWalletRecord;
|
||||
use app\dice\model\reward_config\DiceRewardConfig;
|
||||
use plugin\saiadmin\exception\ApiException;
|
||||
@@ -86,6 +87,7 @@ class PlayStartLogic
|
||||
$configId = (int) $config->id;
|
||||
$rewardId = (int) $reward->id;
|
||||
$configName = (string) ($config->name ?? '');
|
||||
$isTierT5 = (string) ($reward->tier ?? '') === 'T5';
|
||||
try {
|
||||
Db::transaction(function () use (
|
||||
$playerId,
|
||||
@@ -99,6 +101,7 @@ class PlayStartLogic
|
||||
$startIndex,
|
||||
$targetIndex,
|
||||
$rollArray,
|
||||
$isTierT5,
|
||||
&$record
|
||||
) {
|
||||
$record = DicePlayRecord::create([
|
||||
@@ -128,6 +131,19 @@ class PlayStartLogic
|
||||
} else {
|
||||
$p->free_draw_count = max(0, (int) $p->free_draw_count - 1);
|
||||
}
|
||||
|
||||
// 若本局中奖档位为 T5,则额外赠送 1 次免费抽奖次数(总次数也 +1),并记录抽奖券获取记录
|
||||
if ($isTierT5) {
|
||||
$p->free_draw_count = (int) $p->free_draw_count + 1;
|
||||
$p->total_draw_count = (int) $p->total_draw_count + 1;
|
||||
|
||||
DicePlayerTicketRecord::create([
|
||||
'player_id' => $playerId,
|
||||
'free_draw_count' => 1,
|
||||
'remark' => '中奖结果为T5',
|
||||
]);
|
||||
}
|
||||
|
||||
$p->save();
|
||||
|
||||
// 累加彩金池盈利额度(累加值为 -real_ev)。若 dice_lottery_config 表有 ev 字段则执行
|
||||
|
||||
Reference in New Issue
Block a user