TOrderNewMapper.xml 86 KB

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