vantuz 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +45 -0
- package/README.md +44 -0
- package/cli.js +420 -0
- package/core/ai-analyst.js +46 -0
- package/core/database.js +74 -0
- package/core/license-manager.js +50 -0
- package/core/product-manager.js +134 -0
- package/package.json +72 -0
- package/plugins/vantuz/index.js +480 -0
- package/plugins/vantuz/memory/hippocampus.js +464 -0
- package/plugins/vantuz/package.json +21 -0
- package/plugins/vantuz/platforms/amazon.js +239 -0
- package/plugins/vantuz/platforms/ciceksepeti.js +175 -0
- package/plugins/vantuz/platforms/hepsiburada.js +189 -0
- package/plugins/vantuz/platforms/index.js +215 -0
- package/plugins/vantuz/platforms/n11.js +263 -0
- package/plugins/vantuz/platforms/pazarama.js +171 -0
- package/plugins/vantuz/platforms/pttavm.js +136 -0
- package/plugins/vantuz/platforms/trendyol.js +307 -0
- package/plugins/vantuz/services/alerts.js +253 -0
- package/plugins/vantuz/services/license.js +237 -0
- package/plugins/vantuz/services/scheduler.js +232 -0
- package/plugins/vantuz/tools/analytics.js +152 -0
- package/plugins/vantuz/tools/crossborder.js +187 -0
- package/plugins/vantuz/tools/nl-parser.js +211 -0
- package/plugins/vantuz/tools/product.js +110 -0
- package/plugins/vantuz/tools/quick-report.js +175 -0
- package/plugins/vantuz/tools/repricer.js +314 -0
- package/plugins/vantuz/tools/sentiment.js +115 -0
- package/plugins/vantuz/tools/vision.js +257 -0
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🌍 Cross-Border Tool
|
|
3
|
+
* Ürünleri yurt dışı pazarlarına uyarla
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const EXCHANGE_RATES = {
|
|
7
|
+
TRY_EUR: 0.027,
|
|
8
|
+
TRY_USD: 0.029,
|
|
9
|
+
TRY_GBP: 0.023
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const FBA_FEES = {
|
|
13
|
+
de: { base: 3.50, perKg: 0.50, storage: 0.10 },
|
|
14
|
+
us: { base: 3.99, perKg: 0.55, storage: 0.12 },
|
|
15
|
+
uk: { base: 3.20, perKg: 0.45, storage: 0.09 }
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const SHIPPING_COSTS = {
|
|
19
|
+
de: { base: 8.50, perKg: 2.00 },
|
|
20
|
+
us: { base: 15.00, perKg: 3.50 },
|
|
21
|
+
uk: { base: 9.00, perKg: 2.20 }
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const crossborderTool = {
|
|
25
|
+
name: 'crossborder',
|
|
26
|
+
|
|
27
|
+
async execute(params, context) {
|
|
28
|
+
const { api, memory, license } = context;
|
|
29
|
+
const { productId, sourcePlatform = 'trendyol', targetMarket, fulfillment = 'fba' } = params;
|
|
30
|
+
|
|
31
|
+
if (!license.hasFeature('crossborder')) {
|
|
32
|
+
return { success: false, error: 'Cross-Border için lisans gerekli.' };
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Kaynak ürünü al
|
|
36
|
+
const sourceProduct = await this._getSourceProduct(productId, sourcePlatform, api);
|
|
37
|
+
if (!sourceProduct) {
|
|
38
|
+
return { success: false, error: 'Kaynak ürün bulunamadı.' };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Çeviri yap
|
|
42
|
+
const translation = await this._translateProduct(sourceProduct, targetMarket, api);
|
|
43
|
+
|
|
44
|
+
// Maliyet hesapla
|
|
45
|
+
const costs = this._calculateCosts(sourceProduct, targetMarket, fulfillment);
|
|
46
|
+
|
|
47
|
+
// Optimal fiyat belirle
|
|
48
|
+
const pricing = this._calculatePricing(sourceProduct, costs, targetMarket);
|
|
49
|
+
|
|
50
|
+
// Hafızaya kaydet
|
|
51
|
+
await memory.remember('product', {
|
|
52
|
+
type: 'crossborder_preparation',
|
|
53
|
+
sourceProduct: productId,
|
|
54
|
+
targetMarket,
|
|
55
|
+
translation,
|
|
56
|
+
pricing
|
|
57
|
+
}, { productId, targetMarket });
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
success: true,
|
|
61
|
+
source: {
|
|
62
|
+
platform: sourcePlatform,
|
|
63
|
+
name: sourceProduct.name,
|
|
64
|
+
price: `${sourceProduct.price} ₺`
|
|
65
|
+
},
|
|
66
|
+
target: {
|
|
67
|
+
market: targetMarket,
|
|
68
|
+
title: translation.title,
|
|
69
|
+
description: translation.description,
|
|
70
|
+
currency: this._getCurrency(targetMarket)
|
|
71
|
+
},
|
|
72
|
+
costs: {
|
|
73
|
+
productCost: `${costs.productCostForeign.toFixed(2)} ${this._getCurrency(targetMarket)}`,
|
|
74
|
+
shipping: `${costs.shipping.toFixed(2)} ${this._getCurrency(targetMarket)}`,
|
|
75
|
+
fbaFees: fulfillment === 'fba' ? `${costs.fbaFees.toFixed(2)} ${this._getCurrency(targetMarket)}` : 'N/A',
|
|
76
|
+
platformCommission: `${costs.commission.toFixed(2)} ${this._getCurrency(targetMarket)}`,
|
|
77
|
+
totalCost: `${costs.total.toFixed(2)} ${this._getCurrency(targetMarket)}`
|
|
78
|
+
},
|
|
79
|
+
pricing: {
|
|
80
|
+
suggestedPrice: `${pricing.suggested.toFixed(2)} ${this._getCurrency(targetMarket)}`,
|
|
81
|
+
minPrice: `${pricing.min.toFixed(2)} ${this._getCurrency(targetMarket)}`,
|
|
82
|
+
expectedProfit: `${pricing.profit.toFixed(2)} ${this._getCurrency(targetMarket)}`,
|
|
83
|
+
profitMargin: `${pricing.margin.toFixed(0)}%`
|
|
84
|
+
},
|
|
85
|
+
readyToPublish: true,
|
|
86
|
+
nextStep: `"Amazon ${targetMarket.toUpperCase()}'ya yayınla" demek isterseniz otomatik listeleyebilirim.`
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
async _getSourceProduct(productId, platform, api) {
|
|
91
|
+
// TODO: Platform API'sinden ürün bilgisi al
|
|
92
|
+
return {
|
|
93
|
+
id: productId,
|
|
94
|
+
name: 'Kadın Basic Tişört - Kırmızı',
|
|
95
|
+
description: '%100 Pamuklu, V Yaka, rahat kesim kadın tişört.',
|
|
96
|
+
price: 349,
|
|
97
|
+
weight: 0.3, // kg
|
|
98
|
+
category: 'Kadın > Giyim > Tişört',
|
|
99
|
+
images: ['https://example.com/image.jpg']
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
async _translateProduct(product, targetMarket, api) {
|
|
104
|
+
const languages = {
|
|
105
|
+
de: 'Almanca',
|
|
106
|
+
us: 'İngilizce (Amerikan)',
|
|
107
|
+
uk: 'İngilizce (İngiliz)',
|
|
108
|
+
fr: 'Fransızca'
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
// TODO: AI ile çeviri
|
|
112
|
+
const translations = {
|
|
113
|
+
de: {
|
|
114
|
+
title: 'Damen Basic T-Shirt - Rot',
|
|
115
|
+
description: '100% Baumwolle, V-Ausschnitt, bequeme Passform Damen T-Shirt.'
|
|
116
|
+
},
|
|
117
|
+
us: {
|
|
118
|
+
title: "Women's Basic T-Shirt - Red",
|
|
119
|
+
description: '100% Cotton, V-Neck, comfortable fit women\'s t-shirt.'
|
|
120
|
+
},
|
|
121
|
+
uk: {
|
|
122
|
+
title: "Ladies Basic T-Shirt - Red",
|
|
123
|
+
description: '100% Cotton, V-Neck, comfortable fit ladies t-shirt.'
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
return translations[targetMarket] || translations.us;
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
_calculateCosts(product, targetMarket, fulfillment) {
|
|
131
|
+
const rate = this._getExchangeRate(targetMarket);
|
|
132
|
+
const fbaFee = FBA_FEES[targetMarket] || FBA_FEES.de;
|
|
133
|
+
const shippingCost = SHIPPING_COSTS[targetMarket] || SHIPPING_COSTS.de;
|
|
134
|
+
|
|
135
|
+
const productCostForeign = product.price * rate;
|
|
136
|
+
const shipping = shippingCost.base + (product.weight * shippingCost.perKg);
|
|
137
|
+
const fbaFees = fulfillment === 'fba'
|
|
138
|
+
? fbaFee.base + (product.weight * fbaFee.perKg)
|
|
139
|
+
: 0;
|
|
140
|
+
const commission = productCostForeign * 0.15; // Amazon komisyonu ~15%
|
|
141
|
+
|
|
142
|
+
return {
|
|
143
|
+
productCostForeign,
|
|
144
|
+
shipping,
|
|
145
|
+
fbaFees,
|
|
146
|
+
commission,
|
|
147
|
+
total: productCostForeign + shipping + fbaFees + commission
|
|
148
|
+
};
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
_calculatePricing(product, costs, targetMarket) {
|
|
152
|
+
const minMargin = 0.20; // Minimum %20 kar
|
|
153
|
+
const targetMargin = 0.35; // Hedef %35 kar
|
|
154
|
+
|
|
155
|
+
const minPrice = costs.total * (1 + minMargin);
|
|
156
|
+
const suggested = costs.total * (1 + targetMargin);
|
|
157
|
+
const profit = suggested - costs.total;
|
|
158
|
+
const margin = (profit / suggested) * 100;
|
|
159
|
+
|
|
160
|
+
return {
|
|
161
|
+
min: minPrice,
|
|
162
|
+
suggested,
|
|
163
|
+
profit,
|
|
164
|
+
margin
|
|
165
|
+
};
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
_getExchangeRate(targetMarket) {
|
|
169
|
+
const rates = {
|
|
170
|
+
de: EXCHANGE_RATES.TRY_EUR,
|
|
171
|
+
fr: EXCHANGE_RATES.TRY_EUR,
|
|
172
|
+
us: EXCHANGE_RATES.TRY_USD,
|
|
173
|
+
uk: EXCHANGE_RATES.TRY_GBP
|
|
174
|
+
};
|
|
175
|
+
return rates[targetMarket] || EXCHANGE_RATES.TRY_EUR;
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
_getCurrency(targetMarket) {
|
|
179
|
+
const currencies = {
|
|
180
|
+
de: '€',
|
|
181
|
+
fr: '€',
|
|
182
|
+
us: '$',
|
|
183
|
+
uk: '£'
|
|
184
|
+
};
|
|
185
|
+
return currencies[targetMarket] || '€';
|
|
186
|
+
}
|
|
187
|
+
};
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🧠 AKILLI KOMUT AYRISTIRICI
|
|
3
|
+
* Doğal dil mesajlarını e-ticaret komutlarına çevir
|
|
4
|
+
*
|
|
5
|
+
* Kullanıcı: "trendyoldaki kırmızı kılıfların fiyatını 149 yap"
|
|
6
|
+
* Çıktı: { action: 'updatePrice', platform: 'trendyol', filter: 'kırmızı kılıf', price: 149 }
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const PRICE_PATTERNS = [
|
|
10
|
+
/(?:fiyat[ıi]n[ıi]?|fiyat)\s*(?:şimdi\s+)?(\d+(?:[.,]\d+)?)\s*(?:tl|₺|lira)?(?:\s*yap)?/i,
|
|
11
|
+
/(\d+(?:[.,]\d+)?)\s*(?:tl|₺|lira)?\s*(?:yap|ol(?:sun)?|ayarla)/i,
|
|
12
|
+
/(?:yeni\s+fiyat|güncel\s+fiyat)[:\s]*(\d+(?:[.,]\d+)?)/i,
|
|
13
|
+
/%(\d+)\s*(?:indir|düşür|azalt)/i,
|
|
14
|
+
/%(\d+)\s*(?:artır|yükselt|zam)/i
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
const STOCK_PATTERNS = [
|
|
18
|
+
/stok[u]?\s*(\d+)\s*(?:yap|ol(?:sun)?|ayarla)?/i,
|
|
19
|
+
/(\d+)\s*adet\s*(?:stok|envanter)/i,
|
|
20
|
+
/(?:stok|envanter)[:\s]*(\d+)/i
|
|
21
|
+
];
|
|
22
|
+
|
|
23
|
+
const PLATFORM_PATTERNS = {
|
|
24
|
+
trendyol: /trendyol|ty/i,
|
|
25
|
+
hepsiburada: /hepsiburada|hb/i,
|
|
26
|
+
n11: /n11/i,
|
|
27
|
+
amazon: /amazon|amz/i,
|
|
28
|
+
ciceksepeti: /çiçek\s*sepeti|ciceksepeti|cs/i,
|
|
29
|
+
pttavm: /ptt\s*avm|pttavm|ptt/i,
|
|
30
|
+
pazarama: /pazarama|pzr/i
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const ACTION_PATTERNS = {
|
|
34
|
+
updatePrice: /fiyat|price|ücret|tutar/i,
|
|
35
|
+
updateStock: /stok|stock|envanter|adet/i,
|
|
36
|
+
getOrders: /sipariş|order|satış/i,
|
|
37
|
+
getProducts: /ürün|product|liste/i,
|
|
38
|
+
analyze: /analiz|rapor|report|özet/i,
|
|
39
|
+
competitor: /rakip|rekabet|competitor/i
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const TIME_PATTERNS = {
|
|
43
|
+
'1d': /bugün|son\s*1\s*gün|dün/i,
|
|
44
|
+
'7d': /son\s*(?:1\s*)?hafta|7\s*gün|bu\s*hafta/i,
|
|
45
|
+
'30d': /son\s*(?:1\s*)?ay|30\s*gün|bu\s*ay/i,
|
|
46
|
+
'90d': /son\s*3\s*ay|90\s*gün|çeyrek/i
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export class NLParser {
|
|
50
|
+
/**
|
|
51
|
+
* Mesajı analiz et
|
|
52
|
+
*/
|
|
53
|
+
parse(message) {
|
|
54
|
+
const result = {
|
|
55
|
+
original: message,
|
|
56
|
+
action: null,
|
|
57
|
+
platform: null,
|
|
58
|
+
filter: null,
|
|
59
|
+
value: null,
|
|
60
|
+
period: null,
|
|
61
|
+
confidence: 0,
|
|
62
|
+
parsed: {}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// Platform bul
|
|
66
|
+
for (const [platform, pattern] of Object.entries(PLATFORM_PATTERNS)) {
|
|
67
|
+
if (pattern.test(message)) {
|
|
68
|
+
result.platform = platform;
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Action bul
|
|
74
|
+
for (const [action, pattern] of Object.entries(ACTION_PATTERNS)) {
|
|
75
|
+
if (pattern.test(message)) {
|
|
76
|
+
result.action = action;
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Fiyat değişikliği
|
|
82
|
+
for (const pattern of PRICE_PATTERNS) {
|
|
83
|
+
const match = message.match(pattern);
|
|
84
|
+
if (match) {
|
|
85
|
+
result.action = 'updatePrice';
|
|
86
|
+
const value = parseFloat(match[1].replace(',', '.'));
|
|
87
|
+
|
|
88
|
+
// Yüzde mi yoksa sabit fiyat mı?
|
|
89
|
+
if (message.match(/%\d+\s*(?:indir|düşür|azalt)/i)) {
|
|
90
|
+
result.parsed.percentChange = -value;
|
|
91
|
+
} else if (message.match(/%\d+\s*(?:artır|yükselt|zam)/i)) {
|
|
92
|
+
result.parsed.percentChange = value;
|
|
93
|
+
} else {
|
|
94
|
+
result.parsed.price = value;
|
|
95
|
+
}
|
|
96
|
+
result.value = value;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// Stok değişikliği
|
|
102
|
+
for (const pattern of STOCK_PATTERNS) {
|
|
103
|
+
const match = message.match(pattern);
|
|
104
|
+
if (match) {
|
|
105
|
+
result.action = 'updateStock';
|
|
106
|
+
result.value = parseInt(match[1]);
|
|
107
|
+
result.parsed.stock = result.value;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Zaman dilimi
|
|
113
|
+
for (const [period, pattern] of Object.entries(TIME_PATTERNS)) {
|
|
114
|
+
if (pattern.test(message)) {
|
|
115
|
+
result.period = period;
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// SKU/Barkod bul
|
|
121
|
+
const skuMatch = message.match(/(?:sku|barkod|kod)[:\s]*([A-Z0-9\-]+)/i);
|
|
122
|
+
if (skuMatch) {
|
|
123
|
+
result.parsed.sku = skuMatch[1];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Ürün filtresi (kalan kısım)
|
|
127
|
+
result.filter = this.extractFilter(message);
|
|
128
|
+
|
|
129
|
+
// Güven skoru
|
|
130
|
+
result.confidence = this.calculateConfidence(result);
|
|
131
|
+
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Ürün filtresini çıkar
|
|
137
|
+
*/
|
|
138
|
+
extractFilter(message) {
|
|
139
|
+
// Platform ve action kelimelerini temizle
|
|
140
|
+
let cleaned = message
|
|
141
|
+
.replace(/trendyol|hepsiburada|n11|amazon|çiçeksepeti|pttavm|pazarama/gi, '')
|
|
142
|
+
.replace(/fiyat[ıi]?|stok[u]?|sipariş|ürün|analiz|rakip/gi, '')
|
|
143
|
+
.replace(/\d+\s*(?:tl|₺|lira)?/gi, '')
|
|
144
|
+
.replace(/(?:yap|ol|ayarla|güncelle|değiştir)/gi, '')
|
|
145
|
+
.replace(/(?:tüm|hepsi|bütün)/gi, '')
|
|
146
|
+
.trim();
|
|
147
|
+
|
|
148
|
+
// Anlamlı kelimeler kaldı mı?
|
|
149
|
+
const words = cleaned.split(/\s+/).filter(w => w.length > 2);
|
|
150
|
+
return words.length > 0 ? words.join(' ') : null;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Güven skoru hesapla
|
|
155
|
+
*/
|
|
156
|
+
calculateConfidence(result) {
|
|
157
|
+
let score = 0;
|
|
158
|
+
if (result.action) score += 30;
|
|
159
|
+
if (result.platform) score += 20;
|
|
160
|
+
if (result.value) score += 25;
|
|
161
|
+
if (result.filter || result.parsed.sku) score += 15;
|
|
162
|
+
if (result.period) score += 10;
|
|
163
|
+
return Math.min(score, 100);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Sonucu insan diline çevir
|
|
168
|
+
*/
|
|
169
|
+
toHuman(result) {
|
|
170
|
+
const parts = [];
|
|
171
|
+
|
|
172
|
+
if (result.action === 'updatePrice' && result.parsed.price) {
|
|
173
|
+
parts.push(`Fiyatı ${result.parsed.price}₺ yap`);
|
|
174
|
+
} else if (result.action === 'updatePrice' && result.parsed.percentChange) {
|
|
175
|
+
const dir = result.parsed.percentChange > 0 ? 'artır' : 'düşür';
|
|
176
|
+
parts.push(`Fiyatı %${Math.abs(result.parsed.percentChange)} ${dir}`);
|
|
177
|
+
} else if (result.action === 'updateStock') {
|
|
178
|
+
parts.push(`Stoku ${result.parsed.stock} yap`);
|
|
179
|
+
} else if (result.action === 'getOrders') {
|
|
180
|
+
parts.push('Siparişleri getir');
|
|
181
|
+
} else if (result.action === 'analyze') {
|
|
182
|
+
parts.push('Analiz yap');
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (result.platform) {
|
|
186
|
+
parts.push(`(${result.platform})`);
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (result.filter) {
|
|
190
|
+
parts.push(`"${result.filter}" için`);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (result.period) {
|
|
194
|
+
parts.push(`son ${result.period}`);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return parts.join(' ');
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Kısa yardımcı fonksiyonlar
|
|
202
|
+
export function parseCommand(message) {
|
|
203
|
+
return new NLParser().parse(message);
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export function whatDoYouMean(message) {
|
|
207
|
+
const result = new NLParser().parse(message);
|
|
208
|
+
return new NLParser().toHuman(result);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export default NLParser;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 📦 Product Tool
|
|
3
|
+
* Ürün yönetimi işlemleri
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export const productTool = {
|
|
7
|
+
name: 'product',
|
|
8
|
+
|
|
9
|
+
async execute(params, context) {
|
|
10
|
+
const { api, memory } = context;
|
|
11
|
+
const { action, productId, platform, data } = params;
|
|
12
|
+
|
|
13
|
+
switch (action) {
|
|
14
|
+
case 'list':
|
|
15
|
+
return await this._listProducts(platform, data, context);
|
|
16
|
+
case 'get':
|
|
17
|
+
return await this._getProduct(productId, platform, context);
|
|
18
|
+
case 'update':
|
|
19
|
+
return await this._updateProduct(productId, data, context);
|
|
20
|
+
case 'updatePrice':
|
|
21
|
+
return await this._updatePrice(productId, data.price, platform, context);
|
|
22
|
+
case 'updateStock':
|
|
23
|
+
return await this._updateStock(productId, data.stock, platform, context);
|
|
24
|
+
case 'publish':
|
|
25
|
+
return await this._publishProduct(productId, platform, context);
|
|
26
|
+
case 'unpublish':
|
|
27
|
+
return await this._unpublishProduct(productId, platform, context);
|
|
28
|
+
default:
|
|
29
|
+
return { success: false, error: 'Geçersiz işlem' };
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
async getStockSummary(platform, context) {
|
|
34
|
+
// TODO: Veritabanı/API'den stok özeti
|
|
35
|
+
return {
|
|
36
|
+
trendyol: { total: 1250, critical: 23, zero: 5 },
|
|
37
|
+
hepsiburada: { total: 890, critical: 12, zero: 3 },
|
|
38
|
+
n11: { total: 450, critical: 8, zero: 2 },
|
|
39
|
+
amazon: { total: 320, critical: 5, zero: 1 }
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
async parseAndUpdatePrice(args, context) {
|
|
44
|
+
// Parse: "iPhone kılıf 199 TL" veya "SKU-123 %10 indirim"
|
|
45
|
+
if (!args) {
|
|
46
|
+
return { success: false, message: '❌ Kullanım: /fiyat [ürün adı/SKU] [yeni fiyat veya %indirim]' };
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const percentMatch = args.match(/%(\d+)/);
|
|
50
|
+
const priceMatch = args.match(/(\d+(?:[.,]\d+)?)\s*(?:TL|₺)?/i);
|
|
51
|
+
|
|
52
|
+
// TODO: Ürünü bul ve fiyatı güncelle
|
|
53
|
+
|
|
54
|
+
if (percentMatch) {
|
|
55
|
+
const percent = parseInt(percentMatch[1]);
|
|
56
|
+
return {
|
|
57
|
+
success: true,
|
|
58
|
+
message: `✅ Ürünlere %${percent} indirim uygulandı.`
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (priceMatch) {
|
|
63
|
+
const newPrice = parseFloat(priceMatch[1].replace(',', '.'));
|
|
64
|
+
return {
|
|
65
|
+
success: true,
|
|
66
|
+
message: `✅ Fiyat ${newPrice} ₺ olarak güncellendi.`
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return { success: false, message: '❌ Fiyat formatı anlaşılamadı.' };
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
// Private methods
|
|
74
|
+
async _listProducts(platform, filters, context) {
|
|
75
|
+
return {
|
|
76
|
+
success: true,
|
|
77
|
+
products: [],
|
|
78
|
+
total: 0,
|
|
79
|
+
page: 1
|
|
80
|
+
};
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
async _getProduct(productId, platform, context) {
|
|
84
|
+
return {
|
|
85
|
+
success: true,
|
|
86
|
+
product: null
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
async _updateProduct(productId, data, context) {
|
|
91
|
+
return { success: true, message: 'Ürün güncellendi.' };
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
async _updatePrice(productId, price, platform, context) {
|
|
95
|
+
context.api.logger.info(`💰 Fiyat güncellendi: ${productId} → ${price} ₺`);
|
|
96
|
+
return { success: true, message: `Fiyat ${price} ₺ olarak güncellendi.` };
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
async _updateStock(productId, stock, platform, context) {
|
|
100
|
+
return { success: true, message: `Stok ${stock} olarak güncellendi.` };
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
async _publishProduct(productId, platform, context) {
|
|
104
|
+
return { success: true, message: 'Ürün yayınlandı.' };
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
async _unpublishProduct(productId, platform, context) {
|
|
108
|
+
return { success: true, message: 'Ürün yayından kaldırıldı.' };
|
|
109
|
+
}
|
|
110
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 📊 HIZLI DURUM RAPORU
|
|
3
|
+
* Emoji bazlı özet raporlar
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { platformHub } from '../platforms/index.js';
|
|
7
|
+
|
|
8
|
+
export const quickReportTool = {
|
|
9
|
+
name: 'quick-report',
|
|
10
|
+
|
|
11
|
+
async execute(params, context) {
|
|
12
|
+
const { type = 'overview' } = params;
|
|
13
|
+
|
|
14
|
+
switch (type) {
|
|
15
|
+
case 'overview':
|
|
16
|
+
case 'ozet':
|
|
17
|
+
return await this.generateOverview(context);
|
|
18
|
+
|
|
19
|
+
case 'stock':
|
|
20
|
+
case 'stok':
|
|
21
|
+
return await this.generateStockReport(context);
|
|
22
|
+
|
|
23
|
+
case 'orders':
|
|
24
|
+
case 'siparis':
|
|
25
|
+
return await this.generateOrderReport(context);
|
|
26
|
+
|
|
27
|
+
case 'platforms':
|
|
28
|
+
case 'platformlar':
|
|
29
|
+
return this.generatePlatformStatus();
|
|
30
|
+
|
|
31
|
+
default:
|
|
32
|
+
return { success: false, error: 'Bilinmeyen rapor tipi' };
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
async generateOverview(context) {
|
|
37
|
+
const connected = platformHub.getConnected();
|
|
38
|
+
|
|
39
|
+
let report = '📊 **Günlük Özet**\n\n';
|
|
40
|
+
|
|
41
|
+
// Platform durumu
|
|
42
|
+
report += '🏪 **Platformlar**\n';
|
|
43
|
+
for (const platform of connected) {
|
|
44
|
+
report += ` ${platformHub.getIcon(platform)} ${platform}: ✅ Bağlı\n`;
|
|
45
|
+
}
|
|
46
|
+
report += '\n';
|
|
47
|
+
|
|
48
|
+
// Özet metrikler (placeholder - gerçek veriler API'den çekilmeli)
|
|
49
|
+
report += '📈 **Bugün**\n';
|
|
50
|
+
report += ' • Sipariş: 0 yeni\n';
|
|
51
|
+
report += ' • Ciro: ₺0\n';
|
|
52
|
+
report += ' • Stok Uyarı: 0 ürün\n';
|
|
53
|
+
report += '\n';
|
|
54
|
+
|
|
55
|
+
report += '💡 *Detay için: /rapor 7d*';
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
success: true,
|
|
59
|
+
report,
|
|
60
|
+
raw: { connectedPlatforms: connected }
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
async generateStockReport(context) {
|
|
65
|
+
const connected = platformHub.getConnected();
|
|
66
|
+
|
|
67
|
+
let report = '📦 **Stok Durumu**\n\n';
|
|
68
|
+
|
|
69
|
+
// Her platform için stok özeti
|
|
70
|
+
for (const platform of connected) {
|
|
71
|
+
const api = platformHub.resolve(platform);
|
|
72
|
+
if (!api) continue;
|
|
73
|
+
|
|
74
|
+
try {
|
|
75
|
+
const result = await api.getProducts({ page: 0, size: 100 });
|
|
76
|
+
if (result.success) {
|
|
77
|
+
const products = result.data.content || result.data.products || result.data || [];
|
|
78
|
+
|
|
79
|
+
const outOfStock = products.filter(p => (p.quantity || p.stock || 0) <= 0);
|
|
80
|
+
const lowStock = products.filter(p => {
|
|
81
|
+
const q = p.quantity || p.stock || 0;
|
|
82
|
+
return q > 0 && q <= 10;
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
report += `${platformHub.getIcon(platform)} **${platform}**\n`;
|
|
86
|
+
report += ` 📦 Toplam: ${products.length}\n`;
|
|
87
|
+
report += ` 🔴 Stok dışı: ${outOfStock.length}\n`;
|
|
88
|
+
report += ` 🟡 Düşük (≤10): ${lowStock.length}\n`;
|
|
89
|
+
report += '\n';
|
|
90
|
+
}
|
|
91
|
+
} catch (e) {
|
|
92
|
+
report += `${platformHub.getIcon(platform)} **${platform}**: ⚠️ Hata\n`;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return { success: true, report };
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
async generateOrderReport(context) {
|
|
100
|
+
const connected = platformHub.getConnected();
|
|
101
|
+
const today = new Date();
|
|
102
|
+
today.setHours(0, 0, 0, 0);
|
|
103
|
+
|
|
104
|
+
let report = '🛒 **Sipariş Durumu**\n\n';
|
|
105
|
+
let totalOrders = 0;
|
|
106
|
+
|
|
107
|
+
for (const platform of connected) {
|
|
108
|
+
const api = platformHub.resolve(platform);
|
|
109
|
+
if (!api) continue;
|
|
110
|
+
|
|
111
|
+
try {
|
|
112
|
+
const result = await api.getOrders({
|
|
113
|
+
startDate: today.toISOString(),
|
|
114
|
+
size: 100
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
if (result.success) {
|
|
118
|
+
const orders = result.data.content || result.data.orders || result.data || [];
|
|
119
|
+
totalOrders += orders.length;
|
|
120
|
+
|
|
121
|
+
const pending = orders.filter(o =>
|
|
122
|
+
['created', 'new', 'pending', 'yeni'].some(s =>
|
|
123
|
+
o.status?.toLowerCase()?.includes(s)
|
|
124
|
+
)
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
report += `${platformHub.getIcon(platform)} **${platform}**\n`;
|
|
128
|
+
report += ` 📋 Bugün: ${orders.length}\n`;
|
|
129
|
+
report += ` ⏳ Bekleyen: ${pending.length}\n`;
|
|
130
|
+
report += '\n';
|
|
131
|
+
}
|
|
132
|
+
} catch (e) {
|
|
133
|
+
report += `${platformHub.getIcon(platform)} **${platform}**: ⚠️ Hata\n`;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
report += `📊 **Toplam**: ${totalOrders} sipariş`;
|
|
138
|
+
|
|
139
|
+
return { success: true, report };
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
generatePlatformStatus() {
|
|
143
|
+
const status = platformHub.getStatus();
|
|
144
|
+
|
|
145
|
+
let report = '🔌 **Platform Bağlantıları**\n\n';
|
|
146
|
+
|
|
147
|
+
for (const [name, info] of Object.entries(status)) {
|
|
148
|
+
const statusIcon = info.connected ? '✅' : '⭕';
|
|
149
|
+
const statusText = info.connected ? 'Bağlı' : 'Bağlı değil';
|
|
150
|
+
report += `${info.icon} ${name}: ${statusIcon} ${statusText}\n`;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const connectedCount = Object.values(status).filter(s => s.connected).length;
|
|
154
|
+
report += `\n📊 ${connectedCount}/${Object.keys(status).length} platform aktif`;
|
|
155
|
+
|
|
156
|
+
return { success: true, report };
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Kolay erişim fonksiyonları
|
|
162
|
+
*/
|
|
163
|
+
export async function dailyOverview(context) {
|
|
164
|
+
return await quickReportTool.execute({ type: 'overview' }, context);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export async function stockStatus(context) {
|
|
168
|
+
return await quickReportTool.execute({ type: 'stock' }, context);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export async function orderStatus(context) {
|
|
172
|
+
return await quickReportTool.execute({ type: 'orders' }, context);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
export default quickReportTool;
|