Files
zxjp-web/coolstore-partner-dao/src/main/resources/mapper/HyPartnerExhibitionMapper.xml
2023-12-21 16:25:53 +08:00

493 lines
18 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.cool.store.mapper.HyPartnerExhibitionMapper">
<resultMap id="BaseResultMap" type="com.cool.store.entity.HyPartnerExhibitionDO">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="exhibition_id" jdbcType="BIGINT" property="exhibitionId" />
<result column="partner_line_id" jdbcType="BIGINT" property="partnerLineId" />
<result column="partner_id" jdbcType="VARCHAR" property="partnerId" />
<result column="want_shop_area" jdbcType="VARCHAR" property="wantShopArea" />
<result column="investment_manager_name" jdbcType="VARCHAR" property="investmentManagerName" />
<result column="expected_visitors_count" jdbcType="INTEGER" property="expectedVisitorsCount" />
<result column="expected_information" jdbcType="VARCHAR" property="expectedInformation" />
<result column="participation_status" jdbcType="TINYINT" property="participationStatus" />
<result column="interview_plan_id" jdbcType="BIGINT" property="interviewPlanId" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="creator" jdbcType="VARCHAR" property="creator" />
<result column="updater" jdbcType="VARCHAR" property="updater" />
<result column="deleted" jdbcType="BIT" property="deleted" />
<result column="check_in_time" jdbcType="TIMESTAMP" property="checkInTime" />
</resultMap>
<sql id="Base_Column_List">
id, exhibition_id, partner_line_id, partner_id, want_shop_area, investment_manager_name,
expected_visitors_count, expected_information, participation_status, interview_plan_id,
create_time, update_time, creator, updater, deleted,check_in_time
</sql>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from hy_partner_exhibition
where id = #{id,jdbcType=BIGINT}
</select>
<select id="querySelective" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from hy_partner_exhibition
<where>
<if test="exhibitionId != null">
and exhibition_id = #{exhibitionId,jdbcType=BIGINT}
</if>
<if test="partnerLineId != null">
and partner_line_id = #{partnerLineId,jdbcType=BIGINT}
</if>
<if test="partnerId != null">
and partner_id = #{partnerId,jdbcType=VARCHAR}
</if>
<if test="wantShopArea != null">
and want_shop_area = #{wantShopArea,jdbcType=VARCHAR}
</if>
<if test="investmentManagerName != null">
and investment_manager_name = #{investmentManagerName,jdbcType=VARCHAR}
</if>
<if test="expectedVisitorsCount != null">
and expected_visitors_count = #{expectedVisitorsCount,jdbcType=INTEGER}
</if>
<if test="expectedInformation != null">
and expected_information = #{expectedInformation,jdbcType=VARCHAR}
</if>
<if test="participationStatus != null">
and participation_status = #{participationStatus,jdbcType=TINYINT}
</if>
<if test="interviewPlanId != null">
and interview_plan_id = #{interviewPlanId,jdbcType=BIGINT}
</if>
<if test="createTime != null">
and create_time = #{createTime,jdbcType=TIMESTAMP}
</if>
<if test="updateTime != null">
and update_time = #{updateTime,jdbcType=TIMESTAMP}
</if>
<if test="creator != null">
and creator = #{creator,jdbcType=VARCHAR}
</if>
<if test="updater != null">
and updater = #{updater,jdbcType=VARCHAR}
</if>
<if test="deleted != null">
and deleted = #{deleted,jdbcType=BIT}
</if>
</where>
</select>
<select id="exhibitionLineList" resultType="com.cool.store.dto.exhibition.ExhibitionLineDTO">
select
hpe.id as id ,
hpe.partner_id as partnerId,
hpe.partner_line_id as lineId,
hpe.participation_status as participationStatus,
hpe.investment_manager_name as customerManager,
hpe.expected_visitors_count as expectedVisitorsCount,
hpe.expected_information as expectedInformation,
hpui.username as partnerName,
hpui.mobile as mobile,
hoai.id as wantShopArea,
hoai.area_path as wantShopAreaName
from hy_partner_exhibition hpe
left join hy_partner_user_info hpui on hpe.partner_id = hpui.partner_id
left join hy_open_area_info hoai on hpe.want_shop_area = hoai.id
left join hy_partner_intent_info hpii on hpii.partner_line_id = hpe.partner_line_id
left join hy_partner_interview_plan hpip on hpip.id = hpe.interview_plan_id
<where>
<if test="exhibitionId != null">
and hpe.exhibition_id = #{exhibitionId,jdbcType=BIGINT}
</if>
<if test="participationStatus != null">
<if test="participationStatus==4">
and hpe.participation_status in (4,5,6)
</if>
<if test="participationStatus!=4">
and hpe.participation_status = #{participationStatus,jdbcType=BIGINT}
</if>
</if>
<if test="partnerUserId != null and partnerUserId!=''">
and hpui.user_id = #{partnerUserId,jdbcType=VARCHAR}
</if>
</where>
<if test="participationStatus == null">
ORDER BY CASE WHEN hpe.participation_status != 7 THEN 1 ELSE 2 END, hpe.create_time DESC
</if>
<if test="participationStatus != null and participationStatus==1">
ORDER BY hpe.check_in_time DESC
</if>
<if test="participationStatus != null and participationStatus==2">
ORDER BY hpii.create_time DESC
</if>
<if test="participationStatus != null and participationStatus==3">
ORDER BY CASE
WHEN hpip.interviewer = #{userId} THEN 0 ELSE 1 END,
hpip.actual_start_time DESC
</if>
<if test="participationStatus != null and participationStatus==4">
ORDER BY hpe.participation_status asc,
CASE WHEN hpip.interviewer = #{userId} THEN 0 ELSE 1 END,
hpip.actual_end_time DESC
</if>
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
delete from hy_partner_exhibition
where id = #{id,jdbcType=BIGINT}
</delete>
<select id="getExhibitionLine" resultType="com.cool.store.dto.exhibition.ExhibitionLineDTO">
select
hpe.partner_id as partnerId,
hpe.partner_line_id as lineId,
hpe.exhibition_id as exhibitionId,
pu.username as partnerName,
pu.mobile as mobile
from hy_partner_exhibition hpe left join hy_partner_user_info pu on hpe.partner_id = pu.partner_id
where hpe.participation_status != 7
and hpe.deleted = 0
<if test="exhibitionId != null and exhibitionId!=''">
and hpe.exhibition_id = #{exhibitionId}
</if>
</select>
<insert id="insertSelective" parameterType="com.cool.store.entity.HyPartnerExhibitionDO">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Long">
SELECT LAST_INSERT_ID()
</selectKey>
insert into hy_partner_exhibition
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="exhibitionId != null">
exhibition_id,
</if>
<if test="partnerLineId != null">
partner_line_id,
</if>
<if test="partnerId != null">
partner_id,
</if>
<if test="wantShopArea != null">
want_shop_area,
</if>
<if test="investmentManagerName != null">
investment_manager_name,
</if>
<if test="expectedVisitorsCount != null">
expected_visitors_count,
</if>
<if test="expectedInformation != null">
expected_information,
</if>
<if test="participationStatus != null">
participation_status,
</if>
<if test="interviewPlanId != null">
interview_plan_id,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
<if test="creator != null">
creator,
</if>
<if test="updater != null">
updater,
</if>
<if test="deleted != null">
deleted,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="exhibitionId != null">
#{exhibitionId,jdbcType=VARCHAR},
</if>
<if test="partnerLineId != null">
#{partnerLineId,jdbcType=BIGINT},
</if>
<if test="partnerId != null">
#{partnerId,jdbcType=VARCHAR},
</if>
<if test="wantShopArea != null">
#{wantShopArea,jdbcType=VARCHAR},
</if>
<if test="investmentManagerName != null">
#{investmentManagerName,jdbcType=VARCHAR},
</if>
<if test="expectedVisitorsCount != null">
#{expectedVisitorsCount,jdbcType=INTEGER},
</if>
<if test="expectedInformation != null">
#{expectedInformation,jdbcType=VARCHAR},
</if>
<if test="participationStatus != null">
#{participationStatus,jdbcType=TINYINT},
</if>
<if test="interviewPlanId != null">
#{interviewPlanId,jdbcType=BIGINT},
</if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="creator != null">
#{creator,jdbcType=VARCHAR},
</if>
<if test="updater != null">
#{updater,jdbcType=VARCHAR},
</if>
<if test="deleted != null">
#{deleted,jdbcType=BIT},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.cool.store.entity.HyPartnerExhibitionDO">
update hy_partner_exhibition
<set>
<if test="exhibitionId != null">
exhibition_id = #{exhibitionId,jdbcType=BIGINT},
</if>
<if test="partnerLineId != null">
partner_line_id = #{partnerLineId,jdbcType=BIGINT},
</if>
<if test="partnerId != null">
partner_id = #{partnerId,jdbcType=VARCHAR},
</if>
<if test="wantShopArea != null">
want_shop_area = #{wantShopArea,jdbcType=VARCHAR},
</if>
<if test="investmentManagerName != null">
investment_manager_name = #{investmentManagerName,jdbcType=VARCHAR},
</if>
<if test="expectedVisitorsCount != null">
expected_visitors_count = #{expectedVisitorsCount,jdbcType=INTEGER},
</if>
<if test="expectedInformation != null">
expected_information = #{expectedInformation,jdbcType=VARCHAR},
</if>
<if test="participationStatus != null">
participation_status = #{participationStatus,jdbcType=TINYINT},
</if>
<if test="interviewPlanId != null">
interview_plan_id = #{interviewPlanId,jdbcType=BIGINT},
</if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
<if test="creator != null">
creator = #{creator,jdbcType=VARCHAR},
</if>
<if test="updater != null">
updater = #{updater,jdbcType=VARCHAR},
</if>
<if test="deleted != null">
deleted = #{deleted,jdbcType=BIT},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
<sql id="dynamicQuery">
<trim prefix="WHERE" prefixOverrides="AND | OR">
<if test="null != id">
and t.id = #{id,jdbcType=BIGINT}
</if>
<if test="null != exhibitionId">
and t.exhibition_id = #{exhibitionId,jdbcType=VARCHAR}
</if>
<if test="null != partnerLineId">
and t.partner_line_id = #{partnerLineId,jdbcType=BIGINT}
</if>
<if test="null != partnerId">
and t.partner_id = #{partnerId,jdbcType=VARCHAR}
</if>
<if test="null != wantShopArea">
and t.want_shop_area = #{wantShopArea,jdbcType=VARCHAR}
</if>
<if test="null != investmentManagerName">
and t.investment_manager_name = #{investmentManagerName,jdbcType=VARCHAR}
</if>
<if test="null != expectedVisitorsCount">
and t.expected_visitors_count = #{expectedVisitorsCount,jdbcType=INTEGER}
</if>
<if test="null != expectedInformation">
and t.expected_information = #{expectedInformation,jdbcType=VARCHAR}
</if>
<if test="null != participationStatus">
and t.participation_status = #{participationStatus,jdbcType=TINYINT}
</if>
<if test="null != interviewPlanId">
and t.interview_plan_id = #{interviewPlanId,jdbcType=BIGINT}
</if>
<if test="null != createTime">
and t.create_time = #{createTime,jdbcType=TIMESTAMP}
</if>
<if test="null != updateTime">
and t.update_time = #{updateTime,jdbcType=TIMESTAMP}
</if>
<if test="null != creator">
and t.creator = #{creator,jdbcType=VARCHAR}
</if>
<if test="null != updater">
and t.updater = #{updater,jdbcType=VARCHAR}
</if>
<if test="null != deleted">
and t.deleted = #{deleted,jdbcType=BIT}
</if>
</trim>
</sql>
<update id="rejectExhibitionInterview">
UPDATE hy_partner_exhibition
SET participation_status = 6
WHERE partner_line_id = #{partnerLineId}
AND participation_status = 4
</update>
<update id="deleteAllByLineId">
UPDATE hy_partner_exhibition
SET deleted = 1
WHERE partner_line_id = #{partnerLineId}
AND deleted = 0
</update>
<select id="queryListByInterviewPlanIds" resultType="java.lang.Long">
SELECT interview_plan_id
FROM hy_partner_exhibition
WHERE deleted = 0
AND interview_plan_id IN (
<foreach collection="interviewPlanIds" item="interviewPlanId" separator=",">
#{interviewPlanId}
</foreach>
)
</select>
<select id="queryListByLineIds" resultType="java.lang.Long">
SELECT partner_line_id
FROM (
SELECT partner_line_id, exhibition_id
FROM hy_partner_exhibition
WHERE partner_line_id IN (
<foreach collection="lineIds" item="lineId" separator=",">
#{lineId}
</foreach>
)
AND deleted = 0
AND participation_status = 4
) t1
LEFT JOIN (
SELECT id, closed_type
FROM hy_exhibition
WHERE deleted = 0
AND closed_type = 0
) t2 ON t1.exhibition_id = t2.id
WHERE closed_type = 0
</select>
<select id="queryPartnerExhibitionInterviewInfo"
resultType="com.cool.store.entity.HyPartnerExhibitionInterviewDO">
SELECT
exhibition_id AS exhibitionId,
interview_plan_id AS interviewPlanId,
exhibition_name AS exhibitionName,
start_date AS exhibitionDate
FROM (
SELECT exhibition_id, interview_plan_id
FROM hy_partner_exhibition
WHERE deleted = 0
AND partner_line_id = #{partnerLineId}
AND interview_plan_id = #{interviewPlanId}
) t1 LEFT JOIN (
SELECT id, exhibition_name, start_date
FROM hy_exhibition
WHERE deleted = 0
) t2 ON t1.exhibition_id = t2.id
</select>
<select id="exhibitionLineBaseInfo" resultType="com.cool.store.dto.exhibition.ExhibitionLineBaseDTO">
select
hpe.participation_status as participationStatus,
hpui.username as partnerName,
hpui.partner_id as partnerId,
hpui.mobile as mobile
from hy_partner_exhibition hpe
left join hy_partner_user_info hpui
on hpe.partner_id = hpui.partner_id
<where>
<if test="partnerName!=null and partnerName!=''">
and hpui.username like concat("%", #{partnerName}, "%")
</if>
<if test="id!=null">
and hpe.exhibition_id = #{id}
</if>
</where>
</select>
<select id="getPartnerExhibition" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from hy_partner_exhibition
<where>
<if test="exhibitionId!=null">
and exhibition_id = #{exhibitionId}
</if>
<if test="lineId!=null">
and partner_line_id = #{lineId}
</if>
</where>
</select>
<select id="partnerSignUpCount" resultType="com.cool.store.dto.exhibition.PartnerSignUpDTO">
select
a.partner_line_id as lineId ,
count(1) as count
from hy_partner_exhibition a
left join hy_exhibition b on a.exhibition_id = b.id
where a.participation_status != 7 and b.closed_type=0
<foreach collection="lineIds" item="lineId" open="and a.partner_line_id in (" separator="," close=")">
#{lineId}
</foreach>
group by a.partner_line_id
</select>
<select id="getCloseExhibitionLineIds" resultType="java.lang.Long">
SELECT DISTINCT partner_line_id
FROM hy_partner_exhibition
WHERE deleted = 0
AND exhibition_id IN (
<foreach collection="exhibitionIds" item="exhibitionId" separator=",">
#{exhibitionId}
</foreach>
)
AND participation_status != 7
</select>
<select id="getLineByExhibitionIds" resultType="com.cool.store.dto.exhibition.ExhibitionLineDTO">
select distinct
hpe.partner_id as partnerId,
hpe.partner_line_id as lineId,
hpe.exhibition_id as exhibitionId,
pu.username as partnerName,
pu.mobile as mobile
from hy_partner_exhibition hpe left join hy_partner_user_info pu on hpe.partner_id = pu.partner_id
where hpe.participation_status != 7
and hpe.deleted = 0
and hpe.exhibition_id in (
<foreach collection="exhibitionIds" item="exhibitionId" separator=",">
#{exhibitionId}
</foreach>
)
</select>
</mapper>