重构产品价和红线价功能
This commit is contained in:
@@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<resultMap type="PrcPriceSetVersion" id="PrcPriceSetVersionResult">
|
||||
<id property="psvId" column="psv_id" />
|
||||
<result property="priceSetId" column="price_set_id" />
|
||||
<result property="priceType" column="price_type" />
|
||||
<result property="versionNo" column="version_no" />
|
||||
<result property="versionSeq" column="version_seq" />
|
||||
<result property="effectiveTime" column="effective_time" />
|
||||
@@ -17,10 +18,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="updated_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="productCount" column="product_count" />
|
||||
<result property="detailCount" column="detail_count" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPrcPriceSetVersionVo">
|
||||
select psv_id, price_set_id, version_no, version_seq, effective_time, expire_time, status,
|
||||
select psv_id, price_set_id, price_type, version_no, version_seq, effective_time, expire_time, status,
|
||||
price_build_mode, created_by, create_time, updated_by, update_time
|
||||
from prc_price_set_version
|
||||
</sql>
|
||||
@@ -36,6 +39,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="priceSetId != null">
|
||||
AND price_set_id = #{priceSetId}
|
||||
</if>
|
||||
<if test="priceSetId == null and priceType != null and priceType != '' and priceType != 'SALES'">
|
||||
AND price_set_id is null
|
||||
</if>
|
||||
<if test="priceType != null and priceType != ''">
|
||||
AND price_type = #{priceType}
|
||||
</if>
|
||||
<if test="versionNo != null and versionNo != ''">
|
||||
AND version_no = #{versionNo}
|
||||
</if>
|
||||
@@ -46,13 +55,56 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
order by version_seq desc
|
||||
</select>
|
||||
|
||||
<select id="selectCatalogVersionList" parameterType="PrcPriceSetVersion" resultMap="PrcPriceSetVersionResult">
|
||||
select v.psv_id, v.price_set_id, v.price_type, v.version_no, v.version_seq,
|
||||
v.effective_time, v.expire_time, v.status, v.price_build_mode,
|
||||
v.created_by, v.create_time, v.updated_by, v.update_time,
|
||||
(select count(1) from prc_price_set_product p
|
||||
where p.psv_id = v.psv_id and ifnull(p.is_del, '0') = '0') as product_count,
|
||||
(select count(1) from prc_price_set_detail d
|
||||
where d.psv_id = v.psv_id and ifnull(d.is_del, '0') = '0') as detail_count
|
||||
from prc_price_set_version v
|
||||
where v.price_set_id is null
|
||||
and v.price_type = #{priceType}
|
||||
<choose>
|
||||
<when test="statusGroup != null and statusGroup == 'pending'">
|
||||
and v.status in ('0', '3')
|
||||
</when>
|
||||
<when test="statusGroup != null and statusGroup == 'expired'">
|
||||
and v.status = '2'
|
||||
</when>
|
||||
<when test="statusGroup != null and statusGroup == 'effect'">
|
||||
and v.status = '1'
|
||||
</when>
|
||||
<when test="status != null and status != ''">
|
||||
and v.status = #{status}
|
||||
</when>
|
||||
</choose>
|
||||
order by v.version_seq desc, v.psv_id desc
|
||||
</select>
|
||||
|
||||
<select id="selectMaxVersionSeq" resultType="java.lang.Integer">
|
||||
select max(version_seq) from prc_price_set_version where price_set_id = #{priceSetId}
|
||||
select max(version_seq) from prc_price_set_version
|
||||
where price_type = 'SALES' and price_set_id = #{priceSetId}
|
||||
</select>
|
||||
|
||||
<select id="selectMaxVersionSeqByType" resultType="java.lang.Integer">
|
||||
select max(version_seq) from prc_price_set_version
|
||||
where price_type = #{priceType}
|
||||
<choose>
|
||||
<when test="priceSetId != null">
|
||||
and price_set_id = #{priceSetId}
|
||||
</when>
|
||||
<otherwise>
|
||||
and price_set_id is null
|
||||
</otherwise>
|
||||
</choose>
|
||||
</select>
|
||||
|
||||
<insert id="insertPrcPriceSetVersion" parameterType="PrcPriceSetVersion" useGeneratedKeys="true" keyProperty="psvId">
|
||||
insert into prc_price_set_version (
|
||||
<if test="priceSetId != null">price_set_id,</if>
|
||||
<if test="priceType != null and priceType != ''">price_type,</if>
|
||||
<if test="versionNo != null and versionNo != ''">version_no,</if>
|
||||
<if test="versionSeq != null">version_seq,</if>
|
||||
<if test="effectiveTime != null">effective_time,</if>
|
||||
@@ -63,6 +115,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
create_time
|
||||
) values (
|
||||
<if test="priceSetId != null">#{priceSetId},</if>
|
||||
<if test="priceType != null and priceType != ''">#{priceType},</if>
|
||||
<if test="versionNo != null and versionNo != ''">#{versionNo},</if>
|
||||
<if test="versionSeq != null">#{versionSeq},</if>
|
||||
<if test="effectiveTime != null">#{effectiveTime},</if>
|
||||
@@ -77,6 +130,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<update id="updatePrcPriceSetVersion" parameterType="PrcPriceSetVersion">
|
||||
update prc_price_set_version
|
||||
<set>
|
||||
<if test="priceType != null and priceType != ''">price_type = #{priceType},</if>
|
||||
<if test="versionNo != null and versionNo != ''">version_no = #{versionNo},</if>
|
||||
<if test="versionSeq != null">version_seq = #{versionSeq},</if>
|
||||
<if test="effectiveTime != null">effective_time = #{effectiveTime},</if>
|
||||
@@ -97,16 +151,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
</delete>
|
||||
|
||||
<delete id="deletePrcPriceSetVersionByPriceSetId" parameterType="Long">
|
||||
delete from prc_price_set_version where price_set_id = #{priceSetId}
|
||||
delete from prc_price_set_version where price_set_id = #{priceSetId} and price_type = 'SALES'
|
||||
</delete>
|
||||
|
||||
<select id="selectPriceSetIds" resultType="Long">
|
||||
select distinct price_set_id from prc_price_set_version
|
||||
select distinct price_set_id from prc_price_set_version where price_set_id is not null
|
||||
</select>
|
||||
|
||||
<select id="selectActiveByPriceSetAt" resultMap="PrcPriceSetVersionResult">
|
||||
<include refid="selectPrcPriceSetVersionVo"/>
|
||||
where price_set_id = #{priceSetId}
|
||||
where price_type = 'SALES'
|
||||
and price_set_id = #{priceSetId}
|
||||
and effective_time is not null
|
||||
and effective_time <= #{asOf}
|
||||
and (expire_time is null or expire_time > #{asOf})
|
||||
@@ -114,4 +169,29 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<select id="selectActiveByTypeAt" resultMap="PrcPriceSetVersionResult">
|
||||
<include refid="selectPrcPriceSetVersionVo"/>
|
||||
where price_type = #{priceType}
|
||||
and price_set_id is null
|
||||
and effective_time is not null
|
||||
and effective_time <= #{asOf}
|
||||
and (expire_time is null or expire_time > #{asOf})
|
||||
order by effective_time desc, version_seq desc, psv_id desc
|
||||
limit 1
|
||||
</select>
|
||||
|
||||
<update id="refreshCatalogStatusByDates">
|
||||
update prc_price_set_version
|
||||
set status = case
|
||||
when expire_time is not null and expire_time <= now() then '2'
|
||||
when effective_time is not null and effective_time > now() then '3'
|
||||
when effective_time is null then '0'
|
||||
else '1'
|
||||
end,
|
||||
update_time = sysdate()
|
||||
where price_type = #{priceType}
|
||||
and price_set_id is null
|
||||
and status in ('0','1','2','3')
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user