TOrderNewMapper.xml 74 KB

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