1.增加/dice/reward_config_record/index的关联删除/dice/play_record_test/index中的测试详细数据
This commit is contained in:
@@ -11,6 +11,7 @@ use app\dice\model\ante_config\DiceAnteConfig;
|
||||
use app\dice\model\lottery_pool_config\DiceLotteryPoolConfig;
|
||||
use app\dice\model\reward\DiceReward;
|
||||
use app\dice\model\reward\DiceRewardConfig;
|
||||
use app\dice\model\play_record_test\DicePlayRecordTest;
|
||||
use app\dice\model\reward_config_record\DiceRewardConfigRecord;
|
||||
use app\dice\basic\DiceBaseLogic;
|
||||
use plugin\saiadmin\exception\ApiException;
|
||||
@@ -77,6 +78,51 @@ class DiceRewardConfigRecordLogic extends DiceBaseLogic
|
||||
return $map;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除权重测试记录,并级联删除 dice_play_record_test 中 reward_config_record_id 关联的明细
|
||||
* @param mixed $ids
|
||||
*/
|
||||
public function destroy($ids): bool
|
||||
{
|
||||
return $this->transaction(function () use ($ids) {
|
||||
$intIds = $this->normalizeDestroyIds($ids);
|
||||
if ($intIds === []) {
|
||||
return false;
|
||||
}
|
||||
$this->destroyRelatedPlayRecordTests($intIds);
|
||||
|
||||
return parent::destroy($intIds);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $ids
|
||||
* @return list<int>
|
||||
*/
|
||||
private function normalizeDestroyIds($ids): array
|
||||
{
|
||||
$idList = is_array($ids) ? $ids : explode(',', (string) $ids);
|
||||
$intIds = [];
|
||||
foreach ($idList as $v) {
|
||||
$iv = (int) $v;
|
||||
if ($iv > 0) {
|
||||
$intIds[] = $iv;
|
||||
}
|
||||
}
|
||||
|
||||
return array_values(array_unique($intIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<int> $recordIds dice_reward_config_record.id
|
||||
*/
|
||||
private function destroyRelatedPlayRecordTests(array $recordIds): void
|
||||
{
|
||||
DicePlayRecordTest::destroy(function ($query) use ($recordIds) {
|
||||
$query->whereIn('reward_config_record_id', $recordIds);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 将测试记录导入:DiceReward(权重快照)、DiceRewardConfig(BIGWIN weight)、DiceLotteryPoolConfig(付费/免费 T1-T5)
|
||||
* @param int $recordId 测试记录 ID
|
||||
|
||||
Reference in New Issue
Block a user