重构打单套餐相关逻辑,更新服务接口,优化保存和查询功能

This commit is contained in:
wuweihua
2026-11-13 11:27:58 +08:00
parent 6675808dfc
commit a024b45940
37 changed files with 11647 additions and 160 deletions
@@ -0,0 +1,320 @@
<?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.bms.price.mapper.LblProductMapper">
<insert id="insertProduct" useGeneratedKeys="true" keyProperty="productId">
insert into prc_label_product (
product_name, dict_value, country_scope, charge_type, extra_per_kg, service_type, classification,
catalog_remark, update_content, weight_limit, sheet_name, related_sheet, source_file, file_path, file_md5,
supplier_name, currency, service_note, parse_status, weight_count, surcharge_count,
created_by, create_time, updated_by, update_time, remark
) values (
#{productName}, #{dictValue}, #{countryScope}, #{chargeType}, #{extraPerKg}, #{serviceType}, #{classification},
#{catalogRemark}, #{updateContent}, #{weightLimit}, #{sheetName}, #{relatedSheet}, #{sourceFile}, #{filePath}, #{fileMd5},
#{supplierName}, #{currency}, #{serviceNote}, ifnull(#{parseStatus}, 'OK'), ifnull(#{weightCount}, 0), ifnull(#{surchargeCount}, 0),
#{createBy}, sysdate(), #{updateBy}, sysdate(), #{remark}
)
</insert>
<update id="updateProduct">
update prc_label_product
set product_name = #{productName},
dict_value = #{dictValue},
country_scope = #{countryScope},
charge_type = #{chargeType},
extra_per_kg = #{extraPerKg},
service_type = #{serviceType},
classification = #{classification},
catalog_remark = #{catalogRemark},
update_content = #{updateContent},
weight_limit = #{weightLimit},
sheet_name = #{sheetName},
related_sheet = #{relatedSheet},
source_file = #{sourceFile},
file_path = #{filePath},
file_md5 = #{fileMd5},
supplier_name = #{supplierName},
currency = #{currency},
service_note = #{serviceNote},
parse_status = ifnull(#{parseStatus}, parse_status),
weight_count = ifnull(#{weightCount}, weight_count),
surcharge_count = ifnull(#{surchargeCount}, surcharge_count),
updated_by = #{updateBy},
update_time = sysdate(),
remark = #{remark}
where product_id = #{productId}
</update>
<select id="selectProductById" resultType="com.bms.price.domain.LblProduct">
select product_id as productId, product_name as productName, dict_value as dictValue, country_scope as countryScope,
charge_type as chargeType, extra_per_kg as extraPerKg, service_type as serviceType, classification,
catalog_remark as catalogRemark, update_content as updateContent, weight_limit as weightLimit,
sheet_name as sheetName, related_sheet as relatedSheet, source_file as sourceFile, file_path as filePath,
file_md5 as fileMd5, supplier_name as supplierName, currency, service_note as serviceNote,
parse_status as parseStatus, weight_count as weightCount, surcharge_count as surchargeCount,
created_by as createBy, create_time as createTime, updated_by as updateBy, update_time as updateTime, remark
from prc_label_product where product_id = #{productId}
</select>
<select id="selectProductByDict" resultType="com.bms.price.domain.LblProduct">
select product_id as productId, product_name as productName, dict_value as dictValue
from prc_label_product where dict_value = #{dictValue} order by product_id desc limit 1
</select>
<select id="selectProductIdBySetAndDict" resultType="long">
select v.product_id
from prc_label_product_version v
where v.price_set_id = #{priceSetId} and v.dict_value = #{dictValue}
order by v.version_id desc limit 1
</select>
<insert id="insertVersion" useGeneratedKeys="true" keyProperty="versionId">
insert into prc_label_product_version (
price_set_id, product_id, dict_value, version_no, effective_start, effective_end, file_path, status,
created_by, create_time, updated_by, update_time, remark
) values (
#{priceSetId}, #{productId}, #{dictValue}, ifnull(#{versionNo}, 1), #{effectiveStart}, #{effectiveEnd}, #{filePath},
ifnull(#{status}, '0'), #{createBy}, sysdate(), #{updateBy}, sysdate(), #{remark}
)
</insert>
<update id="updateVersion">
update prc_label_product_version
set effective_start = #{effectiveStart},
effective_end = #{effectiveEnd},
file_path = #{filePath},
status = #{status},
updated_by = #{updateBy},
update_time = sysdate(),
remark = #{remark}
where version_id = #{versionId}
</update>
<update id="closePendingBySetProduct">
update prc_label_product_version
set status = '2',
effective_end = ifnull(effective_end, #{endDate}),
updated_by = #{operator},
update_time = sysdate()
where price_set_id = #{priceSetId}
and product_id = #{productId}
and status = '0'
</update>
<select id="selectVersionIdsBySetAndNo" resultType="long">
select version_id from prc_label_product_version
where price_set_id = #{priceSetId} and version_no = #{versionNo}
</select>
<delete id="deletePendingVersionsBySetAndNo">
delete from prc_label_product_version
where price_set_id = #{priceSetId} and version_no = #{versionNo} and status = '0'
</delete>
<delete id="deleteAllVersionsBySetAndNo">
delete from prc_label_product_version
where price_set_id = #{priceSetId} and version_no = #{versionNo}
</delete>
<select id="selectVersionsBySet" resultType="com.bms.price.domain.LblProductVersion">
select v.version_id as versionId, v.price_set_id as priceSetId, v.product_id as productId, v.dict_value as dictValue,
v.version_no as versionNo, v.effective_start as effectiveStart, v.effective_end as effectiveEnd, v.file_path as filePath,
v.status, p.product_name as productName, p.source_file as sourceFile, p.weight_count as weightCount,
p.surcharge_count as surchargeCount, p.currency
from prc_label_product_version v
join prc_label_product p on p.product_id = v.product_id
where v.price_set_id = #{priceSetId} and v.status in ('0', '1')
order by p.product_name, v.version_id desc
</select>
<select id="selectVersionsBySetAndNo" resultType="com.bms.price.domain.LblProductVersion">
select v.version_id as versionId, v.price_set_id as priceSetId, v.product_id as productId, v.dict_value as dictValue,
v.version_no as versionNo, v.effective_start as effectiveStart, v.effective_end as effectiveEnd, v.file_path as filePath,
v.status, p.product_name as productName, p.source_file as sourceFile, p.weight_count as weightCount,
p.surcharge_count as surchargeCount, p.currency
from prc_label_product_version v
join prc_label_product p on p.product_id = v.product_id
where v.price_set_id = #{priceSetId} and v.version_no = #{versionNo}
order by p.product_name, v.version_id desc
</select>
<select id="selectVersionById" resultType="com.bms.price.domain.LblProductVersion">
select version_id as versionId, price_set_id as priceSetId, product_id as productId, dict_value as dictValue,
version_no as versionNo, effective_start as effectiveStart, effective_end as effectiveEnd, file_path as filePath, status
from prc_label_product_version where version_id = #{versionId}
</select>
<select id="selectMaxVersionNo" resultType="int">
select ifnull(max(version_no), 0) from prc_label_product_version where price_set_id = #{priceSetId}
</select>
<select id="selectLabelVersionGroups" resultType="com.bms.price.domain.LabelPackageVersion">
select price_set_id as priceSetId,
version_no as versionNo,
min(effective_start) as effectiveTime,
max(effective_end) as expireTime,
count(1) as productCount,
sum(case when status = '1' then 1 else 0 end) as activeCount,
sum(case when status = '0' then 1 else 0 end) as pendingCount,
min(create_time) as createTime
from prc_label_product_version
where price_set_id = #{priceSetId}
group by price_set_id, version_no
order by version_no desc
</select>
<insert id="insertWeightBand" useGeneratedKeys="true" keyProperty="bandId">
insert into prc_label_weight_band (
product_id, version_id, fee_type, country_name, country_code, zone_code, zone_name, postcode_param,
weight_label, weight_min, weight_max, volume_text, charge_name, charge_mode, calc_param,
price, price_unit, extra_price, extra_price_unit, sort_no
) values (
#{productId}, #{versionId}, ifnull(#{feeType}, 'FREIGHT'), #{countryName}, ifnull(#{countryCode}, ''), ifnull(#{zoneCode}, ''), #{zoneName}, ifnull(#{postcodeParam}, ''),
#{weightLabel}, #{weightMin}, #{weightMax}, #{volumeText}, #{chargeName}, ifnull(#{chargeMode}, 'ITEM'), #{calcParam},
#{price}, #{priceUnit}, #{extraPrice}, #{extraPriceUnit}, ifnull(#{sortNo}, 0)
)
</insert>
<update id="updateWeightBand">
update prc_label_weight_band
set fee_type = ifnull(#{feeType}, fee_type),
charge_mode = ifnull(#{chargeMode}, charge_mode),
calc_param = #{calcParam},
postcode_param = ifnull(#{postcodeParam}, ''),
price = #{price},
extra_price = #{extraPrice}
where band_id = #{bandId}
</update>
<select id="selectWeightBandById" resultType="com.bms.price.domain.LblWeightBand">
select band_id as bandId, product_id as productId, version_id as versionId, fee_type as feeType,
country_name as countryName, country_code as countryCode, zone_code as zoneCode, zone_name as zoneName,
postcode_param as postcodeParam, weight_label as weightLabel, weight_min as weightMin, weight_max as weightMax,
volume_text as volumeText, charge_name as chargeName, charge_mode as chargeMode, calc_param as calcParam,
price, price_unit as priceUnit, extra_price as extraPrice, extra_price_unit as extraPriceUnit, sort_no as sortNo
from prc_label_weight_band where band_id = #{bandId}
</select>
<delete id="deleteWeightBandsByVersion">
delete from prc_label_weight_band where version_id = #{versionId}
</delete>
<select id="selectWeightBandsByVersion" resultType="com.bms.price.domain.LblWeightBand">
select band_id as bandId, product_id as productId, version_id as versionId, fee_type as feeType,
country_name as countryName, country_code as countryCode, zone_code as zoneCode, zone_name as zoneName,
postcode_param as postcodeParam, weight_label as weightLabel, weight_min as weightMin, weight_max as weightMax,
volume_text as volumeText, charge_name as chargeName, charge_mode as chargeMode, calc_param as calcParam,
price, price_unit as priceUnit, extra_price as extraPrice, extra_price_unit as extraPriceUnit, sort_no as sortNo
from prc_label_weight_band where version_id = #{versionId} order by sort_no, band_id
</select>
<insert id="insertSurcharge" useGeneratedKeys="true" keyProperty="surchargeId">
insert into prc_label_surcharge (
product_id, version_id, fee_name, sc_id, zone_code, zone_name, charge_text, amount, currency, price_unit,
fee_desc, period_text, effective_start, effective_end, charge_timing, calc_rule, calc_param, postcode_param,
weight_min, weight_max, sort_no
) values (
#{productId}, #{versionId}, #{feeName}, #{scId}, #{zoneCode}, #{zoneName}, #{chargeText}, #{amount}, #{currency}, #{priceUnit},
#{feeDesc}, #{periodText}, #{effectiveStart}, #{effectiveEnd}, #{chargeTiming}, ifnull(#{calcRule}, 'MANUAL'), #{calcParam}, #{postcodeParam},
#{weightMin}, #{weightMax}, ifnull(#{sortNo}, 0)
)
</insert>
<update id="updateSurcharge">
update prc_label_surcharge
set fee_name = ifnull(#{feeName}, fee_name),
amount = #{amount},
currency = #{currency},
price_unit = #{priceUnit},
charge_text = #{chargeText},
fee_desc = #{feeDesc},
calc_rule = ifnull(#{calcRule}, calc_rule),
calc_param = #{calcParam},
postcode_param = #{postcodeParam},
zone_code = #{zoneCode},
zone_name = #{zoneName}
where surcharge_id = #{surchargeId}
</update>
<select id="selectSurchargeById" resultType="com.bms.price.domain.LblSurcharge">
select surcharge_id as surchargeId, product_id as productId, version_id as versionId, fee_name as feeName,
sc_id as scId, zone_code as zoneCode, zone_name as zoneName, charge_text as chargeText, amount, currency,
price_unit as priceUnit, fee_desc as feeDesc, period_text as periodText,
effective_start as effectiveStart, effective_end as effectiveEnd, charge_timing as chargeTiming,
calc_rule as calcRule, calc_param as calcParam, postcode_param as postcodeParam,
weight_min as weightMin, weight_max as weightMax, sort_no as sortNo
from prc_label_surcharge where surcharge_id = #{surchargeId}
</select>
<delete id="deleteSurchargesByVersion">
delete from prc_label_surcharge where version_id = #{versionId}
</delete>
<select id="selectSurchargesByVersion" resultType="com.bms.price.domain.LblSurcharge">
select surcharge_id as surchargeId, product_id as productId, version_id as versionId, fee_name as feeName, sc_id as scId,
zone_code as zoneCode, zone_name as zoneName, charge_text as chargeText, amount, currency, price_unit as priceUnit,
fee_desc as feeDesc, period_text as periodText, effective_start as effectiveStart, effective_end as effectiveEnd,
charge_timing as chargeTiming, calc_rule as calcRule, calc_param as calcParam, postcode_param as postcodeParam,
weight_min as weightMin, weight_max as weightMax, sort_no as sortNo
from prc_label_surcharge where version_id = #{versionId} order by sort_no, surcharge_id
</select>
<select id="selectVersionIdsBySetAndProducts" resultType="long">
select version_id from prc_label_product_version
where price_set_id = #{priceSetId}
and product_id in
<foreach collection="productIds" item="id" open="(" separator="," close=")">#{id}</foreach>
</select>
<delete id="deleteVersionsBySetAndProducts">
delete from prc_label_product_version
where price_set_id = #{priceSetId}
and product_id in
<foreach collection="productIds" item="id" open="(" separator="," close=")">#{id}</foreach>
</delete>
<select id="selectProductsBySet" resultType="com.bms.price.domain.LblProduct">
select p.product_id as productId, p.product_name as productName, p.dict_value as dictValue,
v.version_id as versionId, v.version_no as versionNo, v.status as versionStatus,
v.effective_start as versionStart, v.effective_end as versionEnd,
p.country_scope as countryScope, p.charge_type as chargeType, p.currency, p.sheet_name as sheetName,
p.source_file as sourceFile, p.file_path as filePath, p.weight_count as weightCount, p.surcharge_count as surchargeCount
from prc_label_product_version v
join prc_label_product p on p.product_id = v.product_id
where v.price_set_id = #{priceSetId} and v.status in ('0', '1')
order by p.product_name, v.version_id desc
</select>
<select id="selectProductsBySetAndVersion" resultType="com.bms.price.domain.LblProduct">
select p.product_id as productId, p.product_name as productName, p.dict_value as dictValue,
v.version_id as versionId, v.version_no as versionNo, v.status as versionStatus,
v.effective_start as versionStart, v.effective_end as versionEnd,
p.country_scope as countryScope, p.charge_type as chargeType, p.currency, p.sheet_name as sheetName,
p.source_file as sourceFile, p.file_path as filePath, p.weight_count as weightCount, p.surcharge_count as surchargeCount
from prc_label_product_version v
join prc_label_product p on p.product_id = v.product_id
where v.price_set_id = #{priceSetId} and v.version_no = #{versionNo}
order by p.product_name, v.version_id desc
</select>
<update id="activateVersionRows">
update prc_label_product_version
set status = '1',
effective_start = #{effectiveStart},
updated_by = #{operator},
update_time = sysdate()
where price_set_id = #{priceSetId} and version_no = #{versionNo}
</update>
<update id="expireOtherActive">
update prc_label_product_version
set status = '2',
effective_end = #{endDate},
updated_by = #{operator},
update_time = sysdate()
where price_set_id = #{priceSetId}
and version_no &lt;&gt; #{versionNo}
and status = '1'
</update>
</mapper>