feat: 订单明细增加商品冗余字段,保存完整商品信息
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Agent
2026-03-31 16:27:04 +00:00
parent 161fe60bd7
commit abd1d32e14
3 changed files with 49 additions and 0 deletions

View File

@@ -26,6 +26,11 @@ public class OrderItem {
*/ */
private String productId; private String productId;
/**
* 分类ID(冗余)
*/
private String categoryId;
/** /**
* 商品名称(冗余) * 商品名称(冗余)
*/ */
@@ -41,11 +46,36 @@ public class OrderItem {
*/ */
private String unit; private String unit;
/**
* 成本价(冗余)
*/
private BigDecimal costPrice;
/** /**
* 销售单价(当时标价) * 销售单价(当时标价)
*/ */
private BigDecimal price; private BigDecimal price;
/**
* 商品图片URL(冗余)
*/
private String imageUrl;
/**
* 商品条码(冗余)
*/
private String barcode;
/**
* 库存预警阈值(冗余)
*/
private Integer stockAlert;
/**
* 商品描述(冗余)
*/
private String description;
/** /**
* 数量 * 数量
*/ */

View File

@@ -102,9 +102,15 @@ public class OrderServiceImpl implements OrderService {
item.setItemId(UUID.randomUUID().toString()); item.setItemId(UUID.randomUUID().toString());
item.setOrderId(order.getOrderId()); item.setOrderId(order.getOrderId());
item.setProductId(product.getProductId()); item.setProductId(product.getProductId());
item.setCategoryId(product.getCategoryId());
item.setProductName(product.getName()); item.setProductName(product.getName());
item.setProductSpec(product.getSpec()); item.setProductSpec(product.getSpec());
item.setUnit(product.getUnit()); item.setUnit(product.getUnit());
item.setCostPrice(product.getCostPrice());
item.setImageUrl(product.getImageUrl());
item.setBarcode(product.getBarcode());
item.setStockAlert(product.getStockAlert());
item.setDescription(product.getDescription());
item.setPrice(price); item.setPrice(price);
item.setQuantity(itemDTO.getQuantity()); item.setQuantity(itemDTO.getQuantity());
item.setSubtotal(subtotal); item.setSubtotal(subtotal);
@@ -347,9 +353,15 @@ public class OrderServiceImpl implements OrderService {
item.setItemId(UUID.randomUUID().toString()); item.setItemId(UUID.randomUUID().toString());
item.setOrderId(orderId); item.setOrderId(orderId);
item.setProductId(product.getProductId()); item.setProductId(product.getProductId());
item.setCategoryId(product.getCategoryId());
item.setProductName(product.getName()); item.setProductName(product.getName());
item.setProductSpec(product.getSpec()); item.setProductSpec(product.getSpec());
item.setUnit(product.getUnit()); item.setUnit(product.getUnit());
item.setCostPrice(product.getCostPrice());
item.setImageUrl(product.getImageUrl());
item.setBarcode(product.getBarcode());
item.setStockAlert(product.getStockAlert());
item.setDescription(product.getDescription());
item.setPrice(price); item.setPrice(price);
item.setQuantity(itemDTO.getQuantity()); item.setQuantity(itemDTO.getQuantity());
item.setSubtotal(subtotal); item.setSubtotal(subtotal);

View File

@@ -0,0 +1,7 @@
-- 订单明细表增加商品冗余字段
ALTER TABLE order_items ADD COLUMN IF NOT EXISTS category_id VARCHAR(36);
ALTER TABLE order_items ADD COLUMN IF NOT EXISTS cost_price DECIMAL(10,2);
ALTER TABLE order_items ADD COLUMN IF NOT EXISTS image_url VARCHAR(500);
ALTER TABLE order_items ADD COLUMN IF NOT EXISTS barcode VARCHAR(50);
ALTER TABLE order_items ADD COLUMN IF NOT EXISTS stock_alert INTEGER;
ALTER TABLE order_items ADD COLUMN IF NOT EXISTS description TEXT;