fix: preserve order dispatch mode
This commit is contained in:
@@ -341,7 +341,9 @@ func (s *Store) AutoMatchTaskOrder(ctx context.Context, tenantID, memberID, orde
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if order.AutoDispatch != 1 || time.Now().UTC().Before(matchAt) {
|
dispatchMode, _ := snapshot["dispatch_mode"].(string)
|
||||||
|
isAutoDispatch := dispatchMode == "auto" || dispatchMode == "" && order.AutoDispatch == 1
|
||||||
|
if !isAutoDispatch || time.Now().UTC().Before(matchAt) {
|
||||||
return tx.Commit()
|
return tx.Commit()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -77,6 +77,7 @@ type Order struct {
|
|||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
StatusText string `json:"status_text"`
|
StatusText string `json:"status_text"`
|
||||||
Message string `json:"message"`
|
Message string `json:"message"`
|
||||||
|
DispatchMode string `json:"dispatch_mode,omitempty"`
|
||||||
ScheduledMatchAt string `json:"scheduled_match_at,omitempty"`
|
ScheduledMatchAt string `json:"scheduled_match_at,omitempty"`
|
||||||
DispatchDelay int `json:"dispatch_delay_seconds,omitempty"`
|
DispatchDelay int `json:"dispatch_delay_seconds,omitempty"`
|
||||||
DeadlineAt string `json:"deadline_at"`
|
DeadlineAt string `json:"deadline_at"`
|
||||||
@@ -397,6 +398,7 @@ func orderFromStore(row store.TaskOrder, detail bool) Order {
|
|||||||
DeadlineAt: row.DeadlineAt, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt}
|
DeadlineAt: row.DeadlineAt, CreatedAt: row.CreatedAt, UpdatedAt: row.UpdatedAt}
|
||||||
var snapshot map[string]any
|
var snapshot map[string]any
|
||||||
if json.Unmarshal(row.RuleSnapshot, &snapshot) == nil {
|
if json.Unmarshal(row.RuleSnapshot, &snapshot) == nil {
|
||||||
|
result.DispatchMode, _ = snapshot["dispatch_mode"].(string)
|
||||||
result.ScheduledMatchAt, _ = snapshot["scheduled_match_at"].(string)
|
result.ScheduledMatchAt, _ = snapshot["scheduled_match_at"].(string)
|
||||||
result.DispatchDelay = intValue(snapshot["dispatch_delay_seconds"])
|
result.DispatchDelay = intValue(snapshot["dispatch_delay_seconds"])
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,6 +142,7 @@
|
|||||||
const matchStep = computed(() => (matchProgress.value < 35 ? 0 : matchProgress.value < 60 ? 1 : matchProgress.value < 85 ? 2 : 3));
|
const matchStep = computed(() => (matchProgress.value < 35 ? 0 : matchProgress.value < 60 ? 1 : matchProgress.value < 85 ? 2 : 3));
|
||||||
const matchSteps = ['正在匹配任务', '获取商品信息', '确认任务内容', '发放任务结果'];
|
const matchSteps = ['正在匹配任务', '获取商品信息', '确认任务内容', '发放任务结果'];
|
||||||
const matchingHint = computed(() => {
|
const matchingHint = computed(() => {
|
||||||
|
if (order.value?.dispatch_mode === 'manual') return '订单已领取,正在等待后台匹配...';
|
||||||
if (matchRemainingSeconds.value > 0) return `系统正在派单... ${formatCountdown(matchRemainingSeconds.value)}`;
|
if (matchRemainingSeconds.value > 0) return `系统正在派单... ${formatCountdown(matchRemainingSeconds.value)}`;
|
||||||
return pollFinished.value ? '任务仍在匹配,可稍后前往记录查看' : '系统正在为您匹配任务,请稍等...';
|
return pollFinished.value ? '任务仍在匹配,可稍后前往记录查看' : '系统正在为您匹配任务,请稍等...';
|
||||||
});
|
});
|
||||||
@@ -275,7 +276,9 @@
|
|||||||
if (!order.value?.id) return;
|
if (!order.value?.id) return;
|
||||||
if (pollTimer) window.clearTimeout(pollTimer);
|
if (pollTimer) window.clearTimeout(pollTimer);
|
||||||
const scheduledAt = Date.parse(String(order.value?.scheduled_match_at || ''));
|
const scheduledAt = Date.parse(String(order.value?.scheduled_match_at || ''));
|
||||||
const wait = Number.isFinite(scheduledAt) && scheduledAt > Date.now()
|
const wait = order.value?.dispatch_mode === 'manual'
|
||||||
|
? 10000
|
||||||
|
: Number.isFinite(scheduledAt) && scheduledAt > Date.now()
|
||||||
? scheduledAt - Date.now() + 300
|
? scheduledAt - Date.now() + 300
|
||||||
: 1200;
|
: 1200;
|
||||||
pollTimer = window.setTimeout(async () => {
|
pollTimer = window.setTimeout(async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user