From 5e4cc668e5aa0ea69a0df056aaa0bea7e7b78b66 Mon Sep 17 00:00:00 2001 From: wangjia <809946525@qq.com> Date: Thu, 25 Jun 2026 19:56:27 +0800 Subject: [PATCH] =?UTF-8?q?feat(backend):=20=E5=BA=93=E5=AD=98=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E5=B8=A6=E5=87=BA=E5=94=AE=E4=BB=B7=20sale=5Fprice?= =?UTF-8?q?=EF=BC=88=E5=BA=93=E5=AD=98=E5=B1=8F=E6=88=90=E6=9C=AC=E4=BB=B7?= =?UTF-8?q?/=E5=8D=95=E4=BB=B7=E4=B8=A4=E5=88=97=E5=9C=B0=E5=9F=BA?= =?UTF-8?q?=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 照原型库存表「成本价(进价)+单价(售价)」两列: - 库存查询 SELECT 加 p.sale_price AS sale_price;成本价 unit_price 补 p.purchase_price 兜底 - inventoryRow 加 SalePrice;前端 Inventory model 加 salePrice - 多租户隔离不变(baseWhere 仍 inv.shop_id);库存测试通过 Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01TSKEiHsvauyxYUW2itzUXX --- backend/internal/handler/inventory.go | 6 ++++-- client/lib/models/inventory.dart | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/backend/internal/handler/inventory.go b/backend/internal/handler/inventory.go index 80ac350..daabd6f 100644 --- a/backend/internal/handler/inventory.go +++ b/backend/internal/handler/inventory.go @@ -36,7 +36,8 @@ type inventoryRow struct { Spec string `json:"spec"` Unit string `json:"unit"` WarehouseName string `json:"warehouse_name"` - UnitPrice *float64 `json:"unit_price"` + UnitPrice *float64 `json:"unit_price"` // 成本价(入库进价) + SalePrice *float64 `json:"sale_price"` // 单价(product 售价) ProductionDate *string `json:"production_date"` BatchNo string `json:"batch_no"` SupplierName string `json:"supplier_name"` @@ -131,7 +132,8 @@ func (h *InventoryHandler) List(c *gin.Context) { COALESCE(NULLIF(p.spec,''), NULLIF(sii.spec,''), inv.spec, '') AS spec, COALESCE(NULLIF(p.unit,''), inv.unit, '') AS unit, COALESCE(NULLIF(w.name,''), inv.warehouse_name, '') AS warehouse_name, - COALESCE(sii.unit_price, inv.unit_price) AS unit_price, + COALESCE(sii.unit_price, inv.unit_price, p.purchase_price) AS unit_price, + p.sale_price AS sale_price, COALESCE(DATE(sii.production_date), DATE(inv.production_date)) AS production_date, COALESCE(NULLIF(sii.batch_no,''), inv.batch_no, '') AS batch_no, inv.supplier_name, diff --git a/client/lib/models/inventory.dart b/client/lib/models/inventory.dart index afa6f38..b1ce039 100644 --- a/client/lib/models/inventory.dart +++ b/client/lib/models/inventory.dart @@ -15,7 +15,8 @@ class Inventory { final String spec; final String unit; final String warehouseName; - final double? unitPrice; + final double? unitPrice; // 成本价(入库进价) + final double? salePrice; // 单价(product 售价) final String? productionDate; final String batchNo; final String supplierName; @@ -37,6 +38,7 @@ class Inventory { this.unit = '', this.warehouseName = '', this.unitPrice, + this.salePrice, this.productionDate, this.batchNo = '', this.supplierName = '', @@ -59,6 +61,7 @@ class Inventory { unit: json['unit'] as String? ?? '', warehouseName: json['warehouse_name'] as String? ?? '', unitPrice: (json['unit_price'] as num?)?.toDouble(), + salePrice: (json['sale_price'] as num?)?.toDouble(), productionDate: _parseDate(json['production_date'] as String?), batchNo: json['batch_no'] as String? ?? '', supplierName: json['supplier_name'] as String? ?? '',