<?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.sqx.modules.order.dao.OrderGoodsDao">

    <select id="selectByPayTime" resultType="com.sqx.modules.order.entity.TbOrder">
        select * from tb_order where 1 = 1
        and date_format(pay_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
        order by pay_time desc limit 1
    </select>

    <select id="selectParentShareTheBill" resultType="com.sqx.modules.order.entity.OrderGoods">
        select og.*, tu.nick_name as nickName, tu.avatar as avatar
        from order_goods og left join tb_user tu on og.user_id = tu.user_id where order_id = #{orderId} and og.user_id = #{userId}
    </select>

    <select id="selectShareTheBill" resultType="com.sqx.modules.order.entity.OrderGoods">
        select og.*, tu.nick_name as nickName, tu.avatar as avatar
        from order_goods og left join tb_user tu on og.user_id = tu.user_id where order_id = #{orderId} and og.user_id != #{userId} order by user_id asc
    </select>

</mapper>