| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316 |
- <?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.sckw.manage.dao.KwmCooperateMapper">
- <select id="findList" parameterType="com.sckw.manage.model.dto.req.CooperateManageQueryReqDto"
- resultType="com.sckw.manage.model.dto.res.CooperateManageQueryResDto">
- SELECT a.id,
- b.status,
- group_concat(b.type) types,
- min(a.ent_id) entId,
- min(a.invitee_ent_id) inviteeEntId,
- min(a.inviter_ent_id) inviterEntId,
- min(a.invitee_contacts) inviteeContacts,
- min(a.inviter_contacts) inviterContacts,
- min(a.invitee_contacts_id) inviteeContactsId,
- min(a.inviter_contacts_id) inviterContactsId,
- min(a.invitee_phone) inviteePhone,
- min(a.inviter_phone) inviterPhone,
- min(b.create_time) createTime,
- min(b.create_by) createBy,
- min(a.remark) remark,
- min(a.approval_remark) approvalRemark,
- case when min(a.ent_id) = #{reqDto.currentEntId} then min(a.invitee_ent_id) else min(a.inviter_ent_id) end targetEntId,
- case when min(a.ent_id) = #{reqDto.currentEntId} then min(a.inviter_ent_id) else min(a.invitee_ent_id) end ourEntId,
- case when min(a.ent_id) = #{reqDto.currentEntId} then 1 else 2 end applyTypeCode
- FROM kwm_cooperate a
- LEFT JOIN kwm_cooperate_type b ON a.id = b.cooperate_id
- WHERE a.del_flag = 0
- and ((a.invitee_ent_id in
- <foreach collection="reqDto.currentEntIdList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- <if test="reqDto.targetEntIdList != null and reqDto.targetEntIdList.size() > 0">
- and (a.inviter_ent_id in
- <foreach collection="reqDto.targetEntIdList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- or a.inviter_contacts like concat('%', #{reqDto.keywords}, '%') or
- a.inviter_phone like concat('%', #{reqDto.keywords}, '%')
- )
- </if>
- ) OR
- (a.inviter_ent_id in
- <foreach collection="reqDto.currentEntIdList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- <if test="reqDto.targetEntIdList != null and reqDto.targetEntIdList.size() > 0">
- and (a.invitee_ent_id in
- <foreach collection="reqDto.targetEntIdList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- or a.invitee_contacts like concat('%', #{reqDto.keywords}, '%') or
- a.invitee_phone like concat('%', #{reqDto.keywords}, '%')
- )
- </if>
- ))
- <if test="reqDto.startTime != null">
- and b.create_time >= #{reqDto.startTime}
- </if>
- <if test="reqDto.endTime != null">
- and b.create_time < date_add(#{reqDto.endTime}, INTERVAL 1 DAY)
- </if>
- <if test="reqDto.applyTypeCode != null and reqDto.applyTypeCode == 1">
- and a.ent_id = #{reqDto.currentEntId}
- </if>
- <if test="reqDto.applyTypeCode != null and reqDto.applyTypeCode == 2">
- and a.ent_id != #{reqDto.currentEntId}
- </if>
- <if test="reqDto.cooperateTypes != null and reqDto.cooperateTypes.size() > 0">
- and exists (select 1
- from kwm_cooperate_type c
- where c.cooperate_id = a.id
- and c.status = b.status
- and c.del_flag = 0
- and c.type in
- <foreach collection="reqDto.cooperateTypes" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- )
- </if>
- <if test="reqDto.status != null and reqDto.status.size() > 0">
- and b.status in
- <foreach collection="reqDto.status" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="reqDto.keywords != null and (reqDto.targetEntIdList == null or reqDto.targetEntIdList.size() == 0)">
- and (a.invitee_contacts like concat('%', #{reqDto.keywords}, '%') or
- a.inviter_contacts like concat('%', #{reqDto.keywords}, '%') or
- a.invitee_phone like concat('%', #{reqDto.keywords}, '%') or
- a.inviter_phone like concat('%', #{reqDto.keywords}, '%')
- )
- </if>
- <if test="reqDto.ids != null and reqDto.ids.size() > 0">
- and a.id in
- <foreach collection="reqDto.ids" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- group by a.id, b.status
- order by a.create_time desc
- </select>
- <select id="findCooperateByEnt" resultType="com.sckw.manage.model.entity.KwmCooperate">
- select a.*
- from kwm_cooperate a
- where a.del_flag = 0
- and a.status = 1
- and ((a.inviter_ent_id = #{entId}
- <if test="targetEntId != null">
- and a.invitee_ent_id = #{targetEntId}
- </if>
- )
- or
- (a.invitee_ent_id = #{entId}
- <if test="targetEntId != null">
- and a.inviter_ent_id = #{targetEntId}
- </if>
- ))
- <if test="cooperateType != null">
- and exists (select 1
- from kwm_cooperate_type c
- where c.cooperate_id = a.id
- and c.del_flag = 0
- and c.type = #{cooperateType}
- )
- </if>
- </select>
- <select id="findManageList" resultType="com.sckw.manage.model.dto.res.CooperateManageQueryResDto">
- SELECT a.id,
- min(a.status) status,
- group_concat(b.type) types,
- min(a.ent_id) entId,
- min(a.invitee_ent_id) inviteeEntId,
- min(a.inviter_ent_id) inviterEntId,
- min(a.invitee_contacts) inviteeContacts,
- min(a.inviter_contacts) inviterContacts,
- min(a.invitee_contacts_id) inviteeContactsId,
- min(a.inviter_contacts_id) inviterContactsId,
- min(a.invitee_phone) inviteePhone,
- min(a.inviter_phone) inviterPhone,
- min(b.create_time) createTime,
- min(b.create_by) createBy,
- min(a.remark) remark,
- min(a.approval_remark) approvalRemark,
- case when min(a.ent_id) = #{reqDto.currentEntId} then min(a.invitee_ent_id) else min(a.inviter_ent_id) end targetEntId,
- case when min(a.ent_id) = #{reqDto.currentEntId} then min(a.inviter_ent_id) else min(a.invitee_ent_id) end ourEntId,
- case when min(a.ent_id) = #{reqDto.currentEntId} then 1 else 2 end applyTypeCode
- FROM kwm_cooperate a
- LEFT JOIN kwm_cooperate_type b ON a.id = b.cooperate_id and b.status = 1 and b.del_flag = 0
- WHERE a.del_flag = 0
- and ((a.invitee_ent_id in
- <foreach collection="reqDto.currentEntIdList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- <if test="reqDto.targetEntIdList != null and reqDto.targetEntIdList.size() > 0">
- and (a.inviter_ent_id in
- <foreach collection="reqDto.targetEntIdList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- or a.inviter_contacts like concat('%', #{reqDto.keywords}, '%') or
- a.inviter_phone like concat('%', #{reqDto.keywords}, '%')
- )
- </if>
- )
- OR (a.inviter_ent_id in
- <foreach collection="reqDto.currentEntIdList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- <if test="reqDto.targetEntIdList != null and reqDto.targetEntIdList.size() > 0">
- and (a.invitee_ent_id in
- <foreach collection="reqDto.targetEntIdList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- or a.invitee_contacts like concat('%', #{reqDto.keywords}, '%') or
- a.invitee_phone like concat('%', #{reqDto.keywords}, '%')
- )
- </if>
- ))
- <if test="reqDto.startTime != null">
- and b.create_time >= #{reqDto.startTime}
- </if>
- <if test="reqDto.endTime != null">
- and b.create_time < date_add(#{reqDto.endTime}, INTERVAL 1 DAY)
- </if>
- <if test="reqDto.applyTypeCode != null and reqDto.applyTypeCode == 1">
- and a.ent_id = #{reqDto.currentEntId}
- </if>
- <if test="reqDto.applyTypeCode != null and reqDto.applyTypeCode == 2">
- and a.ent_id != #{reqDto.currentEntId}
- </if>
- <if test="reqDto.cooperateTypes != null and reqDto.cooperateTypes.size() > 0">
- and exists (select 1
- from kwm_cooperate_type c
- where c.cooperate_id = a.id
- and c.status = 1
- and c.del_flag = 0
- and c.type in
- <foreach collection="reqDto.cooperateTypes" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- )
- </if>
- <if test="reqDto.status != null and reqDto.status.size() > 0">
- and a.status in
- <foreach collection="reqDto.status" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="reqDto.keywords != null and (reqDto.targetEntIdList == null or reqDto.targetEntIdList.size() == 0)">
- and (a.invitee_contacts like concat('%', #{reqDto.keywords}, '%') or
- a.inviter_contacts like concat('%', #{reqDto.keywords}, '%') or
- a.invitee_phone like concat('%', #{reqDto.keywords}, '%') or
- a.inviter_phone like concat('%', #{reqDto.keywords}, '%')
- )
- </if>
- <if test="reqDto.ids != null and reqDto.ids.size() > 0">
- and a.id in
- <foreach collection="reqDto.ids" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- group by a.id
- order by a.create_time desc
- </select>
- <select id="findEntCooperate" resultType="com.sckw.manage.model.entity.KwmCooperate">
- select a.* from kwm_cooperate a
- where a.del_flag = 0
- and a.status = 1
- and ((a.inviter_ent_id = #{id}
- <if test="targetEntId != null">
- and a.invitee_ent_id = #{targetEntId}
- </if>) or
- (a.invitee_ent_id = #{id}
- <if test="targetEntId != null">
- and a.inviter_ent_id = #{targetEntId}
- </if>)
- )
- </select>
- <select id="queryAllCooperateInfoList"
- resultType="com.sckw.manage.model.dto.res.CooperateManageQueryResDto">
- SELECT a.id,
- min(a.status) status,
- group_concat(b.type) types,
- min(a.ent_id) entId,
- min(a.invitee_ent_id) inviteeEntId,
- min(a.inviter_ent_id) inviterEntId,
- min(a.invitee_contacts) inviteeContacts,
- min(a.inviter_contacts) inviterContacts,
- min(a.invitee_contacts_id) inviteeContactsId,
- min(a.inviter_contacts_id) inviterContactsId,
- min(a.invitee_phone) inviteePhone,
- min(a.inviter_phone) inviterPhone,
- min(b.create_time) createTime,
- min(b.update_time) updateTime,
- min(b.create_by) createBy,
- min(a.remark) remark
- FROM kwm_cooperate a
- LEFT JOIN kwm_cooperate_type b ON a.id = b.cooperate_id and b.status = 1 and b.del_flag = 0
- WHERE a.del_flag = 0
- and a.status in (1,2)
- <if test="reqDto.cooperateTypes != null and reqDto.cooperateTypes.size() > 0">
- and exists (select 1
- from kwm_cooperate_type c
- where c.cooperate_id = a.id
- and c.status = b.status
- and c.del_flag = 0
- and c.type in
- <foreach collection="reqDto.cooperateTypes" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- )
- </if>
- <if test="reqDto.startTime != null">
- and b.create_time >= #{reqDto.startTime}
- </if>
- <if test="reqDto.endTime != null">
- and b.create_time < date_add(#{reqDto.endTime}, INTERVAL 1 DAY)
- </if>
- <if test="reqDto.ids != null and reqDto.ids.size() > 0">
- and a.id in
- <foreach collection="reqDto.ids" separator="," open="(" close=")" item="item">
- #{item}
- </foreach>
- </if>
- <if test="reqDto.queryEntIdList != null and reqDto.queryEntIdList.size() > 0">
- and (a.inviter_ent_id in
- <foreach collection="reqDto.queryEntIdList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- or
- a.invitee_ent_id in
- <foreach collection="reqDto.queryEntIdList" item="item" open="(" close=")" separator=",">
- #{item}
- </foreach>
- )
- </if>
- <if test="reqDto.keywords != null and (reqDto.queryEntIdList == null or reqDto.queryEntIdList.size() == 0)">
- and (a.invitee_contacts like concat('%', #{reqDto.keywords}, '%') or
- a.inviter_contacts like concat('%', #{reqDto.keywords}, '%') or
- a.invitee_phone like concat('%', #{reqDto.keywords}, '%') or
- a.inviter_phone like concat('%', #{reqDto.keywords}, '%')
- )
- </if>
- group by a.id
- order by a.create_time desc
- </select>
- </mapper>
|