refactor: 将SKU脚本移动到sku-designer技能目录下

This commit is contained in:
12600k-rog-d4
2026-04-04 23:06:06 +08:00
parent 647f4a76c4
commit 40d9daf42a
3 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
const fs = require('fs');
const path = require('path');
const skuDir = path.join(__dirname, '../../产品/飞牛 NAS/fyd-亚克力机箱 - 单/sku');
const FIXED_COST = 42 + 12 + 4 + 1 + 1 + 10 + 5 + 10;
const CPU_PRICES = { 'N2840': 45, 'N2930': 50, 'AMD-A4': 45, 'J1900': 80, 'J3160': 90 };
const MEMORY_COST = {
'2G-16G': { ram: 13, disk: 15 },
'2G-32G': { ram: 13, disk: 20 },
'4G-64G': { ram: 25, disk: 40 },
'4G-128G': { ram: 25, disk: 68 }
};
const files = fs.readdirSync(skuDir).filter(f => f.endsWith('.md'));
files.forEach(file => {
const filePath = path.join(skuDir, file);
let content = fs.readFileSync(filePath, 'utf-8');
// 解析: 亚克力-单-{CPU}-{MEM}.md
// CPU可能是AMD-A4这样的组合
const match = file.match(/亚克力-单-([A-Z0-9-]+)-(\d+G)-(\d+G)\.md/);
if (!match) {
console.log(`Skipped: ${file} (no match)`);
return;
}
const cpu = match[1];
const mem = match[2] + '-' + match[3];
console.log(`Processing: ${file} - CPU: ${cpu}, Mem: ${mem}`);
const cpuCost = CPU_PRICES[cpu];
const ramCost = MEMORY_COST[mem].ram;
const diskCost = MEMORY_COST[mem].disk;
const totalCost = FIXED_COST + cpuCost + ramCost + diskCost;
const price = Math.round(totalCost * 1.3);
const skuName = `亚克力-单-${cpu}-${mem}`;
content = content.replace(/\| \*\*产品型号\*\* \| [^|]+ \|/, `| **产品型号** | ${skuName} |`);
content = content.replace(/\| \*\*CPU\*\* \| [^|]+ \| ¥\d+ \|/, `| **CPU** | ${cpu} | ¥${cpuCost} |`);
const ramName = mem.includes('4G') ? 'D3-4G' : 'D3-2G';
const diskName = mem.includes('128G') ? 'mSATA-128G' : (mem.includes('32G') ? 'mSATA-32G' : 'mSATA-16G');
content = content.replace(/\| \*\*内存\*\* \| D3-\dG \| ¥\d+ \|/, `| **内存** | ${ramName} | ¥${ramCost} |`);
content = content.replace(/\| \*\*系统盘\*\* \| mSATA-\d+G \| ¥\d+ \|/, `| **系统盘** | ${diskName} | ¥${diskCost} |`);
content = content.replace(/\| \*\*总成本\*\* \| - \| ¥\d+ \|/, `| **总成本** | - | ¥${totalCost} |`);
content = content.replace(/\| \*\*建议零售价\*\* \| - \| ¥\d+ \|/, `| **建议零售价** | - | ¥${price} |`);
fs.writeFileSync(filePath, content, 'utf-8');
console.log(` -> 成本: ¥${totalCost}, 售价: ¥${price}`);
});
console.log(`\n完成! 共处理 ${files.length} 个文件`);

View File

