zhwl/zhwl-business/zhwl-hotel-homestay-order/target/classes/mapper/hotelHomestay/ZdyHotelHomestayOrderMapper.xml
2025-07-01 17:54:58 +08:00

1118 lines
46 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.order.mapper.ZdyHotelHomestayOrderMapper">
<resultMap type="ZdyHotelHomestayOrder" id="ZdyHotelHomestayOrderResult">
<result property="id" column="id"/>
<result property="hotelHomestayId" column="hotel_homestay_id"/>
<result property="hotelHomestayName" column="hotel_homestay_name"/>
<result property="orderCode" column="order_code"/>
<result property="orderSource" column="order_source"/>
<result property="contactMobile" column="contact_mobile"/>
<result property="contactNames" column="contact_names"/>
<result property="stayType" column="stay_type"/>
<result property="inDateTime" column="in_datetime"/>
<result property="outDateTime" column="out_datetime"/>
<result property="estimatedArrivalTime" column="estimated_arrival_time"/>
<result property="estimatedArrivalDateTime" column="estimated_arrival_date_time"/>
<result property="stayStatus" column="stay_status"/>
<result property="roomQuantity" column="room_quantity"/>
<result property="roomClassifyId" column="room_classify_id"/>
<result property="roomClassifyName" column="room_classify_name"/>
<result property="roomPrice" column="room_price"/>
<result property="roomCharge" column="room_charge"/>
<result property="roomConsumption" column="room_consumption"/>
<result property="penaltyFee" column="penalty_fee"/>
<result property="refund" column="refund"/>
<result property="totalAmount" column="total_amount"/>
<result property="balanceStatus" column="balance_status"/>
<result property="blockBookingStatus" column="block_booking_status"/>
<result property="paymentType" column="payment_type"/>
<result property="paymentMethod" column="payment_method"/>
<result property="paymentScene" column="payment_scene"/>
<result property="paymentTime" column="payment_time"/>
<result property="orderPrepayId" column="order_prepay_id"/>
<result property="tradeSession" column="trade_session"/>
<result property="refundStatus" column="refund_status"/>
<result property="refundTime" column="refund_time"/>
<result property="cancelTime" column="cancel_time"/>
<result property="createTime" column="create_time"/>
<result property="createZdyUserId" column="create_zdy_user_id"/>
<result property="createSysUserId" column="create_sys_user_id"/>
<result property="updateTime" column="update_time"/>
<result property="updaterId" column="updater_id"/>
<result property="isDeleted" column="is_deleted"/>
<result property="remark" column="remark"/>
<result property="processedBy" column="processed_by"/>
<result property="processedByName" column="processed_by_user_name"/>
<result property="processingTime" column="processing_time"/>
<result property="payAmount" column="pay_amount"/>
<result property="couponAmount" column="coupon_amount"/>
<result property="couponId" column="coupon_id"/>
<result property="actualCheckInTime" column="actual_check_in_time"/>
<result property="actualCheckOutTime" column="actual_check_out_time"/>
<association property="zdyHotelHomestayVO" javaType="ZdyHotelHomestayVO" resultMap="ZdyHotelHomestayVOResult"/>
</resultMap>
<resultMap type="ZdyHotelHomestayOrder" id="ZdyHotelHomestayOrderAndStayInfoResult">
<result property="id" column="id"/>
<result property="hotelHomestayId" column="hotel_homestay_id"/>
<result property="hotelHomestayName" column="hotel_homestay_name"/>
<result property="orderCode" column="order_code"/>
<result property="orderSource" column="order_source"/>
<result property="contactMobile" column="contact_mobile"/>
<result property="contactNames" column="contact_names"/>
<result property="stayType" column="stay_type"/>
<result property="inDateTime" column="in_datetime"/>
<result property="outDateTime" column="out_datetime"/>
<result property="estimatedArrivalTime" column="estimated_arrival_time"/>
<result property="estimatedArrivalDateTime" column="estimated_arrival_date_time"/>
<result property="stayStatus" column="stay_status"/>
<result property="roomQuantity" column="room_quantity"/>
<result property="roomClassifyId" column="room_classify_id"/>
<result property="roomClassifyName" column="room_classify_name"/>
<result property="roomPrice" column="room_price"/>
<result property="roomCharge" column="room_charge"/>
<result property="roomConsumption" column="room_consumption"/>
<result property="penaltyFee" column="penalty_fee"/>
<result property="refund" column="refund"/>
<result property="totalAmount" column="total_amount"/>
<result property="balanceStatus" column="balance_status"/>
<result property="blockBookingStatus" column="block_booking_status"/>
<result property="paymentType" column="payment_type"/>
<result property="paymentMethod" column="payment_method"/>
<result property="paymentScene" column="payment_scene"/>
<result property="paymentTime" column="payment_time"/>
<result property="orderPrepayId" column="order_prepay_id"/>
<result property="tradeSession" column="trade_session"/>
<result property="refundStatus" column="refund_status"/>
<result property="refundTime" column="refund_time"/>
<result property="cancelTime" column="cancel_time"/>
<result property="createTime" column="create_time"/>
<result property="createZdyUserId" column="create_zdy_user_id"/>
<result property="createSysUserId" column="create_sys_user_id"/>
<result property="updateTime" column="update_time"/>
<result property="updaterId" column="updater_id"/>
<result property="isDeleted" column="is_deleted"/>
<result property="remark" column="remark"/>
<result property="processedBy" column="processed_by"/>
<result property="processingTime" column="processing_time"/>
<result property="roomStatusId" column="room_status_id"/>
<result property="payAmount" column="pay_amount"/>
<result property="couponAmount" column="coupon_amount"/>
<result property="couponId" column="coupon_id"/>
<result property="actualCheckInTime" column="actual_check_in_time"/>
<result property="actualCheckOutTime" column="actual_check_out_time"/>
<collection property="stayInfos" javaType="java.util.List" resultMap="StayInfoResult"/>
</resultMap>
<resultMap type="ZdyHotelHomestayOrderStayInfo" id="StayInfoResult">
<result property="id" column="stay_info_id"/>
<result property="orderId" column="stay_info_order_id"/>
<result property="orderRoomDetailId" column="stay_info_order_room_detail_id"/>
<result property="customerId" column="stay_info_customer_id"/>
<result property="mobile" column="stay_info_mobile"/>
<result property="idCard" column="stay_info_id_card"/>
<result property="idCardType" column="stay_info_id_card_type"/>
<result property="name" column="stay_info_name"/>
<result property="processedBy" column="stay_info_processed_by"/>
<result property="processingTime" column="stay_info_processing_time"/>
<result property="idCardFrontPhoto" column="stay_info_id_card_front_photo"/>
<result property="idCardBackPhoto" column="stay_info_id_card_back_photo"/>
<result property="facePhoto" column="stay_info_face_photo"/>
</resultMap>
<resultMap type="ZdyHotelHomestayVO" id="ZdyHotelHomestayVOResult">
<result property="id" column="hotel_homestay_id"/>
<result property="name" column="hotel_homestay_name"/>
<result property="longitude" column="hotel_homestay_longitude"/>
<result property="latitude" column="hotel_homestay_latitude"/>
<result property="coverImage" column="hotel_homestay_cover_image"/>
<result property="phone" column="hotel_homestay_phonenumber"/>
</resultMap>
<sql id="selectZdyHotelHomestayOrderVo">
select zhho.id,
zhho.hotel_homestay_id,
zhho.order_code,
zhho.order_source,
zhho.contact_mobile,
zhho.contact_names,
zhho.stay_type,
zhho.in_datetime,
zhho.out_datetime,
zhho.estimated_arrival_time,
zhho.estimated_arrival_date_time,
zhho.stay_status,
zhho.room_quantity,
zhho.room_classify_id,
zhho.room_price,
zhho.room_charge,
zhho.room_consumption,
zhho.penalty_fee,
zhho.refund,
zhho.total_amount,
zhho.balance_status,
zhho.block_booking_status,
zhho.payment_type,
zhho.payment_method,
zhho.payment_scene,
zhho.payment_time,
zhho.order_prepay_id,
zhho.trade_session,
zhho.refund_status,
zhho.refund_time,
zhho.cancel_time,
zhho.create_time,
zhho.create_zdy_user_id,
zhho.create_sys_user_id,
zhho.update_time,
zhho.updater_id,
zhho.is_deleted,
zhho.processed_by,
zhho.processing_time,
zhho.remark,
zhho.pay_amount,
zhho.coupon_amount,
zhho.coupon_id,
zhho.actual_check_in_time,
zhho.actual_check_out_time,
sbi.name as hotel_homestay_name,
sbi.images as hotel_homestay_cover_image,
sbi.longitude as hotel_homestay_longitude,
sbi.latitude as hotel_homestay_latitude,
sbi.contact_phone as hotel_homestay_phonenumber,
processed_by_user.nick_name as processed_by_user_name
from zdy_hotel_homestay_order zhho
left join zdy_hotel_homestay zhh on zhho.hotel_homestay_id = zhh.id
left join zdy_store_base_info sbi on sbi.id = zhh.store_id
left join sys_user processed_by_user on zhho.processed_by = processed_by_user.user_id
</sql>
<select id="selectZdyHotelHomestayOrderList" parameterType="ZdyHotelHomestayOrder"
resultMap="ZdyHotelHomestayOrderResult">
<include refid="selectZdyHotelHomestayOrderVo"/>
<where>
<if test="hotelHomestayId != null ">
and zhho.hotel_homestay_id = #{hotelHomestayId}
</if>
<if test="deptId != null ">
and sbi.dept_id = #{deptId}
</if>
<if test="orderCode != null and orderCode != ''">
and zhho.order_code = #{orderCode}
</if>
<if test="orderSource != null and orderSource != ''">
and zhho.order_source = #{orderSource}
</if>
<if test="contactMobile != null and contactMobile != ''">
and zhho.contact_mobile = #{contactMobile}
</if>
<if test="contactNames != null and contactNames != ''">
and zhho.contact_names like concat('%',#{contactNames},'%')
</if>
<if test="stayType != null">
and zhho.stay_type = #{stayType}
</if>
<if test="inDateTime != null ">
and zhho.in_datetime = #{inDateTime}
</if>
<if test="outDateTime != null ">
and zhho.out_datetime = #{outDateTime}
</if>
<if test="stayStatus != null">
and zhho.stay_status = #{stayStatus.name}
</if>
<if test="roomQuantity != null ">
and zhho.room_quantity = #{roomQuantity}
</if>
<if test="roomClassifyId != null ">
and zhho.room_classify_id = #{roomClassifyId}
</if>
<if test="roomPrice != null ">
and zhho.room_price = #{roomPrice}
</if>
<if test="roomCharge != null ">
and zhho.room_charge = #{roomCharge}
</if>
<if test="roomConsumption != null ">
and zhho.room_consumption = #{roomConsumption}
</if>
<if test="penaltyFee != null ">
and zhho.penalty_fee = #{penaltyFee}
</if>
<if test="refund != null ">
and zhho.refund = #{refund}
</if>
<if test="totalAmount != null ">
and zhho.total_amount = #{totalAmount}
</if>
<if test="balanceStatus != null">
and zhho.balance_status = #{balanceStatus}
</if>
<if test="blockBookingStatus != null and blockBookingStatus != ''">
and zhho.block_booking_status = #{blockBookingStatus}
</if>
<if test="paymentType != null and paymentType != ''">
and zhho.payment_type = #{paymentType}
</if>
<if test="paymentMethod != null and paymentMethod != ''">
and zhho.payment_method = #{paymentMethod}
</if>
<if test="paymentScene != null and paymentScene != ''">
and zhho.payment_scene = #{paymentScene}
</if>
<if test="paymentTime != null ">
and zhho.payment_time = #{paymentTime}
</if>
<if test="orderPrepayId != null and orderPrepayId != ''">
and zhho.order_prepay_id = #{orderPrepayId}
</if>
<if test="tradeSession != null and tradeSession != ''">
and zhho.trade_session = #{tradeSession}
</if>
<if test="refundStatus != null and refundStatus != ''">
and zhho.refund_status = #{refundStatus}
</if>
<if test="refundTime != null ">
and zhho.refund_time = #{refundTime}
</if>
<if test="createZdyUserId != null ">
and zhho.create_zdy_user_id = #{createZdyUserId}
</if>
<if test="createSysUserId != null ">
and zhho.create_sys_user_id = #{createSysUserId}
</if>
<if test="updaterId != null ">
and zhho.updater_id = #{updaterId}
</if>
<choose>
<when test="isDeleted != null ">
and zhho.is_deleted = #{isDeleted}
</when>
<otherwise>
and zhho.is_deleted = 0
</otherwise>
</choose>
<if test="queryRefundAll != null and queryRefundAll">
and zhho.refund_status is not null
</if>
</where>
order by zhho.id desc
</select>
<select id="selectZdyHotelHomestayOrderById" parameterType="Long"
resultMap="ZdyHotelHomestayOrderResult">
<include refid="selectZdyHotelHomestayOrderVo"/>
where zhho.id = #{id}
</select>
<insert id="insertZdyHotelHomestayOrder" parameterType="ZdyHotelHomestayOrder" useGeneratedKeys="true"
keyProperty="id">
insert into zdy_hotel_homestay_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="hotelHomestayId != null">hotel_homestay_id,
</if>
<if test="orderCode != null and orderCode != ''">order_code,
</if>
<if test="orderSource != null">order_source,
</if>
<if test="contactMobile != null">contact_mobile,
</if>
<if test="contactNames != null">contact_names,
</if>
<if test="stayType != null">stay_type,
</if>
<if test="inDateTime != null">in_datetime,
</if>
<if test="outDateTime != null">out_datetime,
</if>
<if test="estimatedArrivalTime != null">estimated_arrival_time,
</if>
<if test="estimatedArrivalDateTime != null">estimated_arrival_date_time,
</if>
<if test="stayStatus != null">stay_status,
</if>
<if test="roomQuantity != null">room_quantity,
</if>
<if test="roomClassifyId != null">room_classify_id,
</if>
<if test="roomPrice != null">room_price,
</if>
<if test="roomCharge != null">room_charge,
</if>
<if test="roomConsumption != null">room_consumption,
</if>
<if test="penaltyFee != null">penalty_fee,
</if>
<if test="refund != null">refund,
</if>
<if test="totalAmount != null">total_amount,
</if>
<if test="balanceStatus != null">balance_status,
</if>
<if test="blockBookingStatus != null">block_booking_status,
</if>
<if test="paymentType != null">payment_type,
</if>
<if test="paymentMethod != null">payment_method,
</if>
<if test="paymentScene != null">payment_scene,
</if>
<if test="paymentTime != null">payment_time,
</if>
<if test="orderPrepayId != null">order_prepay_id,
</if>
<if test="tradeSession != null">trade_session,
</if>
<if test="refundStatus != null">refund_status,
</if>
<if test="refundTime != null">refund_time,
</if>
<if test="cancelTime != null">cancel_time,
</if>
<if test="createTime != null">create_time,
</if>
<if test="createZdyUserId != null">create_zdy_user_id,
</if>
<if test="createSysUserId != null">create_sys_user_id,
</if>
<if test="updateTime != null">update_time,
</if>
<if test="updaterId != null">updater_id,
</if>
<if test="isDeleted != null">is_deleted,
</if>
<if test="remark != null">remark,
</if>
<if test="processedBy != null">processed_by,
</if>
<if test="processingTime != null">processing_time,
</if>
<if test="payAmount!= null">pay_amount,
</if>
<if test="couponAmount!= null">coupon_amount,
</if>
<if test="couponId!= null">coupon_id,
</if>
<if test="actualCheckInTime!= null">actual_check_in_time,
</if>
<if test="actualCheckOutTime!= null">actual_check_out_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="hotelHomestayId != null">#{hotelHomestayId},
</if>
<if test="orderCode != null and orderCode != ''">#{orderCode},
</if>
<if test="orderSource != null">#{orderSource},
</if>
<if test="contactMobile != null">#{contactMobile},
</if>
<if test="contactNames != null">#{contactNames},
</if>
<if test="stayType != null">#{stayType},
</if>
<if test="inDateTime != null">#{inDateTime},
</if>
<if test="outDateTime != null">#{outDateTime},
</if>
<if test="estimatedArrivalTime != null">#{estimatedArrivalTime},
</if>
<if test="estimatedArrivalDateTime != null">#{estimatedArrivalDateTime},
</if>
<if test="stayStatus != null">#{stayStatus},
</if>
<if test="roomQuantity != null">#{roomQuantity},
</if>
<if test="roomClassifyId != null">#{roomClassifyId},
</if>
<if test="roomPrice != null">#{roomPrice},
</if>
<if test="roomCharge != null">#{roomCharge},
</if>
<if test="roomConsumption != null">#{roomConsumption},
</if>
<if test="penaltyFee != null">#{penaltyFee},
</if>
<if test="refund != null">#{refund},
</if>
<if test="totalAmount != null">#{totalAmount},
</if>
<if test="balanceStatus != null">#{balanceStatus},
</if>
<if test="blockBookingStatus != null">#{blockBookingStatus},
</if>
<if test="paymentType != null">#{paymentType},
</if>
<if test="paymentMethod != null">#{paymentMethod},
</if>
<if test="paymentScene != null">#{paymentScene},
</if>
<if test="paymentTime != null">#{paymentTime},
</if>
<if test="orderPrepayId != null">#{orderPrepayId},
</if>
<if test="tradeSession != null">#{tradeSession},
</if>
<if test="refundStatus != null">#{refundStatus},
</if>
<if test="refundTime != null">#{refundTime},
</if>
<if test="cancelTime != null">#{cancelTime},
</if>
<if test="createTime != null">#{createTime},
</if>
<if test="createZdyUserId != null">#{createZdyUserId},
</if>
<if test="createSysUserId != null">#{createSysUserId},
</if>
<if test="updateTime != null">#{updateTime},
</if>
<if test="updaterId != null">#{updaterId},
</if>
<if test="isDeleted != null">#{isDeleted},
</if>
<if test="remark != null">#{remark},
</if>
<if test="processedBy != null">#{processedBy},
</if>
<if test="processingTime != null">#{processingTime},
</if>
<if test="payAmount!= null">#{payAmount},
</if>
<if test="couponAmount!= null">#{couponAmount},
</if>
<if test="couponId!= null">#{couponId},
</if>
<if test="actualCheckInTime!= null">#{actualCheckInTime},
</if>
<if test="actualCheckOutTime!= null">#{actualCheckOutTime},
</if>
</trim>
</insert>
<update id="updateZdyHotelHomestayOrder" parameterType="ZdyHotelHomestayOrder">
update zdy_hotel_homestay_order
<trim prefix="SET" suffixOverrides=",">
<if test="hotelHomestayId != null">hotel_homestay_id =
#{hotelHomestayId},
</if>
<if test="orderCode != null and orderCode != ''">order_code =
#{orderCode},
</if>
<if test="orderSource != null">order_source =
#{orderSource},
</if>
<if test="contactMobile != null">contact_mobile =
#{contactMobile},
</if>
<if test="contactNames != null">contact_names =
#{contactNames},
</if>
<if test="stayType != null">stay_type =
#{stayType},
</if>
<if test="inDateTime != null">in_datetime =
#{inDateTime},
</if>
<if test="outDateTime != null">out_datetime =
#{outDateTime},
</if>
<if test="estimatedArrivalTime != null">estimated_arrival_time =
#{estimatedArrivalTime},
</if>
<if test="estimatedArrivalDateTime != null">estimated_arrival_date_time =
#{estimatedArrivalDateTime},
</if>
<if test="stayStatus != null">stay_status =
#{stayStatus},
</if>
<if test="roomQuantity != null">room_quantity =
#{roomQuantity},
</if>
<if test="roomClassifyId != null">room_classify_id =
#{roomClassifyId},
</if>
<if test="roomPrice != null">room_price =
#{roomPrice},
</if>
<if test="roomCharge != null">room_charge =
#{roomCharge},
</if>
<if test="roomConsumption != null">room_consumption =
#{roomConsumption},
</if>
<if test="penaltyFee != null">penalty_fee =
#{penaltyFee},
</if>
<if test="refund != null">refund =
#{refund},
</if>
<if test="totalAmount != null">total_amount =
#{totalAmount},
</if>
<if test="balanceStatus != null">balance_status =
#{balanceStatus},
</if>
<if test="blockBookingStatus != null">block_booking_status =
#{blockBookingStatus},
</if>
<if test="paymentType != null">payment_type =
#{paymentType},
</if>
<if test="paymentMethod != null">payment_method =
#{paymentMethod},
</if>
<if test="paymentScene != null">payment_scene =
#{paymentScene},
</if>
<if test="paymentTime != null">payment_time =
#{paymentTime},
</if>
<if test="orderPrepayId != null">order_prepay_id =
#{orderPrepayId},
</if>
<if test="tradeSession != null">trade_session =
#{tradeSession},
</if>
<if test="refundStatus != null">refund_status =
#{refundStatus},
</if>
<if test="refundTime != null">refund_time =
#{refundTime},
</if>
<if test="cancelTime != null">cancel_time =
#{cancelTime},
</if>
<if test="createTime != null">create_time =
#{createTime},
</if>
<if test="createZdyUserId != null">create_zdy_user_id =
#{createZdyUserId},
</if>
<if test="createSysUserId != null">create_sys_user_id =
#{createSysUserId},
</if>
<if test="updateTime != null">update_time =
#{updateTime},
</if>
<if test="updaterId != null">updater_id =
#{updaterId},
</if>
<if test="isDeleted != null">is_deleted =
#{isDeleted},
</if>
<if test="remark != null">remark =
#{remark},
</if>
<if test="processedBy != null">processed_by =
#{processedBy},
</if>
<if test="processingTime != null">processing_time =
#{processingTime},
</if>
<if test="payAmount!= null">pay_amount =
#{payAmount},
</if>
<if test="couponAmount!= null">coupon_amount =
#{couponAmount},
</if>
<if test="couponId!= null">coupon_id =
#{couponId},
</if>
<if test="actualCheckInTime!= null">
`actual_check_in_time` = CASE WHEN ISNULL(actual_check_in_time) THEN #{actualCheckInTime} ELSE
`actual_check_in_time` END,
</if>
<if test="actualCheckOutTime!= null">actual_check_out_time =
#{actualCheckOutTime},
</if>
</trim>
where id = #{id}
</update>
<update id="deleteZdyHotelHomestayOrderByIds" parameterType="String">
update zdy_hotel_homestay_order set is_deleted = 1 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</update>
<select id="existsOrdersWithIdsAndPaymentTypes" resultType="Integer">
SELECT EXISTS
(SELECT 1
FROM zdy_hotel_homestay_order
WHERE id IN
<foreach item="id" collection="ids" open="(" separator="," close=")">
#{id}
</foreach>
AND payment_type IN
<foreach item="paymentType" collection="paymentTypes" open="(" separator="," close=")">
#{paymentType}
</foreach>
)
</select>
<select id="getByOrderCode" parameterType="String" resultMap="ZdyHotelHomestayOrderResult">
<include refid="selectZdyHotelHomestayOrderVo"/>
where order_code = #{orderCode}
</select>
<update id="updateByOrderCode" parameterType="ZdyHotelHomestayOrder">
update zdy_hotel_homestay_order
<trim prefix="SET" suffixOverrides=",">
<if test="hotelHomestayId != null">hotel_homestay_id =
#{hotelHomestayId},
</if>
<if test="orderSource != null">order_source =
#{orderSource},
</if>
<if test="contactMobile != null">contact_mobile =
#{contactMobile},
</if>
<if test="contactNames != null">contact_names =
#{contactNames},
</if>
<if test="stayType != null">stay_type =
#{stayType},
</if>
<if test="inDateTime != null">in_datetime =
#{inDateTime},
</if>
<if test="outDateTime != null">out_datetime =
#{outDateTime},
</if>
<if test="estimatedArrivalTime != null">estimated_arrival_time =
#{estimatedArrivalTime},
</if>
<if test="estimatedArrivalDateTime != null">estimated_arrival_date_time =
#{estimatedArrivalDateTime},
</if>
<if test="stayStatus != null">stay_status =
#{stayStatus},
</if>
<if test="roomQuantity != null">room_quantity =
#{roomQuantity},
</if>
<if test="roomClassifyId != null">room_classify_id =
#{roomClassifyId},
</if>
<if test="roomPrice != null">room_price =
#{roomPrice},
</if>
<if test="roomCharge != null">room_charge =
#{roomCharge},
</if>
<if test="roomConsumption != null">room_consumption =
#{roomConsumption},
</if>
<if test="penaltyFee != null">penalty_fee =
#{penaltyFee},
</if>
<if test="refund != null">refund =
#{refund},
</if>
<if test="totalAmount != null">total_amount =
#{totalAmount},
</if>
<if test="balanceStatus != null">balance_status =
#{balanceStatus},
</if>
<if test="blockBookingStatus != null">block_booking_status =
#{blockBookingStatus},
</if>
<if test="paymentType != null">payment_type =
#{paymentType},
</if>
<if test="paymentMethod != null">payment_method =
#{paymentMethod},
</if>
<if test="paymentScene != null">payment_scene =
#{paymentScene},
</if>
<if test="paymentTime != null">payment_time =
#{paymentTime},
</if>
<if test="orderPrepayId != null">order_prepay_id =
#{orderPrepayId},
</if>
<if test="tradeSession != null">trade_session =
#{tradeSession},
</if>
<if test="refundStatus != null">refund_status =
#{refundStatus},
</if>
<if test="refundTime != null">refund_time =
#{refundTime},
</if>
<if test="cancelTime != null">cancel_time =
#{cancelTime},
</if>
<if test="createTime != null">create_time =
#{createTime},
</if>
<if test="createZdyUserId != null">create_zdy_user_id =
#{createZdyUserId},
</if>
<if test="createSysUserId != null">create_sys_user_id =
#{createSysUserId},
</if>
<if test="updateTime != null">update_time =
#{updateTime},
</if>
<if test="updaterId != null">updater_id =
#{updaterId},
</if>
<if test="isDeleted != null">is_deleted =
#{isDeleted},
</if>
<if test="remark != null">remark =
#{remark},
</if>
<if test="processedBy != null">processed_by =
#{processedBy},
</if>
<if test="processingTime != null">processing_time =
#{processingTime},
</if>
<if test="payAmount!= null">pay_amount =
#{payAmount},
</if>
<if test="couponAmount!= null">coupon_amount =
#{couponAmount},
</if>
<if test="couponId!= null">coupon_id =
#{couponId},
</if>
<if test="actualCheckInTime!= null">
`actual_check_in_time` = CASE WHEN ISNULL(actual_check_in_time) THEN #{actualCheckInTime} ELSE
`actual_check_in_time` END,
</if>
<if test="actualCheckOutTime!= null">actual_check_out_time =
#{actualCheckOutTime},
</if>
</trim>
where order_code = #{orderCode}
</update>
<select id="listRoomClassifyNamesByOrderIds" resultMap="ZdyHotelHomestayOrderResult">
SELECT
zhhord.order_id as id,
zhhrc.level2_name as room_classify_name
FROM
( SELECT order_id, room_classify_id FROM zdy_hotel_homestay_order_room_detail
where order_id in
<foreach item="id" collection="list" open="(" separator="," close=")">
#{id}
</foreach>
GROUP BY order_id, room_classify_id ) zhhord
LEFT JOIN zdy_hotel_homestay_room_classify zhhrc ON zhhrc.id = zhhord.room_classify_id
</select>
<select id="listByRoomStatusIds" resultMap="ZdyHotelHomestayOrderAndStayInfoResult">
SELECT zhho.id,
zhho.contact_names,
zhho.stay_status,
zhhord.room_status_id,
zhhc.name as stay_info_name
FROM zdy_hotel_homestay_order_room_detail zhhord
LEFT JOIN zdy_hotel_homestay_order_stay_info zhhosi ON zhhord.id = zhhosi.order_room_detail_id
LEFT JOIN zdy_hotel_homestay_order zhho ON zhho.id = zhhord.order_id
LEFT JOIN zdy_hotel_homestay_customer zhhc on zhhc.id = zhhosi.customer_id
WHERE zhhord.room_status_id in
<foreach item="id" collection="list" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="countOrderQuantityByHotelHomestayIds" resultType="HotelHomestayOrderQuantityBO">
select
hotel_homestay_id as hotelHomestayId,
count(*) as orderQuantity
from zdy_hotel_homestay_order
where
payment_type = #{paymentType}
and isnull(refund_time)
and hotel_homestay_id in
<foreach item="hotelHomestayId" collection="hotelHomestayIds" open="(" separator="," close=")">
#{hotelHomestayId}
</foreach>
GROUP BY hotel_homestay_id
</select>
<select id="getMostRecentOrderByRoomStatusId" parameterType="Long" resultMap="ZdyHotelHomestayOrderResult">
SELECT zhho.id,
zhho.hotel_homestay_id,
zhho.order_code,
zhho.order_source,
zhho.contact_mobile,
zhho.contact_names,
zhho.stay_type,
zhho.in_datetime,
zhho.out_datetime,
zhho.estimated_arrival_time,
zhho.estimated_arrival_date_time,
zhho.stay_status,
zhho.room_quantity,
zhho.room_classify_id,
zhho.room_price,
zhho.room_charge,
zhho.room_consumption,
zhho.penalty_fee,
zhho.refund,
zhho.total_amount,
zhho.balance_status,
zhho.block_booking_status,
zhho.payment_type,
zhho.payment_method,
zhho.payment_scene,
zhho.payment_time,
zhho.order_prepay_id,
zhho.trade_session,
zhho.refund_status,
zhho.refund_time,
zhho.cancel_time,
zhho.create_time,
zhho.create_zdy_user_id,
zhho.create_sys_user_id,
zhho.update_time,
zhho.updater_id,
zhho.is_deleted,
zhho.processed_by,
zhho.processing_time,
zhho.remark,
zhho.pay_amount,
zhho.coupon_amount,
zhho.coupon_id,
zhho.actual_check_in_time,
zhho.actual_check_out_time
FROM zdy_hotel_homestay_order_room_detail zhhord
LEFT JOIN zdy_hotel_homestay_order zhho on zhho.id = zhhord.order_id
WHERE zhhord.room_status_id = #{roomStatusId}
</select>
<select id="listByCustomerId" parameterType="ZdyHotelHomestayOrder" resultMap="ZdyHotelHomestayOrderResult">
select zhho.id,
zhho.hotel_homestay_id,
zhho.order_code,
zhho.order_source,
zhho.contact_mobile,
zhho.contact_names,
zhho.stay_type,
zhho.in_datetime,
zhho.out_datetime,
zhho.estimated_arrival_time,
zhho.estimated_arrival_date_time,
zhho.stay_status,
zhho.room_quantity,
zhho.room_classify_id,
zhho.room_price,
zhho.room_charge,
zhho.room_consumption,
zhho.penalty_fee,
zhho.refund,
zhho.total_amount,
zhho.balance_status,
zhho.block_booking_status,
zhho.payment_type,
zhho.payment_method,
zhho.payment_scene,
zhho.payment_time,
zhho.order_prepay_id,
zhho.trade_session,
zhho.refund_status,
zhho.refund_time,
zhho.cancel_time,
zhho.create_time,
zhho.create_zdy_user_id,
zhho.create_sys_user_id,
zhho.update_time,
zhho.updater_id,
zhho.is_deleted,
zhho.processed_by,
zhho.processing_time,
zhho.remark,
zhho.pay_amount,
zhho.coupon_amount,
zhho.coupon_id,
sbi.name as hotel_homestay_name,
sbi.images as hotel_homestay_cover_image,
sbi.longitude as hotel_homestay_longitude,
sbi.latitude as hotel_homestay_latitude,
sbi.contact_phone as hotel_homestay_phonenumber
from
zdy_hotel_homestay_order_stay_info zhhosi
left join zdy_hotel_homestay_order zhho on zhho.id = zhhosi.order_id
left join zdy_hotel_homestay zhh on zhho.hotel_homestay_id = zhh.id
left join zdy_store_base_info sbi on sbi.id = zhh.store_id
<where>
<if test="customerId != null ">
and zhhosi.customer_id = #{customerId}
</if>
<if test="deptId != null ">
and sbi.dept_id = #{deptId}
</if>
<if test="orderCode != null and orderCode != ''">
and zhho.order_code = #{orderCode}
</if>
<if test="orderSource != null and orderSource != ''">
and zhho.order_source = #{orderSource}
</if>
<if test="contactMobile != null and contactMobile != ''">
and zhho.contact_mobile = #{contactMobile}
</if>
<if test="contactNames != null and contactNames != ''">
and zhho.contact_names like concat('%',#{contactNames},'%')
</if>
<if test="stayType != null and stayType != ''">
and zhho.stay_type = #{stayType}
</if>
<if test="inDateTime != null ">
and zhho.in_datetime = #{inDateTime}
</if>
<if test="outDateTime != null ">
and zhho.out_datetime = #{outDateTime}
</if>
<if test="stayStatus != null">
and zhho.stay_status = #{stayStatus.name}
</if>
<if test="roomQuantity != null ">
and zhho.room_quantity = #{roomQuantity}
</if>
<if test="roomClassifyId != null ">
and zhho.room_classify_id = #{roomClassifyId}
</if>
<if test="roomPrice != null ">
and zhho.room_price = #{roomPrice}
</if>
<if test="roomCharge != null ">
and zhho.room_charge = #{roomCharge}
</if>
<if test="roomConsumption != null ">
and zhho.room_consumption = #{roomConsumption}
</if>
<if test="penaltyFee != null ">
and zhho.penalty_fee = #{penaltyFee}
</if>
<if test="refund != null ">
and zhho.refund = #{refund}
</if>
<if test="totalAmount != null ">
and zhho.total_amount = #{totalAmount}
</if>
<if test="balanceStatus != null and balanceStatus != ''">
and zhho.balance_status = #{balanceStatus}
</if>
<if test="blockBookingStatus != null and blockBookingStatus != ''">
and zhho.block_booking_status = #{blockBookingStatus}
</if>
<if test="paymentType != null and paymentType != ''">
and zhho.payment_type = #{paymentType}
</if>
<if test="paymentMethod != null and paymentMethod != ''">
and zhho.payment_method = #{paymentMethod}
</if>
<if test="paymentScene != null and paymentScene != ''">
and zhho.payment_scene = #{paymentScene}
</if>
<if test="paymentTime != null ">
and zhho.payment_time = #{paymentTime}
</if>
<if test="orderPrepayId != null and orderPrepayId != ''">
and zhho.order_prepay_id = #{orderPrepayId}
</if>
<if test="tradeSession != null and tradeSession != ''">
and zhho.trade_session = #{tradeSession}
</if>
<if test="refundStatus != null and refundStatus != ''">
and zhho.refund_status = #{refundStatus}
</if>
<if test="refundTime != null ">
and zhho.refund_time = #{refundTime}
</if>
<if test="createZdyUserId != null ">
and zhho.create_zdy_user_id = #{createZdyUserId}
</if>
<if test="createSysUserId != null ">
and zhho.create_sys_user_id = #{createSysUserId}
</if>
<if test="updaterId != null ">
and zhho.updater_id = #{updaterId}
</if>
<choose>
<when test="isDeleted != null ">
and zhho.is_deleted = #{isDeleted}
</when>
<otherwise>
and zhho.is_deleted = 0
</otherwise>
</choose>
<if test="queryRefundAll != null and queryRefundAll">
and zhho.refund_status is not null
</if>
</where>
order by zhho.id desc
</select>
<select id="countOrdersAndLastOrderTimeByPaymentType" resultType="ZdyHotelHomestayCustomer">
SELECT zhhosi.customer_id as id,
COUNT(zhhosi.order_id) as totalOrderCount,
MAX(zhho.create_time) as lastOrderTime
FROM zdy_hotel_homestay_order_stay_info zhhosi
LEFT JOIN zdy_hotel_homestay_order zhho on zhho.id = zhhosi.order_id
WHERE zhho.payment_type = #{paymentType}
AND zhhosi.customer_id IN
<foreach collection="customerIds" item="customerId" separator="," open="(" close=")">
#{customerId}
</foreach>
GROUP BY zhhosi.customer_id;
</select>
<select id="countNotDeleteOrders" resultType="int">
select count(id) from zdy_hotel_homestay_order
<where>
is_deleted = 0
<if test="hotelHomestayIds!=null and hotelHomestayIds.size()>0">
and hotel_homestay_id in
<foreach item="hotelHomestayId" collection="hotelHomestayIds" open="(" separator="," close=")">
#{hotelHomestayId}
</foreach>
</if>
</where>
</select>
<select id="roomCost" parameterType="com.zhwl.hotel.homestay.order.domain.dto.RoomCostStatisticsQueryDTO"
resultType="com.zhwl.hotel.homestay.order.domain.vo.RoomCostStatisticsVO">
select rc.level2_name level2Name,
count(distinct o.id) orderQuantity,
sum(ifnull(ord.room_charge, 0)) orderAmount,
count(o.refund_status = 200) refundQuantity,
sum(ifnull(o.refund, 0)) refundAmount
from zdy_hotel_homestay_order_room_detail ord
left join zdy_hotel_homestay_order o on ord.order_id = o.id
left join zdy_hotel_homestay_room_classify rc
on o.hotel_homestay_id = rc.hotel_homestay_id and ord.room_classify_id = rc.id
left join zdy_hotel_homestay h on o.hotel_homestay_id = h.id
left join zdy_store_base_info sbi on h.store_id = sbi.id
<where>
o.is_deleted = 0
and o.payment_type = 200
<if test="level2Name != null and level2Name != ''">
and rc.level2_name=#{level2Name}
</if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
AND date_format(o.create_time,'%y%m%d') &gt;= date_format(#{params.beginTime},'%y%m%d')
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
AND date_format(o.create_time,'%y%m%d') &lt;= date_format(#{params.endTime},'%y%m%d')
</if>
${params.dataScope}
</where>
group by rc.level2_name
</select>
</mapper>