|
|
@@ -4,55 +4,27 @@
|
|
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
|
<mapper namespace="com.sckw.manage.dao.KwmCooperateMapper">
|
|
|
|
|
|
- <resultMap id="BaseResultMap" type="com.sckw.manage.model.entity.KwmCooperate">
|
|
|
- <id property="id" column="id" jdbcType="BIGINT"/>
|
|
|
- <result property="entId" column="ent_id" jdbcType="BIGINT"/>
|
|
|
- <result property="inviterEntId" column="inviter_ent_id" jdbcType="BIGINT"/>
|
|
|
- <result property="inviteeEntId" column="invitee_ent_id" jdbcType="BIGINT"/>
|
|
|
- <result property="inviterContacts" column="inviter_contacts" jdbcType="VARCHAR"/>
|
|
|
- <result property="inviterPhone" column="inviter_phone" jdbcType="VARCHAR"/>
|
|
|
- <result property="inviteeContacts" column="invitee_contacts" jdbcType="VARCHAR"/>
|
|
|
- <result property="inviteePhone" column="invitee_phone" jdbcType="VARCHAR"/>
|
|
|
- <result property="remark" column="remark" jdbcType="VARCHAR"/>
|
|
|
- <result property="status" column="status" jdbcType="INTEGER"/>
|
|
|
- <result property="createBy" column="create_by" jdbcType="BIGINT"/>
|
|
|
- <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
|
|
- <result property="updateBy" column="update_by" jdbcType="BIGINT"/>
|
|
|
- <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
|
|
- <result property="delFlag" column="del_flag" jdbcType="INTEGER"/>
|
|
|
- </resultMap>
|
|
|
-
|
|
|
- <sql id="Base_Column_List">
|
|
|
- id,ent_id,inviter_ent_id,
|
|
|
- invitee_ent_id,inviter_contacts,inviter_phone,
|
|
|
- invitee_contacts,invitee_phone,remark,
|
|
|
- status,create_by,create_time,
|
|
|
- update_by,update_time,del_flag
|
|
|
- </sql>
|
|
|
-
|
|
|
<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
|
|
|
+ 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
|
|
|
@@ -272,4 +244,73 @@
|
|
|
)
|
|
|
</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>
|