File size: 681 Bytes
3cc9b94
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// services/assetMapper.js
const googleSheets = require('./googleSheets');

const assetMapper = {
    // Từ mã SP, đi tìm mọi thông tin liên quan để gửi cho khách
    mapProductToAssets: async (productCode) => {
        const product = await googleSheets.getProductInfo(productCode);
        
        if (product) {
            return {
                price: product.price,
                // Chuyển ID Drive thành link có thể xem trực tiếp
                imageUrl: `https://lh3.googleusercontent.com/d/${product.driveId}`,
                available: product.stock > 0
            };
        }
        return null;
    }
};

module.exports = assetMapper;