UserMidMapper.xml 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910
  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" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.UserMid" useGeneratedKeys="true">
  48. insert into user_mid (`uid`, aid, last_follow_time,
  49. last_sign_time, create_time, big_customer,
  50. update_aid, update_name, date_update_time,
  51. channel_type, chargeback, `member`,
  52. last_sales_type, last_follow_type, follow_number,
  53. task_names, sign_number, sign_amount,
  54. last_signing_time, first_signing_time, follow_dep,
  55. follow_explain, follow_aname, follow_aid
  56. )
  57. values (#{uid,jdbcType=VARCHAR}, #{aid,jdbcType=VARCHAR}, #{lastFollowTime,jdbcType=TIMESTAMP},
  58. #{lastSignTime,jdbcType=TIMESTAMP}, #{createTime,jdbcType=TIMESTAMP}, #{bigCustomer,jdbcType=INTEGER},
  59. #{updateAid,jdbcType=VARCHAR}, #{updateName,jdbcType=VARCHAR}, #{dateUpdateTime,jdbcType=TIMESTAMP},
  60. #{channelType,jdbcType=INTEGER}, #{chargeback,jdbcType=INTEGER}, #{member,jdbcType=INTEGER},
  61. #{lastSalesType,jdbcType=INTEGER}, #{lastFollowType,jdbcType=INTEGER}, #{followNumber,jdbcType=INTEGER},
  62. #{taskNames,jdbcType=VARCHAR}, #{signNumber,jdbcType=INTEGER}, #{signAmount,jdbcType=DECIMAL},
  63. #{lastSigningTime,jdbcType=DATE}, #{firstSigningTime,jdbcType=DATE}, #{followDep,jdbcType=VARCHAR},
  64. #{followExplain,jdbcType=VARCHAR}, #{followAname,jdbcType=VARCHAR}, #{followAid,jdbcType=VARCHAR}
  65. )
  66. </insert>
  67. <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.UserMid" useGeneratedKeys="true">
  68. insert into user_mid
  69. <trim prefix="(" suffix=")" suffixOverrides=",">
  70. <if test="uid != null">
  71. `uid`,
  72. </if>
  73. <if test="aid != null">
  74. aid,
  75. </if>
  76. <if test="lastFollowTime != null">
  77. last_follow_time,
  78. </if>
  79. <if test="lastSignTime != null">
  80. last_sign_time,
  81. </if>
  82. <if test="createTime != null">
  83. create_time,
  84. </if>
  85. <if test="bigCustomer != null">
  86. big_customer,
  87. </if>
  88. <if test="updateAid != null">
  89. update_aid,
  90. </if>
  91. <if test="updateName != null">
  92. update_name,
  93. </if>
  94. <if test="dateUpdateTime != null">
  95. date_update_time,
  96. </if>
  97. <if test="channelType != null">
  98. channel_type,
  99. </if>
  100. <if test="chargeback != null">
  101. chargeback,
  102. </if>
  103. <if test="member != null">
  104. `member`,
  105. </if>
  106. <if test="lastSalesType != null">
  107. last_sales_type,
  108. </if>
  109. <if test="lastFollowType != null">
  110. last_follow_type,
  111. </if>
  112. <if test="followNumber != null">
  113. follow_number,
  114. </if>
  115. <if test="taskNames != null">
  116. task_names,
  117. </if>
  118. <if test="signNumber != null">
  119. sign_number,
  120. </if>
  121. <if test="signAmount != null">
  122. sign_amount,
  123. </if>
  124. <if test="lastSigningTime != null">
  125. last_signing_time,
  126. </if>
  127. <if test="firstSigningTime != null">
  128. first_signing_time,
  129. </if>
  130. <if test="followDep != null">
  131. follow_dep,
  132. </if>
  133. <if test="followExplain != null">
  134. follow_explain,
  135. </if>
  136. <if test="followAname != null">
  137. follow_aname,
  138. </if>
  139. <if test="followAid != null">
  140. follow_aid,
  141. </if>
  142. </trim>
  143. <trim prefix="values (" suffix=")" suffixOverrides=",">
  144. <if test="uid != null">
  145. #{uid,jdbcType=VARCHAR},
  146. </if>
  147. <if test="aid != null">
  148. #{aid,jdbcType=VARCHAR},
  149. </if>
  150. <if test="lastFollowTime != null">
  151. #{lastFollowTime,jdbcType=TIMESTAMP},
  152. </if>
  153. <if test="lastSignTime != null">
  154. #{lastSignTime,jdbcType=TIMESTAMP},
  155. </if>
  156. <if test="createTime != null">
  157. #{createTime,jdbcType=TIMESTAMP},
  158. </if>
  159. <if test="bigCustomer != null">
  160. #{bigCustomer,jdbcType=INTEGER},
  161. </if>
  162. <if test="updateAid != null">
  163. #{updateAid,jdbcType=VARCHAR},
  164. </if>
  165. <if test="updateName != null">
  166. #{updateName,jdbcType=VARCHAR},
  167. </if>
  168. <if test="dateUpdateTime != null">
  169. #{dateUpdateTime,jdbcType=TIMESTAMP},
  170. </if>
  171. <if test="channelType != null">
  172. #{channelType,jdbcType=INTEGER},
  173. </if>
  174. <if test="chargeback != null">
  175. #{chargeback,jdbcType=INTEGER},
  176. </if>
  177. <if test="member != null">
  178. #{member,jdbcType=INTEGER},
  179. </if>
  180. <if test="lastSalesType != null">
  181. #{lastSalesType,jdbcType=INTEGER},
  182. </if>
  183. <if test="lastFollowType != null">
  184. #{lastFollowType,jdbcType=INTEGER},
  185. </if>
  186. <if test="followNumber != null">
  187. #{followNumber,jdbcType=INTEGER},
  188. </if>
  189. <if test="taskNames != null">
  190. #{taskNames,jdbcType=VARCHAR},
  191. </if>
  192. <if test="signNumber != null">
  193. #{signNumber,jdbcType=INTEGER},
  194. </if>
  195. <if test="signAmount != null">
  196. #{signAmount,jdbcType=DECIMAL},
  197. </if>
  198. <if test="lastSigningTime != null">
  199. #{lastSigningTime,jdbcType=DATE},
  200. </if>
  201. <if test="firstSigningTime != null">
  202. #{firstSigningTime,jdbcType=DATE},
  203. </if>
  204. <if test="followDep != null">
  205. #{followDep,jdbcType=VARCHAR},
  206. </if>
  207. <if test="followExplain != null">
  208. #{followExplain,jdbcType=VARCHAR},
  209. </if>
  210. <if test="followAname != null">
  211. #{followAname,jdbcType=VARCHAR},
  212. </if>
  213. <if test="followAid != null">
  214. #{followAid,jdbcType=VARCHAR},
  215. </if>
  216. </trim>
  217. </insert>
  218. <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.UserMid">
  219. update user_mid
  220. <set>
  221. <if test="uid != null">
  222. `uid` = #{uid,jdbcType=VARCHAR},
  223. </if>
  224. <if test="aid != null">
  225. aid = #{aid,jdbcType=VARCHAR},
  226. </if>
  227. <if test="lastFollowTime != null">
  228. last_follow_time = #{lastFollowTime,jdbcType=TIMESTAMP},
  229. </if>
  230. <if test="lastSignTime != null">
  231. last_sign_time = #{lastSignTime,jdbcType=TIMESTAMP},
  232. </if>
  233. <if test="createTime != null">
  234. create_time = #{createTime,jdbcType=TIMESTAMP},
  235. </if>
  236. <if test="bigCustomer != null">
  237. big_customer = #{bigCustomer,jdbcType=INTEGER},
  238. </if>
  239. <if test="updateAid != null">
  240. update_aid = #{updateAid,jdbcType=VARCHAR},
  241. </if>
  242. <if test="updateName != null">
  243. update_name = #{updateName,jdbcType=VARCHAR},
  244. </if>
  245. <if test="dateUpdateTime != null">
  246. date_update_time = #{dateUpdateTime,jdbcType=TIMESTAMP},
  247. </if>
  248. <if test="channelType != null">
  249. channel_type = #{channelType,jdbcType=INTEGER},
  250. </if>
  251. <if test="chargeback != null">
  252. chargeback = #{chargeback,jdbcType=INTEGER},
  253. </if>
  254. <if test="member != null">
  255. `member` = #{member,jdbcType=INTEGER},
  256. </if>
  257. <if test="lastSalesType != null">
  258. last_sales_type = #{lastSalesType,jdbcType=INTEGER},
  259. </if>
  260. <if test="lastFollowType != null">
  261. last_follow_type = #{lastFollowType,jdbcType=INTEGER},
  262. </if>
  263. <if test="followNumber != null">
  264. follow_number = #{followNumber,jdbcType=INTEGER},
  265. </if>
  266. <if test="taskNames != null">
  267. task_names = #{taskNames,jdbcType=VARCHAR},
  268. </if>
  269. <if test="signNumber != null">
  270. sign_number = #{signNumber,jdbcType=INTEGER},
  271. </if>
  272. <if test="signAmount != null">
  273. sign_amount = #{signAmount,jdbcType=DECIMAL},
  274. </if>
  275. <if test="lastSigningTime != null">
  276. last_signing_time = #{lastSigningTime,jdbcType=DATE},
  277. </if>
  278. <if test="firstSigningTime != null">
  279. first_signing_time = #{firstSigningTime,jdbcType=DATE},
  280. </if>
  281. <if test="followDep != null">
  282. follow_dep = #{followDep,jdbcType=VARCHAR},
  283. </if>
  284. <if test="followExplain != null">
  285. follow_explain = #{followExplain,jdbcType=VARCHAR},
  286. </if>
  287. <if test="followAname != null">
  288. follow_aname = #{followAname,jdbcType=VARCHAR},
  289. </if>
  290. <if test="followAid != null">
  291. follow_aid = #{followAid,jdbcType=VARCHAR},
  292. </if>
  293. </set>
  294. where id = #{id,jdbcType=INTEGER}
  295. </update>
  296. <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.UserMid">
  297. update user_mid
  298. set `uid` = #{uid,jdbcType=VARCHAR},
  299. aid = #{aid,jdbcType=VARCHAR},
  300. last_follow_time = #{lastFollowTime,jdbcType=TIMESTAMP},
  301. last_sign_time = #{lastSignTime,jdbcType=TIMESTAMP},
  302. create_time = #{createTime,jdbcType=TIMESTAMP},
  303. big_customer = #{bigCustomer,jdbcType=INTEGER},
  304. update_aid = #{updateAid,jdbcType=VARCHAR},
  305. update_name = #{updateName,jdbcType=VARCHAR},
  306. date_update_time = #{dateUpdateTime,jdbcType=TIMESTAMP},
  307. channel_type = #{channelType,jdbcType=INTEGER},
  308. chargeback = #{chargeback,jdbcType=INTEGER},
  309. `member` = #{member,jdbcType=INTEGER},
  310. last_sales_type = #{lastSalesType,jdbcType=INTEGER},
  311. last_follow_type = #{lastFollowType,jdbcType=INTEGER},
  312. follow_number = #{followNumber,jdbcType=INTEGER},
  313. task_names = #{taskNames,jdbcType=VARCHAR},
  314. sign_number = #{signNumber,jdbcType=INTEGER},
  315. sign_amount = #{signAmount,jdbcType=DECIMAL},
  316. last_signing_time = #{lastSigningTime,jdbcType=DATE},
  317. first_signing_time = #{firstSigningTime,jdbcType=DATE},
  318. follow_dep = #{followDep,jdbcType=VARCHAR},
  319. follow_explain = #{followExplain,jdbcType=VARCHAR},
  320. follow_aname = #{followAname,jdbcType=VARCHAR},
  321. follow_aid = #{followAid,jdbcType=VARCHAR}
  322. where id = #{id,jdbcType=INTEGER}
  323. </update>
  324. <update id="updateByUid" parameterType="com.goafanti.common.model.UserMid">
  325. update user_mid
  326. <set>
  327. <if test="aid != null">
  328. aid = #{aid,jdbcType=VARCHAR},
  329. </if>
  330. <if test="lastFollowTime != null">
  331. last_follow_time = #{lastFollowTime,jdbcType=TIMESTAMP},
  332. </if>
  333. <if test="lastSignTime != null">
  334. last_sign_time = #{lastSignTime,jdbcType=TIMESTAMP},
  335. </if>
  336. <if test="createTime != null">
  337. create_time = #{createTime,jdbcType=TIMESTAMP},
  338. </if>
  339. <if test="bigCustomer != null">
  340. big_customer = #{bigCustomer,jdbcType=INTEGER},
  341. </if>
  342. <if test="updateAid != null">
  343. update_aid = #{updateAid,jdbcType=VARCHAR},
  344. </if>
  345. <if test="updateName != null">
  346. update_name = #{updateName,jdbcType=VARCHAR},
  347. </if>
  348. <if test="dateUpdateTime != null">
  349. date_update_time = #{dateUpdateTime,jdbcType=TIMESTAMP},
  350. </if>
  351. <if test="channelType != null">
  352. channel_type = #{channelType,jdbcType=INTEGER},
  353. </if>
  354. <if test="chargeback != null">
  355. chargeback = #{chargeback,jdbcType=INTEGER},
  356. </if>
  357. <if test="member != null">
  358. `member` = #{member,jdbcType=INTEGER},
  359. </if>
  360. <if test="lastSalesType != null">
  361. last_sales_type = #{lastSalesType,jdbcType=INTEGER},
  362. </if>
  363. <if test="lastFollowType != null">
  364. last_follow_type = #{lastFollowType,jdbcType=INTEGER},
  365. </if>
  366. <if test="followNumber != null">
  367. follow_number = #{followNumber,jdbcType=INTEGER},
  368. </if>
  369. <if test="taskNames != null">
  370. task_names = #{taskNames,jdbcType=VARCHAR},
  371. </if>
  372. <if test="signNumber != null">
  373. sign_number = #{signNumber,jdbcType=INTEGER},
  374. </if>
  375. <if test="signAmount != null">
  376. sign_amount = #{signAmount,jdbcType=DECIMAL},
  377. </if>
  378. <if test="lastSigningTime != null">
  379. last_signing_time = #{lastSigningTime,jdbcType=DATE},
  380. </if>
  381. <if test="firstSigningTime != null">
  382. first_signing_time = #{firstSigningTime,jdbcType=DATE},
  383. </if>
  384. <if test="followDep != null">
  385. follow_dep = #{followDep,jdbcType=VARCHAR},
  386. </if>
  387. <if test="followExplain != null">
  388. follow_explain = #{followExplain,jdbcType=VARCHAR},
  389. </if>
  390. <if test="followAname != null">
  391. follow_aname = #{followAname,jdbcType=VARCHAR},
  392. </if>
  393. <if test="followAid != null">
  394. follow_aid = #{followAid,jdbcType=VARCHAR},
  395. </if>
  396. </set>
  397. where `uid` = #{uid,jdbcType=VARCHAR}
  398. </update>
  399. <update id="updateListByUid" parameterType="com.goafanti.common.model.UserMid">
  400. update user_mid
  401. <set>
  402. <if test="aid != null">
  403. aid = #{aid,jdbcType=VARCHAR},
  404. </if>
  405. <if test="updateFollow ==1">
  406. last_follow_time = null,
  407. </if>
  408. <if test="lastSignTime != null">
  409. last_sign_time = #{lastSignTime,jdbcType=TIMESTAMP},
  410. </if>
  411. <if test="createTime != null">
  412. create_time = #{createTime,jdbcType=TIMESTAMP},
  413. </if>
  414. <if test="bigCustomer != null">
  415. big_customer = #{bigCustomer,jdbcType=INTEGER},
  416. </if>
  417. <if test="updateAid != null">
  418. update_aid = #{updateAid,jdbcType=VARCHAR},
  419. </if>
  420. <if test="updateName != null">
  421. update_name = #{updateName,jdbcType=VARCHAR},
  422. </if>
  423. <if test="dateUpdateTime != null">
  424. date_update_time = #{dateUpdateTime,jdbcType=TIMESTAMP},
  425. </if>
  426. </set>
  427. where `uid` in
  428. <foreach item="item" collection="list" separator="," open="(" close=")" index="">
  429. #{item}
  430. </foreach>
  431. </update>
  432. <select id="getUserTaskNames" resultType="java.lang.String">
  433. select group_concat(distinct b.commodity_name)task_names from t_order_new a
  434. left join t_order_task b on a.order_no =b.order_no
  435. where a.buyer_id = #{uid}
  436. group by a.buyer_id
  437. </select>
  438. <select id="getUserDtails" resultType="com.goafanti.common.model.UserMid">
  439. select a.buyer_id uid,min(a.sign_time)firstSigningTime,max(a.sign_time)lastSigningTime,
  440. sum(a.total_amount)signAmount,count(*)signNumber
  441. from t_order_new a
  442. where a.delete_sign in (0,2) and a.process_status >4
  443. and a.buyer_id= #{uid}
  444. group by a.buyer_id
  445. </select>
  446. <select id="selectSignSummaryList" resultType="com.goafanti.order.bo.OutSignSummary">
  447. select a.id ,a.nickname ,b.sign_number signNumber,b.sign_amount signAmount,
  448. date_format(b.first_signing_time ,'%Y-%m-%d') firstSigningTime,
  449. date_format(b.last_signing_time ,'%Y-%m-%d') lastSigningTime ,
  450. b.last_sales_type lastSalesType,c.name,d.name depName,
  451. b.last_follow_type lastFollowType,b.follow_explain followExplain ,b.follow_number followNumber ,
  452. date_format(b.last_follow_time ,'%Y-%m-%d %H:%i:%S') lastFollowTime ,b.task_names taskNames ,
  453. b.`member` ,b.chargeback ,b.big_customer bigCustomer,b.follow_aname followAname
  454. from user a left join user_mid b on a.id=b.uid left join admin c on a.aid=c.id
  455. left join department d on c.department_id =d.id
  456. where a.share_type =2
  457. <if test="userName != null">
  458. and a.nickname like concat('%',#{userName},'%')
  459. </if>
  460. <if test="aid != null">
  461. and c.id =#{aid}
  462. </if>
  463. <if test="followAid != null">
  464. and b.follow_aid =#{followAid}
  465. </if>
  466. <if test="member != null">
  467. and b.`member` = #{member}
  468. </if>
  469. <if test="chargeback != null">
  470. and b.chargeback = #{chargeback}
  471. </if>
  472. <if test="bigCustomer != null">
  473. and b.big_customer = #{bigCustomer}
  474. </if>
  475. <if test="lastFollowType != null">
  476. and b.last_follow_type = #{lastFollowType}
  477. </if>
  478. <if test="depId != null">
  479. and c.department_id = #{depId}
  480. </if>
  481. <if test="lastFollowTimeStart != null and lastFollowTimeEnd !=null">
  482. and b.last_follow_time BETWEEN #{lastFollowTimeStart} and #{lastFollowTimeEnd}
  483. </if>
  484. <if test="firstSigningTimeStart != null and firstSigningTimeEnd !=null">
  485. and b.first_signing_time BETWEEN #{firstSigningTimeStart} and #{firstSigningTimeEnd}
  486. </if>
  487. <if test="lastSigningTimeStart != null and lastSigningTimeStart !=null">
  488. and b.last_signing_time BETWEEN #{lastSigningTimeStart} and #{lastSigningTimeEnd}
  489. </if>
  490. <if test="signNumber != null">
  491. and b.sign_number = #{signNumber}
  492. </if>
  493. <if test="lastSalesType != null">
  494. and b.last_sales_type = #{lastSalesType}
  495. </if>
  496. <if test="page_sql!=null">
  497. ${page_sql}
  498. </if>
  499. </select>
  500. <select id="selectSignSummaryCount" resultType="integer">
  501. select count(*)
  502. from user a left join user_mid b on a.id=b.uid left join admin c on a.aid=c.id
  503. where a.share_type = 2
  504. <if test="userName != null">
  505. and a.nickname like concat('%',#{userName},'%')
  506. </if>
  507. <if test="aid != null">
  508. and c.id =#{aid}
  509. </if>
  510. <if test="followAid != null">
  511. and b.follow_aid =#{followAid}
  512. </if>
  513. <if test="member != null">
  514. and b.`member` = #{member}
  515. </if>
  516. <if test="chargeback != null">
  517. and b.chargeback = #{chargeback}
  518. </if>
  519. <if test="bigCustomer != null">
  520. and b.big_customer = #{bigCustomer}
  521. </if>
  522. <if test="lastFollowType != null">
  523. and b.last_follow_type = #{lastFollowType}
  524. </if>
  525. <if test="depId != null">
  526. and c.department_id = #{depId}
  527. </if>
  528. <if test="lastFollowTimeStart != null and lastFollowTimeEnd !=null">
  529. and b.last_follow_time BETWEEN #{lastFollowTimeStart} and #{lastFollowTimeEnd}
  530. </if>
  531. <if test="firstSigningTimeStart != null and firstSigningTimeEnd !=null">
  532. and b.first_signing_time BETWEEN #{firstSigningTimeStart} and #{firstSigningTimeEnd}
  533. </if>
  534. <if test="lastSigningTimeStart != null and lastSigningTimeStart !=null">
  535. and b.last_signing_time BETWEEN #{lastSigningTimeStart} and #{lastSigningTimeEnd}
  536. </if>
  537. <if test="signNumber != null">
  538. and b.sign_number = #{signNumber}
  539. </if>
  540. <if test="lastSalesType != null">
  541. and b.last_sales_type = #{lastSalesType}
  542. </if>
  543. </select>
  544. <select id="selectsignStatisticsList" resultType="com.goafanti.order.bo.OutSignStatistics">
  545. select a.id, a.name, userCount, orderCount, totalAmount, newSignNumber, repeatSignNumber, channelSignNumber,
  546. (newSignNumber/orderCount)newRatio,(repeatSignNumber/orderCount)repeatRatio,(channelSignNumber/orderCount)channelRatio
  547. from admin a
  548. left join user_role ur on ur.uid =a.id left join `role` r on r.id=ur.rid
  549. left join ( select x.aid,count(id) userCount, sum(x.orderCount)orderCount,sum(x.totalAmount)totalAmount,
  550. sum(x.newSignNumber)newSignNumber,sum(x.repeatSignNumber)repeatSignNumber,
  551. sum(x.channelSignNumber)channelSignNumber
  552. from ( select b.aid,b.id,count(*)orderCount ,sum(a.total_amount) totalAmount ,
  553. sum(if(a.sales_type &lt; 3 || (a.sales_type &gt; 3 &amp;&amp; a.sales_type &lt; 6),1,0 ))newSignNumber,
  554. sum(if(a.sales_type=3,1,0 ))channelSignNumber,sum(if(a.sales_type &gt; 5,1,0 ))repeatSignNumber
  555. from t_order_new a left join user b on b.id=a.buyer_id
  556. where a.process_status &gt;4 and b.share_type =2 and a.delete_sign in(0,2)
  557. <if test="signTimeStart != null and signTimeEnd!=null">
  558. and a.sign_time BETWEEN #{signTimeStart} and #{signTimeEnd}
  559. </if>
  560. group by b.aid,b.id)x group by x.aid)y on y.aid=a.id
  561. where a.status= 0 and r.role_type in (96,996)
  562. <if test="aid != null">
  563. and a.id= #{aid}
  564. </if>
  565. <if test="deps != null">
  566. and a.department_id in
  567. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  568. #{depId}
  569. </foreach>
  570. </if>
  571. <if test="amountType != null">
  572. <if test="amountType == 1">
  573. and ( totalAmount &lt; 10 or totalAmount is null)
  574. </if>
  575. <if test="amountType == 2">
  576. and totalAmount BETWEEN 10 and 20
  577. </if>
  578. <if test="amountType == 3">
  579. and totalAmount BETWEEN 20 and 30
  580. </if>
  581. <if test="amountType == 4">
  582. and totalAmount &gt; 30
  583. </if>
  584. </if>
  585. <if test="page_sql!=null">
  586. ${page_sql}
  587. </if>
  588. </select>
  589. <select id="selectsignStatisticsCount" resultType="integer">
  590. select count(*)
  591. from admin a left join user_role ur on ur.uid =a.id left join `role` r on r.id=ur.rid
  592. left join (select b.aid,sum(a.total_amount) totalAmount
  593. from t_order_new a left join user b on b.id=a.buyer_id
  594. where a.process_status >4 and b.share_type =2 and a.delete_sign in(0,2)
  595. group by b.aid)x on a.id=x.aid
  596. where a.status= 0 and r.role_type in (96,996)
  597. <if test="aid != null">
  598. and a.id= #{aid}
  599. </if>
  600. <if test="deps != null">
  601. and a.department_id in
  602. <foreach close=")" collection="deps" item="depId" open="(" separator=",">
  603. #{depId}
  604. </foreach>
  605. </if>
  606. <if test="amountType != null">
  607. <if test="amountType == 1">
  608. and ( totalAmount &lt; 10 or totalAmount is null)
  609. </if>
  610. <if test="amountType == 2">
  611. and totalAmount BETWEEN 10 and 20
  612. </if>
  613. <if test="amountType == 3">
  614. and totalAmount BETWEEN 20 and 30
  615. </if>
  616. <if test="amountType == 4">
  617. and totalAmount &gt; 30
  618. </if>
  619. </if>
  620. </select>
  621. <select id="selectsignStatisticsOrderList" resultType="com.goafanti.order.bo.TOrderNewBo">
  622. 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,
  623. a.contract_no as contractNo, b.nickname as userName ,a.process_status as processStatus,a.total_amount as totalAmount,
  624. a.order_status as orderStatus, a.liquidation_status as liquidationStatus,a.approval,c.salesman_name as salesmanName,c.project_type projectType,
  625. dep.name as depName,c.finance_name as financeName,c.invoice_amount invoiceAmount,a.settlement_amount settlementAmount,
  626. a.sales_type salesType, a.channel_id channelId ,a.other
  627. 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
  628. left join department dep on a.order_dep=dep.id
  629. where a.process_status &gt;4 and b.share_type =2 and a.delete_sign in(0,2)
  630. <if test="amountType != null">
  631. <if test="amountType == 1">
  632. and a.total_amount &lt; 10
  633. </if>
  634. <if test="amountType == 2">
  635. and a.total_amount BETWEEN 10 and 20
  636. </if>
  637. <if test="amountType == 3">
  638. and a.total_amount BETWEEN 20 and 30
  639. </if>
  640. <if test="amountType == 4">
  641. and a.total_amount &gt; 30
  642. </if>
  643. </if>
  644. <if test="signTimeStart != null and signTimeEnd!=null">
  645. and a.sign_time BETWEEN #{signTimeStart} and #{signTimeEnd}
  646. </if>
  647. <if test="aid !=null">
  648. and b.aid= #{aid}
  649. </if>
  650. <if test="uid !=null">
  651. and b.id= #{uid}
  652. </if>
  653. <if test="orderType !=null">
  654. <if test="orderType ==1">
  655. and(a.sales_type &lt; 3 or (a.sales_type &gt; 3 and a.sales_type &lt; 6))
  656. </if>
  657. <if test="orderType ==2">
  658. and a.sales_type &gt; 5
  659. </if>
  660. <if test="orderType ==3">
  661. and a.sales_type=3
  662. </if>
  663. </if>
  664. order by a.create_time desc
  665. <if test="page_sql!=null">
  666. ${page_sql}
  667. </if>
  668. </select>
  669. <select id="selectsignStatisticsOrderCount" resultType="integer">
  670. select count(*)
  671. 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
  672. left join department dep on a.order_dep=dep.id
  673. where a.process_status &gt;4 and b.share_type =2 and a.delete_sign in(0,2)
  674. <if test="amountType != null">
  675. <if test="amountType == 1">
  676. and a.total_amount &lt; 10
  677. </if>
  678. <if test="amountType == 2">
  679. and a.total_amount BETWEEN 10 and 20
  680. </if>
  681. <if test="amountType == 3">
  682. and a.total_amount BETWEEN 20 and 30
  683. </if>
  684. <if test="amountType == 4">
  685. and a.total_amount &gt; 30
  686. </if>
  687. </if>
  688. <if test="signTimeStart != null and signTimeEnd!=null">
  689. and a.sign_time BETWEEN #{signTimeStart} and #{signTimeEnd}
  690. </if>
  691. <if test="aid !=null">
  692. and b.aid= #{aid}
  693. </if>
  694. <if test="uid !=null">
  695. and b.id= #{uid}
  696. </if>
  697. <if test="orderType !=null">
  698. <if test="orderType ==1">
  699. and(a.sales_type &lt; 3 or (a.sales_type &gt; 3 and a.sales_type &lt; 6))
  700. </if>
  701. <if test="orderType ==2">
  702. and a.sales_type &gt; 5
  703. </if>
  704. <if test="orderType ==3">
  705. and a.sales_type=3
  706. </if>
  707. </if>
  708. </select>
  709. <select id="selectStatisticsOrderProjectList" resultType="com.goafanti.order.bo.OutOrderProject">
  710. SELECT a.order_no as orderNo, a.order_type orderType,a.sales_type as salesType, b.service_type AS serviceType,
  711. a.liquidation_status as liquidationStatus,b2.big_customer as bigCustomer,b.project_type as projectType,
  712. a.total_amount as totalAmount,a.approval ,a.sign_time as signTime,date_format(a.create_time ,'%Y-%m-%d %H:%i:%S') as createTime,
  713. b.buyer_name as buyerName,a.contract_no as contractNo, c.cname htlx,b.province_name province ,b.dep_name depName,
  714. b.order_receivables orderReceivables,a.refund_amount refundAmount,a.settlement_amount as settlementAmount,
  715. b.invoice_amount as invicueAmount, b.cost_amount as costAmount,b.payment_amount as paymentAmount,
  716. b.finance_name as financeName,b.salesman_name as salesmanName,b.expense_amount as expenseAmount,
  717. e.commodity_name as commodityName,ttm.service_year as serviceYear,ttm.service_life as serviceLife,ttm.year_sum as yearSum,
  718. date_format(e.task_distribution_time ,'%Y-%m-%d %H:%i:%S') as taskDistributionTime ,e.commodity_quantity as commodityQuantity,
  719. e3.cost_amount as costAmount,e.project_status as projectStatus,e.task_start_time as taskStartTime,e.task_end_time as taskEndTime,
  720. e.receiver_name as receiverName ,'技术组' jsz,a.order_status orderStatus,e.satisfaction_degree satisfactionDegree,
  721. e.task_comment taskComment,'核算比例' hsbl,a.order_status orderStatus,
  722. b.change_count changeType, b.restatement_count restatementType,b.refund_count refundType
  723. from t_order_new a
  724. left join t_order_mid b on a.order_no =b.order_no
  725. left join t_order_task c on a.order_no =c.order_no and c.main =1
  726. left join user_mid b2 on a.buyer_id=b2.uid
  727. left join t_order_task e on a.order_no =e.order_no and e.split_status in (0,2)
  728. <if test="liabilitiesDepId !=null">
  729. left join admin e2 on e.task_receiver=e2.id
  730. </if>
  731. left join t_task_mid e3 on e.id=e3.tid
  732. left join t_task_member ttm on e.id =ttm.tid
  733. <if test="dunType !=null">
  734. left join new_order_dun nod on e.id=nod.tid
  735. </if>
  736. <if test="province !=null">
  737. left join admin p1 on a.salesman_id=p1.id left join department p2 on p1.department_id=p2.id
  738. </if>
  739. where a.process_status >6 and a.delete_sign in (0,2)
  740. <include refid="selectStatisticsOrderProjectSql"/>
  741. <if test="page_sql!=null">
  742. ${page_sql}
  743. </if>
  744. </select>
  745. <sql id="selectStatisticsOrderProjectSql">
  746. <if test="orderNo !=null">
  747. and a.order_no like CONCAT('%',#{orderNo},'%')
  748. </if>
  749. <if test="contractNo !=null">
  750. and a.contract_no like CONCAT('%',#{contractNo},'%')
  751. </if>
  752. <if test="userName !=null">
  753. and b.buyer_name like CONCAT('%',#{userName},'%')
  754. </if>
  755. <if test="businessCategory !=null">
  756. and d2.id = #{businessCategory}
  757. </if>
  758. <if test="projectName !=null">
  759. and e.commodity_name like CONCAT('%',#{projectName},'%')
  760. </if>
  761. <if test="orderAmountType==1">
  762. and a.total_amount &lt; 10
  763. </if>
  764. <if test="orderAmountType==2">
  765. and a.total_amount &gt;= 10 and a.total_amount &lt; 20
  766. </if>
  767. <if test="orderAmountType==3">
  768. and a.total_amount &gt;= 20 and a.total_amount &lt; 30
  769. </if>
  770. <if test="orderAmountType==4">
  771. and a.total_amount &gt;= 30 and a.total_amount &lt; 40
  772. </if>
  773. <if test="orderAmountType==5">
  774. and a.total_amount &gt;= 40
  775. </if>
  776. <if test="depId !=null">
  777. and a.order_dep = #{depId}
  778. </if>
  779. <if test="liabilitiesDepId !=null">
  780. and e2.department_id = #{liabilitiesDepId}
  781. </if>
  782. <if test="declarationBatch !=null">
  783. and e.declaration_batch = #{declarationBatch}
  784. </if>
  785. <if test="projectAmountType==1">
  786. and e.commodity_price &lt; 1
  787. </if>
  788. <if test="projectAmountType==2">
  789. and e.commodity_price &gt;= 1 and e.commodity_price &lt; 5
  790. </if>
  791. <if test="projectAmountType==3">
  792. and e.commodity_price &gt;= 5 and e.commodity_price &lt; 10
  793. </if>
  794. <if test="projectAmountType==4">
  795. and e.commodity_price &gt;= 10 and e.commodity_price &lt; 20
  796. </if>
  797. <if test="projectAmountType==5">
  798. and e.commodity_price &gt;= 20
  799. </if>
  800. <if test="projectStatus !=null">
  801. and e.project_status = #{projectStatus}
  802. </if>
  803. <if test="satisfactionDegree !=null">
  804. and e.satisfaction_degree = #{satisfactionDegree}
  805. </if>
  806. <if test="startDate !=null and endDate !=null">
  807. and a.create_time BETWEEN #{startDate} and #{endDate}
  808. </if>
  809. <if test="signStartDate !=null and signEndDate !=null">
  810. and a.sign_time BETWEEN #{signStartDate} and #{signEndDate}
  811. </if>
  812. <if test="projectStartDate !=null and projectEndDate !=null">
  813. and e.task_distribution_time BETWEEN #{projectStartDate} and #{projectEndDate}
  814. </if>
  815. <if test="salesType !=null">
  816. and a.sales_type = #{salesType}
  817. </if>
  818. <if test="serviceType !=null">
  819. and find_in_set(b.service_type,#{serviceType})
  820. </if>
  821. <if test="liquidationStatus !=null">
  822. and a.liquidation_status = #{liquidationStatus}
  823. </if>
  824. <if test="dunType !=null">
  825. and nod.status = #{dunType}
  826. </if>
  827. <if test="province !=null">
  828. and p2.province = #{province}
  829. </if>
  830. <if test="salesmanId !=null">
  831. and a.salesman_id = #{salesmanId}
  832. </if>
  833. <if test="financeId !=null">
  834. and a.finance_id = #{financeId}
  835. </if>
  836. <if test="techId !=null">
  837. and e.task_receiver =#{techId}
  838. </if>
  839. <if test="approval ==0">
  840. and a.approval = 0
  841. </if>
  842. <if test="approval ==1">
  843. and a.approval > 0
  844. </if>
  845. <if test="projectType !=null">
  846. and b.project_type = #{projectType}
  847. </if>
  848. <if test="bigCustomer !=null">
  849. and b2.big_customer = #{bigCustomer}
  850. </if>
  851. <if test="restatement ==0">
  852. and b.restatement_count = 0
  853. </if>
  854. <if test="restatement ==1">
  855. and b.restatement_count > 0
  856. </if>
  857. <if test="changeCount ==0">
  858. and b.change_count =0
  859. </if>
  860. <if test="changeType ==1">
  861. and b.change_count >0
  862. </if>
  863. <if test="refundType ==0">
  864. and b.refund_count=0
  865. </if>
  866. <if test="refundType ==1">
  867. and b.refund_count >0
  868. </if>
  869. <if test="orderType ==0">
  870. and a.order_type in(0,2)
  871. </if>
  872. <if test="orderType ==1">
  873. and a.order_type in(1)
  874. </if>
  875. <if test="projectCompleteStartTime !=null and projectCompleteEndTime !=null">
  876. and e.complete_date BETWEEN #{projectCompleteStartTime} and #{projectCompleteEndTime}
  877. </if>
  878. </sql>
  879. <select id="selectStatisticsOrderProjectCount" resultType="java.lang.Integer">
  880. SELECT count(*)
  881. from t_order_new a
  882. left join t_order_mid b on a.order_no =b.order_no
  883. left join t_order_task c on a.order_no =c.order_no and c.main =1
  884. left join user_mid b2 on a.buyer_id=b2.uid
  885. left join t_order_task e on a.order_no =e.order_no and e.split_status in (0,2)
  886. left join t_task_mid e3 on e.id=e3.tid
  887. left join t_task_member ttm on e.id =ttm.tid
  888. <if test="dunType !=null">
  889. left join new_order_dun nod on e.id=nod.tid
  890. </if>
  891. <if test="province !=null">
  892. left join admin p1 on a.salesman_id=p1.id left join department p2 on p1.department_id=p2.id
  893. </if>
  894. where a.process_status >6 and a.delete_sign in (0,2)
  895. <include refid="selectStatisticsOrderProjectSql"/>
  896. </select>
  897. </mapper>