PensionOrderDao.xml 9.66 KB
<?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="io.hmit.modules.serviceOrder.dao.PensionOrderDao">

    <resultMap type="io.hmit.modules.serviceOrder.entity.PensionOrderEntity" id="pensionOrderMap">
        <result property="id" column="id"/>
        <result property="orderNum" column="order_num"/>
        <result property="status" column="status"/>
        <result property="statusName" column="status_name"/>
        <result property="address" column="address"/>
        <result property="serviceId" column="service_id"/>
        <result property="serviceName" column="service_name"/>
        <result property="appointmentPerson" column="appointment_person"/>
        <result property="appointmentPhone" column="appointment_phone"/>
        <result property="appointmentTime" column="appointment_time"/>
        <result property="remark" column="remark"/>
        <result property="orderRecipientId" column="order_recipient_id"/>
        <result property="orderRecipientName" column="order_recipient_name"/>
        <result property="orderRecipientTime" column="order_recipient_time"/>
        <result property="orderRecipientPhone" column="order_recipient_phone"/>
        <result property="actPrice" column="act_price"/>
        <result property="communityName" column="community_name"/>
        <result property="communityId" column="community_id"/>
        <result property="deptId" column="dept_id"/>
        <result property="creator" column="creator"/>
        <result property="creatorName" column="creator_name"/>
        <result property="creatorTel" column="creator_tel"/>
        <result property="createDate" column="create_date"/>
        <result property="updater" column="updater"/>
        <result property="updateDate" column="update_date"/>
    </resultMap>

    <select id="getOrderInfoByIdAndStatus" resultType="io.hmit.modules.serviceOrder.entity.PensionOrderEntity">
        SELECT po.id, po.order_num, po.status, po.status_name, po.address, po.service_id, po.service_name,
               po.appointment_person, po.appointment_phone, po.appointment_time, po.remark, po.location,
               po.order_recipient_id, po.order_recipient_name, po.order_recipient_time, po.order_recipient_phone,
               po.act_price, po.community_name, po.community_id, po.dept_id, po.cancel_reason, content,
               po.creator, po.creator_name, po.creator_tel, po.create_date
        FROM pension_order po
        WHERE po.id = #{orderId} AND po.status = #{status}
    </select>

    <select id="getOrderPageByStatusOrUserId" resultType="io.hmit.modules.serviceOrder.dto.PensionOrderDTO">
        SELECT po.id, po.order_num, po.status, po.status_name, po.address, po.service_id, po.service_name,
               po.appointment_person, po.appointment_phone, po.appointment_time, po.remark, po.location,
               po.order_recipient_id, po.order_recipient_name, po.order_recipient_time, po.order_recipient_phone,
               po.act_price, po.community_name, po.community_id, po.dept_id, po.cancel_reason, content,
               po.creator, po.creator_name, po.creator_tel, po.create_date,
               ps.icon
        FROM pension_order po, pension_service ps
        WHERE po.service_id = ps.id
        <if test="status != null and status == 0">
            <if test="userId != null">
                AND po.order_recipient_id IS NULL
            </if>
            AND po.status = 0
        </if>
        <if test="status != null and status != 0">
            <if test="userId != null">
                AND po.order_recipient_id = #{userId}
            </if>
            AND po.status = #{status}
        </if>
        <if test="status == null and userId != null">
            AND po.order_recipient_id = #{userId}
        </if>
    </select>

    <select id="getOrderInfoByIdAndUserIdOrStatus" resultType="io.hmit.modules.serviceOrder.dto.PensionOrderDTO">
        SELECT po.id, po.order_num, po.status, po.status_name, po.address, po.service_id, po.service_name,
               po.appointment_person, po.appointment_phone, po.appointment_time, po.remark, po.location,
               po.order_recipient_id, po.order_recipient_name, po.order_recipient_time, po.order_recipient_phone,
               po.act_price, po.community_name, po.community_id, po.dept_id, po.cancel_reason, content,
               po.creator, po.creator_name, po.creator_tel, po.create_date,
               ps.icon
        FROM pension_order po, pension_service ps
        WHERE po.service_id = ps.id AND po.id = #{orderId}
        <if test="userId != null">
            AND po.order_recipient_id = #{userId}
        </if>
        <if test="status != null">
            AND po.status = #{status}
        </if>
    </select>

    <select id="getTodayNoProceedOrderPage" resultType="io.hmit.modules.serviceOrder.dto.PensionOrderDTO">
        SELECT po.id, po.order_num, po.status, po.status_name, po.address, po.service_id, po.service_name,
               po.appointment_person, po.appointment_phone, po.appointment_time, po.remark, po.location,
               po.order_recipient_id, po.order_recipient_name, po.order_recipient_time, po.order_recipient_phone,
               po.act_price, po.community_name, po.community_id, po.dept_id, po.cancel_reason, content,
               po.creator, po.creator_name, po.creator_tel, po.create_date,
               ps.icon
        FROM pension_order po, pension_service ps
        WHERE po.service_id = ps.id AND TO_DAYS(appointment_time) = TO_DAYS(NOW()) AND po.status = 0 AND po.order_recipient_id IS NULL
    </select>

    <select id="getElderTodayOrderPage" resultType="io.hmit.modules.serviceOrder.dto.PensionOrderDTO">
        SELECT po.id, po.order_num, po.status, po.status_name, po.address, po.service_id, po.service_name,
               po.appointment_person, po.appointment_phone, po.appointment_time, po.remark, po.location,
               po.order_recipient_id, po.order_recipient_name, po.order_recipient_time, po.order_recipient_phone,
               po.act_price, po.community_name, po.community_id, po.dept_id, po.cancel_reason, content,
               po.creator, po.creator_name, po.creator_tel, po.create_date,
               ps.icon
        FROM pension_order po, pension_service ps
        WHERE po.service_id = ps.id AND TO_DAYS(appointment_time) = TO_DAYS(NOW()) AND po.creator = #{creator}
    </select>

    <select id="getElderAllOrderOrByStatusList" resultType="io.hmit.modules.serviceOrder.dto.PensionOrderDTO">
        SELECT po.id, po.order_num, po.status, po.status_name, po.address, po.service_id, po.service_name,
               po.appointment_person, po.appointment_phone, po.appointment_time, po.remark, po.location,
               po.order_recipient_id, po.order_recipient_name, po.order_recipient_time, po.order_recipient_phone,
               po.act_price, po.community_name, po.community_id, po.dept_id, po.cancel_reason, content,
               po.creator, po.creator_name, po.creator_tel, po.create_date,
               ps.icon
        FROM pension_order po, pension_service ps
        WHERE po.service_id = ps.id AND po.creator = #{creator}
        <if test="status != null">
            AND po.status = #{status}
        </if>
    </select>

    <select id="getAllOrderByCommunityUserIdPage" resultType="io.hmit.modules.serviceOrder.dto.PensionOrderDTO">
        SELECT po.id, po.order_num, po.status, po.status_name, po.address, po.service_id, po.service_name,
               po.appointment_person, po.appointment_phone, po.appointment_time, po.remark, po.location,
               po.order_recipient_id, po.order_recipient_name, po.order_recipient_time, po.order_recipient_phone,
               po.act_price, po.community_name, po.community_id, po.dept_id, po.cancel_reason, content,
               po.creator, po.creator_name, po.creator_tel, po.create_date,
               ps.icon
        FROM pension_order po, pension_service ps, tb_user tu
        WHERE po.service_id = ps.id AND po.community_id = tu.community_id AND tu.id = #{userId}
    </select>

    <select id="getElderAllOrderByCommunityUserIdPage" resultType="io.hmit.modules.serviceOrder.dto.PensionOrderDTO">
        SELECT po.id, po.order_num, po.status, po.status_name, po.address, po.service_id, po.service_name,
               po.appointment_person, po.appointment_phone, po.appointment_time, po.remark, po.location,
               po.order_recipient_id, po.order_recipient_name, po.order_recipient_time, po.order_recipient_phone,
               po.act_price, po.community_name, po.community_id, po.dept_id, po.cancel_reason, content,
               po.creator, po.creator_name, po.creator_tel, po.create_date,
               ps.icon
        FROM pension_order po, pension_service ps, tb_user tu
        WHERE po.service_id = ps.id AND po.community_id = tu.community_id
          AND tu.id = #{userId} AND po.appointment_person LIKE CONCAT('%', #{appointmentPerson}, '%')
    </select>

    <select id="getAllOrderByServiceId" resultType="io.hmit.modules.serviceOrder.dto.PensionOrderDTO">
        SELECT po.id, po.order_num, po.status, po.status_name, po.address, po.service_id, po.service_name,
        po.appointment_person, po.appointment_phone, po.appointment_time, po.remark, po.location,
        po.order_recipient_id, po.order_recipient_name, po.order_recipient_time, po.order_recipient_phone,
        po.act_price, po.community_name, po.community_id, po.dept_id, po.cancel_reason, content,
        po.creator, po.creator_name, po.creator_tel, po.create_date,
        ps.icon
        FROM pension_order po, pension_service ps
        WHERE po.service_id = ps.id AND po.service_id = #{serviceId}
        <if test="status != null">
            AND po.status = #{status}
        </if>
    </select>

</mapper>