UserMidMapper.xml 22 KB

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