TOrderNewMapper.xml 98 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321
  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
  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 where delete_sign in(0,2) and o.approval in(0,1,2,4,5,7,8)
  784. and outsource= #{o.outsource,jdbcType=INTEGER}
  785. <if test="o.processStatus == 3">
  786. and o.process_status = #{o.processStatus,jdbcType=INTEGER}
  787. </if>
  788. <if test="o.processStatus == 4" >
  789. and o.process_status &gt;= #{o.processStatus,jdbcType=INTEGER}
  790. </if>
  791. <if test="o.processStatus == 9">
  792. and o.back_status = 3
  793. </if>
  794. <if test="fids != null and fids.size() &gt; 0">
  795. and (d.finance_id in
  796. <foreach close=")" collection="fids" index="" item="item" open="(" separator=",">
  797. #{item}
  798. </foreach>
  799. or d.retrial_finance_id in
  800. <foreach close=")" collection="fids" index="" item="item" open="(" separator=",">
  801. #{item}
  802. </foreach>)
  803. </if>
  804. <if test="o.orderStatus != null and o.orderStatus != &quot;&quot;">
  805. and (o.order_status >= #{o.orderStatus,jdbcType=INTEGER} or o.back_status=3)
  806. </if>
  807. <if test="deps !=null">
  808. and o.order_dep in
  809. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  810. #{depId}
  811. </foreach>
  812. </if>
  813. <if test="o.contractNo != null and o.contractNo != &quot;&quot;">
  814. and o.contract_no like CONCAT('%',#{o.contractNo,jdbcType=VARCHAR},'%')
  815. </if>
  816. <if test="o.liquidationStatus != null">
  817. and o.liquidation_status = #{o.liquidationStatus,jdbcType=INTEGER}
  818. </if>
  819. <if test="o.amountStatus == 0">
  820. and o.total_amount &lt; 10
  821. </if>
  822. <if test="o.amountStatus == 1">
  823. and o.total_amount between 10 and 20
  824. </if>
  825. <if test="o.amountStatus == 2">
  826. and o.total_amount between 20 and 30
  827. </if>
  828. <if test="o.amountStatus == 3">
  829. and o.total_amount between 30 and 40
  830. </if>
  831. <if test="o.amountStatus == 4">
  832. and o.total_amount &gt; 40
  833. </if>
  834. <if test="o.orderNo != null and o.orderNo != &quot;&quot;">
  835. and o.order_no = #{o.orderNo,jdbcType=VARCHAR}
  836. </if>
  837. <if test="o.projectType != null and o.projectType != &quot;&quot;">
  838. and a.project_type = #{o.projectType}
  839. </if>
  840. <if test="o.approval != null and o.approval ==1">
  841. and o.approval in (1,4,7)
  842. </if>
  843. <if test="o.approval != null and o.approval ==2">
  844. and o.approval in (2,5,8)
  845. </if>
  846. <if test="o.approval != null and o.approval ==4">
  847. and o.approval in (1,2,4,5,7,8)
  848. </if>
  849. <if test="o.buyerName != null and o.buyerName != &quot;&quot;">
  850. <bind name="n" value="'%' + o.buyerName + '%'" />
  851. and u.nickname like #{n,jdbcType=VARCHAR}
  852. </if>
  853. <if test="o.startTime != null and o.startTime != &quot;&quot; and o.endTime != null and o.endTime != &quot;&quot;">
  854. <bind name="a" value="o.startTime + ' 00:00:00'" />
  855. <bind name="b" value="o.endTime + ' 23:59:59'" />
  856. and o.create_time between #{a,jdbcType=VARCHAR} and #{b,jdbcType=VARCHAR}
  857. </if>
  858. <if test="o.startFinalReceivablesTime != null and o.startFinalReceivablesTime != &quot;&quot; and o.endFinalReceivablesTime != null and o.endFinalReceivablesTime != &quot;&quot;">
  859. <bind name="c" value="o.startFinalReceivablesTime + ' 00:00:00'" />
  860. <bind name="d" value="o.endFinalReceivablesTime + ' 23:59:59'" />
  861. and a.final_Receivables_time between #{c,jdbcType=VARCHAR} and #{d,jdbcType=VARCHAR}
  862. </if>
  863. order by o.liquidation_status, o.sign_time desc
  864. <if test="page_sql != null">
  865. ${page_sql}
  866. </if>
  867. </select>
  868. <select id="financeCount" parameterType="Map" resultType="java.lang.Integer">
  869. select count(*) from t_order_new o left join `user` u on o.buyer_id = u.id
  870. left join department d on o.order_dep = d.id left join t_order_mid a on o.order_no=a.order_no
  871. where delete_sign in(0,2) and o.approval in(0,1,2,4,5,7,8) and outsource= #{o.outsource,jdbcType=INTEGER}
  872. <if test="o.processStatus == 3">
  873. and o.process_status = #{o.processStatus,jdbcType=INTEGER}
  874. </if>
  875. <if test="o.processStatus == 4" >
  876. and o.process_status &gt;= #{o.processStatus,jdbcType=INTEGER}
  877. </if>
  878. <if test="o.processStatus == 9">
  879. and o.back_status = 3
  880. </if>
  881. <if test="fids != null and fids.size() &gt; 0">
  882. and (d.finance_id in
  883. <foreach close=")" collection="fids" index="" item="item" open="(" separator=",">
  884. #{item}
  885. </foreach>
  886. or d.retrial_finance_id in
  887. <foreach close=")" collection="fids" index="" item="item" open="(" separator=",">
  888. #{item}
  889. </foreach>)
  890. </if>
  891. <if test="o.orderStatus != null and o.orderStatus != &quot;&quot;">
  892. and (o.order_status >= #{o.orderStatus,jdbcType=INTEGER} or o.back_status=3)
  893. </if>
  894. <if test="deps !=null">
  895. and o.order_dep in
  896. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  897. #{depId}
  898. </foreach>
  899. </if>
  900. <if test="o.contractNo != null and o.contractNo != &quot;&quot;">
  901. and o.contract_no like CONCAT('%',#{o.contractNo,jdbcType=VARCHAR},'%')
  902. </if>
  903. <if test="o.liquidationStatus != null">
  904. and o.liquidation_status = #{o.liquidationStatus,jdbcType=INTEGER}
  905. </if>
  906. <if test="o.amountStatus == 0">
  907. and o.total_amount &lt; 10
  908. </if>
  909. <if test="o.amountStatus == 1">
  910. and o.total_amount between 10 and 20
  911. </if>
  912. <if test="o.amountStatus == 2">
  913. and o.total_amount between 20 and 30
  914. </if>
  915. <if test="o.amountStatus == 3">
  916. and o.total_amount between 30 and 40
  917. </if>
  918. <if test="o.amountStatus == 4">
  919. and o.total_amount &gt; 40
  920. </if>
  921. <if test="o.orderNo != null and o.orderNo != &quot;&quot;">
  922. and o.order_no = #{o.orderNo,jdbcType=VARCHAR}
  923. </if>
  924. <if test="o.projectType != null and o.projectType != &quot;&quot;">
  925. and a.project_type = #{o.projectType}
  926. </if>
  927. <if test="o.approval != null and o.approval ==1">
  928. and o.approval in (1,4,7)
  929. </if>
  930. <if test="o.approval != null and o.approval ==2">
  931. and o.approval in (2,5,8)
  932. </if>
  933. <if test="o.approval != null and o.approval ==4">
  934. and o.approval in (1,2,4,5,7,8)
  935. </if>
  936. <if test="o.buyerName != null and o.buyerName != &quot;&quot;">
  937. <bind name="n" value="'%' + o.buyerName + '%'" />
  938. and u.nickname like #{n,jdbcType=VARCHAR}
  939. </if>
  940. <if test="o.startTime != null and o.startTime != &quot;&quot; and o.endTime != null and o.endTime != &quot;&quot;">
  941. <bind name="a" value="o.startTime + ' 00:00:00'" />
  942. <bind name="b" value="o.endTime + ' 23:59:59'" />
  943. and o.create_time between #{a,jdbcType=VARCHAR} and #{b,jdbcType=VARCHAR}
  944. </if>
  945. <if test="o.startFinalReceivablesTime != null and o.startFinalReceivablesTime != &quot;&quot; and o.endFinalReceivablesTime != null and o.endFinalReceivablesTime != &quot;&quot;">
  946. <bind name="c" value="o.startFinalReceivablesTime + ' 00:00:00'" />
  947. <bind name="d" value="o.endFinalReceivablesTime + ' 23:59:59'" />
  948. and a.final_Receivables_time between #{c,jdbcType=VARCHAR} and #{d,jdbcType=VARCHAR}
  949. </if>
  950. </select>
  951. <!-- 通过订单编号获得订单的负责人(营销员) -->
  952. <select id="getSaleIdByOno" parameterType="java.lang.String" resultType="com.goafanti.order.bo.TOrderNewBo">
  953. select o.order_no orderNo ,o.salesman_id as salesmanId, a.name as salesmanName,e.name managerName,
  954. o.contract_no contractNo,a.email ,u.nickname as userName,o.order_dep orderDep,d.name departmentName,
  955. d.finance_id financeId,d.approval approvalStatus,d.approval_aid approvalAid,ad.name approvalName
  956. 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
  957. left join department d on o.order_dep=d.id left join admin e on a.manager_id=e.id
  958. left join admin ad on d.approval_aid=ad.id
  959. where order_no = #{_parameter,jdbcType=VARCHAR}
  960. </select>
  961. <select id="selectOrderNewListByPage" resultType="com.goafanti.order.bo.TOrderNewBo">
  962. 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,
  963. a.contract_no as contractNo, b.nickname as userName ,a.process_status as processStatus,a.total_amount as totalAmount,a.tag,
  964. a.contract_picture_url contractPictureUrl,
  965. a.order_status as orderStatus, a.liquidation_status as liquidationStatus,a.approval,c.salesman_name as salesmanName,c.project_type projectType,
  966. dep.name as depName,c.finance_name as financeName,c.invoice_amount invoiceAmount,a.settlement_amount settlementAmount,
  967. a.sales_type salesType, a.channel_id channelId ,a.other,a.examine_name examineName,c.stop_project stopProject
  968. <if test="specially == 2">
  969. ,f.name as initiateName ,e.reason ,date_format(e.create_time,'%Y-%m-%d' ) as backDate,e.id as backId
  970. </if>
  971. <if test="specially == 4">
  972. ,e.receiver_name as consultantName,a.settlement_amount as settlementAmount,if(isnull(g.order_no)=0,1,0) ischange
  973. </if>
  974. 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
  975. left join department dep on a.order_dep=dep.id
  976. <if test="specially == 2">
  977. left join (select * from t_order_back a where back_status=0) e on a.order_no=e.order_no
  978. left join admin f on e.initiate=f.id
  979. </if>
  980. <if test="specially == 4">
  981. left join t_order_task e on a.order_no=e.order_no and e.main =1
  982. left join (select order_no from new_order_change group by order_no)g on a.order_no=g.order_no
  983. </if>
  984. <if test="specially == 9">
  985. left join t_order_task tot on a.order_no =tot.order_no
  986. left join business_project bp on tot.commodity_id =bp.id
  987. </if>
  988. <if test="specially == 10">
  989. left join admin mg on a.salesman_id=mg.id
  990. </if>
  991. where a.delete_sign in(0,2)
  992. <if test="specially ==7">
  993. and a.process_status > 4
  994. and a.salesman_id = #{aid,jdbcType=VARCHAR}
  995. </if>
  996. <if test="specially ==8">
  997. and a.process_status > 4
  998. <if test="uid !=null">
  999. and a.buyer_id = #{uid}
  1000. </if>
  1001. </if>
  1002. <if test="specially ==9">
  1003. and a.process_status > 4 and bp.type=5
  1004. <if test="aid !=null">
  1005. and a.salesman_id = #{aid,jdbcType=VARCHAR}
  1006. </if>
  1007. </if>
  1008. <if test="outsource != null">
  1009. and a.outsource= #{outsource,jdbcType=INTEGER}
  1010. </if>
  1011. <if test="specially == 0">
  1012. <if test="approval ==null">
  1013. and a.approval in(0,1,2,4,5,7,8)
  1014. </if>
  1015. and a.order_status in(0,1,2,4)
  1016. and a.salesman_id = #{aid,jdbcType=VARCHAR}
  1017. </if>
  1018. <if test="specially == 10">
  1019. and a.process_status = 1 and a.order_status in (0,1,2)
  1020. and mg.manager_id= #{aid}
  1021. </if>
  1022. <if test="specially == 1">
  1023. and a.process_status = 2 and a.order_status in (0,1,2)
  1024. </if>
  1025. <if test="specially == 2">
  1026. and a.order_status in(3,5)
  1027. and a.salesman_id = #{aid,jdbcType=VARCHAR}
  1028. </if>
  1029. <if test="specially == 3">
  1030. and a.order_status=2
  1031. <if test="manageType ==0">
  1032. and dep.approval_aid= #{aid,jdbcType=VARCHAR}
  1033. </if>
  1034. <if test="approval ==0">
  1035. and a.process_status in(4)
  1036. and a.approval = 0
  1037. </if>
  1038. <if test="approval ==1">
  1039. and a.process_status in(4)
  1040. and a.approval in
  1041. <if test="manageType ==0">
  1042. (1)
  1043. </if>
  1044. <if test="manageType ==1">
  1045. (4)
  1046. </if>
  1047. </if>
  1048. <if test="approval ==2">
  1049. and a.approval in
  1050. <if test="manageType ==0">
  1051. (2,3)
  1052. </if>
  1053. <if test="manageType ==1">
  1054. (5,6)
  1055. </if>
  1056. </if>
  1057. </if>
  1058. <if test="specially !=3 ">
  1059. <if test="approval ==0">
  1060. and a.approval = 0
  1061. </if>
  1062. <if test="approval ==1">
  1063. and a.approval in (1,4,7)
  1064. </if>
  1065. <if test="approval ==2">
  1066. and a.approval in (2,5,8)
  1067. </if>
  1068. <if test="approval ==4">
  1069. and a.approval in (1,2,4,5,7,8)
  1070. </if>
  1071. </if>
  1072. <if test="specially == 4">
  1073. and a.process_status in (3,5,6,7,99)
  1074. and a.order_status in(1,2,3,4,6)
  1075. </if>
  1076. <if test="deps!=null">
  1077. and a.order_dep in
  1078. <foreach close=")" collection="deps" item="dep" open="(" separator=",">
  1079. #{dep}
  1080. </foreach>
  1081. </if>
  1082. <if test="distribution == 0">
  1083. and a.process_status = 3
  1084. </if>
  1085. <if test="distribution == 1">
  1086. and a.process_status = 5
  1087. </if>
  1088. <if test="distribution == 2">
  1089. and a.process_status = 6
  1090. </if>
  1091. <if test="distribution == 3">
  1092. and a.process_status = 7
  1093. </if>
  1094. <if test="name != null">
  1095. and b.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  1096. </if>
  1097. <if test="projectType != null">
  1098. and c.project_type = #{projectType}
  1099. </if>
  1100. <if test="processStatus != null">
  1101. and a.process_status = #{processStatus}
  1102. </if>
  1103. <if test="orderNo != null">
  1104. and a.order_no like CONCAT('%',#{orderNo,jdbcType=VARCHAR},'%')
  1105. </if>
  1106. <if test="contractNo != null">
  1107. and a.contract_no like CONCAT('%',#{contractNo,jdbcType=VARCHAR},'%')
  1108. </if>
  1109. <if test="liquidationStatus != null">
  1110. and a.liquidation_status = #{liquidationStatus,jdbcType=INTEGER}
  1111. </if>
  1112. <if test="tag != null">
  1113. and a.tag= #{tag}
  1114. </if>
  1115. <if test="amountStatus == 0">
  1116. and a.total_amount &lt; 10
  1117. </if>
  1118. <if test="amountStatus == 1">
  1119. and a.total_amount between 10 and 20
  1120. </if>
  1121. <if test="amountStatus == 2">
  1122. and a.total_amount between 20 and 30
  1123. </if>
  1124. <if test="amountStatus == 3">
  1125. and a.total_amount between 30 and 40
  1126. </if>
  1127. <if test="amountStatus == 4">
  1128. and a.total_amount &gt; 40
  1129. </if>
  1130. <if test="starTime !=null and endTime !=null">
  1131. and a.create_time between #{starTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  1132. </if>
  1133. <if test="contractStart !=null and contractEnd !=null">
  1134. and a.sign_time between #{contractStart,jdbcType=VARCHAR} and #{contractEnd,jdbcType=VARCHAR}
  1135. </if>
  1136. order by
  1137. <if test="specially == 3">
  1138. a.approval,
  1139. </if>
  1140. <if test="specially == 4">
  1141. a.process_status,
  1142. </if>
  1143. <if test="specially != 4">
  1144. a.order_status,
  1145. </if>
  1146. a.create_time
  1147. <if test="specially != 4">
  1148. desc
  1149. </if>
  1150. <if test="page_sql!=null">
  1151. ${page_sql}
  1152. </if>
  1153. </select>
  1154. <select id="selectOrderNewListCount" resultType="java.lang.Integer">
  1155. select count(*)
  1156. 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
  1157. left join department dep on a.order_dep=dep.id
  1158. <if test="specially == 9">
  1159. left join t_order_task tot on a.order_no =tot.order_no
  1160. left join business_project bp on tot.commodity_id =bp.id
  1161. </if>
  1162. <if test="specially == 10">
  1163. left join admin mg on a.salesman_id=mg.id
  1164. </if>
  1165. where a.delete_sign in(0,2)
  1166. <if test="specially ==7">
  1167. and a.process_status > 4
  1168. and a.salesman_id = #{aid,jdbcType=VARCHAR}
  1169. </if>
  1170. <if test="specially ==8">
  1171. and a.process_status > 4
  1172. <if test="uid !=null">
  1173. and a.buyer_id = #{uid}
  1174. </if>
  1175. </if>
  1176. <if test="specially ==9">
  1177. and a.process_status > 4 and bp.type=5
  1178. <if test="aid !=null">
  1179. and a.salesman_id = #{aid,jdbcType=VARCHAR}
  1180. </if>
  1181. </if>
  1182. <if test="outsource != null">
  1183. and a.outsource= #{outsource,jdbcType=INTEGER}
  1184. </if>
  1185. <if test="specially == 0">
  1186. <if test="approval ==null">
  1187. and a.approval in(0,1,2,4,5,7,8)
  1188. </if>
  1189. and a.order_status in(0,1,2,4)
  1190. and a.salesman_id = #{aid,jdbcType=VARCHAR}
  1191. </if>
  1192. <if test="specially == 10">
  1193. and a.process_status = 1 and a.order_status in (0,1,2)
  1194. and mg.manager_id= #{aid}
  1195. </if>
  1196. <if test="specially == 1">
  1197. and a.process_status = 2 and a.order_status in (0,1,2)
  1198. </if>
  1199. <if test="specially == 2">
  1200. and a.order_status in(3,5)
  1201. and a.salesman_id = #{aid,jdbcType=VARCHAR}
  1202. </if>
  1203. <if test="specially == 3">
  1204. <if test="manageType ==0">
  1205. and dep.approval_aid= #{aid,jdbcType=VARCHAR}
  1206. </if>
  1207. and a.order_status=2
  1208. <if test="approval ==0">
  1209. and a.process_status in(4)
  1210. and a.approval = 0
  1211. </if>
  1212. <if test="approval ==1">
  1213. and a.process_status in(4)
  1214. and a.approval in
  1215. <if test="manageType ==0">
  1216. (1)
  1217. </if>
  1218. <if test="manageType ==1">
  1219. (4)
  1220. </if>
  1221. </if>
  1222. <if test="approval ==2">
  1223. and a.approval in
  1224. <if test="manageType ==0">
  1225. (2,3)
  1226. </if>
  1227. <if test="manageType ==1">
  1228. (5,6)
  1229. </if>
  1230. </if>
  1231. </if>
  1232. <if test="specially !=3 ">
  1233. <if test="approval ==0">
  1234. and a.approval = 0
  1235. </if>
  1236. <if test="approval ==1">
  1237. and a.approval in (1,4,7)
  1238. </if>
  1239. <if test="approval ==2">
  1240. and a.approval in (2,5,8)
  1241. </if>
  1242. <if test="approval ==4">
  1243. and a.approval in (1,2,4,5,7,8)
  1244. </if>
  1245. </if>
  1246. <if test="specially == 4">
  1247. and a.process_status in (3,5,6,7,99)
  1248. and a.order_status in(1,2,3,4,6)
  1249. </if>
  1250. <if test="deps!=null">
  1251. and a.order_dep in
  1252. <foreach close=")" collection="deps" item="dep" open="(" separator=",">
  1253. #{dep}
  1254. </foreach>
  1255. </if>
  1256. <if test="distribution == 0">
  1257. and a.process_status = 3
  1258. </if>
  1259. <if test="distribution == 1">
  1260. and a.process_status = 5
  1261. </if>
  1262. <if test="distribution == 2">
  1263. and a.process_status = 6
  1264. </if>
  1265. <if test="distribution == 3">
  1266. and a.process_status = 7
  1267. </if>
  1268. <if test="name != null">
  1269. and b.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  1270. </if>
  1271. <if test="projectType != null">
  1272. and c.project_type = #{projectType}
  1273. </if>
  1274. <if test="processStatus != null">
  1275. and a.process_status = #{processStatus}
  1276. </if>
  1277. <if test="orderNo != null">
  1278. and a.order_no like CONCAT('%',#{orderNo,jdbcType=VARCHAR},'%')
  1279. </if>
  1280. <if test="contractNo != null">
  1281. and a.contract_no like CONCAT('%',#{contractNo,jdbcType=VARCHAR},'%')
  1282. </if>
  1283. <if test="liquidationStatus != null">
  1284. and a.liquidation_status = #{liquidationStatus,jdbcType=INTEGER}
  1285. </if>
  1286. <if test="tag != null">
  1287. and a.tag= #{tag}
  1288. </if>
  1289. <if test="amountStatus == 0">
  1290. and a.total_amount &lt; 10
  1291. </if>
  1292. <if test="amountStatus == 1">
  1293. and a.total_amount between 10 and 20
  1294. </if>
  1295. <if test="amountStatus == 2">
  1296. and a.total_amount between 20 and 30
  1297. </if>
  1298. <if test="amountStatus == 3">
  1299. and a.total_amount between 30 and 40
  1300. </if>
  1301. <if test="amountStatus == 4">
  1302. and a.total_amount &gt; 40
  1303. </if>
  1304. <if test="starTime !=null and endTime !=null">
  1305. and a.create_time between #{starTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  1306. </if>
  1307. <if test="contractStart !=null and contractEnd !=null">
  1308. and a.sign_time between #{contractStart,jdbcType=VARCHAR} and #{contractEnd,jdbcType=VARCHAR}
  1309. </if>
  1310. </select>
  1311. <select id="selectDunOrderNewListByPage" resultType="com.goafanti.order.bo.outOrderDunListBo">
  1312. 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,
  1313. b.total_amount as totalAmount,b.liquidation_status as liquidationStatus,b.settlement_amount as settlementAmount,a.money as accountsReceivable,
  1314. if((b.total_amount-b.settlement_amount) &lt; 0,0,(b.total_amount-b.settlement_amount)) as uncollectedAmount,b.order_status as orderStatus,
  1315. date_format(a.start_time, '%Y-%m-%d') as startDate,dep.name as depName,date_format(b.sign_time,'%Y-%m-%d') as signDate,
  1316. b.approval ,b.delete_sign deleteSign ,tm.project_type memberType,
  1317. <if test="newStatus == 0 ">
  1318. a.dun_subject as dunSubject,a.dun_status dunStatus
  1319. from t_order_dun a
  1320. </if>
  1321. <if test="newStatus == 1 ">
  1322. a.project_type projectType,a.status dunStatus, a.dun_type dunType,a.appropriation_ratio appropriationRatio,e.commodity_name commodityName,
  1323. e.set_up_amount setUpAmount,date_format(a.customize_time,'%Y-%m-%d') customizeTimes, a.customize_name customizeName
  1324. from new_order_dun a left join t_order_task e on a.tid=e.id
  1325. </if>
  1326. left join t_order_new b on a.order_no=b.order_no left join `user` c on b.buyer_id=c.id
  1327. left join t_order_mid tm on b.order_no=tm.order_no left join department dep on b.order_dep=dep.id
  1328. where b.delete_sign in (0,2)
  1329. <if test="shiroType == 1 and fid !=null">
  1330. and tm.finance_id= #{fid,jdbcType=VARCHAR}
  1331. </if>
  1332. <if test="shiroType == 2 and fid !=null">
  1333. and tm.finance_id in (select id from admin where superior_id= #{fid,jdbcType=VARCHAR})
  1334. </if>
  1335. <if test="amountStatus == 0">
  1336. and b.total_amount &lt; 10
  1337. </if>
  1338. <if test="amountStatus == 1">
  1339. and b.total_amount between 10 and 20
  1340. </if>
  1341. <if test="amountStatus == 2">
  1342. and b.total_amount between 20 and 30
  1343. </if>
  1344. <if test="amountStatus == 3">
  1345. and b.total_amount between 30 and 40
  1346. </if>
  1347. <if test="amountStatus == 4">
  1348. and b.total_amount &gt; 40
  1349. </if>
  1350. <if test="approval != null and approval &lt; 3">
  1351. and b.approval = #{approval}
  1352. </if>
  1353. <if test="approval != null and approval ==4">
  1354. and b.approval in (1,2)
  1355. </if>
  1356. <if test="memberType !=null">
  1357. and tm.project_type= #{memberType}
  1358. </if>
  1359. <if test="name != null">
  1360. and c.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  1361. </if>
  1362. <if test="adminName != null">
  1363. and tm.salesman_name like CONCAT('%',#{adminName,jdbcType=VARCHAR},'%')
  1364. </if>
  1365. <if test="orderNo != null">
  1366. and a.order_no like CONCAT('%',#{orderNo,jdbcType=VARCHAR},'%')
  1367. </if>
  1368. <if test="contractNo != null">
  1369. and b.contract_no like CONCAT('%',#{contractNo,jdbcType=VARCHAR},'%')
  1370. </if>
  1371. <if test="deps != null">
  1372. and b.order_dep in
  1373. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  1374. #{depId}
  1375. </foreach>
  1376. </if>
  1377. <if test="dunStatus != null">
  1378. and a.status= #{dunStatus}
  1379. </if>
  1380. <if test="aid != null">
  1381. and b.salesman_id= #{aid,jdbcType=VARCHAR}
  1382. </if>
  1383. <if test="starTime !=null and endTime !=null">
  1384. and b.sign_time between #{starTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  1385. </if>
  1386. order by b.sign_time desc,b.create_time desc
  1387. <if test="page_sql!=null">
  1388. ${page_sql}
  1389. </if>
  1390. </select>
  1391. <select id="selectDunOrderNewListCount" resultType="java.lang.Integer">
  1392. select
  1393. count(*)
  1394. <if test="newStatus == 0 ">
  1395. from t_order_dun a
  1396. </if>
  1397. <if test="newStatus == 1 ">
  1398. from new_order_dun a left join t_order_task e on a.tid=e.id
  1399. </if>
  1400. left join t_order_new b on a.order_no=b.order_no left join `user` c on b.buyer_id=c.id
  1401. left join t_order_mid tm on b.order_no=tm.order_no
  1402. where b.delete_sign in (0,2)
  1403. <if test="shiroType == 1 and fid !=null">
  1404. and tm.finance_id= #{fid,jdbcType=VARCHAR}
  1405. </if>
  1406. <if test="shiroType == 2 and fid !=null">
  1407. and tm.finance_id in (select id from admin where superior_id= #{fid,jdbcType=VARCHAR})
  1408. </if>
  1409. <if test="amountStatus == 0">
  1410. and b.total_amount &lt; 10
  1411. </if>
  1412. <if test="amountStatus == 1">
  1413. and b.total_amount between 10 and 20
  1414. </if>
  1415. <if test="amountStatus == 2">
  1416. and b.total_amount between 20 and 30
  1417. </if>
  1418. <if test="amountStatus == 3">
  1419. and b.total_amount between 30 and 40
  1420. </if>
  1421. <if test="amountStatus == 4">
  1422. and b.total_amount &gt; 40
  1423. </if>
  1424. <if test="approval != null and approval &lt; 3">
  1425. and b.approval = #{approval}
  1426. </if>
  1427. <if test="approval != null and approval ==4">
  1428. and b.approval in (1,2)
  1429. </if>
  1430. <if test="memberType !=null">
  1431. and tm.project_type= #{memberType}
  1432. </if>
  1433. <if test="name != null">
  1434. and c.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  1435. </if>
  1436. <if test="adminName != null">
  1437. and salesman_name like CONCAT('%',#{adminName,jdbcType=VARCHAR},'%')
  1438. </if>
  1439. <if test="orderNo != null">
  1440. and a.order_no like CONCAT('%',#{orderNo,jdbcType=VARCHAR},'%')
  1441. </if>
  1442. <if test="contractNo != null">
  1443. and b.contract_no like CONCAT('%',#{contractNo,jdbcType=VARCHAR},'%')
  1444. </if>
  1445. <if test="deps != null">
  1446. and b.order_dep in
  1447. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  1448. #{depId}
  1449. </foreach>
  1450. </if>
  1451. <if test="dunStatus != null">
  1452. and a.status= #{dunStatus}
  1453. </if>
  1454. <if test="aid != null">
  1455. and b.salesman_id= #{aid,jdbcType=VARCHAR}
  1456. </if>
  1457. <if test="starTime !=null and endTime !=null">
  1458. and b.sign_time between #{starTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  1459. </if>
  1460. </select>
  1461. <select id="getOrderNewDetail" parameterType="java.lang.String" resultType="com.goafanti.order.bo.TOrderNewBo">
  1462. select
  1463. 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,
  1464. a.first_amount as firstAmount,a.total_amount as totalAmount, a.settlement_amount as settlementAmount, order_status as orderStatus,a.user_type userType,
  1465. a.liquidation_status as liquidationStatus, a.process_status as processStatus, a.project_status as projectStatus, a.approval,a.sales_type salesType,
  1466. a.order_remarks as orderRemarks, a.delete_sign as deleteSign, a.salesman_id as salesmanId, a.finance_id as financeId, technician_id as technicianId,
  1467. 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,
  1468. 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,
  1469. a.proof_aid as proofAid,contract_picture_url as contractPictureUrl, c.name as salesmanName,dep.name as depName,d.name as financeName,
  1470. 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,
  1471. 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,
  1472. g.location_city as locationCity,g.location_area locationArea,g.postal_address postalAddress,outsource,a.primary_order primaryOrder,a.agreement_url agreementUrl,
  1473. h.name NowFinance,h.contact_mobile NowFinanceMobile,a.additional_order additionalOrder,i.name as oldSalesmanName, i.contact_mobile oldSalesmanMobile,
  1474. a.service_content serviceContent,a.examine_name examineName, tht.knowledge_services knowledgeServices, tht.audit_services auditServices,c.manager_id managerId,
  1475. tht.add_deduction_services addDeductionServices, tht.knowledge_other knowledgeOther, tht.audit_other auditOther, tht.add_deduction_other addDeductionOther
  1476. 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
  1477. left join admin c on a.salesman_id=c.id left join department dep on a.order_dep=dep.id
  1478. left join admin d on a.finance_id=d.id left join admin h on dep.finance_id=h.id
  1479. left join t_order_back e on a.order_no=e.order_no and e.back_status=0
  1480. left join admin f on e.initiate=f.id left join organization_identity g on a.buyer_id=g.uid
  1481. left join t_order_high_tech tht on a.order_no=tht.order_no
  1482. where a.order_no = #{orderNo,jdbcType=VARCHAR}
  1483. </select>
  1484. <select id="selectOrderRefundListByPage" resultType="com.goafanti.order.bo.TOrderRefundBo">
  1485. select a.id, date_format(a.create_time,'%Y-%m-%d') as createDate,a.order_no as orderNo,
  1486. c.nickname as userName,b.order_status as orderStatus,a.refund_status as refundStatus,
  1487. a.reason,b.liquidation_status as liquidationStatus
  1488. from t_order_refund a left join t_order_new b on a.order_no=b.order_no
  1489. left join `user` c on b.buyer_id=c.id
  1490. where b.delete_sign in(0,2,3)
  1491. <if test="name != null">
  1492. and c.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  1493. </if>
  1494. <if test="aid != null">
  1495. and a.initiate = #{aid,jdbcType=VARCHAR}
  1496. </if>
  1497. <if test="orderNo != null">
  1498. and a.order_no = #{orderNo,jdbcType=VARCHAR}
  1499. </if>
  1500. <if test="starTime !=null and endTime !=null">
  1501. and a.create_time between #{starTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  1502. </if>
  1503. order by a.create_time desc
  1504. <if test="page_sql!=null">
  1505. ${page_sql}
  1506. </if>
  1507. </select>
  1508. <select id="selectOrderRefundListCount" resultType="java.lang.Integer">
  1509. select
  1510. count(*)
  1511. from t_order_refund a left join t_order_new b on a.order_no=b.order_no
  1512. left join `user` c on b.buyer_id=c.id
  1513. where b.delete_sign in(0,2,3)
  1514. <if test="name != null">
  1515. and c.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  1516. </if>
  1517. <if test="aid != null">
  1518. and a.initiate = #{aid,jdbcType=VARCHAR}
  1519. </if>
  1520. <if test="orderNo != null">
  1521. and a.order_no = #{orderNo,jdbcType=VARCHAR}
  1522. </if>
  1523. <if test="starTime !=null and endTime !=null">
  1524. and a.create_time between #{starTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  1525. </if>
  1526. </select>
  1527. <!-- 财务同意退款邮件通知需要的数据 -->
  1528. <select id="agreeEmailData" parameterType="java.lang.Integer" resultType="com.goafanti.order.bo.TOrderNewBo">
  1529. 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,
  1530. concat(a.email,"," , ifnull(t.email,"")) as email , concat(a.name,"," , ifnull(t.name,"")) as salesmanName
  1531. from t_order_refund r
  1532. left join t_order_new o on r.order_no = o.order_no
  1533. left join admin a on a.id = o.salesman_id
  1534. left join admin t on t.id = o.technician_id
  1535. left join `user` u on u.id = o.buyer_id
  1536. where r.id = #{id,jdbcType=INTEGER}
  1537. </select>
  1538. <select id="orderRefundDetail" resultType="com.goafanti.order.bo.OrderRefundDetailBo">
  1539. select a.id,date_format(a.create_time,'%Y-%m-%d') as createDate ,a.order_no as orderNo,
  1540. b.order_status as orderStatus,a.refund_status as refundStatus, a.application_url as applicationUrl,
  1541. a.contract_url as contractUrl,a.reason,b.liquidation_status as liquidationStatus
  1542. from t_order_refund a
  1543. left join t_order_new b on a.order_no=b.order_no
  1544. where a.id= #{id,jdbcType=INTEGER}
  1545. </select>
  1546. <update id="updateFinance" parameterType="string">
  1547. update t_order_new set finance_id= #{newFinance,jdbcType=VARCHAR}
  1548. where order_no in
  1549. <foreach close=")" collection="orderNos" item="orderNo" open="(" separator=",">
  1550. #{orderNo}
  1551. </foreach>
  1552. and finance_id= #{aid,jdbcType=VARCHAR}
  1553. </update>
  1554. <select id="checkContractNo" resultType="java.lang.Integer">
  1555. select count(contract_no) from t_order_new
  1556. where contract_no= #{0}
  1557. </select>
  1558. <select id="countTotalAndActually" parameterType="Map" resultType="java.util.Map">
  1559. select IFNULL( sum(o.settlement_amount),0) actuallyTotalAmount,IFNULL(sum(o.total_amount),0) signTotalAmount
  1560. from t_order_new o
  1561. 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
  1562. 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}
  1563. <if test="o.processStatus == 3">
  1564. and o.process_status = #{o.processStatus,jdbcType=INTEGER}
  1565. </if>
  1566. <if test="o.processStatus == 4">
  1567. and o.process_status &gt;= #{o.processStatus,jdbcType=INTEGER}
  1568. </if>
  1569. <if test="o.processStatus == 9">
  1570. and o.back_status = 3
  1571. </if>
  1572. <if test="fids != null and fids.size() &gt; 0">
  1573. and (d.finance_id in
  1574. <foreach close=")" collection="fids" index="" item="item" open="(" separator=",">
  1575. #{item}
  1576. </foreach>
  1577. or d.retrial_finance_id in
  1578. <foreach close=")" collection="fids" index="" item="item" open="(" separator=",">
  1579. #{item}
  1580. </foreach>)
  1581. </if>
  1582. <if test="o.orderStatus != null and o.orderStatus != &quot;&quot;">
  1583. and (o.order_status >= #{o.orderStatus,jdbcType=INTEGER} or o.back_status=3)
  1584. </if>
  1585. <if test="deps !=null">
  1586. and o.order_dep in
  1587. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  1588. #{depId}
  1589. </foreach>
  1590. </if>
  1591. <if test="o.contractNo != null and o.contractNo != &quot;&quot;">
  1592. and o.contract_no like CONCAT('%',#{o.contractNo,jdbcType=VARCHAR},'%')
  1593. </if>
  1594. <if test="o.liquidationStatus != null">
  1595. and o.liquidation_status = #{o.liquidationStatus,jdbcType=INTEGER}
  1596. </if>
  1597. <if test="o.amountStatus == 0">
  1598. and o.total_amount &lt; 10
  1599. </if>
  1600. <if test="o.amountStatus == 1">
  1601. and o.total_amount between 10 and 20
  1602. </if>
  1603. <if test="o.amountStatus == 2">
  1604. and o.total_amount between 20 and 30
  1605. </if>
  1606. <if test="o.amountStatus == 3">
  1607. and o.total_amount between 30 and 40
  1608. </if>
  1609. <if test="o.amountStatus == 4">
  1610. and o.total_amount &gt; 40
  1611. </if>
  1612. <if test="o.orderNo != null and o.orderNo != &quot;&quot;">
  1613. and o.order_no = #{o.orderNo,jdbcType=VARCHAR}
  1614. </if>
  1615. <if test="o.projectType != null and o.projectType != &quot;&quot;">
  1616. and a.project_type = #{o.projectType}
  1617. </if>
  1618. <if test="o.approval != null and o.approval ==1">
  1619. and o.approval in (1,4,7)
  1620. </if>
  1621. <if test="o.approval != null and o.approval ==2">
  1622. and o.approval in (2,5,8)
  1623. </if>
  1624. <if test="o.approval != null and o.approval ==4">
  1625. and o.approval in (1,2,4,5,7,8)
  1626. </if>
  1627. <if test="o.buyerName != null and o.buyerName != &quot;&quot;">
  1628. <bind name="n" value="'%' + o.buyerName + '%'" />
  1629. and u.nickname like #{n,jdbcType=VARCHAR}
  1630. </if>
  1631. <if test="o.startTime != null and o.startTime != &quot;&quot; and o.endTime != null and o.endTime != &quot;&quot;">
  1632. <bind name="a" value="o.startTime + ' 00:00:00'" />
  1633. <bind name="b" value="o.endTime + ' 23:59:59'" />
  1634. and o.create_time between #{a,jdbcType=VARCHAR} and #{b,jdbcType=VARCHAR}
  1635. </if>
  1636. <if test="o.startFinalReceivablesTime != null and o.startFinalReceivablesTime != &quot;&quot; and o.endFinalReceivablesTime != null and o.endFinalReceivablesTime != &quot;&quot;">
  1637. <bind name="c" value="o.startFinalReceivablesTime + ' 00:00:00'" />
  1638. <bind name="d" value="o.endFinalReceivablesTime + ' 23:59:59'" />
  1639. and a.final_Receivables_time between #{c,jdbcType=VARCHAR} and #{d,jdbcType=VARCHAR}
  1640. </if>
  1641. </select>
  1642. <select id="getLastPayment" resultType="com.goafanti.common.model.TOrderBillNew">
  1643. select date_format(create_time, '%Y-%m-%d %H:%i:%s') createTimes,transaction_amount transactionAmount from t_order_bill_new
  1644. where order_no= #{orderNo}
  1645. order by create_time desc limit 1;
  1646. </select>
  1647. <update id="updateSalesmanId">
  1648. update t_order_new set salesman_id= #{transferId},old_salesman_id= #{aid}
  1649. where delete_sign in(0,2,3) and salesman_id= #{aid}
  1650. </update>
  1651. <select id="selectUsedOrderByOrder" resultType="com.goafanti.order.bo.TOrderNewBo">
  1652. select
  1653. 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,
  1654. a.first_amount as firstAmount,a.total_amount as totalAmount, a.settlement_amount as settlementAmount, order_status as orderStatus,
  1655. a.liquidation_status as liquidationStatus, a.process_status as processStatus, a.project_status as projectStatus, a.approval,
  1656. a.order_remarks as orderRemarks, a.delete_sign as deleteSign, a.salesman_id as salesmanId, a.finance_id as financeId, technician_id as technicianId,
  1657. a.sign_time as signTime, a.settlement_time as settlementTime, a.contract_no as contractNo, a.contract_type as contractType, a.contacts,
  1658. a.contact_mobile as contactMobile, a.legal_person as legalPerson, a.legal_person_tel as legalPersonTel, a.proof_count as proofCount,
  1659. a.proof_aid as proofAid,contract_picture_url as contractPictureUrl, c.name as salesmanName,dep.name as depName,d.name as financeName,
  1660. c.contact_mobile as salesmanMobile,d.contact_mobile as financeMobile,b.nickname as userName ,e.back_status as backStatus,f.name as initiateName,
  1661. 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,
  1662. g.location_city as locationCity,g.location_area locationArea,g.postal_address postalAddress,outsource,a.primary_order primaryOrder,
  1663. h.name NowFinance,h.contact_mobile NowFinanceMobile,a.additional_order additionalOrder,i.name as oldSalesmanName, i.contact_mobile oldSalesmanMobile
  1664. 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
  1665. 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
  1666. 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
  1667. left join admin f on e.initiate=f.id left join organization_identity g on a.buyer_id=g.uid
  1668. where noc.order_no= #{orderNo} order by noc.create_time
  1669. </select>
  1670. <update id="updaterefund" parameterType="com.goafanti.common.model.TOrderNew">
  1671. update t_order_new set settlement_amount=settlement_amount-#{refundAmount,jdbcType=DECIMAL},
  1672. refund_amount=#{refundAmount,jdbcType=DECIMAL} where order_no=#{orderNo}
  1673. </update>
  1674. <update id="updateDepExamine">
  1675. update t_order_new a ,(select a.department_id depId,group_concat(a.name) name
  1676. from admin a left join user_role b on a.id=b.uid
  1677. left join `role` c on b.rid =c.id
  1678. where c.role_type ='9996' and a.status ='0' and a.department_id = #{departmentId}
  1679. group by a.department_id ) b
  1680. set a.examine_name =b.name
  1681. where a.order_dep = #{departmentId} and a.order_dep =b.depId
  1682. </update>
  1683. <update id="updateExamineById">
  1684. update t_order_new a
  1685. <if test="type==0 or type==1">
  1686. left join admin b on a.salesman_id =b.id
  1687. left join admin c on b.manager_id =c.id
  1688. set a.examine_name =c.name
  1689. where a.process_status =1 and c.id= #{id}
  1690. </if>
  1691. <if test="type==2">
  1692. left join (select a.department_id depId,group_concat(a.name) name
  1693. from admin a left join admin b on a.department_id =b.department_id
  1694. left join user_role c on a.id=c.uid left join `role` d on c.rid =d.id
  1695. where b.id= #{id} and d.role_type ='9996'
  1696. and a.status ='0' group by b.department_id )x on a.order_dep=x.depId
  1697. set a.examine_name=x.name
  1698. where a.process_status =2
  1699. </if>
  1700. <if test="type==3">
  1701. left join department b on a.order_dep =b.id
  1702. left join admin c on b.finance_id =c.id
  1703. set a.examine_name =c.name
  1704. where a.process_status =3 and c.id =#{id}
  1705. </if>
  1706. <if test="type==5">
  1707. update t_order_new a left join (select group_concat(a.name) name
  1708. from admin a left join user_role b on a.id=b.uid
  1709. left join `role` c on b.rid =c.id
  1710. where c.role_type in ('9998') and a.status ='0' )b on 1=1
  1711. set a.examine_name =b.name
  1712. where a.process_status =5
  1713. </if>
  1714. </update>
  1715. <select id="selectArrearsDunListByPage" resultType="com.goafanti.order.bo.OutArrearsDunListBo">
  1716. select a.id, b.contract_no contractNo,a.order_no as orderNo,c.nickname as userName,tm.salesman_name as salesmanName,
  1717. b.project_status projectStatus, b.total_amount as totalAmount,b.liquidation_status as liquidationStatus,a.`type`,
  1718. b.settlement_amount as settlementAmount, a.order_receivables orderReceivables,a.order_arrears as orderArrears,
  1719. b.order_status as orderStatus, date_format(a.start_time, '%Y-%m-%d %H:%i:%s') as startDate,dep.name as depName,
  1720. date_format(b.sign_time,'%Y-%m-%d') as signDate,a.dun_status dunStatus,x.commodity_name commodityName
  1721. from t_arrears_dun a
  1722. left join (select order_no ,commodity_name from t_order_task where main =1)x on a.order_no =x.order_no
  1723. left join t_order_new b on a.order_no=b.order_no left join `user` c on b.buyer_id=c.id
  1724. left join t_order_mid tm on b.order_no=tm.order_no left join department dep on b.order_dep=dep.id
  1725. where b.delete_sign in(0,2,3) and dun_status in (1,2,3)
  1726. <if test="shiroType == 1 and fid !=null">
  1727. and tm.finance_id= #{fid,jdbcType=VARCHAR}
  1728. </if>
  1729. <if test="shiroType == 2 and fid !=null">
  1730. and tm.finance_id in (select id from admin where superior_id= #{fid,jdbcType=VARCHAR})
  1731. </if>
  1732. <if test="name != null">
  1733. and c.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  1734. </if>
  1735. <if test="adminName != null">
  1736. and tm.salesman_name like CONCAT('%',#{adminName,jdbcType=VARCHAR},'%')
  1737. </if>
  1738. <if test="orderNo != null">
  1739. and a.order_no like CONCAT('%',#{orderNo,jdbcType=VARCHAR},'%')
  1740. </if>
  1741. <if test="contractNo != null">
  1742. and b.contract_no like CONCAT('%',#{contractNo,jdbcType=VARCHAR},'%')
  1743. </if>
  1744. <if test="deps != null">
  1745. and b.order_dep in
  1746. <foreach close=")" collection="deps" item="dep" open="(" separator=",">
  1747. #{dep}
  1748. </foreach>
  1749. </if>
  1750. <if test="shiroType !=3 and aid != null">
  1751. and b.salesman_id= #{aid,jdbcType=VARCHAR}
  1752. </if>
  1753. <if test="starTime !=null and endTime !=null">
  1754. and b.sign_time between #{starTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  1755. </if>
  1756. <if test="tStarTime !=null and tEndTime !=null">
  1757. and a.start_time between #{tStarTime,jdbcType=VARCHAR} and #{tEndTime,jdbcType=VARCHAR}
  1758. </if>
  1759. order by dun_status,a.start_time desc
  1760. <if test="page_sql!=null">
  1761. ${page_sql}
  1762. </if>
  1763. </select>
  1764. <select id="selectArrearsDunListByCount" resultType="java.lang.Integer">
  1765. select count(*) from t_arrears_dun a
  1766. left join t_order_new b on a.order_no=b.order_no left join `user` c on b.buyer_id=c.id
  1767. left join t_order_mid tm on b.order_no=tm.order_no left join department dep on b.order_dep=dep.id
  1768. where b.delete_sign in(0,2,3) and dun_status in (1,2,3)
  1769. <if test="shiroType == 1 and fid !=null">
  1770. and tm.finance_id= #{fid,jdbcType=VARCHAR}
  1771. </if>
  1772. <if test="shiroType == 2 and fid !=null">
  1773. and tm.finance_id in (select id from admin where superior_id= #{fid,jdbcType=VARCHAR})
  1774. </if>
  1775. <if test="shiroType !=3 and aid != null">
  1776. and b.salesman_id= #{aid,jdbcType=VARCHAR}
  1777. </if>
  1778. <if test="name != null">
  1779. and c.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  1780. </if>
  1781. <if test="adminName != null">
  1782. and tm.salesman_name like CONCAT('%',#{adminName,jdbcType=VARCHAR},'%')
  1783. </if>
  1784. <if test="orderNo != null">
  1785. and a.order_no like CONCAT('%',#{orderNo,jdbcType=VARCHAR},'%')
  1786. </if>
  1787. <if test="deps != null">
  1788. and b.order_dep in
  1789. <foreach close=")" collection="deps" item="dep" open="(" separator=",">
  1790. #{dep}
  1791. </foreach>
  1792. </if>
  1793. <if test="shiroType !=3 and aid != null">
  1794. and b.salesman_id= #{aid,jdbcType=VARCHAR}
  1795. </if>
  1796. <if test="starTime !=null and endTime !=null">
  1797. and b.sign_time between #{starTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
  1798. </if>
  1799. <if test="tStarTime !=null and tEndTime !=null">
  1800. and a.start_time between #{tStarTime,jdbcType=VARCHAR} and #{tEndTime,jdbcType=VARCHAR}
  1801. </if>
  1802. </select>
  1803. <select id="selectByUidAndNewUser" resultType="java.math.BigDecimal">
  1804. select total_amount from t_order_new
  1805. where process_status >4 and buyer_id = #{uid}
  1806. and salesman_id =#{aid}
  1807. and new_user = #{newUser}
  1808. and create_time between #{date} and #{now}
  1809. </select>
  1810. <select id="statisticsList" resultType="com.goafanti.order.bo.OutStatisticsList">
  1811. select z.id,z.province,z.counts,z.quantity,z.total
  1812. from (select y.id,y.province,count(aid)counts,sum(quantity)quantity,sum(total)total
  1813. from (select x.id,x.province,x.aid,sum(quantity)quantity, sum(x.total)total
  1814. from (select d.id,d.name province,a.order_no,a.salesman_id aid,
  1815. if(a.total_amount>0.5,1,if(a.total_amount>0 and a.order_type=1,0.5,0))quantity,
  1816. a.total_amount total
  1817. from t_order_new a left join admin b on a.salesman_id =b.id
  1818. left join department c on b.department_id =c.id left join district_glossory d on c.province =d.id
  1819. where a.process_status >4 and a.delete_sign in(0,2)
  1820. <if test="depId !=null">
  1821. and b.department_id = #{depId}
  1822. </if>
  1823. <if test="province !=null">
  1824. and c.province = #{province}
  1825. </if>
  1826. <if test="startCreate !=null and endCreate !=null">
  1827. and a.create_time between #{startCreate} and #{endCreate}
  1828. </if>
  1829. <if test="startSign !=null and endSign !=null">
  1830. and a.sign_time between #{startSign} and #{endSign}
  1831. </if>
  1832. )x group by x.id,x.province,x.aid)y group by y.id,y.province)z
  1833. order by
  1834. <if test="sort ==0">
  1835. total
  1836. </if>
  1837. <if test="sort ==1">
  1838. quantity
  1839. </if>
  1840. <if test="sort ==2">
  1841. counts
  1842. </if>
  1843. desc
  1844. </select>
  1845. <select id="provinceStatisticsList" resultType="com.goafanti.order.bo.OutProvinceStatisticsList">
  1846. select z.depName,z.aid,z.name,z.quantity,z.total
  1847. from ( select x.depName,x.aid,x.name,sum(quantity)quantity,sum(total)total
  1848. from ( select c.name depName,a.order_no,b.id aid,b.name name,
  1849. if(a.total_amount>0.5,1,if(a.total_amount>0 and a.order_type=1,0.5,0))quantity,
  1850. a.total_amount total
  1851. from t_order_new a left join admin b on a.salesman_id =b.id
  1852. left join department c on b.department_id =c.id left join district_glossory d on c.province =d.id
  1853. where a.process_status >4 and a.delete_sign in(0,2)
  1854. <if test="depId !=null">
  1855. and b.department_id = #{depId}
  1856. </if>
  1857. <if test="province !=null">
  1858. and c.province = #{province}
  1859. </if>
  1860. <if test="startCreate !=null and endCreate !=null">
  1861. and a.create_time between #{startCreate} and #{endCreate}
  1862. </if>
  1863. <if test="startSign !=null and endSign !=null">
  1864. and a.sign_time between #{startSign} and #{endSign}
  1865. </if>
  1866. )x group by x.depName,x.aid,x.name )z order by
  1867. <if test="sort ==0">
  1868. total
  1869. </if>
  1870. <if test="sort ==1">
  1871. quantity
  1872. </if>
  1873. desc
  1874. </select>
  1875. <select id="selectOrderByuid" resultType="java.util.Map">
  1876. select order_no orderNo,contract_no contractNo
  1877. from t_order_new where delete_sign in (0,2) and buyer_id = #{uid}
  1878. order by create_time desc
  1879. </select>
  1880. <select id="orderSalesSourceAmount" resultType="com.goafanti.order.bo.outStatistics.OutOrderSalesSourceAmount">
  1881. select y.province,dg.name ,y.total_amount totalAmount,y.counts,y.dhxkf,
  1882. y.dhxkf/y.total_amount dhxkfl, y.dhzdzy,y.dhzdzy/y.total_amount dhzdzyl,y.wl,y.wl/y.total_amount wll,
  1883. y.qd,y.qd/y.total_amount qdl,y.zjs,y.zjs/y.total_amount zjsl,y.qt,y.qt/y.total_amount qtl,
  1884. y.gxfg,y.gxfg/y.total_amount gxfgl,y.qtfg,y.qtfg/y.total_amount qtfgl
  1885. from (select x.province,sum(x.total_amount)total_amount,sum(x.counts)counts,
  1886. sum(x.dhxkf)dhxkf,sum(x.dhzdzy)dhzdzy,sum(x.wl)wl,sum(x.qd)qd, sum(x.zjs)zjs, sum(x.qt)qt,
  1887. sum(x.gxfg)gxfg, sum(x.qtfg)qtfg
  1888. from ( select b.province ,1 counts,a.total_amount,a.sales_type ,
  1889. case a.sales_type when 0 then a.total_amount else 0 end dhxkf,
  1890. case a.sales_type when 1 then a.total_amount else 0 end dhzdzy,
  1891. case a.sales_type when 2 then a.total_amount else 0 end wl,
  1892. case a.sales_type when 3 then a.total_amount else 0 end qd,
  1893. case a.sales_type when 4 then a.total_amount else 0 end zjs,
  1894. case a.sales_type when 5 then a.total_amount else 0 end qt,
  1895. case a.sales_type when 6 then a.total_amount else 0 end gxfg,
  1896. case a.sales_type when 7 then a.total_amount else 0 end qtfg
  1897. from t_order_new a left join department b on a.order_dep =b.id
  1898. where a.delete_sign in (0,2) and a.process_status &gt; 0 and a.approval in (0,1,2)
  1899. <if test=" startDate !=null and endDate != null">
  1900. and a.create_time between #{startDate} and #{endDate}
  1901. </if>
  1902. <if test=" deps !=null">
  1903. and a.order_dep in
  1904. <foreach close=")" collection="listDep" item="depId" open="(" separator=",">
  1905. #{depId}
  1906. </foreach>
  1907. </if>
  1908. <if test=" province !=null">
  1909. and b.province = #{province}
  1910. </if>
  1911. )x group by x.province)y left join district_glossory dg on y.province=dg.id
  1912. order by y.total_amount desc
  1913. </select>
  1914. <select id="orderSalesSource" resultType="com.goafanti.order.bo.OutOrderSalesSource">
  1915. select y.province,dg.name ,y.total_amount totalAmount,y.counts,y.dhxkf,y.dhxkf/y.counts dhxkfl,
  1916. y.dhzdzy,y.dhzdzy/y.counts dhzdzyl,y.wl,y.wl/y.counts wll,
  1917. y.qd,y.qd/y.counts qdl,y.zjs,y.zjs/y.counts zjsl,y.qt,y.qt/y.counts qtl,
  1918. y.gxfg,y.gxfg/y.counts gxfgl,y.qtfg,y.qtfg/y.counts qtfgl
  1919. from (select x.province,sum(x.total_amount)total_amount,sum(x.counts)counts,
  1920. sum(x.dhxkf)dhxkf,sum(x.dhzdzy)dhzdzy,sum(x.wl)wl,sum(x.qd)qd, sum(x.zjs)zjs, sum(x.qt)qt,
  1921. sum(x.gxfg)gxfg, sum(x.qtfg)qtfg
  1922. from ( select b.province ,1 counts,a.total_amount,a.sales_type ,
  1923. case a.sales_type when 0 then 1 else 0 end dhxkf,
  1924. case a.sales_type when 1 then 1 else 0 end dhzdzy,
  1925. case a.sales_type when 2 then 1 else 0 end wl,
  1926. case a.sales_type when 3 then 1 else 0 end qd,
  1927. case a.sales_type when 4 then 1 else 0 end zjs,
  1928. case a.sales_type when 5 then 1 else 0 end qt,
  1929. case a.sales_type when 6 then 1 else 0 end gxfg,
  1930. case a.sales_type when 7 then 1 else 0 end qtfg
  1931. from t_order_new a left join department b on a.order_dep =b.id
  1932. where a.delete_sign in (0,2) and a.process_status &gt; 0 and a.approval in (0,1,2)
  1933. <if test=" startDate !=null and endDate != null">
  1934. and a.create_time between #{startDate} and #{endDate}
  1935. </if>
  1936. <if test=" deps !=null">
  1937. and a.order_dep in
  1938. <foreach close=")" collection="listDep" item="depId" open="(" separator=",">
  1939. #{depId}
  1940. </foreach>
  1941. </if>
  1942. <if test=" province !=null">
  1943. and b.province = #{province}
  1944. </if>
  1945. )x group by x.province)y left join district_glossory dg on y.province=dg.id
  1946. order by y.counts desc
  1947. </select>
  1948. <select id="selectstatisticsOrderListPage" resultType="com.goafanti.order.bo.TOrderNewBo">
  1949. 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,
  1950. a.contract_no as contractNo, b.nickname as userName ,a.process_status as processStatus,a.total_amount as totalAmount,
  1951. a.order_status as orderStatus, a.liquidation_status as liquidationStatus,a.approval,c.salesman_name as salesmanName,c.project_type projectType,
  1952. dep.name as depName,c.finance_name as financeName,c.invoice_amount invoiceAmount,a.settlement_amount settlementAmount,
  1953. a.sales_type salesType, a.channel_id channelId ,a.other
  1954. 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
  1955. left join department dep on a.order_dep=dep.id
  1956. where a.delete_sign in(0,2) and a.process_status >0 and a.approval in (0,1,2)
  1957. <if test="province !=null ">
  1958. and dep.province = #{province}
  1959. </if>
  1960. <if test="salesType !=null ">
  1961. and a.sales_type = #{salesType}
  1962. </if>
  1963. <if test=" startDate !=null and endDate != null">
  1964. and a.create_time between #{startDate} and #{endDate}
  1965. </if>
  1966. <if test=" depId !=null">
  1967. and a.order_dep= #{depId}
  1968. </if>
  1969. <if test="orderNo != null">
  1970. and a.order_no like CONCAT('%',#{orderNo,jdbcType=VARCHAR},'%')
  1971. </if>
  1972. <if test="name != null">
  1973. and b.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  1974. </if>
  1975. <if test="contractNo != null">
  1976. and a.contract_no like CONCAT('%',#{contractNo,jdbcType=VARCHAR},'%')
  1977. </if>
  1978. <if test="liquidationStatus != null">
  1979. and a.liquidation_status = #{liquidationStatus,jdbcType=INTEGER}
  1980. </if>
  1981. <if test="approval ==0">
  1982. and a.approval = 0
  1983. </if>
  1984. <if test="approval ==1">
  1985. and a.approval in (1,2)
  1986. </if>
  1987. <if test="amountStatus == 0">
  1988. and a.total_amount &lt; 10
  1989. </if>
  1990. <if test="amountStatus == 1">
  1991. and a.total_amount between 10 and 20
  1992. </if>
  1993. <if test="amountStatus == 2">
  1994. and a.total_amount between 20 and 30
  1995. </if>
  1996. <if test="amountStatus == 3">
  1997. and a.total_amount between 30 and 40
  1998. </if>
  1999. <if test="amountStatus == 4">
  2000. and a.total_amount &gt; 40
  2001. </if>
  2002. order by a.create_time desc
  2003. <if test="page_sql!=null">
  2004. ${page_sql}
  2005. </if>
  2006. </select>
  2007. <select id="selectstatisticsOrderListCount" resultType="integer">
  2008. select count(*)
  2009. 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
  2010. left join department dep on a.order_dep=dep.id
  2011. where a.delete_sign in(0,2) and a.process_status >0 and a.approval in (0,1,2)
  2012. <if test="province !=null ">
  2013. and dep.province = #{province}
  2014. </if>
  2015. <if test="salesType !=null ">
  2016. and a.sales_type = #{salesType}
  2017. </if>
  2018. <if test=" startDate !=null and endDate != null">
  2019. and a.create_time between #{startDate} and #{endDate}
  2020. </if>
  2021. <if test=" depId !=null">
  2022. and a.order_dep= #{depId}
  2023. </if>
  2024. <if test="orderNo != null">
  2025. and a.order_no like CONCAT('%',#{orderNo,jdbcType=VARCHAR},'%')
  2026. </if>
  2027. <if test="name != null">
  2028. and b.nickname like CONCAT('%',#{name,jdbcType=VARCHAR},'%')
  2029. </if>
  2030. <if test="contractNo != null">
  2031. and a.contract_no like CONCAT('%',#{contractNo,jdbcType=VARCHAR},'%')
  2032. </if>
  2033. <if test="liquidationStatus != null">
  2034. and a.liquidation_status = #{liquidationStatus,jdbcType=INTEGER}
  2035. </if>
  2036. <if test="approval ==0">
  2037. and a.approval = 0
  2038. </if>
  2039. <if test="approval ==1">
  2040. and a.approval in (1,2)
  2041. </if>
  2042. <if test="amountStatus == 0">
  2043. and a.total_amount &lt; 10
  2044. </if>
  2045. <if test="amountStatus == 1">
  2046. and a.total_amount between 10 and 20
  2047. </if>
  2048. <if test="amountStatus == 2">
  2049. and a.total_amount between 20 and 30
  2050. </if>
  2051. <if test="amountStatus == 3">
  2052. and a.total_amount between 30 and 40
  2053. </if>
  2054. <if test="amountStatus == 4">
  2055. and a.total_amount &gt; 40
  2056. </if>
  2057. </select>
  2058. <select id="checkOrderProcessStatus" resultMap="BaseResultMap">
  2059. select
  2060. <include refid="Base_Column_List" />
  2061. from t_order_new
  2062. where order_no = (select t_order_task.order_no from t_order_task where id=#{tid})
  2063. </select>
  2064. <select id="selectgetAll" resultType="com.goafanti.common.model.TOrderNew">
  2065. select order_no orderNo,contract_picture_url contractPictureUrl ,agreement_url agreementUrl ,service_content serviceContent
  2066. from t_order_new where delete_sign in (0,2)
  2067. </select>
  2068. <select id="getProcessName" resultType="com.goafanti.order.bo.OrderProcessName">
  2069. select a.order_no orderNo,a.approval,a.process_status processStatus ,b.name yxy,mg.name yxjl,
  2070. yxgly.name yxgly,d.name cwzy, zxsgly.name zxsgly,dsz.name dsz,dep.approval approvalStatus ,da.name approvalName
  2071. from t_order_new a left join admin b on a.salesman_id =b.id
  2072. left join admin mg on b.manager_id =mg.id left join department c on a.order_dep =c.id
  2073. left join (select a.department_id depId,group_concat(a.name) name
  2074. from admin a left join user_role b on a.id=b.uid left join `role` c on b.rid =c.id
  2075. where c.role_type ='9996' and a.status ='0' group by a.department_id )yxgly on c.id =yxgly.depId
  2076. 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
  2077. left join (select group_concat(a.name) name
  2078. from admin a left join user_role b on a.id=b.uid left join `role` c on b.rid =c.id
  2079. where c.role_type in ('99999','99989') and a.status ='0' ) dsz on 1=1
  2080. left join (select group_concat(a.name) name
  2081. from admin a left join user_role b on a.id=b.uid left join `role` c on b.rid =c.id
  2082. where c.role_type in ('9998') and a.status ='0' ) zxsgly on 1=1
  2083. left join department dep on a.order_dep =dep.id left join admin da on dep.approval_aid=da.id
  2084. where a.order_no = #{orderNo}
  2085. </select>
  2086. <select id="selectByuidandAid" resultType="com.goafanti.order.bo.TOrderNewBo">
  2087. select order_no orderNo,sign_time signTime
  2088. from t_order_new
  2089. where buyer_id=#{uid} and salesman_id=#{aid}
  2090. </select>
  2091. <select id="statisticsOrderList" resultType="com.goafanti.order.bo.StatisOrderList">
  2092. select d.id,d.name province,c.name depName,a.order_no,a.salesman_id aid ,b.name aname,
  2093. 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
  2094. 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
  2095. left join district_glossory d on c.province =d.id
  2096. where a.process_status >4 and a.delete_sign in(0,2)
  2097. <if test="depId !=null">
  2098. and b.department_id = #{depId}
  2099. </if>
  2100. <if test="province !=null">
  2101. and c.province = #{province}
  2102. </if>
  2103. <if test="startCreate !=null and endCreate !=null">
  2104. and a.create_time between #{startCreate} and #{endCreate}
  2105. </if>
  2106. <if test="startSign !=null and endSign !=null">
  2107. and a.sign_time between #{startSign} and #{endSign}
  2108. </if>
  2109. </select>
  2110. <select id="matchingOrderNoOrUserName" resultType="com.goafanti.order.bo.UserOrder">
  2111. select order_no orderNo ,buyer_id uid ,b.username userName
  2112. from t_order_new a left join `user` b on a.buyer_id =b.id
  2113. where 1=1
  2114. <if test="orderNo !=null">
  2115. and order_no like concat('%',#{orderNo},'%')
  2116. </if>
  2117. <if test="userName !=null">
  2118. and b.nickname like concat('%',#{userName},'%')
  2119. </if>
  2120. limit 0,20
  2121. </select>
  2122. <update id="updateTagByListOrderNo">
  2123. update t_order_new
  2124. set tag = #{param2}
  2125. where order_no in
  2126. <foreach collection="param1" item="e" open="(" close=")" separator=",">
  2127. #{e}
  2128. </foreach>
  2129. </update>
  2130. <update id="updateOrderDepFinanceExamineName">
  2131. update t_order_new x ,(select order_no ,group_concat(aname)name
  2132. from t_order_examine where order_no in
  2133. <foreach collection="list" item="e" close=")" open="(" separator=",">
  2134. #{e}
  2135. </foreach>
  2136. and status =0 group by order_no) y
  2137. set x.examine_name =y.name
  2138. where x.order_no in
  2139. <foreach collection="list" item="e" close=")" open="(" separator=",">
  2140. #{e}
  2141. </foreach>
  2142. and x.order_no =y.order_no
  2143. </update>
  2144. <select id="selectAidAndDate" resultType="java.lang.Integer">
  2145. select count(*)
  2146. from t_order_new
  2147. where process_status >0
  2148. and salesman_id = #{aid}
  2149. and create_time BETWEEN #{startTime} and #{endTime}
  2150. </select>
  2151. <select id="selectCountByFinance" resultType="com.goafanti.common.model.FinanceCount">
  2152. select x.aid, x.dates dateTime, count(*)orderCount, sum(if(x.process_status = 3, 1, 0))orderUnauditedCount
  2153. from (SELECT b.finance_id aid, a.process_status, DATE_FORMAT(a.create_time , '%Y-%m-%d') dates
  2154. from t_order_new a left join department b on a.order_dep = b.id
  2155. where a.delete_sign in (0, 2, 3) and process_status >2 and a.outsource =0
  2156. and b.finance_id = #{aid})x
  2157. group by x.aid, x.dates;
  2158. </select>
  2159. <select id="selectOrderFinance" resultType="com.goafanti.organization.bo.OrganizationListOut">
  2160. select b.id,b.finance_id financeId,c.name financeName,b.retrial_finance_id retrialFinanceId,
  2161. d.name retrialFinanceName
  2162. from t_order_new a left join department b on a.order_dep = b.id
  2163. left join admin c on b.finance_id=c.id
  2164. left join admin d on b.retrial_finance_id=d.id
  2165. where a.order_no =#{orderNo}
  2166. </select>
  2167. <select id="selectDepByOrderNo" resultType="com.goafanti.common.model.Department">
  2168. select a.id,a.name,a.province,a.finance_id financeId,a.approval ,a.approval_aid approvalAid
  2169. from department a left join t_order_new b on a.id =b.order_dep
  2170. where b.order_no= #{orderNo}
  2171. </select>
  2172. <select id="selectByFinanceNotExamine" resultType="string">
  2173. select a.order_no orderNo,a.process_status processStatus
  2174. from t_order_new a left join t_order_examine b on a.order_no=b.order_no
  2175. where b.status=0 and b.aid = #{financeId} and a.process_status = 3
  2176. </select>
  2177. <select id="selectExpenseCount" parameterType="com.goafanti.expenseAccount.bo.ExpenseCountsInput" resultType="com.goafanti.expenseAccount.bo.ExpenseCountsBo">
  2178. select a.order_no orderNo,a.contract_no contractNo,b.buyer_name buyerName,toc.max_duration maxDuration ,toc.actual_duration actualDuration ,
  2179. toc.exceed_duration exceedDuration, a.total_amount totalAmount,a.settlement_amount settlementAmount,b.bid_type bidType,
  2180. c.expenseCount,c.peopleCount,c.notExamine,c.rejectCount,d.paymentAmount,c.days,c.amount expenseAmount
  2181. from t_order_new a left join t_order_mid b on a.order_no =b.order_no
  2182. left join t_order_public_release_count toc on a.order_no =toc.order_no
  2183. left join (select a.order_no,a.expenseCount,b.peopleCount,c.notExamine, c.rejectCount,a.days,a.amount
  2184. from (select a.order_no,count(a.id)expenseCount,sum(a.amount) amount,sum(ROUND(a.duration/7.5) )days
  2185. from expense_account a where a.order_no in (select a.order_no from expense_account a
  2186. where a.target_type = 1 group by order_no)
  2187. and a.status=2
  2188. <if test="startTime !=null and endTime != null">
  2189. and a.create_time BETWEEN #{startTime} and #{endTime}
  2190. </if>
  2191. group by order_no )a
  2192. left join (select order_no,count(aid)peopleCount from (select a.order_no,aid from expense_account a where a.order_no in
  2193. (select a.order_no from expense_account a where a.target_type = 1
  2194. and a.status=2
  2195. group by order_no)
  2196. <if test="startTime !=null and endTime != null">
  2197. and a.create_time BETWEEN #{startTime} and #{endTime}
  2198. </if>
  2199. group by order_no,aid )a group by order_no)b on a.order_no=b.order_no
  2200. left join (select a.order_no,sum(notExamine)notExamine,sum(rejectCount)rejectCount
  2201. from (select a.order_no,status ,IF(status=1,1,0)notExamine,IF(status=3,1,0)rejectCount
  2202. from expense_account a where a.order_no in (select a.order_no from expense_account a where a.target_type = 1
  2203. group by order_no)
  2204. <if test="startTime !=null and endTime != null">
  2205. and a.create_time BETWEEN #{startTime} and #{endTime}
  2206. </if>
  2207. )a group by order_no)c on a.order_no=c.order_no )c on a.order_no =c.order_no
  2208. left join ( select a.order_no ,sum(c.payment_amount) paymentAmount
  2209. 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
  2210. where c.status =3 and a.order_no in (select a.order_no from expense_account a where a.target_type = 1
  2211. group by order_no)
  2212. <if test="startTime !=null and endTime != null">
  2213. and a.create_time BETWEEN #{startTime} and #{endTime}
  2214. </if>
  2215. group by order_no )d on a.order_no=d.order_no
  2216. where a.process_status &gt; 0
  2217. and a.order_no in (select a.order_no from expense_account a where a.target_type = 1
  2218. <if test="startTime !=null and endTime != null">
  2219. and a.create_time BETWEEN #{startTime} and #{endTime}
  2220. </if>
  2221. group by order_no)
  2222. <if test="contactNo !=null ">
  2223. and a.contract_no like concat('%' ,#{contactNo},'%')
  2224. </if>
  2225. <if test="buyerName !=null ">
  2226. and b.buyer_name like concat('%' ,#{buyerName},'%')
  2227. </if>
  2228. <if test="depId !=null ">
  2229. and a.order_dep = #{depId}
  2230. </if>
  2231. </select>
  2232. <select id="selectExpenseDepCount" resultType="com.goafanti.expenseAccount.bo.ExpenseCountsBo">
  2233. select a.id depId,a.name depName,ifnull(b.totalAmount,0) totalAmount,ifnull(b.settlementAmount,0) settlementAmount,
  2234. c.amount ExpenseAmount,ifnull(f.paymentAmount,0) paymentAmount,d.peopleCount,c.days,c.expenseCount, e.notExamine,
  2235. e.rejectCount
  2236. from department a
  2237. left join (select a.order_dep ,sum(a.total_amount)totalAmount,sum(a.settlement_amount)settlementAmount
  2238. from t_order_new a where a.order_dep in (select a.apply_dep
  2239. from expense_account a where a.target_type = 0 group by apply_dep)
  2240. <if test="startTime !=null and endTime != null">
  2241. and a.create_time BETWEEN #{startTime} and #{endTime}
  2242. </if>
  2243. group by a.order_dep )b on a.id=b.order_dep
  2244. left join (select a.apply_dep,count(a.id)expenseCount, sum(ROUND(a.duration/7.5) )days ,sum(a.amount)amount
  2245. 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)
  2246. and a.status=2
  2247. <if test="startTime !=null and endTime != null">
  2248. and a.create_time BETWEEN #{startTime} and #{endTime}
  2249. </if>
  2250. group by apply_dep )c on a.id=c.apply_dep
  2251. left join (select apply_dep,count(aid)peopleCount from (select a.apply_dep,aid from expense_account a where a.apply_dep in
  2252. (select a.apply_dep
  2253. from expense_account a where a.target_type = 0 group by apply_dep)
  2254. and a.status=2
  2255. <if test="startTime !=null and endTime != null">
  2256. and a.create_time BETWEEN #{startTime} and #{endTime}
  2257. </if>
  2258. group by apply_dep,aid )a group by apply_dep)d on a.id=d.apply_dep
  2259. left join (select a.apply_dep,sum(notExamine)notExamine,sum(rejectCount)rejectCount
  2260. from (select a.apply_dep,status ,IF(status=1,1,0)notExamine,IF(status=3,1,0)rejectCount
  2261. 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)
  2262. <if test="startTime !=null and endTime != null">
  2263. and a.create_time BETWEEN #{startTime} and #{endTime}
  2264. </if>
  2265. )a group by apply_dep)e on a.id=e.apply_dep
  2266. left join (select a.order_dep ,sum(c.payment_amount) paymentAmount from t_order_new a
  2267. left join t_order_task b on a.order_no =b.order_no left join t_order_payment c on b.id =c.tid
  2268. 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)
  2269. <if test="startTime !=null and endTime != null">
  2270. and a.create_time BETWEEN #{startTime} and #{endTime}
  2271. </if>
  2272. group by order_dep )f on a.id=f.order_dep
  2273. where a.id in (select a.apply_dep
  2274. from expense_account a where a.target_type = 0
  2275. <if test="startTime !=null and endTime != null">
  2276. and a.create_time BETWEEN #{startTime} and #{endTime}
  2277. </if>
  2278. group by apply_dep)
  2279. <if test="depId !=null ">
  2280. and a.id = #{depId}
  2281. </if>
  2282. </select>
  2283. </mapper>