TOrderNewMapper.xml 90 KB

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