refactor(batch): 去重阻断warning组装提炼BatchDispatchWarning并加单测
This commit is contained in:
@@ -1632,22 +1632,14 @@ class PlatformOrderController extends Controller
|
||||
$existing = (string) (\App\Support\BatchDispatchLock::getExistingValue($lockKey) ?? '');
|
||||
$existing = trim($existing);
|
||||
|
||||
$warningMsg = '检测到刚刚已提交过同一批次的 BAS 任务(1 分钟内)。为避免重复投递,本次未再次提交。';
|
||||
$flash = \App\Support\BatchDispatchWarning::build('BAS ', $existing, 'bas');
|
||||
|
||||
// 若锁内已有 run_id(作为 value 存储),则在提示中带出 run_id(短展示)并给运营一个直达复盘入口。
|
||||
if ($existing !== '' && str_starts_with($existing, 'BAS')) {
|
||||
$display = \App\Support\RunId::short((string) $existing, 6, 4);
|
||||
$warningMsg = '检测到刚刚已提交过同一批次的 BAS 任务(1 分钟内,run_id=' . $display . ')。为避免重复投递,本次未再次提交。';
|
||||
}
|
||||
$res = redirect()->back()->with('warning', (string) ($flash['warning'] ?? ''));
|
||||
|
||||
$res = redirect()->back()->with('warning', $warningMsg);
|
||||
|
||||
if ($existing !== '' && str_starts_with($existing, 'BAS')) {
|
||||
$res = $res
|
||||
->with('warning_link_href', '/admin/platform-batches/show?type=bas&run_id=' . urlencode($existing))
|
||||
->with('warning_link_label', '进入上次批次复盘')
|
||||
->with('warning_copy_text', $existing)
|
||||
->with('warning_copy_label', '复制run_id');
|
||||
foreach (['warning_link_href', 'warning_link_label', 'warning_copy_text', 'warning_copy_label'] as $k) {
|
||||
if (isset($flash[$k]) && (string) $flash[$k] !== '') {
|
||||
$res = $res->with($k, (string) $flash[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
@@ -1793,21 +1785,14 @@ class PlatformOrderController extends Controller
|
||||
$existing = (string) (\App\Support\BatchDispatchLock::getExistingValue($lockKey) ?? '');
|
||||
$existing = trim($existing);
|
||||
|
||||
$warningMsg = '检测到刚刚已提交过同一批次的 BMPA 任务(1 分钟内)。为避免重复投递,本次未再次提交。';
|
||||
$flash = \App\Support\BatchDispatchWarning::build('BMPA ', $existing, 'bmpa');
|
||||
|
||||
if ($existing !== '' && str_starts_with($existing, 'BMPA')) {
|
||||
$display = \App\Support\RunId::short((string) $existing, 7, 4);
|
||||
$warningMsg = '检测到刚刚已提交过同一批次的 BMPA 任务(1 分钟内,run_id=' . $display . ')。为避免重复投递,本次未再次提交。';
|
||||
}
|
||||
$res = redirect()->back()->with('warning', (string) ($flash['warning'] ?? ''));
|
||||
|
||||
$res = redirect()->back()->with('warning', $warningMsg);
|
||||
|
||||
if ($existing !== '' && str_starts_with($existing, 'BMPA')) {
|
||||
$res = $res
|
||||
->with('warning_link_href', '/admin/platform-batches/show?type=bmpa&run_id=' . urlencode($existing))
|
||||
->with('warning_link_label', '进入上次批次复盘')
|
||||
->with('warning_copy_text', $existing)
|
||||
->with('warning_copy_label', '复制run_id');
|
||||
foreach (['warning_link_href', 'warning_link_label', 'warning_copy_text', 'warning_copy_label'] as $k) {
|
||||
if (isset($flash[$k]) && (string) $flash[$k] !== '') {
|
||||
$res = $res->with($k, (string) $flash[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
return $res;
|
||||
|
||||
Reference in New Issue
Block a user