Compare commits
3 Commits
8684fdc9f0
...
master-v2
| Author | SHA1 | Date | |
|---|---|---|---|
| 68092759d3 | |||
| 8702cb0571 | |||
| ca620eb536 |
@@ -36,6 +36,9 @@
|
|||||||
"editSuccess": "Updated successfully",
|
"editSuccess": "Updated successfully",
|
||||||
"validateFailed": "Validation failed, please check required fields and format"
|
"validateFailed": "Validation failed, please check required fields and format"
|
||||||
},
|
},
|
||||||
|
"toolbar": {
|
||||||
|
"platformTotalProfit": "Platform Total Profit"
|
||||||
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"player": "Player",
|
"player": "Player",
|
||||||
"lotteryPoolConfig": "Lottery Pool Config",
|
"lotteryPoolConfig": "Lottery Pool Config",
|
||||||
|
|||||||
@@ -36,6 +36,9 @@
|
|||||||
"editSuccess": "修改成功",
|
"editSuccess": "修改成功",
|
||||||
"validateFailed": "表单验证失败,请检查必填项与格式"
|
"validateFailed": "表单验证失败,请检查必填项与格式"
|
||||||
},
|
},
|
||||||
|
"toolbar": {
|
||||||
|
"platformTotalProfit": "平台总盈利"
|
||||||
|
},
|
||||||
"search": {
|
"search": {
|
||||||
"player": "玩家",
|
"player": "玩家",
|
||||||
"lotteryPoolConfig": "彩金池配置",
|
"lotteryPoolConfig": "彩金池配置",
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
<!-- 表格头部 -->
|
<!-- 表格头部 -->
|
||||||
<ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData">
|
<ArtTableHeader v-model:columns="columnChecks" :loading="loading" @refresh="refreshData">
|
||||||
<template #left>
|
<template #left>
|
||||||
|
<span v-if="totalWinCoin !== null" class="table-summary-inline">
|
||||||
|
{{ $t('page.toolbar.platformTotalProfit') }}:<strong>{{ totalWinCoin }}</strong>
|
||||||
|
</span>
|
||||||
<!-- <ElSpace wrap>-->
|
<!-- <ElSpace wrap>-->
|
||||||
<!-- <ElButton-->
|
<!-- <ElButton-->
|
||||||
<!-- v-permission="'dice:play_record:index:save'"-->
|
<!-- v-permission="'dice:play_record:index:save'"-->
|
||||||
@@ -126,6 +129,15 @@
|
|||||||
direction: undefined
|
direction: undefined
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** 当前筛选下平台总盈利(付费抽奖次数×100 - 玩家总收益) */
|
||||||
|
const totalWinCoin = ref<number | null>(null)
|
||||||
|
|
||||||
|
const listApi = async (params: Record<string, any>) => {
|
||||||
|
const res = await api.list(params)
|
||||||
|
totalWinCoin.value = (res as any)?.total_win_coin ?? null
|
||||||
|
return res
|
||||||
|
}
|
||||||
|
|
||||||
// 搜索处理
|
// 搜索处理
|
||||||
const handleSearch = (params: Record<string, any>) => {
|
const handleSearch = (params: Record<string, any>) => {
|
||||||
Object.assign(searchParams, params)
|
Object.assign(searchParams, params)
|
||||||
@@ -170,7 +182,8 @@
|
|||||||
refreshData
|
refreshData
|
||||||
} = useTable({
|
} = useTable({
|
||||||
core: {
|
core: {
|
||||||
apiFn: api.list,
|
apiFn: listApi,
|
||||||
|
apiParams: { limit: 100 },
|
||||||
columnsFactory: () => [
|
columnsFactory: () => [
|
||||||
// { type: 'selection' },
|
// { type: 'selection' },
|
||||||
{ prop: 'id', label: 'page.table.id', width: 80 },
|
{ prop: 'id', label: 'page.table.id', width: 80 },
|
||||||
@@ -219,3 +232,15 @@
|
|||||||
// selectedRows
|
// selectedRows
|
||||||
} = useSaiAdmin()
|
} = useSaiAdmin()
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.table-summary-inline {
|
||||||
|
margin-right: 12px;
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--el-text-color-regular);
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
.table-summary-inline strong {
|
||||||
|
color: var(--el-color-danger);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -122,6 +122,7 @@
|
|||||||
} = useTable({
|
} = useTable({
|
||||||
core: {
|
core: {
|
||||||
apiFn: api.list,
|
apiFn: api.list,
|
||||||
|
apiParams: { limit: 100 },
|
||||||
columnsFactory: () => {
|
columnsFactory: () => {
|
||||||
const usernameFormatter = (row: Record<string, any>) =>
|
const usernameFormatter = (row: Record<string, any>) =>
|
||||||
row?.dicePlayer?.username ?? row?.player_id ?? '-'
|
row?.dicePlayer?.username ?? row?.player_id ?? '-'
|
||||||
|
|||||||
@@ -163,6 +163,7 @@
|
|||||||
} = useTable({
|
} = useTable({
|
||||||
core: {
|
core: {
|
||||||
apiFn: api.list,
|
apiFn: api.list,
|
||||||
|
apiParams: { limit: 100 },
|
||||||
columnsFactory: () => [
|
columnsFactory: () => [
|
||||||
{ type: 'selection', align: 'center' },
|
{ type: 'selection', align: 'center' },
|
||||||
{ prop: 'id', label: 'page.table.id', width: 80, align: 'center' },
|
{ prop: 'id', label: 'page.table.id', width: 80, align: 'center' },
|
||||||
|
|||||||
@@ -77,23 +77,14 @@ class PlayStartLogic
|
|||||||
throw new ApiException('Lottery pool config not found (name=default required)');
|
throw new ApiException('Lottery pool config not found (name=default required)');
|
||||||
}
|
}
|
||||||
|
|
||||||
// 玩家累计盈利:仅统计 lottery_config_id=default 的成功对局。
|
// 彩金池累计盈利:用于判断是否触发杀分(不再依赖单个玩家累计盈利)
|
||||||
// 付费券:盈利按 win_coin - 100/局计算;免费券:不扣除 100/局,只计入 win_coin。
|
// 该值来自 dice_lottery_pool_config.profit_amount
|
||||||
$playerQuery = DicePlayRecord::where('player_id', $playerId)
|
$poolProfitTotal = $configType0->profit_amount ?? 0;
|
||||||
->where('lottery_config_id', $configType0->id)
|
|
||||||
->where('status', self::RECORD_STATUS_SUCCESS);
|
|
||||||
$playerWinSum = (float) $playerQuery->sum('win_coin');
|
|
||||||
$paidPlayCount = (int) DicePlayRecord::where('player_id', $playerId)
|
|
||||||
->where('lottery_config_id', $configType0->id)
|
|
||||||
->where('lottery_type', self::LOTTERY_TYPE_PAID)
|
|
||||||
->where('status', self::RECORD_STATUS_SUCCESS)
|
|
||||||
->count();
|
|
||||||
$playerProfitTotal = $playerWinSum - 100.0 * $paidPlayCount;
|
|
||||||
$safetyLine = (int) ($configType0->safety_line ?? 0);
|
$safetyLine = (int) ($configType0->safety_line ?? 0);
|
||||||
$killEnabled = ((int) ($configType0->kill_enabled ?? 1)) === 1;
|
$killEnabled = ((int) ($configType0->kill_enabled ?? 1)) === 1;
|
||||||
// 盈利>=安全线且开启杀分:付费/免费都用 killScore;盈利<安全线:付费用玩家权重,免费用 killScore(无则用 default)
|
// 盈利>=安全线且开启杀分:付费/免费都用 killScore;盈利<安全线:付费用玩家权重,免费用 killScore(无则用 default)
|
||||||
// 记录 lottery_config_id:用池权重时记对应池,付费用玩家权重时记 default
|
// 记录 lottery_config_id:用池权重时记对应池,付费用玩家权重时记 default
|
||||||
$usePoolWeights = ($ticketType === self::LOTTERY_TYPE_PAID && $killEnabled && $playerProfitTotal >= $safetyLine && $configType1 !== null)
|
$usePoolWeights = ($ticketType === self::LOTTERY_TYPE_PAID && $killEnabled && $poolProfitTotal >= $safetyLine && $configType1 !== null)
|
||||||
|| ($ticketType === self::LOTTERY_TYPE_FREE);
|
|| ($ticketType === self::LOTTERY_TYPE_FREE);
|
||||||
$config = $usePoolWeights
|
$config = $usePoolWeights
|
||||||
? (($ticketType === self::LOTTERY_TYPE_FREE && $configType1 === null) ? $configType0 : $configType1)
|
? (($ticketType === self::LOTTERY_TYPE_FREE && $configType1 === null) ? $configType0 : $configType1)
|
||||||
@@ -274,8 +265,10 @@ class PlayStartLogic
|
|||||||
|
|
||||||
$p->save();
|
$p->save();
|
||||||
|
|
||||||
// 玩家累计盈利累加在 type=0 彩金池上:每局按“当前中奖金额(含 BIGWIN) - 抽奖券费用 100”
|
// 彩金池累计盈利累加在 name=default 彩金池上:
|
||||||
$perPlayProfit = $winCoin - 100.0;
|
// 付费券:每局按“当前中奖金额(含 BIGWIN) - 抽奖券费用 100”
|
||||||
|
// 免费券:取消票价成本 100,只计入中奖金额
|
||||||
|
$perPlayProfit = ($ticketType === self::LOTTERY_TYPE_PAID) ? ($winCoin - 100.0) : $winCoin;
|
||||||
$addProfit = $perPlayProfit;
|
$addProfit = $perPlayProfit;
|
||||||
try {
|
try {
|
||||||
DiceLotteryPoolConfig::where('id', $type0ConfigId)->update([
|
DiceLotteryPoolConfig::where('id', $type0ConfigId)->update([
|
||||||
|
|||||||
@@ -60,7 +60,16 @@ class DicePlayRecordController extends BaseController
|
|||||||
'diceRewardConfig',
|
'diceRewardConfig',
|
||||||
'diceLotteryPoolConfig',
|
'diceLotteryPoolConfig',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// 按当前筛选条件统计:平台总盈利 = 付费抽奖(lottery_type=0)次数×100 - 玩家总收益(win_coin 求和)
|
||||||
|
$sumQuery = clone $query;
|
||||||
|
$playerTotalWin = (float) $sumQuery->sum('win_coin');
|
||||||
|
$paidCountQuery = clone $query;
|
||||||
|
$paidCount = (int) $paidCountQuery->where('lottery_type', 0)->count();
|
||||||
|
$totalWinCoin = $paidCount * 100 - $playerTotalWin;
|
||||||
|
|
||||||
$data = $this->logic->getList($query);
|
$data = $this->logic->getList($query);
|
||||||
|
$data['total_win_coin'] = $totalWinCoin;
|
||||||
return $this->success($data);
|
return $this->success($data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ class DicePlayRecordLogic extends BaseLogic
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->model = new DicePlayRecord();
|
$this->model = new DicePlayRecord();
|
||||||
|
// 默认按主键倒序:最新数据优先展示
|
||||||
|
$this->setOrderType('DESC');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -22,6 +22,8 @@ class DicePlayerTicketRecordLogic extends BaseLogic
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->model = new DicePlayerTicketRecord();
|
$this->model = new DicePlayerTicketRecord();
|
||||||
|
// 默认按主键倒序:最新数据优先展示
|
||||||
|
$this->setOrderType('DESC');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -23,6 +23,8 @@ class DicePlayerWalletRecordLogic extends BaseLogic
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->model = new DicePlayerWalletRecord();
|
$this->model = new DicePlayerWalletRecord();
|
||||||
|
// 默认按主键倒序:最新数据优先展示
|
||||||
|
$this->setOrderType('DESC');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ class DiceRewardConfigRecordLogic extends BaseLogic
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->model = new DiceRewardConfigRecord();
|
$this->model = new DiceRewardConfigRecord();
|
||||||
|
// 默认按主键倒序:最新数据优先展示
|
||||||
|
$this->setOrderType('DESC');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -80,9 +80,8 @@ class WeightTestRunner
|
|||||||
DiceRewardConfig::clearRequestInstance();
|
DiceRewardConfig::clearRequestInstance();
|
||||||
DiceReward::clearRequestInstance();
|
DiceReward::clearRequestInstance();
|
||||||
|
|
||||||
//“玩家”盈利:仅统计 lottery_config_id=default 的成功对局。
|
// 彩金池累计盈利:用于判断是否触发杀分(不再依赖单个玩家累计盈利)
|
||||||
// 付费券:盈利 = win_coin - 100/局;免费券:盈利 = win_coin(不扣除 100/局)
|
$poolProfitTotal = $configType0->profit_amount ?? 0;
|
||||||
$playerProfitTotal = 0.0;
|
|
||||||
|
|
||||||
$playLogic = new PlayStartLogic();
|
$playLogic = new PlayStartLogic();
|
||||||
$resultCounts = [];
|
$resultCounts = [];
|
||||||
@@ -92,22 +91,22 @@ class WeightTestRunner
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
for ($i = 0; $i < $paidS; $i++) {
|
for ($i = 0; $i < $paidS; $i++) {
|
||||||
$usePoolWeights = $killEnabled && $playerProfitTotal >= $safetyLine && $configType1 !== null;
|
$usePoolWeights = $killEnabled && $poolProfitTotal >= $safetyLine && $configType1 !== null;
|
||||||
$paidConfig = $usePoolWeights ? $configType1 : $configType0;
|
$paidConfig = $usePoolWeights ? $configType1 : $configType0;
|
||||||
$customWeights = $usePoolWeights ? null : $paidTierWeights;
|
$customWeights = $usePoolWeights ? null : $paidTierWeights;
|
||||||
$row = $playLogic->simulateOnePlay($paidConfig, 0, 0, $customWeights);
|
$row = $playLogic->simulateOnePlay($paidConfig, 0, 0, $customWeights);
|
||||||
$this->accumulateProfitForDefault($row, 0, $paidConfig, $configType0, $playerProfitTotal);
|
$this->accumulateProfitForDefault($row, 0, $paidConfig, $configType0, $poolProfitTotal);
|
||||||
$this->aggregate($row, $resultCounts, $tierCounts);
|
$this->aggregate($row, $resultCounts, $tierCounts);
|
||||||
$buffer[] = $this->rowForInsert($row, $recordId);
|
$buffer[] = $this->rowForInsert($row, $recordId);
|
||||||
$done++;
|
$done++;
|
||||||
$this->flushIfNeeded($buffer, $recordId, $done, $total, $resultCounts, $tierCounts);
|
$this->flushIfNeeded($buffer, $recordId, $done, $total, $resultCounts, $tierCounts);
|
||||||
}
|
}
|
||||||
for ($i = 0; $i < $paidN; $i++) {
|
for ($i = 0; $i < $paidN; $i++) {
|
||||||
$usePoolWeights = $killEnabled && $playerProfitTotal >= $safetyLine && $configType1 !== null;
|
$usePoolWeights = $killEnabled && $poolProfitTotal >= $safetyLine && $configType1 !== null;
|
||||||
$paidConfig = $usePoolWeights ? $configType1 : $configType0;
|
$paidConfig = $usePoolWeights ? $configType1 : $configType0;
|
||||||
$customWeights = $usePoolWeights ? null : $paidTierWeights;
|
$customWeights = $usePoolWeights ? null : $paidTierWeights;
|
||||||
$row = $playLogic->simulateOnePlay($paidConfig, 1, 0, $customWeights);
|
$row = $playLogic->simulateOnePlay($paidConfig, 1, 0, $customWeights);
|
||||||
$this->accumulateProfitForDefault($row, 0, $paidConfig, $configType0, $playerProfitTotal);
|
$this->accumulateProfitForDefault($row, 0, $paidConfig, $configType0, $poolProfitTotal);
|
||||||
$this->aggregate($row, $resultCounts, $tierCounts);
|
$this->aggregate($row, $resultCounts, $tierCounts);
|
||||||
$buffer[] = $this->rowForInsert($row, $recordId);
|
$buffer[] = $this->rowForInsert($row, $recordId);
|
||||||
$done++;
|
$done++;
|
||||||
@@ -115,7 +114,7 @@ class WeightTestRunner
|
|||||||
}
|
}
|
||||||
for ($i = 0; $i < $freeS; $i++) {
|
for ($i = 0; $i < $freeS; $i++) {
|
||||||
$row = $playLogic->simulateOnePlay($freeConfig, 0, 1, null);
|
$row = $playLogic->simulateOnePlay($freeConfig, 0, 1, null);
|
||||||
$this->accumulateProfitForDefault($row, 1, $freeConfig, $configType0, $playerProfitTotal);
|
$this->accumulateProfitForDefault($row, 1, $freeConfig, $configType0, $poolProfitTotal);
|
||||||
$this->aggregate($row, $resultCounts, $tierCounts);
|
$this->aggregate($row, $resultCounts, $tierCounts);
|
||||||
$buffer[] = $this->rowForInsert($row, $recordId);
|
$buffer[] = $this->rowForInsert($row, $recordId);
|
||||||
$done++;
|
$done++;
|
||||||
@@ -123,7 +122,7 @@ class WeightTestRunner
|
|||||||
}
|
}
|
||||||
for ($i = 0; $i < $freeN; $i++) {
|
for ($i = 0; $i < $freeN; $i++) {
|
||||||
$row = $playLogic->simulateOnePlay($freeConfig, 1, 1, null);
|
$row = $playLogic->simulateOnePlay($freeConfig, 1, 1, null);
|
||||||
$this->accumulateProfitForDefault($row, 1, $freeConfig, $configType0, $playerProfitTotal);
|
$this->accumulateProfitForDefault($row, 1, $freeConfig, $configType0, $poolProfitTotal);
|
||||||
$this->aggregate($row, $resultCounts, $tierCounts);
|
$this->aggregate($row, $resultCounts, $tierCounts);
|
||||||
$buffer[] = $this->rowForInsert($row, $recordId);
|
$buffer[] = $this->rowForInsert($row, $recordId);
|
||||||
$done++;
|
$done++;
|
||||||
@@ -142,20 +141,19 @@ class WeightTestRunner
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 仅当使用 default 池(lottery_config_id=default)时累加玩家盈利,与 PlayStartLogic 一致
|
* 累加彩金池累计盈利,用于触发杀分,与 PlayStartLogic 一致
|
||||||
* @param int $lotteryType 0=付费券,1=免费券
|
* @param int $lotteryType 0=付费券,1=免费券
|
||||||
* @param object $usedConfig 本次使用的奖池配置
|
* @param object $usedConfig 本次使用的奖池配置(仅用于校验非空)
|
||||||
* @param object $configType0 name=default 的彩金池
|
* @param object $configType0 name=default 的彩金池
|
||||||
|
* @param float $playerProfitTotal 实际为“彩金池累计盈利”滚动值
|
||||||
*/
|
*/
|
||||||
private function accumulateProfitForDefault(array $row, int $lotteryType, $usedConfig, $configType0, float &$playerProfitTotal): void
|
private function accumulateProfitForDefault(array $row, int $lotteryType, $usedConfig, $configType0, float &$playerProfitTotal): void
|
||||||
{
|
{
|
||||||
if (($lotteryType !== 0 && $lotteryType !== 1) || $usedConfig === null || $configType0 === null || !isset($row['win_coin'])) {
|
if (($lotteryType !== 0 && $lotteryType !== 1) || $usedConfig === null || $configType0 === null || !isset($row['win_coin'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((int) $usedConfig->id === (int) $configType0->id) {
|
$winCoin = (float) $row['win_coin'];
|
||||||
$winCoin = (float) $row['win_coin'];
|
$playerProfitTotal += $lotteryType === 0 ? ($winCoin - 100.0) : $winCoin;
|
||||||
$playerProfitTotal += $lotteryType === 0 ? ($winCoin - 100.0) : $winCoin;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function aggregate(array $row, array &$resultCounts, array &$tierCounts): void
|
private function aggregate(array $row, array &$resultCounts, array &$tierCounts): void
|
||||||
|
|||||||
Reference in New Issue
Block a user