NewOrderChangeMapper.xml 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913
  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
  504. <if test="complete ==1">
  505. and status=0
  506. </if>
  507. <if test="complete ==2">
  508. and status=1
  509. </if>
  510. group by order_no,aid)x on a.order_no = x.order_no
  511. </if>
  512. <if test="processState==4">
  513. left join (select order_no, aid from order_examine where`type`=1
  514. <if test="complete ==1">
  515. and status=0
  516. </if>
  517. <if test="complete ==2">
  518. and status=1
  519. </if>
  520. group by order_no,aid)x on a.order_no = x.order_no
  521. </if>
  522. where 1=1
  523. <if test="processState==0">
  524. and b.salesman_id= #{aid}
  525. </if>
  526. <if test="processState==1">
  527. and d.manager_id= #{aid}
  528. </if>
  529. <if test="processState==3 and complete !=5">
  530. and x.aid=#{aid} and a.process_state &gt;= #{processState}
  531. </if>
  532. <if test="processState==4 and complete !=5">
  533. and x.aid=#{aid} and a.process_state &gt;= #{processState}
  534. </if>
  535. <if test="processState==3 and complete ==5">
  536. and x.aid=#{aid} and a.back_status &gt;= #{processState}
  537. </if>
  538. <if test="processState==4 and complete ==5">
  539. and x.aid=#{aid} and a.back_status &gt;= #{processState}
  540. </if>
  541. <if test="processState==6 and aid !=null">
  542. and e.finance_id =#{aid}
  543. </if>
  544. <if test="processState==6 and aids !=null">
  545. and e.finance_id in
  546. <foreach close=")" collection="aids" item="id" open="(" separator=",">
  547. #{id}
  548. </foreach>
  549. </if>
  550. <if test="userName !=null">
  551. and c.nickname like concat('%',#{userName},'%')
  552. </if>
  553. <if test="orderNo !=null">
  554. and a.order_no like concat('%',#{orderNo},'%')
  555. </if>
  556. <if test="contractNo !=null">
  557. and b.contract_no like concat('%',#{contractNo},'%')
  558. </if>
  559. <if test="type !=null">
  560. and a.type = #{type}
  561. </if>
  562. <if test="timeType == 0 and startTime !=null and endTime !=null">
  563. and a.create_time between #{startTime} and #{endTime}
  564. </if>
  565. <if test="timeType == 1 and startTime !=null and endTime !=null">
  566. and b.create_time between #{startTime} and #{endTime}
  567. </if>
  568. <if test="deps !=null">
  569. and b.order_dep in
  570. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  571. #{depId}
  572. </foreach>
  573. </if>
  574. <if test="salesmanName !=null">
  575. and d.name like concat('%',#{salesmanName},'%')
  576. </if>
  577. <if test="complete ==0 and processState != 9 and processState != 5 and processState != 7">
  578. and ((a.process_state &gt;= #{processState} or a.back_status &gt;= #{processState}))
  579. </if>
  580. <if test="complete ==0 and processState == 9">
  581. and ((a.process_state &gt;= #{processState} and a.process_state &lt; 10)or a.back_status &gt;= #{processState})
  582. </if>
  583. <if test="complete ==0 and (processState == 5 or processState == 7)">
  584. and ((a.process_state &gt;= 1 and a.process_state &lt; 10)or a.back_status &gt;= #{processState})
  585. </if>
  586. <if test="complete ==1 and processState != 6 and processState != 8 and processState != 9">
  587. and a.process_state = #{processState} and a.status in (0,1,2,3)
  588. </if>
  589. <if test="complete ==1 and processState == 6">
  590. and (a.process_state in(6) and a.status in (0,1,2,3,5,6))
  591. </if>
  592. <if test="complete ==1 and processState == 8">
  593. and (a.process_state = 8 and a.status =1)
  594. </if>
  595. <if test="complete ==1 and processState == 9">
  596. and (a.process_state = #{processState} and a.status =1)
  597. </if>
  598. <if test="complete ==2 and processState != 6 and processState != 8 and processState != 9 and processState !=3 and processState !=4">
  599. and a.process_state &gt; #{processState}
  600. </if>
  601. <if test="complete ==2 and processState == 6">
  602. and((a.process_state &gt; 6 and a.process_state &lt; 10) or (a.process_state =6 and a.status=4))
  603. </if>
  604. <if test="complete ==2 and processState == 8">
  605. and ((a.process_state = 8 and (a.status = 4 or a.status = 2))or a.process_state &gt; 8)
  606. </if>
  607. <if test="complete ==2 and processState == 9">
  608. and a.process_state = 9 and (a.status = 4 or a.status = 2)
  609. </if>
  610. <if test="complete ==3">
  611. and a.status = 2
  612. </if>
  613. <if test="complete ==4">
  614. and a.status = 4
  615. </if>
  616. <if test="complete ==5 and processState != 3 and processState != 4">
  617. and a.back_status &gt;= #{processState}
  618. </if>
  619. <if test="complete ==6">
  620. and a.status = 6
  621. </if>
  622. order by a.status,a.create_time desc
  623. <if test="page_sql != null">
  624. ${page_sql}
  625. </if>
  626. </select>
  627. <select id="selectOrderChangeCount" resultType="java.lang.Integer">
  628. select count(*) from new_order_change noc left join new_order_change a on noc.id=a.id
  629. left join t_order_new b on a.order_no=b.order_no left join user c on b.buyer_id=c.id
  630. left join admin d on b.salesman_id=d.id left join department e on b.order_dep=e.id
  631. <if test="processState==3">
  632. left join (select order_no, aid from order_examine where`type`=0
  633. <if test="complete ==1">
  634. and status=0
  635. </if>
  636. <if test="complete ==2">
  637. and status=1
  638. </if>
  639. group by order_no,aid)x on a.order_no = x.order_no
  640. </if>
  641. <if test="processState==4">
  642. left join (select order_no, aid from order_examine where`type`=1
  643. <if test="complete ==1">
  644. and status=0
  645. </if>
  646. <if test="complete ==2">
  647. and status=1
  648. </if>
  649. group by order_no,aid)x on a.order_no = x.order_no
  650. </if>
  651. where 1=1
  652. <if test="processState==0">
  653. and b.salesman_id= #{aid}
  654. </if>
  655. <if test="processState==1">
  656. and d.manager_id= #{aid}
  657. </if>
  658. <if test="processState==3 and complete !=5">
  659. and x.aid=#{aid} and a.process_state &gt;= #{processState}
  660. </if>
  661. <if test="processState==4 and complete !=5">
  662. and x.aid=#{aid} and a.process_state &gt;= #{processState}
  663. </if>
  664. <if test="processState==3 and complete ==5">
  665. and x.aid=#{aid} and a.back_status &gt;= #{processState}
  666. </if>
  667. <if test="processState==4 and complete ==5">
  668. and x.aid=#{aid} and a.back_status &gt;= #{processState}
  669. </if>
  670. <if test="processState==6 and aid !=null">
  671. and e.finance_id =#{aid}
  672. </if>
  673. <if test="processState==6 and aids !=null">
  674. and e.finance_id in
  675. <foreach close=")" collection="aids" item="id" open="(" separator=",">
  676. #{id}
  677. </foreach>
  678. </if>
  679. <if test="userName !=null">
  680. and c.nickname like concat('%',#{userName},'%')
  681. </if>
  682. <if test="orderNo !=null">
  683. and a.order_no like concat('%',#{orderNo},'%')
  684. </if>
  685. <if test="contractNo !=null">
  686. and b.contract_no like concat('%',#{contractNo},'%')
  687. </if>
  688. <if test="type !=null">
  689. and a.type = #{type}
  690. </if>
  691. <if test="timeType == 0 and startTime !=null and endTime !=null">
  692. and a.create_time between #{startTime} and #{endTime}
  693. </if>
  694. <if test="timeType == 1 and startTime !=null and endTime !=null">
  695. and b.create_time between #{startTime} and #{endTime}
  696. </if>
  697. <if test="deps !=null">
  698. and b.order_dep in
  699. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  700. #{depId}
  701. </foreach>
  702. </if>
  703. <if test="salesmanName !=null">
  704. and d.name like concat('%',#{salesmanName},'%')
  705. </if>
  706. <if test="complete ==0 and processState != 9 and processState != 5 and processState != 7">
  707. and (a.process_state &gt;= #{processState} or a.back_status &gt;= #{processState})
  708. </if>
  709. <if test="complete ==0 and processState == 9">
  710. and ((a.process_state &gt;= #{processState} and a.process_state &lt; 10)or a.back_status &gt;= #{processState})
  711. </if>
  712. <if test="complete ==0 and (processState == 5 or processState == 7)">
  713. and ((a.process_state &gt;= 1 and a.process_state &lt; 10)or a.back_status &gt;= #{processState})
  714. </if>
  715. <if test="complete ==1 and processState != 6 and processState != 8 and processState != 9">
  716. and a.process_state = #{processState} and a.status in (0,1,2,3)
  717. </if>
  718. <if test="complete ==1 and processState == 6">
  719. and (a.process_state in(6) and a.status in (0,1,2,3,5,6))
  720. </if>
  721. <if test="complete ==1 and processState == 8">
  722. and (a.process_state = 8 and a.status =1)
  723. </if>
  724. <if test="complete ==1 and processState == 9">
  725. and (a.process_state = #{processState} and a.status =1)
  726. </if>
  727. <if test="complete ==2 and processState != 6 and processState != 8 and processState != 9 and processState !=3 and processState !=4">
  728. and a.process_state &gt; #{processState}
  729. </if>
  730. <if test="complete ==2 and processState == 6">
  731. and((a.process_state &gt; 6 and a.process_state &lt; 10) or (a.process_state =6 and a.status=4))
  732. </if>
  733. <if test="complete ==2 and processState == 8">
  734. and ((a.process_state = 8 and (a.status = 4 or a.status = 2))or a.process_state &gt; 8)
  735. </if>
  736. <if test="complete ==2 and processState == 9">
  737. and a.process_state = 9 and (a.status = 4 or a.status = 2)
  738. </if>
  739. <if test="complete ==3">
  740. and a.status = 2
  741. </if>
  742. <if test="complete ==4">
  743. and a.status = 4
  744. </if>
  745. <if test="complete ==5 and processState != 3 and processState != 4">
  746. and a.back_status &gt;= #{processState}
  747. </if>
  748. <if test="complete ==6">
  749. and a.status = 6
  750. </if>
  751. </select>
  752. <update id="addRefundInvoice">
  753. update new_order_change
  754. set `refund_Invoice`=ifnull(`refund_Invoice`,0)+ #{amount}
  755. where order_no= #{orderNo}
  756. </update>
  757. <update id="subtractRefundInvoice">
  758. update new_order_change
  759. set `refund_Invoice`=ifnull(`refund_Invoice`,0)- #{amount}
  760. where order_no= #{orderNo}
  761. </update>
  762. <select id="getOrderChange" resultType="java.util.Map">
  763. select id,used_order usedOrder from new_order_change where order_no= #{orderNo} order by id desc
  764. </select>
  765. <update id="updateExamineName">
  766. update new_order_change a , t_order_new b ,(select a.department_id depId,group_concat(a.name) name
  767. from admin a left join user_role b on a.id=b.uid
  768. left join `role` c on b.rid =c.id
  769. where c.role_type ='9996' and a.status ='0' and a.department_id = #{depId}
  770. group by a.department_id ) c
  771. set a.examine_name =c.name
  772. where a.order_no =b.order_no and b.order_dep = #{depId} and b.order_dep =c.depId
  773. </update>
  774. <update id="updateTaskExamineName">
  775. update new_order_change n left join (select c.id
  776. from t_order_new a left join t_order_task b on a.order_no =b.order_no
  777. left join new_order_change c on a.order_no =c.order_no
  778. where (b.consultant_id in (#{aid},#{taskReceiverId}) or b.manager_id in (#{aid},#{taskReceiverId}))
  779. and c.process_state in (#{type}) group by c.id)x on n.id =x.id
  780. 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
  781. where 1=1
  782. <if test="type==3">
  783. and a.type=0
  784. </if>
  785. <if test="type==4">
  786. and a.type=1
  787. </if>
  788. group by a.order_no ) a on n.order_no =a.order_no
  789. set n.examine_name =a.name
  790. where n.process_state =#{type}
  791. </update>
  792. <update id="updateExamineById">
  793. update new_order_change a left join t_order_new b on a.order_no =b.order_no
  794. <if test="type==0 or type==1">
  795. left join admin c on b.salesman_id =c.id
  796. left join admin d on c.manager_id =d.id
  797. set a.examine_name=d.name
  798. where a.process_state =1 and d.id = #{id}
  799. </if>
  800. <if test="type==1">
  801. left join admin c on b.salesman_id =c.id
  802. set a.examine_name=c.name
  803. where a.process_state =1 and c.manager_id = #{id}
  804. </if>
  805. <if test="type==2">
  806. left join (select a.department_id depId,group_concat(a.name) name
  807. from admin a left join admin b on a.department_id =b.department_id
  808. left join user_role c on a.id=c.uid left join `role` d on c.rid =d.id
  809. where b.id= #{id} and d.role_type ='9996'
  810. and a.status ='0' group by b.department_id )x on b.order_dep=x.depId
  811. set a.examine_name=x.name
  812. where a.process_state =2
  813. </if>
  814. <if test="type==3">
  815. left join t_order_task c on a.order_no =c.order_no
  816. left join (select a.order_no ,a.`type` ,GROUP_CONCAT(distinct b.name) name
  817. from order_examine a left join admin b on a.aid=b.id where a.`type` =0
  818. group by order_no ,type)d on a.order_no =d.order_no
  819. set a.examine_name =d.name
  820. where a.process_state =3 and c.manager_id = #{id}
  821. </if>
  822. <if test="type==4">
  823. left join t_order_task c on a.order_no =c.order_no
  824. left join (select a.order_no ,a.`type` ,GROUP_CONCAT(distinct b.name) name
  825. from order_examine a left join admin b on a.aid=b.id where a.`type` =1
  826. group by order_no ,type)d on a.order_no =d.order_no
  827. set a.examine_name =d.name
  828. where a.process_state =3 and c.consultant_id = #{id}
  829. </if>
  830. <if test="type==6">
  831. left join department c on b.order_dep =c.id
  832. left join admin d on c.finance_id =d.id
  833. set a.examine_name=d.name
  834. where a.process_state =6 and d.id = #{id}
  835. </if>
  836. <if test="type==5 or type==7">
  837. left join (select group_concat(a.name) name
  838. from admin a left join user_role b on a.id=b.uid
  839. left join `role` c on b.rid =c.id
  840. <if test="type==5">
  841. where c.role_type in ('9998') and a.status ='0'
  842. </if>
  843. <if test="type==7">
  844. where c.role_type in ('9997') and a.status ='0'
  845. </if>
  846. )c on 1=1
  847. set a.examine_name =c.name
  848. where a.process_state = #{type}
  849. </if>
  850. </update>
  851. <select id="getProcessName" resultType="com.goafanti.order.bo.OutProcessName">
  852. select a.id,a.order_no orderNo ,a.`type`,a.change_amount changeAmount ,a.status,a.process_state processState,
  853. c.name yxy,mg.name yxjl, yxgly.name yxgly,zxs.name zxs,zxsjl.name zxsjl, zxsgly.name zxsgly,
  854. fm.name cwzy,cwgly.name cwgly, zc.name zc,dsz.name dsz,b.salesman_id salesmanId
  855. from new_order_change a
  856. left join t_order_new b on a.order_no =b.order_no
  857. left join admin c on b.salesman_id =c.id
  858. left join department dep on b.order_dep =dep.id
  859. left join admin fm on dep.finance_id =fm.id
  860. left join admin mg on c.manager_id =mg.id
  861. left join (select a.department_id depId,group_concat(a.name) name
  862. from admin a left join user_role b on a.id=b.uid
  863. left join `role` c on b.rid =c.id
  864. where c.role_type ='9996' and a.status ='0' group by a.department_id )yxgly on b.order_dep =yxgly.depId
  865. left join (select a.order_no ,a.`type` ,GROUP_CONCAT(distinct b.name) name
  866. from order_examine a left join admin b on a.aid=b.id where a.order_no = #{orderNo} and a.`type` =0
  867. group by order_no ,type)zxs on a.order_no =zxs.order_no
  868. left join (select a.order_no ,a.`type` ,GROUP_CONCAT(distinct b.name) name
  869. from order_examine a left join admin b on a.aid=b.id where a.order_no = #{orderNo} and a.`type` =1
  870. group by order_no ,type)zxsjl on a.order_no =zxsjl.order_no
  871. left join (select group_concat(a.name) name
  872. from admin a left join user_role b on a.id=b.uid
  873. left join `role` c on b.rid =c.id
  874. where c.role_type in ('99998','99988') and a.status ='0' ) zc on 1=1
  875. left join (select group_concat(a.name) name
  876. from admin a left join user_role b on a.id=b.uid
  877. left join `role` c on b.rid =c.id
  878. where c.role_type in ('99999','99989') and a.status ='0' ) dsz on 1=1
  879. left join (select group_concat(a.name) name
  880. from admin a left join user_role b on a.id=b.uid
  881. left join `role` c on b.rid =c.id
  882. where c.role_type in ('9998') and a.status ='0' ) zxsgly on 1=1
  883. left join (select group_concat(a.name) name
  884. from admin a left join user_role b on a.id=b.uid
  885. left join `role` c on b.rid =c.id
  886. where c.role_type in ('9997') and a.status ='0' ) cwgly on 1=1
  887. where a.id= #{id}
  888. </select>
  889. <select id="selectProcess" resultType="java.lang.Integer">
  890. select t0.id from (select x.id
  891. from (select a.id from new_order_change a left join t_order_task c on a.order_no =c.order_no
  892. where a.process_state= #{type}
  893. <if test="type==3">
  894. and c.consultant_id = #{aid}
  895. </if>
  896. <if test="type==4">
  897. and c.manager_id = #{aid}
  898. </if>
  899. group by a.id)x
  900. left join new_order_change z on x.id=z.id
  901. left join order_examine y on z.order_no=y.order_no
  902. where y.`type` =0 group by x.id)t0
  903. </select>
  904. </mapper>