TOrderNewMapper.xml 112 KB

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