TOrderNewMapper.xml 110 KB

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