UserMidMapper.xml 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  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.UserMidMapper">
  4. <resultMap id="BaseResultMap" type="com.goafanti.common.model.UserMid">
  5. <id column="id" jdbcType="INTEGER" property="id" />
  6. <result column="uid" jdbcType="VARCHAR" property="uid" />
  7. <result column="aid" jdbcType="VARCHAR" property="aid" />
  8. <result column="last_follow_time" jdbcType="TIMESTAMP" property="lastFollowTime" />
  9. <result column="last_sign_time" jdbcType="TIMESTAMP" property="lastSignTime" />
  10. <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
  11. <result column="big_customer" jdbcType="INTEGER" property="bigCustomer" />
  12. <result column="update_aid" jdbcType="VARCHAR" property="updateAid" />
  13. <result column="update_name" jdbcType="VARCHAR" property="updateName" />
  14. <result column="date_update_time" jdbcType="TIMESTAMP" property="dateUpdateTime" />
  15. <result column="channel_type" jdbcType="INTEGER" property="channelType" />
  16. <result column="chargeback" jdbcType="INTEGER" property="chargeback" />
  17. <result column="member" jdbcType="INTEGER" property="member" />
  18. <result column="last_sales_type" jdbcType="INTEGER" property="lastSalesType" />
  19. <result column="last_follow_type" jdbcType="INTEGER" property="lastFollowType" />
  20. <result column="follow_number" jdbcType="INTEGER" property="followNumber" />
  21. <result column="task_names" jdbcType="VARCHAR" property="taskNames" />
  22. <result column="sign_number" jdbcType="INTEGER" property="signNumber" />
  23. <result column="sign_amount" jdbcType="DECIMAL" property="signAmount" />
  24. <result column="last_signing_time" jdbcType="DATE" property="lastSigningTime" />
  25. <result column="first_signing_time" jdbcType="DATE" property="firstSigningTime" />
  26. <result column="follow_dep" jdbcType="VARCHAR" property="followDep" />
  27. <result column="follow_explain" jdbcType="VARCHAR" property="followExplain" />
  28. <result column="follow_aname" jdbcType="VARCHAR" property="followAname" />
  29. <result column="follow_aid" jdbcType="VARCHAR" property="followAid" />
  30. </resultMap>
  31. <sql id="Base_Column_List">
  32. id, `uid`, aid, last_follow_time, last_sign_time, create_time, big_customer, update_aid,
  33. update_name, date_update_time, channel_type, chargeback, `member`, last_sales_type,
  34. last_follow_type, follow_number, task_names, sign_number, sign_amount, last_signing_time,
  35. first_signing_time, follow_dep, follow_explain, follow_aname, follow_aid
  36. </sql>
  37. <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
  38. select
  39. <include refid="Base_Column_List" />
  40. from user_mid
  41. where id = #{id,jdbcType=INTEGER}
  42. </select>
  43. <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
  44. delete from user_mid
  45. where id = #{id,jdbcType=INTEGER}
  46. </delete>
  47. <insert id="insert" parameterType="com.goafanti.common.model.UserMid">
  48. insert into user_mid (id, `uid`, aid,
  49. last_follow_time, last_sign_time, create_time,
  50. big_customer, update_aid, update_name,
  51. date_update_time, channel_type, chargeback,
  52. `member`, last_sales_type, last_follow_type,
  53. follow_number, task_names, sign_number,
  54. sign_amount, last_signing_time, first_signing_time,
  55. follow_dep, follow_explain, follow_aname,
  56. follow_aid)
  57. values (#{id,jdbcType=INTEGER}, #{uid,jdbcType=VARCHAR}, #{aid,jdbcType=VARCHAR},
  58. #{lastFollowTime,jdbcType=TIMESTAMP}, #{lastSignTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP},
  59. #{bigCustomer,jdbcType=INTEGER}, #{updateAid,jdbcType=VARCHAR}, #{updateName,jdbcType=VARCHAR},
  60. #{dateUpdateTime,jdbcType=TIMESTAMP}, #{channelType,jdbcType=INTEGER}, #{chargeback,jdbcType=INTEGER},
  61. #{member,jdbcType=INTEGER}, #{lastSalesType,jdbcType=INTEGER}, #{lastFollowType,jdbcType=INTEGER},
  62. #{followNumber,jdbcType=INTEGER}, #{taskNames,jdbcType=VARCHAR}, #{signNumber,jdbcType=INTEGER},
  63. #{signAmount,jdbcType=DECIMAL}, #{lastSigningTime,jdbcType=DATE}, #{firstSigningTime,jdbcType=DATE},
  64. #{followDep,jdbcType=VARCHAR}, #{followExplain,jdbcType=VARCHAR}, #{followAname,jdbcType=VARCHAR},
  65. #{followAid,jdbcType=VARCHAR})
  66. </insert>
  67. <insert id="insertSelective" parameterType="com.goafanti.common.model.UserMid">
  68. insert into user_mid
  69. <trim prefix="(" suffix=")" suffixOverrides=",">
  70. <if test="id != null">
  71. id,
  72. </if>
  73. <if test="uid != null">
  74. `uid`,
  75. </if>
  76. <if test="aid != null">
  77. aid,
  78. </if>
  79. <if test="lastFollowTime != null">
  80. last_follow_time,
  81. </if>
  82. <if test="lastSignTime != null">
  83. last_sign_time,
  84. </if>
  85. <if test="createTime != null">
  86. create_time,
  87. </if>
  88. <if test="bigCustomer != null">
  89. big_customer,
  90. </if>
  91. <if test="updateAid != null">
  92. update_aid,
  93. </if>
  94. <if test="updateName != null">
  95. update_name,
  96. </if>
  97. <if test="dateUpdateTime != null">
  98. date_update_time,
  99. </if>
  100. <if test="channelType != null">
  101. channel_type,
  102. </if>
  103. <if test="chargeback != null">
  104. chargeback,
  105. </if>
  106. <if test="member != null">
  107. `member`,
  108. </if>
  109. <if test="lastSalesType != null">
  110. last_sales_type,
  111. </if>
  112. <if test="lastFollowType != null">
  113. last_follow_type,
  114. </if>
  115. <if test="followNumber != null">
  116. follow_number,
  117. </if>
  118. <if test="taskNames != null">
  119. task_names,
  120. </if>
  121. <if test="signNumber != null">
  122. sign_number,
  123. </if>
  124. <if test="signAmount != null">
  125. sign_amount,
  126. </if>
  127. <if test="lastSigningTime != null">
  128. last_signing_time,
  129. </if>
  130. <if test="firstSigningTime != null">
  131. first_signing_time,
  132. </if>
  133. <if test="followDep != null">
  134. follow_dep,
  135. </if>
  136. <if test="followExplain != null">
  137. follow_explain,
  138. </if>
  139. <if test="followAname != null">
  140. follow_aname,
  141. </if>
  142. <if test="followAid != null">
  143. follow_aid,
  144. </if>
  145. </trim>
  146. <trim prefix="values (" suffix=")" suffixOverrides=",">
  147. <if test="id != null">
  148. #{id,jdbcType=INTEGER},
  149. </if>
  150. <if test="uid != null">
  151. #{uid,jdbcType=VARCHAR},
  152. </if>
  153. <if test="aid != null">
  154. #{aid,jdbcType=VARCHAR},
  155. </if>
  156. <if test="lastFollowTime != null">
  157. #{lastFollowTime,jdbcType=TIMESTAMP},
  158. </if>
  159. <if test="lastSignTime != null">
  160. #{lastSignTime,jdbcType=TIMESTAMP},
  161. </if>
  162. <if test="createTime != null">
  163. #{createTime,jdbcType=TIMESTAMP},
  164. </if>
  165. <if test="bigCustomer != null">
  166. #{bigCustomer,jdbcType=INTEGER},
  167. </if>
  168. <if test="updateAid != null">
  169. #{updateAid,jdbcType=VARCHAR},
  170. </if>
  171. <if test="updateName != null">
  172. #{updateName,jdbcType=VARCHAR},
  173. </if>
  174. <if test="dateUpdateTime != null">
  175. #{dateUpdateTime,jdbcType=TIMESTAMP},
  176. </if>
  177. <if test="channelType != null">
  178. #{channelType,jdbcType=INTEGER},
  179. </if>
  180. <if test="chargeback != null">
  181. #{chargeback,jdbcType=INTEGER},
  182. </if>
  183. <if test="member != null">
  184. #{member,jdbcType=INTEGER},
  185. </if>
  186. <if test="lastSalesType != null">
  187. #{lastSalesType,jdbcType=INTEGER},
  188. </if>
  189. <if test="lastFollowType != null">
  190. #{lastFollowType,jdbcType=INTEGER},
  191. </if>
  192. <if test="followNumber != null">
  193. #{followNumber,jdbcType=INTEGER},
  194. </if>
  195. <if test="taskNames != null">
  196. #{taskNames,jdbcType=VARCHAR},
  197. </if>
  198. <if test="signNumber != null">
  199. #{signNumber,jdbcType=INTEGER},
  200. </if>
  201. <if test="signAmount != null">
  202. #{signAmount,jdbcType=DECIMAL},
  203. </if>
  204. <if test="lastSigningTime != null">
  205. #{lastSigningTime,jdbcType=DATE},
  206. </if>
  207. <if test="firstSigningTime != null">
  208. #{firstSigningTime,jdbcType=DATE},
  209. </if>
  210. <if test="followDep != null">
  211. #{followDep,jdbcType=VARCHAR},
  212. </if>
  213. <if test="followExplain != null">
  214. #{followExplain,jdbcType=VARCHAR},
  215. </if>
  216. <if test="followAname != null">
  217. #{followAname,jdbcType=VARCHAR},
  218. </if>
  219. <if test="followAid != null">
  220. #{followAid,jdbcType=VARCHAR},
  221. </if>
  222. </trim>
  223. </insert>
  224. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.UserMid">
  225. update user_mid
  226. <set>
  227. <if test="uid != null">
  228. `uid` = #{uid,jdbcType=VARCHAR},
  229. </if>
  230. <if test="aid != null">
  231. aid = #{aid,jdbcType=VARCHAR},
  232. </if>
  233. <if test="lastFollowTime != null">
  234. last_follow_time = #{lastFollowTime,jdbcType=TIMESTAMP},
  235. </if>
  236. <if test="lastSignTime != null">
  237. last_sign_time = #{lastSignTime,jdbcType=TIMESTAMP},
  238. </if>
  239. <if test="createTime != null">
  240. create_time = #{createTime,jdbcType=TIMESTAMP},
  241. </if>
  242. <if test="bigCustomer != null">
  243. big_customer = #{bigCustomer,jdbcType=INTEGER},
  244. </if>
  245. <if test="updateAid != null">
  246. update_aid = #{updateAid,jdbcType=VARCHAR},
  247. </if>
  248. <if test="updateName != null">
  249. update_name = #{updateName,jdbcType=VARCHAR},
  250. </if>
  251. <if test="dateUpdateTime != null">
  252. date_update_time = #{dateUpdateTime,jdbcType=TIMESTAMP},
  253. </if>
  254. <if test="channelType != null">
  255. channel_type = #{channelType,jdbcType=INTEGER},
  256. </if>
  257. <if test="chargeback != null">
  258. chargeback = #{chargeback,jdbcType=INTEGER},
  259. </if>
  260. <if test="member != null">
  261. `member` = #{member,jdbcType=INTEGER},
  262. </if>
  263. <if test="lastSalesType != null">
  264. last_sales_type = #{lastSalesType,jdbcType=INTEGER},
  265. </if>
  266. <if test="lastFollowType != null">
  267. last_follow_type = #{lastFollowType,jdbcType=INTEGER},
  268. </if>
  269. <if test="followNumber != null">
  270. follow_number = #{followNumber,jdbcType=INTEGER},
  271. </if>
  272. <if test="taskNames != null">
  273. task_names = #{taskNames,jdbcType=VARCHAR},
  274. </if>
  275. <if test="signNumber != null">
  276. sign_number = #{signNumber,jdbcType=INTEGER},
  277. </if>
  278. <if test="signAmount != null">
  279. sign_amount = #{signAmount,jdbcType=DECIMAL},
  280. </if>
  281. <if test="lastSigningTime != null">
  282. last_signing_time = #{lastSigningTime,jdbcType=DATE},
  283. </if>
  284. <if test="firstSigningTime != null">
  285. first_signing_time = #{firstSigningTime,jdbcType=DATE},
  286. </if>
  287. <if test="followDep != null">
  288. follow_dep = #{followDep,jdbcType=VARCHAR},
  289. </if>
  290. <if test="followExplain != null">
  291. follow_explain = #{followExplain,jdbcType=VARCHAR},
  292. </if>
  293. <if test="followAname != null">
  294. follow_aname = #{followAname,jdbcType=VARCHAR},
  295. </if>
  296. <if test="followAid != null">
  297. follow_aid = #{followAid,jdbcType=VARCHAR},
  298. </if>
  299. </set>
  300. where id = #{id,jdbcType=INTEGER}
  301. </update>
  302. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.UserMid">
  303. update user_mid
  304. set `uid` = #{uid,jdbcType=VARCHAR},
  305. aid = #{aid,jdbcType=VARCHAR},
  306. last_follow_time = #{lastFollowTime,jdbcType=TIMESTAMP},
  307. last_sign_time = #{lastSignTime,jdbcType=TIMESTAMP},
  308. create_time = #{createTime,jdbcType=TIMESTAMP},
  309. big_customer = #{bigCustomer,jdbcType=INTEGER},
  310. update_aid = #{updateAid,jdbcType=VARCHAR},
  311. update_name = #{updateName,jdbcType=VARCHAR},
  312. date_update_time = #{dateUpdateTime,jdbcType=TIMESTAMP},
  313. channel_type = #{channelType,jdbcType=INTEGER},
  314. chargeback = #{chargeback,jdbcType=INTEGER},
  315. `member` = #{member,jdbcType=INTEGER},
  316. last_sales_type = #{lastSalesType,jdbcType=INTEGER},
  317. last_follow_type = #{lastFollowType,jdbcType=INTEGER},
  318. follow_number = #{followNumber,jdbcType=INTEGER},
  319. task_names = #{taskNames,jdbcType=VARCHAR},
  320. sign_number = #{signNumber,jdbcType=INTEGER},
  321. sign_amount = #{signAmount,jdbcType=DECIMAL},
  322. last_signing_time = #{lastSigningTime,jdbcType=DATE},
  323. first_signing_time = #{firstSigningTime,jdbcType=DATE},
  324. follow_dep = #{followDep,jdbcType=VARCHAR},
  325. follow_explain = #{followExplain,jdbcType=VARCHAR},
  326. follow_aname = #{followAname,jdbcType=VARCHAR},
  327. follow_aid = #{followAid,jdbcType=VARCHAR}
  328. where id = #{id,jdbcType=INTEGER}
  329. </update>
  330. <update id="updateByUid" parameterType="com.goafanti.common.model.UserMid">
  331. update user_mid
  332. <set>
  333. <if test="aid != null">
  334. aid = #{aid,jdbcType=VARCHAR},
  335. </if>
  336. <if test="lastFollowTime != null">
  337. last_follow_time = #{lastFollowTime,jdbcType=TIMESTAMP},
  338. </if>
  339. <if test="lastSignTime != null">
  340. last_sign_time = #{lastSignTime,jdbcType=TIMESTAMP},
  341. </if>
  342. <if test="createTime != null">
  343. create_time = #{createTime,jdbcType=TIMESTAMP},
  344. </if>
  345. <if test="bigCustomer != null">
  346. big_customer = #{bigCustomer,jdbcType=INTEGER},
  347. </if>
  348. <if test="updateAid != null">
  349. update_aid = #{updateAid,jdbcType=VARCHAR},
  350. </if>
  351. <if test="updateName != null">
  352. update_name = #{updateName,jdbcType=VARCHAR},
  353. </if>
  354. <if test="dateUpdateTime != null">
  355. date_update_time = #{dateUpdateTime,jdbcType=TIMESTAMP},
  356. </if>
  357. <if test="channelType != null">
  358. channel_type = #{channelType,jdbcType=INTEGER},
  359. </if>
  360. <if test="chargeback != null">
  361. chargeback = #{chargeback,jdbcType=INTEGER},
  362. </if>
  363. <if test="member != null">
  364. `member` = #{member,jdbcType=INTEGER},
  365. </if>
  366. <if test="lastSalesType != null">
  367. last_sales_type = #{lastSalesType,jdbcType=INTEGER},
  368. </if>
  369. <if test="lastFollowType != null">
  370. last_follow_type = #{lastFollowType,jdbcType=INTEGER},
  371. </if>
  372. <if test="followNumber != null">
  373. follow_number = #{followNumber,jdbcType=INTEGER},
  374. </if>
  375. <if test="taskNames != null">
  376. task_names = #{taskNames,jdbcType=VARCHAR},
  377. </if>
  378. <if test="signNumber != null">
  379. sign_number = #{signNumber,jdbcType=INTEGER},
  380. </if>
  381. <if test="signAmount != null">
  382. sign_amount = #{signAmount,jdbcType=DECIMAL},
  383. </if>
  384. <if test="lastSigningTime != null">
  385. last_signing_time = #{lastSigningTime,jdbcType=DATE},
  386. </if>
  387. <if test="firstSigningTime != null">
  388. first_signing_time = #{firstSigningTime,jdbcType=DATE},
  389. </if>
  390. <if test="followDep != null">
  391. follow_dep = #{followDep,jdbcType=VARCHAR},
  392. </if>
  393. <if test="followExplain != null">
  394. follow_explain = #{followExplain,jdbcType=VARCHAR},
  395. </if>
  396. <if test="followAname != null">
  397. follow_aname = #{followAname,jdbcType=VARCHAR},
  398. </if>
  399. <if test="followAid != null">
  400. follow_aid = #{followAid,jdbcType=VARCHAR},
  401. </if>
  402. </set>
  403. where `uid` = #{uid,jdbcType=VARCHAR}
  404. </update>
  405. <update id="updateListByUid" parameterType="com.goafanti.common.model.UserMid">
  406. update user_mid
  407. <set>
  408. <if test="aid != null">
  409. aid = #{aid,jdbcType=VARCHAR},
  410. </if>
  411. <if test="updateFollow ==1">
  412. last_follow_time = null,
  413. </if>
  414. <if test="lastSignTime != null">
  415. last_sign_time = #{lastSignTime,jdbcType=TIMESTAMP},
  416. </if>
  417. <if test="createTime != null">
  418. create_time = #{createTime,jdbcType=TIMESTAMP},
  419. </if>
  420. <if test="bigCustomer != null">
  421. big_customer = #{bigCustomer,jdbcType=INTEGER},
  422. </if>
  423. <if test="updateAid != null">
  424. update_aid = #{updateAid,jdbcType=VARCHAR},
  425. </if>
  426. <if test="updateName != null">
  427. update_name = #{updateName,jdbcType=VARCHAR},
  428. </if>
  429. <if test="dateUpdateTime != null">
  430. date_update_time = #{dateUpdateTime,jdbcType=TIMESTAMP},
  431. </if>
  432. </set>
  433. where `uid` in
  434. <foreach item="item" collection="list" separator="," open="(" close=")" index="">
  435. #{item}
  436. </foreach>
  437. </update>
  438. <select id="getUserTaskNames" resultType="java.lang.String">
  439. select group_concat(distinct b.commodity_name)task_names from t_order_new a
  440. left join t_order_task b on a.order_no =b.order_no
  441. where a.buyer_id = #{uid}
  442. group by a.buyer_id
  443. </select>
  444. <select id="getUserDtails" resultType="com.goafanti.common.model.UserMid">
  445. select a.buyer_id uid,min(a.sign_time)firstSigningTime,max(a.sign_time)lastSigningTime,
  446. sum(a.total_amount)signAmount,count(*)signNumber
  447. from t_order_new a
  448. where a.delete_sign in (0,2) and a.process_status >4
  449. and a.buyer_id= #{uid}
  450. group by a.buyer_id
  451. </select>
  452. <select id="selectSignSummaryList" resultType="com.goafanti.order.bo.OutSignSummary">
  453. select a.id ,a.nickname ,b.sign_number signNumber,b.sign_amount signAmount,
  454. date_format(b.first_signing_time ,'%Y-%m-%d') firstSigningTime,
  455. date_format(b.last_signing_time ,'%Y-%m-%d') lastSigningTime ,
  456. b.last_sales_type lastSalesType,c.name,d.name depName,
  457. b.last_follow_type lastFollowType,b.follow_explain followExplain ,b.follow_number followNumber ,
  458. date_format(b.last_follow_time ,'%Y-%m-%d %H:%i:%S') lastFollowTime ,b.task_names taskNames ,
  459. b.`member` ,b.chargeback ,b.big_customer bigCustomer,b.follow_aname followAname
  460. from user a left join user_mid b on a.id=b.uid left join admin c on a.aid=c.id
  461. left join department d on c.department_id =d.id
  462. where 1=1
  463. <if test="userName != null">
  464. and a.nickname like concat('%',#{userName},'%')
  465. </if>
  466. <if test="aid != null">
  467. and c.id =#{aid}
  468. </if>
  469. <if test="followAid != null">
  470. and b.follow_aid =#{followAid}
  471. </if>
  472. <if test="member != null">
  473. and b.`member` = #{member}
  474. </if>
  475. <if test="chargeback != null">
  476. and b.chargeback = #{chargeback}
  477. </if>
  478. <if test="bigCustomer != null">
  479. and b.big_customer = #{bigCustomer}
  480. </if>
  481. <if test="lastFollowType != null">
  482. and b.last_follow_type = #{lastFollowType}
  483. </if>
  484. <if test="followDep != null">
  485. and b.follow_dep = #{followDep}
  486. </if>
  487. <if test="lastFollowTimeStart != null and lastFollowTimeEnd !=null">
  488. and b.last_follow_time BETWEEN #{lastFollowTimeStart} and #{lastFollowTimeEnd}
  489. </if>
  490. <if test="firstSigningTimeStart != null and firstSigningTimeEnd !=null">
  491. and b.first_signing_time BETWEEN #{firstSigningTimeStart} and #{firstSigningTimeEnd}
  492. </if>
  493. <if test="lastSigningTimeStart != null and lastSigningTimeStart !=null">
  494. and b.last_signing_time BETWEEN #{lastSigningTimeStart} and #{lastSigningTimeEnd}
  495. </if>
  496. <if test="signNumber != null">
  497. and b.sign_number = #{signNumber}
  498. </if>
  499. <if test="lastSalesType != null">
  500. and b.last_sales_type = #{lastSalesType}
  501. </if>
  502. <if test="page_sql!=null">
  503. ${page_sql}
  504. </if>
  505. </select>
  506. <select id="selectSignSummaryCount" resultType="integer">
  507. select count(*)
  508. from user a left join user_mid b on a.id=b.uid left join admin c on a.aid=c.id
  509. where 1=1
  510. <if test="userName != null">
  511. and a.nickname like concat('%',#{userName},'%')
  512. </if>
  513. <if test="aid != null">
  514. and c.id =#{aid}
  515. </if>
  516. <if test="followAid != null">
  517. and b.follow_aid =#{followAid}
  518. </if>
  519. <if test="member != null">
  520. and b.`member` = #{member}
  521. </if>
  522. <if test="chargeback != null">
  523. and b.chargeback = #{chargeback}
  524. </if>
  525. <if test="bigCustomer != null">
  526. and b.big_customer = #{bigCustomer}
  527. </if>
  528. <if test="lastFollowType != null">
  529. and b.last_follow_type = #{lastFollowType}
  530. </if>
  531. <if test="followDep != null">
  532. and b.follow_dep = #{followDep}
  533. </if>
  534. <if test="lastFollowTimeStart != null and lastFollowTimeEnd !=null">
  535. and b.last_follow_time BETWEEN #{lastFollowTimeStart} and #{lastFollowTimeEnd}
  536. </if>
  537. <if test="firstSigningTimeStart != null and firstSigningTimeEnd !=null">
  538. and b.first_signing_time BETWEEN #{firstSigningTimeStart} and #{firstSigningTimeEnd}
  539. </if>
  540. <if test="lastSigningTimeStart != null and lastSigningTimeStart !=null">
  541. and b.last_signing_time BETWEEN #{lastSigningTimeStart} and #{lastSigningTimeEnd}
  542. </if>
  543. <if test="signNumber != null">
  544. and b.sign_number = #{signNumber}
  545. </if>
  546. <if test="lastSalesType != null">
  547. and b.last_sales_type = #{lastSalesType}
  548. </if>
  549. </select>
  550. <select id="selectsignStatisticsList" resultType="com.goafanti.order.bo.OutSignStatistics">
  551. select a.id, a.name,y.aid, userCount, orderCount, totalAmount, newSignNumber, repeatSignNumber, channelSignNumber,
  552. (newSignNumber/orderCount)newRatio,(repeatSignNumber/orderCount)repeatRatio,(newSignNumber/orderCount)channelRatio
  553. from admin a
  554. left join user_role ur on ur.uid =a.id left join `role` r on r.id=ur.rid
  555. left join ( select x.aid,count(id) userCount, sum(x.orderCount)orderCount,sum(x.totalAmount)totalAmount,
  556. sum(x.newSignNumber)newSignNumber,sum(x.repeatSignNumber)repeatSignNumber,
  557. sum(x.channelSignNumber)channelSignNumber
  558. from ( select b.aid,b.id,count(*)orderCount ,sum(a.total_amount) totalAmount ,
  559. sum(if(a.sales_type &lt; 3 || (a.sales_type &gt; 3 &amp;&amp; a.sales_type &lt; 6),1,0 ))newSignNumber,
  560. sum(if(a.sales_type=3,1,0 ))channelSignNumber,sum(if(a.sales_type &gt; 5,1,0 ))repeatSignNumber
  561. from t_order_new a left join user b on b.id=a.buyer_id
  562. where a.process_status &gt;4 and b.share_type =2 and a.delete_sign in(0,2)
  563. <if test="signTimeStart != null and signTimeEnd!=null">
  564. and a.sign_time BETWEEN #{signTimeStart} and #{signTimeEnd}
  565. </if>
  566. group by b.aid,b.id)x group by x.aid)y on y.aid=a.id
  567. where r.role_type in (96,996)
  568. <if test="aid != null">
  569. and a.id= #{aid}
  570. </if>
  571. <if test="depId != null">
  572. and a.department_id = #{depId}
  573. </if>
  574. <if test="amountType != null">
  575. <if test="amountType == 1">
  576. and totalAmount &lt; 10
  577. </if>
  578. <if test="amountType == 2">
  579. and totalAmount BETWEEN 10 and 20
  580. </if>
  581. <if test="amountType == 3">
  582. and totalAmount BETWEEN 20 and 30
  583. </if>
  584. <if test="amountType == 4">
  585. and totalAmount &gt; 30
  586. </if>
  587. </if>
  588. <if test="page_sql!=null">
  589. ${page_sql}
  590. </if>
  591. </select>
  592. <select id="selectsignStatisticsCount" resultType="integer">
  593. select count(*)from (select a.id,a.name
  594. from admin a left join user_role ur on ur.uid =a.id left join `role` r on r.id=ur.rid
  595. where r.role_type in (96,996)
  596. <if test="aid != null">
  597. and a.id= #{aid}
  598. </if>
  599. <if test="depId != null">
  600. and a.department_id = #{depId}
  601. </if>
  602. group by a.id,a.name)x
  603. </select>
  604. <select id="selectsignStatisticsOrderList" resultType="com.goafanti.order.bo.TOrderNewBo">
  605. 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,
  606. a.contract_no as contractNo, b.nickname as userName ,a.process_status as processStatus,a.total_amount as totalAmount,
  607. a.order_status as orderStatus, a.liquidation_status as liquidationStatus,a.approval,c.salesman_name as salesmanName,c.project_type projectType,
  608. dep.name as depName,c.finance_name as financeName,c.invoice_amount invoiceAmount,a.settlement_amount settlementAmount,
  609. a.sales_type salesType, a.channel_id channelId ,a.other
  610. 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
  611. left join department dep on a.order_dep=dep.id
  612. where a.process_status &gt;4 and b.share_type =2 and a.delete_sign in(0,2)
  613. <if test="amountType != null">
  614. <if test="amountType == 1">
  615. and a.total_amount &lt; 10
  616. </if>
  617. <if test="amountType == 2">
  618. and a.total_amount BETWEEN 10 and 20
  619. </if>
  620. <if test="amountType == 3">
  621. and a.total_amount BETWEEN 20 and 30
  622. </if>
  623. <if test="amountType == 4">
  624. and a.total_amount &gt; 30
  625. </if>
  626. </if>
  627. <if test="signTimeStart != null and signTimeEnd!=null">
  628. and a.sign_time BETWEEN #{signTimeStart} and #{signTimeEnd}
  629. </if>
  630. <if test="aid !=null">
  631. and b.aid= #{aid}
  632. </if>
  633. <if test="orderType !=null">
  634. <if test="orderType ==1">
  635. and(a.sales_type &lt; 3 or (a.sales_type &gt; 3 and a.sales_type &lt; 6))
  636. </if>
  637. <if test="orderType ==2">
  638. and a.sales_type &gt; 5
  639. </if>
  640. <if test="orderType ==3">
  641. and a.sales_type=3
  642. </if>
  643. </if>
  644. order by a.create_time desc
  645. <if test="page_sql!=null">
  646. ${page_sql}
  647. </if>
  648. </select>
  649. <select id="selectsignStatisticsOrderCount" resultType="integer">
  650. select count(*)
  651. 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
  652. left join department dep on a.order_dep=dep.id
  653. where a.process_status &gt;4 and b.share_type =2 and a.delete_sign in(0,2)
  654. <if test="amountType != null">
  655. <if test="amountType == 1">
  656. and a.total_amount &lt; 10
  657. </if>
  658. <if test="amountType == 2">
  659. and a.total_amount BETWEEN 10 and 20
  660. </if>
  661. <if test="amountType == 3">
  662. and a.total_amount BETWEEN 20 and 30
  663. </if>
  664. <if test="amountType == 4">
  665. and a.total_amount &gt; 30
  666. </if>
  667. </if>
  668. <if test="signTimeStart != null and signTimeEnd!=null">
  669. and a.sign_time BETWEEN #{signTimeStart} and #{signTimeEnd}
  670. </if>
  671. <if test="aid !=null">
  672. and b.aid= #{aid}
  673. </if>
  674. <if test="orderType !=null">
  675. <if test="orderType ==1">
  676. and(a.sales_type &lt; 3 or (a.sales_type &gt; 3 and a.sales_type &lt; 6))
  677. </if>
  678. <if test="orderType ==2">
  679. and a.sales_type &gt; 5
  680. </if>
  681. <if test="orderType ==3">
  682. and a.sales_type=3
  683. </if>
  684. </if>
  685. </select>
  686. </mapper>