BillInvoiceMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  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.plateNum != null and billInvoice.plateNum != ''">
  99. and plateNum = BINARY #{billInvoice.plateNum}
  100. </if>
  101. <if test="billInvoice.codeAndNumVos != null">
  102. and (invoiceCode,invoiceNum) IN
  103. <foreach collection="billInvoice.codeAndNumVos" item="codeAndNumVo" index="index" separator="," open="(" close=")">
  104. (#{codeAndNumVo.code},#{codeAndNumVo.num})
  105. </foreach>
  106. </if>
  107. <if test="billInvoice.codeAndNumVos == null">
  108. <if test="billInvoice.invoiceCode != null and billInvoice.invoiceCode != ''">
  109. and invoiceCode = #{billInvoice.invoiceCode}
  110. </if>
  111. <if test="billInvoice.invoiceNum != null and billInvoice.invoiceNum != ''">
  112. and invoiceNum = #{billInvoice.invoiceNum}
  113. </if>
  114. </if>
  115. <!-- <if test="billInvoice.invoiceCodes != null">
  116. and invoiceCode IN
  117. <foreach collection="billInvoice.invoiceCodes" item="invoiceCode" index="index" separator="," open="(" close=")">
  118. #{invoiceCode}
  119. </foreach>
  120. </if>
  121. <if test="billInvoice.invoiceNums != null">
  122. and invoiceNum in
  123. <foreach collection="billInvoice.invoiceNums" item="invoiceNum" index="index" separator="," open="(" close=")">
  124. #{invoiceNum}
  125. </foreach>
  126. </if>-->
  127. <if test="billInvoice.invoiceMakeStart != null and billInvoice.invoiceMakeStart != ''">
  128. and invoiceMakeTime BETWEEN #{billInvoice.invoiceMakeStart} and #{billInvoice.invoiceMakeEnd}
  129. </if>
  130. <if test="billInvoice.calculateTimeStart != null and billInvoice.calculateTimeStart != ''"> and
  131. calculateTime BETWEEN #{billInvoice.calculateTimeStart} and #{billInvoice.calculateTimeEnd}
  132. </if>
  133. </where>
  134. </select>
  135. <select id="selectAllByPageByBillInvoice" resultMap="BaseResultMap" parameterType="com.jkcredit.invoice.model.entity.invoice.BillInvoice">
  136. select
  137. <include refid="baseSql" />
  138. from t_billInvoice
  139. <where>
  140. <if test="waybillNum != null and waybillNum != ''">
  141. and waybillNum = BINARY #{waybillNum}
  142. </if>
  143. <if test="invoiceCode != null and invoiceCode != ''">
  144. and invoiceCode = BINARY #{invoiceCode}
  145. </if>
  146. <if test="invoiceNum != null and invoiceNum != ''">
  147. and invoiceNum = BINARY #{invoiceNum}
  148. </if>
  149. </where>
  150. </select>
  151. <insert id="insert" parameterType="com.jkcredit.invoice.model.entity.invoice.BillInvoice" >
  152. insert into t_billInvoice (
  153. companyNum,
  154. customerName,
  155. companyName,
  156. waybillNum,
  157. invoiceNum,
  158. invoiceCode,
  159. invoiceMakeTime,
  160. invoiceUrl,
  161. invoiceHtmlUrl,
  162. enStation,
  163. exStation,
  164. exTime,
  165. fee,
  166. totalTaxAmount,
  167. plateNum,
  168. vehicleType,
  169. sellerName,
  170. sellerTaxpayerCode,
  171. waybillStatus,
  172. waybillStartTime,
  173. waybillEndTime,
  174. totalAmount,
  175. taxRate,
  176. invoiceType,
  177. amount,
  178. transactionId,
  179. tradeMatchTime,
  180. buyerName,
  181. buyerTaxpayerCode,calculateTime,
  182. invoiceStatus,
  183. msg
  184. )
  185. values ( #{companyNum,jdbcType=VARCHAR},#{customerName,jdbcType=VARCHAR},#{companyName,jdbcType=VARCHAR},#{waybillNum,jdbcType=VARCHAR}, #{invoiceNum,jdbcType=VARCHAR},
  186. #{invoiceCode,jdbcType=VARCHAR}, #{invoiceMakeTime,jdbcType=VARCHAR}, #{invoiceUrl,jdbcType=VARCHAR},
  187. #{invoiceHtmlUrl,jdbcType=VARCHAR}, #{enStation,jdbcType=VARCHAR}, #{exStation,jdbcType=VARCHAR},
  188. #{exTime,jdbcType=VARCHAR}, #{fee,jdbcType=INTEGER}, #{totalTaxAmount,jdbcType=INTEGER},
  189. #{plateNum,jdbcType=VARCHAR},#{vehicleType,jdbcType=VARCHAR},#{sellerName,jdbcType=VARCHAR},
  190. #{sellerTaxpayerCode,jdbcType=VARCHAR},#{waybillStatus,jdbcType=INTEGER}, #{waybillStartTime,jdbcType=VARCHAR}, #{waybillEndTime,jdbcType=VARCHAR}
  191. , #{totalAmount,jdbcType=INTEGER}, #{taxRate,jdbcType=DOUBLE},#{invoiceType,jdbcType=VARCHAR},#{amount,jdbcType=INTEGER},
  192. #{transactionId,jdbcType=VARCHAR},#{tradeMatchTime,jdbcType=VARCHAR},#{buyerName,jdbcType=VARCHAR},#{buyerTaxpayerCode,jdbcType=VARCHAR}
  193. ,#{calculateTime,jdbcType=VARCHAR}
  194. ,#{invoiceStatus,jdbcType=INTEGER}
  195. ,#{msg,jdbcType=VARCHAR}
  196. )
  197. </insert>
  198. <update id="updateByPrimaryKey" parameterType="com.jkcredit.invoice.model.entity.invoice.BillInvoice" >
  199. update t_billInvoice
  200. set
  201. companyNum = #{companyNum,jdbcType=VARCHAR},
  202. customerName = #{customerName,jdbcType=VARCHAR},
  203. companyName = #{companyName,jdbcType=VARCHAR},
  204. waybillNum = #{waybillNum,jdbcType=VARCHAR},
  205. invoiceNum = #{invoiceNum,jdbcType=VARCHAR},
  206. invoiceCode = #{invoiceCode,jdbcType=VARCHAR},
  207. invoiceMakeTime = #{invoiceMakeTime,jdbcType=VARCHAR},
  208. invoiceUrl = #{invoiceUrl,jdbcType=VARCHAR},
  209. invoiceHtmlUrl = #{invoiceHtmlUrl,jdbcType=VARCHAR},
  210. enStation = #{enStation,jdbcType=VARCHAR},
  211. exStation = #{exStation,jdbcType=VARCHAR},
  212. exTime = #{exTime,jdbcType=VARCHAR},
  213. fee = #{fee,jdbcType=INTEGER},
  214. totalTaxAmount = #{totalTaxAmount,jdbcType=INTEGER},
  215. plateNum = #{plateNum,jdbcType=VARCHAR},
  216. vehicleType = #{vehicleType,jdbcType=INTEGER},
  217. sellerName = #{sellerName,jdbcType=VARCHAR},
  218. sellerTaxpayerCode = #{sellerTaxpayerCode,jdbcType=VARCHAR},
  219. waybillStatus = #{waybillStatus,jdbcType=INTEGER},
  220. waybillStartTime = #{waybillStartTime,jdbcType=VARCHAR},
  221. waybillEndTime = #{waybillEndTime,jdbcType=VARCHAR},
  222. totalAmount = #{totalAmount,jdbcType=INTEGER},
  223. taxRate = #{taxRate,jdbcType=DOUBLE},
  224. invoiceType = #{invoiceType,jdbcType=VARCHAR},
  225. amount = #{amount,jdbcType=INTEGER},
  226. transactionId = #{transactionId,jdbcType=VARCHAR},
  227. tradeMatchTime = #{tradeMatchTime,jdbcType=VARCHAR},
  228. buyerName = #{buyerName,jdbcType=VARCHAR},
  229. buyerTaxpayerCode = #{buyerTaxpayerCode,jdbcType=VARCHAR},
  230. calculateTime = #{calculateTime,jdbcType=VARCHAR}
  231. where id = #{id,jdbcType=INTEGER}
  232. </update>
  233. <update id="updateByInvoiceNum" parameterType="com.jkcredit.invoice.model.entity.invoice.BillInvoice" >
  234. update t_billInvoice
  235. set companyNum = #{companyNum,jdbcType=VARCHAR},
  236. customerName = #{customerName,jdbcType=VARCHAR},
  237. companyName = #{companyName,jdbcType=VARCHAR},
  238. waybillNum = #{waybillNum,jdbcType=VARCHAR},
  239. invoiceNum = #{invoiceNum,jdbcType=VARCHAR},
  240. invoiceCode = #{invoiceCode,jdbcType=VARCHAR},
  241. invoiceMakeTime = #{invoiceMakeTime,jdbcType=VARCHAR},
  242. invoiceUrl = #{invoiceUrl,jdbcType=VARCHAR},
  243. invoiceHtmlUrl = #{invoiceHtmlUrl,jdbcType=VARCHAR},
  244. enStation = #{enStation,jdbcType=VARCHAR},
  245. exStation = #{exStation,jdbcType=VARCHAR},
  246. exTime = #{exTime,jdbcType=VARCHAR},
  247. fee = #{fee,jdbcType=INTEGER},
  248. totalTaxAmount = #{totalTaxAmount,jdbcType=INTEGER},
  249. plateNum = #{plateNum,jdbcType=VARCHAR},
  250. vehicleType = #{vehicleType,jdbcType=INTEGER},
  251. sellerName = #{sellerName,jdbcType=VARCHAR},
  252. sellerTaxpayerCode = #{sellerTaxpayerCode,jdbcType=VARCHAR},
  253. waybillStatus = #{waybillStatus,jdbcType=INTEGER},
  254. waybillStartTime = #{waybillStartTime,jdbcType=VARCHAR},
  255. waybillEndTime = #{waybillEndTime,jdbcType=VARCHAR},
  256. totalAmount = #{totalAmount,jdbcType=INTEGER},
  257. taxRate = #{taxRate,jdbcType=DOUBLE},
  258. invoiceType = #{invoiceType,jdbcType=VARCHAR},
  259. amount = #{amount,jdbcType=INTEGER},
  260. transactionId = #{transactionId,jdbcType=VARCHAR},
  261. tradeMatchTime = #{tradeMatchTime,jdbcType=VARCHAR},
  262. buyerName = #{buyerName,jdbcType=VARCHAR},
  263. buyerTaxpayerCode = #{buyerTaxpayerCode,jdbcType=VARCHAR},
  264. calculateTime = #{calculateTime,jdbcType=VARCHAR}
  265. where invoiceNum = BINARY #{invoiceNum,jdbcType=VARCHAR}
  266. </update>
  267. <select id="selectByBillNum" resultMap="BaseResultMap" parameterType="java.lang.String" >
  268. select
  269. <include refid="baseSql" />,calculateTime,invoiceStatus,msg
  270. from t_billInvoice
  271. where waybillNum = BINARY #{waybillNum,jdbcType=VARCHAR}
  272. </select>
  273. <select id="selectByInvoiceNum" resultMap="BaseResultMap" parameterType="java.lang.String" >
  274. select
  275. <include refid="baseSql" />,calculateTime
  276. from t_billInvoice
  277. where invoiceNum = BINARY #{invoiceNum,jdbcType=VARCHAR}
  278. </select>
  279. <delete id="deleteByBillNum" parameterType="java.lang.String">
  280. DELETE from t_billInvoice WHERE waybillNum = BINARY #{waybillNum,jdbcType=VARCHAR}
  281. </delete>
  282. <resultMap id="staticResultMap" type="java.util.Map">
  283. <result column="fee" property="fee"/>
  284. <result column="totalTaxAmount" property="totalTaxAmount"/>
  285. <result column="feeCount" property="feeCount"/>
  286. </resultMap>
  287. <select id="findInvoiceStatics" resultMap="staticResultMap">
  288. select
  289. (CASE WHEN sum(totalAmount) = '' THEN 0
  290. WHEN sum(totalAmount) is null THEN 0
  291. WHEN sum(totalAmount) is not null THEN sum(totalAmount)
  292. ELSE sum(totalAmount) END)as fee,
  293. (CASE WHEN sum(totalTaxAmount) = '' THEN 0
  294. WHEN sum(totalTaxAmount) is null THEN 0
  295. WHEN sum(totalTaxAmount) is not null THEN sum(totalTaxAmount)
  296. ELSE sum(totalTaxAmount) END)as totalTaxAmount,
  297. count(DISTINCT(transactionId)) feeCount
  298. from t_billInvoice
  299. <where>
  300. <if test="billInvoice.companyName != null and billInvoice.companyName != ''">
  301. and buyerName = BINARY #{billInvoice.companyName}
  302. </if>
  303. <if test="billInvoice.waybillNum != null and billInvoice.waybillNum != ''">
  304. and waybillNum = BINARY #{billInvoice.waybillNum}
  305. </if>
  306. <if test="billInvoice.plateNum != null and billInvoice.plateNum != ''">
  307. and plateNum = BINARY #{billInvoice.plateNum}
  308. </if>
  309. <if test="billInvoice.invoiceCode != null and billInvoice.invoiceCode != ''">
  310. and invoiceCode = BINARY #{billInvoice.invoiceCode}
  311. </if>
  312. <if test="billInvoice.invoiceNum != null and billInvoice.invoiceNum != ''">
  313. and invoiceNum = BINARY #{billInvoice.invoiceNum}
  314. </if>
  315. <if test="billInvoice.invoiceMakeStart != null and billInvoice.invoiceMakeStart != ''">
  316. and invoiceMakeTime BETWEEN #{billInvoice.invoiceMakeStart} and #{billInvoice.invoiceMakeEnd}
  317. </if>
  318. <if test="billInvoice.calculateTimeStart != null and billInvoice.calculateTimeStart != ''"> and
  319. calculateTime BETWEEN #{billInvoice.calculateTimeStart} and #{billInvoice.calculateTimeEnd}
  320. </if>
  321. </where>
  322. </select>
  323. <select id="selectNoCarNoVoiceQuery" resultMap="BaseResultMap" parameterType="java.lang.String" >
  324. select
  325. <include refid="baseSql" />
  326. from t_billInvoice
  327. where customerName = BINARY #{customerName,jdbcType=VARCHAR}
  328. </select>
  329. <update id="upDateCompany" parameterType="com.jkcredit.invoice.model.vo.CompanyVo">
  330. UPDATE t_billInvoice set companyName = #{newCompanyName} where companyName = #{oldCompanyName}
  331. </update>
  332. </mapper>