yn_cw_gj/src/main/resources/mappers/ca/PrepaymentMapper.xml

210 lines
7.7 KiB
XML
Raw Normal View History

2025-04-16 17:10:46 +08:00
<?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="com.bonus.boot.manager.ca.bm.dao.PrepaymentDao">
<insert id="addPrepayment">
INSERT INTO `bm_project_prepayment` (`project_code`, `project_name`, `business_unit`, `contact_unit`, `type`,
`initial_amount`, `first_payment_date`, `current_balance`, `remarks`,`operator`,`is_active`)
VALUES (#{projectCode},#{projectName},#{businessUnit},#{contactUnit},#{type},
#{initialAmount},#{firstPaymentDate},#{initialAmount},#{remarks},#{operator},'1')
</insert>
<insert id="addOperations">
INSERT INTO `bm_monthly_operations` ( `p_id`, `month`, `operation_type`, `amount`, `executor`, `remarks`,
`next_month`, `proposed_amount`, `handler`, `next_remarks`,`is_active`,`operator` )
VALUES
(
#{prepaymentId},
#{month},
#{operationType},
#{amount},
#{executor},
#{remarks},
#{nextMonth},
#{proposedAmount},
#{handler},
#{nextRemarks},'1',#{operator})
</insert>
<update id="updatePrepaymentId">
UPDATE `bm_project_prepayment` SET `current_balance` = #{currentBalance}, `operator` = #{operator} WHERE `id` = #{prepaymentId}
</update>
<update id="updatePrepayment">
UPDATE `bm_project_prepayment` SET `operator` = #{operator}
<if test="projectCode != null">
,project_code = #{projectCode}
</if>
<if test="projectName != null">
,project_name = #{projectName}
</if>
<if test="businessUnit != null">
,business_unit = #{businessUnit}
</if>
<if test="contactUnit != null">
,contact_unit = #{contactUnit}
</if>
<if test="type != null">
,type = #{type}
</if>
<if test="initialAmount != null">
,initial_amount = #{initialAmount}
</if>
<if test="firstPaymentDate != null">
,first_payment_date = #{firstPaymentDate}
</if>
<if test="currentBalance != null">
,current_balance = #{currentBalance}
</if>
<if test="remarks != null">
,remarks = #{remarks}
</if>
WHERE `id` = #{id}
</update>
<update id="updateOperations">
UPDATE `bm_monthly_operations` SET `month` = #{month}, `operation_type` = #{operationType},
`amount` = #{amount}, `executor` = #{executor},operator = #{operator},
<if test="remarks != null">
,remarks = #{remarks}
</if>
<if test="nextMonth != null">
,next_month = #{nextMonth}
</if>
<if test="proposedAmount != null">
,proposed_amount = #{proposedAmount}
</if>
<if test="handler != null">
,handler = #{handler}
</if>
<if test="nextRemarks != null">
,next_remarks = #{nextRemarks}
</if>
WHERE `id` = #{id} and is_active = '1'
</update>
<delete id="delPrepayment">
UPDATE `bm_project_prepayment` SET `is_active` = '0' , operator = #{userId} WHERE `id` = #{id}
</delete>
<delete id="delOperations">
UPDATE `bm_monthly_operations` SET `is_active` = '0' , operator = #{userId} WHERE `id` = #{id}
</delete>
<select id="getList" resultType="com.bonus.boot.manager.ca.bm.entity.PrepaymentBean">
SELECT
id,
project_code as projectCode,
project_name as projectName,
business_unit as businessUnit,
contact_unit as contactUnit,
type,
initial_amount as initialAmount,
first_payment_date as firstPaymentDate,
current_balance as currentBalance,
remarks,
operator,
created_time as createdTime,
updated_time as updatedTime,
GREATEST(PERIOD_DIFF(DATE_FORMAT(CURDATE(), '%Y%m'), DATE_FORMAT(first_payment_date, '%Y%m')), 0) AS agingMonths,
CASE
WHEN current_balance = 0 THEN 0
ELSE 1
END AS state
FROM
`bm_project_prepayment`
WHERE is_active = '1'
<if test="params.keyword != null and params.keyword != ''">
AND (
project_code LIKE CONCAT('%', #{params.keyword}, '%')
OR project_name LIKE CONCAT('%', #{params.keyword}, '%')
OR business_unit LIKE CONCAT('%', #{params.keyword}, '%')
OR contact_unit LIKE CONCAT('%', #{params.keyword}, '%')
OR type LIKE CONCAT('%', #{params.keyword}, '%')
)
</if>
<if test="params.state =='1' || params.state ==1">
AND current_balance>0
</if>
<if test="params.state =='2' || params.state ==2">
AND current_balance=0
</if>
ORDER BY updated_time DESC
</select>
<select id="getListById" resultType="com.bonus.boot.manager.ca.bm.entity.PrepaymentBean">
SELECT
id,
project_code as projectCode,
project_name as projectName,
business_unit as businessUnit,
contact_unit as contactUnit,
type,
initial_amount as initialAmount,
first_payment_date as firstPaymentDate,
current_balance as currentBalance,
remarks,
operator,
created_time as createdTime,
updated_time as updatedTime,
GREATEST(PERIOD_DIFF(DATE_FORMAT(CURDATE(), '%Y%m'), DATE_FORMAT(first_payment_date, '%Y%m')), 0) AS agingMonths,
CASE
WHEN current_balance = 0 THEN 0
ELSE 1
END AS state
FROM
`bm_project_prepayment`
WHERE is_active = '1' and id= #{id}
</select>
<select id="getOperationsList" resultType="com.bonus.boot.manager.ca.bm.entity.OperationsBean">
SELECT
id,
p_id as prepaymentId,
month,
operation_type as operationType,
amount,
executor,
remarks,
next_month as nextMonth,
proposed_amount as proposedAmount,
handler,
next_remarks as nextRemarks,
operator,
created_time as createdTime,
updated_time as updatedTime
FROM `bm_monthly_operations`
WHERE is_active = '1' AND p_id = #{params.prepaymentId}
ORDER BY updated_time DESC
</select>
<select id="getMath" resultType="java.lang.Integer">
SELECT COUNT(*) FROM `bm_monthly_operations`
WHERE p_id = #{prepaymentId} and `month` = #{month} AND is_active = '1'
<if test="id !=null ">
and id != #{id}
</if>
</select>
<select id="getOperationsById" resultType="com.bonus.boot.manager.ca.bm.entity.OperationsBean">
SELECT
bm.id,
p_id as prepaymentId,
month,
operation_type as operationType,
amount,
executor,
remarks,
next_month as nextMonth,
proposed_amount as proposedAmount,
handler,
next_remarks as nextRemarks,
u.username as operator,
created_time as createdTime,
updated_time as updatedTime,
u.id as userId,
u.username as userName
FROM `bm_monthly_operations` bm
LEFT JOIN sys_user u ON u.id = bm.operator
WHERE bm.is_active = '1' AND bm.id= #{id}
</select>
</mapper>