TOrderNewMapper.xml 73 KB

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