IVdaOrderGateService.cs
3.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
using Rcs.Domain.Entities;
namespace Rcs.Application.Services.Protocol;
public enum VdaOrderChannel
{
Normal = 0,
Yield = 1
}
public enum VdaOrderSessionStatus
{
Sending = 0,
Sent = 1,
Failed = 2,
Completed = 3
}
public interface IVdaOrderGateLease : IAsyncDisposable
{
Guid RobotId { get; }
string GateKey { get; }
}
public sealed class VdaOrderGateSession
{
public Guid RobotId { get; set; }
public VdaOrderChannel Channel { get; set; }
public string OrderId { get; set; } = string.Empty;
public int OrderUpdateId { get; set; }
public VdaOrderSessionStatus Status { get; set; }
public DateTime UpdatedAt { get; set; }
public string? PrecheckReason { get; set; }
}
public sealed class VdaOrderGateAcquireResult
{
public bool Success { get; init; }
public string Message { get; init; } = string.Empty;
public string GateKey { get; init; } = string.Empty;
public IVdaOrderGateLease? Lease { get; init; }
public VdaOrderGateSession? CurrentSession { get; init; }
}
public sealed class VdaOrderUpdatePrecheckResult
{
public bool Success { get; init; }
public string Reason { get; init; } = string.Empty;
public RobotStatus? RobotStatus { get; init; }
public string? CurrentOrderId { get; init; }
public uint? CurrentOrderUpdateId { get; init; }
public DateTime? StateTimestampUtc { get; init; }
}
public interface IVdaOrderGateService
{
Task<VdaOrderGateAcquireResult> TryAcquireAsync(
Guid robotId,
VdaOrderChannel channel,
string orderId,
int orderUpdateId,
CancellationToken ct = default);
Task MarkSessionSendingAsync(
Guid robotId,
VdaOrderChannel channel,
string orderId,
int orderUpdateId,
string? precheckReason = null,
CancellationToken ct = default);
Task MarkSessionSentAsync(
Guid robotId,
VdaOrderChannel channel,
string orderId,
int orderUpdateId,
CancellationToken ct = default);
Task MarkSessionFailedAsync(
Guid robotId,
VdaOrderChannel channel,
string orderId,
int orderUpdateId,
string? precheckReason = null,
CancellationToken ct = default);
Task MarkSessionCompletedAsync(
Guid robotId,
VdaOrderChannel channel,
string orderId,
int orderUpdateId,
CancellationToken ct = default);
Task<VdaOrderGateSession?> GetSessionAsync(Guid robotId, CancellationToken ct = default);
Task<bool> HasActiveYieldSessionAsync(
Guid robotId,
string? currentOrderId,
uint? currentOrderUpdateId,
string? lastNodeCode,
CancellationToken ct = default);
Task<VdaOrderUpdatePrecheckResult> ValidateOrderUpdatePrecheckAsync(
Guid robotId,
VdaOrderChannel channel,
string? manufacturer,
string serialNumber,
string orderId,
int orderUpdateId,
CancellationToken ct = default);
Task<int> RegisterNormalPrecheckFailureAsync(
Guid robotId,
string? precheckReason,
CancellationToken ct = default);
Task ResetNormalPrecheckFailuresAsync(Guid robotId, CancellationToken ct = default);
Task ClearSessionAsync(Guid robotId, CancellationToken ct = default);
Task RecordOrderUpdateDowngradeAsync(
Guid robotId,
VdaOrderChannel channel,
string orderId,
int orderUpdateId,
string? precheckReason,
CancellationToken ct = default);
Task RecordOrderRecoveryResetAsync(
Guid robotId,
string orderId,
string? precheckReason,
CancellationToken ct = default);
}