TOrderNewMapper.xml 85 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068
  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.TOrderNewMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.TOrderNew">
  5. <id column="order_no" jdbcType="VARCHAR" property="orderNo" />
  6. <result column="order_type" jdbcType="INTEGER" property="orderType" />
  7. <result column="creater" jdbcType="VARCHAR" property="creater" />
  8. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  9. <result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
  10. <result column="buyer_id" jdbcType="VARCHAR" property="buyerId" />
  11. <result column="first_amount" jdbcType="DECIMAL" property="firstAmount" />
  12. <result column="total_amount" jdbcType="DECIMAL" property="totalAmount" />
  13. <result column="settlement_amount" jdbcType="DECIMAL" property="settlementAmount" />
  14. <result column="refund_amount" jdbcType="DECIMAL" property="refundAmount" />
  15. <result column="order_status" jdbcType="INTEGER" property="orderStatus" />
  16. <result column="liquidation_status" jdbcType="INTEGER" property="liquidationStatus" />
  17. <result column="process_status" jdbcType="INTEGER" property="processStatus" />
  18. <result column="project_status" jdbcType="INTEGER" property="projectStatus" />
  19. <result column="approval" jdbcType="INTEGER" property="approval" />
  20. <result column="order_remarks" jdbcType="VARCHAR" property="orderRemarks" />
  21. <result column="delete_sign" jdbcType="INTEGER" property="deleteSign" />
  22. <result column="salesman_id" jdbcType="VARCHAR" property="salesmanId" />
  23. <result column="finance_id" jdbcType="VARCHAR" property="financeId" />
  24. <result column="technician_id" jdbcType="VARCHAR" property="technicianId" />
  25. <result column="sign_time" jdbcType="DATE" property="signTime" />
  26. <result column="settlement_time" jdbcType="DATE" property="settlementTime" />
  27. <result column="contract_picture_url" jdbcType="VARCHAR" property="contractPictureUrl" />
  28. <result column="contract_no" jdbcType="VARCHAR" property="contractNo" />
  29. <result column="contract_type" jdbcType="VARCHAR" property="contractType" />
  30. <result column="contacts" jdbcType="VARCHAR" property="contacts" />
  31. <result column="contact_mobile" jdbcType="VARCHAR" property="contactMobile" />
  32. <result column="legal_person" jdbcType="VARCHAR" property="legalPerson" />
  33. <result column="legal_person_tel" jdbcType="VARCHAR" property="legalPersonTel" />
  34. <result column="proof_count" jdbcType="FLOAT" property="proofCount" />
  35. <result column="proof_aid" jdbcType="VARCHAR" property="proofAid" />
  36. <result column="proof_time" jdbcType="TIMESTAMP" property="proofTime" />
  37. <result column="proof_status" jdbcType="INTEGER" property="proofStatus" />
  38. <result column="order_dep" jdbcType="VARCHAR" property="orderDep" />
  39. <result column="outsource" jdbcType="INTEGER" property="outsource" />
  40. <result column="additional_order" jdbcType="VARCHAR" property="additionalOrder" />
  41. <result column="primary_order" jdbcType="VARCHAR" property="primaryOrder" />
  42. <result column="old_salesman_id" jdbcType="VARCHAR" property="oldSalesmanId" />
  43. <result column="back_status" jdbcType="INTEGER" property="backStatus" />
  44. <result column="agreement_url" jdbcType="VARCHAR" property="agreementUrl" />
  45. <result column="new_user" jdbcType="INTEGER" property="newUser" />
  46. <result column="service_content" jdbcType="VARCHAR" property="serviceContent" />
  47. <result column="sales_type" jdbcType="INTEGER" property="salesType" />
  48. <result column="channel_id" jdbcType="VARCHAR" property="channelId" />
  49. <result column="other" jdbcType="VARCHAR" property="other" />
  50. <result column="user_type" jdbcType="INTEGER" property="userType" />
  51. <result column="examine_name" jdbcType="VARCHAR" property="examineName" />
  52. </resultMap>
  53. <sql id="Base_Column_List">
  54. order_no, order_type, creater, create_time, update_time, buyer_id, first_amount,
  55. total_amount, settlement_amount, refund_amount, order_status, liquidation_status,
  56. process_status, project_status, approval, order_remarks, delete_sign, salesman_id,
  57. finance_id, technician_id, sign_time, settlement_time, contract_picture_url, contract_no,
  58. contract_type, contacts, contact_mobile, legal_person, legal_person_tel, proof_count,
  59. proof_aid, proof_time, proof_status, order_dep, outsource, additional_order, primary_order,
  60. old_salesman_id, back_status, agreement_url, new_user, service_content, sales_type,
  61. channel_id, other, user_type, examine_name
  62. </sql>
  63. <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
  64. select
  65. <include refid="Base_Column_List" />
  66. from t_order_new
  67. where order_no = #{orderNo,jdbcType=VARCHAR}
  68. </select>
  69. <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
  70. delete from t_order_new
  71. where order_no = #{orderNo,jdbcType=VARCHAR}
  72. </delete>
  73. <insert id="insert" parameterType="com.goafanti.common.model.TOrderNew">
  74. insert into t_order_new (order_no, order_type, creater,
  75. create_time, update_time, buyer_id,
  76. first_amount, total_amount, settlement_amount,
  77. refund_amount, order_status, liquidation_status,
  78. process_status, project_status, approval,
  79. order_remarks, delete_sign, salesman_id,
  80. finance_id, technician_id, sign_time,
  81. settlement_time, contract_picture_url, contract_no,
  82. contract_type, contacts, contact_mobile,
  83. legal_person, legal_person_tel, proof_count,
  84. proof_aid, proof_time, proof_status,
  85. order_dep, outsource, additional_order,
  86. primary_order, old_salesman_id, back_status,
  87. agreement_url, new_user, service_content,
  88. sales_type, channel_id, other,
  89. user_type, examine_name)
  90. values (#{orderNo,jdbcType=VARCHAR}, #{orderType,jdbcType=INTEGER}, #{creater,jdbcType=VARCHAR},
  91. #{createTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP}, #{buyerId,jdbcType=VARCHAR},
  92. #{firstAmount,jdbcType=DECIMAL}, #{totalAmount,jdbcType=DECIMAL}, #{settlementAmount,jdbcType=DECIMAL},
  93. #{refundAmount,jdbcType=DECIMAL}, #{orderStatus,jdbcType=INTEGER}, #{liquidationStatus,jdbcType=INTEGER},
  94. #{processStatus,jdbcType=INTEGER}, #{projectStatus,jdbcType=INTEGER}, #{approval,jdbcType=INTEGER},
  95. #{orderRemarks,jdbcType=VARCHAR}, #{deleteSign,jdbcType=INTEGER}, #{salesmanId,jdbcType=VARCHAR},
  96. #{financeId,jdbcType=VARCHAR}, #{technicianId,jdbcType=VARCHAR}, #{signTime,jdbcType=DATE},
  97. #{settlementTime,jdbcType=DATE}, #{contractPictureUrl,jdbcType=VARCHAR}, #{contractNo,jdbcType=VARCHAR},
  98. #{contractType,jdbcType=VARCHAR}, #{contacts,jdbcType=VARCHAR}, #{contactMobile,jdbcType=VARCHAR},
  99. #{legalPerson,jdbcType=VARCHAR}, #{legalPersonTel,jdbcType=VARCHAR}, #{proofCount,jdbcType=FLOAT},
  100. #{proofAid,jdbcType=VARCHAR}, #{proofTime,jdbcType=TIMESTAMP}, #{proofStatus,jdbcType=INTEGER},
  101. #{orderDep,jdbcType=VARCHAR}, #{outsource,jdbcType=INTEGER}, #{additionalOrder,jdbcType=VARCHAR},
  102. #{primaryOrder,jdbcType=VARCHAR}, #{oldSalesmanId,jdbcType=VARCHAR}, #{backStatus,jdbcType=INTEGER},
  103. #{agreementUrl,jdbcType=VARCHAR}, #{newUser,jdbcType=INTEGER}, #{serviceContent,jdbcType=VARCHAR},
  104. #{salesType,jdbcType=INTEGER}, #{channelId,jdbcType=VARCHAR}, #{other,jdbcType=VARCHAR},
  105. #{userType,jdbcType=INTEGER}, #{examineName,jdbcType=VARCHAR})
  106. </insert>
  107. <insert id="insertSelective" parameterType="com.goafanti.common.model.TOrderNew">
  108. insert into t_order_new
  109. <trim prefix="(" suffix=")" suffixOverrides=",">
  110. <if test="orderNo != null">
  111. order_no,
  112. </if>
  113. <if test="orderType != null">
  114. order_type,
  115. </if>
  116. <if test="creater != null">
  117. creater,
  118. </if>
  119. <if test="createTime != null">
  120. create_time,
  121. </if>
  122. <if test="updateTime != null">
  123. update_time,
  124. </if>
  125. <if test="buyerId != null">
  126. buyer_id,
  127. </if>
  128. <if test="firstAmount != null">
  129. first_amount,
  130. </if>
  131. <if test="totalAmount != null">
  132. total_amount,
  133. </if>
  134. <if test="settlementAmount != null">
  135. settlement_amount,
  136. </if>
  137. <if test="refundAmount != null">
  138. refund_amount,
  139. </if>
  140. <if test="orderStatus != null">
  141. order_status,
  142. </if>
  143. <if test="liquidationStatus != null">
  144. liquidation_status,
  145. </if>
  146. <if test="processStatus != null">
  147. process_status,
  148. </if>
  149. <if test="projectStatus != null">
  150. project_status,
  151. </if>
  152. <if test="approval != null">
  153. approval,
  154. </if>
  155. <if test="orderRemarks != null">
  156. order_remarks,
  157. </if>
  158. <if test="deleteSign != null">
  159. delete_sign,
  160. </if>
  161. <if test="salesmanId != null">
  162. salesman_id,
  163. </if>
  164. <if test="financeId != null">
  165. finance_id,
  166. </if>
  167. <if test="technicianId != null">
  168. technician_id,
  169. </if>
  170. <if test="signTime != null">
  171. sign_time,
  172. </if>
  173. <if test="settlementTime != null">
  174. settlement_time,
  175. </if>
  176. <if test="contractPictureUrl != null">
  177. contract_picture_url,
  178. </if>
  179. <if test="contractNo != null">
  180. contract_no,
  181. </if>
  182. <if test="contractType != null">
  183. contract_type,
  184. </if>
  185. <if test="contacts != null">
  186. contacts,
  187. </if>
  188. <if test="contactMobile != null">
  189. contact_mobile,
  190. </if>
  191. <if test="legalPerson != null">
  192. legal_person,
  193. </if>
  194. <if test="legalPersonTel != null">
  195. legal_person_tel,
  196. </if>
  197. <if test="proofCount != null">
  198. proof_count,
  199. </if>
  200. <if test="proofAid != null">
  201. proof_aid,
  202. </if>
  203. <if test="proofTime != null">
  204. proof_time,
  205. </if>
  206. <if test="proofStatus != null">
  207. proof_status,
  208. </if>
  209. <if test="orderDep != null">
  210. order_dep,
  211. </if>
  212. <if test="outsource != null">
  213. outsource,
  214. </if>
  215. <if test="additionalOrder != null">
  216. additional_order,
  217. </if>
  218. <if test="primaryOrder != null">
  219. primary_order,
  220. </if>
  221. <if test="oldSalesmanId != null">
  222. old_salesman_id,
  223. </if>
  224. <if test="backStatus != null">
  225. back_status,
  226. </if>
  227. <if test="agreementUrl != null">
  228. agreement_url,
  229. </if>
  230. <if test="newUser != null">
  231. new_user,
  232. </if>
  233. <if test="serviceContent != null">
  234. service_content,
  235. </if>
  236. <if test="salesType != null">
  237. sales_type,
  238. </if>
  239. <if test="channelId != null">
  240. channel_id,
  241. </if>
  242. <if test="other != null">
  243. other,
  244. </if>
  245. <if test="userType != null">
  246. user_type,
  247. </if>
  248. <if test="examineName != null">
  249. examine_name,
  250. </if>
  251. </trim>
  252. <trim prefix="values (" suffix=")" suffixOverrides=",">
  253. <if test="orderNo != null">
  254. #{orderNo,jdbcType=VARCHAR},
  255. </if>
  256. <if test="orderType != null">
  257. #{orderType,jdbcType=INTEGER},
  258. </if>
  259. <if test="creater != null">
  260. #{creater,jdbcType=VARCHAR},
  261. </if>
  262. <if test="createTime != null">
  263. #{createTime,jdbcType=TIMESTAMP},
  264. </if>
  265. <if test="updateTime != null">
  266. #{updateTime,jdbcType=TIMESTAMP},
  267. </if>
  268. <if test="buyerId != null">
  269. #{buyerId,jdbcType=VARCHAR},
  270. </if>
  271. <if test="firstAmount != null">
  272. #{firstAmount,jdbcType=DECIMAL},
  273. </if>
  274. <if test="totalAmount != null">
  275. #{totalAmount,jdbcType=DECIMAL},
  276. </if>
  277. <if test="settlementAmount != null">
  278. #{settlementAmount,jdbcType=DECIMAL},
  279. </if>
  280. <if test="refundAmount != null">
  281. #{refundAmount,jdbcType=DECIMAL},
  282. </if>
  283. <if test="orderStatus != null">
  284. #{orderStatus,jdbcType=INTEGER},
  285. </if>
  286. <if test="liquidationStatus != null">
  287. #{liquidationStatus,jdbcType=INTEGER},
  288. </if>
  289. <if test="processStatus != null">
  290. #{processStatus,jdbcType=INTEGER},
  291. </if>
  292. <if test="projectStatus != null">
  293. #{projectStatus,jdbcType=INTEGER},
  294. </if>
  295. <if test="approval != null">
  296. #{approval,jdbcType=INTEGER},
  297. </if>
  298. <if test="orderRemarks != null">
  299. #{orderRemarks,jdbcType=VARCHAR},
  300. </if>
  301. <if test="deleteSign != null">
  302. #{deleteSign,jdbcType=INTEGER},
  303. </if>
  304. <if test="salesmanId != null">
  305. #{salesmanId,jdbcType=VARCHAR},
  306. </if>
  307. <if test="financeId != null">
  308. #{financeId,jdbcType=VARCHAR},
  309. </if>
  310. <if test="technicianId != null">
  311. #{technicianId,jdbcType=VARCHAR},
  312. </if>
  313. <if test="signTime != null">
  314. #{signTime,jdbcType=DATE},
  315. </if>
  316. <if test="settlementTime != null">
  317. #{settlementTime,jdbcType=DATE},
  318. </if>
  319. <if test="contractPictureUrl != null">
  320. #{contractPictureUrl,jdbcType=VARCHAR},
  321. </if>
  322. <if test="contractNo != null">
  323. #{contractNo,jdbcType=VARCHAR},
  324. </if>
  325. <if test="contractType != null">
  326. #{contractType,jdbcType=VARCHAR},
  327. </if>
  328. <if test="contacts != null">
  329. #{contacts,jdbcType=VARCHAR},
  330. </if>
  331. <if test="contactMobile != null">
  332. #{contactMobile,jdbcType=VARCHAR},
  333. </if>
  334. <if test="legalPerson != null">
  335. #{legalPerson,jdbcType=VARCHAR},
  336. </if>
  337. <if test="legalPersonTel != null">
  338. #{legalPersonTel,jdbcType=VARCHAR},
  339. </if>
  340. <if test="proofCount != null">
  341. #{proofCount,jdbcType=FLOAT},
  342. </if>
  343. <if test="proofAid != null">
  344. #{proofAid,jdbcType=VARCHAR},
  345. </if>
  346. <if test="proofTime != null">
  347. #{proofTime,jdbcType=TIMESTAMP},
  348. </if>
  349. <if test="proofStatus != null">
  350. #{proofStatus,jdbcType=INTEGER},
  351. </if>
  352. <if test="orderDep != null">
  353. #{orderDep,jdbcType=VARCHAR},
  354. </if>
  355. <if test="outsource != null">
  356. #{outsource,jdbcType=INTEGER},
  357. </if>
  358. <if test="additionalOrder != null">
  359. #{additionalOrder,jdbcType=VARCHAR},
  360. </if>
  361. <if test="primaryOrder != null">
  362. #{primaryOrder,jdbcType=VARCHAR},
  363. </if>
  364. <if test="oldSalesmanId != null">
  365. #{oldSalesmanId,jdbcType=VARCHAR},
  366. </if>
  367. <if test="backStatus != null">
  368. #{backStatus,jdbcType=INTEGER},
  369. </if>
  370. <if test="agreementUrl != null">
  371. #{agreementUrl,jdbcType=VARCHAR},
  372. </if>
  373. <if test="newUser != null">
  374. #{newUser,jdbcType=INTEGER},
  375. </if>
  376. <if test="serviceContent != null">
  377. #{serviceContent,jdbcType=VARCHAR},
  378. </if>
  379. <if test="salesType != null">
  380. #{salesType,jdbcType=INTEGER},
  381. </if>
  382. <if test="channelId != null">
  383. #{channelId,jdbcType=VARCHAR},
  384. </if>
  385. <if test="other != null">
  386. #{other,jdbcType=VARCHAR},
  387. </if>
  388. <if test="userType != null">
  389. #{userType,jdbcType=INTEGER},
  390. </if>
  391. <if test="examineName != null">
  392. #{examineName,jdbcType=VARCHAR},
  393. </if>
  394. </trim>
  395. </insert>
  396. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.TOrderNew">
  397. update t_order_new
  398. <set>
  399. <if test="orderType != null">
  400. order_type = #{orderType,jdbcType=INTEGER},
  401. </if>
  402. <if test="creater != null">
  403. creater = #{creater,jdbcType=VARCHAR},
  404. </if>
  405. <if test="createTime != null">
  406. create_time = #{createTime,jdbcType=TIMESTAMP},
  407. </if>
  408. <if test="updateTime != null">
  409. update_time = #{updateTime,jdbcType=TIMESTAMP},
  410. </if>
  411. <if test="buyerId != null">
  412. buyer_id = #{buyerId,jdbcType=VARCHAR},
  413. </if>
  414. <if test="firstAmount != null">
  415. first_amount = #{firstAmount,jdbcType=DECIMAL},
  416. </if>
  417. <if test="totalAmount != null">
  418. total_amount = #{totalAmount,jdbcType=DECIMAL},
  419. </if>
  420. <if test="settlementAmount != null">
  421. settlement_amount = #{settlementAmount,jdbcType=DECIMAL},
  422. </if>
  423. <if test="refundAmount != null">
  424. refund_amount = #{refundAmount,jdbcType=DECIMAL},
  425. </if>
  426. <if test="orderStatus != null">
  427. order_status = #{orderStatus,jdbcType=INTEGER},
  428. </if>
  429. <if test="liquidationStatus != null">
  430. liquidation_status = #{liquidationStatus,jdbcType=INTEGER},
  431. </if>
  432. <if test="processStatus != null">
  433. process_status = #{processStatus,jdbcType=INTEGER},
  434. </if>
  435. <if test="projectStatus != null">
  436. project_status = #{projectStatus,jdbcType=INTEGER},
  437. </if>
  438. <if test="approval != null">
  439. approval = #{approval,jdbcType=INTEGER},
  440. </if>
  441. <if test="orderRemarks != null">
  442. order_remarks = #{orderRemarks,jdbcType=VARCHAR},
  443. </if>
  444. <if test="deleteSign != null">
  445. delete_sign = #{deleteSign,jdbcType=INTEGER},
  446. </if>
  447. <if test="salesmanId != null">
  448. salesman_id = #{salesmanId,jdbcType=VARCHAR},
  449. </if>
  450. <if test="financeId != null">
  451. finance_id = #{financeId,jdbcType=VARCHAR},
  452. </if>
  453. <if test="technicianId != null">
  454. technician_id = #{technicianId,jdbcType=VARCHAR},
  455. </if>
  456. <if test="signTime != null">
  457. sign_time = #{signTime,jdbcType=DATE},
  458. </if>
  459. <if test="settlementTime != null">
  460. settlement_time = #{settlementTime,jdbcType=DATE},
  461. </if>
  462. <if test="contractPictureUrl != null">
  463. contract_picture_url = #{contractPictureUrl,jdbcType=VARCHAR},
  464. </if>
  465. <if test="contractNo != null">
  466. contract_no = #{contractNo,jdbcType=VARCHAR},
  467. </if>
  468. <if test="contractType != null">
  469. contract_type = #{contractType,jdbcType=VARCHAR},
  470. </if>
  471. <if test="contacts != null">
  472. contacts = #{contacts,jdbcType=VARCHAR},
  473. </if>
  474. <if test="contactMobile != null">
  475. contact_mobile = #{contactMobile,jdbcType=VARCHAR},
  476. </if>
  477. <if test="legalPerson != null">
  478. legal_person = #{legalPerson,jdbcType=VARCHAR},
  479. </if>
  480. <if test="legalPersonTel != null">
  481. legal_person_tel = #{legalPersonTel,jdbcType=VARCHAR},
  482. </if>
  483. <if test="proofCount != null">
  484. proof_count = #{proofCount,jdbcType=FLOAT},
  485. </if>
  486. <if test="proofAid != null">
  487. proof_aid = #{proofAid,jdbcType=VARCHAR},
  488. </if>
  489. <if test="proofTime != null">
  490. proof_time = #{proofTime,jdbcType=TIMESTAMP},
  491. </if>
  492. <if test="proofStatus != null">
  493. proof_status = #{proofStatus,jdbcType=INTEGER},
  494. </if>
  495. <if test="orderDep != null">
  496. order_dep = #{orderDep,jdbcType=VARCHAR},
  497. </if>
  498. <if test="outsource != null">
  499. outsource = #{outsource,jdbcType=INTEGER},
  500. </if>
  501. <if test="additionalOrder != null">
  502. additional_order = #{additionalOrder,jdbcType=VARCHAR},
  503. </if>
  504. <if test="primaryOrder != null">
  505. primary_order = #{primaryOrder,jdbcType=VARCHAR},
  506. </if>
  507. <if test="oldSalesmanId != null">
  508. old_salesman_id = #{oldSalesmanId,jdbcType=VARCHAR},
  509. </if>
  510. <if test="backStatus != null">
  511. back_status = #{backStatus,jdbcType=INTEGER},
  512. </if>
  513. <if test="agreementUrl != null">
  514. agreement_url = #{agreementUrl,jdbcType=VARCHAR},
  515. </if>
  516. <if test="newUser != null">
  517. new_user = #{newUser,jdbcType=INTEGER},
  518. </if>
  519. <if test="serviceContent != null">
  520. service_content = #{serviceContent,jdbcType=VARCHAR},
  521. </if>
  522. <if test="salesType != null">
  523. sales_type = #{salesType,jdbcType=INTEGER},
  524. </if>
  525. <if test="channelId != null">
  526. channel_id = #{channelId,jdbcType=VARCHAR},
  527. </if>
  528. <if test="other != null">
  529. other = #{other,jdbcType=VARCHAR},
  530. </if>
  531. <if test="userType != null">
  532. user_type = #{userType,jdbcType=INTEGER},
  533. </if>
  534. <if test="examineName != null">
  535. examine_name = #{examineName,jdbcType=VARCHAR},
  536. </if>
  537. </set>
  538. where order_no = #{orderNo,jdbcType=VARCHAR}
  539. </update>
  540. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.TOrderNew">
  541. update t_order_new
  542. set order_type = #{orderType,jdbcType=INTEGER},
  543. creater = #{creater,jdbcType=VARCHAR},
  544. create_time = #{createTime,jdbcType=TIMESTAMP},
  545. update_time = #{updateTime,jdbcType=TIMESTAMP},
  546. buyer_id = #{buyerId,jdbcType=VARCHAR},
  547. first_amount = #{firstAmount,jdbcType=DECIMAL},
  548. total_amount = #{totalAmount,jdbcType=DECIMAL},
  549. settlement_amount = #{settlementAmount,jdbcType=DECIMAL},
  550. refund_amount = #{refundAmount,jdbcType=DECIMAL},
  551. order_status = #{orderStatus,jdbcType=INTEGER},
  552. liquidation_status = #{liquidationStatus,jdbcType=INTEGER},
  553. process_status = #{processStatus,jdbcType=INTEGER},
  554. project_status = #{projectStatus,jdbcType=INTEGER},
  555. approval = #{approval,jdbcType=INTEGER},
  556. order_remarks = #{orderRemarks,jdbcType=VARCHAR},
  557. delete_sign = #{deleteSign,jdbcType=INTEGER},
  558. salesman_id = #{salesmanId,jdbcType=VARCHAR},
  559. finance_id = #{financeId,jdbcType=VARCHAR},
  560. technician_id = #{technicianId,jdbcType=VARCHAR},
  561. sign_time = #{signTime,jdbcType=DATE},
  562. settlement_time = #{settlementTime,jdbcType=DATE},
  563. contract_picture_url = #{contractPictureUrl,jdbcType=VARCHAR},
  564. contract_no = #{contractNo,jdbcType=VARCHAR},
  565. contract_type = #{contractType,jdbcType=VARCHAR},
  566. contacts = #{contacts,jdbcType=VARCHAR},
  567. contact_mobile = #{contactMobile,jdbcType=VARCHAR},
  568. legal_person = #{legalPerson,jdbcType=VARCHAR},
  569. legal_person_tel = #{legalPersonTel,jdbcType=VARCHAR},
  570. proof_count = #{proofCount,jdbcType=FLOAT},
  571. proof_aid = #{proofAid,jdbcType=VARCHAR},
  572. proof_time = #{proofTime,jdbcType=TIMESTAMP},
  573. proof_status = #{proofStatus,jdbcType=INTEGER},
  574. order_dep = #{orderDep,jdbcType=VARCHAR},
  575. outsource = #{outsource,jdbcType=INTEGER},
  576. additional_order = #{additionalOrder,jdbcType=VARCHAR},
  577. primary_order = #{primaryOrder,jdbcType=VARCHAR},
  578. old_salesman_id = #{oldSalesmanId,jdbcType=VARCHAR},
  579. back_status = #{backStatus,jdbcType=INTEGER},
  580. agreement_url = #{agreementUrl,jdbcType=VARCHAR},
  581. new_user = #{newUser,jdbcType=INTEGER},
  582. service_content = #{serviceContent,jdbcType=VARCHAR},
  583. sales_type = #{salesType,jdbcType=INTEGER},
  584. channel_id = #{channelId,jdbcType=VARCHAR},
  585. other = #{other,jdbcType=VARCHAR},
  586. user_type = #{userType,jdbcType=INTEGER},
  587. examine_name = #{examineName,jdbcType=VARCHAR}
  588. where order_no = #{orderNo,jdbcType=VARCHAR}
  589. </update>
  590. <!-- 查看所有待财务管理员分配的订单数据 -->
  591. <select id="getAllUnassignedListOrder" parameterType="Map" resultType="com.goafanti.order.bo.OrderListBo">
  592. select o.order_no as orderNo, o.order_type orderType, o.create_time as createTime, o.process_status as processStatus,
  593. o.sign_time as signTime, u.nickname as buyerName,o.total_amount signTotalAmount, o.approval , a.name sellerName
  594. ,liquidation_status,o.finance_id as financeId,contract_no as contractNo,d.name as departmentName,e.name as outsourceName
  595. from t_order_new o left join `user` u on o.buyer_id = u.id left join admin a on o.salesman_id = a.id
  596. left join department d on o.order_dep=d.id left join (select order_no,max(name)as name from outsource_organization group by order_no) e
  597. on o.order_no=e.order_no left join t_order_outsource f on f.order_no=o.order_no where delete_sign in(0,2,3)
  598. and approval in (0,2)
  599. <if test="o.outsource != null">
  600. and o.outsource=#{o.outsource,jdbcType=INTEGER}
  601. </if>
  602. <if test="o.outsource == 1">
  603. and f.refund_status=1
  604. </if>
  605. <if test="o.processStatus == 2">
  606. and process_status = 2
  607. </if>
  608. <if test="o.processStatus == 3">
  609. and process_status &gt;= 2 and process_status &lt; 7
  610. </if>
  611. <if test="o.departmentId != null and o.departmentId != &quot;&quot;">
  612. and o.order_dep= #{o.departmentId,jdbcType=VARCHAR}
  613. </if>
  614. <if test="o.orderNo != null and o.orderNo != &quot;&quot;">
  615. and o.order_no = #{o.orderNo,jdbcType=VARCHAR}
  616. </if>
  617. <if test="o.financeId != null and o.financeId != &quot;&quot;">
  618. and o.finance_id = #{o.financeId,jdbcType=VARCHAR}
  619. </if>
  620. <if test="o.contractNo != null and o.contractNo != &quot;&quot;">
  621. and o.contract_no like CONCAT('%',#{o.contractNo,jdbcType=VARCHAR},'%')
  622. </if>
  623. <if test="o.buyerName != null and o.buyerName != &quot;&quot;">
  624. <bind name="n" value="'%' + o.buyerName + '%'" />
  625. and u.nickname like #{n,jdbcType=VARCHAR}
  626. </if>
  627. <if test="o.startTime != null and o.startTime != &quot;&quot; and o.endTime != null and o.endTime != &quot;&quot;">
  628. <bind name="a" value="o.startTime + ' 00:00:00'" />
  629. <bind name="b" value="o.endTime + ' 23:59:59'" />
  630. and o.create_time between #{a,jdbcType=VARCHAR} and #{b,jdbcType=VARCHAR}
  631. </if>
  632. order by o.process_status,o.create_time desc
  633. <if test="page_sql != null">
  634. ${page_sql}
  635. </if>
  636. </select>
  637. <select id="getAllUnassignedCountOrder" parameterType="Map" resultType="java.lang.Integer">
  638. select count(*) from t_order_new o left join `user` u on o.buyer_id = u.id left join admin a on o.salesman_id = a.id
  639. left join t_order_outsource f on f.order_no=o.order_no where delete_sign in(0,2,3) and approval in (0,2)
  640. <if test="o.outsource != null">
  641. and o.outsource=#{o.outsource,jdbcType=INTEGER}
  642. </if>
  643. <if test="o.outsource == 1">
  644. and f.refund_status=1
  645. </if>
  646. <if test="o.processStatus == 2">
  647. and process_status = 2
  648. </if>
  649. <if test="o.processStatus == 3">
  650. and process_status &gt; 2 and process_status &lt; 7
  651. </if>
  652. <if test="o.departmentId != null and o.departmentId != &quot;&quot;">
  653. and o.order_dep= #{o.departmentId,jdbcType=VARCHAR}
  654. </if>
  655. <if test="o.orderNo != null and o.orderNo != &quot;&quot;">
  656. and o.order_no = #{o.orderNo,jdbcType=VARCHAR}
  657. </if>
  658. <if test="o.financeId != null and o.financeId != &quot;&quot;">
  659. and o.finance_id = #{o.financeId,jdbcType=VARCHAR}
  660. </if>
  661. <if test="o.contractNo != null and o.contractNo != &quot;&quot;">
  662. and o.contract_no like CONCAT('%',#{o.contractNo,jdbcType=VARCHAR},'%')
  663. </if>
  664. <if test="o.buyerName != null and o.buyerName != &quot;&quot;">
  665. <bind name="n" value="'%' + o.buyerName + '%'" />
  666. and u.nickname like #{n,jdbcType=VARCHAR}
  667. </if>
  668. <if test="o.startTime != null and o.startTime != &quot;&quot; and o.endTime != null and o.endTime != &quot;&quot;">
  669. <bind name="a" value="o.startTime + ' 00:00:00'" />
  670. <bind name="b" value="o.endTime + ' 23:59:59'" />
  671. and o.create_time between #{a,jdbcType=VARCHAR} and #{b,jdbcType=VARCHAR}
  672. </if>
  673. </select>
  674. <!-- 查看某订单状态是否符合要求 -->
  675. <select id="getCountByIdAndStatus" parameterType="com.goafanti.common.model.TOrderNew" resultType="java.lang.Integer">
  676. select count(*) from t_order_new
  677. where order_no = #{orderNo,jdbcType=VARCHAR}
  678. <if test="orderType != null">
  679. and order_type = #{orderType,jdbcType=INTEGER}
  680. </if>
  681. <if test="creater != null">
  682. and creater = #{creater,jdbcType=VARCHAR}
  683. </if>
  684. <if test="buyerId != null">
  685. and buyer_id = #{buyerId,jdbcType=VARCHAR}
  686. </if>
  687. <if test="firstAmount != null">
  688. and first_amount = #{firstAmount,jdbcType=DECIMAL}
  689. </if>
  690. <if test="totalAmount != null">
  691. and total_amount = #{totalAmount,jdbcType=DECIMAL}
  692. </if>
  693. <if test="settlementAmount != null">
  694. and settlement_amount = #{settlementAmount,jdbcType=DECIMAL}
  695. </if>
  696. <if test="orderStatus != null">
  697. and order_status = #{orderStatus,jdbcType=INTEGER}
  698. </if>
  699. <if test="liquidationStatus == 1">
  700. and liquidation_status between 1 and 2
  701. </if>
  702. <if test="processStatus != null">
  703. and process_status = #{processStatus,jdbcType=INTEGER}
  704. </if>
  705. <if test="projectStatus != null">
  706. and project_status = #{projectStatus,jdbcType=INTEGER}
  707. </if>
  708. <if test="approval != null">
  709. and approval = #{approval,jdbcType=INTEGER}
  710. </if>
  711. <if test="orderRemarks != null">
  712. and order_remarks = #{orderRemarks,jdbcType=VARCHAR}
  713. </if>
  714. <if test="deleteSign != null">
  715. and delete_sign = #{deleteSign,jdbcType=INTEGER}
  716. </if>
  717. <if test="salesmanId != null">
  718. and salesman_id = #{salesmanId,jdbcType=VARCHAR}
  719. </if>
  720. <if test="financeId != null">
  721. and finance_id = #{financeId,jdbcType=VARCHAR}
  722. </if>
  723. <if test="technicianId != null">
  724. and technician_id = #{technicianId,jdbcType=VARCHAR}
  725. </if>
  726. <if test="contractNo != null">
  727. and contract_no = #{contractNo,jdbcType=VARCHAR}
  728. </if>
  729. <if test="contractType != null">
  730. and contract_type = #{contractType,jdbcType=VARCHAR}
  731. </if>
  732. <if test="contacts != null">
  733. and contacts = #{contacts,jdbcType=VARCHAR}
  734. </if>
  735. <if test="contactMobile != null">
  736. and contact_mobile = #{contactMobile,jdbcType=VARCHAR}
  737. </if>
  738. <if test="legalPerson != null">
  739. and legal_person = #{legalPerson,jdbcType=VARCHAR}
  740. </if>
  741. <if test="legalPersonTel != null">
  742. and legal_person_tel = #{legalPersonTel,jdbcType=VARCHAR}
  743. </if>
  744. </select>
  745. <!-- 财务专员查看需要待收款的数据 -->
  746. <select id="financeList" parameterType="Map" resultType="com.goafanti.order.bo.OrderListBo">
  747. select o.order_no as orderNo, o.sign_time as signTime, u.nickname as buyerName, o.order_status as orderStatus,a.finance_name financeName,
  748. a.cost_amount costAmount,a.payment_amount paymentAmount,o.process_status as processStatus, o.settlement_amount as actuallyTotalAmount,
  749. o.contract_no as contractNo, o.approval, o.back_status backStatus,a.salesman_name as sellerName, o.salesman_id as sellerId,
  750. o.buyer_id as buyerId, o.liquidation_status as liquidationStatus ,too.amount outsourceAmount, o.first_amount as signFirstPayment,
  751. o.total_amount as signTotalAmount, date_format(o.create_time, '%Y-%m-%d %H:%i:%s') as createTime, too.company_name as outsourceName,
  752. 0 as companyId, d.name as departmentName, a.final_receivables finalReceivables ,a.invoice_amount invoiceAmount ,a.order_arrears orderArrears,
  753. o.order_status orderStatus,a.project_type projectType,o.sales_type salesType,o.other ,o.delete_sign deleteSign, a.order_receivables orderReceivables,
  754. date_format(a.`final_Receivables_time`, '%Y-%m-%d %H:%i:%s')finalReceivablesTime,a.patent_cost patentCost,a.patent_cost_actual patentCostActual ,
  755. a.soft_cost softCost ,a.soft_cost_actual softCostActual ,a.audit_cost auditCost ,a.audit_cost_actual auditCostActual ,a.other_cost otherCost ,
  756. a.other_cost_actual otherCostActual , a.expect_profit expectProfit ,a.actual_profit actualProfit,a.service_type serviceType,
  757. a.service_project serviceProject,o.examine_name examineName
  758. from t_order_new o left join department d on o.order_dep = d.id left join `user` u on o.buyer_id = u.id left join t_order_mid a on o.order_no=a.order_no
  759. left join (select * from t_order_outsource where type=0) too on o.order_no=too.order_no where delete_sign in(0,2) and approval in(0,1,2,4,5)
  760. and outsource= #{o.outsource,jdbcType=INTEGER}
  761. <if test="o.processStatus == 3">
  762. and o.process_status = #{o.processStatus,jdbcType=INTEGER}
  763. </if>
  764. <if test="o.processStatus == 4" >
  765. and o.process_status &gt;= #{o.processStatus,jdbcType=INTEGER}
  766. </if>
  767. <if test="o.processStatus == 9">
  768. and o.back_status = 3
  769. </if>
  770. <if test="fids != null and fids.size() &gt; 0">
  771. and d.finance_id in
  772. <foreach close=")" collection="fids" index="" item="item" open="(" separator=",">
  773. #{item}
  774. </foreach>
  775. </if>
  776. <if test="o.orderStatus != null and o.orderStatus != &quot;&quot;">
  777. and (o.order_status >= #{o.orderStatus,jdbcType=INTEGER} or o.back_status=3)
  778. </if>
  779. <if test="deps !=null">
  780. and o.order_dep in
  781. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  782. #{depId}
  783. </foreach>
  784. </if>
  785. <if test="o.contractNo != null and o.contractNo != &quot;&quot;">
  786. and o.contract_no like CONCAT('%',#{o.contractNo,jdbcType=VARCHAR},'%')
  787. </if>
  788. <if test="o.liquidationStatus != null">
  789. and o.liquidation_status = #{o.liquidationStatus,jdbcType=INTEGER}
  790. </if>
  791. <if test="o.amountStatus == 0">
  792. and o.total_amount &lt; 10
  793. </if>
  794. <if test="o.amountStatus == 1">
  795. and o.total_amount between 10 and 20
  796. </if>
  797. <if test="o.amountStatus == 2">
  798. and o.total_amount between 20 and 30
  799. </if>
  800. <if test="o.amountStatus == 3">
  801. and o.total_amount between 30 and 40
  802. </if>
  803. <if test="o.amountStatus == 4">
  804. and o.total_amount &gt; 40
  805. </if>
  806. <if test="o.orderNo != null and o.orderNo != &quot;&quot;">
  807. and o.order_no = #{o.orderNo,jdbcType=VARCHAR}
  808. </if>
  809. <if test="o.projectType != null and o.projectType != &quot;&quot;">
  810. and a.project_type = #{o.projectType}
  811. </if>
  812. <if test="o.approval != null and o.approval ==1">
  813. and o.approval in (1,4)
  814. </if>
  815. <if test="o.approval != null and o.approval ==2">
  816. and o.approval in (2,5)
  817. </if>
  818. <if test="o.approval != null and o.approval ==4">
  819. and o.approval in (1,2,4,5)
  820. </if>
  821. <if test="o.buyerName != null and o.buyerName != &quot;&quot;">
  822. <bind name="n" value="'%' + o.buyerName + '%'" />
  823. and u.nickname like #{n,jdbcType=VARCHAR}
  824. </if>
  825. <if test="o.startTime != null and o.startTime != &quot;&quot; and o.endTime != null and o.endTime != &quot;&quot;">
  826. <bind name="a" value="o.startTime + ' 00:00:00'" />
  827. <bind name="b" value="o.endTime + ' 23:59:59'" />
  828. and o.create_time between #{a,jdbcType=VARCHAR} and #{b,jdbcType=VARCHAR}
  829. </if>
  830. <if test="o.startFinalReceivablesTime != null and o.startFinalReceivablesTime != &quot;&quot; and o.endFinalReceivablesTime != null and o.endFinalReceivablesTime != &quot;&quot;">
  831. <bind name="c" value="o.startFinalReceivablesTime + ' 00:00:00'" />
  832. <bind name="d" value="o.endFinalReceivablesTime + ' 23:59:59'" />
  833. and a.final_Receivables_time between #{c,jdbcType=VARCHAR} and #{d,jdbcType=VARCHAR}
  834. </if>
  835. order by o.liquidation_status, o.sign_time desc
  836. <if test="page_sql != null">
  837. ${page_sql}
  838. </if>
  839. </select>
  840. <select id="financeCount" parameterType="Map" resultType="java.lang.Integer">
  841. select count(*) from t_order_new o left join `user` u on o.buyer_id = u.id
  842. left join department d on o.order_dep = d.id left join t_order_mid a on o.order_no=a.order_no
  843. where delete_sign in(0,2) and approval in(0,1,2) and outsource= #{o.outsource,jdbcType=INTEGER}
  844. <if test="o.processStatus == 3">
  845. and o.process_status = #{o.processStatus,jdbcType=INTEGER}
  846. </if>
  847. <if test="o.processStatus == 4" >
  848. and o.process_status &gt;= #{o.processStatus,jdbcType=INTEGER}
  849. </if>
  850. <if test="o.processStatus == 9">
  851. and o.back_status = 3
  852. </if>
  853. <if test="fids != null and fids.size() &gt; 0">
  854. and d.finance_id in
  855. <foreach close=")" collection="fids" index="" item="item" open="(" separator=",">
  856. #{item}
  857. </foreach>
  858. </if>
  859. <if test="o.orderStatus != null and o.orderStatus != &quot;&quot;">
  860. and (o.order_status >= #{o.orderStatus,jdbcType=INTEGER} or o.back_status=3)
  861. </if>
  862. <if test="deps !=null">
  863. and o.order_dep in
  864. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  865. #{depId}
  866. </foreach>
  867. </if>
  868. <if test="o.contractNo != null and o.contractNo != &quot;&quot;">
  869. and o.contract_no like CONCAT('%',#{o.contractNo,jdbcType=VARCHAR},'%')
  870. </if>
  871. <if test="o.liquidationStatus != null">
  872. and o.liquidation_status = #{o.liquidationStatus,jdbcType=INTEGER}
  873. </if>
  874. <if test="o.amountStatus == 0">
  875. and o.total_amount &lt; 10
  876. </if>
  877. <if test="o.amountStatus == 1">
  878. and o.total_amount between 10 and 20
  879. </if>
  880. <if test="o.amountStatus == 2">
  881. and o.total_amount between 20 and 30
  882. </if>
  883. <if test="o.amountStatus == 3">
  884. and o.total_amount between 30 and 40
  885. </if>
  886. <if test="o.amountStatus == 4">
  887. and o.total_amount &gt; 40
  888. </if>
  889. <if test="o.orderNo != null and o.orderNo != &quot;&quot;">
  890. and o.order_no = #{o.orderNo,jdbcType=VARCHAR}
  891. </if>
  892. <if test="o.projectType != null and o.projectType != &quot;&quot;">
  893. and a.project_type = #{o.projectType}
  894. </if>
  895. <if test="o.approval != null and o.approval ==1">
  896. and o.approval in (1,4)
  897. </if>
  898. <if test="o.approval != null and o.approval ==2">
  899. and o.approval in (2,5)
  900. </if>
  901. <if test="o.approval != null and o.approval ==4">
  902. and o.approval in (1,2,4,5)
  903. </if>
  904. <if test="o.buyerName != null and o.buyerName != &quot;&quot;">
  905. <bind name="n" value="'%' + o.buyerName + '%'" />
  906. and u.nickname like #{n,jdbcType=VARCHAR}
  907. </if>
  908. <if test="o.startTime != null and o.startTime != &quot;&quot; and o.endTime != null and o.endTime != &quot;&quot;">
  909. <bind name="a" value="o.startTime + ' 00:00:00'" />
  910. <bind name="b" value="o.endTime + ' 23:59:59'" />
  911. and o.create_time between #{a,jdbcType=VARCHAR} and #{b,jdbcType=VARCHAR}
  912. </if>
  913. <if test="o.startFinalReceivablesTime != null and o.startFinalReceivablesTime != &quot;&quot; and o.endFinalReceivablesTime != null and o.endFinalReceivablesTime != &quot;&quot;">
  914. <bind name="c" value="o.startFinalReceivablesTime + ' 00:00:00'" />
  915. <bind name="d" value="o.endFinalReceivablesTime + ' 23:59:59'" />
  916. and a.final_Receivables_time between #{c,jdbcType=VARCHAR} and #{d,jdbcType=VARCHAR}
  917. </if>
  918. </select>
  919. <!-- 通过订单编号获得订单的负责人(营销员) -->
  920. <select id="getSaleIdByOno" parameterType="java.lang.String" resultType="com.goafanti.order.bo.TOrderNewBo">
  921. select o.order_no orderNo ,o.salesman_id as salesmanId, a.name as salesmanName,e.name managerName,
  922. o.contract_no contractNo,a.email ,u.nickname as userName,o.order_dep orderDep,d.name departmentName,
  923. d.finance_id financeId
  924. from t_order_new o left join admin a on o.salesman_id = a.id left join `user` u on u.id = o.buyer_id
  925. left join department d on o.order_dep=d.id left join admin e on a.manager_id=e.id
  926. where order_no = #{_parameter,jdbcType=VARCHAR}
  927. </select>
  928. <select id="selectOrderNewListByPage" resultType="com.goafanti.order.bo.TOrderNewBo">
  929. select a.order_no as orderNo,a.create_time as createTime, date_format(a.sign_time,'%Y-%m-%d' ) as signDate,a.delete_sign deleteSign,
  930. a.contract_no as contractNo, b.nickname as userName ,a.process_status as processStatus,a.total_amount as totalAmount,
  931. a.order_status as orderStatus, a.liquidation_status as liquidationStatus,a.approval,c.salesman_name as salesmanName,c.project_type projectType,
  932. dep.name as depName,c.finance_name as financeName,c.invoice_amount invoiceAmount,a.settlement_amount settlementAmount,
  933. a.sales_type salesType, a.channel_id channelId ,a.other,a.examine_name examineName,c.stop_project stopProject
  934. <if test="specially == 2">
  935. ,f.name as initiateName ,e.reason ,date_format(e.create_time,'%Y-%m-%d' ) as backDate,e.id as backId
  936. </if>
  937. <if test="specially == 4">
  938. ,e.receiver_name as consultantName,a.settlement_amount as settlementAmount,if(isnull(g.order_no)=0,1,0) ischange
  939. </if>
  940. from t_order_new a left join `user` b on a.buyer_id=b.id left join t_order_mid c on a.order_no=c.order_no
  941. left join department dep on a.order_dep=dep.id
  942. <if test="specially == 2">
  943. left join (select * from t_order_back a where back_status=0) e on a.order_no=e.order_no
  944. left join admin f on e.initiate=f.id
  945. </if>
  946. <if test="specially == 4">
  947. left join t_order_task e on a.order_no=e.order_no and e.main =1
  948. left join (select order_no from new_order_change group by order_no)g on a.order_no=g.order_no
  949. </if>
  950. <if test="specially == 9">
  951. left join t_order_task tot on a.order_no =tot.order_no
  952. left join business_project bp on tot.commodity_id =bp.id
  953. </if>
  954. <if test="specially == 10">
  955. left join admin mg on a.salesman_id=mg.id
  956. </if>
  957. where a.delete_sign in(0,2)
  958. <if test="specially ==7">
  959. and a.process_status > 4
  960. and a.salesman_id = #{aid,jdbcType=VARCHAR}
  961. </if>
  962. <if test="specially ==8">
  963. and a.process_status > 4
  964. <if test="uid !=null">
  965. and a.buyer_id = #{uid}
  966. </if>
  967. </if>
  968. <if test="specially ==9">
  969. and a.process_status > 4 and bp.type=5
  970. <if test="aid !=null">
  971. and a.salesman_id = #{aid,jdbcType=VARCHAR}
  972. </if>
  973. </if>
  974. <if test="outsource != null">
  975. and a.outsource= #{outsource,jdbcType=INTEGER}
  976. </if>
  977. <if test="specially == 0">
  978. <if test="approval ==null">
  979. and a.approval in(0,1,2,4,5)
  980. </if>
  981. and a.order_status in(0,1,2,4)
  982. and a.salesman_id = #{aid,jdbcType=VARCHAR}
  983. </if>
  984. <if test="specially == 10">
  985. and a.process_status = 1 and a.order_status in (0,1,2)
  986. and mg.manager_id= #{aid}
  987. </if>
  988. <if test="specially == 1">
  989. and a.process_status = 2 and a.order_status in (0,1,2)
  990. </if>
  991. <if test="specially == 2">
  992. and a.order_status in(3,5)
  993. and a.salesman_id = #{aid,jdbcType=VARCHAR}
  994. </if>
  995. <if test="specially == 3">
  996. and a.order_status=2
  997. <if test="approval ==0">
  998. and a.process_status in(4)
  999. and a.approval = 0
  1000. </if>
  1001. <if test="approval ==1">
  1002. and a.process_status in(4)
  1003. and a.approval in
  1004. <if test="manageType ==0">
  1005. (1)
  1006. </if>
  1007. <if test="manageType ==1">
  1008. (4)
  1009. </if>
  1010. </if>
  1011. <if test="approval ==2">
  1012. and a.approval in
  1013. <if test="manageType ==0">
  1014. (2)
  1015. </if>
  1016. <if test="manageType ==1">
  1017. (5)
  1018. </if>
  1019. </if>
  1020. </if>
  1021. <if test="specially !=3 ">
  1022. <if test="approval ==0">
  1023. and a.approval = 0
  1024. </if>
  1025. <if test="approval ==1">
  1026. and a.approval in (1,4)
  1027. </if>
  1028. <if test="approval ==2">
  1029. and a.approval in (2,5)
  1030. </if>
  1031. <if test="approval ==4">
  1032. and a.approval in (1,2,4,5)
  1033. </if>
  1034. </if>
  1035. <if test="specially == 4">
  1036. and a.process_status in (5,6,7,99)
  1037. and a.order_status in(1,2,3,4,6)
  1038. </if>
  1039. <if test="deps!=null">
  1040. and a.order_dep in
  1041. <foreach close=")" collection="deps" item="dep" open="(" separator=",">
  1042. #{dep}
  1043. </foreach>
  1044. </if>
  1045. <if test="distribution == 0">
  1046. and a.process_status &lt; 6
  1047. </if>
  1048. <if test="distribution == 1">
  1049. and a.process_status = 6
  1050. </if>
  1051. <if test="distribution == 2">
  1052. and a.process_status = 7
  1053. </if>
  1054. <if test="name != null">
  1055. and b.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  1056. </if>
  1057. <if test="projectType != null">
  1058. and c.project_type = #{projectType}
  1059. </if>
  1060. <if test="processStatus != null">
  1061. and a.process_status = #{processStatus}
  1062. </if>
  1063. <if test="orderNo != null">
  1064. and a.order_no like CONCAT('%',#{orderNo,jdbcType=VARCHAR},'%')
  1065. </if>
  1066. <if test="contractNo != null">
  1067. and a.contract_no like CONCAT('%',#{contractNo,jdbcType=VARCHAR},'%')
  1068. </if>
  1069. <if test="liquidationStatus != null">
  1070. and a.liquidation_status = #{liquidationStatus,jdbcType=INTEGER}
  1071. </if>
  1072. <if test="amountStatus == 0">
  1073. and a.total_amount &lt; 10
  1074. </if>
  1075. <if test="amountStatus == 1">
  1076. and a.total_amount between 10 and 20
  1077. </if>
  1078. <if test="amountStatus == 2">
  1079. and a.total_amount between 20 and 30
  1080. </if>
  1081. <if test="amountStatus == 3">
  1082. and a.total_amount between 30 and 40
  1083. </if>
  1084. <if test="amountStatus == 4">
  1085. and a.total_amount &gt; 40
  1086. </if>
  1087. <if test="starTime !=null and endTime !=null">
  1088. and a.create_time between #{starTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  1089. </if>
  1090. <if test="contractStart !=null and contractEnd !=null">
  1091. and a.sign_time between #{contractStart,jdbcType=VARCHAR} and #{contractEnd,jdbcType=VARCHAR}
  1092. </if>
  1093. order by
  1094. <if test="specially == 3">
  1095. a.approval,
  1096. </if>
  1097. <if test="specially == 4">
  1098. a.process_status,
  1099. </if>
  1100. <if test="specially != 4">
  1101. a.order_status,
  1102. </if>
  1103. a.create_time
  1104. <if test="specially != 4">
  1105. desc
  1106. </if>
  1107. <if test="page_sql!=null">
  1108. ${page_sql}
  1109. </if>
  1110. </select>
  1111. <select id="selectOrderNewListCount" resultType="java.lang.Integer">
  1112. select count(*)
  1113. from t_order_new a left join `user` b on a.buyer_id=b.id left join t_order_mid c on a.order_no=c.order_no
  1114. left join department dep on a.order_dep=dep.id
  1115. <if test="specially == 9">
  1116. left join t_order_task tot on a.order_no =tot.order_no
  1117. left join business_project bp on tot.commodity_id =bp.id
  1118. </if>
  1119. <if test="specially == 10">
  1120. left join admin mg on a.salesman_id=mg.id
  1121. </if>
  1122. where a.delete_sign in(0,2)
  1123. <if test="specially ==7">
  1124. and a.process_status > 4
  1125. and a.salesman_id = #{aid,jdbcType=VARCHAR}
  1126. </if>
  1127. <if test="specially ==8">
  1128. and a.process_status > 4
  1129. <if test="uid !=null">
  1130. and a.buyer_id = #{uid}
  1131. </if>
  1132. </if>
  1133. <if test="specially ==9">
  1134. and a.process_status > 4 and bp.type=5
  1135. <if test="aid !=null">
  1136. and a.salesman_id = #{aid,jdbcType=VARCHAR}
  1137. </if>
  1138. </if>
  1139. <if test="outsource != null">
  1140. and a.outsource= #{outsource,jdbcType=INTEGER}
  1141. </if>
  1142. <if test="specially == 0">
  1143. <if test="approval ==null">
  1144. and a.approval in(0,1,2,4,5)
  1145. </if>
  1146. and a.order_status in(0,1,2,4)
  1147. and a.salesman_id = #{aid,jdbcType=VARCHAR}
  1148. </if>
  1149. <if test="specially == 10">
  1150. and a.process_status = 1 and a.order_status in (0,1,2)
  1151. and mg.manager_id= #{aid}
  1152. </if>
  1153. <if test="specially == 1">
  1154. and a.process_status = 2 and a.order_status in (0,1,2)
  1155. </if>
  1156. <if test="specially == 2">
  1157. and a.order_status in(3,5)
  1158. and a.salesman_id = #{aid,jdbcType=VARCHAR}
  1159. </if>
  1160. <if test="specially == 3">
  1161. and a.order_status=2
  1162. <if test="approval ==0">
  1163. and a.process_status in(7)
  1164. and a.approval = 0
  1165. </if>
  1166. <if test="approval ==1">
  1167. and a.process_status in(7)
  1168. and a.approval in
  1169. <if test="manageType ==0">
  1170. (1)
  1171. </if>
  1172. <if test="manageType ==1">
  1173. (4)
  1174. </if>
  1175. </if>
  1176. <if test="approval ==2">
  1177. and a.approval in
  1178. <if test="manageType ==0">
  1179. (2)
  1180. </if>
  1181. <if test="manageType ==1">
  1182. (5)
  1183. </if>
  1184. </if>
  1185. </if>
  1186. <if test="specially !=3">
  1187. <if test="approval ==0">
  1188. and a.approval = 0
  1189. </if>
  1190. <if test="approval ==1">
  1191. and a.approval in (1,4)
  1192. </if>
  1193. <if test="approval ==2">
  1194. and a.approval in (2,5)
  1195. </if>
  1196. <if test="approval ==4">
  1197. and a.approval in (1,2,4,5)
  1198. </if>
  1199. </if>
  1200. <if test="specially == 4">
  1201. and a.process_status in (5,6,7,99)
  1202. and a.order_status in(1,2,3,4,6)
  1203. </if>
  1204. <if test="deps!=null">
  1205. and a.order_dep in
  1206. <foreach close=")" collection="deps" item="dep" open="(" separator=",">
  1207. #{dep}
  1208. </foreach>
  1209. </if>
  1210. <if test="distribution == 0">
  1211. and a.process_status &lt; 6
  1212. </if>
  1213. <if test="distribution == 1">
  1214. and a.process_status = 6
  1215. </if>
  1216. <if test="distribution == 2">
  1217. and a.process_status = 7
  1218. </if>
  1219. <if test="name != null">
  1220. and b.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  1221. </if>
  1222. <if test="projectType != null">
  1223. and c.project_type = #{projectType}
  1224. </if>
  1225. <if test="processStatus != null">
  1226. and a.process_status = #{processStatus}
  1227. </if>
  1228. <if test="orderNo != null">
  1229. and a.order_no like CONCAT('%',#{orderNo,jdbcType=VARCHAR},'%')
  1230. </if>
  1231. <if test="contractNo != null">
  1232. and a.contract_no like CONCAT('%',#{contractNo,jdbcType=VARCHAR},'%')
  1233. </if>
  1234. <if test="liquidationStatus != null">
  1235. and a.liquidation_status = #{liquidationStatus,jdbcType=INTEGER}
  1236. </if>
  1237. <if test="amountStatus == 0">
  1238. and a.total_amount &lt; 10
  1239. </if>
  1240. <if test="amountStatus == 1">
  1241. and a.total_amount between 10 and 20
  1242. </if>
  1243. <if test="amountStatus == 2">
  1244. and a.total_amount between 20 and 30
  1245. </if>
  1246. <if test="amountStatus == 3">
  1247. and a.total_amount between 30 and 40
  1248. </if>
  1249. <if test="amountStatus == 4">
  1250. and a.total_amount &gt; 40
  1251. </if>
  1252. <if test="starTime !=null and endTime !=null">
  1253. and a.create_time between #{starTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  1254. </if>
  1255. <if test="contractStart !=null and contractEnd !=null">
  1256. and a.sign_time between #{contractStart,jdbcType=VARCHAR} and #{contractEnd,jdbcType=VARCHAR}
  1257. </if>
  1258. </select>
  1259. <select id="selectDunOrderNewListByPage" resultType="com.goafanti.order.bo.outOrderDunListBo">
  1260. select a.id, b.contract_no contractNo,a.order_no as orderNo,c.nickname as userName,tm.salesman_name as salesmanName,e.project_status projectStatus,
  1261. b.total_amount as totalAmount,b.liquidation_status as liquidationStatus,b.settlement_amount as settlementAmount,a.money as accountsReceivable,
  1262. if((b.total_amount-b.settlement_amount) &lt; 0,0,(b.total_amount-b.settlement_amount)) as uncollectedAmount,b.order_status as orderStatus,
  1263. date_format(a.start_time, '%Y-%m-%d') as startDate,dep.name as depName,date_format(b.sign_time,'%Y-%m-%d') as signDate,
  1264. b.approval ,b.delete_sign deleteSign ,tm.project_type memberType,
  1265. <if test="newStatus == 0 ">
  1266. a.dun_subject as dunSubject,a.dun_status dunStatus
  1267. from t_order_dun a
  1268. </if>
  1269. <if test="newStatus == 1 ">
  1270. a.project_type projectType,a.status dunStatus, a.dun_type dunType,a.appropriation_ratio appropriationRatio,e.commodity_name commodityName,
  1271. e.set_up_amount setUpAmount,date_format(a.customize_time,'%Y-%m-%d') customizeTimes, a.customize_name customizeName
  1272. from new_order_dun a left join t_order_task e on a.tid=e.id
  1273. </if>
  1274. left join t_order_new b on a.order_no=b.order_no left join `user` c on b.buyer_id=c.id
  1275. left join t_order_mid tm on b.order_no=tm.order_no left join department dep on b.order_dep=dep.id
  1276. where b.delete_sign in (0,2)
  1277. <if test="shiroType == 1 and fid !=null">
  1278. and tm.finance_id= #{fid,jdbcType=VARCHAR}
  1279. </if>
  1280. <if test="shiroType == 2 and fid !=null">
  1281. and tm.finance_id in (select id from admin where superior_id= #{fid,jdbcType=VARCHAR})
  1282. </if>
  1283. <if test="amountStatus == 0">
  1284. and b.total_amount &lt; 10
  1285. </if>
  1286. <if test="amountStatus == 1">
  1287. and b.total_amount between 10 and 20
  1288. </if>
  1289. <if test="amountStatus == 2">
  1290. and b.total_amount between 20 and 30
  1291. </if>
  1292. <if test="amountStatus == 3">
  1293. and b.total_amount between 30 and 40
  1294. </if>
  1295. <if test="amountStatus == 4">
  1296. and b.total_amount &gt; 40
  1297. </if>
  1298. <if test="approval != null and approval &lt; 3">
  1299. and b.approval = #{approval}
  1300. </if>
  1301. <if test="approval != null and approval ==4">
  1302. and b.approval in (1,2)
  1303. </if>
  1304. <if test="memberType !=null">
  1305. and tm.project_type= #{memberType}
  1306. </if>
  1307. <if test="name != null">
  1308. and c.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  1309. </if>
  1310. <if test="adminName != null">
  1311. and tm.salesman_name like CONCAT('%',#{adminName,jdbcType=VARCHAR},'%')
  1312. </if>
  1313. <if test="orderNo != null">
  1314. and a.order_no like CONCAT('%',#{orderNo,jdbcType=VARCHAR},'%')
  1315. </if>
  1316. <if test="contractNo != null">
  1317. and b.contract_no like CONCAT('%',#{contractNo,jdbcType=VARCHAR},'%')
  1318. </if>
  1319. <if test="deps != null">
  1320. and b.order_dep in
  1321. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  1322. #{depId}
  1323. </foreach>
  1324. </if>
  1325. <if test="dunStatus != null">
  1326. and a.status= #{dunStatus}
  1327. </if>
  1328. <if test="aid != null">
  1329. and b.salesman_id= #{aid,jdbcType=VARCHAR}
  1330. </if>
  1331. <if test="starTime !=null and endTime !=null">
  1332. and b.sign_time between #{starTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  1333. </if>
  1334. order by b.sign_time desc,b.create_time desc
  1335. <if test="page_sql!=null">
  1336. ${page_sql}
  1337. </if>
  1338. </select>
  1339. <select id="selectDunOrderNewListCount" resultType="java.lang.Integer">
  1340. select
  1341. count(*)
  1342. <if test="newStatus == 0 ">
  1343. from t_order_dun a
  1344. </if>
  1345. <if test="newStatus == 1 ">
  1346. from new_order_dun a left join t_order_task e on a.tid=e.id
  1347. </if>
  1348. left join t_order_new b on a.order_no=b.order_no left join `user` c on b.buyer_id=c.id
  1349. left join t_order_mid tm on b.order_no=tm.order_no
  1350. where b.delete_sign in (0,2)
  1351. <if test="shiroType == 1 and fid !=null">
  1352. and tm.finance_id= #{fid,jdbcType=VARCHAR}
  1353. </if>
  1354. <if test="shiroType == 2 and fid !=null">
  1355. and tm.finance_id in (select id from admin where superior_id= #{fid,jdbcType=VARCHAR})
  1356. </if>
  1357. <if test="amountStatus == 0">
  1358. and b.total_amount &lt; 10
  1359. </if>
  1360. <if test="amountStatus == 1">
  1361. and b.total_amount between 10 and 20
  1362. </if>
  1363. <if test="amountStatus == 2">
  1364. and b.total_amount between 20 and 30
  1365. </if>
  1366. <if test="amountStatus == 3">
  1367. and b.total_amount between 30 and 40
  1368. </if>
  1369. <if test="amountStatus == 4">
  1370. and b.total_amount &gt; 40
  1371. </if>
  1372. <if test="approval != null and approval &lt; 3">
  1373. and b.approval = #{approval}
  1374. </if>
  1375. <if test="approval != null and approval ==4">
  1376. and b.approval in (1,2)
  1377. </if>
  1378. <if test="memberType !=null">
  1379. and tm.project_type= #{memberType}
  1380. </if>
  1381. <if test="name != null">
  1382. and c.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  1383. </if>
  1384. <if test="adminName != null">
  1385. and salesman_name like CONCAT('%',#{adminName,jdbcType=VARCHAR},'%')
  1386. </if>
  1387. <if test="orderNo != null">
  1388. and a.order_no like CONCAT('%',#{orderNo,jdbcType=VARCHAR},'%')
  1389. </if>
  1390. <if test="contractNo != null">
  1391. and b.contract_no like CONCAT('%',#{contractNo,jdbcType=VARCHAR},'%')
  1392. </if>
  1393. <if test="deps != null">
  1394. and b.order_dep in
  1395. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  1396. #{depId}
  1397. </foreach>
  1398. </if>
  1399. <if test="dunStatus != null">
  1400. and a.status= #{dunStatus}
  1401. </if>
  1402. <if test="aid != null">
  1403. and b.salesman_id= #{aid,jdbcType=VARCHAR}
  1404. </if>
  1405. <if test="starTime !=null and endTime !=null">
  1406. and b.sign_time between #{starTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  1407. </if>
  1408. </select>
  1409. <select id="getOrderNewDetail" parameterType="java.lang.String" resultType="com.goafanti.order.bo.TOrderNewBo">
  1410. select
  1411. a.order_no as orderNo, a.order_type as orderType, a.creater, a.create_time as createTime,a.update_time as updateTime, a.buyer_id as buyerId,a.other,
  1412. a.first_amount as firstAmount,a.total_amount as totalAmount, a.settlement_amount as settlementAmount, order_status as orderStatus,a.user_type userType,
  1413. a.liquidation_status as liquidationStatus, a.process_status as processStatus, a.project_status as projectStatus, a.approval,a.sales_type salesType,
  1414. a.order_remarks as orderRemarks, a.delete_sign as deleteSign, a.salesman_id as salesmanId, a.finance_id as financeId, technician_id as technicianId,
  1415. a.sign_time as signTime, a.settlement_time as settlementTime, a.contract_no as contractNo, a.contract_type as contractType, a.contacts,a.channel_id channelId,
  1416. a.contact_mobile as contactMobile, a.legal_person as legalPerson, a.legal_person_tel as legalPersonTel, a.proof_count as proofCount,
  1417. a.proof_aid as proofAid,contract_picture_url as contractPictureUrl, c.name as salesmanName,dep.name as depName,d.name as financeName,
  1418. c.contact_mobile as salesmanMobile,d.contact_mobile as financeMobile,b.username as userName ,b.nickname as nickname ,e.back_status as backStatus,f.name as initiateName,
  1419. e.reason,date_format(e.create_time,'%Y-%m-%d') as backDate,a.buyer_id as uid,a.order_dep as orderDep, g.location_province as locationProvince,
  1420. g.location_city as locationCity,g.location_area locationArea,g.postal_address postalAddress,outsource,a.primary_order primaryOrder,a.agreement_url agreementUrl,
  1421. h.name NowFinance,h.contact_mobile NowFinanceMobile,a.additional_order additionalOrder,i.name as oldSalesmanName, i.contact_mobile oldSalesmanMobile,
  1422. a.service_content serviceContent,a.examine_name examineName, tht.knowledge_services knowledgeServices, tht.audit_services auditServices,c.manager_id managerId,
  1423. tht.add_deduction_services addDeductionServices, tht.knowledge_other knowledgeOther, tht.audit_other auditOther, tht.add_deduction_other addDeductionOther
  1424. from t_order_new a left join `user` b on a.buyer_id=b.id left join admin i on a.old_salesman_id=i.id
  1425. left join admin c on a.salesman_id=c.id left join department dep on a.order_dep=dep.id
  1426. left join admin d on a.finance_id=d.id left join admin h on dep.finance_id=h.id
  1427. left join t_order_back e on a.order_no=e.order_no and e.back_status=0
  1428. left join admin f on e.initiate=f.id left join organization_identity g on a.buyer_id=g.uid
  1429. left join t_order_high_tech tht on a.order_no=tht.order_no
  1430. where a.order_no = #{orderNo,jdbcType=VARCHAR}
  1431. </select>
  1432. <select id="selectOrderRefundListByPage" resultType="com.goafanti.order.bo.TOrderRefundBo">
  1433. select a.id, date_format(a.create_time,'%Y-%m-%d') as createDate,a.order_no as orderNo,
  1434. c.nickname as userName,b.order_status as orderStatus,a.refund_status as refundStatus,
  1435. a.reason,b.liquidation_status as liquidationStatus
  1436. from t_order_refund a left join t_order_new b on a.order_no=b.order_no
  1437. left join `user` c on b.buyer_id=c.id
  1438. where b.delete_sign in(0,2,3)
  1439. <if test="name != null">
  1440. and c.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  1441. </if>
  1442. <if test="aid != null">
  1443. and a.initiate = #{aid,jdbcType=VARCHAR}
  1444. </if>
  1445. <if test="orderNo != null">
  1446. and a.order_no = #{orderNo,jdbcType=VARCHAR}
  1447. </if>
  1448. <if test="starTime !=null and endTime !=null">
  1449. and a.create_time between #{starTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  1450. </if>
  1451. order by a.create_time desc
  1452. <if test="page_sql!=null">
  1453. ${page_sql}
  1454. </if>
  1455. </select>
  1456. <select id="selectOrderRefundListCount" resultType="java.lang.Integer">
  1457. select
  1458. count(*)
  1459. from t_order_refund a left join t_order_new b on a.order_no=b.order_no
  1460. left join `user` c on b.buyer_id=c.id
  1461. where b.delete_sign in(0,2,3)
  1462. <if test="name != null">
  1463. and c.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  1464. </if>
  1465. <if test="aid != null">
  1466. and a.initiate = #{aid,jdbcType=VARCHAR}
  1467. </if>
  1468. <if test="orderNo != null">
  1469. and a.order_no = #{orderNo,jdbcType=VARCHAR}
  1470. </if>
  1471. <if test="starTime !=null and endTime !=null">
  1472. and a.create_time between #{starTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  1473. </if>
  1474. </select>
  1475. <!-- 财务同意退款邮件通知需要的数据 -->
  1476. <select id="agreeEmailData" parameterType="java.lang.Integer" resultType="com.goafanti.order.bo.TOrderNewBo">
  1477. select u.nickname as userName, r.order_no as orderNo, o.order_status as orderStatus, o.salesman_id as salesmanId, o.technician_id as technicianId,
  1478. concat(a.email,"," , ifnull(t.email,"")) as email , concat(a.name,"," , ifnull(t.name,"")) as salesmanName
  1479. from t_order_refund r
  1480. left join t_order_new o on r.order_no = o.order_no
  1481. left join admin a on a.id = o.salesman_id
  1482. left join admin t on t.id = o.technician_id
  1483. left join `user` u on u.id = o.buyer_id
  1484. where r.id = #{id,jdbcType=INTEGER}
  1485. </select>
  1486. <select id="orderRefundDetail" resultType="com.goafanti.order.bo.OrderRefundDetailBo">
  1487. select a.id,date_format(a.create_time,'%Y-%m-%d') as createDate ,a.order_no as orderNo,
  1488. b.order_status as orderStatus,a.refund_status as refundStatus, a.application_url as applicationUrl,
  1489. a.contract_url as contractUrl,a.reason,b.liquidation_status as liquidationStatus
  1490. from t_order_refund a
  1491. left join t_order_new b on a.order_no=b.order_no
  1492. where a.id= #{id,jdbcType=INTEGER}
  1493. </select>
  1494. <update id="updateFinance" parameterType="string">
  1495. update t_order_new set finance_id= #{newFinance,jdbcType=VARCHAR}
  1496. where order_no in
  1497. <foreach close=")" collection="orderNos" item="orderNo" open="(" separator=",">
  1498. #{orderNo}
  1499. </foreach>
  1500. and finance_id= #{aid,jdbcType=VARCHAR}
  1501. </update>
  1502. <select id="checkContractNo" resultType="java.lang.Integer">
  1503. select count(contract_no) from t_order_new
  1504. where contract_no= #{0}
  1505. </select>
  1506. <select id="countTotalAndActually" parameterType="Map" resultType="java.util.Map">
  1507. select IFNULL( sum(o.settlement_amount),0) actuallyTotalAmount,IFNULL(sum(o.total_amount),0) signTotalAmount
  1508. from t_order_new o
  1509. left join department d on o.order_dep=d.id left join `user` u on o.buyer_id = u.id left join t_order_mid a on o.order_no=a.order_no
  1510. where o.delete_sign in(0,2,3) and (o.approval = 0 or o.approval = 2) and outsource= #{o.outsource,jdbcType=INTEGER}
  1511. <if test="o.processStatus == 3">
  1512. and o.process_status = #{o.processStatus,jdbcType=INTEGER}
  1513. </if>
  1514. <if test="o.processStatus == 4">
  1515. and o.process_status &gt;= #{o.processStatus,jdbcType=INTEGER}
  1516. </if>
  1517. <if test="o.processStatus == 9">
  1518. and o.back_status = 3
  1519. </if>
  1520. <if test="fids != null and fids.size() &gt; 0">
  1521. and d.finance_id in
  1522. <foreach close=")" collection="fids" index="" item="item" open="(" separator=",">
  1523. #{item}
  1524. </foreach>
  1525. </if>
  1526. <if test="o.orderStatus != null and o.orderStatus != &quot;&quot;">
  1527. and (o.order_status >= #{o.orderStatus,jdbcType=INTEGER} or o.back_status=3)
  1528. </if>
  1529. <if test="deps !=null">
  1530. and o.order_dep in
  1531. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  1532. #{depId}
  1533. </foreach>
  1534. </if>
  1535. <if test="o.contractNo != null and o.contractNo != &quot;&quot;">
  1536. and o.contract_no like CONCAT('%',#{o.contractNo,jdbcType=VARCHAR},'%')
  1537. </if>
  1538. <if test="o.liquidationStatus != null">
  1539. and o.liquidation_status = #{o.liquidationStatus,jdbcType=INTEGER}
  1540. </if>
  1541. <if test="o.amountStatus == 0">
  1542. and o.total_amount &lt; 10
  1543. </if>
  1544. <if test="o.amountStatus == 1">
  1545. and o.total_amount between 10 and 20
  1546. </if>
  1547. <if test="o.amountStatus == 2">
  1548. and o.total_amount between 20 and 30
  1549. </if>
  1550. <if test="o.amountStatus == 3">
  1551. and o.total_amount between 30 and 40
  1552. </if>
  1553. <if test="o.amountStatus == 4">
  1554. and o.total_amount &gt; 40
  1555. </if>
  1556. <if test="o.orderNo != null and o.orderNo != &quot;&quot;">
  1557. and o.order_no = #{o.orderNo,jdbcType=VARCHAR}
  1558. </if>
  1559. <if test="o.projectType != null and o.projectType != &quot;&quot;">
  1560. and a.project_type = #{o.projectType}
  1561. </if>
  1562. <if test="o.approval != null and o.approval &lt; 3">
  1563. and o.approval = #{o.approval}
  1564. </if>
  1565. <if test="o.approval != null and o.approval ==4">
  1566. and o.approval in (1,2)
  1567. </if>
  1568. <if test="o.buyerName != null and o.buyerName != &quot;&quot;">
  1569. <bind name="n" value="'%' + o.buyerName + '%'" />
  1570. and u.nickname like #{n,jdbcType=VARCHAR}
  1571. </if>
  1572. <if test="o.startTime != null and o.startTime != &quot;&quot; and o.endTime != null and o.endTime != &quot;&quot;">
  1573. <bind name="a" value="o.startTime + ' 00:00:00'" />
  1574. <bind name="b" value="o.endTime + ' 23:59:59'" />
  1575. and o.create_time between #{a,jdbcType=VARCHAR} and #{b,jdbcType=VARCHAR}
  1576. </if>
  1577. <if test="o.startFinalReceivablesTime != null and o.startFinalReceivablesTime != &quot;&quot; and o.endFinalReceivablesTime != null and o.endFinalReceivablesTime != &quot;&quot;">
  1578. <bind name="c" value="o.startFinalReceivablesTime + ' 00:00:00'" />
  1579. <bind name="d" value="o.endFinalReceivablesTime + ' 23:59:59'" />
  1580. and a.final_Receivables_time between #{c,jdbcType=VARCHAR} and #{d,jdbcType=VARCHAR}
  1581. </if>
  1582. </select>
  1583. <select id="getLastPayment" resultType="com.goafanti.common.model.TOrderBillNew">
  1584. select date_format(create_time, '%Y-%m-%d %H:%i:%s') createTimes,transaction_amount transactionAmount from t_order_bill_new
  1585. where order_no= #{orderNo}
  1586. order by create_time desc limit 1;
  1587. </select>
  1588. <update id="updateSalesmanId">
  1589. update t_order_new set salesman_id= #{transferId},old_salesman_id= #{aid}
  1590. where delete_sign in(0,2,3) and salesman_id= #{aid}
  1591. </update>
  1592. <select id="selectUsedOrderByOrder" resultType="com.goafanti.order.bo.TOrderNewBo">
  1593. select
  1594. a.order_no as orderNo, a.order_type as orderType, a.creater, a.create_time as createTime,a.update_time as updateTime, a.buyer_id as buyerId,
  1595. a.first_amount as firstAmount,a.total_amount as totalAmount, a.settlement_amount as settlementAmount, order_status as orderStatus,
  1596. a.liquidation_status as liquidationStatus, a.process_status as processStatus, a.project_status as projectStatus, a.approval,
  1597. a.order_remarks as orderRemarks, a.delete_sign as deleteSign, a.salesman_id as salesmanId, a.finance_id as financeId, technician_id as technicianId,
  1598. a.sign_time as signTime, a.settlement_time as settlementTime, a.contract_no as contractNo, a.contract_type as contractType, a.contacts,
  1599. a.contact_mobile as contactMobile, a.legal_person as legalPerson, a.legal_person_tel as legalPersonTel, a.proof_count as proofCount,
  1600. a.proof_aid as proofAid,contract_picture_url as contractPictureUrl, c.name as salesmanName,dep.name as depName,d.name as financeName,
  1601. c.contact_mobile as salesmanMobile,d.contact_mobile as financeMobile,b.nickname as userName ,e.back_status as backStatus,f.name as initiateName,
  1602. e.reason,date_format(e.create_time,'%Y-%m-%d') as backDate,a.buyer_id as uid,a.order_dep as orderDep, g.location_province as locationProvince,
  1603. g.location_city as locationCity,g.location_area locationArea,g.postal_address postalAddress,outsource,a.primary_order primaryOrder,
  1604. h.name NowFinance,h.contact_mobile NowFinanceMobile,a.additional_order additionalOrder,i.name as oldSalesmanName, i.contact_mobile oldSalesmanMobile
  1605. from new_order_change noc left join t_order_new a on noc.used_order=a.order_no left join `user` b on a.buyer_id=b.id left join admin i on a.old_salesman_id=i.id
  1606. left join admin c on a.salesman_id=c.id left join department dep on a.order_dep=dep.id left join admin d on a.finance_id=d.id
  1607. left join admin h on dep.finance_id=h.id left join (select * from t_order_back a where back_status=0) e on a.order_no=e.order_no
  1608. left join admin f on e.initiate=f.id left join organization_identity g on a.buyer_id=g.uid
  1609. where noc.order_no= #{orderNo} order by noc.create_time
  1610. </select>
  1611. <update id="updaterefund" parameterType="com.goafanti.common.model.TOrderNew">
  1612. update t_order_new set settlement_amount=settlement_amount-#{refundAmount,jdbcType=DECIMAL},
  1613. refund_amount=#{refundAmount,jdbcType=DECIMAL} where order_no=#{orderNo}
  1614. </update>
  1615. <update id="updateDepExamine">
  1616. update t_order_new a ,(select a.department_id depId,group_concat(a.name) name
  1617. from admin a left join user_role b on a.id=b.uid
  1618. left join `role` c on b.rid =c.id
  1619. where c.role_type ='9996' and a.status ='0' and a.department_id = #{departmentId}
  1620. group by a.department_id ) b
  1621. set a.examine_name =b.name
  1622. where a.order_dep = #{departmentId} and a.order_dep =b.depId
  1623. </update>
  1624. <update id="updateExamineById">
  1625. update t_order_new a
  1626. <if test="type==0 or type==1">
  1627. left join admin b on a.salesman_id =b.id
  1628. left join admin c on b.manager_id =c.id
  1629. set a.examine_name =c.name
  1630. where a.process_status =1 and c.id= #{id}
  1631. </if>
  1632. <if test="type==2">
  1633. left join (select a.department_id depId,group_concat(a.name) name
  1634. from admin a left join admin b on a.department_id =b.department_id
  1635. left join user_role c on a.id=c.uid left join `role` d on c.rid =d.id
  1636. where b.id= #{id} and d.role_type ='9996'
  1637. and a.status ='0' group by b.department_id )x on a.order_dep=x.depId
  1638. set a.examine_name=x.name
  1639. where a.process_status =2
  1640. </if>
  1641. <if test="type==3">
  1642. left join department b on a.order_dep =b.id
  1643. left join admin c on b.finance_id =c.id
  1644. set a.examine_name =c.name
  1645. where a.process_status =3 and c.id =#{id}
  1646. </if>
  1647. <if test="type==5">
  1648. update t_order_new a left join (select group_concat(a.name) name
  1649. from admin a left join user_role b on a.id=b.uid
  1650. left join `role` c on b.rid =c.id
  1651. where c.role_type in ('9998') and a.status ='0' )b on 1=1
  1652. set a.examine_name =b.name
  1653. where a.process_status =5
  1654. </if>
  1655. </update>
  1656. <select id="selectArrearsDunListByPage" resultType="com.goafanti.order.bo.OutArrearsDunListBo">
  1657. select a.id, b.contract_no contractNo,a.order_no as orderNo,c.nickname as userName,tm.salesman_name as salesmanName,
  1658. b.project_status projectStatus, b.total_amount as totalAmount,b.liquidation_status as liquidationStatus,a.`type`,
  1659. b.settlement_amount as settlementAmount, a.order_receivables orderReceivables,a.order_arrears as orderArrears,
  1660. b.order_status as orderStatus, date_format(a.start_time, '%Y-%m-%d %H:%i:%s') as startDate,dep.name as depName,
  1661. date_format(b.sign_time,'%Y-%m-%d') as signDate,a.dun_status dunStatus,x.commodity_name commodityName
  1662. from t_arrears_dun a
  1663. left join (select order_no ,commodity_name from t_order_task where main =1)x on a.order_no =x.order_no
  1664. left join t_order_new b on a.order_no=b.order_no left join `user` c on b.buyer_id=c.id
  1665. left join t_order_mid tm on b.order_no=tm.order_no left join department dep on b.order_dep=dep.id
  1666. where b.delete_sign in(0,2,3) and dun_status in (1,2,3)
  1667. <if test="shiroType == 1 and fid !=null">
  1668. and tm.finance_id= #{fid,jdbcType=VARCHAR}
  1669. </if>
  1670. <if test="shiroType == 2 and fid !=null">
  1671. and tm.finance_id in (select id from admin where superior_id= #{fid,jdbcType=VARCHAR})
  1672. </if>
  1673. <if test="name != null">
  1674. and c.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  1675. </if>
  1676. <if test="adminName != null">
  1677. and tm.salesman_name like CONCAT('%',#{adminName,jdbcType=VARCHAR},'%')
  1678. </if>
  1679. <if test="orderNo != null">
  1680. and a.order_no like CONCAT('%',#{orderNo,jdbcType=VARCHAR},'%')
  1681. </if>
  1682. <if test="contractNo != null">
  1683. and b.contract_no like CONCAT('%',#{contractNo,jdbcType=VARCHAR},'%')
  1684. </if>
  1685. <if test="deps != null">
  1686. and b.order_dep in
  1687. <foreach close=")" collection="deps" item="dep" open="(" separator=",">
  1688. #{dep}
  1689. </foreach>
  1690. </if>
  1691. <if test="shiroType !=3 and aid != null">
  1692. and b.salesman_id= #{aid,jdbcType=VARCHAR}
  1693. </if>
  1694. <if test="starTime !=null and endTime !=null">
  1695. and b.sign_time between #{starTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  1696. </if>
  1697. <if test="tStarTime !=null and tEndTime !=null">
  1698. and a.start_time between #{tStarTime,jdbcType=VARCHAR} and #{tEndTime,jdbcType=VARCHAR}
  1699. </if>
  1700. order by dun_status,a.start_time desc
  1701. <if test="page_sql!=null">
  1702. ${page_sql}
  1703. </if>
  1704. </select>
  1705. <select id="selectArrearsDunListByCount" resultType="java.lang.Integer">
  1706. select count(*) from t_arrears_dun a
  1707. left join t_order_new b on a.order_no=b.order_no left join `user` c on b.buyer_id=c.id
  1708. left join t_order_mid tm on b.order_no=tm.order_no left join department dep on b.order_dep=dep.id
  1709. where b.delete_sign in(0,2,3) and dun_status in (1,2,3)
  1710. <if test="shiroType == 1 and fid !=null">
  1711. and tm.finance_id= #{fid,jdbcType=VARCHAR}
  1712. </if>
  1713. <if test="shiroType == 2 and fid !=null">
  1714. and tm.finance_id in (select id from admin where superior_id= #{fid,jdbcType=VARCHAR})
  1715. </if>
  1716. <if test="shiroType !=3 and aid != null">
  1717. and b.salesman_id= #{aid,jdbcType=VARCHAR}
  1718. </if>
  1719. <if test="name != null">
  1720. and c.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  1721. </if>
  1722. <if test="adminName != null">
  1723. and tm.salesman_name like CONCAT('%',#{adminName,jdbcType=VARCHAR},'%')
  1724. </if>
  1725. <if test="orderNo != null">
  1726. and a.order_no like CONCAT('%',#{orderNo,jdbcType=VARCHAR},'%')
  1727. </if>
  1728. <if test="deps != null">
  1729. and b.order_dep in
  1730. <foreach close=")" collection="deps" item="dep" open="(" separator=",">
  1731. #{dep}
  1732. </foreach>
  1733. </if>
  1734. <if test="shiroType !=3 and aid != null">
  1735. and b.salesman_id= #{aid,jdbcType=VARCHAR}
  1736. </if>
  1737. <if test="starTime !=null and endTime !=null">
  1738. and b.sign_time between #{starTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  1739. </if>
  1740. <if test="tStarTime !=null and tEndTime !=null">
  1741. and a.start_time between #{tStarTime,jdbcType=VARCHAR} and #{tEndTime,jdbcType=VARCHAR}
  1742. </if>
  1743. </select>
  1744. <select id="selectByUidAndNewUser" resultType="java.math.BigDecimal">
  1745. select total_amount from t_order_new
  1746. where process_status >4 and buyer_id = #{uid}
  1747. and salesman_id =#{aid}
  1748. and new_user = #{newUser}
  1749. and create_time between #{date} and #{now}
  1750. </select>
  1751. <select id="statisticsList" resultType="com.goafanti.order.bo.outStatisticsList">
  1752. select z.id,z.province,z.counts,z.quantity,z.total
  1753. from (select y.id,y.province,count(aid)counts,sum(quantity)quantity,sum(total)total
  1754. from (select x.id,x.province,x.aid,sum(quantity)quantity, sum(x.total)total
  1755. from (select d.id,d.name province,a.order_no,a.salesman_id aid,
  1756. if(a.total_amount>0.5,1,if(a.total_amount>0 and a.order_type=1,0.5,0))quantity,
  1757. a.total_amount total
  1758. from t_order_new a left join admin b on a.salesman_id =b.id
  1759. left join department c on b.department_id =c.id left join district_glossory d on c.province =d.id
  1760. where a.process_status >4 and a.delete_sign in(0,2)
  1761. <if test="depId !=null">
  1762. and b.department_id = #{depId}
  1763. </if>
  1764. <if test="province !=null">
  1765. and c.province = #{province}
  1766. </if>
  1767. <if test="startCreate !=null and endCreate !=null">
  1768. and a.create_time between #{startCreate} and #{endCreate}
  1769. </if>
  1770. <if test="startSign !=null and endSign !=null">
  1771. and a.sign_time between #{startSign} and #{endSign}
  1772. </if>
  1773. )x group by x.id,x.province,x.aid)y group by y.id,y.province)z
  1774. order by
  1775. <if test="sort ==0">
  1776. total
  1777. </if>
  1778. <if test="sort ==1">
  1779. quantity
  1780. </if>
  1781. <if test="sort ==2">
  1782. counts
  1783. </if>
  1784. desc
  1785. </select>
  1786. <select id="provinceStatisticsList" resultType="com.goafanti.order.bo.outProvinceStatisticsList">
  1787. select z.depName,z.aid,z.name,z.quantity,z.total
  1788. from ( select x.depName,x.aid,x.name,sum(quantity)quantity,sum(total)total
  1789. from ( select c.name depName,a.order_no,b.id aid,b.name name,
  1790. if(a.total_amount>0.5,1,if(a.total_amount>0 and a.order_type=1,0.5,0))quantity,
  1791. a.total_amount total
  1792. from t_order_new a left join admin b on a.salesman_id =b.id
  1793. left join department c on b.department_id =c.id left join district_glossory d on c.province =d.id
  1794. where a.process_status >4 and a.delete_sign in(0,2)
  1795. <if test="depId !=null">
  1796. and b.department_id = #{depId}
  1797. </if>
  1798. <if test="province !=null">
  1799. and c.province = #{province}
  1800. </if>
  1801. <if test="startCreate !=null and endCreate !=null">
  1802. and a.create_time between #{startCreate} and #{endCreate}
  1803. </if>
  1804. <if test="startSign !=null and endSign !=null">
  1805. and a.sign_time between #{startSign} and #{endSign}
  1806. </if>
  1807. )x group by x.depName,x.aid,x.name )z order by
  1808. <if test="sort ==0">
  1809. total
  1810. </if>
  1811. <if test="sort ==1">
  1812. quantity
  1813. </if>
  1814. desc
  1815. </select>
  1816. <select id="selectOrderByuid" resultType="java.util.Map">
  1817. select order_no orderNo,contract_no contractNo
  1818. from t_order_new where delete_sign in (0,2) and buyer_id = #{uid}
  1819. order by create_time desc
  1820. </select>
  1821. <select id="orderSalesSourceAmount" resultType="com.goafanti.order.bo.outStatistics.OutOrderSalesSourceAmount">
  1822. select y.province,dg.name ,y.total_amount totalAmount,y.counts,y.dhxkf,
  1823. y.dhxkf/y.total_amount dhxkfl, y.dhzdzy,y.dhzdzy/y.total_amount dhzdzyl,y.wl,y.wl/y.total_amount wll,
  1824. y.qd,y.qd/y.total_amount qdl,y.zjs,y.zjs/y.total_amount zjsl,y.qt,y.qt/y.total_amount qtl,
  1825. y.gxfg,y.gxfg/y.total_amount gxfgl,y.qtfg,y.qtfg/y.total_amount qtfgl
  1826. from (select x.province,sum(x.total_amount)total_amount,sum(x.counts)counts,
  1827. sum(x.dhxkf)dhxkf,sum(x.dhzdzy)dhzdzy,sum(x.wl)wl,sum(x.qd)qd, sum(x.zjs)zjs, sum(x.qt)qt,
  1828. sum(x.gxfg)gxfg, sum(x.qtfg)qtfg
  1829. from ( select b.province ,1 counts,a.total_amount,a.sales_type ,
  1830. case a.sales_type when 0 then a.total_amount else 0 end dhxkf,
  1831. case a.sales_type when 1 then a.total_amount else 0 end dhzdzy,
  1832. case a.sales_type when 2 then a.total_amount else 0 end wl,
  1833. case a.sales_type when 3 then a.total_amount else 0 end qd,
  1834. case a.sales_type when 4 then a.total_amount else 0 end zjs,
  1835. case a.sales_type when 5 then a.total_amount else 0 end qt,
  1836. case a.sales_type when 6 then a.total_amount else 0 end gxfg,
  1837. case a.sales_type when 7 then a.total_amount else 0 end qtfg
  1838. from t_order_new a left join department b on a.order_dep =b.id
  1839. where a.delete_sign in (0,2) and a.process_status &gt; 0 and a.approval in (0,1,2)
  1840. <if test=" startDate !=null and endDate != null">
  1841. and a.create_time between #{startDate} and #{endDate}
  1842. </if>
  1843. <if test=" deps !=null">
  1844. and a.order_dep in
  1845. <foreach close=")" collection="listDep" item="depId" open="(" separator=",">
  1846. #{depId}
  1847. </foreach>
  1848. </if>
  1849. <if test=" province !=null">
  1850. and b.province = #{province}
  1851. </if>
  1852. )x group by x.province)y left join district_glossory dg on y.province=dg.id
  1853. order by y.total_amount desc
  1854. </select>
  1855. <select id="orderSalesSource" resultType="com.goafanti.order.bo.OutOrderSalesSource">
  1856. select y.province,dg.name ,y.total_amount totalAmount,y.counts,y.dhxkf,y.dhxkf/y.counts dhxkfl,
  1857. y.dhzdzy,y.dhzdzy/y.counts dhzdzyl,y.wl,y.wl/y.counts wll,
  1858. y.qd,y.qd/y.counts qdl,y.zjs,y.zjs/y.counts zjsl,y.qt,y.qt/y.counts qtl,
  1859. y.gxfg,y.gxfg/y.counts gxfgl,y.qtfg,y.qtfg/y.counts qtfgl
  1860. from (select x.province,sum(x.total_amount)total_amount,sum(x.counts)counts,
  1861. sum(x.dhxkf)dhxkf,sum(x.dhzdzy)dhzdzy,sum(x.wl)wl,sum(x.qd)qd, sum(x.zjs)zjs, sum(x.qt)qt,
  1862. sum(x.gxfg)gxfg, sum(x.qtfg)qtfg
  1863. from ( select b.province ,1 counts,a.total_amount,a.sales_type ,
  1864. case a.sales_type when 0 then 1 else 0 end dhxkf,
  1865. case a.sales_type when 1 then 1 else 0 end dhzdzy,
  1866. case a.sales_type when 2 then 1 else 0 end wl,
  1867. case a.sales_type when 3 then 1 else 0 end qd,
  1868. case a.sales_type when 4 then 1 else 0 end zjs,
  1869. case a.sales_type when 5 then 1 else 0 end qt,
  1870. case a.sales_type when 6 then 1 else 0 end gxfg,
  1871. case a.sales_type when 7 then 1 else 0 end qtfg
  1872. from t_order_new a left join department b on a.order_dep =b.id
  1873. where a.delete_sign in (0,2) and a.process_status &gt; 0 and a.approval in (0,1,2)
  1874. <if test=" startDate !=null and endDate != null">
  1875. and a.create_time between #{startDate} and #{endDate}
  1876. </if>
  1877. <if test=" deps !=null">
  1878. and a.order_dep in
  1879. <foreach close=")" collection="listDep" item="depId" open="(" separator=",">
  1880. #{depId}
  1881. </foreach>
  1882. </if>
  1883. <if test=" province !=null">
  1884. and b.province = #{province}
  1885. </if>
  1886. )x group by x.province)y left join district_glossory dg on y.province=dg.id
  1887. order by y.counts desc
  1888. </select>
  1889. <select id="selectstatisticsOrderListPage" resultType="com.goafanti.order.bo.TOrderNewBo">
  1890. select a.order_no as orderNo,a.create_time as createTime, date_format(a.sign_time,'%Y-%m-%d' ) as signDate,a.delete_sign deleteSign,
  1891. a.contract_no as contractNo, b.nickname as userName ,a.process_status as processStatus,a.total_amount as totalAmount,
  1892. a.order_status as orderStatus, a.liquidation_status as liquidationStatus,a.approval,c.salesman_name as salesmanName,c.project_type projectType,
  1893. dep.name as depName,c.finance_name as financeName,c.invoice_amount invoiceAmount,a.settlement_amount settlementAmount,
  1894. a.sales_type salesType, a.channel_id channelId ,a.other
  1895. from t_order_new a left join `user` b on a.buyer_id=b.id left join t_order_mid c on a.order_no=c.order_no
  1896. left join department dep on a.order_dep=dep.id
  1897. where a.delete_sign in(0,2) and a.process_status >0 and a.approval in (0,1,2)
  1898. <if test="province !=null ">
  1899. and dep.province = #{province}
  1900. </if>
  1901. <if test="salesType !=null ">
  1902. and a.sales_type = #{salesType}
  1903. </if>
  1904. <if test=" startDate !=null and endDate != null">
  1905. and a.create_time between #{startDate} and #{endDate}
  1906. </if>
  1907. <if test=" depId !=null">
  1908. and a.order_dep= #{depId}
  1909. </if>
  1910. <if test="orderNo != null">
  1911. and a.order_no like CONCAT('%',#{orderNo,jdbcType=VARCHAR},'%')
  1912. </if>
  1913. <if test="name != null">
  1914. and b.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  1915. </if>
  1916. <if test="contractNo != null">
  1917. and a.contract_no like CONCAT('%',#{contractNo,jdbcType=VARCHAR},'%')
  1918. </if>
  1919. <if test="liquidationStatus != null">
  1920. and a.liquidation_status = #{liquidationStatus,jdbcType=INTEGER}
  1921. </if>
  1922. <if test="approval ==0">
  1923. and a.approval = 0
  1924. </if>
  1925. <if test="approval ==1">
  1926. and a.approval in (1,2)
  1927. </if>
  1928. <if test="amountStatus == 0">
  1929. and a.total_amount &lt; 10
  1930. </if>
  1931. <if test="amountStatus == 1">
  1932. and a.total_amount between 10 and 20
  1933. </if>
  1934. <if test="amountStatus == 2">
  1935. and a.total_amount between 20 and 30
  1936. </if>
  1937. <if test="amountStatus == 3">
  1938. and a.total_amount between 30 and 40
  1939. </if>
  1940. <if test="amountStatus == 4">
  1941. and a.total_amount &gt; 40
  1942. </if>
  1943. order by a.create_time desc
  1944. <if test="page_sql!=null">
  1945. ${page_sql}
  1946. </if>
  1947. </select>
  1948. <select id="selectstatisticsOrderListCount" resultType="integer">
  1949. select count(*)
  1950. from t_order_new a left join `user` b on a.buyer_id=b.id left join t_order_mid c on a.order_no=c.order_no
  1951. left join department dep on a.order_dep=dep.id
  1952. where a.delete_sign in(0,2) and a.process_status >0 and a.approval in (0,1,2)
  1953. <if test="province !=null ">
  1954. and dep.province = #{province}
  1955. </if>
  1956. <if test="salesType !=null ">
  1957. and a.sales_type = #{salesType}
  1958. </if>
  1959. <if test=" startDate !=null and endDate != null">
  1960. and a.create_time between #{startDate} and #{endDate}
  1961. </if>
  1962. <if test=" depId !=null">
  1963. and a.order_dep= #{depId}
  1964. </if>
  1965. <if test="orderNo != null">
  1966. and a.order_no like CONCAT('%',#{orderNo,jdbcType=VARCHAR},'%')
  1967. </if>
  1968. <if test="name != null">
  1969. and b.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  1970. </if>
  1971. <if test="contractNo != null">
  1972. and a.contract_no like CONCAT('%',#{contractNo,jdbcType=VARCHAR},'%')
  1973. </if>
  1974. <if test="liquidationStatus != null">
  1975. and a.liquidation_status = #{liquidationStatus,jdbcType=INTEGER}
  1976. </if>
  1977. <if test="approval ==0">
  1978. and a.approval = 0
  1979. </if>
  1980. <if test="approval ==1">
  1981. and a.approval in (1,2)
  1982. </if>
  1983. <if test="amountStatus == 0">
  1984. and a.total_amount &lt; 10
  1985. </if>
  1986. <if test="amountStatus == 1">
  1987. and a.total_amount between 10 and 20
  1988. </if>
  1989. <if test="amountStatus == 2">
  1990. and a.total_amount between 20 and 30
  1991. </if>
  1992. <if test="amountStatus == 3">
  1993. and a.total_amount between 30 and 40
  1994. </if>
  1995. <if test="amountStatus == 4">
  1996. and a.total_amount &gt; 40
  1997. </if>
  1998. </select>
  1999. <select id="checkOrderProcessStatus" resultMap="BaseResultMap">
  2000. select
  2001. <include refid="Base_Column_List" />
  2002. from t_order_new
  2003. where order_no = (select t_order_task.order_no from t_order_task where id=#{tid})
  2004. </select>
  2005. <select id="selectgetAll" resultType="com.goafanti.common.model.TOrderNew">
  2006. select order_no orderNo,contract_picture_url contractPictureUrl ,agreement_url agreementUrl ,service_content serviceContent
  2007. from t_order_new where delete_sign in (0,2)
  2008. </select>
  2009. <select id="getProcessName" resultType="com.goafanti.order.bo.OrderProcessName">
  2010. select a.order_no orderNo,a.approval,a.process_status processStatus ,b.name yxy,mg.name yxjl,
  2011. yxgly.name yxgly,d.name cwzy,zc.name zc, zxsgly.name zxsgly,dsz.name dsz
  2012. from t_order_new a left join admin b on a.salesman_id =b.id
  2013. left join admin mg on b.manager_id =mg.id
  2014. left join department c on a.order_dep =c.id
  2015. left join (select a.department_id depId,group_concat(a.name) name
  2016. from admin a left join user_role b on a.id=b.uid left join `role` c on b.rid =c.id
  2017. where c.role_type ='9996' and a.status ='0' group by a.department_id )yxgly on c.id =yxgly.depId
  2018. left join admin d on c.finance_id =d.id
  2019. left join (select group_concat(a.name) name
  2020. from admin a left join user_role b on a.id=b.uid left join `role` c on b.rid =c.id
  2021. where c.role_type in ('99998','99988') and a.status ='0' ) zc on 1=1
  2022. left join (select group_concat(a.name) name
  2023. from admin a left join user_role b on a.id=b.uid left join `role` c on b.rid =c.id
  2024. where c.role_type in ('99999','99989') and a.status ='0' ) dsz on 1=1
  2025. left join (select group_concat(a.name) name
  2026. from admin a left join user_role b on a.id=b.uid left join `role` c on b.rid =c.id
  2027. where c.role_type in ('9998') and a.status ='0' ) zxsgly on 1=1
  2028. where a.order_no = #{orderNo}
  2029. </select>
  2030. <select id="selectByuidandAid" resultType="com.goafanti.order.bo.TOrderNewBo">
  2031. select order_no orderNo
  2032. from t_order_new
  2033. where buyer_id=#{uid} and salesman_id=#{aid}
  2034. </select>
  2035. </mapper>