feat(fulfillment): 接入Rock发货平台(0666.pro)代理履约、通用库存池与UID强一致风控
1. 数据库新增 012_rock_fulfillment 迁移,创建 rock_configs 配置表与 rock_tokens 通用库存表,补齐黑色ROCK长袖T恤与蓝色运动服上衣商品目录; 2. 封装 RockClient 与 RockService,实现 0666.pro 平台 Bearer Token 极简连通校验、批量采购50个入库、水位监控巡检与自动补货; 3. 新增 RockProvider 实现标准履约路由,引入 Anti-Ghost 旧绑定基线比对与 UID 强一致门禁,扫错号硬阻断并记录为 mismatch 状态; 4. 针对黑色ROCK与蓝色运动服实现动态发货(绑定后发货前动态选择 skin),并提取腾讯官方发货流水号 fulfillId 对账; 5. 新增全局自动发货总开关(Kill Switch),支持一键软熔断降级转人工接单处理; 6. 前端新增 PlatformRock 管理大屏,提供总开关切换、Token配置与连通测试、库存监控、一键补货及错单解冻重置。
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Rock 相关常量
|
||||
const (
|
||||
RockColorBlack = "black"
|
||||
RockColorBlue = "blue"
|
||||
|
||||
RockStatusAvailable = "available" // 可用库存
|
||||
RockStatusUsing = "using" // 已分配给订单,正在提货扫码
|
||||
RockStatusBound = "bound" // 扫码绑定成功
|
||||
RockStatusRedeemed = "redeemed" // 发货完成
|
||||
RockStatusMismatch = "mismatch" // UID 校验不符阻断(绑错)
|
||||
RockStatusAbnormal = "abnormal" // 异常/作废
|
||||
|
||||
RockSKUBlackTshirt = "rock_black_tshirt"
|
||||
RockSKUBlueSportswear = "rock_blue_sportswear"
|
||||
|
||||
RockSkinBlackTshirt = "黑色ROCK长袖T恤"
|
||||
RockSkinBlueSportswear = "蓝色运动服上衣"
|
||||
)
|
||||
|
||||
// RockConfig 平台配置项
|
||||
type RockConfig struct {
|
||||
ID uint `gorm:"primaryKey;default:1" json:"id"`
|
||||
AutoDeliveryEnabled bool `gorm:"not null;default:true" json:"auto_delivery_enabled"` // 全局自动发货总开关
|
||||
BaseURL string `gorm:"size:255;not null;default:'https://0666.pro'" json:"base_url"`
|
||||
BearerToken string `gorm:"type:text;not null;default:''" json:"bearer_token"`
|
||||
Username string `gorm:"size:128;not null;default:''" json:"username"`
|
||||
Points float64 `gorm:"type:numeric(12,2);not null;default:0.00" json:"points"`
|
||||
MinPointsWarning float64 `gorm:"type:numeric(12,2);not null;default:1050.00" json:"min_points_warning"`
|
||||
TokenWarningStock int `gorm:"not null;default:10" json:"token_warning_stock"`
|
||||
AutoPurchaseEnabled bool `gorm:"not null;default:false" json:"auto_purchase_enabled"`
|
||||
AutoPurchaseCount int `gorm:"not null;default:50" json:"auto_purchase_count"`
|
||||
PurchaseCooldownMinutes int `gorm:"not null;default:10" json:"purchase_cooldown_minutes"`
|
||||
LastPurchasedAt *time.Time `json:"last_purchased_at"`
|
||||
LastHeartbeatAt *time.Time `json:"last_heartbeat_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (RockConfig) TableName() string {
|
||||
return "rock_configs"
|
||||
}
|
||||
|
||||
// RockToken 通用 Token 本地库存池记录
|
||||
type RockToken struct {
|
||||
ID uint `gorm:"primaryKey" json:"id"`
|
||||
UpstreamTokenID string `gorm:"size:64;not null;default:''" json:"upstream_token_id"`
|
||||
Token string `gorm:"type:text;not null" json:"-"`
|
||||
RedeemCode string `gorm:"size:64;not null;index" json:"redeem_code"`
|
||||
Color string `gorm:"size:32;not null;default:'black';index" json:"color"`
|
||||
Region string `gorm:"size:64;not null;default:'Q/V可用'" json:"region"`
|
||||
Status string `gorm:"size:32;not null;default:'available';index" json:"status"`
|
||||
AssignedOrderNo string `gorm:"size:128;index" json:"assigned_order_no"`
|
||||
ExpectedUID string `gorm:"size:64" json:"expected_uid"`
|
||||
ActualRoleName string `gorm:"size:128" json:"actual_role_name"`
|
||||
ActualRoleID string `gorm:"size:64" json:"actual_role_id"`
|
||||
ActualChannel string `gorm:"size:64" json:"actual_channel"`
|
||||
InitialBoundSnapshot string `gorm:"type:text" json:"-"` // 分配时初始旧数据快照 JSON
|
||||
UpstreamFulfillID int64 `json:"upstream_fulfill_id"`
|
||||
TargetSkin string `gorm:"size:128" json:"target_skin"`
|
||||
TargetCurrency string `gorm:"size:64;not null;default:'幸运币'" json:"target_currency"`
|
||||
TargetCurrencyQuantity int `gorm:"not null;default:0" json:"target_currency_quantity"`
|
||||
MismatchAt *time.Time `gorm:"index" json:"mismatch_at"`
|
||||
MismatchReason string `gorm:"size:255" json:"mismatch_reason"`
|
||||
ClaimedAt *time.Time `json:"claimed_at"`
|
||||
BoundAt *time.Time `json:"bound_at"`
|
||||
RedeemedAt *time.Time `json:"redeemed_at"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at"`
|
||||
}
|
||||
|
||||
func (RockToken) TableName() string {
|
||||
return "rock_tokens"
|
||||
}
|
||||
Reference in New Issue
Block a user