TOrderNewMapper.xml 66 KB

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