TOrderMidMapper.xml 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  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. <result column="project_type" jdbcType="INTEGER" property="projectType" />
  28. <result column="service_type" jdbcType="VARCHAR" property="serviceType" />
  29. <result column="service_project" jdbcType="VARCHAR" property="serviceProject" />
  30. <result column="patent_cost" jdbcType="DECIMAL" property="patentCost" />
  31. <result column="patent_cost_actual" jdbcType="DECIMAL" property="patentCostActual" />
  32. <result column="soft_cost" jdbcType="DECIMAL" property="softCost" />
  33. <result column="soft_cost_actual" jdbcType="DECIMAL" property="softCostActual" />
  34. <result column="audit_cost" jdbcType="DECIMAL" property="auditCost" />
  35. <result column="audit_cost_actual" jdbcType="DECIMAL" property="auditCostActual" />
  36. <result column="other_cost" jdbcType="DECIMAL" property="otherCost" />
  37. <result column="other_cost_actual" jdbcType="DECIMAL" property="otherCostActual" />
  38. <result column="expect_profit" jdbcType="DECIMAL" property="expectProfit" />
  39. <result column="actual_profit" jdbcType="DECIMAL" property="actualProfit" />
  40. </resultMap>
  41. <sql id="Base_Column_List">
  42. id, order_no, salesman_id, finance_id, salesman_name, finance_name, final_receivables,
  43. final_Receivables_time, invoice_amount, create_time, buyer_name, order_receivables,
  44. order_arrears, payment_amount, cost_amount, dep_name, province_name, legal_affairs,
  45. dun_start_time, legal_affairs_type, operation_time, legal_affairs_status, project_type,
  46. service_type, service_project, patent_cost, patent_cost_actual, soft_cost, soft_cost_actual,
  47. audit_cost, audit_cost_actual, other_cost, other_cost_actual, expect_profit, actual_profit
  48. </sql>
  49. <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  50. select
  51. <include refid="Base_Column_List" />
  52. from t_order_mid
  53. where id = #{id,jdbcType=INTEGER}
  54. </select>
  55. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  56. delete from t_order_mid
  57. where id = #{id,jdbcType=INTEGER}
  58. </delete>
  59. <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TOrderMid" useGeneratedKeys="true">
  60. insert into t_order_mid (order_no, salesman_id, finance_id,
  61. salesman_name, finance_name, final_receivables,
  62. final_Receivables_time, invoice_amount,
  63. create_time, buyer_name, order_receivables,
  64. order_arrears, payment_amount, cost_amount,
  65. dep_name, province_name, legal_affairs,
  66. dun_start_time, legal_affairs_type, operation_time,
  67. legal_affairs_status, project_type, service_type,
  68. service_project, patent_cost, patent_cost_actual,
  69. soft_cost, soft_cost_actual, audit_cost,
  70. audit_cost_actual, other_cost, other_cost_actual,
  71. expect_profit, actual_profit)
  72. values (#{orderNo,jdbcType=VARCHAR}, #{salesmanId,jdbcType=VARCHAR}, #{financeId,jdbcType=VARCHAR},
  73. #{salesmanName,jdbcType=VARCHAR}, #{financeName,jdbcType=VARCHAR}, #{finalReceivables,jdbcType=DECIMAL},
  74. #{finalReceivablesTime,jdbcType=TIMESTAMP}, #{invoiceAmount,jdbcType=DECIMAL},
  75. #{createTime,jdbcType=TIMESTAMP}, #{buyerName,jdbcType=VARCHAR}, #{orderReceivables,jdbcType=DECIMAL},
  76. #{orderArrears,jdbcType=DECIMAL}, #{paymentAmount,jdbcType=DECIMAL}, #{costAmount,jdbcType=DECIMAL},
  77. #{depName,jdbcType=VARCHAR}, #{provinceName,jdbcType=VARCHAR}, #{legalAffairs,jdbcType=INTEGER},
  78. #{dunStartTime,jdbcType=TIMESTAMP}, #{legalAffairsType,jdbcType=INTEGER}, #{operationTime,jdbcType=DATE},
  79. #{legalAffairsStatus,jdbcType=INTEGER}, #{projectType,jdbcType=INTEGER}, #{serviceType,jdbcType=VARCHAR},
  80. #{serviceProject,jdbcType=VARCHAR}, #{patentCost,jdbcType=DECIMAL}, #{patentCostActual,jdbcType=DECIMAL},
  81. #{softCost,jdbcType=DECIMAL}, #{softCostActual,jdbcType=DECIMAL}, #{auditCost,jdbcType=DECIMAL},
  82. #{auditCostActual,jdbcType=DECIMAL}, #{otherCost,jdbcType=DECIMAL}, #{otherCostActual,jdbcType=DECIMAL},
  83. #{expectProfit,jdbcType=DECIMAL}, #{actualProfit,jdbcType=DECIMAL})
  84. </insert>
  85. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TOrderMid" useGeneratedKeys="true">
  86. insert into t_order_mid
  87. <trim prefix="(" suffix=")" suffixOverrides=",">
  88. <if test="orderNo != null">
  89. order_no,
  90. </if>
  91. <if test="salesmanId != null">
  92. salesman_id,
  93. </if>
  94. <if test="financeId != null">
  95. finance_id,
  96. </if>
  97. <if test="salesmanName != null">
  98. salesman_name,
  99. </if>
  100. <if test="financeName != null">
  101. finance_name,
  102. </if>
  103. <if test="finalReceivables != null">
  104. final_receivables,
  105. </if>
  106. <if test="finalReceivablesTime != null">
  107. final_Receivables_time,
  108. </if>
  109. <if test="invoiceAmount != null">
  110. invoice_amount,
  111. </if>
  112. <if test="createTime != null">
  113. create_time,
  114. </if>
  115. <if test="buyerName != null">
  116. buyer_name,
  117. </if>
  118. <if test="orderReceivables != null">
  119. order_receivables,
  120. </if>
  121. <if test="orderArrears != null">
  122. order_arrears,
  123. </if>
  124. <if test="paymentAmount != null">
  125. payment_amount,
  126. </if>
  127. <if test="costAmount != null">
  128. cost_amount,
  129. </if>
  130. <if test="depName != null">
  131. dep_name,
  132. </if>
  133. <if test="provinceName != null">
  134. province_name,
  135. </if>
  136. <if test="legalAffairs != null">
  137. legal_affairs,
  138. </if>
  139. <if test="dunStartTime != null">
  140. dun_start_time,
  141. </if>
  142. <if test="legalAffairsType != null">
  143. legal_affairs_type,
  144. </if>
  145. <if test="operationTime != null">
  146. operation_time,
  147. </if>
  148. <if test="legalAffairsStatus != null">
  149. legal_affairs_status,
  150. </if>
  151. <if test="projectType != null">
  152. project_type,
  153. </if>
  154. <if test="serviceType != null">
  155. service_type,
  156. </if>
  157. <if test="serviceProject != null">
  158. service_project,
  159. </if>
  160. <if test="patentCost != null">
  161. patent_cost,
  162. </if>
  163. <if test="patentCostActual != null">
  164. patent_cost_actual,
  165. </if>
  166. <if test="softCost != null">
  167. soft_cost,
  168. </if>
  169. <if test="softCostActual != null">
  170. soft_cost_actual,
  171. </if>
  172. <if test="auditCost != null">
  173. audit_cost,
  174. </if>
  175. <if test="auditCostActual != null">
  176. audit_cost_actual,
  177. </if>
  178. <if test="otherCost != null">
  179. other_cost,
  180. </if>
  181. <if test="otherCostActual != null">
  182. other_cost_actual,
  183. </if>
  184. <if test="expectProfit != null">
  185. expect_profit,
  186. </if>
  187. <if test="actualProfit != null">
  188. actual_profit,
  189. </if>
  190. </trim>
  191. <trim prefix="values (" suffix=")" suffixOverrides=",">
  192. <if test="orderNo != null">
  193. #{orderNo,jdbcType=VARCHAR},
  194. </if>
  195. <if test="salesmanId != null">
  196. #{salesmanId,jdbcType=VARCHAR},
  197. </if>
  198. <if test="financeId != null">
  199. #{financeId,jdbcType=VARCHAR},
  200. </if>
  201. <if test="salesmanName != null">
  202. #{salesmanName,jdbcType=VARCHAR},
  203. </if>
  204. <if test="financeName != null">
  205. #{financeName,jdbcType=VARCHAR},
  206. </if>
  207. <if test="finalReceivables != null">
  208. #{finalReceivables,jdbcType=DECIMAL},
  209. </if>
  210. <if test="finalReceivablesTime != null">
  211. #{finalReceivablesTime,jdbcType=TIMESTAMP},
  212. </if>
  213. <if test="invoiceAmount != null">
  214. #{invoiceAmount,jdbcType=DECIMAL},
  215. </if>
  216. <if test="createTime != null">
  217. #{createTime,jdbcType=TIMESTAMP},
  218. </if>
  219. <if test="buyerName != null">
  220. #{buyerName,jdbcType=VARCHAR},
  221. </if>
  222. <if test="orderReceivables != null">
  223. #{orderReceivables,jdbcType=DECIMAL},
  224. </if>
  225. <if test="orderArrears != null">
  226. #{orderArrears,jdbcType=DECIMAL},
  227. </if>
  228. <if test="paymentAmount != null">
  229. #{paymentAmount,jdbcType=DECIMAL},
  230. </if>
  231. <if test="costAmount != null">
  232. #{costAmount,jdbcType=DECIMAL},
  233. </if>
  234. <if test="depName != null">
  235. #{depName,jdbcType=VARCHAR},
  236. </if>
  237. <if test="provinceName != null">
  238. #{provinceName,jdbcType=VARCHAR},
  239. </if>
  240. <if test="legalAffairs != null">
  241. #{legalAffairs,jdbcType=INTEGER},
  242. </if>
  243. <if test="dunStartTime != null">
  244. #{dunStartTime,jdbcType=TIMESTAMP},
  245. </if>
  246. <if test="legalAffairsType != null">
  247. #{legalAffairsType,jdbcType=INTEGER},
  248. </if>
  249. <if test="operationTime != null">
  250. #{operationTime,jdbcType=DATE},
  251. </if>
  252. <if test="legalAffairsStatus != null">
  253. #{legalAffairsStatus,jdbcType=INTEGER},
  254. </if>
  255. <if test="projectType != null">
  256. #{projectType,jdbcType=INTEGER},
  257. </if>
  258. <if test="serviceType != null">
  259. #{serviceType,jdbcType=VARCHAR},
  260. </if>
  261. <if test="serviceProject != null">
  262. #{serviceProject,jdbcType=VARCHAR},
  263. </if>
  264. <if test="patentCost != null">
  265. #{patentCost,jdbcType=DECIMAL},
  266. </if>
  267. <if test="patentCostActual != null">
  268. #{patentCostActual,jdbcType=DECIMAL},
  269. </if>
  270. <if test="softCost != null">
  271. #{softCost,jdbcType=DECIMAL},
  272. </if>
  273. <if test="softCostActual != null">
  274. #{softCostActual,jdbcType=DECIMAL},
  275. </if>
  276. <if test="auditCost != null">
  277. #{auditCost,jdbcType=DECIMAL},
  278. </if>
  279. <if test="auditCostActual != null">
  280. #{auditCostActual,jdbcType=DECIMAL},
  281. </if>
  282. <if test="otherCost != null">
  283. #{otherCost,jdbcType=DECIMAL},
  284. </if>
  285. <if test="otherCostActual != null">
  286. #{otherCostActual,jdbcType=DECIMAL},
  287. </if>
  288. <if test="expectProfit != null">
  289. #{expectProfit,jdbcType=DECIMAL},
  290. </if>
  291. <if test="actualProfit != null">
  292. #{actualProfit,jdbcType=DECIMAL},
  293. </if>
  294. </trim>
  295. </insert>
  296. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.TOrderMid">
  297. update t_order_mid
  298. <set>
  299. <if test="orderNo != null">
  300. order_no = #{orderNo,jdbcType=VARCHAR},
  301. </if>
  302. <if test="salesmanId != null">
  303. salesman_id = #{salesmanId,jdbcType=VARCHAR},
  304. </if>
  305. <if test="financeId != null">
  306. finance_id = #{financeId,jdbcType=VARCHAR},
  307. </if>
  308. <if test="salesmanName != null">
  309. salesman_name = #{salesmanName,jdbcType=VARCHAR},
  310. </if>
  311. <if test="financeName != null">
  312. finance_name = #{financeName,jdbcType=VARCHAR},
  313. </if>
  314. <if test="finalReceivables != null">
  315. final_receivables = #{finalReceivables,jdbcType=DECIMAL},
  316. </if>
  317. <if test="finalReceivablesTime != null">
  318. final_Receivables_time = #{finalReceivablesTime,jdbcType=TIMESTAMP},
  319. </if>
  320. <if test="invoiceAmount != null">
  321. invoice_amount = #{invoiceAmount,jdbcType=DECIMAL},
  322. </if>
  323. <if test="createTime != null">
  324. create_time = #{createTime,jdbcType=TIMESTAMP},
  325. </if>
  326. <if test="buyerName != null">
  327. buyer_name = #{buyerName,jdbcType=VARCHAR},
  328. </if>
  329. <if test="orderReceivables != null">
  330. order_receivables = #{orderReceivables,jdbcType=DECIMAL},
  331. </if>
  332. <if test="orderArrears != null">
  333. order_arrears = #{orderArrears,jdbcType=DECIMAL},
  334. </if>
  335. <if test="paymentAmount != null">
  336. payment_amount = #{paymentAmount,jdbcType=DECIMAL},
  337. </if>
  338. <if test="costAmount != null">
  339. cost_amount = #{costAmount,jdbcType=DECIMAL},
  340. </if>
  341. <if test="depName != null">
  342. dep_name = #{depName,jdbcType=VARCHAR},
  343. </if>
  344. <if test="provinceName != null">
  345. province_name = #{provinceName,jdbcType=VARCHAR},
  346. </if>
  347. <if test="legalAffairs != null">
  348. legal_affairs = #{legalAffairs,jdbcType=INTEGER},
  349. </if>
  350. <if test="dunStartTime != null">
  351. dun_start_time = #{dunStartTime,jdbcType=TIMESTAMP},
  352. </if>
  353. <if test="legalAffairsType != null">
  354. legal_affairs_type = #{legalAffairsType,jdbcType=INTEGER},
  355. </if>
  356. <if test="operationTime != null">
  357. operation_time = #{operationTime,jdbcType=DATE},
  358. </if>
  359. <if test="legalAffairsStatus != null">
  360. legal_affairs_status = #{legalAffairsStatus,jdbcType=INTEGER},
  361. </if>
  362. <if test="projectType != null">
  363. project_type = #{projectType,jdbcType=INTEGER},
  364. </if>
  365. <if test="serviceType != null">
  366. service_type = #{serviceType,jdbcType=VARCHAR},
  367. </if>
  368. <if test="serviceProject != null">
  369. service_project = #{serviceProject,jdbcType=VARCHAR},
  370. </if>
  371. <if test="patentCost != null">
  372. patent_cost = #{patentCost,jdbcType=DECIMAL},
  373. </if>
  374. <if test="patentCostActual != null">
  375. patent_cost_actual = #{patentCostActual,jdbcType=DECIMAL},
  376. </if>
  377. <if test="softCost != null">
  378. soft_cost = #{softCost,jdbcType=DECIMAL},
  379. </if>
  380. <if test="softCostActual != null">
  381. soft_cost_actual = #{softCostActual,jdbcType=DECIMAL},
  382. </if>
  383. <if test="auditCost != null">
  384. audit_cost = #{auditCost,jdbcType=DECIMAL},
  385. </if>
  386. <if test="auditCostActual != null">
  387. audit_cost_actual = #{auditCostActual,jdbcType=DECIMAL},
  388. </if>
  389. <if test="otherCost != null">
  390. other_cost = #{otherCost,jdbcType=DECIMAL},
  391. </if>
  392. <if test="otherCostActual != null">
  393. other_cost_actual = #{otherCostActual,jdbcType=DECIMAL},
  394. </if>
  395. <if test="expectProfit != null">
  396. expect_profit = #{expectProfit,jdbcType=DECIMAL},
  397. </if>
  398. <if test="actualProfit != null">
  399. actual_profit = #{actualProfit,jdbcType=DECIMAL},
  400. </if>
  401. </set>
  402. where id = #{id,jdbcType=INTEGER}
  403. </update>
  404. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.TOrderMid">
  405. update t_order_mid
  406. set order_no = #{orderNo,jdbcType=VARCHAR},
  407. salesman_id = #{salesmanId,jdbcType=VARCHAR},
  408. finance_id = #{financeId,jdbcType=VARCHAR},
  409. salesman_name = #{salesmanName,jdbcType=VARCHAR},
  410. finance_name = #{financeName,jdbcType=VARCHAR},
  411. final_receivables = #{finalReceivables,jdbcType=DECIMAL},
  412. final_Receivables_time = #{finalReceivablesTime,jdbcType=TIMESTAMP},
  413. invoice_amount = #{invoiceAmount,jdbcType=DECIMAL},
  414. create_time = #{createTime,jdbcType=TIMESTAMP},
  415. buyer_name = #{buyerName,jdbcType=VARCHAR},
  416. order_receivables = #{orderReceivables,jdbcType=DECIMAL},
  417. order_arrears = #{orderArrears,jdbcType=DECIMAL},
  418. payment_amount = #{paymentAmount,jdbcType=DECIMAL},
  419. cost_amount = #{costAmount,jdbcType=DECIMAL},
  420. dep_name = #{depName,jdbcType=VARCHAR},
  421. province_name = #{provinceName,jdbcType=VARCHAR},
  422. legal_affairs = #{legalAffairs,jdbcType=INTEGER},
  423. dun_start_time = #{dunStartTime,jdbcType=TIMESTAMP},
  424. legal_affairs_type = #{legalAffairsType,jdbcType=INTEGER},
  425. operation_time = #{operationTime,jdbcType=DATE},
  426. legal_affairs_status = #{legalAffairsStatus,jdbcType=INTEGER},
  427. project_type = #{projectType,jdbcType=INTEGER},
  428. service_type = #{serviceType,jdbcType=VARCHAR},
  429. service_project = #{serviceProject,jdbcType=VARCHAR},
  430. patent_cost = #{patentCost,jdbcType=DECIMAL},
  431. patent_cost_actual = #{patentCostActual,jdbcType=DECIMAL},
  432. soft_cost = #{softCost,jdbcType=DECIMAL},
  433. soft_cost_actual = #{softCostActual,jdbcType=DECIMAL},
  434. audit_cost = #{auditCost,jdbcType=DECIMAL},
  435. audit_cost_actual = #{auditCostActual,jdbcType=DECIMAL},
  436. other_cost = #{otherCost,jdbcType=DECIMAL},
  437. other_cost_actual = #{otherCostActual,jdbcType=DECIMAL},
  438. expect_profit = #{expectProfit,jdbcType=DECIMAL},
  439. actual_profit = #{actualProfit,jdbcType=DECIMAL}
  440. where id = #{id,jdbcType=INTEGER}
  441. </update>
  442. <select id="selectByOrderNo" resultMap="BaseResultMap">
  443. select
  444. <include refid="Base_Column_List" />
  445. from t_order_mid
  446. where order_no = #{id,jdbcType=INTEGER}
  447. </select>
  448. <update id="updateSalesmanId">
  449. update t_order_mid a ,admin b set a.salesman_id=#{transferId},a.salesman_name=b.name
  450. where b.id=#{transferId} and a.salesman_id=#{aid}
  451. </update>
  452. <update id="updateFinanceId">
  453. update t_order_new a ,t_order_mid b,admin c set b.finance_id=#{financeId},b.finance_name=c.name
  454. where a.order_dep=#{id} and a.order_no=b.order_no and c.id= #{financeId}
  455. </update>
  456. <update id="updatefinalReceivables">
  457. update t_order_mid set final_receivables= #{amount},`final_Receivables_time`= #{receivablesTime},
  458. order_arrears=if(order_arrears- #{amount} &lt; 0,0,order_arrears- #{amount})
  459. where order_no= #{orderNo}
  460. </update>
  461. <update id="updateInvoice">
  462. update t_order_mid m,(select order_no,sum(amount)amount from t_order_invoice where status=2 group by order_no)b
  463. set m.invoice_amount=b.amount where m.order_no= #{orderNo} and m.order_no=b.order_no
  464. </update>
  465. <select id="selectDepNameByDepid" resultType="java.lang.String">
  466. select name from department where id= #{orderDep}
  467. </select>
  468. <update id="updateCostAmount">
  469. update t_order_task a ,t_order_mid b
  470. <set>
  471. <if test="cost !=null">
  472. b.cost_amount= #{cost},
  473. </if>
  474. <if test="payment !=null">
  475. b.payment_amount= #{payment},
  476. </if>
  477. </set>
  478. where a.order_no=b.order_no and a.id= #{tid}
  479. </update>
  480. <update id="updateByOrderNo">
  481. update t_order_mid
  482. <set>
  483. <if test="salesmanId != null">
  484. salesman_id = #{salesmanId,jdbcType=VARCHAR},
  485. </if>
  486. <if test="financeId != null">
  487. finance_id = #{financeId,jdbcType=VARCHAR},
  488. </if>
  489. <if test="salesmanName != null">
  490. salesman_name = #{salesmanName,jdbcType=VARCHAR},
  491. </if>
  492. <if test="financeName != null">
  493. finance_name = #{financeName,jdbcType=VARCHAR},
  494. </if>
  495. <if test="finalReceivables != null">
  496. final_receivables = #{finalReceivables,jdbcType=DECIMAL},
  497. </if>
  498. <if test="finalReceivablesTime != null">
  499. final_Receivables_time = #{finalReceivablesTime,jdbcType=TIMESTAMP},
  500. </if>
  501. <if test="invoiceAmount != null">
  502. invoice_amount = #{invoiceAmount,jdbcType=DECIMAL},
  503. </if>
  504. <if test="createTime != null">
  505. create_time = #{createTime,jdbcType=TIMESTAMP},
  506. </if>
  507. <if test="buyerName != null">
  508. buyer_name = #{buyerName,jdbcType=VARCHAR},
  509. </if>
  510. <if test="orderReceivables != null">
  511. order_receivables = #{orderReceivables,jdbcType=DECIMAL},
  512. </if>
  513. <if test="orderArrears != null">
  514. order_arrears = #{orderArrears,jdbcType=DECIMAL},
  515. </if>
  516. <if test="paymentAmount != null">
  517. payment_amount = #{paymentAmount,jdbcType=DECIMAL},
  518. </if>
  519. <if test="costAmount != null">
  520. cost_amount = #{costAmount,jdbcType=DECIMAL},
  521. </if>
  522. <if test="depName != null">
  523. dep_name = #{depName,jdbcType=VARCHAR},
  524. </if>
  525. <if test="provinceName != null">
  526. province_name = #{provinceName,jdbcType=VARCHAR},
  527. </if>
  528. <if test="legalAffairs != null">
  529. legal_affairs = #{legalAffairs,jdbcType=INTEGER},
  530. </if>
  531. <if test="dunStartTime != null">
  532. dun_start_time = #{dunStartTime,jdbcType=TIMESTAMP},
  533. </if>
  534. <if test="legalAffairsType != null">
  535. legal_affairs_type = #{legalAffairsType,jdbcType=INTEGER},
  536. </if>
  537. <if test="operationTime != null">
  538. operation_time = #{operationTime,jdbcType=DATE},
  539. </if>
  540. <if test="legalAffairsStatus != null">
  541. legal_affairs_status = #{legalAffairsStatus,jdbcType=INTEGER},
  542. </if>
  543. <if test="projectType != null">
  544. project_type = #{projectType,jdbcType=INTEGER},
  545. </if>
  546. <if test="serviceType != null">
  547. service_type = #{serviceType,jdbcType=VARCHAR},
  548. </if>
  549. <if test="serviceProject != null">
  550. service_project = #{serviceProject,jdbcType=VARCHAR},
  551. </if>
  552. </set>
  553. where order_no = #{orderNo,jdbcType=VARCHAR}
  554. </update>
  555. <select id="legalAffairsOrderList" resultType="com.goafanti.order.bo.OutOrderLegalAffairsListBo">
  556. select a.order_no orderNo,a.contract_no contractNo,b.buyer_name buyerName,b.salesman_name salesmanName,b.dep_name depName,
  557. a.total_amount totalAmount ,a.settlement_amount settlementAmount ,b.order_receivables orderReceivables,b.legal_affairs legalAffairs,
  558. b.order_arrears orderArrears,b.dun_start_time dunStartTime,date_format(b.dun_start_time,'%Y-%m-%d %H:%i:%S')dunStartTimes
  559. <if test="type==1 or type==2 or type==3">
  560. ,b.operation_time operationTime,date_format(b.operation_time,'%Y-%m-%d')operationDate,b.legal_affairs_type `type`,
  561. b.legal_affairs_status status
  562. </if>
  563. from t_order_new a left join t_order_mid b on a.order_no =b.order_no
  564. <if test="shiro == 2">
  565. left join admin c on a.salesman_id =c.id
  566. </if>
  567. where 1=1 and a.delete_sign in (0,2)
  568. <if test="type==1 or type==2 or type==3">
  569. and b.legal_affairs =1
  570. and b.legal_affairs_type = (#{type}-1)
  571. </if>
  572. <if test="type==0">
  573. and b.order_receivables >0
  574. </if>
  575. <if test="status != null">
  576. and b.legal_affairs_status = #{status}
  577. </if>
  578. <if test="shiro ==2">
  579. and c.superior_id = #{sid}
  580. </if>
  581. <if test="userName != null">
  582. and b.buyer_name like concat('%',#{userName},'%')
  583. </if>
  584. <if test="legalAffairs != null">
  585. and b.legal_affairs = #{legalAffairs}
  586. </if>
  587. <if test="contractNo != null">
  588. and a.contract_no like concat('%',#{contractNo},'%')
  589. </if>
  590. <if test="aid != null">
  591. and b.salesman_id = #{aid}
  592. </if>
  593. <if test="deps != null">
  594. and a.order_dep in
  595. <foreach close=")" collection="deps" item="dep" open="(" separator=",">
  596. #{dep}
  597. </foreach>
  598. </if>
  599. <if test="type==0">
  600. <if test="startTime != null and endTime != null">
  601. and b.dun_start_time between #{startTime} and #{endTime}
  602. </if>
  603. </if>
  604. <if test="type==1 or type==2 or type==3">
  605. <if test="startTime != null and endTime != null">
  606. and b.operation_time between #{startTime} and #{endTime}
  607. </if>
  608. </if>
  609. order by b.dun_start_time
  610. <if test="page_sql != null">
  611. ${page_sql}
  612. </if>
  613. </select>
  614. <select id="legalAffairsOrderCount" resultType="integer">
  615. select count(*)
  616. from t_order_new a left join t_order_mid b on a.order_no =b.order_no
  617. <if test="shiro == 2">
  618. left join admin c on a.salesman_id =c.id
  619. </if>
  620. where 1=1 and a.delete_sign in (0,2)
  621. <if test="type==1 or type==2 or type==3">
  622. and b.legal_affairs =1
  623. and b.legal_affairs_type = (#{type}-1)
  624. </if>
  625. <if test="type==0">
  626. and b.order_receivables >0
  627. </if>
  628. <if test="status != null">
  629. and b.legal_affairs_status = #{status}
  630. </if>
  631. <if test="shiro ==2">
  632. and c.superior_id = #{sid}
  633. </if>
  634. <if test="userName != null">
  635. and b.buyer_name like concat('%',#{userName},'%')
  636. </if>
  637. <if test="legalAffairs != null">
  638. and b.legal_affairs = #{legalAffairs}
  639. </if>
  640. <if test="contractNo != null">
  641. and a.contract_no like concat('%',#{contractNo},'%')
  642. </if>
  643. <if test="aid != null">
  644. and b.salesman_id = #{aid}
  645. </if>
  646. <if test="deps != null">
  647. and a.order_dep in
  648. <foreach close=")" collection="deps" item="dep" open="(" separator=",">
  649. #{dep}
  650. </foreach>
  651. </if>
  652. <if test="type==0">
  653. <if test="startTime != null and endTime != null">
  654. and b.dun_start_time between #{startTime} and #{endTime}
  655. </if>
  656. </if>
  657. <if test="type==1 or type==2 or type==3">
  658. <if test="startTime != null and endTime != null">
  659. and b.operation_time between #{startTime} and #{endTime}
  660. </if>
  661. </if>
  662. </select>
  663. <update id="updateByList">
  664. update t_order_mid
  665. set legal_affairs=1,legal_affairs_type =0
  666. where order_no in(
  667. <foreach collection="list" index="index" item="item" separator=",">
  668. #{item}
  669. </foreach>
  670. )
  671. </update>
  672. <select id="selectErrorDun" resultType="com.goafanti.common.bo.ErrorDunListBo">
  673. select a.order_no orderNo,a.order_receivables orderReceivables ,a.order_arrears orderArrears,b.money,a.create_time createTime
  674. from t_order_mid a left join (select order_no ,ifnull(sum(money),0)money from new_order_dun where status =1 group by order_no)b
  675. on a.order_no =b.order_no
  676. where a.order_receivables !=b.money order by a.create_time;
  677. </select>
  678. <update id="updateErrorDun">
  679. update t_order_mid a ,(select order_no ,ifnull(sum(money),0)money from new_order_dun where status =1 group by order_no)b,
  680. t_order_new c
  681. set a.order_receivables=b.money,a.order_arrears =(b.money-c.settlement_amount)
  682. where a.order_no =b.order_no and a.order_no =c.order_no and a.order_receivables !=b.money;
  683. </update>
  684. <select id="judgeProjectType" resultType="java.lang.Integer">
  685. select count(*) from t_order_new a left join t_order_task b on a.order_no =b.order_no
  686. left join business_project c on b.commodity_id =c.id left join business_category d on c.cid =d.id
  687. where d.sort =6 and a.order_no = #{orderNo}
  688. </select>
  689. <update id="updateCountProjectAndType">
  690. update t_order_mid a ,(select a.order_no ,GROUP_CONCAT(DISTINCT a.commodity_name )pname, GROUP_CONCAT(DISTINCT c.cname )cname
  691. from t_order_task a left join business_project b on a.commodity_id =b.id
  692. left join business_category c on b.cid =c.id
  693. group by a.order_no )b
  694. set a.service_project =b.pname,a.service_type =b.cname
  695. where a.order_no=b.order_no and a.order_no = #{orderNo};
  696. </update>
  697. <update id="updateAddCostAmount" parameterType="com.goafanti.common.model.TOrderMid">
  698. update t_order_mid
  699. <set>
  700. <if test="costActual != null">
  701. payment_amount =payment_amount+ #{paymentAmount,jdbcType=DECIMAL},
  702. </if>
  703. <if test="patentCost != null">
  704. patent_cost =patent_cost+ #{patentCost,jdbcType=DECIMAL},
  705. </if>
  706. <if test="patentCostActual != null">
  707. patent_cost_actual =patent_cost_actual+ #{patentCostActual,jdbcType=DECIMAL},
  708. </if>
  709. <if test="softCost != null">
  710. soft_cost =soft_cost+ #{softCost,jdbcType=DECIMAL},
  711. </if>
  712. <if test="softCostActual != null">
  713. soft_cost_actual =soft_cost_actual+ #{softCostActual,jdbcType=DECIMAL},
  714. </if>
  715. <if test="auditCost != null">
  716. audit_cost =audit_cost+ #{auditCost,jdbcType=DECIMAL},
  717. </if>
  718. <if test="auditCostActual != null">
  719. audit_cost_actual =audit_cost_actual+ #{auditCostActual,jdbcType=DECIMAL},
  720. </if>
  721. <if test="otherCost != null">
  722. other_cost =other_cost+ #{otherCost,jdbcType=DECIMAL},
  723. </if>
  724. <if test="otherCostActual != null">
  725. other_cost_actual =other_cost_actual+ #{otherCostActual,jdbcType=DECIMAL},
  726. </if>
  727. <if test="expectProfit != null">
  728. expect_profit =expect_profit+ #{expectProfit,jdbcType=DECIMAL},
  729. </if>
  730. <if test="actualProfit != null">
  731. actual_profit =actual_profit+ #{actualProfit,jdbcType=DECIMAL},
  732. </if>
  733. <if test="costAmount != null">
  734. cost_amount =cost_amount+ #{costAmount,jdbcType=DECIMAL},
  735. </if>
  736. </set>
  737. where order_no =#{orderNo}
  738. </update>
  739. </mapper>