Merge branch 'test' of https://git.lionquexpress.com/wuweihua/BMS into test
# Conflicts: # bms-back/bms-system/src/main/java/com/bms/price/domain/PrcPayBillFee.java # bms-back/bms-system/src/main/resources/mapper/price/PrcPayBillFeeMapper.xml
This commit is contained in:
@@ -50,18 +50,292 @@
|
||||
order by block_title asc
|
||||
</select>
|
||||
|
||||
<select id="selectLineList" parameterType="com.bms.price.domain.PayPostcodeLine" resultType="com.bms.price.domain.PayPostcodeLine">
|
||||
select line_id as lineId, group_id as groupId, country_name as countryName, country_code as countryCode,
|
||||
region_name as regionName, region_name_cn as regionNameCn, city_name as cityName, region_code as regionCode,
|
||||
zone_name as zoneName, postcode, postcode_raw as postcodeRaw, postcode_end as postcodeEnd,
|
||||
extra_text as extraText, sort_no as sortNo
|
||||
from pay_postcode_line
|
||||
<sql id="countryMatch">
|
||||
<choose>
|
||||
<when test="countryCode != null and countryCode != ''">
|
||||
and upper(trim(g.country_code)) = upper(trim(#{countryCode}))
|
||||
</when>
|
||||
<otherwise>
|
||||
and (g.country_code is null or trim(g.country_code) = '')
|
||||
and g.country_name = #{countryName}
|
||||
</otherwise>
|
||||
</choose>
|
||||
</sql>
|
||||
|
||||
<sql id="zoneExpr">
|
||||
case
|
||||
when nullif(trim(l.zone_name), '') is not null then trim(l.zone_name)
|
||||
when nullif(trim(l.region_name), '') is not null then trim(l.region_name)
|
||||
when nullif(trim(g.block_title), '') is not null then trim(g.block_title)
|
||||
else '未分区'
|
||||
end
|
||||
</sql>
|
||||
|
||||
<select id="selectCountryList" parameterType="com.bms.price.domain.PayPostcodeGroup" resultType="com.bms.price.domain.PayPostcodeGroup">
|
||||
select min(g.group_id) as groupId,
|
||||
max(g.country_name) as countryName,
|
||||
max(g.country_code) as countryCode,
|
||||
group_concat(distinct nullif(trim(g.coverage), '') order by g.coverage separator '、') as coverage,
|
||||
group_concat(distinct nullif(trim(g.service_type), '') order by g.service_type separator '、') as serviceType,
|
||||
group_concat(distinct nullif(trim(g.product_name), '') order by g.product_name separator '、') as productName,
|
||||
group_concat(distinct nullif(trim(g.channel_name), '') order by g.channel_name separator '、') as channelName,
|
||||
count(distinct
|
||||
case
|
||||
when l.line_id is not null then
|
||||
case
|
||||
when nullif(trim(l.zone_name), '') is not null then trim(l.zone_name)
|
||||
when nullif(trim(l.region_name), '') is not null then trim(l.region_name)
|
||||
when nullif(trim(g.block_title), '') is not null then trim(g.block_title)
|
||||
else '未分区'
|
||||
end
|
||||
when nullif(trim(g.block_title), '') is not null then trim(g.block_title)
|
||||
else null
|
||||
end
|
||||
) as zoneCount,
|
||||
count(l.line_id) as lineCount,
|
||||
max(g.create_time) as createTime
|
||||
from pay_postcode_group g
|
||||
left join pay_postcode_line l on l.group_id = g.group_id
|
||||
<where>
|
||||
<if test="groupId != null">and group_id = #{groupId}</if>
|
||||
<if test="postcode != null and postcode != ''">and postcode like concat('%', #{postcode}, '%')</if>
|
||||
<if test="regionName != null and regionName != ''">and (region_name like concat('%', #{regionName}, '%') or region_name_cn like concat('%', #{regionName}, '%') or zone_name like concat('%', #{regionName}, '%'))</if>
|
||||
<if test="countryName != null and countryName != ''">
|
||||
and (g.country_name like concat('%', #{countryName}, '%') or g.country_code like concat('%', #{countryName}, '%') or g.catalog_country like concat('%', #{countryName}, '%'))
|
||||
</if>
|
||||
<if test="serviceType != null and serviceType != ''">and g.service_type like concat('%', #{serviceType}, '%')</if>
|
||||
<if test="productName != null and productName != ''">and g.product_name like concat('%', #{productName}, '%')</if>
|
||||
<if test="channelName != null and channelName != ''">and g.channel_name like concat('%', #{channelName}, '%')</if>
|
||||
<if test="coverage != null and coverage != ''">and g.coverage = #{coverage}</if>
|
||||
<if test="postcode != null and postcode != ''">
|
||||
and exists (
|
||||
select 1 from pay_postcode_line lp
|
||||
where lp.group_id = g.group_id and lp.postcode like concat('%', #{postcode}, '%')
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
order by sort_no asc, line_id asc
|
||||
group by case
|
||||
when nullif(trim(g.country_code), '') is not null then upper(trim(g.country_code))
|
||||
when nullif(trim(g.country_name), '') is not null then trim(g.country_name)
|
||||
else '未填写国家'
|
||||
end
|
||||
order by max(g.create_time) desc
|
||||
</select>
|
||||
|
||||
<select id="selectZoneList" parameterType="com.bms.price.domain.PayPostcodeGroup" resultType="com.bms.price.domain.PayPostcodeGroup">
|
||||
select t.zone_name as zoneName,
|
||||
min(t.group_id) as groupId,
|
||||
group_concat(distinct nullif(trim(t.coverage), '') order by t.coverage separator '、') as coverage,
|
||||
count(t.line_id) as lineCount,
|
||||
max(t.country_name) as countryName,
|
||||
max(t.country_code) as countryCode
|
||||
from (
|
||||
select g.group_id, g.coverage, g.country_name, g.country_code, l.line_id,
|
||||
case
|
||||
when l.line_id is null then nullif(trim(g.block_title), '')
|
||||
else
|
||||
case
|
||||
when nullif(trim(l.zone_name), '') is not null then trim(l.zone_name)
|
||||
when nullif(trim(l.region_name), '') is not null then trim(l.region_name)
|
||||
when nullif(trim(g.block_title), '') is not null then trim(g.block_title)
|
||||
else '未分区'
|
||||
end
|
||||
end as zone_name
|
||||
from pay_postcode_group g
|
||||
left join pay_postcode_line l on l.group_id = g.group_id
|
||||
<where>
|
||||
<include refid="countryMatch"/>
|
||||
</where>
|
||||
) t
|
||||
where t.zone_name is not null and t.zone_name <> ''
|
||||
group by t.zone_name
|
||||
order by t.zone_name asc
|
||||
</select>
|
||||
|
||||
<select id="selectSampleGroup" parameterType="com.bms.price.domain.PayPostcodeGroup" resultType="com.bms.price.domain.PayPostcodeGroup">
|
||||
select group_id as groupId, source_file as sourceFile, file_md5 as fileMd5, sheet_name as sheetName,
|
||||
block_title as blockTitle, config_kind as configKind, coverage, channel_name as channelName,
|
||||
country_name as countryName, country_code as countryCode,
|
||||
service_type as serviceType, catalog_country as catalogCountry, product_name as productName, quote_sheet as quoteSheet
|
||||
from pay_postcode_group g
|
||||
<where>
|
||||
<include refid="countryMatch"/>
|
||||
</where>
|
||||
order by g.group_id asc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="countZoneName" parameterType="com.bms.price.domain.PayPostcodeGroup" resultType="int">
|
||||
select count(*) from (
|
||||
select 1
|
||||
from pay_postcode_group g
|
||||
left join pay_postcode_line l on l.group_id = g.group_id
|
||||
<where>
|
||||
<include refid="countryMatch"/>
|
||||
and (
|
||||
(l.line_id is null and trim(g.block_title) = #{zoneName})
|
||||
or (l.line_id is not null and <include refid="zoneExpr"/> = #{zoneName})
|
||||
)
|
||||
</where>
|
||||
limit 1
|
||||
) hit
|
||||
</select>
|
||||
|
||||
<select id="selectZoneGroupId" parameterType="com.bms.price.domain.PayPostcodeGroup" resultType="long">
|
||||
select g.group_id
|
||||
from pay_postcode_group g
|
||||
left join pay_postcode_line l on l.group_id = g.group_id
|
||||
<where>
|
||||
<include refid="countryMatch"/>
|
||||
and (
|
||||
(g.source_file = '手工新增' and trim(g.block_title) = #{zoneName})
|
||||
or (l.line_id is not null and <include refid="zoneExpr"/> = #{zoneName})
|
||||
)
|
||||
</where>
|
||||
order by case when g.source_file = '手工新增' and trim(g.block_title) = #{zoneName} then 0 else 1 end, g.group_id asc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<update id="updateCountryProfile" parameterType="com.bms.price.domain.PayPostcodeGroup">
|
||||
update pay_postcode_group g
|
||||
set g.service_type = #{serviceType},
|
||||
g.product_name = #{productName},
|
||||
g.channel_name = #{channelName}
|
||||
<where>
|
||||
<include refid="countryMatch"/>
|
||||
</where>
|
||||
</update>
|
||||
|
||||
<select id="selectGroupIdsByCountry" parameterType="com.bms.price.domain.PayPostcodeGroup" resultType="long">
|
||||
select g.group_id from pay_postcode_group g
|
||||
<where>
|
||||
<include refid="countryMatch"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<update id="renameZoneLines" parameterType="com.bms.price.domain.PayPostcodeGroup">
|
||||
update pay_postcode_line l
|
||||
inner join pay_postcode_group g on g.group_id = l.group_id
|
||||
set l.zone_name = #{zoneName}
|
||||
<where>
|
||||
<include refid="countryMatch"/>
|
||||
and <include refid="zoneExpr"/> = #{oldZoneName}
|
||||
</where>
|
||||
</update>
|
||||
|
||||
<update id="updateExclusiveZone" parameterType="com.bms.price.domain.PayPostcodeGroup">
|
||||
update pay_postcode_group g
|
||||
set g.block_title = case
|
||||
when trim(g.block_title) = #{oldZoneName} or g.source_file = '手工新增' then #{zoneName}
|
||||
else g.block_title
|
||||
end,
|
||||
g.coverage = #{coverage},
|
||||
g.fee_name = case
|
||||
when #{coverage} = 'REMOTE' and (g.fee_name is null or trim(g.fee_name) = '') then '偏远'
|
||||
else g.fee_name
|
||||
end
|
||||
<where>
|
||||
<include refid="countryMatch"/>
|
||||
and (
|
||||
trim(g.block_title) = #{oldZoneName}
|
||||
or (
|
||||
exists (
|
||||
select 1 from pay_postcode_line l
|
||||
where l.group_id = g.group_id and <include refid="zoneExpr"/> = #{zoneName}
|
||||
)
|
||||
and not exists (
|
||||
select 1 from pay_postcode_line l
|
||||
where l.group_id = g.group_id and <include refid="zoneExpr"/> <> #{zoneName}
|
||||
)
|
||||
)
|
||||
)
|
||||
</where>
|
||||
</update>
|
||||
|
||||
<insert id="insertLine" parameterType="com.bms.price.domain.PayPostcodeLine" useGeneratedKeys="true" keyProperty="lineId">
|
||||
insert into pay_postcode_line (
|
||||
group_id, country_name, country_code, region_name, region_name_cn, city_name, region_code,
|
||||
zone_name, postcode, postcode_raw, postcode_end, extra_text, sort_no
|
||||
) values (
|
||||
#{groupId}, #{countryName}, #{countryCode}, #{regionName}, #{regionNameCn}, #{cityName}, #{regionCode},
|
||||
#{zoneName}, #{postcode}, #{postcodeRaw}, #{postcodeEnd}, #{extraText}, ifnull(#{sortNo}, 0)
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateLine" parameterType="com.bms.price.domain.PayPostcodeLine">
|
||||
update pay_postcode_line
|
||||
set city_name = #{cityName},
|
||||
zone_name = #{zoneName},
|
||||
postcode = #{postcode},
|
||||
postcode_raw = #{postcodeRaw},
|
||||
postcode_end = #{postcodeEnd}
|
||||
where line_id = #{lineId}
|
||||
</update>
|
||||
|
||||
<select id="selectLineById" resultType="com.bms.price.domain.PayPostcodeLine">
|
||||
select line_id as lineId, group_id as groupId, country_name as countryName, country_code as countryCode,
|
||||
city_name as cityName, zone_name as zoneName, postcode, postcode_raw as postcodeRaw, postcode_end as postcodeEnd
|
||||
from pay_postcode_line
|
||||
where line_id = #{lineId}
|
||||
</select>
|
||||
|
||||
<select id="selectGroupIdsByLineIds" resultType="long">
|
||||
select distinct group_id from pay_postcode_line
|
||||
where line_id in
|
||||
<foreach collection="lineIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</select>
|
||||
|
||||
<delete id="deleteLineByIds">
|
||||
delete from pay_postcode_line where line_id in
|
||||
<foreach collection="lineIds" item="id" open="(" separator="," close=")">#{id}</foreach>
|
||||
</delete>
|
||||
|
||||
<delete id="deleteLinesByZone" parameterType="com.bms.price.domain.PayPostcodeGroup">
|
||||
delete l from pay_postcode_line l
|
||||
inner join pay_postcode_group g on g.group_id = l.group_id
|
||||
<where>
|
||||
<include refid="countryMatch"/>
|
||||
and <include refid="zoneExpr"/> = #{zoneName}
|
||||
</where>
|
||||
</delete>
|
||||
|
||||
<update id="refreshLineCount">
|
||||
update pay_postcode_group g
|
||||
set g.line_count = (select count(*) from pay_postcode_line l where l.group_id = g.group_id)
|
||||
where g.group_id = #{groupId}
|
||||
</update>
|
||||
|
||||
<select id="selectLineList" parameterType="com.bms.price.domain.PayPostcodeLine" resultType="com.bms.price.domain.PayPostcodeLine">
|
||||
select l.line_id as lineId, l.group_id as groupId, l.country_name as countryName, l.country_code as countryCode,
|
||||
l.region_name as regionName, l.region_name_cn as regionNameCn, l.city_name as cityName, l.region_code as regionCode,
|
||||
l.zone_name as zoneName, l.postcode, l.postcode_raw as postcodeRaw, l.postcode_end as postcodeEnd,
|
||||
l.extra_text as extraText, l.sort_no as sortNo
|
||||
from pay_postcode_line l
|
||||
<where>
|
||||
<if test="groupId != null">and l.group_id = #{groupId}</if>
|
||||
<if test="postcode != null and postcode != ''">and l.postcode like concat('%', #{postcode}, '%')</if>
|
||||
<if test="regionName != null and regionName != ''">and (l.region_name like concat('%', #{regionName}, '%') or l.region_name_cn like concat('%', #{regionName}, '%') or l.zone_name like concat('%', #{regionName}, '%') or l.city_name like concat('%', #{regionName}, '%'))</if>
|
||||
<if test="zoneName != null and zoneName != ''">
|
||||
and (
|
||||
trim(l.zone_name) = #{zoneName}
|
||||
or ((l.zone_name is null or trim(l.zone_name) = '') and trim(l.region_name) = #{zoneName})
|
||||
or (
|
||||
(l.zone_name is null or trim(l.zone_name) = '')
|
||||
and (l.region_name is null or trim(l.region_name) = '')
|
||||
and l.group_id in (select g.group_id from pay_postcode_group g where trim(g.block_title) = #{zoneName})
|
||||
)
|
||||
)
|
||||
</if>
|
||||
<if test="countryCode != null and countryCode != ''">
|
||||
and l.group_id in (
|
||||
select g.group_id from pay_postcode_group g where upper(trim(g.country_code)) = upper(trim(#{countryCode}))
|
||||
)
|
||||
</if>
|
||||
<if test="(countryCode == null or countryCode == '') and countryName != null and countryName != ''">
|
||||
and l.group_id in (
|
||||
select g.group_id from pay_postcode_group g
|
||||
where (g.country_code is null or trim(g.country_code) = '') and g.country_name = #{countryName}
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
order by l.sort_no asc, l.line_id asc
|
||||
</select>
|
||||
|
||||
<insert id="insertGroup" parameterType="com.bms.price.domain.PayPostcodeGroup" useGeneratedKeys="true" keyProperty="groupId">
|
||||
@@ -134,6 +408,30 @@
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectRemoteGroupsByCountry" resultType="com.bms.price.domain.PayPostcodeGroup">
|
||||
select group_id as groupId, block_title as blockTitle, channel_name as channelName,
|
||||
product_name as productName, quote_sheet as quoteSheet, sheet_name as sheetName,
|
||||
config_kind as configKind, coverage, fee_name as feeName, fee_text as feeText,
|
||||
country_name as countryName, country_code as countryCode
|
||||
from pay_postcode_group
|
||||
where (
|
||||
upper(ifnull(coverage, '')) = 'REMOTE'
|
||||
or ifnull(fee_name, '') like '%偏远%'
|
||||
or lower(ifnull(fee_name, '')) like '%remote%'
|
||||
)
|
||||
<choose>
|
||||
<when test="countryCode != null and countryCode != ''">
|
||||
and upper(trim(country_code)) = upper(trim(#{countryCode}))
|
||||
</when>
|
||||
<when test="countryName != null and countryName != ''">
|
||||
and trim(country_name) = trim(#{countryName})
|
||||
</when>
|
||||
<otherwise>
|
||||
and 1 = 0
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<select id="selectGroupsByTokens" resultType="com.bms.price.domain.PayPostcodeGroup">
|
||||
select group_id as groupId, block_title as blockTitle, channel_name as channelName,
|
||||
product_name as productName, quote_sheet as quoteSheet, sheet_name as sheetName,
|
||||
|
||||
@@ -91,6 +91,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
and ifnull(is_deleted, '0') = '0'
|
||||
</update>
|
||||
|
||||
<update id="fillSourceIdByFeeIds">
|
||||
update prc_pay_bill_fee
|
||||
set source_id = id
|
||||
where (source_id is null or source_id = '')
|
||||
and fee_id in
|
||||
<foreach collection="feeIds" item="feeId" open="(" separator="," close=")">#{feeId}</foreach>
|
||||
</update>
|
||||
|
||||
<delete id="deleteByBillId" parameterType="Long">
|
||||
delete from prc_pay_bill_fee
|
||||
where bill_id = #{billId}
|
||||
|
||||
Reference in New Issue
Block a user