1.优化/dice/reward_config/index页面中的备注根据设置的档位来进行变化
2.检查为什么色子奖励权重有104条显示,应该只有26条(对应色子点数5-30) 3.移除掉所有实际金额在后台的显示
This commit is contained in:
@@ -43,19 +43,21 @@ class DiceRewardLogic
|
||||
$orderField = isset($where['orderField']) && $where['orderField'] !== '' ? (string) $where['orderField'] : 'r.tier';
|
||||
$orderType = isset($where['orderType']) && strtoupper((string) $where['orderType']) === 'DESC' ? 'desc' : 'asc';
|
||||
|
||||
$keepIds = $this->resolveDedupedRewardIdsByGrid($direction, $tier, $adminInfo, $requestDeptId);
|
||||
if ($keepIds === []) {
|
||||
return [
|
||||
'total' => 0,
|
||||
'per_page' => $limit,
|
||||
'current_page' => $page,
|
||||
'data' => [],
|
||||
];
|
||||
}
|
||||
|
||||
$query = DiceReward::alias('r')
|
||||
->where('r.direction', $direction)
|
||||
->whereIn('r.id', $keepIds)
|
||||
->field('r.id,r.tier,r.direction,r.end_index,r.weight,r.grid_number,r.start_index,r.ui_text,r.real_ev,r.remark,r.type,r.create_time,r.update_time')
|
||||
->order($orderField, $orderType)
|
||||
->order('r.end_index', 'asc');
|
||||
|
||||
if ($adminInfo !== null) {
|
||||
AdminScopeHelper::applyConfigScope($query, $adminInfo, $requestDeptId, 'r.dept_id');
|
||||
}
|
||||
|
||||
if ($tier !== '') {
|
||||
$query->where('r.tier', $tier);
|
||||
}
|
||||
->order('r.grid_number', 'asc');
|
||||
|
||||
$paginator = $query->paginate($limit, false, ['page' => $page]);
|
||||
$arr = $paginator->toArray();
|
||||
@@ -81,6 +83,41 @@ class DiceRewardLogic
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表去重:每个方向、每个色子点数(5-30)仅保留一条(取 id 最大),避免历史重复数据导致 104 条
|
||||
* @return int[]
|
||||
*/
|
||||
private function resolveDedupedRewardIdsByGrid(
|
||||
int $direction,
|
||||
string $tier,
|
||||
?array $adminInfo,
|
||||
$requestDeptId
|
||||
): array {
|
||||
$dedupeQuery = DiceReward::alias('rd')
|
||||
->field('MAX(rd.id) AS keep_id')
|
||||
->where('rd.direction', $direction)
|
||||
->whereBetween('rd.grid_number', [5, 30]);
|
||||
|
||||
if ($adminInfo !== null) {
|
||||
AdminScopeHelper::applyConfigScope($dedupeQuery, $adminInfo, $requestDeptId, 'rd.dept_id');
|
||||
}
|
||||
|
||||
if ($tier !== '') {
|
||||
$dedupeQuery->where('rd.tier', $tier);
|
||||
}
|
||||
|
||||
$rows = $dedupeQuery->group('rd.grid_number')->select()->toArray();
|
||||
$ids = [];
|
||||
foreach ($rows as $row) {
|
||||
$id = isset($row['keep_id']) ? (int) $row['keep_id'] : 0;
|
||||
if ($id > 0) {
|
||||
$ids[] = $id;
|
||||
}
|
||||
}
|
||||
|
||||
return $ids;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按单方向批量更新权重(仅更新当前方向的 weight,并刷新缓存)
|
||||
* @param int $direction 0=顺时针 1=逆时针
|
||||
|
||||
Reference in New Issue
Block a user