<?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.xunwang.payment.mapper.OrderInfoMapper">

    <update id="updateRequireStatus">
        update stu_needs
        set deal = "成交", display = "下架"
        where require_id = #{id}
    </update>

    <update id="updateCourseStatus">
        update teacher_courses
        set deal = "成交", display = "下架"
        where course_id = #{id}
    </update>

    <update id="updateRefundCourseStatus">
        update teacher_courses
        set deal = "未成交", locked = "未锁"
        where course_id = #{id}
    </update>

    <update id="updateRefundRequireStatus">
        update stu_needs
        set deal = "未成交", locked = "未锁"
        where require_id = #{id}
    </update>

    <select id="selectInviteInfo" resultType="com.xunwang.payment.entity.InviteInfo">
        select
            id, from_uid, to_uid, require_id, course_id, from_uname, to_uname, require_detail, datetime, recommend_uid, require_salary, `identity`, read_status, operate_status
        from
            invite_info
        where
            id = #{inviteId}
    </select>

    <select id="getOpenIdByUid" resultType="java.lang.String">
        select
            openid
        from
            mp_openid_uid
        where
            uid = #{uid}
    </select>

    <select id="getMyOrderList" resultType="com.xunwang.payment.entity.dto.MyOrder">
        select
            order_id, require_detail, datetime, student_name, status
        from
            order_info
        where
            open_id = #{id}
        order by datetime desc
    </select>

    <select id="getNotWithdrawOrderListByRecommendUid" resultType="com.xunwang.payment.entity.OrderInfo">
        select
            order_id, datetime, reco_status
        from
            order_info
        where
            recommend_uid = #{id} and is_refund = '0' and status = '支付成功' and reco_status <![CDATA[<>]]> '已提现'
        order by datetime desc
    </select>

    <select id="getWithdrawOrderListByRecommendUid" resultType="com.xunwang.payment.entity.OrderInfo">
        select
            order_id, datetime, reco_status
        from
            order_info
        where
            recommend_uid = #{id} and is_refund = '0' and reco_status = '已提现'
        order by datetime desc
    </select>
</mapper>
