TOrderMidMapper.xml 30 KB

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