TOrderNewMapper.xml 88 KB

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