TaInvoiceDetailMapper.xml 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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.njyunzhi.invoice.mapper.TaInvoiceDetailMapper">
  4. <insert id="createBatch">
  5. INSERT INTO ta_invoice_detail_tpl (
  6. `detail_id`,
  7. `invoice_id`,
  8. `invoice_person_id`,
  9. `person_id`,
  10. `person_name`,
  11. `invoice_org_id`,
  12. `invoice_org_name`,
  13. `org_id`,
  14. `org_name`,
  15. `tax_no`,
  16. `address`,
  17. `phone`,
  18. `bank_id`,
  19. `bank_name`,
  20. `card_no`,
  21. `invoice_item_tpl_id`,
  22. `item_name`,
  23. `charge`,
  24. `merge_remark`,
  25. `stay_remark`,
  26. `status`,
  27. `create_date`
  28. ) SELECT
  29. UUID_SHORT( ),
  30. t.invoice_id,
  31. t.invoice_person_id,
  32. NULL,
  33. t.`name`,
  34. t.invoice_org_id,
  35. t.org_name,
  36. NULL,
  37. NULL,
  38. NULL,
  39. NULL,
  40. NULL,
  41. NULL,
  42. NULL,
  43. NULL,
  44. NULL,
  45. NULL,
  46. NULL,
  47. NULL,
  48. NULL,
  49. 1,
  50. now( )
  51. FROM
  52. ta_invoice_person t
  53. WHERE
  54. t.invoice_id = #{invoiceId}
  55. AND t.`status` &gt; -1
  56. </insert>
  57. <update id="updatePerson">
  58. UPDATE ta_invoice_detail t
  59. SET t.person_id = #{personId}
  60. WHERE
  61. t.invoice_id = #{invoiceId}
  62. AND t.invoice_person_id = #{invoicePersonId}
  63. </update>
  64. <delete id="removeTplById">
  65. DELETE FROM ta_invoice_detail_tpl
  66. WHERE detail_id = #{id}
  67. </delete>
  68. <select id="getByPerson" resultType="com.njyunzhi.invoice.entity.TaInvoiceDetail">
  69. SELECT
  70. *
  71. FROM
  72. ta_invoice_detail t
  73. WHERE
  74. t.invoice_id = #{invoiceId}
  75. AND t.person_id = #{personId}
  76. AND t.`status` = 1
  77. </select>
  78. <sql id="getInvoiceDetail">
  79. SELECT
  80. t.`detail_id`,
  81. t.`invoice_id`,
  82. t.`invoice_person_id`,
  83. t.`person_id`,
  84. t.`person_name`,
  85. t.`invoice_org_id`,
  86. t.`invoice_org_name`,
  87. t.`org_id`,
  88. t.`org_name`,
  89. t.`tax_no`,
  90. t.`address`,
  91. t.`phone`,
  92. t.`bank_id`,
  93. t.`bank_name`,
  94. t.`card_no`,
  95. s.`invoice_item_id`,
  96. s.`name` AS item_name,
  97. s.`charge`,
  98. t.`merge_remark`,
  99. t.`stay_remark`,
  100. t.`mail_user`,
  101. t.`mail_phone`,
  102. t.`mail_address`,
  103. t.`status`,
  104. t.`create_date`,
  105. t.`is_need_lodging`,
  106. t.`room_code`
  107. FROM
  108. ta_invoice_detail t
  109. INNER JOIN ta_invoice_item s ON t.invoice_id = s.invoice_id AND t.invoice_person_id = s.invoice_person_id
  110. </sql>
  111. <select id="getListByMainId" resultType="com.njyunzhi.invoice.entity.TaInvoiceDetail">
  112. <include refid="getInvoiceDetail"></include>
  113. WHERE
  114. t.`status` = 1
  115. AND t.invoice_id = #{invoiceId}
  116. ORDER BY
  117. t.org_name ASC,
  118. t.person_name ASC,
  119. s.`name` ASC
  120. </select>
  121. <select id="getTplPageBy" resultType="com.njyunzhi.invoice.entity.TaInvoiceDetail">
  122. SELECT
  123. t.`invoice_person_id`,
  124. t.`person_id`,
  125. t.`invoice_org_id`,
  126. t.`name` AS `person_name`,
  127. t.`phone`,
  128. t.`status`,
  129. t.`create_date`,
  130. t.`invoice_id`,
  131. t.`org_name` AS invoice_org_name,
  132. s.`invoice_item_id`,
  133. s.`name` AS item_name,
  134. s.`charge`
  135. FROM
  136. ta_invoice_person t
  137. INNER JOIN ta_invoice_item s ON t.invoice_person_id = s.invoice_person_id
  138. WHERE
  139. t.invoice_id = #{invoiceId}
  140. AND t.`status` &gt; -1
  141. AND s.`status` &gt; -1
  142. ORDER BY
  143. t.org_name ASC,
  144. t.`name` ASC,
  145. s.`name` ASC
  146. </select>
  147. <select id="getPersonPage" resultType="com.njyunzhi.invoice.entity.TaInvoiceDetail">
  148. SELECT
  149. t.*,
  150. s.`name` as invoice_name
  151. FROM
  152. ta_invoice_detail t
  153. INNER JOIN ta_invoice_fill s ON s.invoice_id = t.invoice_id
  154. WHERE
  155. t.`status` = 1
  156. <if test="invoiceId != null and invoiceId != ''">
  157. AND t.invoice_id = #{invoiceId}
  158. </if>
  159. <if test="personId != null and personId != ''">
  160. AND t.person_id = #{personId}
  161. </if>
  162. <if test="personName != null and personName != ''">
  163. AND t.person_name LIKE CONCAT( '%', #{personName}, '%' )
  164. </if>
  165. GROUP BY
  166. t.person_id
  167. ORDER BY
  168. t.org_name ASC,
  169. t.person_name ASC
  170. </select>
  171. <select id="getTplByPerson" resultType="com.njyunzhi.invoice.entity.TaInvoiceDetail">
  172. SELECT
  173. t.`invoice_person_id`,
  174. t.`person_id`,
  175. t.`invoice_org_id`,
  176. t.`name` AS `person_name`,
  177. t.`phone`,
  178. t.`status`,
  179. t.`create_date`,
  180. t.`invoice_id`,
  181. t.`org_name` AS invoice_org_name
  182. FROM
  183. ta_invoice_person t
  184. WHERE
  185. t.invoice_id = #{invoiceId}
  186. AND t.`invoice_person_id` = #{invoicePersonId}
  187. AND t.`status` &gt; -1
  188. ORDER BY
  189. t.org_name ASC,
  190. t.`name` ASC
  191. </select>
  192. <select id="getPageBy" resultType="com.njyunzhi.invoice.entity.TaInvoiceDetail">
  193. <include refid="getInvoiceDetail"></include>
  194. WHERE
  195. t.`status` = 1
  196. AND t.invoice_id = #{invoiceId}
  197. <if test="orgName != null and orgName != ''">
  198. AND t.org_name LIKE CONCAT( '%', #{orgName}, '%' )
  199. </if>
  200. <if test="personName != null and personName != ''">
  201. AND t.person_name LIKE CONCAT( '%', #{personName}, '%' )
  202. </if>
  203. ORDER BY
  204. t.org_name ASC,
  205. t.person_name ASC,
  206. s.`name` ASC
  207. </select>
  208. </mapper>