// Cube.js 数据模型 - 商品资料 // 基于 jst_sku 表 cube(`Products`, { sql: `SELECT * FROM rpt.jst_sku`, measures: { count: { sql: `autoid`, type: `count`, title: `商品总数` }, totalCost: { sql: `cost_price`, type: `sum`, format: `currency`, title: `总成本` }, avgSalePrice: { sql: `sale_price`, type: `avg`, format: `currency`, title: `平均销售价` }, avgCostPrice: { sql: `cost_price`, type: `avg`, format: `currency`, title: `平均成本价` }, totalWeight: { sql: `weight`, type: `sum`, title: `总重量` }, }, dimensions: { id: { sql: `autoid`, type: `number`, primaryKey: true, }, skuId: { sql: `sku_id`, type: `string`, title: `商品编码`, }, iId: { sql: `i_id`, type: `string`, title: `款式编码`, }, name: { sql: `name`, type: `string`, title: `商品名称`, }, shortName: { sql: `short_name`, type: `string`, title: `商品简称`, }, salePrice: { sql: `sale_price`, type: `number`, format: `currency`, title: `销售价`, }, costPrice: { sql: `cost_price`, type: `number`, format: `currency`, title: `成本价`, }, category: { sql: `category`, type: `string`, title: `分类`, }, brand: { sql: `brand`, type: `string`, title: `品牌`, }, supplierName: { sql: `supplier_name`, type: `string`, title: `供应商名称`, }, enabled: { sql: `CASE WHEN enabled = 1 THEN '启用' WHEN enabled = 0 THEN '备用' ELSE '禁用' END`, type: `string`, title: `系统状态`, }, itemType: { sql: `item_type`, type: `string`, title: `商品属性`, }, // 新增字段映射 priceType: { sql: `CASE WHEN other_price_1 = 1 THEN '预估价' WHEN other_price_1 = 2 THEN '定价' WHEN other_price_1 = 3 THEN '清货价' ELSE '未知' END`, type: `string`, title: `价格类型`, }, spu: { sql: `other_1`, type: `string`, title: `SPU`, }, warehouse: { sql: `other_3`, type: `string`, title: `发货仓库`, }, productState: { sql: `other_5`, type: `string`, title: `商品业务状态`, }, productNo: { sql: `other_7`, type: `string`, title: `货号`, }, drawingId: { sql: `other_9`, type: `string`, title: `图纸ID`, }, created: { sql: `created`, type: `time`, title: `创建时间`, }, modified: { sql: `modified`, type: `time`, title: `修改时间`, }, }, });