@@ -0,0 +1,142 @@
[
{
"index": 1,
"sku": "亚克力 - 单-N2840-2G-16G",
"cost": 158,
"price": 205,
"profit": 47
},
{
"index": 2,
"sku": "亚克力 - 单-N2840-2G-32G",
"cost": 163,
"price": 212,
"profit": 49
},
{
"index": 3,
"sku": "亚克力 - 单-N2840-4G-64G",
"cost": 195,
"price": 254,
"profit": 59
},
{
"index": 4,
"sku": "亚克力 - 单-N2840-4G-128G",
"cost": 223,
"price": 290,
"profit": 67
},
{
"index": 5,
"sku": "亚克力 - 单-N2930-2G-16G",
"cost": 163,
"price": 212,
"profit": 49
},
{
"index": 6,
"sku": "亚克力 - 单-N2930-2G-32G",
"cost": 168,
"price": 218,
"profit": 50
},
{
"index": 7,
"sku": "亚克力 - 单-N2930-4G-64G",
"cost": 200,
"price": 260,
"profit": 60
},
{
"index": 8,
"sku": "亚克力 - 单-N2930-4G-128G",
"cost": 228,
"price": 296,
"profit": 68
},
{
"index": 9,
"sku": "亚克力 - 单-AMD-A4-2G-16G",
"cost": 158,
"price": 205,
"profit": 47
},
{
"index": 10,
"sku": "亚克力 - 单-AMD-A4-2G-32G",
"cost": 163,
"price": 212,
"profit": 49
},
{
"index": 11,
"sku": "亚克力 - 单-AMD-A4-4G-64G",
"cost": 195,
"price": 254,
"profit": 59
},
{
"index": 12,
"sku": "亚克力 - 单-AMD-A4-4G-128G",
"cost": 223,
"price": 290,
"profit": 67
},
{
"index": 13,
"sku": "亚克力 - 单-J1900-2G-16G",
"cost": 193,
"price": 251,
"profit": 58
},
{
"index": 14,
"sku": "亚克力 - 单-J1900-2G-32G",
"cost": 198,
"price": 257,
"profit": 59
},
{
"index": 15,
"sku": "亚克力 - 单-J1900-4G-64G",
"cost": 230,
"price": 299,
"profit": 69
},
{
"index": 16,
"sku": "亚克力 - 单-J1900-4G-128G",
"cost": 258,
"price": 335,
"profit": 77
},
{
"index": 17,
"sku": "亚克力 - 单-J3160-2G-16G",
"cost": 203,
"price": 264,
"profit": 61
},
{
"index": 18,
"sku": "亚克力 - 单-J3160-2G-32G",
"cost": 208,
"price": 270,
"profit": 62
},
{
"index": 19,
"sku": "亚克力 - 单-J3160-4G-64G",
"cost": 240,
"price": 312,
"profit": 72
},
{
"index": 20,
"sku": "亚克力 - 单-J3160-4G-128G",
"cost": 268,
"price": 348,
"profit": 80
}
]

View File

@@ -0,0 +1,58 @@
// SKU价格计算工具
// 亚克力-单 固定配件成本
const FIXED_COST = 42 + 12 + 4 + 1 + 1 + 10 + 5 + 10; // 机箱+电源+硬盘线+电池+网线+运费+包装+装机 = 85
// 配件价格(来自配件清单)
const CPU_PRICES = {
'N2840': 45,
'N2930': 50,
'AMD-A4': 45,
'J1900': 80,
'J3160': 90
};
const MEMORY_PRICES = {
'2G-16G': { ram: 13, disk: 15 }, // D3-2G + mSATA-16G
'2G-32G': { ram: 13, disk: 20 }, // D3-2G + mSATA-32G
'4G-64G': { ram: 25, disk: 40 }, // D3-4G + mSATA-64G
'4G-128G': { ram: 25, disk: 68 } // D3-4G + mSATA-128G
};
const CPUS = ['N2840', 'N2930', 'AMD-A4', 'J1900', 'J3160'];
const MEMORIES = ['2G-16G', '2G-32G', '4G-64G', '4G-128G'];
console.log('=== 亚克力-单 SKU 价格计算 ===\n');
let results = [];
let index = 1;
CPUS.forEach(cpu => {
MEMORIES.forEach(mem => {
const cpuCost = CPU_PRICES[cpu];
const ramCost = MEMORY_PRICES[mem].ram;
const diskCost = MEMORY_PRICES[mem].disk;
const totalCost = FIXED_COST + cpuCost + ramCost + diskCost;
const price = Math.round(totalCost * 1.3);
const profit = price - totalCost;
const sku = `亚克力 - 单-${cpu}-${mem}`;
results.push({ index, sku, cost: totalCost, price, profit });
console.log(`${index}. ${sku}`);
console.log(` CPU(${cpu}): ¥${cpuCost} + 内存: ¥${ramCost} + 系统盘: ¥${diskCost} + 固定: ¥${FIXED_COST}`);
console.log(` 成本: ¥${totalCost} | 售价: ¥${price} | 利润: ¥${profit}\n`);
index++;
});
});
// 输出汇总表格式的数据
console.log('\n=== 汇总表更新数据 ===');
results.forEach(r => {
console.log(`| ${r.index} | ${r.sku} | ¥${r.cost} | ¥${r.price} | ¥${r.profit} | 30% |`);
});
// 导出JSON供后续使用
const fs = require('fs');
fs.writeFileSync('./sku-results.json', JSON.stringify(results, null, 2));
console.log('\n已导出计算结果到 sku-results.json');