TOrderNewMapper.xml 63 KB

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