Refactor lease price calculations and enforce source filtering in SQL queries

This commit is contained in:
syruan 2025-11-04 20:25:14 +08:00
parent c5761ebb0d
commit 27c3f54c9f
2 changed files with 15 additions and 9 deletions

View File

@ -700,7 +700,7 @@ public class SltAgreementInfoController extends BaseController {
if (null == bean.getLeasePrice()) { if (null == bean.getLeasePrice()) {
bean.setLeasePrice(BigDecimal.valueOf(0.00)); bean.setLeasePrice(BigDecimal.valueOf(0.00));
}else{ }else{
bean.setLeasePrice(bean.getLeasePrice().setScale(2, BigDecimal.ROUND_HALF_UP)); bean.setLeasePrice(bean.getLeasePrice().setScale(2, RoundingMode.HALF_UP));
} }
if (null == bean.getNum()) { if (null == bean.getNum()) {
@ -712,7 +712,7 @@ public class SltAgreementInfoController extends BaseController {
BigDecimal leasePrice = bean.getLeasePrice(); BigDecimal leasePrice = bean.getLeasePrice();
BigDecimal num = bean.getNum(); BigDecimal num = bean.getNum();
BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays()); BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays());
BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays).setScale(2, BigDecimal.ROUND_HALF_UP); BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays).setScale(2, RoundingMode.HALF_UP);
if(costs!=null){ if(costs!=null){
totalCost = totalCost.add(costs); totalCost = totalCost.add(costs);
} }

View File

