<?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="ownerQualityGuaranteeServiceDaoImpl">
|
|
<!-- 保存业主质保金信息 -->
|
<insert id="saveOwnerQualityGuarantee" parameterType="Map">
|
insert into owner_quality_guarantee(
|
mp_id, available_withdrawal_date, acceptance_date,
|
quality_guarantee_period2, audit_status,
|
quality_guarantee_ratio, quality_guarantee_amount
|
) values (
|
#{mpId}, #{availableWithdrawalDate}, #{acceptanceDate},
|
#{qualityGuaranteePeriod2}, #{auditStatus},
|
#{qualityGuaranteeRatio}, #{qualityGuaranteeAmount}
|
)
|
</insert>
|
|
<!-- 批量保存业主质保金信息 -->
|
<insert id="batchSaveOwnerQualityGuarantee" parameterType="Map">
|
insert into owner_quality_guarantee(
|
mp_id, available_withdrawal_date, acceptance_date,
|
quality_guarantee_period2, audit_status,
|
quality_guarantee_ratio, quality_guarantee_amount
|
) values
|
<foreach collection="guaranteeList" item="item" separator=",">
|
( #{item.mpId}, #{item.availableWithdrawalDate}, #{item.acceptanceDate},
|
#{item.qualityGuaranteePeriod2}, #{item.auditStatus},
|
#{item.qualityGuaranteeRatio}, #{item.qualityGuaranteeAmount} )
|
</foreach>
|
</insert>
|
|
<!-- 查询业主质保金信息 -->
|
<select id="getOwnerQualityGuarantee" parameterType="Map" resultType="Map">
|
select
|
t.id,
|
t.mp_id mpId,
|
t.available_withdrawal_date availableWithdrawalDate,
|
t.acceptance_date acceptanceDate,
|
t.quality_guarantee_period2 qualityGuaranteePeriod2,
|
t.audit_status auditStatus,
|
t.quality_guarantee_ratio qualityGuaranteeRatio,
|
t.quality_guarantee_amount qualityGuaranteeAmount,
|
t.create_time createTime,
|
t.update_time updateTime
|
from owner_quality_guarantee t
|
where 1 = 1
|
<if test="id != null">
|
and t.id = #{id}
|
</if>
|
<if test="mpId != null">
|
and t.mp_id = #{mpId}
|
</if>
|
<if test="availableWithdrawalDate != null">
|
and t.available_withdrawal_date = #{availableWithdrawalDate}
|
</if>
|
<if test="acceptanceDate != null">
|
and t.acceptance_date = #{acceptanceDate}
|
</if>
|
<if test="qualityGuaranteePeriod2 != null and qualityGuaranteePeriod2 != ''">
|
and t.quality_guarantee_period2 = #{qualityGuaranteePeriod2}
|
</if>
|
<if test="auditStatus != null and auditStatus != ''">
|
and t.audit_status = #{auditStatus}
|
</if>
|
<if test="qualityGuaranteeRatio != null">
|
and t.quality_guarantee_ratio = #{qualityGuaranteeRatio}
|
</if>
|
<if test="qualityGuaranteeAmount != null">
|
and t.quality_guarantee_amount = #{qualityGuaranteeAmount}
|
</if>
|
<!-- 时间范围查询 -->
|
<if test="startCreateTime != null">
|
and t.create_time >= #{startCreateTime}
|
</if>
|
<if test="endCreateTime != null">
|
and t.create_time <= #{endCreateTime}
|
</if>
|
<if test="startUpdateTime != null">
|
and t.update_time >= #{startUpdateTime}
|
</if>
|
<if test="endUpdateTime != null">
|
and t.update_time <= #{endUpdateTime}
|
</if>
|
order by t.id desc
|
<if test="page != -1 and page != null">
|
limit #{page}, #{row}
|
</if>
|
</select>
|
|
<!-- 更新业主质保金信息 -->
|
<update id="updateOwnerQualityGuarantee" parameterType="Map">
|
update owner_quality_guarantee t
|
<set>
|
<if test="mpId != null">
|
t.mp_id = #{mpId},
|
</if>
|
<if test="availableWithdrawalDate != null">
|
t.available_withdrawal_date = #{availableWithdrawalDate},
|
</if>
|
<if test="acceptanceDate != null">
|
t.acceptance_date = #{acceptanceDate},
|
</if>
|
<if test="qualityGuaranteePeriod2 != null and qualityGuaranteePeriod2 != ''">
|
t.quality_guarantee_period2 = #{qualityGuaranteePeriod2},
|
</if>
|
<if test="auditStatus != null and auditStatus != ''">
|
t.audit_status = #{auditStatus},
|
</if>
|
<if test="qualityGuaranteeRatio != null">
|
t.quality_guarantee_ratio = #{qualityGuaranteeRatio},
|
</if>
|
<if test="qualityGuaranteeAmount != null">
|
t.quality_guarantee_amount = #{qualityGuaranteeAmount},
|
</if>
|
t.update_time = CURRENT_TIMESTAMP
|
</set>
|
where 1 = 1
|
<if test="id != null">
|
and t.id = #{id}
|
</if>
|
<if test="mpId != null">
|
and t.mp_id = #{mpId}
|
</if>
|
</update>
|
|
<!-- 删除业主质保金信息 -->
|
<delete id="deleteOwnerQualityGuarantee" parameterType="Map">
|
delete from owner_quality_guarantee t
|
where 1 = 1
|
<if test="id != null">
|
and t.id = #{id}
|
</if>
|
<if test="mpId != null">
|
and t.mp_id = #{mpId}
|
</if>
|
</delete>
|
|
<!-- 查询业主质保金信息记录数量 -->
|
<select id="queryOwnerQualityGuaranteeCount" parameterType="Map" resultType="Map">
|
select count(1) count
|
from owner_quality_guarantee t
|
where 1 = 1
|
<if test="id != null">
|
and t.id = #{id}
|
</if>
|
<if test="mpId != null">
|
and t.mp_id = #{mpId}
|
</if>
|
<if test="availableWithdrawalDate != null">
|
and t.available_withdrawal_date = #{availableWithdrawalDate}
|
</if>
|
<if test="acceptanceDate != null">
|
and t.acceptance_date = #{acceptanceDate}
|
</if>
|
<if test="qualityGuaranteePeriod2 != null and qualityGuaranteePeriod2 != ''">
|
and t.quality_guarantee_period2 = #{qualityGuaranteePeriod2}
|
</if>
|
<if test="auditStatus != null and auditStatus != ''">
|
and t.audit_status = #{auditStatus}
|
</if>
|
<if test="qualityGuaranteeRatio != null">
|
and t.quality_guarantee_ratio = #{qualityGuaranteeRatio}
|
</if>
|
<if test="qualityGuaranteeAmount != null">
|
and t.quality_guarantee_amount = #{qualityGuaranteeAmount}
|
</if>
|
<!-- 时间范围查询 -->
|
<if test="startCreateTime != null">
|
and t.create_time >= #{startCreateTime}
|
</if>
|
<if test="endCreateTime != null">
|
and t.create_time <= #{endCreateTime}
|
</if>
|
<if test="startUpdateTime != null">
|
and t.update_time >= #{startUpdateTime}
|
</if>
|
<if test="endUpdateTime != null">
|
and t.update_time <= #{endUpdateTime}
|
</if>
|
</select>
|
|
<!-- 查询统计信息 -->
|
<select id="queryOwnerQualityGuaranteeStatistics" parameterType="Map" resultType="Map">
|
select
|
count(1) as total_count,
|
min(t.create_time) as earliest_create_time,
|
max(t.create_time) as latest_create_time,
|
min(t.update_time) as earliest_update_time,
|
max(t.update_time) as latest_update_time
|
from owner_quality_guarantee t
|
where 1 = 1
|
<if test="mpId != null">
|
and t.mp_id = #{mpId}
|
</if>
|
<if test="startCreateTime != null">
|
and t.create_time >= #{startCreateTime}
|
</if>
|
<if test="endCreateTime != null">
|
and t.create_time <= #{endCreateTime}
|
</if>
|
</select>
|
|
<!-- 按年月分组统计数量 -->
|
<select id="queryOwnerQualityGuaranteeByMonth" parameterType="Map" resultType="Map">
|
select
|
date_format(t.create_time, '%Y-%m') as month,
|
count(1) as count,
|
count(distinct t.mp_id) as mp_count
|
from owner_quality_guarantee t
|
where 1 = 1
|
<if test="mpId != null">
|
and t.mp_id = #{mpId}
|
</if>
|
<if test="startCreateTime != null">
|
and t.create_time >= #{startCreateTime}
|
</if>
|
<if test="endCreateTime != null">
|
and t.create_time <= #{endCreateTime}
|
</if>
|
group by date_format(t.create_time, '%Y-%m')
|
order by month desc
|
</select>
|
|
<!-- 根据mp_id查询最新的业主质保金信息 -->
|
<select id="getLatestOwnerQualityGuaranteeByMpId" parameterType="Map" resultType="Map">
|
select
|
t.id,
|
t.mp_id mpId,
|
t.available_withdrawal_date availableWithdrawalDate,
|
t.acceptance_date acceptanceDate,
|
t.quality_guarantee_period2 qualityGuaranteePeriod2,
|
t.audit_status auditStatus,
|
t.quality_guarantee_ratio qualityGuaranteeRatio,
|
t.quality_guarantee_amount qualityGuaranteeAmount,
|
t.create_time createTime,
|
t.update_time updateTime
|
from owner_quality_guarantee t
|
where t.mp_id = #{mpId}
|
order by t.update_time desc
|
limit 1
|
</select>
|
|
</mapper>
|