TOrderMidMapper.xml 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  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.TOrderMidMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.TOrderMid">
  5. <id column="id" jdbcType="INTEGER" property="id" />
  6. <result column="order_no" jdbcType="VARCHAR" property="orderNo" />
  7. <result column="salesman_id" jdbcType="VARCHAR" property="salesmanId" />
  8. <result column="finance_id" jdbcType="VARCHAR" property="financeId" />
  9. <result column="salesman_name" jdbcType="VARCHAR" property="salesmanName" />
  10. <result column="finance_name" jdbcType="VARCHAR" property="financeName" />
  11. <result column="final_receivables" jdbcType="DECIMAL" property="finalReceivables" />
  12. <result column="final_Receivables_time" jdbcType="TIMESTAMP" property="finalReceivablesTime" />
  13. <result column="invoice_amount" jdbcType="DECIMAL" property="invoiceAmount" />
  14. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  15. <result column="buyer_name" jdbcType="VARCHAR" property="buyerName" />
  16. <result column="order_receivables" jdbcType="DECIMAL" property="orderReceivables" />
  17. <result column="order_arrears" jdbcType="DECIMAL" property="orderArrears" />
  18. <result column="payment_amount" jdbcType="DECIMAL" property="paymentAmount" />
  19. <result column="cost_amount" jdbcType="DECIMAL" property="costAmount" />
  20. <result column="dep_name" jdbcType="VARCHAR" property="depName" />
  21. <result column="province_name" jdbcType="VARCHAR" property="provinceName" />
  22. <result column="legal_affairs" jdbcType="INTEGER" property="legalAffairs" />
  23. <result column="dun_start_time" jdbcType="TIMESTAMP" property="dunStartTime" />
  24. <result column="legal_affairs_type" jdbcType="INTEGER" property="legalAffairsType" />
  25. <result column="operation_time" jdbcType="DATE" property="operationTime" />
  26. <result column="legal_affairs_status" jdbcType="INTEGER" property="legalAffairsStatus" />
  27. </resultMap>
  28. <sql id="Base_Column_List">
  29. id, order_no, salesman_id, finance_id, salesman_name, finance_name, final_receivables,
  30. final_Receivables_time, invoice_amount, create_time, buyer_name, order_receivables,
  31. order_arrears, payment_amount, cost_amount, dep_name, province_name, legal_affairs,
  32. dun_start_time, legal_affairs_type, operation_time, legal_affairs_status
  33. </sql>
  34. <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  35. select
  36. <include refid="Base_Column_List" />
  37. from t_order_mid
  38. where id = #{id,jdbcType=INTEGER}
  39. </select>
  40. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  41. delete from t_order_mid
  42. where id = #{id,jdbcType=INTEGER}
  43. </delete>
  44. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TOrderMid" useGeneratedKeys="true">
  45. insert into t_order_mid (order_no, salesman_id, finance_id,
  46. salesman_name, finance_name, final_receivables,
  47. final_Receivables_time, invoice_amount,
  48. create_time, buyer_name, order_receivables,
  49. order_arrears, payment_amount, cost_amount,
  50. dep_name, province_name, legal_affairs,
  51. dun_start_time, legal_affairs_type, operation_time,
  52. legal_affairs_status)
  53. values (#{orderNo,jdbcType=VARCHAR}, #{salesmanId,jdbcType=VARCHAR}, #{financeId,jdbcType=VARCHAR},
  54. #{salesmanName,jdbcType=VARCHAR}, #{financeName,jdbcType=VARCHAR}, #{finalReceivables,jdbcType=DECIMAL},
  55. #{finalReceivablesTime,jdbcType=TIMESTAMP}, #{invoiceAmount,jdbcType=DECIMAL},
  56. #{createTime,jdbcType=TIMESTAMP}, #{buyerName,jdbcType=VARCHAR}, #{orderReceivables,jdbcType=DECIMAL},
  57. #{orderArrears,jdbcType=DECIMAL}, #{paymentAmount,jdbcType=DECIMAL}, #{costAmount,jdbcType=DECIMAL},
  58. #{depName,jdbcType=VARCHAR}, #{provinceName,jdbcType=VARCHAR}, #{legalAffairs,jdbcType=INTEGER},
  59. #{dunStartTime,jdbcType=TIMESTAMP}, #{legalAffairsType,jdbcType=INTEGER}, #{operationTime,jdbcType=DATE},
  60. #{legalAffairsStatus,jdbcType=INTEGER})
  61. </insert>
  62. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TOrderMid" useGeneratedKeys="true">
  63. insert into t_order_mid
  64. <trim prefix="(" suffix=")" suffixOverrides=",">
  65. <if test="orderNo != null">
  66. order_no,
  67. </if>
  68. <if test="salesmanId != null">
  69. salesman_id,
  70. </if>
  71. <if test="financeId != null">
  72. finance_id,
  73. </if>
  74. <if test="salesmanName != null">
  75. salesman_name,
  76. </if>
  77. <if test="financeName != null">
  78. finance_name,
  79. </if>
  80. <if test="finalReceivables != null">
  81. final_receivables,
  82. </if>
  83. <if test="finalReceivablesTime != null">
  84. final_Receivables_time,
  85. </if>
  86. <if test="invoiceAmount != null">
  87. invoice_amount,
  88. </if>
  89. <if test="createTime != null">
  90. create_time,
  91. </if>
  92. <if test="buyerName != null">
  93. buyer_name,
  94. </if>
  95. <if test="orderReceivables != null">
  96. order_receivables,
  97. </if>
  98. <if test="orderArrears != null">
  99. order_arrears,
  100. </if>
  101. <if test="paymentAmount != null">
  102. payment_amount,
  103. </if>
  104. <if test="costAmount != null">
  105. cost_amount,
  106. </if>
  107. <if test="depName != null">
  108. dep_name,
  109. </if>
  110. <if test="provinceName != null">
  111. province_name,
  112. </if>
  113. <if test="legalAffairs != null">
  114. legal_affairs,
  115. </if>
  116. <if test="dunStartTime != null">
  117. dun_start_time,
  118. </if>
  119. <if test="legalAffairsType != null">
  120. legal_affairs_type,
  121. </if>
  122. <if test="operationTime != null">
  123. operation_time,
  124. </if>
  125. <if test="legalAffairsStatus != null">
  126. legal_affairs_status,
  127. </if>
  128. </trim>
  129. <trim prefix="values (" suffix=")" suffixOverrides=",">
  130. <if test="orderNo != null">
  131. #{orderNo,jdbcType=VARCHAR},
  132. </if>
  133. <if test="salesmanId != null">
  134. #{salesmanId,jdbcType=VARCHAR},
  135. </if>
  136. <if test="financeId != null">
  137. #{financeId,jdbcType=VARCHAR},
  138. </if>
  139. <if test="salesmanName != null">
  140. #{salesmanName,jdbcType=VARCHAR},
  141. </if>
  142. <if test="financeName != null">
  143. #{financeName,jdbcType=VARCHAR},
  144. </if>
  145. <if test="finalReceivables != null">
  146. #{finalReceivables,jdbcType=DECIMAL},
  147. </if>
  148. <if test="finalReceivablesTime != null">
  149. #{finalReceivablesTime,jdbcType=TIMESTAMP},
  150. </if>
  151. <if test="invoiceAmount != null">
  152. #{invoiceAmount,jdbcType=DECIMAL},
  153. </if>
  154. <if test="createTime != null">
  155. #{createTime,jdbcType=TIMESTAMP},
  156. </if>
  157. <if test="buyerName != null">
  158. #{buyerName,jdbcType=VARCHAR},
  159. </if>
  160. <if test="orderReceivables != null">
  161. #{orderReceivables,jdbcType=DECIMAL},
  162. </if>
  163. <if test="orderArrears != null">
  164. #{orderArrears,jdbcType=DECIMAL},
  165. </if>
  166. <if test="paymentAmount != null">
  167. #{paymentAmount,jdbcType=DECIMAL},
  168. </if>
  169. <if test="costAmount != null">
  170. #{costAmount,jdbcType=DECIMAL},
  171. </if>
  172. <if test="depName != null">
  173. #{depName,jdbcType=VARCHAR},
  174. </if>
  175. <if test="provinceName != null">
  176. #{provinceName,jdbcType=VARCHAR},
  177. </if>
  178. <if test="legalAffairs != null">
  179. #{legalAffairs,jdbcType=INTEGER},
  180. </if>
  181. <if test="dunStartTime != null">
  182. #{dunStartTime,jdbcType=TIMESTAMP},
  183. </if>
  184. <if test="legalAffairsType != null">
  185. #{legalAffairsType,jdbcType=INTEGER},
  186. </if>
  187. <if test="operationTime != null">
  188. #{operationTime,jdbcType=DATE},
  189. </if>
  190. <if test="legalAffairsStatus != null">
  191. #{legalAffairsStatus,jdbcType=INTEGER},
  192. </if>
  193. </trim>
  194. </insert>
  195. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.TOrderMid">
  196. update t_order_mid
  197. <set>
  198. <if test="orderNo != null">
  199. order_no = #{orderNo,jdbcType=VARCHAR},
  200. </if>
  201. <if test="salesmanId != null">
  202. salesman_id = #{salesmanId,jdbcType=VARCHAR},
  203. </if>
  204. <if test="financeId != null">
  205. finance_id = #{financeId,jdbcType=VARCHAR},
  206. </if>
  207. <if test="salesmanName != null">
  208. salesman_name = #{salesmanName,jdbcType=VARCHAR},
  209. </if>
  210. <if test="financeName != null">
  211. finance_name = #{financeName,jdbcType=VARCHAR},
  212. </if>
  213. <if test="finalReceivables != null">
  214. final_receivables = #{finalReceivables,jdbcType=DECIMAL},
  215. </if>
  216. <if test="finalReceivablesTime != null">
  217. final_Receivables_time = #{finalReceivablesTime,jdbcType=TIMESTAMP},
  218. </if>
  219. <if test="invoiceAmount != null">
  220. invoice_amount = #{invoiceAmount,jdbcType=DECIMAL},
  221. </if>
  222. <if test="createTime != null">
  223. create_time = #{createTime,jdbcType=TIMESTAMP},
  224. </if>
  225. <if test="buyerName != null">
  226. buyer_name = #{buyerName,jdbcType=VARCHAR},
  227. </if>
  228. <if test="orderReceivables != null">
  229. order_receivables = #{orderReceivables,jdbcType=DECIMAL},
  230. </if>
  231. <if test="orderArrears != null">
  232. order_arrears = #{orderArrears,jdbcType=DECIMAL},
  233. </if>
  234. <if test="paymentAmount != null">
  235. payment_amount = #{paymentAmount,jdbcType=DECIMAL},
  236. </if>
  237. <if test="costAmount != null">
  238. cost_amount = #{costAmount,jdbcType=DECIMAL},
  239. </if>
  240. <if test="depName != null">
  241. dep_name = #{depName,jdbcType=VARCHAR},
  242. </if>
  243. <if test="provinceName != null">
  244. province_name = #{provinceName,jdbcType=VARCHAR},
  245. </if>
  246. <if test="legalAffairs != null">
  247. legal_affairs = #{legalAffairs,jdbcType=INTEGER},
  248. </if>
  249. <if test="dunStartTime != null">
  250. dun_start_time = #{dunStartTime,jdbcType=TIMESTAMP},
  251. </if>
  252. <if test="legalAffairsType != null">
  253. legal_affairs_type = #{legalAffairsType,jdbcType=INTEGER},
  254. </if>
  255. <if test="operationTime != null">
  256. operation_time = #{operationTime,jdbcType=DATE},
  257. </if>
  258. <if test="legalAffairsStatus != null">
  259. legal_affairs_status = #{legalAffairsStatus,jdbcType=INTEGER},
  260. </if>
  261. </set>
  262. where id = #{id,jdbcType=INTEGER}
  263. </update>
  264. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.TOrderMid">
  265. update t_order_mid
  266. set order_no = #{orderNo,jdbcType=VARCHAR},
  267. salesman_id = #{salesmanId,jdbcType=VARCHAR},
  268. finance_id = #{financeId,jdbcType=VARCHAR},
  269. salesman_name = #{salesmanName,jdbcType=VARCHAR},
  270. finance_name = #{financeName,jdbcType=VARCHAR},
  271. final_receivables = #{finalReceivables,jdbcType=DECIMAL},
  272. final_Receivables_time = #{finalReceivablesTime,jdbcType=TIMESTAMP},
  273. invoice_amount = #{invoiceAmount,jdbcType=DECIMAL},
  274. create_time = #{createTime,jdbcType=TIMESTAMP},
  275. buyer_name = #{buyerName,jdbcType=VARCHAR},
  276. order_receivables = #{orderReceivables,jdbcType=DECIMAL},
  277. order_arrears = #{orderArrears,jdbcType=DECIMAL},
  278. payment_amount = #{paymentAmount,jdbcType=DECIMAL},
  279. cost_amount = #{costAmount,jdbcType=DECIMAL},
  280. dep_name = #{depName,jdbcType=VARCHAR},
  281. province_name = #{provinceName,jdbcType=VARCHAR},
  282. legal_affairs = #{legalAffairs,jdbcType=INTEGER},
  283. dun_start_time = #{dunStartTime,jdbcType=TIMESTAMP},
  284. legal_affairs_type = #{legalAffairsType,jdbcType=INTEGER},
  285. operation_time = #{operationTime,jdbcType=DATE},
  286. legal_affairs_status = #{legalAffairsStatus,jdbcType=INTEGER}
  287. where id = #{id,jdbcType=INTEGER}
  288. </update>
  289. <select id="selectByOrderNo" resultMap="BaseResultMap">
  290. select
  291. <include refid="Base_Column_List" />
  292. from t_order_mid
  293. where order_no = #{id,jdbcType=INTEGER}
  294. </select>
  295. <update id="updateSalesmanId">
  296. update t_order_mid a ,admin b set a.salesman_id=#{transferId},a.salesman_name=b.name
  297. where b.id=#{transferId} and a.salesman_id=#{aid}
  298. </update>
  299. <update id="updateFinanceId">
  300. update t_order_new a ,t_order_mid b,admin c set b.finance_id=#{financeId},b.finance_name=c.name
  301. where a.order_dep=#{id} and a.order_no=b.order_no and c.id= #{financeId}
  302. </update>
  303. <update id="updatefinalReceivables">
  304. update t_order_mid set final_receivables= #{amount},`final_Receivables_time`= #{receivablesTime},
  305. order_arrears=if(order_arrears- #{amount} &lt; 0,0,order_arrears- #{amount})
  306. where order_no= #{orderNo}
  307. </update>
  308. <update id="updateInvoice">
  309. update t_order_mid m,(select order_no,sum(amount)amount from t_order_invoice where status=2 group by order_no)b
  310. set m.invoice_amount=b.amount where m.order_no= #{orderNo} and m.order_no=b.order_no
  311. </update>
  312. <update id="addOrderReceivables">
  313. update t_order_mid set order_receivables=order_receivables+#{money},
  314. order_arrears=order_arrears+#{money}
  315. where order_no=#{orderNo}
  316. </update>
  317. <select id="selectDepNameByDepid" resultType="java.lang.String">
  318. select name from department where id= #{orderDep}
  319. </select>
  320. <update id="updateCostAmount">
  321. update t_order_task a ,t_order_mid b
  322. <set>
  323. <if test="cost !=null">
  324. b.cost_amount= #{cost},
  325. </if>
  326. <if test="payment !=null">
  327. b.payment_amount= #{payment},
  328. </if>
  329. </set>
  330. where a.order_no=b.order_no and a.id= #{tid}
  331. </update>
  332. <update id="updateAddCostAmount">
  333. update t_order_task a ,t_order_mid b
  334. <set>
  335. <if test="cost !=null">
  336. b.cost_amount= b.cost_amount+#{cost},
  337. </if>
  338. </set>
  339. where a.order_no=b.order_no and a.id= #{tid}
  340. </update>
  341. <update id="updateByOrderNo">
  342. update t_order_mid
  343. <set>
  344. <if test="salesmanId != null">
  345. salesman_id = #{salesmanId,jdbcType=VARCHAR},
  346. </if>
  347. <if test="financeId != null">
  348. finance_id = #{financeId,jdbcType=VARCHAR},
  349. </if>
  350. <if test="salesmanName != null">
  351. salesman_name = #{salesmanName,jdbcType=VARCHAR},
  352. </if>
  353. <if test="financeName != null">
  354. finance_name = #{financeName,jdbcType=VARCHAR},
  355. </if>
  356. <if test="finalReceivables != null">
  357. final_receivables = #{finalReceivables,jdbcType=DECIMAL},
  358. </if>
  359. <if test="finalReceivablesTime != null">
  360. final_Receivables_time = #{finalReceivablesTime,jdbcType=TIMESTAMP},
  361. </if>
  362. <if test="invoiceAmount != null">
  363. invoice_amount = #{invoiceAmount,jdbcType=DECIMAL},
  364. </if>
  365. <if test="createTime != null">
  366. create_time = #{createTime,jdbcType=TIMESTAMP},
  367. </if>
  368. <if test="buyerName != null">
  369. buyer_name = #{buyerName,jdbcType=VARCHAR},
  370. </if>
  371. <if test="orderReceivables != null">
  372. order_receivables = #{orderReceivables,jdbcType=DECIMAL},
  373. </if>
  374. <if test="orderArrears != null">
  375. order_arrears = #{orderArrears,jdbcType=DECIMAL},
  376. </if>
  377. <if test="paymentAmount != null">
  378. payment_amount = #{paymentAmount,jdbcType=DECIMAL},
  379. </if>
  380. <if test="costAmount != null">
  381. cost_amount = #{costAmount,jdbcType=DECIMAL},
  382. </if>
  383. <if test="depName != null">
  384. dep_name = #{depName,jdbcType=VARCHAR},
  385. </if>
  386. <if test="provinceName != null">
  387. province_name = #{provinceName,jdbcType=VARCHAR},
  388. </if>
  389. <if test="legalAffairs != null">
  390. legal_affairs = #{legalAffairs,jdbcType=INTEGER},
  391. </if>
  392. <if test="dunStartTime != null">
  393. dun_start_time = #{dunStartTime,jdbcType=TIMESTAMP},
  394. </if>
  395. <if test="legalAffairsType != null">
  396. legal_affairs_type = #{legalAffairsType,jdbcType=INTEGER},
  397. </if>
  398. <if test="operationTime != null">
  399. operation_time = #{operationTime,jdbcType=DATE},
  400. </if>
  401. <if test="legalAffairsStatus != null">
  402. legal_affairs_status = #{legalAffairsStatus,jdbcType=INTEGER},
  403. </if>
  404. </set>
  405. where order_no = #{orderNo,jdbcType=VARCHAR}
  406. </update>
  407. <select id="legalAffairsOrderList" resultType="com.goafanti.order.bo.OutOrderLegalAffairsListBo">
  408. select a.order_no orderNo,a.contract_no contractNo,b.buyer_name buyerName,b.salesman_name salesmanName,b.dep_name depName,
  409. a.total_amount totalAmount ,a.settlement_amount settlementAmount ,b.order_receivables orderReceivables,b.legal_affairs legalAffairs,
  410. b.order_arrears orderArrears,b.dun_start_time dunStartTime,date_format(b.dun_start_time,'%Y-%m-%d %H:%i:%S')dunStartTimes
  411. <if test="type==1 or type==2 or type==3">
  412. ,b.operation_time operationTime,date_format(b.operation_time,'%Y-%m-%d')operationDate,b.legal_affairs_type `type`
  413. </if>
  414. from t_order_new a left join t_order_mid b on a.order_no =b.order_no
  415. <if test="shiro == 2">
  416. left join admin c on a.salesman_id =c.id
  417. </if>
  418. where 1=1 and a.delete_sign in (0,2)
  419. <if test="type==1 or type==2 or type==3">
  420. and b.legal_affairs =1
  421. and b.legal_affairs_type = (#{type}-1)
  422. </if>
  423. <if test="type==0">
  424. and b.order_receivables >0
  425. </if>
  426. <if test="status != null">
  427. and b.legal_affairs_status = #{status}
  428. </if>
  429. <if test="shiro==1">
  430. and a.order_type in
  431. <foreach close=")" collection="deps" item="dep" open="(" separator=",">
  432. #{dep}
  433. </foreach>
  434. </if>
  435. <if test="shiro ==2">
  436. and c.superior_id = #{sid}
  437. </if>
  438. <if test="userName != null">
  439. and b.buyer_name like concat('%',#{userName},'%')
  440. </if>
  441. <if test="legalAffairs != null">
  442. and b.legal_affairs = #{legalAffairs}
  443. </if>
  444. <if test="contractNo != null">
  445. and a.contract_no like concat('%',#{contractNo},'%')
  446. </if>
  447. <if test="aid != null">
  448. and b.salesman_id = #{aid}
  449. </if>
  450. <if test="depId != null">
  451. and a.order_dep = #{depId}
  452. </if>
  453. <if test="type==0">
  454. <if test="startTime != null and endTime != null">
  455. and b.dun_start_time between #{startTime} and #{endTime}
  456. </if>
  457. </if>
  458. <if test="type==1 or type==2 or type==3">
  459. <if test="startTime != null and endTime != null">
  460. and b.operation_time between #{startTime} and #{endTime}
  461. </if>
  462. </if>
  463. order by b.dun_start_time
  464. <if test="page_sql != null">
  465. ${page_sql}
  466. </if>
  467. </select>
  468. <select id="legalAffairsOrderCount" resultType="integer">
  469. select count(*)
  470. from t_order_new a left join t_order_mid b on a.order_no =b.order_no
  471. <if test="type==3">
  472. left join t_order_legal_affairs d on a.order_no=d.order_no
  473. </if>
  474. <if test="shiro == 2">
  475. left join admin c on a.salesman_id =c.id
  476. </if>
  477. where 1=1 and a.delete_sign in (0,2)
  478. <if test="type==1 or type==2 or type==3">
  479. and b.legal_affairs =1
  480. and b.legal_affairs_type = (#{type}-1)
  481. </if>
  482. <if test="type==0">
  483. and b.order_receivables >0
  484. </if>
  485. <if test="status != null">
  486. and b.legal_affairs_status = #{status}
  487. </if>
  488. <if test="shiro==1">
  489. and a.order_type in
  490. <foreach close=")" collection="deps" item="dep" open="(" separator=",">
  491. #{dep}
  492. </foreach>
  493. </if>
  494. <if test="shiro ==2">
  495. and c.superior_id = #{sid}
  496. </if>
  497. <if test="userName != null">
  498. and b.buyer_name like concat('%',#{userName},'%')
  499. </if>
  500. <if test="legalAffairs != null">
  501. and b.legal_affairs = #{legalAffairs}
  502. </if>
  503. <if test="contractNo != null">
  504. and a.contract_no like concat('%',#{contractNo},'%')
  505. </if>
  506. <if test="aid != null">
  507. and b.salesman_id = #{aid}
  508. </if>
  509. <if test="depId != null">
  510. and a.order_dep = #{depId}
  511. </if>
  512. <if test="type==0">
  513. <if test="startTime != null and endTime != null">
  514. and b.dun_start_time between #{startTime} and #{endTime}
  515. </if>
  516. </if>
  517. <if test="type==1 or type==2 or type==3">
  518. <if test="startTime != null and endTime != null">
  519. and b.operation_time between #{startTime} and #{endTime}
  520. </if>
  521. </if>
  522. </select>
  523. <update id="updateByList">
  524. update t_order_mid
  525. set legal_affairs=1,legal_affairs_type =0
  526. where order_no in(
  527. <foreach collection="list" index="index" item="item" separator=",">
  528. #{item}
  529. </foreach>
  530. )
  531. </update>
  532. </mapper>