Dockerfile

This commit is contained in:
2026-03-18 10:18:03 +08:00
parent 5c5dbc7420
commit b65f3439f3
189 changed files with 19027 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
package public
// MongoDB集合名称常量
const (
AssetCollection = "assets_asset" // 资产集合
CategoryCollection = "assets_category" // 分类集合
PrivateCategoryCollection = "private_category" // 私域分类集合
StockDetailsCollection = "stock_details" // 库存明细集合
StockBatchCollection = "stock_batch" // 库存批次集合
PrivateStockCollection = "private_stock" // 私域库存批次集合
PurchaseOrderCollection = "purchase_order" // 采购订单主表集合(统一模式)
PurchaseOrderItemCollection = "purchase_order_item" // 采购订单明细集合
PurchaseBidCollection = "purchase_bid" // 采购投标单集合(供应商抢单参与记录)
AssetSkuCollection = "asset_sku" // SKU集合
PrivateSkuCollection = "private_sku" // 私域sku集合
SupplierCollection = "supplier" // 供应商集合
ExpiryMessageCollection = "expiry_message" // 临期消息集合(兼容旧数据)
ExpiryMessageHistoryCollection = "expiry_message_history" // 临期消息历史集合(兼容旧数据)
InventoryWarningCollection = "inventory_warning" // 库存预警集合
InventoryWarningHistoryCollection = "inventory_warning_history" // 库存预警历史集合
PurchaseReturnCollection = "purchase_return" // 采购退换单主表集合
PurchaseReturnItemCollection = "purchase_return_item" // 采购退换单明细集合
PurchaseInboundCollection = "purchase_inbound" // 采购入库记录集合
DealerStockCollection = "dealer_stock" // 经销商库存集合
WarehouseCollection = "warehouse" // 仓库集合
ZoneCollection = "zone" // 库区集合
LocationCollection = "location" // 库位集合
InventoryCountCollection = "inventory_count" // 库存盘点主表集合
InventoryCountDetailCollection = "inventory_count_detail" // 库存盘点明细表集合
InventoryCountAdjustHistoryCollection = "inventory_count_adjust_history" // 库存盘点调整历史表集合
UnitConversionCollection = "unit_conversion" // 单位换算集合
)

17
consts/public/currency.go Normal file
View File

@@ -0,0 +1,17 @@
package public
// Currency 货币类型枚举
type Currency string
const (
CurrencyCNY Currency = "CNY" // 人民币
CurrencyUSD Currency = "USD" // 美元
)
// GetAllCurrencies 获取所有货币类型
func GetAllCurrencies() []Currency {
return []Currency{
CurrencyCNY,
CurrencyUSD,
}
}

View File

@@ -0,0 +1,66 @@
package public
import (
"time"
"github.com/gogf/gf/v2/os/gtime"
)
// DurationType 时长类型枚举
type DurationType string
const (
DurationTypeHour DurationType = "hour" // 小时
DurationTypeDay DurationType = "day" // 天
DurationTypeMonth DurationType = "month" // 月
DurationTypeYear DurationType = "year" // 年
)
// GetAllDurationTypes 获取所有时长类型
func GetAllDurationTypes() []DurationType {
return []DurationType{
DurationTypeHour,
DurationTypeDay,
DurationTypeMonth,
DurationTypeYear,
}
}
type DurationTypeKeyValue struct {
Key DurationType // 对应原有常量值
Value string // 对应描述信息
}
// 定义枚举实例Key-Value 绑定),相当于改造后的常量
var (
DurationTypeHourKeyValue = DurationTypeKeyValue{Key: DurationTypeHour, Value: "小时"}
DurationTypeDayKeyValue = DurationTypeKeyValue{Key: DurationTypeDay, Value: "天"}
DurationTypeMonthKeyValue = DurationTypeKeyValue{Key: DurationTypeMonth, Value: "月"}
DurationTypeYearKeyValue = DurationTypeKeyValue{Key: DurationTypeYear, Value: "年"}
)
func GetAllDurationTypeKeyValue() []DurationTypeKeyValue {
return []DurationTypeKeyValue{
DurationTypeHourKeyValue,
DurationTypeDayKeyValue,
DurationTypeMonthKeyValue,
DurationTypeYearKeyValue,
}
}
// AddTime 根据时长类型和数量计算到期时间
func (dt DurationType) AddTime(count int) *gtime.Time {
now := gtime.Now()
switch dt {
case DurationTypeHour:
return gtime.NewFromTime(now.Time.Add(time.Hour * time.Duration(count)))
case DurationTypeDay:
return gtime.NewFromTime(now.Time.AddDate(0, 0, count))
case DurationTypeMonth:
return gtime.NewFromTime(now.Time.AddDate(0, count, 0))
case DurationTypeYear:
return gtime.NewFromTime(now.Time.AddDate(count, 0, 0))
default:
return now
}
}

