- Mock Ozon Seller API endpoints - Products, Postings, Finance, Returns, Analytics - JSON fixtures for testing - Docker support - Gitea Actions CI/CD
243 lines
7.3 KiB
Go
243 lines
7.3 KiB
Go
package handlers
|
|
|
|
import (
|
|
"log"
|
|
"os"
|
|
)
|
|
|
|
func GetStocksFixtures() []StockItem {
|
|
data := []StockItem{
|
|
{ProductID: 99001234001, OfferID: "TEST-SKU-001", Stock: 150, WarehouseID: 99100001001, WarehouseName: "Moscow FBO"},
|
|
{ProductID: 99001234002, OfferID: "TEST-SKU-002", Stock: 75, WarehouseID: 99100001001, WarehouseName: "Moscow FBO"},
|
|
{ProductID: 99001234003, OfferID: "TEST-SKU-003", Stock: 200, WarehouseID: 99100001002, WarehouseName: "St. Petersburg FBO"},
|
|
{ProductID: 99001234004, OfferID: "TEST-SKU-004", Stock: 0, WarehouseID: 99100001003, WarehouseName: "Kazan FBO"},
|
|
{ProductID: 99001234005, OfferID: "TEST-SKU-005", Stock: 50, WarehouseID: 99100001001, WarehouseName: "Moscow FBO"},
|
|
}
|
|
|
|
// Try to load from file if exists
|
|
if dataStr := os.Getenv("MOCK_STOCKS_JSON"); dataStr != "" {
|
|
log.Printf("MOCK_STOCKS_JSON is set, ignoring fixtures")
|
|
}
|
|
|
|
return data
|
|
}
|
|
|
|
func GetProductsFixtures() []ProductInfoItem {
|
|
return []ProductInfoItem{
|
|
{
|
|
ProductID: 99001234001,
|
|
OfferID: "TEST-SKU-001",
|
|
Name: "Тестовый товар 1",
|
|
Barcode: "4600000000001",
|
|
BuyPrice: 1000.00,
|
|
Price: 1990.00,
|
|
PremiumPrice: 2190.00,
|
|
CategoryID: 17000000,
|
|
},
|
|
{
|
|
ProductID: 99001234002,
|
|
OfferID: "TEST-SKU-002",
|
|
Name: "Тестовый товар 2",
|
|
Barcode: "4600000000002",
|
|
BuyPrice: 500.00,
|
|
Price: 990.00,
|
|
PremiumPrice: 1090.00,
|
|
CategoryID: 17000001,
|
|
},
|
|
{
|
|
ProductID: 99001234003,
|
|
OfferID: "TEST-SKU-003",
|
|
Name: "Тестовый товар 3",
|
|
Barcode: "4600000000003",
|
|
BuyPrice: 2000.00,
|
|
Price: 3990.00,
|
|
PremiumPrice: 4390.00,
|
|
CategoryID: 17000000,
|
|
},
|
|
{
|
|
ProductID: 99001234004,
|
|
OfferID: "TEST-SKU-004",
|
|
Name: "Тестовый товар 4",
|
|
Barcode: "4600000000004",
|
|
BuyPrice: 300.00,
|
|
Price: 590.00,
|
|
PremiumPrice: 650.00,
|
|
CategoryID: 17000002,
|
|
},
|
|
{
|
|
ProductID: 99001234005,
|
|
OfferID: "TEST-SKU-005",
|
|
Name: "Тестовый товар 5",
|
|
Barcode: "4600000000005",
|
|
BuyPrice: 800.00,
|
|
Price: 1590.00,
|
|
PremiumPrice: 1750.00,
|
|
CategoryID: 17000001,
|
|
},
|
|
}
|
|
}
|
|
|
|
func GetPricesFixtures() []ProductPriceItem {
|
|
return []ProductPriceItem{
|
|
{OfferID: "TEST-SKU-001", Price: 1990.00, OldPrice: 2190.00, PremiumPrice: 2190.00, PremiumPriceOld: 2390.00},
|
|
{OfferID: "TEST-SKU-002", Price: 990.00, OldPrice: 1090.00, PremiumPrice: 1090.00, PremiumPriceOld: 1190.00},
|
|
{OfferID: "TEST-SKU-003", Price: 3990.00, OldPrice: 4490.00, PremiumPrice: 4390.00, PremiumPriceOld: 4890.00},
|
|
{OfferID: "TEST-SKU-004", Price: 590.00, OldPrice: 690.00, PremiumPrice: 650.00, PremiumPriceOld: 750.00},
|
|
{OfferID: "TEST-SKU-005", Price: 1590.00, OldPrice: 1790.00, PremiumPrice: 1750.00, PremiumPriceOld: 1950.00},
|
|
}
|
|
}
|
|
|
|
func GetPostingsFixtures() []Posting {
|
|
return []Posting{
|
|
{
|
|
PostingNumber: "TEST-POST-001",
|
|
OrderID: 99000000001,
|
|
OrderNumber: "TEST-ORD-001",
|
|
Status: "delivered",
|
|
Products: []PostingItem{
|
|
{ProductID: 99001234001, OfferID: "TEST-SKU-001", Name: "Тестовый товар 1", Quantity: 2, Price: 1990.00, ItemsCount: 1},
|
|
},
|
|
CreatedAt: "2024-01-15T10:30:00Z",
|
|
UpdatedAt: "2024-01-17T14:45:00Z",
|
|
WarehouseID: 99100001001,
|
|
OrderType: "fbs",
|
|
},
|
|
{
|
|
PostingNumber: "TEST-POST-002",
|
|
OrderID: 99000000002,
|
|
OrderNumber: "TEST-ORD-002",
|
|
Status: "delivered",
|
|
Products: []PostingItem{
|
|
{ProductID: 99001234002, OfferID: "TEST-SKU-002", Name: "Тестовый товар 2", Quantity: 1, Price: 990.00, ItemsCount: 1},
|
|
{ProductID: 99001234003, OfferID: "TEST-SKU-003", Name: "Тестовый товар 3", Quantity: 1, Price: 3990.00, ItemsCount: 1},
|
|
},
|
|
CreatedAt: "2024-01-16T11:00:00Z",
|
|
UpdatedAt: "2024-01-18T09:30:00Z",
|
|
WarehouseID: 99100001001,
|
|
OrderType: "fbs",
|
|
},
|
|
{
|
|
PostingNumber: "TEST-POST-003",
|
|
OrderID: 99000000003,
|
|
OrderNumber: "TEST-ORD-003",
|
|
Status: "awaiting_deliver",
|
|
Products: []PostingItem{
|
|
{ProductID: 99001234004, OfferID: "TEST-SKU-004", Name: "Тестовый товар 4", Quantity: 3, Price: 590.00, ItemsCount: 1},
|
|
},
|
|
CreatedAt: "2024-01-18T08:15:00Z",
|
|
UpdatedAt: "2024-01-18T08:15:00Z",
|
|
WarehouseID: 99100001002,
|
|
OrderType: "fbs",
|
|
},
|
|
{
|
|
PostingNumber: "TEST-POST-004",
|
|
OrderID: 99000000004,
|
|
OrderNumber: "TEST-ORD-004",
|
|
Status: "cancelled",
|
|
Products: []PostingItem{
|
|
{ProductID: 99001234005, OfferID: "TEST-SKU-005", Name: "Тестовый товар 5", Quantity: 1, Price: 1590.00, ItemsCount: 1},
|
|
},
|
|
CreatedAt: "2024-01-17T16:00:00Z",
|
|
UpdatedAt: "2024-01-17T18:30:00Z",
|
|
WarehouseID: 99100001001,
|
|
OrderType: "fbs",
|
|
},
|
|
}
|
|
}
|
|
|
|
func GetReturnsFixtures() []Return {
|
|
return []Return{
|
|
{
|
|
ReturnID: 99000001,
|
|
PostingNumber: "TEST-POST-001",
|
|
Status: "completed",
|
|
Reason: "wrong_item",
|
|
ReasonID: 10,
|
|
CreatedAt: "2024-01-20T10:00:00Z",
|
|
DeliveredAt: "2024-01-22T15:00:00Z",
|
|
Items: []ReturnItem{
|
|
{ProductID: 99001234001, OfferID: "TEST-SKU-001", Name: "Тестовый товар 1", Quantity: 1, IsOptional: false},
|
|
},
|
|
},
|
|
{
|
|
ReturnID: 99000002,
|
|
PostingNumber: "TEST-POST-002",
|
|
Status: "pending",
|
|
Reason: "buyer_remorse",
|
|
ReasonID: 20,
|
|
CreatedAt: "2024-01-21T14:30:00Z",
|
|
Items: []ReturnItem{
|
|
{ProductID: 99001234002, OfferID: "TEST-SKU-002", Name: "Тестовый товар 2", Quantity: 1, IsOptional: true},
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
func GetTransactionsFixtures() []Transaction {
|
|
return []Transaction{
|
|
{
|
|
TransactionType: "orders",
|
|
Amount: 3980.00,
|
|
CurrencyCode: "RUB",
|
|
PostingNumber: "TEST-POST-001",
|
|
OrderID: 99000000001,
|
|
CreatedAt: "2024-01-17T00:00:00Z",
|
|
Items: []TransactionItem{
|
|
{Type: "sale", Amount: 1990.00, Quantity: 1, ProductID: 99001234001, OfferID: "TEST-SKU-001"},
|
|
{Type: "sale", Amount: 1990.00, Quantity: 1, ProductID: 99001234001, OfferID: "TEST-SKU-001"},
|
|
},
|
|
},
|
|
{
|
|
TransactionType: "orders",
|
|
Amount: 4980.00,
|
|
CurrencyCode: "RUB",
|
|
PostingNumber: "TEST-POST-002",
|
|
OrderID: 99000000002,
|
|
CreatedAt: "2024-01-18T00:00:00Z",
|
|
Items: []TransactionItem{
|
|
{Type: "sale", Amount: 990.00, Quantity: 1, ProductID: 99001234002, OfferID: "TEST-SKU-002"},
|
|
{Type: "sale", Amount: 3990.00, Quantity: 1, ProductID: 99001234003, OfferID: "TEST-SKU-003"},
|
|
},
|
|
},
|
|
{
|
|
TransactionType: "commission",
|
|
Amount: -597.00,
|
|
CurrencyCode: "RUB",
|
|
PostingNumber: "TEST-POST-001",
|
|
OrderID: 99000000001,
|
|
CreatedAt: "2024-01-17T00:00:00Z",
|
|
},
|
|
{
|
|
TransactionType: "refund",
|
|
Amount: -990.00,
|
|
CurrencyCode: "RUB",
|
|
PostingNumber: "TEST-POST-004",
|
|
OrderID: 99000000004,
|
|
CreatedAt: "2024-01-17T00:00:00Z",
|
|
},
|
|
}
|
|
}
|
|
|
|
func GetPayoutsFixtures() []Payout {
|
|
return []Payout{
|
|
{
|
|
PayoutID: 99001,
|
|
Type: "payout",
|
|
Status: "completed",
|
|
Amount: 15000.00,
|
|
CurrencyCode: "RUB",
|
|
CreatedAt: "2024-01-15T00:00:00Z",
|
|
OperationsCount: 10,
|
|
},
|
|
{
|
|
PayoutID: 99002,
|
|
Type: "payout",
|
|
Status: "completed",
|
|
Amount: 22500.00,
|
|
CurrencyCode: "RUB",
|
|
CreatedAt: "2024-01-22T00:00:00Z",
|
|
OperationsCount: 15,
|
|
},
|
|
}
|
|
}
|