TOrderInvoiceMapper.xml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  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.goafanti.common.dao.TOrderInvoiceMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.TOrderInvoice">
  5. <id column="id" jdbcType="INTEGER" property="id" />
  6. <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
  7. <result column="type" jdbcType="INTEGER" property="type" />
  8. <result column="status" jdbcType="INTEGER" property="status" />
  9. <result column="reject_reason" jdbcType="VARCHAR" property="rejectReason" />
  10. <result column="remarks" jdbcType="VARCHAR" property="remarks" />
  11. <result column="invoice_type" jdbcType="INTEGER" property="invoiceType" />
  12. <result column="unit_name" jdbcType="VARCHAR" property="unitName" />
  13. <result column="tax_number" jdbcType="VARCHAR" property="taxNumber" />
  14. <result column="amount" jdbcType="DECIMAL" property="amount" />
  15. <result column="banks" jdbcType="VARCHAR" property="banks" />
  16. <result column="content" jdbcType="VARCHAR" property="content" />
  17. <result column="unit_address" jdbcType="VARCHAR" property="unitAddress" />
  18. <result column="invoice_remarks" jdbcType="VARCHAR" property="invoiceRemarks" />
  19. <result column="unit_mobile" jdbcType="VARCHAR" property="unitMobile" />
  20. <result column="voucher_url" jdbcType="VARCHAR" property="voucherUrl" />
  21. <result column="post" jdbcType="INTEGER" property="post" />
  22. <result column="addressee" jdbcType="VARCHAR" property="addressee" />
  23. <result column="addressee_mobile" jdbcType="VARCHAR" property="addresseeMobile" />
  24. <result column="addressee_province" jdbcType="INTEGER" property="addresseeProvince" />
  25. <result column="addressee_city" jdbcType="INTEGER" property="addresseeCity" />
  26. <result column="addressee_area" jdbcType="INTEGER" property="addresseeArea" />
  27. <result column="recipient_address" jdbcType="VARCHAR" property="recipientAddress" />
  28. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  29. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  30. <result column="approval" jdbcType="INTEGER" property="approval" />
  31. <result column="already_amount" jdbcType="DECIMAL" property="alreadyAmount" />
  32. <result column="examine_name" jdbcType="VARCHAR" property="examineName" />
  33. </resultMap>
  34. <sql id="Base_Column_List">
  35. id, order_no, `type`, `status`, reject_reason, remarks, invoice_type, unit_name,
  36. tax_number, amount, banks, content, unit_address, invoice_remarks, unit_mobile, voucher_url,
  37. post, addressee, addressee_mobile, addressee_province, addressee_city, addressee_area,
  38. recipient_address, create_time, update_time, approval, already_amount, examine_name
  39. </sql>
  40. <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  41. select
  42. <include refid="Base_Column_List" />
  43. from t_order_invoice
  44. where id = #{id,jdbcType=INTEGER}
  45. </select>
  46. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  47. delete from t_order_invoice
  48. where id = #{id,jdbcType=INTEGER}
  49. </delete>
  50. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TOrderInvoice" useGeneratedKeys="true">
  51. insert into t_order_invoice (order_no, `type`, `status`,
  52. reject_reason, remarks, invoice_type,
  53. unit_name, tax_number, amount,
  54. banks, content, unit_address,
  55. invoice_remarks, unit_mobile, voucher_url,
  56. post, addressee, addressee_mobile,
  57. addressee_province, addressee_city, addressee_area,
  58. recipient_address, create_time, update_time,
  59. approval, already_amount, examine_name
  60. )
  61. values (#{orderNo,jdbcType=VARCHAR}, #{type,jdbcType=INTEGER}, #{status,jdbcType=INTEGER},
  62. #{rejectReason,jdbcType=VARCHAR}, #{remarks,jdbcType=VARCHAR}, #{invoiceType,jdbcType=INTEGER},
  63. #{unitName,jdbcType=VARCHAR}, #{taxNumber,jdbcType=VARCHAR}, #{amount,jdbcType=DECIMAL},
  64. #{banks,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, #{unitAddress,jdbcType=VARCHAR},
  65. #{invoiceRemarks,jdbcType=VARCHAR}, #{unitMobile,jdbcType=VARCHAR}, #{voucherUrl,jdbcType=VARCHAR},
  66. #{post,jdbcType=INTEGER}, #{addressee,jdbcType=VARCHAR}, #{addresseeMobile,jdbcType=VARCHAR},
  67. #{addresseeProvince,jdbcType=INTEGER}, #{addresseeCity,jdbcType=INTEGER}, #{addresseeArea,jdbcType=INTEGER},
  68. #{recipientAddress,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
  69. #{approval,jdbcType=INTEGER}, #{alreadyAmount,jdbcType=DECIMAL}, #{examineName,jdbcType=VARCHAR}
  70. )
  71. </insert>
  72. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TOrderInvoice" useGeneratedKeys="true">
  73. insert into t_order_invoice
  74. <trim prefix="(" suffix=")" suffixOverrides=",">
  75. <if test="orderNo != null">
  76. order_no,
  77. </if>
  78. <if test="type != null">
  79. `type`,
  80. </if>
  81. <if test="status != null">
  82. `status`,
  83. </if>
  84. <if test="rejectReason != null">
  85. reject_reason,
  86. </if>
  87. <if test="remarks != null">
  88. remarks,
  89. </if>
  90. <if test="invoiceType != null">
  91. invoice_type,
  92. </if>
  93. <if test="unitName != null">
  94. unit_name,
  95. </if>
  96. <if test="taxNumber != null">
  97. tax_number,
  98. </if>
  99. <if test="amount != null">
  100. amount,
  101. </if>
  102. <if test="banks != null">
  103. banks,
  104. </if>
  105. <if test="content != null">
  106. content,
  107. </if>
  108. <if test="unitAddress != null">
  109. unit_address,
  110. </if>
  111. <if test="invoiceRemarks != null">
  112. invoice_remarks,
  113. </if>
  114. <if test="unitMobile != null">
  115. unit_mobile,
  116. </if>
  117. <if test="voucherUrl != null">
  118. voucher_url,
  119. </if>
  120. <if test="post != null">
  121. post,
  122. </if>
  123. <if test="addressee != null">
  124. addressee,
  125. </if>
  126. <if test="addresseeMobile != null">
  127. addressee_mobile,
  128. </if>
  129. <if test="addresseeProvince != null">
  130. addressee_province,
  131. </if>
  132. <if test="addresseeCity != null">
  133. addressee_city,
  134. </if>
  135. <if test="addresseeArea != null">
  136. addressee_area,
  137. </if>
  138. <if test="recipientAddress != null">
  139. recipient_address,
  140. </if>
  141. <if test="createTime != null">
  142. create_time,
  143. </if>
  144. <if test="updateTime != null">
  145. update_time,
  146. </if>
  147. <if test="approval != null">
  148. approval,
  149. </if>
  150. <if test="alreadyAmount != null">
  151. already_amount,
  152. </if>
  153. <if test="examineName != null">
  154. examine_name,
  155. </if>
  156. </trim>
  157. <trim prefix="values (" suffix=")" suffixOverrides=",">
  158. <if test="orderNo != null">
  159. #{orderNo,jdbcType=VARCHAR},
  160. </if>
  161. <if test="type != null">
  162. #{type,jdbcType=INTEGER},
  163. </if>
  164. <if test="status != null">
  165. #{status,jdbcType=INTEGER},
  166. </if>
  167. <if test="rejectReason != null">
  168. #{rejectReason,jdbcType=VARCHAR},
  169. </if>
  170. <if test="remarks != null">
  171. #{remarks,jdbcType=VARCHAR},
  172. </if>
  173. <if test="invoiceType != null">
  174. #{invoiceType,jdbcType=INTEGER},
  175. </if>
  176. <if test="unitName != null">
  177. #{unitName,jdbcType=VARCHAR},
  178. </if>
  179. <if test="taxNumber != null">
  180. #{taxNumber,jdbcType=VARCHAR},
  181. </if>
  182. <if test="amount != null">
  183. #{amount,jdbcType=DECIMAL},
  184. </if>
  185. <if test="banks != null">
  186. #{banks,jdbcType=VARCHAR},
  187. </if>
  188. <if test="content != null">
  189. #{content,jdbcType=VARCHAR},
  190. </if>
  191. <if test="unitAddress != null">
  192. #{unitAddress,jdbcType=VARCHAR},
  193. </if>
  194. <if test="invoiceRemarks != null">
  195. #{invoiceRemarks,jdbcType=VARCHAR},
  196. </if>
  197. <if test="unitMobile != null">
  198. #{unitMobile,jdbcType=VARCHAR},
  199. </if>
  200. <if test="voucherUrl != null">
  201. #{voucherUrl,jdbcType=VARCHAR},
  202. </if>
  203. <if test="post != null">
  204. #{post,jdbcType=INTEGER},
  205. </if>
  206. <if test="addressee != null">
  207. #{addressee,jdbcType=VARCHAR},
  208. </if>
  209. <if test="addresseeMobile != null">
  210. #{addresseeMobile,jdbcType=VARCHAR},
  211. </if>
  212. <if test="addresseeProvince != null">
  213. #{addresseeProvince,jdbcType=INTEGER},
  214. </if>
  215. <if test="addresseeCity != null">
  216. #{addresseeCity,jdbcType=INTEGER},
  217. </if>
  218. <if test="addresseeArea != null">
  219. #{addresseeArea,jdbcType=INTEGER},
  220. </if>
  221. <if test="recipientAddress != null">
  222. #{recipientAddress,jdbcType=VARCHAR},
  223. </if>
  224. <if test="createTime != null">
  225. #{createTime,jdbcType=TIMESTAMP},
  226. </if>
  227. <if test="updateTime != null">
  228. #{updateTime,jdbcType=TIMESTAMP},
  229. </if>
  230. <if test="approval != null">
  231. #{approval,jdbcType=INTEGER},
  232. </if>
  233. <if test="alreadyAmount != null">
  234. #{alreadyAmount,jdbcType=DECIMAL},
  235. </if>
  236. <if test="examineName != null">
  237. #{examineName,jdbcType=VARCHAR},
  238. </if>
  239. </trim>
  240. </insert>
  241. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.TOrderInvoice">
  242. update t_order_invoice
  243. <set>
  244. <if test="orderNo != null">
  245. order_no = #{orderNo,jdbcType=VARCHAR},
  246. </if>
  247. <if test="type != null">
  248. `type` = #{type,jdbcType=INTEGER},
  249. </if>
  250. <if test="status != null">
  251. `status` = #{status,jdbcType=INTEGER},
  252. </if>
  253. <if test="rejectReason != null">
  254. reject_reason = #{rejectReason,jdbcType=VARCHAR},
  255. </if>
  256. <if test="remarks != null">
  257. remarks = #{remarks,jdbcType=VARCHAR},
  258. </if>
  259. <if test="invoiceType != null">
  260. invoice_type = #{invoiceType,jdbcType=INTEGER},
  261. </if>
  262. <if test="unitName != null">
  263. unit_name = #{unitName,jdbcType=VARCHAR},
  264. </if>
  265. <if test="taxNumber != null">
  266. tax_number = #{taxNumber,jdbcType=VARCHAR},
  267. </if>
  268. <if test="amount != null">
  269. amount = #{amount,jdbcType=DECIMAL},
  270. </if>
  271. <if test="banks != null">
  272. banks = #{banks,jdbcType=VARCHAR},
  273. </if>
  274. <if test="content != null">
  275. content = #{content,jdbcType=VARCHAR},
  276. </if>
  277. <if test="unitAddress != null">
  278. unit_address = #{unitAddress,jdbcType=VARCHAR},
  279. </if>
  280. <if test="invoiceRemarks != null">
  281. invoice_remarks = #{invoiceRemarks,jdbcType=VARCHAR},
  282. </if>
  283. <if test="unitMobile != null">
  284. unit_mobile = #{unitMobile,jdbcType=VARCHAR},
  285. </if>
  286. <if test="voucherUrl != null">
  287. voucher_url = #{voucherUrl,jdbcType=VARCHAR},
  288. </if>
  289. <if test="post != null">
  290. post = #{post,jdbcType=INTEGER},
  291. </if>
  292. <if test="addressee != null">
  293. addressee = #{addressee,jdbcType=VARCHAR},
  294. </if>
  295. <if test="addresseeMobile != null">
  296. addressee_mobile = #{addresseeMobile,jdbcType=VARCHAR},
  297. </if>
  298. <if test="addresseeProvince != null">
  299. addressee_province = #{addresseeProvince,jdbcType=INTEGER},
  300. </if>
  301. <if test="addresseeCity != null">
  302. addressee_city = #{addresseeCity,jdbcType=INTEGER},
  303. </if>
  304. <if test="addresseeArea != null">
  305. addressee_area = #{addresseeArea,jdbcType=INTEGER},
  306. </if>
  307. <if test="recipientAddress != null">
  308. recipient_address = #{recipientAddress,jdbcType=VARCHAR},
  309. </if>
  310. <if test="createTime != null">
  311. create_time = #{createTime,jdbcType=TIMESTAMP},
  312. </if>
  313. <if test="updateTime != null">
  314. update_time = #{updateTime,jdbcType=TIMESTAMP},
  315. </if>
  316. <if test="approval != null">
  317. approval = #{approval,jdbcType=INTEGER},
  318. </if>
  319. <if test="alreadyAmount != null">
  320. already_amount = #{alreadyAmount,jdbcType=DECIMAL},
  321. </if>
  322. <if test="examineName != null">
  323. examine_name = #{examineName,jdbcType=VARCHAR},
  324. </if>
  325. </set>
  326. where id = #{id,jdbcType=INTEGER}
  327. </update>
  328. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.TOrderInvoice">
  329. update t_order_invoice
  330. set order_no = #{orderNo,jdbcType=VARCHAR},
  331. `type` = #{type,jdbcType=INTEGER},
  332. `status` = #{status,jdbcType=INTEGER},
  333. reject_reason = #{rejectReason,jdbcType=VARCHAR},
  334. remarks = #{remarks,jdbcType=VARCHAR},
  335. invoice_type = #{invoiceType,jdbcType=INTEGER},
  336. unit_name = #{unitName,jdbcType=VARCHAR},
  337. tax_number = #{taxNumber,jdbcType=VARCHAR},
  338. amount = #{amount,jdbcType=DECIMAL},
  339. banks = #{banks,jdbcType=VARCHAR},
  340. content = #{content,jdbcType=VARCHAR},
  341. unit_address = #{unitAddress,jdbcType=VARCHAR},
  342. invoice_remarks = #{invoiceRemarks,jdbcType=VARCHAR},
  343. unit_mobile = #{unitMobile,jdbcType=VARCHAR},
  344. voucher_url = #{voucherUrl,jdbcType=VARCHAR},
  345. post = #{post,jdbcType=INTEGER},
  346. addressee = #{addressee,jdbcType=VARCHAR},
  347. addressee_mobile = #{addresseeMobile,jdbcType=VARCHAR},
  348. addressee_province = #{addresseeProvince,jdbcType=INTEGER},
  349. addressee_city = #{addresseeCity,jdbcType=INTEGER},
  350. addressee_area = #{addresseeArea,jdbcType=INTEGER},
  351. recipient_address = #{recipientAddress,jdbcType=VARCHAR},
  352. create_time = #{createTime,jdbcType=TIMESTAMP},
  353. update_time = #{updateTime,jdbcType=TIMESTAMP},
  354. approval = #{approval,jdbcType=INTEGER},
  355. already_amount = #{alreadyAmount,jdbcType=DECIMAL},
  356. examine_name = #{examineName,jdbcType=VARCHAR}
  357. where id = #{id,jdbcType=INTEGER}
  358. </update>
  359. <select id="checkApplyAmount" resultType="java.lang.String">
  360. select ifnull(sum(amount),0) from t_order_invoice
  361. where order_no= #{orderNo,jdbcType=VARCHAR} and status in (0,1,2,3)
  362. <if test="id != null">
  363. and id != #{id,jdbcType=INTEGER}
  364. </if>
  365. </select>
  366. <select id="financeOrderInvoiceList" resultType="com.goafanti.order.bo.TOrderInvoiceBo">
  367. select a.id,a.unit_name as unitName,a.order_no as orderNo,c.name,b.project_status as projectStatus,a.amount,a.approval,b.contract_no contractNo,
  368. ifnull(d.sumAmount,0) as sumAmount, date_format(a.create_time,'%Y-%m-%d %H:%i:%S')as createTime ,a.status,b.process_status processStatus,
  369. b.settlement_amount as settlementAmount, (b.total_amount-b.settlement_amount) as notAmount,tm.buyer_name userName
  370. from t_order_invoice a
  371. left join t_order_new b on a.order_no=b.order_no left join admin c on b.salesman_id=c.id
  372. left join (select order_no,sum(amount)as sumAmount from t_order_invoice where status =2 group by order_no) d
  373. on a.order_no=d.order_no left join department e on b.order_dep=e.id
  374. left join t_order_mid tm on a.order_no =tm.order_no
  375. where b.delete_sign in (0,2)
  376. <if test="all ==0">
  377. and a.status in (1,2)
  378. and a.approval in (0,2)
  379. </if>
  380. <if test="all ==1">
  381. and a.status in (1,2,3)
  382. </if>
  383. <if test="type !=null">
  384. and a.`type`= #{type,jdbcType=INTEGER}
  385. </if>
  386. <if test="status == 1">
  387. and a.status=1
  388. </if>
  389. <if test="orderNo !=null">
  390. and a.order_no = #{orderNo,jdbcType=VARCHAR}
  391. </if>
  392. <if test="contractNo != null">
  393. and b.contract_no like concat('%',#{contractNo},'%')
  394. </if>
  395. <if test="userName != null">
  396. and tm.buyer_name like concat('%',#{userName},'%')
  397. </if>
  398. <if test="invoiceType != null">
  399. and a.status =#{invoiceType}
  400. </if>
  401. <if test="startTime != null and endTime != null">
  402. and a.create_time BETWEEN #{startTime} and #{endTime}
  403. </if>
  404. <if test="name !=null">
  405. and c.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  406. </if>
  407. <if test="deps !=null">
  408. and b.order_dep in
  409. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  410. #{depId}
  411. </foreach>
  412. </if>
  413. <if test="status !=null">
  414. and a.status= #{status,jdbcType=INTEGER}
  415. </if>
  416. <if test="approval !=null">
  417. and a.approval= #{approval,jdbcType=INTEGER}
  418. </if>
  419. <if test="aDep !=null">
  420. and b.order_dep in
  421. <foreach collection="aDep" index="index" item="depid" open="(" separator="," close=")">
  422. #{depid}
  423. </foreach>
  424. </if>
  425. order by a.status ,a.create_time desc
  426. <if test="page_sql!=null">
  427. ${page_sql}
  428. </if>
  429. </select>
  430. <select id="financeOrderInvoiceCount" resultType="java.lang.Integer">
  431. select count(*) from t_order_invoice a
  432. left join t_order_new b on a.order_no=b.order_no
  433. left join admin c on b.salesman_id=c.id
  434. left join department e on b.order_dep=e.id
  435. left join t_order_mid tm on a.order_no =tm.order_no
  436. where b.delete_sign in (0,2)
  437. <if test="all ==0">
  438. and a.status in (1,2)
  439. and a.approval in (0,2)
  440. </if>
  441. <if test="all ==1">
  442. and a.status in (1,2,3)
  443. </if>
  444. <if test="type !=null">
  445. and a.`type`= #{type,jdbcType=INTEGER}
  446. </if>
  447. <if test="status == 1">
  448. and a.status=1
  449. </if>
  450. <if test="orderNo !=null">
  451. and a.order_no = #{orderNo,jdbcType=VARCHAR}
  452. </if>
  453. <if test="contractNo != null">
  454. and b.contract_no like concat('%',#{contractNo},'%')
  455. </if>
  456. <if test="userName != null">
  457. and tm.buyer_name like concat('%',#{userName},'%')
  458. </if>
  459. <if test="invoiceType != null">
  460. and a.status =#{invoiceType}
  461. </if>
  462. <if test="startTime != null and endTime != null">
  463. and a.create_time BETWEEN #{startTime} and #{endTime}
  464. </if>
  465. <if test="name !=null">
  466. and c.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  467. </if>
  468. <if test="deps !=null">
  469. and b.order_dep in
  470. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  471. #{depId}
  472. </foreach>
  473. </if>
  474. <if test="status !=null">
  475. and a.status= #{status,jdbcType=INTEGER}
  476. </if>
  477. <if test="approval !=null">
  478. and a.approval= #{approval,jdbcType=INTEGER}
  479. </if>
  480. <if test="aDep !=null">
  481. and b.order_dep in
  482. <foreach collection="aDep" index="index" item="depid" open="(" separator="," close=")">
  483. #{depid}
  484. </foreach>
  485. </if>
  486. </select>
  487. <select id="salesmanOrderInvoiceList" resultType="com.goafanti.order.bo.TOrderInvoiceBo">
  488. select a.id ,a.order_no as orderNo,b.contract_no contractNo,a.amount,date_format(a.create_time,'%Y-%m-%d %H:%i:%S') as createTime,
  489. a.reject_reason as rejectReason,a.status ,a.approval,a.examine_name examineName
  490. from t_order_invoice a left join t_order_new b on a.order_no=b.order_no
  491. where a.status in (0,1,2,3)
  492. <if test="orderNo !=null">
  493. and a.order_no = #{orderNo,jdbcType=VARCHAR}
  494. </if>
  495. order by a.create_time desc
  496. <if test="page_sql!=null">
  497. ${page_sql}
  498. </if>
  499. </select>
  500. <select id="salesmanOrderInvoiceCount" resultType="java.lang.Integer">
  501. select count(*) from t_order_invoice where status in (0,1,2,3)
  502. <if test="orderNo !=null">
  503. and order_no = #{orderNo,jdbcType=VARCHAR}
  504. </if>
  505. </select>
  506. <select id="approvalOrderInvoiceList" resultType="com.goafanti.order.bo.TOrderInvoiceBo">
  507. select a.id,a.unit_name as unitName,a.order_no as orderNo,c.name,b.project_status as projectStatus,a.amount,b.process_status processStatus,
  508. ifnull(d.sumAmount,0) as sumAmount, date_format(a.create_time,'%Y-%m-%d %H:%i:%S')as createTime ,a.status, a.approval,
  509. b.settlement_amount as settlementAmount, (b.total_amount-b.settlement_amount) as notAmount from t_order_invoice a
  510. left join t_order_new b on a.order_no=b.order_no left join admin c on b.salesman_id=c.id
  511. left join (select order_no,sum(amount)as sumAmount from t_order_invoice where status =2 group by order_no) d
  512. on a.order_no=d.order_no where b.delete_sign in (0,2)
  513. <if test="status ==null">
  514. and a.status in(1,2)
  515. </if>
  516. <if test="status != null">
  517. and a.status = #{status,jdbcType=INTEGER}
  518. </if>
  519. <if test="approval ==null and special==null">
  520. and a.approval in(1,2)
  521. </if>
  522. <if test="approval != null">
  523. and a.approval = #{approval,jdbcType=INTEGER}
  524. </if>
  525. <if test="type !=null">
  526. and a.type= #{type,jdbcType=INTEGER}
  527. </if>
  528. <if test="orderNo !=null">
  529. and a.order_no = #{orderNo,jdbcType=VARCHAR}
  530. </if>
  531. <if test="name !=null">
  532. and c.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  533. </if>
  534. <if test="userName !=null">
  535. and a.unit_name like CONCAT('%',#{userName,jdbcType=VARCHAR},'%')
  536. </if>
  537. <if test="orderDep !=null">
  538. and b.order_dep= #{orderDep,jdbcType=VARCHAR}
  539. </if>
  540. <if test="aDep !=null">
  541. and c.department_id= #{aDep,jdbcType=VARCHAR}
  542. </if>
  543. order by a.approval,a.status,a.create_time desc
  544. <if test="page_sql!=null">
  545. ${page_sql}
  546. </if>
  547. </select>
  548. <select id="approvalOrderInvoiceCount" resultType="java.lang.Integer">
  549. select count(*) from t_order_invoice a
  550. left join t_order_new b on a.order_no=b.order_no left join admin c on b.salesman_id=c.id
  551. where b.delete_sign in (0,2)
  552. <if test="status ==null">
  553. and a.status in(1,2)
  554. </if>
  555. <if test="status != null">
  556. and a.status = #{status,jdbcType=INTEGER}
  557. </if>
  558. <if test="approval ==null and special==null">
  559. and a.approval in(1,2)
  560. </if>
  561. <if test="approval != null">
  562. and a.approval = #{approval,jdbcType=INTEGER}
  563. </if>
  564. <if test="type !=null">
  565. and a.type= #{type,jdbcType=INTEGER}
  566. </if>
  567. <if test="orderNo !=null">
  568. and a.order_no = #{orderNo,jdbcType=VARCHAR}
  569. </if>
  570. <if test="name !=null">
  571. and c.name like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  572. </if>
  573. <if test="userName !=null">
  574. and a.unit_name like CONCAT('%',#{userName,jdbcType=VARCHAR},'%')
  575. </if>
  576. <if test="orderDep !=null">
  577. and b.order_dep= #{orderDep,jdbcType=VARCHAR}
  578. </if>
  579. <if test="aDep !=null">
  580. and c.department_id= #{aDep,jdbcType=VARCHAR}
  581. </if>
  582. </select>
  583. <select id="selectByInvoiceDitails" parameterType="java.lang.Integer" resultType="com.goafanti.order.bo.TOrderInvoiceDetails">
  584. select a.id ,a.order_no as orderNo,a.`type`,a.status,a.reject_reason as rejectReason,a.remarks,a.invoice_type as invoiceType,
  585. a.unit_name as unitName,a.tax_number as taxNumber,a.amount,a.banks,a.content,a.unit_address as unitAddress,
  586. a.invoice_remarks as invoiceRemarks,a.unit_mobile as unitMobile,a.voucher_url as voucherUrl ,a.post,a.addressee,
  587. a.addressee_area as addresseeArea,a.addressee_city as addresseeCity,a.addressee_province as addresseeProvince,
  588. a.addressee_mobile as addresseeMobile,a.recipient_address as recipientAddress,a.create_time,a.update_time,a.approval,
  589. a.already_amount as alreadyAmount,b.contract_no as contractNo from t_order_invoice a
  590. left join t_order_new b on a.order_no=b.order_no
  591. where id = #{id,jdbcType=INTEGER}
  592. </select>
  593. <select id="getInvoiceDetails" parameterType="java.lang.String" resultType="com.goafanti.order.bo.TOrderInvoiceDetails">
  594. select a.id ,a.order_no as orderNo,a.`type`,a.status,a.reject_reason as rejectReason,a.remarks,a.invoice_type as invoiceType,
  595. a.unit_name as unitName,a.tax_number as taxNumber,a.amount,a.banks,a.content,a.unit_address as unitAddress,
  596. a.invoice_remarks as invoiceRemarks,a.unit_mobile as unitMobile,a.voucher_url as voucherUrl ,a.post,a.addressee,
  597. a.addressee_area as addresseeArea,a.addressee_city as addresseeCity,a.addressee_province as addresseeProvince,
  598. a.addressee_mobile as addresseeMobile,a.recipient_address as recipientAddress,a.create_time,a.update_time,a.approval,
  599. a.already_amount as alreadyAmount,b.contract_no as contractNo from t_order_invoice a
  600. left join t_order_new b on a.order_no=b.order_no
  601. where a.order_no= #{orderNo,jdbcType=VARCHAR}
  602. and a.create_time=(select max(create_time) from t_order_invoice where order_no= #{orderNo,jdbcType=VARCHAR})
  603. </select>
  604. <select id="conutAmountByOrderNo" resultType="java.math.BigDecimal">
  605. select ifnull(sum(a.amount),0) amount from t_order_invoice a
  606. where a.status=2 and a.order_no= #{orderNo,jdbcType=VARCHAR}
  607. </select>
  608. <select id="selectByOrderNo" resultType="com.goafanti.order.bo.InvoiceBo">
  609. select date_format(a.create_time,'%Y-%m-%d %H:%i:%S') createTime,a.amount from t_order_invoice a
  610. where a.status=2 and a.order_no= #{orderNo,jdbcType=VARCHAR}
  611. </select>
  612. <select id="selectInvoiceLog" resultType="com.goafanti.order.bo.OutInvoiceLog">
  613. select a.id,a.invoice_id invoiceId ,a.status,a.aid,a.create_time createTime,
  614. b.name adminName,date_format(a.create_time,'%Y-%m-%d %H:%i:%S')as createTimes
  615. from invoice_log a left join admin b on a.aid =b.id
  616. where a.invoice_id =#{id} order by a.create_time
  617. </select>
  618. </mapper>