InvoiceMapper.xml 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  3. <mapper namespace="com.fdkankan.manage.mapper.IInvoiceMapper">
  4. <select id="pageInvoice" resultType="com.fdkankan.manage.vo.InvoiceVO">
  5. select * from(
  6. /*配件订单发票*/
  7. SELECT
  8. i.`id`,
  9. o.`order_sn`,
  10. o.`finish_time` AS payTime,
  11. i.`create_time` AS invoiceTime,
  12. i.`money`,
  13. i.`type`,
  14. i.`title`,
  15. i.`code`,
  16. i.`organized_address` as organizedAddress,
  17. i.`register_phone` as registerPhone,
  18. i.`bank_name` as bankName,
  19. i.`bank_account` as bankAccount,
  20. i.`ship_name` as shipName,
  21. i.`ship_mobile` as shipMobile,
  22. i.`ship_address` as shipAddress,
  23. i.`email_address` AS email,
  24. i.`invoiced`
  25. FROM t_invoice i
  26. LEFT JOIN t_order o ON i.`order_id` = o.`id`
  27. WHERE i.`consume_type` = 0 AND i.`rec_status` = 'A' AND o.`rec_status` = 'A' AND i.`type` != 1
  28. <if test="param.orderSn != null and param.orderSn != ''">
  29. and o.`order_sn` like concat('%', #{param.orderSn}, '%')
  30. </if>
  31. <if test="param.invoiceTimeStart != null">
  32. and i.`create_time` >= #{param.invoiceTimeStart}
  33. </if>
  34. <if test="param.invoiceTimeEnd != null">
  35. and i.`create_time` <![CDATA[ <= ]]> #{param.invoiceTimeEnd}
  36. </if>
  37. <if test="param.payTimeStart != null">
  38. and o.`finish_time` >= #{param.payTimeStart}
  39. </if>
  40. <if test="param.payTimeEnd != null">
  41. and o.`finish_time` <![CDATA[ <= ]]> #{param.payTimeEnd}
  42. </if>
  43. UNION
  44. /*会员权益订单发票*/
  45. SELECT
  46. i.`id`,
  47. o.`order_sn`,
  48. o.`trade_time` AS payTime,
  49. i.`create_time` AS invoiceTime,
  50. i.`money`,
  51. i.`type`,
  52. i.`title`,
  53. i.`code`,
  54. i.`organized_address` AS organizedAddress,
  55. i.`register_phone` AS registerPhone,
  56. i.`bank_name` AS bankName,
  57. i.`bank_account` AS bankAccount,
  58. i.`ship_name` AS shipName,
  59. i.`ship_mobile` AS shipMobile,
  60. i.`ship_address` AS shipAddress,
  61. i.`email_address` AS email,
  62. i.`invoiced`
  63. FROM t_invoice i
  64. LEFT JOIN t_increment_order o ON i.`increment_order_id` = o.`id`
  65. WHERE i.`consume_type` = 2 AND i.`rec_status` = 'A' AND o.`rec_status` = 'A' AND i.`type` != 1
  66. <if test="param.orderSn != null and param.orderSn != ''">
  67. and o.`order_sn` like concat('%', #{param.orderSn}, '%')
  68. </if>
  69. <if test="param.invoiceTimeStart != null">
  70. and i.`create_time` >= #{param.invoiceTimeStart}
  71. </if>
  72. <if test="param.invoiceTimeEnd != null">
  73. and i.`create_time` <![CDATA[ <= ]]> #{param.invoiceTimeEnd}
  74. </if>
  75. <if test="param.payTimeStart != null">
  76. and o.`trade_time` >= #{param.payTimeStart}
  77. </if>
  78. <if test="param.payTimeEnd != null">
  79. and o.`trade_time` <![CDATA[ <= ]]> #{param.payTimeEnd}
  80. </if>
  81. UNION
  82. /*下载订单发票*/
  83. SELECT
  84. i.`id`,
  85. o.`order_sn`,
  86. o.`trade_time` AS payTime,
  87. i.`create_time` AS invoiceTime,
  88. i.`money`,
  89. i.`type`,
  90. i.`title`,
  91. i.`code`,
  92. i.`organized_address` AS organizedAddress,
  93. i.`register_phone` AS registerPhone,
  94. i.`bank_name` AS bankName,
  95. i.`bank_account` AS bankAccount,
  96. i.`ship_name` AS shipName,
  97. i.`ship_mobile` AS shipMobile,
  98. i.`ship_address` AS shipAddress,
  99. i.`email_address` AS email,
  100. i.`invoiced`
  101. FROM t_invoice i
  102. LEFT JOIN t_download_order o ON i.`download_order_id` = o.`id`
  103. WHERE i.`consume_type` = 3 AND i.`rec_status` = 'A' AND o.`rec_status` = 'A' AND i.`type` != 1
  104. <if test="param.orderSn != null and param.orderSn != ''">
  105. and o.`order_sn` like concat('%', #{param.orderSn}, '%')
  106. </if>
  107. <if test="param.invoiceTimeStart != null">
  108. and i.`create_time` >= #{param.invoiceTimeStart}
  109. </if>
  110. <if test="param.invoiceTimeEnd != null">
  111. and i.`create_time` <![CDATA[ <= ]]> #{param.invoiceTimeEnd}
  112. </if>
  113. <if test="param.payTimeStart != null">
  114. and o.`trade_time` >= #{param.payTimeStart}
  115. </if>
  116. <if test="param.payTimeEnd != null">
  117. and o.`trade_time` <![CDATA[ <= ]]> #{param.payTimeEnd}
  118. </if>
  119. ) t
  120. <if test="param.orderBy != null and param.orderBy!='' and param.sortBy !=null and param.sortBy !='' ">
  121. order by ${param.orderBy} ${param.sortBy}
  122. </if>
  123. <if test="param.orderBy == null or param.orderBy=='' ">
  124. order by id desc
  125. </if>
  126. </select>
  127. </mapper>