TOrderNewMapper.xml 73 KB

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