123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- <?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.manage.mapper.IInvoiceMapper">
- <select id="pageInvoice" resultType="com.fdkankan.manage.vo.InvoiceVO">
- select * from(
- /*配件订单发票*/
- SELECT
- i.`id`,
- o.`order_sn`,
- o.`finish_time` AS payTime,
- i.`create_time` AS invoiceTime,
- i.`money`,
- i.`type`,
- i.`title`,
- i.`code`,
- i.`organized_address` as organizedAddress,
- i.`register_phone` as registerPhone,
- i.`bank_name` as bankName,
- i.`bank_account` as bankAccount,
- i.`ship_name` as shipName,
- i.`ship_mobile` as shipMobile,
- i.`ship_address` as shipAddress,
- i.`email_address` AS email,
- i.`invoiced`
- FROM t_invoice i
- LEFT JOIN t_order o ON i.`order_id` = o.`id`
- WHERE i.`consume_type` = 0 AND i.`rec_status` = 'A' AND o.`rec_status` = 'A' AND i.`type` != 1
- <if test="param.orderSn != null and param.orderSn != ''">
- and o.`order_sn` like concat('%', #{param.orderSn}, '%')
- </if>
- <if test="param.invoiceTimeStart != null">
- and i.`create_time` >= #{param.invoiceTimeStart}
- </if>
- <if test="param.invoiceTimeEnd != null">
- and i.`create_time` <![CDATA[ <= ]]> #{param.invoiceTimeEnd}
- </if>
- <if test="param.payTimeStart != null">
- and o.`finish_time` >= #{param.payTimeStart}
- </if>
- <if test="param.payTimeEnd != null">
- and o.`finish_time` <![CDATA[ <= ]]> #{param.payTimeEnd}
- </if>
- UNION
- /*会员权益订单发票*/
- SELECT
- i.`id`,
- o.`order_sn`,
- o.`trade_time` AS payTime,
- i.`create_time` AS invoiceTime,
- i.`money`,
- i.`type`,
- i.`title`,
- i.`code`,
- i.`organized_address` AS organizedAddress,
- i.`register_phone` AS registerPhone,
- i.`bank_name` AS bankName,
- i.`bank_account` AS bankAccount,
- i.`ship_name` AS shipName,
- i.`ship_mobile` AS shipMobile,
- i.`ship_address` AS shipAddress,
- i.`email_address` AS email,
- i.`invoiced`
- FROM t_invoice i
- LEFT JOIN t_increment_order o ON i.`increment_order_id` = o.`id`
- WHERE i.`consume_type` = 2 AND i.`rec_status` = 'A' AND o.`rec_status` = 'A' AND i.`type` != 1
- <if test="param.orderSn != null and param.orderSn != ''">
- and o.`order_sn` like concat('%', #{param.orderSn}, '%')
- </if>
- <if test="param.invoiceTimeStart != null">
- and i.`create_time` >= #{param.invoiceTimeStart}
- </if>
- <if test="param.invoiceTimeEnd != null">
- and i.`create_time` <![CDATA[ <= ]]> #{param.invoiceTimeEnd}
- </if>
- <if test="param.payTimeStart != null">
- and o.`trade_time` >= #{param.payTimeStart}
- </if>
- <if test="param.payTimeEnd != null">
- and o.`trade_time` <![CDATA[ <= ]]> #{param.payTimeEnd}
- </if>
- UNION
- /*下载订单发票*/
- SELECT
- i.`id`,
- o.`order_sn`,
- o.`trade_time` AS payTime,
- i.`create_time` AS invoiceTime,
- i.`money`,
- i.`type`,
- i.`title`,
- i.`code`,
- i.`organized_address` AS organizedAddress,
- i.`register_phone` AS registerPhone,
- i.`bank_name` AS bankName,
- i.`bank_account` AS bankAccount,
- i.`ship_name` AS shipName,
- i.`ship_mobile` AS shipMobile,
- i.`ship_address` AS shipAddress,
- i.`email_address` AS email,
- i.`invoiced`
- FROM t_invoice i
- LEFT JOIN t_download_order o ON i.`download_order_id` = o.`id`
- WHERE i.`consume_type` = 3 AND i.`rec_status` = 'A' AND o.`rec_status` = 'A' AND i.`type` != 1
- <if test="param.orderSn != null and param.orderSn != ''">
- and o.`order_sn` like concat('%', #{param.orderSn}, '%')
- </if>
- <if test="param.invoiceTimeStart != null">
- and i.`create_time` >= #{param.invoiceTimeStart}
- </if>
- <if test="param.invoiceTimeEnd != null">
- and i.`create_time` <![CDATA[ <= ]]> #{param.invoiceTimeEnd}
- </if>
- <if test="param.payTimeStart != null">
- and o.`trade_time` >= #{param.payTimeStart}
- </if>
- <if test="param.payTimeEnd != null">
- and o.`trade_time` <![CDATA[ <= ]]> #{param.payTimeEnd}
- </if>
- ) t
- <if test="param.orderBy != null and param.orderBy!='' and param.sortBy !=null and param.sortBy !='' ">
- order by ${param.orderBy} ${param.sortBy}
- </if>
- <if test="param.orderBy == null or param.orderBy=='' ">
- order by id desc
- </if>
- </select>
- </mapper>
|