View File

@@ -0,0 +1,17 @@
package public
const StockDetailLockKey = "stock:lock:skuId-%s"
// 消费者配置(从 Redis Stream 消费请求)
const StockDetailQueueName = "assets:stock:detail:request:stream" // 请求 Stream 键名与发消息的key一致
const StockDetailGroupName = "assets:stock:detail:consumer:group" // 消费者组名
const StockDetailConsumerName = "message-consumer-1" // 消费者名称(唯一标识)
const StockDetailPrefetchCount = 1 // 批处理大小每次读取1条
const StockDetailAutoAck = false // ACK是否自动确认true自动确认false不确认
// 业务自增序列号前缀 Redis Key
const (
StockInventoryNoKeyPrefix = "IC" // 序列号Key前缀如 IC-202602101215-000001
StockInboundNoKeyPrefix = "INB" // 序列号Key前缀如 INB-202602101215-000001
StockBatchNoKeyPrefix = "BATCH" // 序列号Key前缀如 BATCH-202602101215-000001
)

View File

@@ -0,0 +1,145 @@
package public
import "fmt"
// SyncPlatform 同步渠道平台枚举
type SyncPlatform string
const (
SyncPlatformTaobao SyncPlatform = "taobao" // 淘宝
SyncPlatformJD SyncPlatform = "jd" // 京东
SyncPlatformKuaishou SyncPlatform = "kuaishou" // 快手
SyncPlatformDouyin SyncPlatform = "douyin" // 抖音
SyncPlatformXiaohongshu SyncPlatform = "xiaohongshu" // 小红书
SyncPlatformPinduoduo SyncPlatform = "pinduoduo" // 拼多多
SyncPlatformXianyu SyncPlatform = "xianyu" // 闲鱼
SyncPlatformBlockchain SyncPlatform = "blockchain" // 区块链平台
SyncPlatformInternal SyncPlatform = "internal" // 内部平台
)
// SyncStatus 同步状态枚举
type SyncStatus string
const (
SyncStatusPending SyncStatus = "pending" // 等待同步
SyncStatusSyncing SyncStatus = "syncing" // 同步中
SyncStatusSuccess SyncStatus = "success" // 同步成功
SyncStatusFailed SyncStatus = "failed" // 同步失败
)
// SyncType 同步类型
type SyncType string
const (
SyncTypeIncremental SyncType = "incremental" // 增量同步
)
// PlatformSyncConfig 平台同步配置结构
type PlatformSyncConfig struct {
Platform SyncPlatform // 平台名称
IsEnabled bool // 是否启用
SyncInterval int // 同步间隔(秒)
BatchSize int // 批量同步数量
MaxRetries int // 最大重试次数
APIEndpoint string // API端点地址
Description string // 平台描述
}
// GetPlatformSyncConfig 获取平台默认同步配置
func GetPlatformSyncConfig(platform SyncPlatform) (PlatformSyncConfig, error) {
switch platform {
case SyncPlatformTaobao:
return PlatformSyncConfig{
Platform: SyncPlatformTaobao,
IsEnabled: true,
SyncInterval: 300, // 5分钟
BatchSize: 50, // 淘宝API限制较严
MaxRetries: 3,
APIEndpoint: "https://eco.taobao.com/router/rest",
Description: "淘宝电商平台API限制严格",
}, nil
case SyncPlatformJD:
return PlatformSyncConfig{
Platform: SyncPlatformJD,
IsEnabled: true,
SyncInterval: 240, // 4分钟
BatchSize: 100, // 京东API支持较大批次
MaxRetries: 3,
APIEndpoint: "https://api.jd.com/routerjson",
Description: "京东电商平台API相对稳定",
}, nil
case SyncPlatformKuaishou:
return PlatformSyncConfig{
Platform: SyncPlatformKuaishou,
IsEnabled: true,
SyncInterval: 180, // 3分钟直播数据更新快
BatchSize: 80,
MaxRetries: 2, // 快手API相对不稳定
APIEndpoint: "https://open.kuaishou.com/api",
Description: "快手直播平台,数据更新频繁",
}, nil
case SyncPlatformDouyin:
return PlatformSyncConfig{
Platform: SyncPlatformDouyin,
IsEnabled: true,
SyncInterval: 120, // 2分钟内容更新非常频繁
BatchSize: 60,
MaxRetries: 3,
APIEndpoint: "https://open.douyin.com/api",
Description: "抖音短视频平台,实时性要求高",
}, nil
case SyncPlatformXiaohongshu:
return PlatformSyncConfig{
Platform: SyncPlatformXiaohongshu,
IsEnabled: true,
SyncInterval: 300, // 5分钟
BatchSize: 40, // 小红书API限制严格
MaxRetries: 2,
APIEndpoint: "https://open.xiaohongshu.com/api",
Description: "小红书内容平台API调用频率限制严格",
}, nil
case SyncPlatformPinduoduo:
return PlatformSyncConfig{
Platform: SyncPlatformPinduoduo,
IsEnabled: true,
SyncInterval: 360, // 6分钟避免频率限制
BatchSize: 120, // 拼多多支持大批次
MaxRetries: 3,
APIEndpoint: "https://open.pinduoduo.com/api",
Description: "拼多多电商平台,需要控制调用频率",
}, nil
case SyncPlatformXianyu:
return PlatformSyncConfig{
Platform: SyncPlatformXianyu,
IsEnabled: false, // 默认关闭
SyncInterval: 600, // 10分钟闲鱼更新较慢
BatchSize: 30,
MaxRetries: 1,
APIEndpoint: "https://api.xianyu.com/api",
Description: "闲鱼二手平台,数据更新较慢,谨慎使用",
}, nil
case SyncPlatformBlockchain:
return PlatformSyncConfig{
Platform: SyncPlatformBlockchain,
IsEnabled: true,
SyncInterval: 60, // 1分钟需要高实时性
BatchSize: 20, // 区块链数据复杂,减小批次
MaxRetries: 5, // 区块链网络可能不稳定
APIEndpoint: "https://api.blockchain.com/api",
Description: "区块链平台,数据需要高实时性和稳定性",
}, nil
case SyncPlatformInternal:
return PlatformSyncConfig{
Platform: SyncPlatformInternal,
IsEnabled: true,
SyncInterval: 30, // 30秒内部系统实时性高
BatchSize: 200, // 内部系统支持大批次
MaxRetries: 1, // 内部系统稳定
APIEndpoint: "http://localhost:3004/api",
Description: "内部系统平台,高实时性和大批次处理能力",
}, nil
default:
// 返回错误,未知平台
return PlatformSyncConfig{}, fmt.Errorf("unsupported sync platform: %s", platform)
}
}