<?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.nuvole.four.mapper.ActivityDistributeRecordMapper" >
|
<select id="selectList" parameterType="com.nuvole.four.domain.query.ActivityDistributeRecordQuery" resultType="com.nuvole.four.domain.ActivityDistributeRecord">
|
select <include refid="Base_Column_List"></include>
|
from activity_distribute_record
|
<where>
|
<if test="orgId!=null">
|
and org_id =#{orgId}
|
</if>
|
<if test="orgName!=null and orgName!=''">
|
and org_name like concat('%',#{orgName},'%')
|
</if>
|
<if test="totalFee!=null">
|
and total_fee =#{totalFee}
|
</if>
|
<if test="useFee!=null">
|
and use_fee =#{useFee}
|
</if>
|
<if test="surplusFee!=null">
|
and surplus_fee =#{surplusFee}
|
</if>
|
<if test="lv1Id!=null">
|
and lv1_id =#{lv1Id}
|
</if>
|
<if test="lv2Id!=null">
|
and lv2_id =#{lv2Id}
|
</if>
|
<if test="lv3Id!=null">
|
and lv3_id =#{lv3Id}
|
</if>
|
<if test="lv4Id!=null">
|
and lv4_id =#{lv4Id}
|
</if>
|
<if test="status!=null">
|
and status =#{status}
|
</if>
|
<if test="deleted!=null">
|
and deleted =#{deleted}
|
</if>
|
<if test="createBy!=null">
|
and create_by =#{createBy}
|
</if>
|
<if test="createTime!=null">
|
and create_time =#{createTime}
|
</if>
|
<if test="updateBy!=null">
|
and update_by =#{updateBy}
|
</if>
|
<if test="updateTime!=null">
|
and update_time =#{updateTime}
|
</if>
|
</where>
|
</select>
|
|
<select id="getActivityDistributeRecordDetail" parameterType="java.lang.Long"
|
resultType="com.nuvole.four.domain.dto.ActivityDistributeBudgetDto">
|
SELECT
|
adr.id,
|
adr.total_fee totalFee,
|
adr.surplus_fee surplusFee,
|
so.id orgId,
|
so.NAME orgName,
|
so.org_code orgCode,
|
so.pid pId,
|
so.lv orgLv,
|
IFNULL( adr.use_fee, 0 ) useFee,
|
if( adr.id is null, 0, 1) useOrNot
|
FROM
|
sys_org so
|
LEFT JOIN activity_distribute_record adr ON adr.org_id = so.id
|
AND adr.deleted = 0 and adr.activity_id = #{activityId}
|
<where>
|
<if test="orgId != null">
|
and so.pid = #{orgId}
|
</if>
|
</where>
|
GROUP BY
|
so.id
|
ORDER BY
|
sort_no
|
</select>
|
|
|
<select id="getActivityDistributeRecordDetailByAId" parameterType="java.lang.Long"
|
resultType="com.nuvole.four.domain.dto.ActivityDistributeBudgetDto">
|
SELECT
|
adr.id,
|
adr.total_fee totalFee,
|
adr.surplus_fee surplusFee,
|
so.id orgId,
|
so.NAME orgName,
|
so.org_code orgCode,
|
so.pid pId,
|
so.lv orgLv,
|
IFNULL( adr.use_fee, 0 ) useFee
|
FROM
|
sys_org so
|
JOIN activity_distribute_record adr ON adr.org_id = so.id
|
AND adr.deleted = 0 and adr.activity_id = #{activityId}
|
<where>
|
AND adr.deleted = 0
|
<if test="activityId != null">
|
and adr.activity_id = #{activityId}
|
</if>
|
<if test="orgCode!=null and orgCode!=''">
|
and adr.org_code like concat(#{orgCode}, '%')
|
</if>
|
</where>
|
GROUP BY
|
so.id
|
ORDER BY
|
sort_no
|
</select>
|
|
<select id="selectAllByActivityIds" resultType="com.nuvole.four.domain.ActivityDistributeRecord">
|
select * from activity_distribute_record
|
<where>
|
and deleted = 0
|
<if test="ids != null">
|
and activity_id = in
|
<foreach collection="ids" open="(" separator="," item="item" close=")">
|
#{item}
|
</foreach>
|
</if>
|
</where>
|
</select>
|
|
|
<insert id="batchInsertOrUpdate" parameterType="list">
|
insert into activity_distribute_record
|
(id,org_id,org_name,org_code,activity_id,total_fee,use_fee,surplus_fee,lv1_id,lv2_id,lv3_id,lv4_id,status,deleted,create_by,create_time,update_by,update_time)
|
values
|
<foreach collection="list" item="i" separator=",">
|
(
|
#{i.id},
|
#{i.orgId},
|
#{i.orgName},
|
#{i.orgCode},
|
#{i.activityId},
|
#{i.totalFee},
|
#{i.useFee},
|
#{i.surplusFee},
|
#{i.lv1Id},
|
#{i.lv2Id},
|
#{i.lv3Id},
|
#{i.lv4Id},
|
#{i.status},
|
#{i.deleted},
|
#{i.createBy},
|
#{i.createTime},
|
#{i.updateBy},
|
#{i.updateTime}
|
)
|
</foreach>
|
ON duplicate KEY UPDATE
|
use_fee = values(use_fee),
|
deleted = values(deleted),
|
update_by = values(update_by),
|
update_time = values(update_time)
|
</insert>
|
</mapper>
|