新增打单产品分区管理功能,优化常规分区逻辑
This commit is contained in:
@@ -43,6 +43,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
select count(1) from prc_zone_detail d
|
||||
inner join prc_zone z on z.zone_id = d.zone_id
|
||||
where z.region_id = #{regionId}
|
||||
and z.zone_type = 'REGULAR'
|
||||
and z.product_id is null
|
||||
</select>
|
||||
|
||||
<insert id="insertPrcZoneDetail" parameterType="PrcZoneDetail" useGeneratedKeys="true" keyProperty="detailId">
|
||||
@@ -89,11 +91,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
delete d from prc_zone_detail d
|
||||
inner join prc_zone z on z.zone_id = d.zone_id
|
||||
where z.region_id = #{regionId}
|
||||
and z.zone_type = 'REGULAR'
|
||||
and z.product_id is null
|
||||
</delete>
|
||||
|
||||
<delete id="deletePrcZoneDetailByProductId" parameterType="Long">
|
||||
delete d from prc_zone_detail d
|
||||
inner join prc_zone z on z.zone_id = d.zone_id
|
||||
where z.product_id = #{productId}
|
||||
and z.zone_type = 'LABEL'
|
||||
</delete>
|
||||
|
||||
<select id="selectZoneByCountryPostcode" resultType="com.bms.price.domain.PrcZone">
|
||||
select z.zone_id as zoneId,
|
||||
z.zone_type as zoneType,
|
||||
z.region_id as regionId,
|
||||
z.product_id as productId,
|
||||
z.country_code as countryCode,
|
||||
z.zone_code as zoneCode,
|
||||
z.zone_name as zoneName,
|
||||
@@ -103,7 +116,36 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
z.update_time as updateTime
|
||||
from prc_zone_detail d
|
||||
inner join prc_zone z on z.zone_id = d.zone_id
|
||||
where upper(ifnull(z.country_code,'')) = upper(#{countryCode})
|
||||
where z.zone_type = 'REGULAR'
|
||||
and z.product_id is null
|
||||
and upper(ifnull(z.country_code,'')) = upper(#{countryCode})
|
||||
and (
|
||||
replace(upper(ifnull(d.postcode,'')), ' ', '') = replace(upper(#{postcode}), ' ', '')
|
||||
or replace(upper(#{postcode}), ' ', '') like concat(replace(upper(ifnull(d.postcode,'')), ' ', ''), '%')
|
||||
)
|
||||
order by
|
||||
case when replace(upper(ifnull(d.postcode,'')), ' ', '') = replace(upper(#{postcode}), ' ', '') then 0 else 1 end,
|
||||
char_length(replace(ifnull(d.postcode,''), ' ', '')) desc,
|
||||
d.detail_id asc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectZoneByProductPostcode" resultType="com.bms.price.domain.PrcZone">
|
||||
select z.zone_id as zoneId,
|
||||
z.zone_type as zoneType,
|
||||
z.region_id as regionId,
|
||||
z.product_id as productId,
|
||||
z.country_code as countryCode,
|
||||
z.zone_code as zoneCode,
|
||||
z.zone_name as zoneName,
|
||||
z.zone_sort as zoneSort,
|
||||
z.remark as remark,
|
||||
z.create_time as createTime,
|
||||
z.update_time as updateTime
|
||||
from prc_zone_detail d
|
||||
inner join prc_zone z on z.zone_id = d.zone_id
|
||||
where z.zone_type = 'LABEL'
|
||||
and z.product_id = #{productId}
|
||||
and (
|
||||
replace(upper(ifnull(d.postcode,'')), ' ', '') = replace(upper(#{postcode}), ' ', '')
|
||||
or replace(upper(#{postcode}), ' ', '') like concat(replace(upper(ifnull(d.postcode,'')), ' ', ''), '%')
|
||||
|
||||
@@ -6,7 +6,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<resultMap type="PrcZone" id="PrcZoneResult">
|
||||
<id property="zoneId" column="zone_id" />
|
||||
<result property="zoneType" column="zone_type" />
|
||||
<result property="regionId" column="region_id" />
|
||||
<result property="productId" column="product_id" />
|
||||
<result property="countryCode" column="country_code" />
|
||||
<result property="zoneCode" column="zone_code" />
|
||||
<result property="zoneName" column="zone_name" />
|
||||
@@ -16,6 +18,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="detailCount" column="detail_count" />
|
||||
<result property="countryNameCn" column="country_name_cn" />
|
||||
<result property="productName" column="product_name" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="PrcZoneRegion" id="PrcZoneRegionResult">
|
||||
@@ -28,8 +31,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="detailCount" column="detail_count" />
|
||||
</resultMap>
|
||||
|
||||
<resultMap type="PrcZoneLabelProduct" id="PrcZoneLabelProductResult">
|
||||
<id property="productId" column="product_id" />
|
||||
<result property="productName" column="product_name" />
|
||||
<result property="dictValue" column="dict_value" />
|
||||
<result property="zoneCount" column="zone_count" />
|
||||
<result property="detailCount" column="detail_count" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPrcZoneVo">
|
||||
select zone_id, region_id, country_code, zone_code, zone_name, zone_sort, remark, create_time, update_time
|
||||
select zone_id, zone_type, region_id, product_id, country_code, zone_code, zone_name, zone_sort, remark, create_time, update_time
|
||||
from prc_zone
|
||||
</sql>
|
||||
|
||||
@@ -39,25 +50,48 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</select>
|
||||
|
||||
<select id="selectPrcZoneListByRegionId" parameterType="Long" resultMap="PrcZoneResult">
|
||||
select z.zone_id, z.region_id, z.country_code, z.zone_code, z.zone_name, z.zone_sort, z.remark,
|
||||
select z.zone_id, z.zone_type, z.region_id, z.product_id, z.country_code, z.zone_code, z.zone_name, z.zone_sort, z.remark,
|
||||
z.create_time, z.update_time,
|
||||
(select count(1) from prc_zone_detail d where d.zone_id = z.zone_id) as detail_count
|
||||
from prc_zone z
|
||||
where z.region_id = #{regionId}
|
||||
and z.zone_type = 'REGULAR'
|
||||
and z.product_id is null
|
||||
order by z.zone_sort asc, z.zone_id asc
|
||||
</select>
|
||||
|
||||
<select id="selectPrcZoneListByProductId" parameterType="Long" resultMap="PrcZoneResult">
|
||||
select z.zone_id, z.zone_type, z.region_id, z.product_id, z.country_code, z.zone_code, z.zone_name, z.zone_sort, z.remark,
|
||||
z.create_time, z.update_time,
|
||||
(select count(1) from prc_zone_detail d where d.zone_id = z.zone_id) as detail_count
|
||||
from prc_zone z
|
||||
where z.product_id = #{productId}
|
||||
and z.zone_type = 'LABEL'
|
||||
order by z.zone_sort asc, z.zone_id asc
|
||||
</select>
|
||||
|
||||
<select id="selectPrcZoneList" parameterType="PrcZone" resultMap="PrcZoneResult">
|
||||
select z.zone_id, z.region_id, z.country_code, z.zone_code, z.zone_name, z.zone_sort, z.remark,
|
||||
select z.zone_id, z.zone_type, z.region_id, z.product_id, z.country_code, z.zone_code, z.zone_name, z.zone_sort, z.remark,
|
||||
z.create_time, z.update_time,
|
||||
r.country_name_cn,
|
||||
p.product_name,
|
||||
(select count(1) from prc_zone_detail d where d.zone_id = z.zone_id) as detail_count
|
||||
from prc_zone z
|
||||
left join region r on r.region_id = z.region_id
|
||||
left join prc_label_product p on p.product_id = z.product_id
|
||||
<where>
|
||||
<if test="zoneType != null and zoneType != ''">
|
||||
AND z.zone_type = #{zoneType}
|
||||
</if>
|
||||
<if test="zoneType == null or zoneType == ''">
|
||||
AND z.zone_type = 'REGULAR'
|
||||
</if>
|
||||
<if test="regionId != null">
|
||||
AND z.region_id = #{regionId}
|
||||
</if>
|
||||
<if test="productId != null">
|
||||
AND z.product_id = #{productId}
|
||||
</if>
|
||||
<if test="countryCode != null and countryCode != ''">
|
||||
AND z.country_code = #{countryCode}
|
||||
</if>
|
||||
@@ -79,6 +113,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
inner join region r on r.region_id = z.region_id
|
||||
left join prc_zone_detail d on d.zone_id = z.zone_id
|
||||
<where>
|
||||
AND z.zone_type = 'REGULAR'
|
||||
AND z.product_id is null
|
||||
<if test="countryNameCn != null and countryNameCn != ''">
|
||||
AND r.country_name_cn like concat('%', #{countryNameCn}, '%')
|
||||
</if>
|
||||
@@ -95,21 +131,51 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
|
||||
<select id="selectZoneRegionById" parameterType="Long" resultMap="PrcZoneRegionResult">
|
||||
select r.region_id, r.country_name_cn, r.country_name_en, r.country_code_2, r.status,
|
||||
(select count(1) from prc_zone z where z.region_id = r.region_id) as zone_count,
|
||||
(select count(1) from prc_zone z where z.region_id = r.region_id and z.zone_type = 'REGULAR' and z.product_id is null) as zone_count,
|
||||
(select count(1) from prc_zone_detail d
|
||||
inner join prc_zone z on z.zone_id = d.zone_id
|
||||
where z.region_id = r.region_id) as detail_count
|
||||
where z.region_id = r.region_id and z.zone_type = 'REGULAR' and z.product_id is null) as detail_count
|
||||
from region r
|
||||
where r.region_id = #{regionId}
|
||||
</select>
|
||||
|
||||
<select id="selectLabelProductZoneList" parameterType="PrcZoneLabelProduct" resultMap="PrcZoneLabelProductResult">
|
||||
select p.product_id, p.product_name, p.dict_value,
|
||||
count(distinct z.zone_id) as zone_count,
|
||||
count(d.detail_id) as detail_count
|
||||
from prc_zone z
|
||||
inner join prc_label_product p on p.product_id = z.product_id
|
||||
left join prc_zone_detail d on d.zone_id = z.zone_id
|
||||
<where>
|
||||
AND z.zone_type = 'LABEL'
|
||||
AND z.product_id is not null
|
||||
<if test="productName != null and productName != ''">
|
||||
AND (p.product_name like concat('%', #{productName}, '%')
|
||||
OR p.dict_value like concat('%', #{productName}, '%'))
|
||||
</if>
|
||||
<if test="dictValue != null and dictValue != ''">
|
||||
AND p.dict_value like concat('%', #{dictValue}, '%')
|
||||
</if>
|
||||
<if test="productId != null">
|
||||
AND p.product_id = #{productId}
|
||||
</if>
|
||||
</where>
|
||||
group by p.product_id, p.product_name, p.dict_value
|
||||
order by p.product_name asc, p.product_id asc
|
||||
</select>
|
||||
|
||||
<select id="countByRegionId" parameterType="Long" resultType="int">
|
||||
select count(1) from prc_zone where region_id = #{regionId}
|
||||
select count(1) from prc_zone
|
||||
where region_id = #{regionId}
|
||||
and zone_type = 'REGULAR'
|
||||
and product_id is null
|
||||
</select>
|
||||
|
||||
<insert id="insertPrcZone" parameterType="PrcZone" useGeneratedKeys="true" keyProperty="zoneId">
|
||||
insert into prc_zone (
|
||||
<if test="zoneType != null and zoneType != ''">zone_type,</if>
|
||||
<if test="regionId != null">region_id,</if>
|
||||
<if test="productId != null">product_id,</if>
|
||||
<if test="countryCode != null and countryCode != ''">country_code,</if>
|
||||
<if test="zoneCode != null and zoneCode != ''">zone_code,</if>
|
||||
<if test="zoneName != null">zone_name,</if>
|
||||
@@ -117,7 +183,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="remark != null">remark,</if>
|
||||
create_time
|
||||
) values (
|
||||
<if test="zoneType != null and zoneType != ''">#{zoneType},</if>
|
||||
<if test="regionId != null">#{regionId},</if>
|
||||
<if test="productId != null">#{productId},</if>
|
||||
<if test="countryCode != null and countryCode != ''">#{countryCode},</if>
|
||||
<if test="zoneCode != null and zoneCode != ''">#{zoneCode},</if>
|
||||
<if test="zoneName != null">#{zoneName},</if>
|
||||
@@ -130,7 +198,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<update id="updatePrcZone" parameterType="PrcZone">
|
||||
update prc_zone
|
||||
<set>
|
||||
<if test="zoneType != null and zoneType != ''">zone_type = #{zoneType},</if>
|
||||
<if test="regionId != null">region_id = #{regionId},</if>
|
||||
<if test="productId != null">product_id = #{productId},</if>
|
||||
<if test="countryCode != null and countryCode != ''">country_code = #{countryCode},</if>
|
||||
<if test="zoneCode != null and zoneCode != ''">zone_code = #{zoneCode},</if>
|
||||
<if test="zoneName != null">zone_name = #{zoneName},</if>
|
||||
@@ -149,7 +219,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</delete>
|
||||
|
||||
<delete id="deletePrcZoneByRegionId" parameterType="Long">
|
||||
delete from prc_zone where region_id = #{regionId}
|
||||
delete from prc_zone
|
||||
where region_id = #{regionId}
|
||||
and zone_type = 'REGULAR'
|
||||
and product_id is null
|
||||
</delete>
|
||||
|
||||
<delete id="deletePrcZoneByRegionIds" parameterType="Long">
|
||||
@@ -157,6 +230,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<foreach item="regionId" collection="array" open="(" separator="," close=")">
|
||||
#{regionId}
|
||||
</foreach>
|
||||
and zone_type = 'REGULAR'
|
||||
and product_id is null
|
||||
</delete>
|
||||
|
||||
<delete id="deletePrcZoneByProductId" parameterType="Long">
|
||||
delete from prc_zone
|
||||
where product_id = #{productId}
|
||||
and zone_type = 'LABEL'
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user