update product unit

This commit is contained in:
Timi
2026-09-03 15:16:16 +08:00
parent 731c777b8b
commit 913dc3d278
19 changed files with 102 additions and 66 deletions
@@ -0,0 +1,28 @@
ALTER TABLE `gao_product_unit`
ADD COLUMN IF NOT EXISTS `sale_price` BIGINT NULL COMMENT '该业务单位建议售价,单位分' AFTER `name`;
UPDATE `gao_product_unit` u
JOIN `gao_product` p ON p.`id` = u.`product_id`
SET u.`sale_price` = p.`sale_price`
WHERE u.`sale_price` IS NULL;
ALTER TABLE `gao_product_unit`
CHANGE COLUMN `conversion_to_base` `base_quantity_per_unit` DECIMAL(18,6) NOT NULL COMMENT '每个业务单位对应的基础单位数量';
ALTER TABLE `gao_stock_record`
CHANGE COLUMN `conversion_to_base_snapshot` `base_quantity_per_unit_snapshot` DECIMAL(18,6) NOT NULL COMMENT '基础单位数量系数快照';
ALTER TABLE `gao_sales_order_item`
CHANGE COLUMN `conversion_to_base_snapshot` `base_quantity_per_unit_snapshot` DECIMAL(18,6) NOT NULL COMMENT '基础单位数量系数快照';
ALTER TABLE `gao_package_config_item`
CHANGE COLUMN `conversion_to_base_snapshot` `base_quantity_per_unit_snapshot` DECIMAL(18,6) NOT NULL COMMENT '基础单位数量系数快照';
ALTER TABLE `gao_customer_package_item`
CHANGE COLUMN `conversion_to_base_snapshot` `base_quantity_per_unit_snapshot` DECIMAL(18,6) NOT NULL COMMENT '基础单位数量系数快照';
ALTER TABLE `gao_order_fulfillment_item`
CHANGE COLUMN `conversion_to_base_snapshot` `base_quantity_per_unit_snapshot` DECIMAL(18,6) NOT NULL COMMENT '基础单位数量系数快照';
ALTER TABLE `gao_product`
DROP COLUMN `sale_price`;
@@ -5,7 +5,8 @@
<id column="id" property="id"/>
<result column="product_id" property="productId"/>
<result column="name" property="name"/>
<result column="conversion_to_base" property="conversionToBase"/>
<result column="base_quantity_per_unit" property="baseQuantityPerUnit"/>
<result column="sale_price" property="salePrice"/>
<result column="is_base" property="isBase"/>
<result column="allow_purchase" property="allowPurchase"/>
<result column="allow_sale" property="allowSale"/>
@@ -37,7 +38,7 @@
</select>
<update id="updateUnit">
UPDATE `gao_product_unit`
SET `name` = #{name}, `conversion_to_base` = #{conversionToBase}, `is_base` = #{isBase},
SET `name` = #{name}, `base_quantity_per_unit` = #{baseQuantityPerUnit}, `sale_price` = #{salePrice}, `is_base` = #{isBase},
`allow_purchase` = #{allowPurchase}, `allow_sale` = #{allowSale}, `sort` = #{sort},
`updated_at` = FLOOR(UNIX_TIMESTAMP(NOW(3)) * 1000)
WHERE `id` = #{id} AND `product_id` = #{productId} AND `deleted_at` IS NULL