NewOrderChangeMapper.xml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  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.NewOrderChangeMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.NewOrderChange">
  5. <id column="id" jdbcType="INTEGER" property="id" />
  6. <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
  7. <result column="process_state" jdbcType="INTEGER" property="processState" />
  8. <result column="status" jdbcType="INTEGER" property="status" />
  9. <result column="type" jdbcType="INTEGER" property="type" />
  10. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  11. <result column="remarks" jdbcType="VARCHAR" property="remarks" />
  12. <result column="voucher_url" jdbcType="VARCHAR" property="voucherUrl" />
  13. <result column="total_amount" jdbcType="DECIMAL" property="totalAmount" />
  14. <result column="settlement_amount" jdbcType="DECIMAL" property="settlementAmount" />
  15. <result column="change_amount" jdbcType="DECIMAL" property="changeAmount" />
  16. <result column="applicant" jdbcType="VARCHAR" property="applicant" />
  17. <result column="dep_name" jdbcType="VARCHAR" property="depName" />
  18. <result column="project_state" jdbcType="VARCHAR" property="projectState" />
  19. <result column="zxs_cost" jdbcType="DECIMAL" property="zxsCost" />
  20. <result column="zxs_remarks" jdbcType="VARCHAR" property="zxsRemarks" />
  21. <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime" />
  22. <result column="payment_amount" jdbcType="DECIMAL" property="paymentAmount" />
  23. <result column="invoice_time" jdbcType="TIMESTAMP" property="invoiceTime" />
  24. <result column="invoice_amount" jdbcType="DECIMAL" property="invoiceAmount" />
  25. <result column="invoice_type" jdbcType="VARCHAR" property="invoiceType" />
  26. <result column="cw_cost" jdbcType="DECIMAL" property="cwCost" />
  27. <result column="refundable_amount" jdbcType="DECIMAL" property="refundableAmount" />
  28. <result column="cw_remarks" jdbcType="VARCHAR" property="cwRemarks" />
  29. <result column="estimate_cost" jdbcType="DECIMAL" property="estimateCost" />
  30. <result column="estimate_refundable" jdbcType="DECIMAL" property="estimateRefundable" />
  31. <result column="refund_Invoice" jdbcType="DECIMAL" property="refundInvoice" />
  32. <result column="used_order" jdbcType="VARCHAR" property="usedOrder" />
  33. <result column="refund_status" jdbcType="INTEGER" property="refundStatus" />
  34. <result column="refund_url" jdbcType="VARCHAR" property="refundUrl" />
  35. <result column="back_status" jdbcType="INTEGER" property="backStatus" />
  36. <result column="attachment_url" jdbcType="VARCHAR" property="attachmentUrl" />
  37. </resultMap>
  38. <sql id="Base_Column_List">
  39. id, order_no, process_state, `status`, `type`, create_time, remarks, voucher_url,
  40. total_amount, settlement_amount, change_amount, applicant, dep_name, project_state,
  41. zxs_cost, zxs_remarks, payment_time, payment_amount, invoice_time, invoice_amount,
  42. invoice_type, cw_cost, refundable_amount, cw_remarks, estimate_cost, estimate_refundable,
  43. refund_Invoice, used_order, refund_status, refund_url, back_status, attachment_url
  44. </sql>
  45. <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  46. select
  47. <include refid="Base_Column_List" />
  48. from new_order_change
  49. where id = #{id,jdbcType=INTEGER}
  50. </select>
  51. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  52. delete from new_order_change
  53. where id = #{id,jdbcType=INTEGER}
  54. </delete>
  55. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.NewOrderChange" useGeneratedKeys="true">
  56. insert into new_order_change (order_no, process_state, `status`,
  57. `type`, create_time, remarks,
  58. voucher_url, total_amount, settlement_amount,
  59. change_amount, applicant, dep_name,
  60. project_state, zxs_cost, zxs_remarks,
  61. payment_time, payment_amount, invoice_time,
  62. invoice_amount, invoice_type, cw_cost,
  63. refundable_amount, cw_remarks, estimate_cost,
  64. estimate_refundable, refund_Invoice, used_order,
  65. refund_status, refund_url, back_status,
  66. attachment_url)
  67. values (#{orderNo,jdbcType=VARCHAR}, #{processState,jdbcType=INTEGER}, #{status,jdbcType=INTEGER},
  68. #{type,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, #{remarks,jdbcType=VARCHAR},
  69. #{voucherUrl,jdbcType=VARCHAR}, #{totalAmount,jdbcType=DECIMAL}, #{settlementAmount,jdbcType=DECIMAL},
  70. #{changeAmount,jdbcType=DECIMAL}, #{applicant,jdbcType=VARCHAR}, #{depName,jdbcType=VARCHAR},
  71. #{projectState,jdbcType=VARCHAR}, #{zxsCost,jdbcType=DECIMAL}, #{zxsRemarks,jdbcType=VARCHAR},
  72. #{paymentTime,jdbcType=TIMESTAMP}, #{paymentAmount,jdbcType=DECIMAL}, #{invoiceTime,jdbcType=TIMESTAMP},
  73. #{invoiceAmount,jdbcType=DECIMAL}, #{invoiceType,jdbcType=VARCHAR}, #{cwCost,jdbcType=DECIMAL},
  74. #{refundableAmount,jdbcType=DECIMAL}, #{cwRemarks,jdbcType=VARCHAR}, #{estimateCost,jdbcType=DECIMAL},
  75. #{estimateRefundable,jdbcType=DECIMAL}, #{refundInvoice,jdbcType=DECIMAL}, #{usedOrder,jdbcType=VARCHAR},
  76. #{refundStatus,jdbcType=INTEGER}, #{refundUrl,jdbcType=VARCHAR}, #{backStatus,jdbcType=INTEGER},
  77. #{attachmentUrl,jdbcType=VARCHAR})
  78. </insert>
  79. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.NewOrderChange" useGeneratedKeys="true">
  80. insert into new_order_change
  81. <trim prefix="(" suffix=")" suffixOverrides=",">
  82. <if test="orderNo != null">
  83. order_no,
  84. </if>
  85. <if test="processState != null">
  86. process_state,
  87. </if>
  88. <if test="status != null">
  89. `status`,
  90. </if>
  91. <if test="type != null">
  92. `type`,
  93. </if>
  94. <if test="createTime != null">
  95. create_time,
  96. </if>
  97. <if test="remarks != null">
  98. remarks,
  99. </if>
  100. <if test="voucherUrl != null">
  101. voucher_url,
  102. </if>
  103. <if test="totalAmount != null">
  104. total_amount,
  105. </if>
  106. <if test="settlementAmount != null">
  107. settlement_amount,
  108. </if>
  109. <if test="changeAmount != null">
  110. change_amount,
  111. </if>
  112. <if test="applicant != null">
  113. applicant,
  114. </if>
  115. <if test="depName != null">
  116. dep_name,
  117. </if>
  118. <if test="projectState != null">
  119. project_state,
  120. </if>
  121. <if test="zxsCost != null">
  122. zxs_cost,
  123. </if>
  124. <if test="zxsRemarks != null">
  125. zxs_remarks,
  126. </if>
  127. <if test="paymentTime != null">
  128. payment_time,
  129. </if>
  130. <if test="paymentAmount != null">
  131. payment_amount,
  132. </if>
  133. <if test="invoiceTime != null">
  134. invoice_time,
  135. </if>
  136. <if test="invoiceAmount != null">
  137. invoice_amount,
  138. </if>
  139. <if test="invoiceType != null">
  140. invoice_type,
  141. </if>
  142. <if test="cwCost != null">
  143. cw_cost,
  144. </if>
  145. <if test="refundableAmount != null">
  146. refundable_amount,
  147. </if>
  148. <if test="cwRemarks != null">
  149. cw_remarks,
  150. </if>
  151. <if test="estimateCost != null">
  152. estimate_cost,
  153. </if>
  154. <if test="estimateRefundable != null">
  155. estimate_refundable,
  156. </if>
  157. <if test="refundInvoice != null">
  158. refund_Invoice,
  159. </if>
  160. <if test="usedOrder != null">
  161. used_order,
  162. </if>
  163. <if test="refundStatus != null">
  164. refund_status,
  165. </if>
  166. <if test="refundUrl != null">
  167. refund_url,
  168. </if>
  169. <if test="backStatus != null">
  170. back_status,
  171. </if>
  172. <if test="attachmentUrl != null">
  173. attachment_url,
  174. </if>
  175. </trim>
  176. <trim prefix="values (" suffix=")" suffixOverrides=",">
  177. <if test="orderNo != null">
  178. #{orderNo,jdbcType=VARCHAR},
  179. </if>
  180. <if test="processState != null">
  181. #{processState,jdbcType=INTEGER},
  182. </if>
  183. <if test="status != null">
  184. #{status,jdbcType=INTEGER},
  185. </if>
  186. <if test="type != null">
  187. #{type,jdbcType=INTEGER},
  188. </if>
  189. <if test="createTime != null">
  190. #{createTime,jdbcType=TIMESTAMP},
  191. </if>
  192. <if test="remarks != null">
  193. #{remarks,jdbcType=VARCHAR},
  194. </if>
  195. <if test="voucherUrl != null">
  196. #{voucherUrl,jdbcType=VARCHAR},
  197. </if>
  198. <if test="totalAmount != null">
  199. #{totalAmount,jdbcType=DECIMAL},
  200. </if>
  201. <if test="settlementAmount != null">
  202. #{settlementAmount,jdbcType=DECIMAL},
  203. </if>
  204. <if test="changeAmount != null">
  205. #{changeAmount,jdbcType=DECIMAL},
  206. </if>
  207. <if test="applicant != null">
  208. #{applicant,jdbcType=VARCHAR},
  209. </if>
  210. <if test="depName != null">
  211. #{depName,jdbcType=VARCHAR},
  212. </if>
  213. <if test="projectState != null">
  214. #{projectState,jdbcType=VARCHAR},
  215. </if>
  216. <if test="zxsCost != null">
  217. #{zxsCost,jdbcType=DECIMAL},
  218. </if>
  219. <if test="zxsRemarks != null">
  220. #{zxsRemarks,jdbcType=VARCHAR},
  221. </if>
  222. <if test="paymentTime != null">
  223. #{paymentTime,jdbcType=TIMESTAMP},
  224. </if>
  225. <if test="paymentAmount != null">
  226. #{paymentAmount,jdbcType=DECIMAL},
  227. </if>
  228. <if test="invoiceTime != null">
  229. #{invoiceTime,jdbcType=TIMESTAMP},
  230. </if>
  231. <if test="invoiceAmount != null">
  232. #{invoiceAmount,jdbcType=DECIMAL},
  233. </if>
  234. <if test="invoiceType != null">
  235. #{invoiceType,jdbcType=VARCHAR},
  236. </if>
  237. <if test="cwCost != null">
  238. #{cwCost,jdbcType=DECIMAL},
  239. </if>
  240. <if test="refundableAmount != null">
  241. #{refundableAmount,jdbcType=DECIMAL},
  242. </if>
  243. <if test="cwRemarks != null">
  244. #{cwRemarks,jdbcType=VARCHAR},
  245. </if>
  246. <if test="estimateCost != null">
  247. #{estimateCost,jdbcType=DECIMAL},
  248. </if>
  249. <if test="estimateRefundable != null">
  250. #{estimateRefundable,jdbcType=DECIMAL},
  251. </if>
  252. <if test="refundInvoice != null">
  253. #{refundInvoice,jdbcType=DECIMAL},
  254. </if>
  255. <if test="usedOrder != null">
  256. #{usedOrder,jdbcType=VARCHAR},
  257. </if>
  258. <if test="refundStatus != null">
  259. #{refundStatus,jdbcType=INTEGER},
  260. </if>
  261. <if test="refundUrl != null">
  262. #{refundUrl,jdbcType=VARCHAR},
  263. </if>
  264. <if test="backStatus != null">
  265. #{backStatus,jdbcType=INTEGER},
  266. </if>
  267. <if test="attachmentUrl != null">
  268. #{attachmentUrl,jdbcType=VARCHAR},
  269. </if>
  270. </trim>
  271. </insert>
  272. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.NewOrderChange">
  273. update new_order_change
  274. <set>
  275. <if test="orderNo != null">
  276. order_no = #{orderNo,jdbcType=VARCHAR},
  277. </if>
  278. <if test="processState != null">
  279. process_state = #{processState,jdbcType=INTEGER},
  280. </if>
  281. <if test="status != null">
  282. `status` = #{status,jdbcType=INTEGER},
  283. </if>
  284. <if test="type != null">
  285. `type` = #{type,jdbcType=INTEGER},
  286. </if>
  287. <if test="createTime != null">
  288. create_time = #{createTime,jdbcType=TIMESTAMP},
  289. </if>
  290. <if test="remarks != null">
  291. remarks = #{remarks,jdbcType=VARCHAR},
  292. </if>
  293. <if test="voucherUrl != null">
  294. voucher_url = #{voucherUrl,jdbcType=VARCHAR},
  295. </if>
  296. <if test="totalAmount != null">
  297. total_amount = #{totalAmount,jdbcType=DECIMAL},
  298. </if>
  299. <if test="settlementAmount != null">
  300. settlement_amount = #{settlementAmount,jdbcType=DECIMAL},
  301. </if>
  302. <if test="changeAmount != null">
  303. change_amount = #{changeAmount,jdbcType=DECIMAL},
  304. </if>
  305. <if test="applicant != null">
  306. applicant = #{applicant,jdbcType=VARCHAR},
  307. </if>
  308. <if test="depName != null">
  309. dep_name = #{depName,jdbcType=VARCHAR},
  310. </if>
  311. <if test="projectState != null">
  312. project_state = #{projectState,jdbcType=VARCHAR},
  313. </if>
  314. <if test="zxsCost != null">
  315. zxs_cost = #{zxsCost,jdbcType=DECIMAL},
  316. </if>
  317. <if test="zxsRemarks != null">
  318. zxs_remarks = #{zxsRemarks,jdbcType=VARCHAR},
  319. </if>
  320. <if test="paymentTime != null">
  321. payment_time = #{paymentTime,jdbcType=TIMESTAMP},
  322. </if>
  323. <if test="paymentAmount != null">
  324. payment_amount = #{paymentAmount,jdbcType=DECIMAL},
  325. </if>
  326. <if test="invoiceTime != null">
  327. invoice_time = #{invoiceTime,jdbcType=TIMESTAMP},
  328. </if>
  329. <if test="invoiceAmount != null">
  330. invoice_amount = #{invoiceAmount,jdbcType=DECIMAL},
  331. </if>
  332. <if test="invoiceType != null">
  333. invoice_type = #{invoiceType,jdbcType=VARCHAR},
  334. </if>
  335. <if test="cwCost != null">
  336. cw_cost = #{cwCost,jdbcType=DECIMAL},
  337. </if>
  338. <if test="refundableAmount != null">
  339. refundable_amount = #{refundableAmount,jdbcType=DECIMAL},
  340. </if>
  341. <if test="cwRemarks != null">
  342. cw_remarks = #{cwRemarks,jdbcType=VARCHAR},
  343. </if>
  344. <if test="estimateCost != null">
  345. estimate_cost = #{estimateCost,jdbcType=DECIMAL},
  346. </if>
  347. <if test="estimateRefundable != null">
  348. estimate_refundable = #{estimateRefundable,jdbcType=DECIMAL},
  349. </if>
  350. <if test="refundInvoice != null">
  351. refund_Invoice = #{refundInvoice,jdbcType=DECIMAL},
  352. </if>
  353. <if test="usedOrder != null">
  354. used_order = #{usedOrder,jdbcType=VARCHAR},
  355. </if>
  356. <if test="refundStatus != null">
  357. refund_status = #{refundStatus,jdbcType=INTEGER},
  358. </if>
  359. <if test="refundUrl != null">
  360. refund_url = #{refundUrl,jdbcType=VARCHAR},
  361. </if>
  362. <if test="backStatus != null">
  363. back_status = #{backStatus,jdbcType=INTEGER},
  364. </if>
  365. <if test="attachmentUrl != null">
  366. attachment_url = #{attachmentUrl,jdbcType=VARCHAR},
  367. </if>
  368. </set>
  369. where id = #{id,jdbcType=INTEGER}
  370. </update>
  371. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.NewOrderChange">
  372. update new_order_change
  373. set order_no = #{orderNo,jdbcType=VARCHAR},
  374. process_state = #{processState,jdbcType=INTEGER},
  375. `status` = #{status,jdbcType=INTEGER},
  376. `type` = #{type,jdbcType=INTEGER},
  377. create_time = #{createTime,jdbcType=TIMESTAMP},
  378. remarks = #{remarks,jdbcType=VARCHAR},
  379. voucher_url = #{voucherUrl,jdbcType=VARCHAR},
  380. total_amount = #{totalAmount,jdbcType=DECIMAL},
  381. settlement_amount = #{settlementAmount,jdbcType=DECIMAL},
  382. change_amount = #{changeAmount,jdbcType=DECIMAL},
  383. applicant = #{applicant,jdbcType=VARCHAR},
  384. dep_name = #{depName,jdbcType=VARCHAR},
  385. project_state = #{projectState,jdbcType=VARCHAR},
  386. zxs_cost = #{zxsCost,jdbcType=DECIMAL},
  387. zxs_remarks = #{zxsRemarks,jdbcType=VARCHAR},
  388. payment_time = #{paymentTime,jdbcType=TIMESTAMP},
  389. payment_amount = #{paymentAmount,jdbcType=DECIMAL},
  390. invoice_time = #{invoiceTime,jdbcType=TIMESTAMP},
  391. invoice_amount = #{invoiceAmount,jdbcType=DECIMAL},
  392. invoice_type = #{invoiceType,jdbcType=VARCHAR},
  393. cw_cost = #{cwCost,jdbcType=DECIMAL},
  394. refundable_amount = #{refundableAmount,jdbcType=DECIMAL},
  395. cw_remarks = #{cwRemarks,jdbcType=VARCHAR},
  396. estimate_cost = #{estimateCost,jdbcType=DECIMAL},
  397. estimate_refundable = #{estimateRefundable,jdbcType=DECIMAL},
  398. refund_Invoice = #{refundInvoice,jdbcType=DECIMAL},
  399. used_order = #{usedOrder,jdbcType=VARCHAR},
  400. refund_status = #{refundStatus,jdbcType=INTEGER},
  401. refund_url = #{refundUrl,jdbcType=VARCHAR},
  402. back_status = #{backStatus,jdbcType=INTEGER},
  403. attachment_url = #{attachmentUrl,jdbcType=VARCHAR}
  404. where id = #{id,jdbcType=INTEGER}
  405. </update>
  406. <select id="selectByorderNo" resultType="com.goafanti.order.bo.NewOrderChangeBo">
  407. select
  408. a.id, a.order_no orderNo, a.process_state processState, a.status, a.`type`,a.refundable_amount refundableAmount,
  409. date_format(a.create_time, '%Y-%m-%d %H:%i:%S')createTimes, a.remarks, a.voucher_url voucherUrl,a.cw_cost cwCost,
  410. a.total_amount totalAmount, a.settlement_amount settlementAmount, (a.total_amount-a.settlement_amount) arrears,
  411. a.change_amount changeAmount, a.applicant, a.dep_name depName, a.project_state projectState, a.zxs_cost zxsCost,
  412. a.zxs_remarks zxsRemarks, date_format(a.payment_time, '%Y-%m-%d')paymentTimes, a.payment_amount paymentAmount,
  413. date_format(a. invoice_time, '%Y-%m-%d') invoiceTimes, a.invoice_amount invoiceAmount,a.invoice_type invoiceType,
  414. a.cw_remarks cwRemarks from new_order_change a where 1 = 1
  415. and a.order_no= #{orderNo}
  416. order by a.create_time desc limit 1
  417. </select>
  418. <select id="selectByChangeId" resultType="com.goafanti.order.bo.NewOrderChangeBo">
  419. select
  420. a.id, a.order_no orderNo, a.process_state processState, a.status, a.`type`,a.refundable_amount refundableAmount,
  421. date_format(a.create_time, '%Y-%m-%d %H:%i:%S')createTimes, a.remarks, a.voucher_url voucherUrl,a.cw_cost cwCost,
  422. a.total_amount totalAmount, a.settlement_amount settlementAmount, (a.total_amount-a.settlement_amount) arrears,
  423. a.change_amount changeAmount, a.applicant, a.dep_name depName, a.project_state projectState, a.zxs_cost zxsCost,
  424. a.zxs_remarks zxsRemarks, date_format(a.payment_time, '%Y-%m-%d')paymentTimes, a.payment_amount paymentAmount,
  425. date_format(a. invoice_time, '%Y-%m-%d') invoiceTimes, a.invoice_amount invoiceAmount,a.invoice_type invoiceType,
  426. a.cw_remarks cwRemarks,a.back_status backStatus from new_order_change a where 1 = 1 and status!=4
  427. and a.id= #{ChangeId}
  428. order by a.create_time desc
  429. </select>
  430. <select id="selectByorderNoAndStatus" resultType="com.goafanti.order.bo.NewOrderChangeBo">
  431. select
  432. a.id, a.order_no orderNo, a.process_state processState, a.status, a.`type`,a.refundable_amount refundableAmount,
  433. date_format(a.create_time, '%Y-%m-%d %H:%i:%S')createTimes, a.remarks, a.voucher_url voucherUrl,a.cw_cost cwCost,
  434. a.total_amount totalAmount, a.settlement_amount settlementAmount, (a.total_amount-a.settlement_amount) arrears,
  435. a.change_amount changeAmount, a.applicant, a.dep_name depName, a.project_state projectState, a.zxs_cost zxsCost,
  436. a.zxs_remarks zxsRemarks, date_format(a.payment_time, '%Y-%m-%d')paymentTimes, a.payment_amount paymentAmount,
  437. date_format(a. invoice_time, '%Y-%m-%d') invoiceTimes, a.invoice_amount invoiceAmount,a.invoice_type invoiceType,
  438. a.cw_remarks cwRemarks,a.back_status backStatus from new_order_change a where 1 = 1 and status in (0,1,2,3)
  439. and a.order_no= #{orderNo}
  440. order by a.create_time desc
  441. </select>
  442. <select id="selectById" resultType="com.goafanti.order.bo.NewOrderChangeBo">
  443. select
  444. a.id, a.order_no orderNo, a.process_state processState, a.status, a.`type`,a.refundable_amount refundableAmount,a.refund_url refundUrl,
  445. date_format(a.create_time, '%Y-%m-%d %H:%i:%S')createTimes, a.remarks, a.voucher_url voucherUrl,a.cw_cost cwCost,a.refund_status refundStatus,
  446. a.total_amount totalAmount, a.settlement_amount settlementAmount, (a.total_amount-a.settlement_amount) arrears,a.attachment_url attachmentUrl,
  447. a.change_amount changeAmount, a.applicant, a.dep_name depName, a.project_state projectState, a.zxs_cost zxsCost,
  448. a.zxs_remarks zxsRemarks, date_format(a.payment_time, '%Y-%m-%d')paymentTimes, a.payment_amount paymentAmount,
  449. date_format(a. invoice_time, '%Y-%m-%d') invoiceTimes, a.invoice_amount invoiceAmount,a.invoice_type invoiceType,
  450. a.cw_remarks cwRemarks,a.estimate_cost estimateCost,estimate_refundable estimateRefundable,refund_Invoice refundInvoice
  451. from new_order_change a where 1 = 1 and a.id= #{id}
  452. </select>
  453. <select id="checkOderNo" resultType="java.lang.Integer">
  454. select count(*) from new_order_change
  455. where order_no= #{orderNo} and status in (0,1,2,3,6)
  456. </select>
  457. <select id="selectOrderChangeList" resultType="com.goafanti.order.bo.NewOderCahngeListBo">
  458. select a.id,a.order_no orderNo,b.contract_no contractNo, date_format(a.create_time,'%Y-%m-%d %H:%i:%S')createTimes,c.nickname,b.order_type orderType,
  459. date_format(b.create_time,'%Y-%m-%d %H:%i:%S')establishTimes, b.order_status orderStatus,b.total_amount totalAmount,a.status ,
  460. b.settlement_amount settlementAmount,(b.total_amount-b.settlement_amount) arrears,d.name salesmanName,e.name depName,a.`type`,
  461. a.process_state processState,a.back_status backStatus from new_order_change noc left join new_order_change a on noc.id=a.id
  462. left join t_order_new b on a.order_no=b.order_no left join user c on b.buyer_id=c.id left join admin d on b.salesman_id=d.id
  463. left join department e on b.order_dep=e.id
  464. <if test="processState==2">
  465. left join (select order_no, aid from order_examine where`type`=0 group by order_no,aid)x on a.order_no = x.order_no
  466. </if>
  467. <if test="processState==3">
  468. left join (select order_no, aid from order_examine where`type`=1 group by order_no,aid)x on a.order_no = x.order_no
  469. </if>
  470. where 1=1
  471. <if test="processState==0">
  472. and b.salesman_id= #{aid}
  473. </if>
  474. <if test="processState==1">
  475. and b.order_dep in
  476. <foreach close=")" collection="deps" item="deps" open="(" separator=",">
  477. #{deps.id}
  478. </foreach>
  479. </if>
  480. <if test="processState==2 and complete !=5">
  481. and x.aid=#{aid} and a.process_state &gt;= 2
  482. </if>
  483. <if test="processState==3 and complete !=5">
  484. and x.aid=#{aid} and a.process_state &gt;= 3
  485. </if>
  486. <if test="processState==2 and complete ==5">
  487. and x.aid=#{aid} and a.back_status &gt;= #{processState}
  488. </if>
  489. <if test="processState==3 and complete ==5">
  490. and x.aid=#{aid} and a.back_status &gt;= #{processState}
  491. </if>
  492. <if test="processState==5 and aid !=null">
  493. and e.finance_id =#{aid}
  494. </if>
  495. <if test="processState==5 and aids !=null">
  496. and e.finance_id in
  497. <foreach close=")" collection="aids" item="id" open="(" separator=",">
  498. #{id}
  499. </foreach>
  500. </if>
  501. <if test="userName !=null">
  502. and c.nickname like concat('%',#{userName},'%')
  503. </if>
  504. <if test="orderNo !=null">
  505. and a.order_no like concat('%',#{orderNo},'%')
  506. </if>
  507. <if test="contractNo !=null">
  508. and b.contract_no like concat('%',#{contractNo},'%')
  509. </if>
  510. <if test="type !=null">
  511. and a.type = #{type}
  512. </if>
  513. <if test="timeType == 0 and startTime !=null and endTime !=null">
  514. and a.create_time between #{startTime} and #{endTime}
  515. </if>
  516. <if test="timeType == 1 and startTime !=null and endTime !=null">
  517. and b.create_time between #{startTime} and #{endTime}
  518. </if>
  519. <if test="deps !=null">
  520. and b.order_dep in
  521. <foreach close=")" collection="deps" item="deps" open="(" separator=",">
  522. #{deps.id}
  523. </foreach>
  524. </if>
  525. <if test="salesmanName !=null">
  526. and d.name like concat('%',#{salesmanName},'%')
  527. </if>
  528. <if test="complete ==0 and processState != 8">
  529. and (a.process_state &gt;= #{processState} or a.back_status &gt;= #{processState})
  530. </if>
  531. <if test="complete ==0 and processState == 8">
  532. and (a.process_state &gt;= #{processState} and a.process_state &lt; 9)or a.back_status &gt;= #{processState}
  533. </if>
  534. <if test="complete ==1 and processState != 5 and processState != 7 and processState != 8">
  535. and a.process_state = #{processState}
  536. </if>
  537. <if test="complete ==1 and processState == 5">
  538. and (a.process_state in(5,9) and a.status !=4)
  539. </if>
  540. <if test="complete ==1 and processState == 7">
  541. and (a.process_state = 7 and a.status =1)
  542. </if>
  543. <if test="complete ==1 and processState == 8">
  544. and (a.process_state = #{processState} and a.status =1)
  545. </if>
  546. <if test="complete ==2 and processState != 5 and processState != 7 and processState != 8">
  547. and a.process_state &gt; #{processState}
  548. </if>
  549. <if test="complete ==2 and processState == 5">
  550. and (a.process_state &gt; 5 and a.process_state &lt; 9) or (a.process_state =9 and a.status=4)
  551. </if>
  552. <if test="complete ==2 and processState == 7">
  553. and ((a.process_state = 7 and (a.status = 4 or a.status = 2))or a.process_state &gt; 7)
  554. </if>
  555. <if test="complete ==2 and processState == 8">
  556. and a.process_state = 8 and (a.status = 4 or a.status = 2)
  557. </if>
  558. <if test="complete ==3">
  559. and a.status = 2
  560. </if>
  561. <if test="complete ==4">
  562. and a.status = 4
  563. </if>
  564. <if test="complete ==5 and processState != 2 and processState != 3">
  565. and a.back_status &gt;= #{processState}
  566. </if>
  567. <if test="complete ==6">
  568. and a.status = 6
  569. </if>
  570. order by a.status,a.create_time desc
  571. <if test="page_sql != null">
  572. ${page_sql}
  573. </if>
  574. </select>
  575. <select id="selectOrderChangeCount" resultType="java.lang.Integer">
  576. select count(*) from new_order_change noc left join new_order_change a on noc.id=a.id
  577. left join t_order_new b on a.order_no=b.order_no left join user c on b.buyer_id=c.id
  578. left join admin d on b.salesman_id=d.id left join department e on b.order_dep=e.id
  579. <if test="processState==2">
  580. left join (select order_no, aid from order_examine where`type`=0 group by order_no,aid)x on a.order_no = x.order_no
  581. </if>
  582. <if test="processState==3">
  583. left join (select order_no, aid from order_examine where`type`=1 group by order_no,aid)x on a.order_no = x.order_no
  584. </if>
  585. where 1=1
  586. <if test="processState==0">
  587. and b.salesman_id= #{aid}
  588. </if>
  589. <if test="processState==1">
  590. and b.order_dep in
  591. <foreach close=")" collection="deps" item="deps" open="(" separator=",">
  592. #{deps.id}
  593. </foreach>
  594. </if>
  595. <if test="processState==2 and complete !=5">
  596. and x.aid=#{aid} and a.process_state &gt;= 2
  597. </if>
  598. <if test="processState==3 and complete !=5">
  599. and x.aid=#{aid} and a.process_state &gt;= 3
  600. </if>
  601. <if test="processState==2 and complete ==5">
  602. and x.aid=#{aid} and a.back_status &gt;= #{processState}
  603. </if>
  604. <if test="processState==3 and complete ==5">
  605. and x.aid=#{aid} and a.back_status &gt;= #{processState}
  606. </if>
  607. <if test="processState==5 and aid !=null">
  608. and e.finance_id =#{aid}
  609. </if>
  610. <if test="processState==5 and aids !=null">
  611. and e.finance_id in
  612. <foreach close=")" collection="aids" item="id" open="(" separator=",">
  613. #{id}
  614. </foreach>
  615. </if>
  616. <if test="userName !=null">
  617. and c.nickname like concat('%',#{userName},'%')
  618. </if>
  619. <if test="orderNo !=null">
  620. and a.order_no like concat('%',#{orderNo},'%')
  621. </if>
  622. <if test="contractNo !=null">
  623. and b.contract_no like concat('%',#{contractNo},'%')
  624. </if>
  625. <if test="type !=null">
  626. and a.type = #{type}
  627. </if>
  628. <if test="timeType == 0 and startTime !=null and endTime !=null">
  629. and a.create_time between #{startTime} and #{endTime}
  630. </if>
  631. <if test="timeType == 1 and startTime !=null and endTime !=null">
  632. and b.create_time between #{startTime} and #{endTime}
  633. </if>
  634. <if test="deps !=null">
  635. and b.order_dep in
  636. <foreach close=")" collection="deps" item="deps" open="(" separator=",">
  637. #{deps.id}
  638. </foreach>
  639. </if>
  640. <if test="salesmanName !=null">
  641. and d.name like concat('%',#{salesmanName},'%')
  642. </if>
  643. <if test="complete ==0 and processState != 8">
  644. and (a.process_state &gt;= #{processState} or a.back_status &gt;= #{processState})
  645. </if>
  646. <if test="complete ==0 and processState == 8">
  647. and (a.process_state &gt;= #{processState} and a.process_state &lt; 9)or a.back_status &gt;= #{processState}
  648. </if>
  649. <if test="complete ==1 and processState != 5 and processState != 7 and processState != 8">
  650. and a.process_state = #{processState}
  651. </if>
  652. <if test="complete ==1 and processState == 5">
  653. and (a.process_state in(5,9) and a.status !=4)
  654. </if>
  655. <if test="complete ==1 and processState == 7">
  656. and (a.process_state = 7 and a.status =1)
  657. </if>
  658. <if test="complete ==1 and processState == 8">
  659. and (a.process_state = #{processState} and a.status =1)
  660. </if>
  661. <if test="complete ==2 and processState != 5 and processState != 7 and processState != 8">
  662. and a.process_state &gt; #{processState}
  663. </if>
  664. <if test="complete ==2 and processState == 5">
  665. and (a.process_state &gt; 5 and a.process_state &lt; 9) or (a.process_state =9 and a.status=4)
  666. </if>
  667. <if test="complete ==2 and processState == 7">
  668. and ((a.process_state = 7 and (a.status = 4 or a.status = 2))or a.process_state &gt; 7)
  669. </if>
  670. <if test="complete ==2 and processState == 8">
  671. and a.process_state = 8 and (a.status = 4 or a.status = 2)
  672. </if>
  673. <if test="complete ==3">
  674. and a.status = 2
  675. </if>
  676. <if test="complete ==4">
  677. and a.status = 4
  678. </if>
  679. <if test="complete ==5 and processState != 2 and processState != 3">
  680. and a.back_status &gt;= #{processState}
  681. </if>
  682. <if test="complete ==6">
  683. and a.status = 6
  684. </if>
  685. </select>
  686. <update id="addRefundInvoice">
  687. update new_order_change
  688. set `refund_Invoice`=ifnull(`refund_Invoice`,0)+ #{amount}
  689. where order_no= #{orderNo}
  690. </update>
  691. <update id="subtractRefundInvoice">
  692. update new_order_change
  693. set `refund_Invoice`=ifnull(`refund_Invoice`,0)- #{amount}
  694. where order_no= #{orderNo}
  695. </update>
  696. <select id="getOrderChange" resultType="java.util.Map">
  697. select id,used_order usedOrder from new_order_change where order_no= #{orderNo} order by id
  698. </select>
  699. </mapper>