BillInvoiceMapper.xml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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.jkcredit.invoice.mapper.binvoce.BillInvoiceMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="com.jkcredit.invoice.model.entity.invoice.BillInvoice">
  6. <id column="id" property="id"/>
  7. <result column="companyNum" property="companyNum"/>
  8. <result column="customerName" property="customerName"/>
  9. <result column="companyName" property="companyName"/>
  10. <result column="waybillNum" property="waybillNum"/>
  11. <result column="invoiceNum" property="invoiceNum"/>
  12. <result column="invoiceCode" property="invoiceCode"/>
  13. <result column="invoiceMakeTime" property="invoiceMakeTime"/>
  14. <result column="invoiceUrl" property="invoiceUrl"/>
  15. <result column="invoiceHtmlUrl" property="invoiceHtmlUrl"/>
  16. <result column="enStation" property="enStation"/>
  17. <result column="exStation" property="exStation"/>
  18. <result column="exTime" property="exTime"/>
  19. <result column="fee" property="fee"/>
  20. <result column="totalTaxAmount" property="totalTaxAmount"/>
  21. <result column="plateNum" property="plateNum"/>
  22. <result column="vehicleType" property="vehicleType"/>
  23. <result column="sellerName" property="sellerName"/>
  24. <result column="sellerTaxpayerCode" property="sellerTaxpayerCode"/>
  25. <result column="waybillStatus" property="waybillStatus"/>
  26. <result column="waybillStartTime" property="waybillStartTime"/>
  27. <result column="waybillEndTime" property="waybillEndTime"/>
  28. <result column="totalAmount" property="totalAmount"/>
  29. <result column="taxRate" property="taxRate"/>
  30. <result column="invoiceType" property="invoiceType"/>
  31. <result column="amount" property="amount"/>
  32. <result column="transactionId" property="transactionId"/>
  33. <result column="tradeMatchTime" property="tradeMatchTime"/>
  34. <result column="buyerName" property="buyerName"/>
  35. <result column="buyerTaxpayerCode" property="buyerTaxpayerCode"/>
  36. <result column="billStatus" property="billStatus"/>
  37. <result column="calculateTime" property="calculateTime"/>
  38. <result column="interType" property="interType"/>
  39. <result column="invoiceStatus" property="invoiceStatus"/>
  40. <result column="msg" property="msg"/>
  41. </resultMap>
  42. <sql id="baseSql">
  43. id,
  44. companyNum,
  45. customerName,
  46. companyName,
  47. waybillNum,
  48. invoiceNum,
  49. invoiceCode,
  50. invoiceMakeTime,
  51. invoiceUrl,
  52. invoiceHtmlUrl,
  53. enStation,
  54. exStation,
  55. exTime,
  56. fee,
  57. totalTaxAmount,
  58. plateNum,
  59. vehicleType,
  60. sellerName,
  61. sellerTaxpayerCode,
  62. waybillStatus,
  63. waybillStartTime,
  64. waybillEndTime,
  65. totalAmount,
  66. taxRate,
  67. invoiceType,
  68. amount,
  69. transactionId,
  70. tradeMatchTime,
  71. buyerName,
  72. buyerTaxpayerCode,
  73. interType
  74. </sql>
  75. <select id="selectAllByPage" resultMap="BaseResultMap">
  76. select
  77. <include refid="baseSql" />,waybillStatus billStatus,calculateTime,invoiceStatus,msg
  78. from t_billInvoice
  79. <where>
  80. <if test="billInvoice.customerName != null and billInvoice.customerName != ''">
  81. and customerName = BINARY #{billInvoice.customerName}
  82. </if>
  83. <if test="billInvoice.companyName != null and billInvoice.companyName != ''">
  84. and buyerName = BINARY #{billInvoice.companyName}
  85. </if>
  86. <if test="billInvoice.invoiceStatus != null and billInvoice.invoiceStatus != ''">
  87. and invoiceStatus = BINARY #{billInvoice.invoiceStatus}
  88. </if>
  89. <if test="billInvoice.waybillNums != null">
  90. and waybillNum IN
  91. <foreach collection="billInvoice.waybillNums" item="billNum" index="index" separator="," open="(" close=")">
  92. #{billNum}
  93. </foreach>
  94. </if>
  95. <if test="billInvoice.buyerTaxpayerCode != null and billInvoice.buyerTaxpayerCode != ''">
  96. and buyerTaxpayerCode = BINARY #{billInvoice.buyerTaxpayerCode}
  97. </if>
  98. <if test="billInvoice.plateNums != null">
  99. and plateNum IN
  100. <foreach collection="billInvoice.plateNums" item="plateNum1" index="index" separator="," open="(" close=")">
  101. #{plateNum1}
  102. </foreach>
  103. </if>
  104. <if test="billInvoice.codeAndNumVos != null">
  105. and (invoiceCode,invoiceNum) IN
  106. <foreach collection="billInvoice.codeAndNumVos" item="codeAndNumVo" index="index" separator="," open="(" close=")">
  107. (#{codeAndNumVo.code},#{codeAndNumVo.num})
  108. </foreach>
  109. </if>
  110. <if test="billInvoice.codeAndNumVos == null">
  111. <if test="billInvoice.invoiceCode != null and billInvoice.invoiceCode != ''">
  112. and invoiceCode = #{billInvoice.invoiceCode}
  113. </if>
  114. <if test="billInvoice.invoiceNum != null and billInvoice.invoiceNum != ''">
  115. and invoiceNum = #{billInvoice.invoiceNum}
  116. </if>
  117. </if>
  118. <!-- <if test="billInvoice.invoiceCodes != null">
  119. and invoiceCode IN
  120. <foreach collection="billInvoice.invoiceCodes" item="invoiceCode" index="index" separator="," open="(" close=")">
  121. #{invoiceCode}
  122. </foreach>
  123. </if>
  124. <if test="billInvoice.invoiceNums != null">
  125. and invoiceNum in
  126. <foreach collection="billInvoice.invoiceNums" item="invoiceNum" index="index" separator="," open="(" close=")">
  127. #{invoiceNum}
  128. </foreach>
  129. </if>-->
  130. <if test="billInvoice.invoiceMakeStart != null and billInvoice.invoiceMakeStart != ''">
  131. and invoiceMakeTime BETWEEN #{billInvoice.invoiceMakeStart} and #{billInvoice.invoiceMakeEnd}
  132. </if>
  133. <if test="billInvoice.calculateTimeStart != null and billInvoice.calculateTimeStart != ''"> and
  134. calculateTime BETWEEN #{billInvoice.calculateTimeStart} and #{billInvoice.calculateTimeEnd}
  135. </if>
  136. </where>
  137. </select>
  138. <select id="selectAllByPageByBillInvoice" resultMap="BaseResultMap" parameterType="com.jkcredit.invoice.model.entity.invoice.BillInvoice">
  139. select
  140. <include refid="baseSql" />
  141. from t_billInvoice
  142. <where>
  143. <if test="waybillNum != null and waybillNum != ''">
  144. and waybillNum = BINARY #{waybillNum}
  145. </if>
  146. <if test="invoiceCode != null and invoiceCode != ''">
  147. and invoiceCode = BINARY #{invoiceCode}
  148. </if>
  149. <if test="invoiceNum != null and invoiceNum != ''">
  150. and invoiceNum = BINARY #{invoiceNum}
  151. </if>
  152. </where>
  153. </select>
  154. <insert id="insert" parameterType="com.jkcredit.invoice.model.entity.invoice.BillInvoice" >
  155. insert into t_billInvoice (
  156. companyNum,
  157. customerName,
  158. companyName,
  159. waybillNum,
  160. invoiceNum,
  161. invoiceCode,
  162. invoiceMakeTime,
  163. invoiceUrl,
  164. invoiceHtmlUrl,
  165. enStation,
  166. exStation,
  167. exTime,
  168. fee,
  169. totalTaxAmount,
  170. plateNum,
  171. vehicleType,
  172. sellerName,
  173. sellerTaxpayerCode,
  174. waybillStatus,
  175. waybillStartTime,
  176. waybillEndTime,
  177. totalAmount,
  178. taxRate,
  179. invoiceType,
  180. amount,
  181. transactionId,
  182. tradeMatchTime,
  183. buyerName,
  184. buyerTaxpayerCode,calculateTime,
  185. invoiceStatus,
  186. msg
  187. )
  188. values ( #{companyNum,jdbcType=VARCHAR},#{customerName,jdbcType=VARCHAR},#{companyName,jdbcType=VARCHAR},#{waybillNum,jdbcType=VARCHAR}, #{invoiceNum,jdbcType=VARCHAR},
  189. #{invoiceCode,jdbcType=VARCHAR}, #{invoiceMakeTime,jdbcType=VARCHAR}, #{invoiceUrl,jdbcType=VARCHAR},
  190. #{invoiceHtmlUrl,jdbcType=VARCHAR}, #{enStation,jdbcType=VARCHAR}, #{exStation,jdbcType=VARCHAR},
  191. #{exTime,jdbcType=VARCHAR}, #{fee,jdbcType=INTEGER}, #{totalTaxAmount,jdbcType=INTEGER},
  192. #{plateNum,jdbcType=VARCHAR},#{vehicleType,jdbcType=VARCHAR},#{sellerName,jdbcType=VARCHAR},
  193. #{sellerTaxpayerCode,jdbcType=VARCHAR},#{waybillStatus,jdbcType=INTEGER}, #{waybillStartTime,jdbcType=VARCHAR}, #{waybillEndTime,jdbcType=VARCHAR}
  194. , #{totalAmount,jdbcType=INTEGER}, #{taxRate,jdbcType=DOUBLE},#{invoiceType,jdbcType=VARCHAR},#{amount,jdbcType=INTEGER},
  195. #{transactionId,jdbcType=VARCHAR},#{tradeMatchTime,jdbcType=VARCHAR},#{buyerName,jdbcType=VARCHAR},#{buyerTaxpayerCode,jdbcType=VARCHAR}
  196. ,#{calculateTime,jdbcType=VARCHAR}
  197. ,#{invoiceStatus,jdbcType=INTEGER}
  198. ,#{msg,jdbcType=VARCHAR}
  199. )
  200. </insert>
  201. <update id="updateByPrimaryKey" parameterType="com.jkcredit.invoice.model.entity.invoice.BillInvoice" >
  202. update t_billInvoice
  203. set
  204. companyNum = #{companyNum,jdbcType=VARCHAR},
  205. customerName = #{customerName,jdbcType=VARCHAR},
  206. companyName = #{companyName,jdbcType=VARCHAR},
  207. waybillNum = #{waybillNum,jdbcType=VARCHAR},
  208. invoiceNum = #{invoiceNum,jdbcType=VARCHAR},
  209. invoiceCode = #{invoiceCode,jdbcType=VARCHAR},
  210. invoiceMakeTime = #{invoiceMakeTime,jdbcType=VARCHAR},
  211. invoiceUrl = #{invoiceUrl,jdbcType=VARCHAR},
  212. invoiceHtmlUrl = #{invoiceHtmlUrl,jdbcType=VARCHAR},
  213. enStation = #{enStation,jdbcType=VARCHAR},
  214. exStation = #{exStation,jdbcType=VARCHAR},
  215. exTime = #{exTime,jdbcType=VARCHAR},
  216. fee = #{fee,jdbcType=INTEGER},
  217. totalTaxAmount = #{totalTaxAmount,jdbcType=INTEGER},
  218. plateNum = #{plateNum,jdbcType=VARCHAR},
  219. vehicleType = #{vehicleType,jdbcType=INTEGER},
  220. sellerName = #{sellerName,jdbcType=VARCHAR},
  221. sellerTaxpayerCode = #{sellerTaxpayerCode,jdbcType=VARCHAR},
  222. waybillStatus = #{waybillStatus,jdbcType=INTEGER},
  223. waybillStartTime = #{waybillStartTime,jdbcType=VARCHAR},
  224. waybillEndTime = #{waybillEndTime,jdbcType=VARCHAR},
  225. totalAmount = #{totalAmount,jdbcType=INTEGER},
  226. taxRate = #{taxRate,jdbcType=DOUBLE},
  227. invoiceType = #{invoiceType,jdbcType=VARCHAR},
  228. amount = #{amount,jdbcType=INTEGER},
  229. transactionId = #{transactionId,jdbcType=VARCHAR},
  230. tradeMatchTime = #{tradeMatchTime,jdbcType=VARCHAR},
  231. buyerName = #{buyerName,jdbcType=VARCHAR},
  232. buyerTaxpayerCode = #{buyerTaxpayerCode,jdbcType=VARCHAR},
  233. calculateTime = #{calculateTime,jdbcType=VARCHAR}
  234. where id = #{id,jdbcType=INTEGER}
  235. </update>
  236. <update id="updateByInvoiceNum" parameterType="com.jkcredit.invoice.model.entity.invoice.BillInvoice" >
  237. update t_billInvoice
  238. set companyNum = #{companyNum,jdbcType=VARCHAR},
  239. customerName = #{customerName,jdbcType=VARCHAR},
  240. companyName = #{companyName,jdbcType=VARCHAR},
  241. waybillNum = #{waybillNum,jdbcType=VARCHAR},
  242. invoiceNum = #{invoiceNum,jdbcType=VARCHAR},
  243. invoiceCode = #{invoiceCode,jdbcType=VARCHAR},
  244. invoiceMakeTime = #{invoiceMakeTime,jdbcType=VARCHAR},
  245. invoiceUrl = #{invoiceUrl,jdbcType=VARCHAR},
  246. invoiceHtmlUrl = #{invoiceHtmlUrl,jdbcType=VARCHAR},
  247. enStation = #{enStation,jdbcType=VARCHAR},
  248. exStation = #{exStation,jdbcType=VARCHAR},
  249. exTime = #{exTime,jdbcType=VARCHAR},
  250. fee = #{fee,jdbcType=INTEGER},
  251. totalTaxAmount = #{totalTaxAmount,jdbcType=INTEGER},
  252. plateNum = #{plateNum,jdbcType=VARCHAR},
  253. vehicleType = #{vehicleType,jdbcType=INTEGER},
  254. sellerName = #{sellerName,jdbcType=VARCHAR},
  255. sellerTaxpayerCode = #{sellerTaxpayerCode,jdbcType=VARCHAR},
  256. waybillStatus = #{waybillStatus,jdbcType=INTEGER},
  257. waybillStartTime = #{waybillStartTime,jdbcType=VARCHAR},
  258. waybillEndTime = #{waybillEndTime,jdbcType=VARCHAR},
  259. totalAmount = #{totalAmount,jdbcType=INTEGER},
  260. taxRate = #{taxRate,jdbcType=DOUBLE},
  261. invoiceType = #{invoiceType,jdbcType=VARCHAR},
  262. amount = #{amount,jdbcType=INTEGER},
  263. transactionId = #{transactionId,jdbcType=VARCHAR},
  264. tradeMatchTime = #{tradeMatchTime,jdbcType=VARCHAR},
  265. buyerName = #{buyerName,jdbcType=VARCHAR},
  266. buyerTaxpayerCode = #{buyerTaxpayerCode,jdbcType=VARCHAR},
  267. calculateTime = #{calculateTime,jdbcType=VARCHAR}
  268. where invoiceNum = BINARY #{invoiceNum,jdbcType=VARCHAR}
  269. </update>
  270. <select id="selectByBillNum" resultMap="BaseResultMap" parameterType="java.lang.String" >
  271. select
  272. <include refid="baseSql" />,calculateTime,invoiceStatus,msg
  273. from t_billInvoice
  274. where waybillNum = BINARY #{waybillNum,jdbcType=VARCHAR}
  275. </select>
  276. <select id="selectByInvoiceNum" resultMap="BaseResultMap" parameterType="java.lang.String" >
  277. select
  278. <include refid="baseSql" />,calculateTime
  279. from t_billInvoice
  280. where invoiceNum = BINARY #{invoiceNum,jdbcType=VARCHAR}
  281. </select>
  282. <delete id="deleteByBillNum" parameterType="java.lang.String">
  283. DELETE from t_billInvoice WHERE waybillNum = BINARY #{waybillNum,jdbcType=VARCHAR}
  284. </delete>
  285. <resultMap id="staticResultMap" type="java.util.Map">
  286. <result column="fee" property="fee"/>
  287. <result column="totalTaxAmount" property="totalTaxAmount"/>
  288. <result column="feeCount" property="feeCount"/>
  289. </resultMap>
  290. <select id="findInvoiceStatics" resultMap="staticResultMap">
  291. select
  292. (CASE WHEN sum(totalAmount) = '' THEN 0
  293. WHEN sum(totalAmount) is null THEN 0
  294. WHEN sum(totalAmount) is not null THEN sum(totalAmount)
  295. ELSE sum(totalAmount) END)as fee,
  296. (CASE WHEN sum(totalTaxAmount) = '' THEN 0
  297. WHEN sum(totalTaxAmount) is null THEN 0
  298. WHEN sum(totalTaxAmount) is not null THEN sum(totalTaxAmount)
  299. ELSE sum(totalTaxAmount) END)as totalTaxAmount,
  300. count(DISTINCT(transactionId)) feeCount
  301. from t_billInvoice
  302. <where>
  303. <if test="billInvoice.customerName != null and billInvoice.customerName != ''">
  304. and customerName = BINARY #{billInvoice.customerName}
  305. </if>
  306. <if test="billInvoice.companyName != null and billInvoice.companyName != ''">
  307. and buyerName = BINARY #{billInvoice.companyName}
  308. </if>
  309. <if test="billInvoice.waybillNum != null and billInvoice.waybillNum != ''">
  310. and waybillNum = BINARY #{billInvoice.waybillNum}
  311. </if>
  312. <if test="billInvoice.plateNum != null and billInvoice.plateNum != ''">
  313. and plateNum = BINARY #{billInvoice.plateNum}
  314. </if>
  315. <if test="billInvoice.invoiceCode != null and billInvoice.invoiceCode != ''">
  316. and invoiceCode = BINARY #{billInvoice.invoiceCode}
  317. </if>
  318. <if test="billInvoice.invoiceNum != null and billInvoice.invoiceNum != ''">
  319. and invoiceNum = BINARY #{billInvoice.invoiceNum}
  320. </if>
  321. <if test="billInvoice.invoiceMakeStart != null and billInvoice.invoiceMakeStart != ''">
  322. and invoiceMakeTime BETWEEN #{billInvoice.invoiceMakeStart} and #{billInvoice.invoiceMakeEnd}
  323. </if>
  324. <if test="billInvoice.calculateTimeStart != null and billInvoice.calculateTimeStart != ''"> and
  325. calculateTime BETWEEN #{billInvoice.calculateTimeStart} and #{billInvoice.calculateTimeEnd}
  326. </if>
  327. </where>
  328. </select>
  329. <select id="selectNoCarNoVoiceQuery" resultMap="BaseResultMap" parameterType="java.lang.String" >
  330. select
  331. <include refid="baseSql" />
  332. from t_billInvoice
  333. where customerName = BINARY #{customerName,jdbcType=VARCHAR}
  334. </select>
  335. <update id="upDateCompany" parameterType="com.jkcredit.invoice.model.vo.CompanyVo">
  336. UPDATE t_billInvoice set companyName = #{newCompanyName} where companyName = #{oldCompanyName}
  337. </update>
  338. </mapper>