NewOrderChangeMapper.xml 35 KB

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