- 整理sync.go
This commit is contained in:
@@ -211,9 +211,32 @@ func RegisterPurchasePlatform(handler IPurchasePlatformHandler) {
|
||||
if _, ok := PurchasePlatformHandlers[vendorID]; ok {
|
||||
panic(fmt.Sprintf("purchase vendor:%d, already exists", vendorID))
|
||||
}
|
||||
_, isSingleStore := handler.(ISingleStoreHandler)
|
||||
_, isMultiStore := handler.(IMultipleStoresHandler)
|
||||
if !isSingleStore && !isMultiStore {
|
||||
panic(fmt.Sprintf("platform:%d type is wrong!", vendorID))
|
||||
}
|
||||
PurchasePlatformHandlers[vendorID] = handler
|
||||
}
|
||||
|
||||
func GetPurchasePlatformFromVendorID(vendorID int) IPurchasePlatformHandler {
|
||||
return PurchasePlatformHandlers[vendorID]
|
||||
}
|
||||
|
||||
func GetMultiStoreVendorIDs() (vendorIDs []int) {
|
||||
for k, v := range PurchasePlatformHandlers {
|
||||
if _, ok := v.(IMultipleStoresHandler); ok {
|
||||
vendorIDs = append(vendorIDs, k)
|
||||
}
|
||||
}
|
||||
return vendorIDs
|
||||
}
|
||||
|
||||
func GetSingleStoreVendorIDs() (vendorIDs []int) {
|
||||
for k, v := range PurchasePlatformHandlers {
|
||||
if _, ok := v.(ISingleStoreHandler); !ok {
|
||||
vendorIDs = append(vendorIDs, k)
|
||||
}
|
||||
}
|
||||
return vendorIDs
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user