update gao product edit
This commit is contained in:
@@ -0,0 +1,107 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||
<mapper namespace="com.imyeyu.api.modules.gao.mapper.GaoProductEditMapper">
|
||||
<select id="countProductReferences" resultType="int">
|
||||
SELECT
|
||||
(SELECT COUNT(*) FROM `gao_sales_order_item` WHERE `product_id_snapshot` = #{productId}) +
|
||||
(SELECT COUNT(*) FROM `gao_order_fulfillment_item` WHERE `product_id_snapshot` = #{productId}) +
|
||||
(SELECT COUNT(*) FROM `gao_product_stock_record` WHERE `product_id_snapshot` = #{productId}) +
|
||||
(SELECT COUNT(*) FROM `gao_package_config_item` WHERE `product_id_snapshot` = #{productId}) +
|
||||
(SELECT COUNT(*) FROM `gao_point_redemption` WHERE `product_id_snapshot` = #{productId})
|
||||
</select>
|
||||
<select id="countSkuReferences" resultType="int">
|
||||
SELECT
|
||||
(SELECT COUNT(*) FROM `gao_sales_order_item` WHERE `sku_id` = #{skuId}) +
|
||||
(SELECT COUNT(*) FROM `gao_order_fulfillment_item` WHERE `sku_id` = #{skuId}) +
|
||||
(SELECT COUNT(*) FROM `gao_product_stock_record` WHERE `sku_id` = #{skuId}) +
|
||||
(SELECT COUNT(*) FROM `gao_package_config_item` WHERE `sku_id` = #{skuId}) +
|
||||
(SELECT COUNT(*) FROM `gao_point_redeem_sku` WHERE `sku_id` = #{skuId}) +
|
||||
(SELECT COUNT(*) FROM `gao_point_redemption` WHERE `sku_id_snapshot` = #{skuId})
|
||||
</select>
|
||||
<select id="countUnitReferences" resultType="int">
|
||||
SELECT
|
||||
(SELECT COUNT(*) FROM `gao_sales_order_item` WHERE `sku_unit_id` = #{unitId}) +
|
||||
(SELECT COUNT(*) FROM `gao_order_fulfillment_item` WHERE `sku_unit_id` = #{unitId}) +
|
||||
(SELECT COUNT(*) FROM `gao_product_stock_record` WHERE `sku_unit_id` = #{unitId}) +
|
||||
(SELECT COUNT(*) FROM `gao_package_config_item` WHERE `sku_unit_id` = #{unitId}) +
|
||||
(SELECT COUNT(*) FROM `gao_point_redeem_sku` WHERE `sku_unit_id` = #{unitId}) +
|
||||
(SELECT COUNT(*) FROM `gao_point_redemption` WHERE `sku_unit_id_snapshot` = #{unitId})
|
||||
</select>
|
||||
<select id="countMigrationPrecisionLoss" resultType="int">
|
||||
SELECT COUNT(*) FROM (
|
||||
SELECT 1 FROM `gao_product_sku` WHERE `id` = #{skuId} AND `min_stock_quantity` IS NOT NULL
|
||||
AND (`min_stock_quantity` * #{ratio} <> ROUND(`min_stock_quantity` * #{ratio}, 3) OR ABS(`min_stock_quantity` * #{ratio}) > 999999999999999.999)
|
||||
UNION ALL SELECT 1 FROM `gao_product_stock` WHERE `sku_id` = #{skuId}
|
||||
AND (`on_hand_quantity` * #{ratio} <> ROUND(`on_hand_quantity` * #{ratio}, 3) OR ABS(`on_hand_quantity` * #{ratio}) > 999999999999999.999
|
||||
OR `reserved_quantity` * #{ratio} <> ROUND(`reserved_quantity` * #{ratio}, 3) OR ABS(`reserved_quantity` * #{ratio}) > 999999999999999.999)
|
||||
UNION ALL SELECT 1 FROM `gao_sales_order_item` WHERE `sku_id` = #{skuId}
|
||||
AND (`base_quantity` * #{ratio} <> ROUND(`base_quantity` * #{ratio}, 3) OR ABS(`base_quantity` * #{ratio}) > 999999999999999.999
|
||||
OR `reserved_base_quantity` * #{ratio} <> ROUND(`reserved_base_quantity` * #{ratio}, 3) OR ABS(`reserved_base_quantity` * #{ratio}) > 999999999999999.999
|
||||
OR `fulfilled_base_quantity` * #{ratio} <> ROUND(`fulfilled_base_quantity` * #{ratio}, 3) OR ABS(`fulfilled_base_quantity` * #{ratio}) > 999999999999999.999)
|
||||
UNION ALL SELECT 1 FROM `gao_order_fulfillment_item` WHERE `sku_id` = #{skuId}
|
||||
AND (`base_quantity` * #{ratio} <> ROUND(`base_quantity` * #{ratio}, 3) OR ABS(`base_quantity` * #{ratio}) > 999999999999999.999
|
||||
OR `reserved_base_before` * #{ratio} <> ROUND(`reserved_base_before` * #{ratio}, 3) OR ABS(`reserved_base_before` * #{ratio}) > 999999999999999.999
|
||||
OR `reserved_base_after` * #{ratio} <> ROUND(`reserved_base_after` * #{ratio}, 3) OR ABS(`reserved_base_after` * #{ratio}) > 999999999999999.999
|
||||
OR `fulfilled_base_before` * #{ratio} <> ROUND(`fulfilled_base_before` * #{ratio}, 3) OR ABS(`fulfilled_base_before` * #{ratio}) > 999999999999999.999
|
||||
OR `fulfilled_base_after` * #{ratio} <> ROUND(`fulfilled_base_after` * #{ratio}, 3) OR ABS(`fulfilled_base_after` * #{ratio}) > 999999999999999.999)
|
||||
UNION ALL SELECT 1 FROM `gao_product_stock_record` WHERE `sku_id` = #{skuId}
|
||||
AND (`base_quantity` * #{ratio} <> ROUND(`base_quantity` * #{ratio}, 3) OR ABS(`base_quantity` * #{ratio}) > 999999999999999.999
|
||||
OR `on_hand_delta` * #{ratio} <> ROUND(`on_hand_delta` * #{ratio}, 3) OR ABS(`on_hand_delta` * #{ratio}) > 999999999999999.999
|
||||
OR `reserved_delta` * #{ratio} <> ROUND(`reserved_delta` * #{ratio}, 3) OR ABS(`reserved_delta` * #{ratio}) > 999999999999999.999
|
||||
OR `on_hand_before` * #{ratio} <> ROUND(`on_hand_before` * #{ratio}, 3) OR ABS(`on_hand_before` * #{ratio}) > 999999999999999.999
|
||||
OR `on_hand_after` * #{ratio} <> ROUND(`on_hand_after` * #{ratio}, 3) OR ABS(`on_hand_after` * #{ratio}) > 999999999999999.999
|
||||
OR `reserved_before` * #{ratio} <> ROUND(`reserved_before` * #{ratio}, 3) OR ABS(`reserved_before` * #{ratio}) > 999999999999999.999
|
||||
OR `reserved_after` * #{ratio} <> ROUND(`reserved_after` * #{ratio}, 3) OR ABS(`reserved_after` * #{ratio}) > 999999999999999.999)
|
||||
UNION ALL SELECT 1 FROM `gao_point_redemption` WHERE `sku_id_snapshot` = #{skuId}
|
||||
AND (`base_quantity` * #{ratio} <> ROUND(`base_quantity` * #{ratio}, 3) OR ABS(`base_quantity` * #{ratio}) > 999999999999999.999)
|
||||
UNION ALL SELECT 1 FROM `gao_point_redemption_return` r
|
||||
JOIN `gao_point_redemption` d ON d.`id` = r.`redemption_id`
|
||||
WHERE d.`sku_id_snapshot` = #{skuId}
|
||||
AND (r.`base_quantity` * #{ratio} <> ROUND(r.`base_quantity` * #{ratio}, 3) OR ABS(r.`base_quantity` * #{ratio}) > 999999999999999.999)
|
||||
UNION ALL SELECT 1 FROM `gao_product_sku_unit` WHERE `sku_id` = #{skuId} AND `deleted_at` IS NULL
|
||||
AND (#{targetUnitId} IS NULL OR `id` <> #{targetUnitId})
|
||||
AND (`base_quantity_per_unit` * #{ratio} <> ROUND(`base_quantity_per_unit` * #{ratio}, 6) OR ABS(`base_quantity_per_unit` * #{ratio}) > 999999999999.999999)
|
||||
UNION ALL SELECT 1 FROM `gao_sales_order_item` WHERE `sku_id` = #{skuId}
|
||||
AND (ABS(`base_quantity_per_unit_snapshot` * #{ratio}) > 999999999999.999999 OR `base_quantity_per_unit_snapshot` * #{ratio} <> ROUND(`base_quantity_per_unit_snapshot` * #{ratio}, 6))
|
||||
UNION ALL SELECT 1 FROM `gao_order_fulfillment_item` WHERE `sku_id` = #{skuId}
|
||||
AND (ABS(`base_quantity_per_unit_snapshot` * #{ratio}) > 999999999999.999999 OR `base_quantity_per_unit_snapshot` * #{ratio} <> ROUND(`base_quantity_per_unit_snapshot` * #{ratio}, 6))
|
||||
UNION ALL SELECT 1 FROM `gao_product_stock_record` WHERE `sku_id` = #{skuId}
|
||||
AND (ABS(`base_quantity_per_unit_snapshot` * #{ratio}) > 999999999999.999999 OR `base_quantity_per_unit_snapshot` * #{ratio} <> ROUND(`base_quantity_per_unit_snapshot` * #{ratio}, 6))
|
||||
UNION ALL SELECT 1 FROM `gao_package_config_item` WHERE `sku_id` = #{skuId}
|
||||
AND (ABS(`base_quantity_per_unit_snapshot` * #{ratio}) > 999999999999.999999 OR `base_quantity_per_unit_snapshot` * #{ratio} <> ROUND(`base_quantity_per_unit_snapshot` * #{ratio}, 6))
|
||||
UNION ALL SELECT 1 FROM `gao_package_config_item` WHERE `sku_id` = #{skuId}
|
||||
AND (`default_quantity` * `base_quantity_per_unit_snapshot` * #{ratio} <> ROUND(`default_quantity` * `base_quantity_per_unit_snapshot` * #{ratio}, 3)
|
||||
OR ABS(`default_quantity` * `base_quantity_per_unit_snapshot` * #{ratio}) > 999999999999999.999)
|
||||
UNION ALL SELECT 1 FROM `gao_point_redemption` WHERE `sku_id_snapshot` = #{skuId}
|
||||
AND (ABS(`base_quantity_per_unit_snapshot` * #{ratio}) > 999999999999.999999 OR `base_quantity_per_unit_snapshot` * #{ratio} <> ROUND(`base_quantity_per_unit_snapshot` * #{ratio}, 6))
|
||||
) precision_issue
|
||||
</select>
|
||||
<update id="updateProductOrderSnapshots">UPDATE `gao_sales_order_item` SET `product_name_snapshot`=#{productName} WHERE `product_id_snapshot`=#{productId}</update>
|
||||
<update id="updateProductFulfillmentSnapshots">UPDATE `gao_order_fulfillment_item` SET `product_name_snapshot`=#{productName} WHERE `product_id_snapshot`=#{productId}</update>
|
||||
<update id="updateProductStockRecordSnapshots">UPDATE `gao_product_stock_record` SET `product_name_snapshot`=#{productName} WHERE `product_id_snapshot`=#{productId}</update>
|
||||
<update id="updateProductPackageSnapshots">UPDATE `gao_package_config_item` SET `product_name_snapshot`=#{productName} WHERE `product_id_snapshot`=#{productId}</update>
|
||||
<update id="updateProductRedemptionSnapshots">UPDATE `gao_point_redemption` SET `product_name_snapshot`=#{productName} WHERE `product_id_snapshot`=#{productId}</update>
|
||||
<update id="updateSkuOrderSnapshots">UPDATE `gao_sales_order_item` SET `sku_code_snapshot`=#{skuCode}, `sku_name_snapshot`=#{skuName}, `spec_summary_snapshot`=#{specSummary}, `sku_spec_snapshot`=#{skuSpecSnapshot} WHERE `sku_id`=#{skuId}</update>
|
||||
<update id="updateSkuFulfillmentSnapshots">UPDATE `gao_order_fulfillment_item` SET `sku_code_snapshot`=#{skuCode}, `sku_name_snapshot`=#{skuName}, `spec_summary_snapshot`=#{specSummary}, `sku_spec_snapshot`=#{skuSpecSnapshot} WHERE `sku_id`=#{skuId}</update>
|
||||
<update id="updateSkuStockRecordSnapshots">UPDATE `gao_product_stock_record` SET `sku_code_snapshot`=#{skuCode}, `sku_name_snapshot`=#{skuName}, `spec_summary_snapshot`=#{specSummary}, `sku_spec_snapshot`=#{skuSpecSnapshot} WHERE `sku_id`=#{skuId}</update>
|
||||
<update id="updateSkuPackageSnapshots">UPDATE `gao_package_config_item` SET `sku_code_snapshot`=#{skuCode}, `sku_name_snapshot`=#{skuName}, `spec_summary_snapshot`=#{specSummary} WHERE `sku_id`=#{skuId}</update>
|
||||
<update id="updateSkuRedemptionSnapshots">UPDATE `gao_point_redemption` SET `sku_code_snapshot`=#{skuCode}, `sku_name_snapshot`=#{skuName}, `sku_spec_snapshot`=#{skuSpecSnapshot} WHERE `sku_id_snapshot`=#{skuId}</update>
|
||||
<update id="updateUnitOrderSnapshots">UPDATE `gao_sales_order_item` SET `unit_snapshot`=#{unitName} WHERE `sku_unit_id`=#{unitId}</update>
|
||||
<update id="updateUnitFulfillmentSnapshots">UPDATE `gao_order_fulfillment_item` SET `unit_snapshot`=#{unitName} WHERE `sku_unit_id`=#{unitId}</update>
|
||||
<update id="updateUnitStockRecordSnapshots">UPDATE `gao_product_stock_record` SET `unit_snapshot`=#{unitName} WHERE `sku_unit_id`=#{unitId}</update>
|
||||
<update id="updateUnitPackageSnapshots">UPDATE `gao_package_config_item` SET `unit_snapshot`=#{unitName} WHERE `sku_unit_id`=#{unitId}</update>
|
||||
<update id="updateUnitRedemptionSnapshots">UPDATE `gao_point_redemption` SET `unit_snapshot`=#{unitName} WHERE `sku_unit_id_snapshot`=#{unitId}</update>
|
||||
<update id="scaleSkuMinimumStock">UPDATE `gao_product_sku` SET `min_stock_quantity`=`min_stock_quantity`*#{ratio} WHERE `id`=#{skuId} AND `min_stock_quantity` IS NOT NULL</update>
|
||||
<update id="scaleProductStock">UPDATE `gao_product_stock` SET `on_hand_quantity`=`on_hand_quantity`*#{ratio}, `reserved_quantity`=`reserved_quantity`*#{ratio}, `updated_at`=FLOOR(UNIX_TIMESTAMP(NOW(3))*1000) WHERE `sku_id`=#{skuId}</update>
|
||||
<update id="scaleSalesOrderItems">UPDATE `gao_sales_order_item` SET `base_quantity`=`base_quantity`*#{ratio}, `reserved_base_quantity`=`reserved_base_quantity`*#{ratio}, `fulfilled_base_quantity`=`fulfilled_base_quantity`*#{ratio}, `base_quantity_per_unit_snapshot`=`base_quantity_per_unit_snapshot`*#{ratio} WHERE `sku_id`=#{skuId}</update>
|
||||
<update id="scaleFulfillmentItems">UPDATE `gao_order_fulfillment_item` SET `base_quantity`=`base_quantity`*#{ratio}, `reserved_base_before`=`reserved_base_before`*#{ratio}, `reserved_base_after`=`reserved_base_after`*#{ratio}, `fulfilled_base_before`=`fulfilled_base_before`*#{ratio}, `fulfilled_base_after`=`fulfilled_base_after`*#{ratio}, `base_quantity_per_unit_snapshot`=`base_quantity_per_unit_snapshot`*#{ratio} WHERE `sku_id`=#{skuId}</update>
|
||||
<update id="scaleStockRecords">UPDATE `gao_product_stock_record` SET `base_quantity`=`base_quantity`*#{ratio}, `on_hand_delta`=`on_hand_delta`*#{ratio}, `reserved_delta`=`reserved_delta`*#{ratio}, `on_hand_before`=`on_hand_before`*#{ratio}, `on_hand_after`=`on_hand_after`*#{ratio}, `reserved_before`=`reserved_before`*#{ratio}, `reserved_after`=`reserved_after`*#{ratio}, `base_quantity_per_unit_snapshot`=`base_quantity_per_unit_snapshot`*#{ratio} WHERE `sku_id`=#{skuId}</update>
|
||||
<update id="scalePackageConfigItems">UPDATE `gao_package_config_item` SET `base_quantity_per_unit_snapshot`=`base_quantity_per_unit_snapshot`*#{ratio} WHERE `sku_id`=#{skuId}</update>
|
||||
<update id="scalePointRedemptions">UPDATE `gao_point_redemption` SET `base_quantity`=`base_quantity`*#{ratio}, `base_quantity_per_unit_snapshot`=`base_quantity_per_unit_snapshot`*#{ratio} WHERE `sku_id_snapshot`=#{skuId}</update>
|
||||
<update id="scalePointRedemptionReturns">
|
||||
UPDATE `gao_point_redemption_return` r
|
||||
JOIN `gao_point_redemption` d ON d.`id`=r.`redemption_id`
|
||||
SET r.`base_quantity`=r.`base_quantity`*#{ratio}
|
||||
WHERE d.`sku_id_snapshot`=#{skuId}
|
||||
</update>
|
||||
</mapper>
|
||||
@@ -5,4 +5,5 @@
|
||||
<select id="selectByProductIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoProductSpec">SELECT * FROM `gao_product_spec` WHERE `deleted_at` IS NULL <choose><when test="productIdList != null and !productIdList.isEmpty()">AND `product_id` IN <foreach collection="productIdList" item="id" open="(" separator="," close=")">#{id}</foreach></when><otherwise>AND FALSE</otherwise></choose> ORDER BY `product_id`, `sort`, `created_at`</select>
|
||||
<select id="selectProductIdBySpecValueId" resultType="string">SELECT `s`.`product_id` FROM `gao_product_spec_value` `v` INNER JOIN `gao_product_spec` `s` ON `s`.`id`=`v`.`spec_id` AND `s`.`deleted_at` IS NULL WHERE `v`.`id`=#{specValueId} AND `v`.`deleted_at` IS NULL</select>
|
||||
<select id="selectProductIdBySpecId" resultType="string">SELECT `product_id` FROM `gao_product_spec` WHERE `id`=#{specId} AND `deleted_at` IS NULL</select>
|
||||
<update id="updateSpec">UPDATE `gao_product_spec` SET `name`=#{name},`sort`=#{sort},`updated_at`=FLOOR(UNIX_TIMESTAMP(NOW(3))*1000) WHERE `id`=#{id} AND `deleted_at` IS NULL</update>
|
||||
</mapper>
|
||||
|
||||
@@ -3,4 +3,5 @@
|
||||
<mapper namespace="com.imyeyu.api.modules.gao.mapper.GaoProductSpecValueMapper">
|
||||
<select id="selectById" resultType="com.imyeyu.api.modules.gao.entity.GaoProductSpecValue">SELECT * FROM `gao_product_spec_value` WHERE `id` = #{id} AND `deleted_at` IS NULL</select>
|
||||
<select id="selectBySpecIdList" resultType="com.imyeyu.api.modules.gao.entity.GaoProductSpecValue">SELECT * FROM `gao_product_spec_value` WHERE `deleted_at` IS NULL <choose><when test="specIdList != null and !specIdList.isEmpty()">AND `spec_id` IN <foreach collection="specIdList" item="id" open="(" separator="," close=")">#{id}</foreach></when><otherwise>AND FALSE</otherwise></choose> ORDER BY `spec_id`, `sort`, `created_at`</select>
|
||||
<update id="updateValue">UPDATE `gao_product_spec_value` SET `name`=#{name},`sort`=#{sort},`updated_at`=FLOOR(UNIX_TIMESTAMP(NOW(3))*1000) WHERE `id`=#{id} AND `deleted_at` IS NULL</update>
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user