205 lines
8.3 KiB
XML
205 lines
8.3 KiB
XML
<?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`,`current_balance`)
|
|
VALUES (#{prepaymentId},
|
|
#{month},
|
|
#{operationType},
|
|
#{amount},
|
|
#{executor},
|
|
#{remarks},
|
|
#{nextMonth},
|
|
#{proposedAmount},
|
|
#{handler},
|
|
#{nextRemarks}, '1', #{operator},#{currentBalance})
|
|
</insert>
|
|
<update id="updatePrepaymentId">
|
|
UPDATE `bm_project_prepayment`
|
|
SET `current_balance` = #{currentBalanceNew},
|
|
`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
|
|
bm.id,
|
|
bm.project_code as projectCode,
|
|
bm.project_name as projectName,
|
|
bm.business_unit as businessUnit,
|
|
bm.contact_unit as contactUnit,
|
|
bm.type,
|
|
bm.initial_amount as initialAmount,
|
|
bm.first_payment_date as firstPaymentDate,
|
|
bm.current_balance as currentBalance,
|
|
bm.remarks,
|
|
u.username as operator,
|
|
bm.created_time as createdTime,
|
|
bm.updated_time as updatedTime,
|
|
GREATEST(PERIOD_DIFF(DATE_FORMAT(CURDATE(), '%Y%m'), DATE_FORMAT(bm.first_payment_date, '%Y%m')), 0) AS
|
|
agingMonths,
|
|
CASE
|
|
WHEN bm.current_balance = 0 THEN 0
|
|
ELSE 1
|
|
END AS state
|
|
FROM
|
|
`bm_project_prepayment` bm
|
|
LEFT JOIN sys_user u ON u.id = bm.operator
|
|
WHERE bm.is_active = '1'
|
|
<if test="params.keyword != null and params.keyword != ''">
|
|
AND (
|
|
bm.project_code LIKE CONCAT('%', #{params.keyword}, '%')
|
|
OR bm.project_name LIKE CONCAT('%', #{params.keyword}, '%')
|
|
OR bm.business_unit LIKE CONCAT('%', #{params.keyword}, '%')
|
|
OR bm.contact_unit LIKE CONCAT('%', #{params.keyword}, '%')
|
|
OR bm.type LIKE CONCAT('%', #{params.keyword}, '%')
|
|
)
|
|
</if>
|
|
<if test="params.state =='1' || params.state ==1">
|
|
AND bm.current_balance>0
|
|
</if>
|
|
<if test="params.state =='2' || params.state ==2">
|
|
AND bm.current_balance=0
|
|
</if>
|
|
ORDER BY bm.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 bm.id,
|
|
bm.p_id as prepaymentId, bm.month, bm.operation_type as operationType,
|
|
bm.amount, u2.username as executor, bm.remarks, bm.next_month as nextMonth,
|
|
bm.proposed_amount as proposedAmount, bm.handler, bm.next_remarks as nextRemarks,
|
|
u.username as operator, bm.created_time as createdTime, bm.updated_time as updatedTime
|
|
,pro.project_name as projectName
|
|
FROM `bm_monthly_operations` bm
|
|
LEFT JOIN bm_project_prepayment pro ON pro.id = bm.p_id
|
|
LEFT JOIN sys_user u ON u.id = bm.operator
|
|
LEFT JOIN sys_user u2 ON u2.id = bm.executor
|
|
WHERE bm.is_active = '1' AND bm.p_id = #{params.prepaymentId}
|
|
ORDER BY bm.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,
|
|
u2.username as 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,bm.current_balance as currentBalance
|
|
FROM `bm_monthly_operations` bm
|
|
LEFT JOIN sys_user u ON u.id = bm.operator
|
|
LEFT JOIN sys_user u2 ON u2.id = bm.executor
|
|
WHERE bm.is_active = '1' AND bm.id= #{id}
|
|
</select>
|
|
</mapper> |