TOrderNewMapper.xml 97 KB

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