<?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.fdkankan.platform.order.mapper.IDownloadOrderMapper">

    <select id="getCountBySceneNum" resultType="com.fdkankan.platform.goods.vo.SceneCountVo">
        SELECT scene_num as sceneNum,count(*)as total FROM t_download_order WHERE  REC_STATUS = 'A' GROUP BY scene_num
    </select>

    <select id="getOrderList" resultType="com.fdkankan.platform.user.vo.ResponseOrder" >
        SELECT o.id,o.order_sn,o.create_time orderTime,amount totalAmount,pay_type paymentTypeName,number trade_num,
                o.pay_status paymentStatus,trade_time finishTime,o.user_id, c.sn_code snCode,
                abroad, u.user_name,o.scene_num sceneNum,o.scene_name sceneName  FROM t_download_order o
         LEFT JOIN t_scene_pro s on s.num = o.scene_num
         LEFT JOIN t_camera c on c.id = s.camera_id
         LEFT JOIN t_user u on o.user_id = u.id
         where o.tb_status = 0 and (o.pay_status = 1 or o.pay_status = -2)
        <if test="  param.phoneNum != null and  param.phoneNum !='' " >
            and u.user_name like  CONCAT('%',#{param.phoneNum},'%'))
        </if>
        <if test="param.startDate != null and param.startDate !='' " >
            and o.create_time &gt;= ${param.startDate} '00:00:00'
        </if>
        <if test=" param.endDate != null and param.endDate !='' " >
            and o.create_time &lt;= ${param.endDate} '23:59:59'
        </if>
        <if test="  param.tradeNum != null and  param.tradeNum !='' " >
            and o.number like  CONCAT('%',#{param.tradeNum},'%'))
        </if>
        order by o.create_time desc
    </select>
</mapper>