@ -61,13 +61,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectSltAgreementInfoList" parameterType="com.bonus.material.settlement.domain.SltAgreementInfo" resultMap="SltAgreementInfoResult"> <select id="selectSltAgreementInfoList" parameterType="com.bonus.material.settlement.domain.SltAgreementInfo" resultMap="SltAgreementInfoResult">
<include refid="selectSltAgreementInfoVo"/> <include refid="selectSltAgreementInfoVo"/>
<where> <where>
and `source` = '1'
<if test="agreementId != null "> and agreement_id = #{agreementId}</if> <if test="agreementId != null "> and agreement_id = #{agreementId}</if>
<if test="typeId != null "> and type_id = #{typeId}</if> <if test="typeId != null "> and type_id = #{typeId}</if>
<if test="maId != null "> and ma_id = #{maId}</if> <if test="maId != null "> and ma_id = #{maId}</if>
<if test="num != null "> and num = #{num}</if> <if test="num != null "> and num = #{num}</if>
<if test="startTime != null "> and start_time = #{startTime}</if> <if test="startTime != null "> and start_time = #{startTime}</if>
<if test="endTime != null "> and end_time = #{endTime}</if> <if test="endTime != null "> and end_time = #{endTime}</if>
<if test="status != null and status != ''"> and status = #{status}</if> <if test="status != null and status != ''"> and `status` = #{status}</if>
<if test="leaseId != null "> and lease_id = #{leaseId}</if> <if test="leaseId != null "> and lease_id = #{leaseId}</if>
<if test="backId != null "> and back_id = #{backId}</if> <if test="backId != null "> and back_id = #{backId}</if>
<if test="leasePrice != null "> and lease_price = #{leasePrice}</if> <if test="leasePrice != null "> and lease_price = #{leasePrice}</if>
@ -170,6 +171,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
WHERE WHERE
lease_id = #{record.parentId} lease_id = #{record.parentId}
and type_id = #{record.typeId} and type_id = #{record.typeId}
and source = '1'
<if test="record.maId != null"> <if test="record.maId != null">
AND ma_id = #{record.maId} AND ma_id = #{record.maId}
</if> </if>
@ -202,7 +204,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
AND AND
ma_id IS NULL ma_id IS NULL
AND AND
status = '0' status = '0' AND source = '1'
<if test="publishTask != null and publishTask != ''"> <if test="publishTask != null and publishTask != ''">
AND publish_task = #{publishTask} AND publish_task = #{publishTask}
</if> </if>
@ -336,7 +338,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join ma_type mt on sai.type_id = mt.type_id left join ma_type mt on sai.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id left join ma_type mt1 on mt.parent_id = mt1.type_id
where where
sai.agreement_id = #{agreementId} sai.agreement_id = #{agreementId} and sai.source = '1'
<if test="settlementType != null and settlementType != 0"> <if test="settlementType != null and settlementType != 0">
and mt.jiju_type = #{settlementType} and mt.jiju_type = #{settlementType}
</if> </if>
@ -456,7 +458,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
left join ma_type mt on sai.type_id = mt.type_id left join ma_type mt on sai.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id left join ma_type mt1 on mt.parent_id = mt1.type_id
where sai.agreement_id = #{agreementId} and sai.status = 0 where sai.agreement_id = #{agreementId} and sai.status = 0 and sai.source = '1'
<if test="settlementType != null and settlementType != 0"> <if test="settlementType != null and settlementType != 0">
and mt.jiju_type = #{settlementType} and mt.jiju_type = #{settlementType}
</if> </if>
@ -993,6 +995,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="settlementType != null and settlementType != 0"> <if test="settlementType != null and settlementType != 0">
and mt.jiju_type = #{settlementType} and mt.jiju_type = #{settlementType}
</if> </if>
and sai.source = '1'
</where> </where>
) res ) res
GROUP BY res.agreementId,res.typeId,res.startTime,res.endTime GROUP BY res.agreementId,res.typeId,res.startTime,res.endTime
@ -1032,7 +1035,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<foreach item="item" index="index" collection="agreementIds" open="(" separator="," close=")"> <foreach item="item" index="index" collection="agreementIds" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
and sai.end_time is null and sai.end_time is null and sai.source = '1'
<if test="settlementType != null and settlementType != 0"> <if test="settlementType != null and settlementType != 0">
and mt.jiju_type = #{settlementType} and mt.jiju_type = #{settlementType}
</if> </if>
@ -1230,6 +1233,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join ma_type mt on sai.type_id = mt.type_id left join ma_type mt on sai.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id left join ma_type mt1 on mt.parent_id = mt1.type_id
<where> <where>
sai.source = '1'
<if test="settlementType != null and settlementType != 0"> <if test="settlementType != null and settlementType != 0">
and mt.jiju_type = #{settlementType} and mt.jiju_type = #{settlementType}
</if> </if>
@ -1266,6 +1270,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
left join ma_type mt on sai.type_id = mt.type_id left join ma_type mt on sai.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id left join ma_type mt1 on mt.parent_id = mt1.type_id
<where> <where>
sai.source = '1'
<if test="settlementType != null and settlementType != 0"> <if test="settlementType != null and settlementType != 0">
and mt.jiju_type = #{settlementType} and mt.jiju_type = #{settlementType}
</if> </if>
@ -1303,6 +1308,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id AND mt1.`level` = '3' LEFT JOIN ma_type mt1 ON mt.parent_id = mt1.type_id AND mt1.`level` = '3'
<where> <where>
bai.status = '1' bai.status = '1'
AND sai.source = '1'
AND mt.jiju_type = #{sltManageType} AND mt.jiju_type = #{sltManageType}
<if test="agreementCode != null and agreementCode != ''"> <if test="agreementCode != null and agreementCode != ''">
AND bai.agreement_code LIKE concat('%',#{agreementCode},'%') AND bai.agreement_code LIKE concat('%',#{agreementCode},'%')
@ -1570,7 +1576,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SET SET
sai.is_slt = '1', sai.slt_time = NOW() sai.is_slt = '1', sai.slt_time = NOW()
WHERE WHERE
sai.agreement_id = #{agreementId} AND mt.jiju_type = #{settlementType} sai.agreement_id = #{agreementId} AND mt.jiju_type = #{settlementType} AND sai.source = '1'
</update> </update>
<update id="updateMaStatusLoseByAgreementIdType"> <update id="updateMaStatusLoseByAgreementIdType">
@ -1581,7 +1587,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
set set
mi.ma_status = '18', mi.update_time = NOW() mi.ma_status = '18', mi.update_time = NOW()
where where
sai.agreement_id = #{agreementId} AND mt.jiju_type = #{settlementType} sai.agreement_id = #{agreementId} AND mt.jiju_type = #{settlementType} AND sai.source = '1'
</update> </update>
<select id="getUnitAndProjectByAgreementId" resultType="com.bonus.material.settlement.domain.SltAgreementInfo"> <select id="getUnitAndProjectByAgreementId" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">