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()
|
||||
}
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ type Order struct {
|
||||
Status string `json:"status"`
|
||||
StatusText string `json:"status_text"`
|
||||
Message string `json:"message"`
|
||||
DispatchMode string `json:"dispatch_mode,omitempty"`
|
||||
ScheduledMatchAt string `json:"scheduled_match_at,omitempty"`
|
||||
DispatchDelay int `json:"dispatch_delay_seconds,omitempty"`
|
||||
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}
|
||||
var snapshot map[string]any
|
||||
if json.Unmarshal(row.RuleSnapshot, &snapshot) == nil {
|
||||
result.DispatchMode, _ = snapshot["dispatch_mode"].(string)
|
||||
result.ScheduledMatchAt, _ = snapshot["scheduled_match_at"].(string)
|
||||
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 matchSteps = ['正在匹配任务', '获取商品信息', '确认任务内容', '发放任务结果'];
|
||||
const matchingHint = computed(() => {
|
||||
if (order.value?.dispatch_mode === 'manual') return '订单已领取,正在等待后台匹配...';
|
||||
if (matchRemainingSeconds.value > 0) return `系统正在派单... ${formatCountdown(matchRemainingSeconds.value)}`;
|
||||
return pollFinished.value ? '任务仍在匹配,可稍后前往记录查看' : '系统正在为您匹配任务,请稍等...';
|
||||
});
|
||||
@@ -275,7 +276,9 @@
|
||||
if (!order.value?.id) return;
|
||||
if (pollTimer) window.clearTimeout(pollTimer);
|
||||
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
|
||||
: 1200;
|
||||
pollTimer = window.setTimeout(async () => {
|
||||
|
||||
Reference in New Issue
Block a user