feat: complete cmpp platform phases 0-5

This commit is contained in:
hectorzhao
2026-07-01 13:22:04 +08:00
parent 824a8b334f
commit ee926fea04
86 changed files with 10490 additions and 14 deletions
+90
View File
@@ -0,0 +1,90 @@
package queue
import "time"
const SchemaVersion = "v1"
type MessageType string
const (
MessageTypeSubmitCommand MessageType = "SubmitCommand"
MessageTypeSubmitResult MessageType = "SubmitResult"
MessageTypeReceiptEvent MessageType = "ReceiptEvent"
MessageTypeUplinkEvent MessageType = "UplinkEvent"
)
type Envelope struct {
SchemaVersion string `json:"schemaVersion"`
MessageType MessageType `json:"messageType"`
TraceID string `json:"traceId"`
MessageID string `json:"messageId"`
ChannelID string `json:"channelId"`
CreatedAt time.Time `json:"createdAt"`
}
type SubmitCommand struct {
Envelope
TenantID string `json:"tenantId"`
ApplicationID string `json:"applicationId"`
TaskID string `json:"taskId,omitempty"`
SubmitID string `json:"submitId"`
PhoneNumber string `json:"phoneNumber"`
Content string `json:"content"`
Signature string `json:"signature"`
TemplateID string `json:"templateId"`
BillingUnits int `json:"billingUnits"`
Route Route `json:"route"`
CMPP CMPP `json:"cmpp"`
Retry Retry `json:"retry"`
}
type Route struct {
ChannelCode string `json:"channelCode"`
CMPPAccountCode string `json:"cmppAccountCode"`
Priority int `json:"priority"`
RateLimitPerSecond int `json:"rateLimitPerSecond,omitempty"`
}
type CMPP struct {
ServiceID string `json:"serviceId"`
SrcID string `json:"srcId"`
RegisteredDelivery int `json:"registeredDelivery"`
MsgFmt int `json:"msgFmt"`
FeeUserType int `json:"feeUserType,omitempty"`
FeeCode string `json:"feeCode,omitempty"`
FeeType string `json:"feeType,omitempty"`
}
type Retry struct {
Attempt int `json:"attempt"`
MaxAttempts int `json:"maxAttempts"`
}
type SubmitResult struct {
Envelope
SequenceID uint32 `json:"sequenceId"`
GatewayMessageID string `json:"gatewayMessageId"`
SubmitStatus string `json:"submitStatus"`
ErrorCode string `json:"errorCode,omitempty"`
ErrorMessage string `json:"errorMessage,omitempty"`
SubmittedAt time.Time `json:"submittedAt"`
}
type ReceiptEvent struct {
Envelope
SequenceID uint32 `json:"sequenceId"`
GatewayMessageID string `json:"gatewayMessageId"`
ReceiptStatus string `json:"receiptStatus"`
RawStatus string `json:"rawStatus"`
ErrorCode string `json:"errorCode,omitempty"`
DeliveredAt time.Time `json:"deliveredAt"`
}
type UplinkEvent struct {
Envelope
SequenceID uint32 `json:"sequenceId"`
PhoneNumber string `json:"phoneNumber"`
DestID string `json:"destId"`
Content string `json:"content"`
ReceivedAt time.Time `json:"receivedAt"`
}