404 lines
15 KiB
XML
404 lines
15 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.zhwl.hotel.homestay.mapper.ZdyHotelHomestayCustomerMapper">
|
|
|
|
<resultMap type="ZdyHotelHomestayCustomer" id="ZdyHotelHomestayCustomerResult">
|
|
<result property="id" column="id"/>
|
|
<result property="hotelHomestayId" column="hotel_homestay_id"/>
|
|
<result property="mobile" column="mobile"/>
|
|
<result property="idCard" column="id_card"/>
|
|
<result property="idCardType" column="id_card_type"/>
|
|
<result property="name" column="name"/>
|
|
<result property="sex" column="sex"/>
|
|
<result property="birthday" column="birthday"/>
|
|
<result property="source" column="source"/>
|
|
<result property="totalAmountSpent" column="total_amount_spent"/>
|
|
<result property="totalOrderCount" column="total_order_count"/>
|
|
<result property="lastOrderTime" column="last_order_time"/>
|
|
<result property="blacklisted" column="is_blacklisted"/>
|
|
<result property="remark" column="remark"/>
|
|
<result property="createTime" column="create_time"/>
|
|
<result property="createBy" column="create_by"/>
|
|
<result property="createZdyUserId" column="create_zdy_user_id"/>
|
|
<result property="updateTime" column="update_time"/>
|
|
<result property="updateBy" column="update_by"/>
|
|
<result property="deleted" column="is_deleted"/>
|
|
</resultMap>
|
|
|
|
<sql id="selectZdyHotelHomestayCustomerVo">
|
|
select id,
|
|
hotel_homestay_id,
|
|
mobile,
|
|
id_card,
|
|
id_card_type,
|
|
name,
|
|
sex,
|
|
birthday,
|
|
source,
|
|
total_amount_spent,
|
|
total_order_count,
|
|
last_order_time,
|
|
is_blacklisted,
|
|
remark,
|
|
create_time,
|
|
create_by,
|
|
create_zdy_user_id,
|
|
update_time,
|
|
update_by,
|
|
is_deleted
|
|
from zdy_hotel_homestay_customer
|
|
</sql>
|
|
|
|
<select id="selectZdyHotelHomestayCustomerList" parameterType="ZdyHotelHomestayCustomer"
|
|
resultMap="ZdyHotelHomestayCustomerResult">
|
|
select zhhc.id,
|
|
zhhc.hotel_homestay_id,
|
|
zhhc.mobile,
|
|
zhhc.id_card,
|
|
zhhc.id_card_type,
|
|
zhhc.name,
|
|
zhhc.sex,
|
|
zhhc.birthday,
|
|
zhhc.source,
|
|
zhhc.total_amount_spent,
|
|
zhhc.total_order_count,
|
|
zhhc.last_order_time,
|
|
zhhc.is_blacklisted,
|
|
zhhc.remark,
|
|
zhhc.create_time,
|
|
zhhc.create_by,
|
|
zhhc.create_zdy_user_id,
|
|
zhhc.update_time,
|
|
zhhc.update_by,
|
|
zhhc.is_deleted
|
|
from zdy_hotel_homestay_customer zhhc
|
|
left join zdy_hotel_homestay zhh on zhh.id = zhhc.hotel_homestay_id
|
|
left join zdy_store_base_info sbi on sbi.id = zhh.store_id
|
|
<where>
|
|
<if test="hotelHomestayId != null ">
|
|
and zhhc.hotel_homestay_id = #{hotelHomestayId}
|
|
</if>
|
|
<if test="deptId != null ">
|
|
and sbi.dept_id = #{deptId}
|
|
</if>
|
|
<if test="mobile != null and mobile != ''">
|
|
and zhhc.mobile = #{mobile}
|
|
</if>
|
|
<if test="name != null and name != ''">
|
|
and zhhc.name like concat('%', #{name}, '%')
|
|
</if>
|
|
<if test="sex != null and sex != ''">
|
|
and zhhc.sex = #{sex}
|
|
</if>
|
|
<if test="birthday != null ">
|
|
and zhhc.birthday = #{birthday}
|
|
</if>
|
|
<if test="source != null and source != ''">
|
|
and zhhc.source = #{source}
|
|
</if>
|
|
<if test="totalAmountSpent != null ">
|
|
and zhhc.total_amount_spent = #{totalAmountSpent}
|
|
</if>
|
|
<if test="totalOrderCount != null ">
|
|
and zhhc.total_order_count = #{totalOrderCount}
|
|
</if>
|
|
<if test="lastOrderTime != null ">
|
|
and zhhc.last_order_time = #{lastOrderTime}
|
|
</if>
|
|
<if test="blacklisted != null and blacklisted != ''">
|
|
and zhhc.is_blacklisted = #{blacklisted}
|
|
</if>
|
|
<choose>
|
|
<when test="deleted != null ">
|
|
and zhhc.is_deleted = #{deleted}
|
|
</when>
|
|
<otherwise>
|
|
and zhhc.is_deleted = 0
|
|
</otherwise>
|
|
</choose>
|
|
<if test="tagIds != null and tagIds.size > 0">
|
|
and zhhc.id in (
|
|
select DISTINCT customer_id from zdy_hotel_homestay_customer_tag_rel where tag_id in
|
|
<foreach collection="tagIds" item="tagId" open="(" separator="," close=")">
|
|
#{tagId}
|
|
</foreach>
|
|
)
|
|
</if>
|
|
<if test="queryLastOrderTimeStart != null ">
|
|
and zhhc.last_order_time >= #{queryLastOrderTimeStart}
|
|
</if>
|
|
<if test="queryLastOrderTimeEnd != null ">
|
|
and zhhc.last_order_time <= #{queryLastOrderTimeEnd}
|
|
</if>
|
|
</where>
|
|
order by zhhc.id desc
|
|
</select>
|
|
|
|
<select id="selectZdyHotelHomestayCustomerById" parameterType="Long"
|
|
resultMap="ZdyHotelHomestayCustomerResult">
|
|
<include refid="selectZdyHotelHomestayCustomerVo"/>
|
|
where id = #{id}
|
|
</select>
|
|
|
|
<insert id="insertZdyHotelHomestayCustomer" parameterType="ZdyHotelHomestayCustomer" useGeneratedKeys="true"
|
|
keyProperty="id">
|
|
insert into zdy_hotel_homestay_customer
|
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
|
<if test="hotelHomestayId != null">hotel_homestay_id,
|
|
</if>
|
|
<if test="mobile != null and mobile != ''">mobile,
|
|
</if>
|
|
<if test="idCard != null and idCard != ''">id_card,
|
|
</if>
|
|
<if test="idCardType != null and idCardType != ''">id_card_type,
|
|
</if>
|
|
<if test="name != null">name,
|
|
</if>
|
|
<if test="sex != null">sex,
|
|
</if>
|
|
<if test="birthday != null">birthday,
|
|
</if>
|
|
<if test="source != null">source,
|
|
</if>
|
|
<if test="totalAmountSpent != null">total_amount_spent,
|
|
</if>
|
|
<if test="totalOrderCount != null">total_order_count,
|
|
</if>
|
|
<if test="lastOrderTime != null">last_order_time,
|
|
</if>
|
|
<if test="blacklisted != null and blacklisted != ''">is_blacklisted,
|
|
</if>
|
|
<if test="remark != null">remark,
|
|
</if>
|
|
<if test="createTime != null">create_time,
|
|
</if>
|
|
<if test="createBy != null">create_by,
|
|
</if>
|
|
<if test="createZdyUserId != null">create_zdy_user_id,
|
|
</if>
|
|
<if test="updateTime != null">update_time,
|
|
</if>
|
|
<if test="updateBy != null">update_by,
|
|
</if>
|
|
<if test="deleted != null">is_deleted,
|
|
</if>
|
|
</trim>
|
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
<if test="hotelHomestayId != null">#{hotelHomestayId},
|
|
</if>
|
|
<if test="mobile != null and mobile != ''">#{mobile},
|
|
</if>
|
|
<if test="idCard != null and idCard != ''">#{idCard},
|
|
</if>
|
|
<if test="idCardType != null and idCardType != ''">#{idCardType},
|
|
</if>
|
|
<if test="name != null">#{name},
|
|
</if>
|
|
<if test="sex != null">#{sex},
|
|
</if>
|
|
<if test="birthday != null">#{birthday},
|
|
</if>
|
|
<if test="source != null">#{source},
|
|
</if>
|
|
<if test="totalAmountSpent != null">#{totalAmountSpent},
|
|
</if>
|
|
<if test="totalOrderCount != null">#{totalOrderCount},
|
|
</if>
|
|
<if test="lastOrderTime != null">#{lastOrderTime},
|
|
</if>
|
|
<if test="blacklisted != null and blacklisted != ''">#{blacklisted},
|
|
</if>
|
|
<if test="remark != null">#{remark},
|
|
</if>
|
|
<if test="createTime != null">#{createTime},
|
|
</if>
|
|
<if test="createBy != null">#{createBy},
|
|
</if>
|
|
<if test="createZdyUserId != null">#{createZdyUserId},
|
|
</if>
|
|
<if test="updateTime != null">#{updateTime},
|
|
</if>
|
|
<if test="updateBy != null">#{updateBy},
|
|
</if>
|
|
<if test="deleted != null">#{deleted},
|
|
</if>
|
|
</trim>
|
|
</insert>
|
|
|
|
<update id="updateZdyHotelHomestayCustomer" parameterType="ZdyHotelHomestayCustomer">
|
|
update zdy_hotel_homestay_customer
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="hotelHomestayId != null">hotel_homestay_id =
|
|
#{hotelHomestayId},
|
|
</if>
|
|
<if test="mobile != null and mobile != ''">mobile =
|
|
#{mobile},
|
|
</if>
|
|
<if test="idCard != null and idCard != ''">id_card =
|
|
#{idCard},
|
|
</if>
|
|
<if test="idCardType != null and idCardType != ''">id_card_type =
|
|
#{idCardType},
|
|
</if>
|
|
<if test="name != null">name =
|
|
#{name},
|
|
</if>
|
|
<if test="sex != null">sex =
|
|
#{sex},
|
|
</if>
|
|
<if test="birthday != null">birthday =
|
|
#{birthday},
|
|
</if>
|
|
<if test="source != null">source =
|
|
#{source},
|
|
</if>
|
|
<if test="totalAmountSpent != null">total_amount_spent =
|
|
#{totalAmountSpent},
|
|
</if>
|
|
<if test="totalOrderCount != null">total_order_count =
|
|
#{totalOrderCount},
|
|
</if>
|
|
<if test="lastOrderTime != null">last_order_time =
|
|
#{lastOrderTime},
|
|
</if>
|
|
<if test="blacklisted != null and blacklisted != ''">is_blacklisted =
|
|
#{blacklisted},
|
|
</if>
|
|
<if test="remark != null">remark =
|
|
#{remark},
|
|
</if>
|
|
<if test="createTime != null">create_time =
|
|
#{createTime},
|
|
</if>
|
|
<if test="createBy != null">create_by =
|
|
#{createBy},
|
|
</if>
|
|
<if test="createZdyUserId != null">create_zdy_user_id =
|
|
#{createZdyUserId},
|
|
</if>
|
|
<if test="updateTime != null">update_time =
|
|
#{updateTime},
|
|
</if>
|
|
<if test="updateBy != null">update_by =
|
|
#{updateBy},
|
|
</if>
|
|
<if test="deleted != null">is_deleted =
|
|
#{deleted},
|
|
</if>
|
|
</trim>
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<update id="deleteZdyHotelHomestayCustomerById" parameterType="Long">
|
|
update zdy_hotel_homestay_customer
|
|
set is_deleted = 1
|
|
where id = #{id}
|
|
</update>
|
|
|
|
<update id="deleteZdyHotelHomestayCustomerByIds" parameterType="String">
|
|
update zdy_hotel_homestay_customer set is_deleted = 1 where id in
|
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</update>
|
|
|
|
<select id="existsByMobile" resultType="java.lang.Integer">
|
|
select exists(select 1
|
|
from zdy_hotel_homestay_customer
|
|
where is_deleted = 0
|
|
and mobile = #{mobile}
|
|
and hotel_homestay_id = #{hotelHomestayId}
|
|
<if test="id != null">
|
|
and id != #{id}
|
|
</if>
|
|
)
|
|
</select>
|
|
|
|
<update id="updateByMobile" parameterType="ZdyHotelHomestayCustomer">
|
|
update zdy_hotel_homestay_customer
|
|
<trim prefix="SET" suffixOverrides=",">
|
|
<if test="name != null">name =
|
|
#{name},
|
|
</if>
|
|
<if test="sex != null">sex =
|
|
#{sex},
|
|
</if>
|
|
<if test="birthday != null">birthday =
|
|
#{birthday},
|
|
</if>
|
|
<if test="source != null">source =
|
|
#{source},
|
|
</if>
|
|
<if test="totalAmountSpent != null">total_amount_spent =
|
|
#{totalAmountSpent},
|
|
</if>
|
|
<if test="totalOrderCount != null">total_order_count =
|
|
#{totalOrderCount},
|
|
</if>
|
|
<if test="lastOrderTime != null">last_order_time =
|
|
#{lastOrderTime},
|
|
</if>
|
|
<if test="blacklisted != null and blacklisted != ''">is_blacklisted =
|
|
#{blacklisted},
|
|
</if>
|
|
<if test="remark != null">remark =
|
|
#{remark},
|
|
</if>
|
|
<if test="createTime != null">create_time =
|
|
#{createTime},
|
|
</if>
|
|
<if test="createBy != null">create_by =
|
|
#{createBy},
|
|
</if>
|
|
<if test="createZdyUserId != null">create_zdy_user_id =
|
|
#{createZdyUserId},
|
|
</if>
|
|
<if test="updateTime != null">update_time =
|
|
#{updateTime},
|
|
</if>
|
|
<if test="updateBy != null">update_by =
|
|
#{updateBy},
|
|
</if>
|
|
<if test="deleted != null">is_deleted =
|
|
#{deleted},
|
|
</if>
|
|
</trim>
|
|
where
|
|
mobile = #{mobile}
|
|
and hotel_homestay_id = #{hotelHomestayId}
|
|
and is_deleted = 0
|
|
</update>
|
|
|
|
<select id="getByIdCard" parameterType="String" resultMap="ZdyHotelHomestayCustomerResult">
|
|
<include refid="selectZdyHotelHomestayCustomerVo"/>
|
|
where id_card = #{idCard}
|
|
</select>
|
|
|
|
<select id="listByIdCardsAndIdCardTypes" resultMap="ZdyHotelHomestayCustomerResult">
|
|
select id,
|
|
id_card,
|
|
id_card_type,
|
|
is_blacklisted
|
|
from zdy_hotel_homestay_customer
|
|
where hotel_homestay_id = #{hotelHomestayId}
|
|
and is_deleted = 0
|
|
and (
|
|
<foreach item="customerQuery" collection="customerQueryList" open="(" separator="or" close=")">
|
|
(id_card_type = #{customerQuery.idCardType} AND id_card = #{customerQuery.idCard})
|
|
</foreach>
|
|
)
|
|
</select>
|
|
|
|
<update id="updateOrderInfoByIds">
|
|
update zdy_hotel_homestay_customer
|
|
set
|
|
total_order_count = total_order_count + 1,
|
|
last_order_time = #{zdyHotelHomestayCustomer.lastOrderTime}
|
|
where id in
|
|
<foreach item="id" collection="ids" open="(" separator="," close=")">
|
|
#{id}
|
|
</foreach>
|
|
</update>
|
|
</mapper> |