优化导入权重测试数据
This commit is contained in:
@@ -37,6 +37,7 @@ use think\model\relation\HasMany;
|
||||
* @property array $result_counts 落点统计 grid_number=>出现次数
|
||||
* @property array|null $tier_counts 档位出现次数 T1=>count
|
||||
* @property float|null $platform_profit 平台赚取金额(付费抽取次数×100-玩家总收益)
|
||||
* @property array|null $bigwin_weight 测试时 BIGWIN 档位权重快照(JSON:grid_number=>weight)
|
||||
* @property int|null $admin_id 执行测试的管理员ID
|
||||
* @property string|null $create_time 创建时间
|
||||
*/
|
||||
@@ -55,7 +56,7 @@ class DiceRewardConfigRecord extends BaseModel
|
||||
|
||||
protected $table = 'dice_reward_config_record';
|
||||
|
||||
protected $json = ['weight_config_snapshot', 'tier_weights_snapshot', 'result_counts', 'tier_counts', 'paid_tier_weights', 'free_tier_weights'];
|
||||
protected $json = ['weight_config_snapshot', 'tier_weights_snapshot', 'result_counts', 'tier_counts', 'paid_tier_weights', 'free_tier_weights', 'bigwin_weight'];
|
||||
|
||||
protected $jsonAssoc = true;
|
||||
|
||||
@@ -82,4 +83,31 @@ class DiceRewardConfigRecord extends BaseModel
|
||||
->sum('win_coin');
|
||||
return round($paidCount * 100 - $sumWinCoin, 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据关联的 DicePlayRecordTest 统计落点次数
|
||||
* result_counts = [grid_number => 出现次数],只统计 roll_number 在 5-30 之间的记录
|
||||
* @param int $recordId
|
||||
* @return array<int,int>
|
||||
*/
|
||||
public static function computeResultCountsFromRelated(int $recordId): array
|
||||
{
|
||||
$rows = DicePlayRecordTest::where('reward_config_record_id', $recordId)
|
||||
->where('roll_number', '>=', 5)
|
||||
->where('roll_number', '<=', 30)
|
||||
->field('roll_number, COUNT(*) AS c')
|
||||
->group('roll_number')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$result = [];
|
||||
foreach ($rows as $row) {
|
||||
$grid = (int) ($row['roll_number'] ?? 0);
|
||||
$cnt = (int) ($row['c'] ?? 0);
|
||||
if ($grid > 0 && $cnt > 0) {
|
||||
$result[$grid] = $cnt;
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user