lanan-system/dl-module-inspection/src/main/resources/mapper/inspection/InspectionAppointmentMapper.xml
2025-04-28 15:21:05 +08:00

137 lines
7.3 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="cn.iocoder.yudao.module.inspection.mapper.InspectionAppointmentMapper">
<resultMap type="cn.iocoder.yudao.module.inspection.entity.InspectionAppointment" id="InspectionAppointmentResult">
<result property="id" column="id" />
<result property="partnerId" column="partner_id" />
<result property="orderId" column="order_id" />
<result property="goodsTitle" column="goods_title" />
<result property="appointmentDay" column="appointment_day" />
<result property="appointmentPeriod" column="appointment_period" />
<result property="createTime" column="create_time" />
<result property="creator" column="creator" />
<result property="updateTime" column="update_time" />
<result property="updater" column="updater" />
</resultMap>
<sql id="selectInspectionAppointmentVo">
select id, partner_id, order_id, goods_title, appointment_day, appointment_period, create_time, creator, update_time, updater from inspection_appointment
</sql>
<select id="selectInspectionAppointmentList" parameterType="cn.iocoder.yudao.module.inspection.entity.InspectionAppointment" resultMap="InspectionAppointmentResult">
<include refid="selectInspectionAppointmentVo"/>
<where>
<if test="vo.partnerId != null "> and partner_id = #{vo.partnerId}</if>
<if test="vo.orderId != null "> and order_id = #{vo.orderId}</if>
<if test="vo.goodsTitle != null and vo.goodsTitle != ''"> and goods_title = #{vo.goodsTitle}</if>
<if test="vo.appointmentDay != null "> and appointment_day = #{vo.appointmentDay}</if>
<if test="vo.appointmentPeriod != null and vo.appointmentPeriod != ''"> and appointment_period = #{vo.appointmentPeriod}</if>
</where>
</select>
<select id="selectInspectionAppointmentById" parameterType="Long" >
select ia.*,su.nickname as buyName, su.mobile as buyPhoneNum,su2.nickname as meetName,imco.is_meet,ic.appointment_day as pickCarAppointmentDay,ic.appointment_time as pickCarAppointmentTime,ic.adress_detail,ia.is_use
from inspection_appointment ia
left join system_users su on su.id = ia.user_id
LEFT JOIN inspection_meet_car_order imco ON imco.id = ia.meet_order_id
LEFT JOIN system_users su2 on su2.id = imco.meet_man_id
LEFT JOIN inspection_pick_car ic on ic.id = ia.pick_car_id
where ia.id = #{id}
</select>
<insert id="insertInspectionAppointment" parameterType="cn.iocoder.yudao.module.inspection.entity.InspectionAppointment">
insert into inspection_appointment
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="partnerId != null">partner_id,</if>
<if test="orderId != null">order_id,</if>
<if test="goodsTitle != null">goods_title,</if>
<if test="appointmentDay != null">appointment_day,</if>
<if test="appointmentPeriod != null">appointment_period,</if>
<if test="createTime != null">create_time,</if>
<if test="creator != null">creator,</if>
<if test="updateTime != null">update_time,</if>
<if test="updater != null">updater,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="partnerId != null">#{partnerId},</if>
<if test="orderId != null">#{orderId},</if>
<if test="goodsTitle != null">#{goodsTitle},</if>
<if test="appointmentDay != null">#{appointmentDay},</if>
<if test="appointmentPeriod != null">#{appointmentPeriod},</if>
<if test="createTime != null">#{createTime},</if>
<if test="creator != null">#{creator},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updater != null">#{updater},</if>
</trim>
</insert>
<update id="updateInspectionAppointment" parameterType="cn.iocoder.yudao.module.inspection.entity.InspectionAppointment">
update inspection_appointment
<trim prefix="SET" suffixOverrides=",">
<if test="partnerId != null">partner_id = #{partnerId},</if>
<if test="orderId != null">order_id = #{orderId},</if>
<if test="goodsTitle != null">goods_title = #{goodsTitle},</if>
<if test="appointmentDay != null">appointment_day = #{appointmentDay},</if>
<if test="appointmentPeriod != null">appointment_period = #{appointmentPeriod},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="creator != null">creator = #{creator},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updater != null">updater = #{updater},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteInspectionAppointmentById" parameterType="Long">
delete from inspection_appointment where id = #{id}
</delete>
<delete id="deleteInspectionAppointmentByIds" parameterType="String">
delete from inspection_appointment where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<select id="getAppointmentList" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionAppointment">
SELECT
ip.*,su.mobile as buyPhoneNum,su.nickname as buyName,ip.goods_title as goodsTitle,
suc.car_nature,suc.car_brand,suc.car_model,suc.car_no,igs.sku_name
FROM
inspection_appointment ip
INNER JOIN system_users su ON ip.user_id = su.id
left JOIN order_info oi ON ip.order_id = oi.id and oi.deleted=0
left join shop_user_car suc on suc.car_id = oi.user_car_id and suc.deleted=0
LEFT JOIN inspection_goods_sku igs on igs.id = ip.sku_id
where ip.deleted=0 and oi.validation_time IS NULL
<if test="phoneNum!=null and phoneNum!=''">
and (su.mobile like concat('%',#{phoneNum},'%') OR ip.car_no like concat('%',#{phoneNum},'%'))
</if>
<if test="partnerId!=null and partnerId!=''">
and ip.partner_id = #{partnerId}
</if>
<if test="carNo != null and carNo != ''">
and ip.car_no like concat('%',#{carNo},'%')
</if>
<if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
and ip.appointment_day between #{startTime} and #{endTime}
</if>
order by ip.create_time desc
</select>
<select id="getAppointmentOwn" resultType="cn.iocoder.yudao.module.inspection.entity.InspectionAppointment">
SELECT
ip.*,su.mobile as buyPhoneNum,su.nickname as buyName,ip.goods_title as goodsTitle,
suc.car_nature,suc.car_brand,suc.car_model,suc.car_no
FROM
inspection_appointment ip
INNER JOIN system_users su ON ip.user_id = su.id
left JOIN order_info oi ON ip.order_id = oi.id
left join shop_user_car suc on suc.car_id = oi.user_car_id
where ip.deleted=0 and ip.user_id = #{userId}
order by ip.create_time desc
</select>
</mapper>