NewCmClubMapper.xml 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176
  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.caimei.modules.user.dao.NewCmClubDao">
  4. <sql id="newCmClubColumns">
  5. a.checkMan as "checkMan",
  6. a.clubID AS "clubID",
  7. a.userID AS "userID",
  8. u.name AS "name",
  9. a.sname AS "sname",
  10. a.logo AS "logo",
  11. a.legalPerson AS "legalPerson",
  12. a.provinceID AS "provinceID",
  13. a.cityID AS "cityID",
  14. a.townID AS "townID",
  15. a.flag AS "flag",
  16. a.inviterBindID AS "inviterBindID",
  17. a.inviterName AS "inviterName",
  18. a.spID AS "spID",
  19. a.mainServiceProviderID AS "mainServiceProviderID",
  20. a.scanTime AS "scanTime",
  21. a.address AS "address",
  22. a.linkMan AS "linkMan",
  23. a.linkManIdentity AS "linkManIdentity",
  24. a.contractPhone AS "contractPhone",
  25. a.contractMobile AS "contractMobile",
  26. a.contractEmail AS "contractEmail",
  27. a.fax AS "fax",
  28. a.info AS "info",
  29. a.addTime AS "addTime",
  30. a.auditTime AS "auditTime",
  31. a.auditNote AS "auditNote",
  32. a.status AS "status",
  33. a.businessLicenseImage AS "businessLicenseImage",
  34. a.defaultServiceProviderID AS "defaultServiceProviderID",
  35. a.defaultServiceProviderUpdTime AS "defaultServiceProviderUpdTime",
  36. a.mainpro AS "mainpro",
  37. a.scanFlag AS "scanFlag",
  38. a.headpic AS "headpic",
  39. a.socialCreditCode AS "socialCreditCode",
  40. a.lastModify AS "lastModify",
  41. a.firstClubType AS "firstClubType",
  42. a.secondClubType AS "secondClubType",
  43. a.department AS "department",
  44. a.medicalPracticeLicenseImg AS "medicalPracticeLicenseImg",
  45. a.newDeal as "newDeal"
  46. </sql>
  47. <sql id="otherColumns">
  48. ,case sp.status when 91 then '采美默认协销经理(官方账号)' else sp.linkMan end AS "spName",
  49. d.name AS "province",
  50. c.name AS "city",
  51. b.name AS "town",
  52. u.account AS "account",
  53. u.registerTime AS "registerTime",
  54. u.registerIP AS "registerIP",
  55. u.userName AS "userName",
  56. u.bindMobile AS "bindMobile",
  57. u.email AS "email",
  58. u.userOrganizeID AS "userOrganizeID",
  59. u.userIdentity AS "userIdentity",
  60. if(csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime,1,0) as svipUserFlag
  61. </sql>
  62. <sql id="newCmClubJoins">
  63. LEFT JOIN user u ON u.userID = a.userID
  64. LEFT JOIN cm_svip_user csu ON csu.userId = u.userID
  65. LEFT JOIN serviceprovider sp ON sp.serviceProviderID = a.spID
  66. LEFT JOIN town b ON b.townID=a.townID
  67. LEFT JOIN city c ON c.cityID=a.cityID
  68. LEFT JOIN province d ON d.provinceID=a.provinceID
  69. </sql>
  70. <select id="get" resultType="NewCmClub">
  71. SELECT
  72. <include refid="newCmClubColumns"/>
  73. <include refid="otherColumns"/>
  74. FROM club a
  75. <include refid="newCmClubJoins"/>
  76. WHERE a.clubID = #{id}
  77. </select>
  78. <select id="getclubByUserId" resultType="NewCmClub">
  79. SELECT
  80. <include refid="newCmClubColumns"/>
  81. FROM club a
  82. <include refid="newCmClubJoins"/>
  83. WHERE a.userID = #{userID}
  84. </select>
  85. <select id="textUserValue" resultType="NewCmClub">
  86. SELECT userID as valueID, activeState, customerValue
  87. FROM cm_organ_value_system
  88. WHERE stage = 0
  89. AND delType = 1
  90. </select>
  91. <select id="findList" resultType="NewCmClub">
  92. SELECT
  93. <include refid="newCmClubColumns"/>
  94. <include refid="otherColumns"/>,u.userPermission,u.source, covs.activeState,covs.customerValue
  95. FROM club a
  96. <include refid="newCmClubJoins"/>
  97. LEFT JOIN (SELECT userID, activeState, customerValue FROM cm_organ_value_system WHERE stage = 0 AND delType = 1)
  98. covs ON a.userID = covs.userID
  99. <where>
  100. (u.userOrganizeID IN(0,1) or u.clubStatus != 92)
  101. <if test="clubID != null and clubID != ''">
  102. AND a.clubID = #{clubID}
  103. </if>
  104. <if test="clubID == 0">
  105. AND a.clubID = #{clubID}
  106. </if>
  107. <if test="userID != null and userID != ''">
  108. AND a.userID = #{userID}
  109. </if>
  110. <if test="account != null and account != ''">
  111. AND u.account = #{account}
  112. </if>
  113. <if test="name != null and name != ''">
  114. AND u.name LIKE concat('%',#{name},'%')
  115. </if>
  116. <if test="userName != null and userName != ''">
  117. AND u.userName LIKE concat('%',#{userName},'%')
  118. </if>
  119. <if test="townID != null and townID != ''">
  120. AND d.provinceID = #{provinceID}
  121. </if>
  122. <if test="cityID != null and cityID != ''">
  123. AND c.cityID = #{cityID}
  124. </if>
  125. <if test="townID != null and townID != ''">
  126. AND b.townID = #{townID}
  127. </if>
  128. <if test="status != null and status != ''">
  129. AND a.status = #{status}
  130. </if>
  131. <if test="bindMobile != null and bindMobile != ''">
  132. AND u.bindMobile LIKE concat('%',#{bindMobile},'%')
  133. </if>
  134. <if test="email != null and email != ''">
  135. AND u.email LIKE concat('%',#{email},'%')
  136. </if>
  137. <if test="linkMan != null and linkMan != ''">
  138. AND a.linkMan LIKE concat('%',#{linkMan},'%')
  139. </if>
  140. <if test="startTime != null and startTime != ''">
  141. AND (u.registerTime &gt; #{startTime} OR u.registerTime = #{startTime})
  142. </if>
  143. <if test="endTime != null and endTime != ''">
  144. AND (u.registerTime &lt; #{endTime} OR u.registerTime = #{endTime})
  145. </if>
  146. <if test="userIdentity != null and userIdentity != '' and userIdentity != '8'.toString()">
  147. AND u.userIdentity = #{userIdentity}
  148. </if>
  149. <if test="userIdentity != null and userIdentity != '' and userIdentity == '8'.toString()">
  150. AND csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
  151. </if>
  152. <if test="newDeal != null">
  153. AND a.newDeal =#{newDeal}
  154. </if>
  155. <if test="activeState != null and activeState != ''">
  156. AND covs.activeState = #{activeState}
  157. </if>
  158. <if test="customerValue != null and customerValue != ''">
  159. AND covs.customerValue = #{customerValue}
  160. </if>
  161. <if test="spID != null and spID != ''">
  162. AND sp.serviceProviderID = #{spID}
  163. </if>
  164. </where>
  165. <choose>
  166. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  167. ORDER BY ${page.orderBy}
  168. </when>
  169. <otherwise>
  170. ORDER BY case when a.status = 91 then 0 else 1 end desc, a.addTime DESC
  171. </otherwise>
  172. </choose>
  173. </select>
  174. <select id="spNameList" resultType="com.caimei.modules.project.model.ServiceProviderModel">
  175. SELECT serviceProviderID, name
  176. FROM serviceprovider
  177. WHERE NAME NOT LIKE concat('%', '测试', '%')
  178. AND validFlag = 1
  179. AND STATUS = 90
  180. </select>
  181. <select id="findAllList" resultType="NewCmClub">
  182. SELECT
  183. <include refid="newCmClubColumns"/>
  184. <include refid="otherColumns"/>
  185. FROM club a
  186. <include refid="newCmClubJoins"/>
  187. <where>
  188. </where>
  189. <choose>
  190. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  191. ORDER BY ${page.orderBy}
  192. </when>
  193. <otherwise>
  194. </otherwise>
  195. </choose>
  196. </select>
  197. <insert id="insert" parameterType="NewCmClub" keyProperty="clubID" useGeneratedKeys="true">
  198. INSERT INTO club(userID,
  199. name,
  200. sname,
  201. logo,
  202. legalPerson,
  203. provinceID,
  204. cityID,
  205. townID,
  206. flag,
  207. inviterBindID,
  208. inviterName,
  209. spID,
  210. mainServiceProviderID,
  211. scanTime,
  212. address,
  213. linkMan,
  214. linkManIdentity,
  215. contractPhone,
  216. contractMobile,
  217. contractEmail,
  218. fax,
  219. info,
  220. addTime,
  221. auditTime,
  222. auditNote,
  223. status,
  224. businessLicenseImage,
  225. defaultServiceProviderID,
  226. defaultServiceProviderUpdTime,
  227. mainpro,
  228. scanFlag,
  229. headpic,
  230. lastModify,
  231. firstClubType,
  232. socialCreditCode,
  233. secondClubType,
  234. department,
  235. medicalPracticeLicenseImg)
  236. VALUES (#{userID},
  237. #{name},
  238. #{sname},
  239. #{logo},
  240. #{legalPerson},
  241. #{provinceID},
  242. #{cityID},
  243. #{townID},
  244. #{flag},
  245. #{inviterBindID},
  246. #{inviterName},
  247. #{spID},
  248. #{mainServiceProviderID},
  249. #{scanTime},
  250. #{address},
  251. #{linkMan},
  252. #{linkManIdentity},
  253. #{contractPhone},
  254. #{contractMobile},
  255. #{contractEmail},
  256. #{fax},
  257. #{info},
  258. #{addTime},
  259. #{auditTime},
  260. #{auditNote},
  261. #{status},
  262. #{businessLicenseImage},
  263. #{defaultServiceProviderID},
  264. #{defaultServiceProviderUpdTime},
  265. #{mainpro},
  266. #{scanFlag},
  267. #{headpic},
  268. #{lastModify},
  269. #{firstClubType},
  270. #{socialCreditCode},
  271. #{secondClubType},
  272. #{department},
  273. #{medicalPracticeLicenseImg})
  274. </insert>
  275. <update id="update">
  276. UPDATE club SET
  277. <if test="checkMan != null and checkMan != ''">
  278. checkMan = #{checkMan},
  279. </if>
  280. <if test="name != null and name != ''">
  281. name = #{name},
  282. </if>
  283. <if test="sname != null">
  284. sname = #{sname},
  285. </if>
  286. <if test="logo != null and logo != ''">
  287. logo = #{logo},
  288. </if>
  289. <if test="legalPerson != null and legalPerson != ''">
  290. legalPerson = #{legalPerson},
  291. </if>
  292. <if test="provinceID != null and provinceID != ''">
  293. provinceID = #{provinceID},
  294. </if>
  295. <if test="cityID != null and cityID != ''">
  296. cityID = #{cityID},
  297. </if>
  298. <if test="townID != null and townID != ''">
  299. townID = #{townID},
  300. </if>
  301. <if test="flag != null and flag != ''">
  302. flag = #{flag},
  303. </if>
  304. <if test="inviterBindID != null and inviterBindID != ''">
  305. inviterBindID = #{inviterBindID},
  306. </if>
  307. <if test="inviterName != null and inviterName != ''">
  308. inviterName = #{inviterName},
  309. </if>
  310. <if test="spID != null and spID != ''">
  311. spID = #{spID},
  312. </if>
  313. <if test="mainServiceProviderID != null and mainServiceProviderID != ''">
  314. mainServiceProviderID = #{mainServiceProviderID},
  315. </if>
  316. <if test="scanTime != null">
  317. scanTime = #{scanTime},
  318. </if>
  319. <if test="address != null and address != ''">
  320. address = #{address},
  321. </if>
  322. <if test="linkMan != null and linkMan != ''">
  323. linkMan = #{linkMan},
  324. </if>
  325. <if test="linkManIdentity != null and linkManIdentity != ''">
  326. linkManIdentity = #{linkManIdentity},
  327. </if>
  328. <if test="contractPhone != null and contractPhone != ''">
  329. contractPhone = #{contractPhone},
  330. </if>
  331. <if test="contractMobile != null and contractMobile != ''">
  332. contractMobile = #{contractMobile},
  333. </if>
  334. <if test="contractEmail != null and contractEmail != ''">
  335. contractEmail = #{contractEmail},
  336. </if>
  337. <if test="fax != null and fax != ''">
  338. fax = #{fax},
  339. </if>
  340. <if test="info != null and info != ''">
  341. info = #{info},
  342. </if>
  343. <if test="addTime != null">
  344. addTime = #{addTime},
  345. </if>
  346. <if test="auditTime != null">
  347. auditTime = #{auditTime},
  348. </if>
  349. <if test="auditNote != null and auditNote != ''">
  350. auditNote = #{auditNote},
  351. </if>
  352. <if test="status != null and status != ''">
  353. status = #{status},
  354. </if>
  355. <if test="businessLicenseImage != null">
  356. businessLicenseImage = #{businessLicenseImage},
  357. </if>
  358. <if test="socialCreditCode != null and socialCreditCode != ''">
  359. socialCreditCode = #{socialCreditCode},
  360. </if>
  361. <if test="defaultServiceProviderID != null and defaultServiceProviderID != ''">
  362. defaultServiceProviderID = #{defaultServiceProviderID},
  363. </if>
  364. <if test="defaultServiceProviderUpdTime != null and defaultServiceProviderUpdTime != ''">
  365. defaultServiceProviderUpdTime = #{defaultServiceProviderUpdTime},
  366. </if>
  367. <if test="mainpro != null and mainpro != ''">
  368. mainpro = #{mainpro},
  369. </if>
  370. <if test="scanFlag != null and scanFlag != ''">
  371. scanFlag = #{scanFlag},
  372. </if>
  373. <if test="headpic != null">
  374. headpic = #{headpic},
  375. </if>
  376. <if test="lastModify != null and lastModify != ''">
  377. lastModify = DATE_FORMAT(#{lastModify},'%Y-%m-%d %H:%i:%s'),
  378. </if>
  379. <if test="firstClubType != null and firstClubType != ''">
  380. firstClubType=#{firstClubType},
  381. </if>
  382. <if test="secondClubType != null and secondClubType != ''">
  383. secondClubType=#{secondClubType},
  384. </if>
  385. <if test="department != null and department != ''">
  386. department=#{department},
  387. </if>
  388. <if test="medicalPracticeLicenseImg != null and medicalPracticeLicenseImg != ''">
  389. medicalPracticeLicenseImg=#{medicalPracticeLicenseImg},
  390. </if>
  391. userID = #{userID}
  392. WHERE clubID = #{clubID}
  393. </update>
  394. <delete id="delete">
  395. DELETE
  396. FROM club
  397. WHERE clubID = #{clubID}
  398. </delete>
  399. <select id="findClubById" resultType="NewCmClub">
  400. SELECT
  401. <include refid="newCmClubColumns"/>
  402. , CONCAT(d.name,c.name ,b.name ,a.`address` ) address
  403. FROM club a
  404. LEFT JOIN user u ON u.userID = a.userID
  405. LEFT JOIN town b ON a.townID =b.townID
  406. LEFT JOIN city c ON b.cityID=c.cityID
  407. JOIN province d ON c.`provinceID` =d.`provinceID`
  408. WHERE a.clubID=#{clubID}
  409. </select>
  410. <select id="findSpId" resultType="java.lang.Integer">
  411. select serviceProviderID
  412. from serviceprovider
  413. where serviceProviderID = #{spID}
  414. and status = 90
  415. </select>
  416. <select id="findRemarksList" resultType="com.caimei.modules.user.entity.CmClubRemarks">
  417. select DISTINCT ccr.id as remarksId,
  418. ccr.remarks,
  419. s.linkMan as spName,
  420. ccr.addTime,
  421. ccr.questionMan,
  422. ccr.consultType as consult,
  423. ccr.clubType,
  424. ccr.pinceSensitve,
  425. ccr.satisfied,
  426. ccr.followup,
  427. ccr.extra,
  428. (SELECT NAME FROM serviceprovider s WHERE s.serviceProviderID = csr.leaderId) AS leaderName
  429. from cm_club_remarks ccr
  430. left join serviceprovider s on ccr.serviceProviderId = s.serviceProviderID
  431. LEFT JOIN cm_serviceteam_group csg ON ccr.serviceProviderId = csg.serviceId
  432. LEFT JOIN cm_serviceteam_role csr ON csr.id = csg.teamId
  433. where clubId = #{clubId}
  434. order by addTime desc
  435. </select>
  436. <select id="getRemarksImageList" resultType="java.lang.String">
  437. select imageUrl
  438. from cm_club_remarks_file
  439. where remarksId = #{remarksId}
  440. and fileType = 1
  441. </select>
  442. <select id="getRemarksFileList" resultType="com.caimei.modules.user.entity.RemarksFileVo">
  443. select fileName, ossName
  444. from cm_club_remarks_file
  445. where remarksId = #{remarksId}
  446. and fileType = 2
  447. </select>
  448. <insert id="insertBeansHistory">
  449. INSERT INTO `user_beans_history` (`userId`, `type`, `beansType`, `orderId`,
  450. `num`, `pushStatus`, `addTime`, delFlag)
  451. VALUES (#{userId}, #{type}, #{beansType}, #{orderId},
  452. #{num}, #{pushStatus}, #{addTime}, 0)
  453. </insert>
  454. <update id="updateByStatus">
  455. UPDATE club
  456. SET status = #{clubStatus}
  457. WHERE userID = #{confirmUserId}
  458. </update>
  459. <select id="findLowOrder" resultType="com.caimei.modules.user.entity.UserBeansHistory">
  460. select userId, type, beansType, orderId, num, addTime
  461. from user_beans_history
  462. where orderId = #{orderId}
  463. and delFlag = 0
  464. and type = 2
  465. and num = 500
  466. </select>
  467. <select id="findRegistList" resultType="com.caimei.modules.user.entity.CmClubRemarks">
  468. SELECT DISTINCT
  469. ccr.id AS remarksId, ccr.remarks,s.linkman AS spName, ccr.addTime,ccr.questionMan,
  470. csr.leaderId AS leaderId,IFNULL(ccr.consultType,'') AS consult, c.Name AS
  471. clubName,ccr.clubType,ccr.pinceSensitve,ccr.satisfied,ccr.followup,ccr.extra,c.newDeal,c.contractMobile,
  472. (SELECT NAME FROM serviceprovider s WHERE s.serviceProviderID= csr.leaderId) AS leaderName,
  473. (SELECT mainImage FROM product p WHERE p.productID= ccre.productID) AS productMainImage,
  474. (SELECT NAME FROM product p WHERE p.productID= ccre.productID) AS proName,
  475. # (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID= ccr.serviceProviderID) AS oldName
  476. ccre.reportText AS reportText,ccre.status AS reportStatus,ccre.auditName AS auditName,ccre.auditTime AS
  477. auditTime,p.mainImage
  478. AS mainImage,p.name AS productName,sh.name AS shopName
  479. FROM cm_club_remarks ccr
  480. LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
  481. LEFT JOIN club c ON c.clubId=ccr.clubId
  482. # LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
  483. LEFT JOIN cm_serviceTeam_group csg ON ccr.serviceProviderId = csg.serviceId
  484. LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
  485. LEFT JOIN cm_club_report ccre ON ccre.Id= ccr.reportID
  486. LEFT JOIN product p ON p.productID = ccr.productID
  487. LEFT JOIN shop sh ON sh.shopID = p.shopID
  488. <where>
  489. <if test="remarks != null and remarks !=''">
  490. AND ccr.remarks LIKE concat('%',#{remarks},'%')
  491. </if>
  492. <if test="clubId != null">
  493. AND c.clubID = #{clubId}
  494. </if>
  495. <if test="contractMobile != null and contractMobile != ''">
  496. AND c.contractMobile = #{contractMobile}
  497. </if>
  498. <if test="clubName !=null and clubName !=''">
  499. AND c.Name like concat('%',#{clubName},'%')
  500. </if>
  501. <if test="leaderId != null">
  502. and csr.leaderId = #{leaderId}
  503. </if>
  504. <if test="serviceProviderId != null">
  505. and csg.serviceId = #{serviceProviderId}
  506. </if>
  507. <if test="startAddTime != null and startAddTime != ''">
  508. and ccr.addTime <![CDATA[ > ]]> #{startAddTime}
  509. </if>
  510. <if test="endAddTime != null and endAddTime != ''">
  511. and ccr.addTime <![CDATA[ < ]]> #{endAddTime}
  512. </if>
  513. <if test="newDeal !=null">
  514. and c.newDeal=#{newDeal}
  515. </if>
  516. <if test="reportID !=null">
  517. and ccr.reportID=#{reportID}
  518. </if>
  519. </where>
  520. ORDER BY ADDTIME DESC
  521. <choose>
  522. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  523. ORDER BY ${page.orderBy}
  524. </when>
  525. </choose>
  526. </select>
  527. <select id="findConsults" resultType="com.caimei.modules.consult.entity.type.CmConsulttype">
  528. select id, className, createdTime
  529. from cm_consulttype
  530. where delflag = 0
  531. </select>
  532. <select id="findTeams" resultType="com.caimei.modules.user.entity.CmSaleMan">
  533. select csr.leaderId, s.name as leaderName
  534. from cm_serviceteam_role csr
  535. left join serviceprovider s on s.serviceProviderID = csr.leaderId
  536. where csr.delflag = 0
  537. </select>
  538. <select id="findGroup" resultType="com.caimei.modules.project.model.ServiceProviderModel">
  539. SELECT serviceId as serviceProviderID, s.name
  540. FROM cm_serviceteam_group csg
  541. LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamid
  542. LEFT JOIN serviceprovider s ON s.serviceProviderID = csg.serviceId
  543. WHERE csr.leaderId = #{leaderId}
  544. </select>
  545. <select id="findClassName" resultType="java.lang.String">
  546. select className
  547. from cm_consulttype
  548. where id = #{string}
  549. </select>
  550. <delete id="deleteRamarks">
  551. DELETE
  552. FROM `cm_remarks`
  553. WHERE remarksId = #{remarksId}
  554. </delete>
  555. <insert id="addRemarks">
  556. INSERT INTO `cm_remarks`(remarks, `addtime`)
  557. VALUES (#{remarks}, #{addtime})
  558. </insert>
  559. <update id="upremarks">
  560. UPDATE `cm_remarks`
  561. SET remarks = #{remarks}
  562. WHERE remarksId = #{remarksId}
  563. </update>
  564. <select id="upremakasList" resultType="java.lang.String">
  565. SELECT remarks
  566. FROM `cm_remarks`
  567. WHERE remarksId = #{remarksId}
  568. </select>
  569. <select id="ClubsIds" resultType="java.lang.Integer">
  570. select oldserviceProviderId
  571. FROM `cm_club_remarks`
  572. WHERE clubId = #{clubID}
  573. </select>
  574. <update id="oldname">
  575. UPDATE cm_club_remarks
  576. SET oldserviceProviderId = #{oldserviceProviderId},
  577. serviceProviderId=#{newSpID}
  578. WHERE clubId = #{clubID}
  579. AND serviceProviderId = #{oldSpID}
  580. </update>
  581. <update id="oldnames">
  582. UPDATE cm_club_remarks
  583. SET serviceProviderId=#{newSpID}
  584. WHERE clubId = #{clubID}
  585. AND serviceProviderId = #{oldSpID}
  586. </update>
  587. <select id="ReportList" resultType="com.caimei.modules.user.entity.CmReport">
  588. SELECT ccr.Id as reportId, p.mainImage AS mainImage,p.`name` AS productName,c.`name` AS clubName,ccr.reportName
  589. AS reportName,
  590. ccr.reportText AS reportText,ccr.addTime AS ADDTIME,ccr.status AS STATUS,ccr.auditName AS
  591. auditName,ccr.auditTime AS auditTime,c.newDeal,ccr.auditText
  592. FROM cm_club_report ccr
  593. LEFT JOIN product p ON p.productID = ccr.productID
  594. LEFT JOIN club c ON c.clubID = ccr.clubID
  595. <where>
  596. <if test="reportId!=null and reportId!=''">
  597. AND ccr.id=#{reportId}
  598. </if>
  599. <if test="productName!=null and productName!=''">
  600. AND p.name LIKE concat('%',#{productName},'%')
  601. </if>
  602. <if test="clubID != null">
  603. c.clubID = #{clubID}
  604. </if>
  605. <if test="clubName!=null and clubName!=''">
  606. AND c.name LIKE concat('%',#{clubName},'%')
  607. </if>
  608. <if test="newDeal!=null">
  609. AND c.newDeal =#{newDeal}
  610. </if>
  611. <if test="startAddTime != null and startAddTime != ''">
  612. and ccr.addTime <![CDATA[ > ]]> #{startAddTime}
  613. </if>
  614. <if test="endAddTime != null and endAddTime != ''">
  615. and ccr.addTime <![CDATA[ < ]]> #{endAddTime}
  616. </if>
  617. </where>
  618. ORDER BY ccr.`addTime` DESC
  619. </select>
  620. <select id="findRegistLists" resultType="com.caimei.modules.user.entity.VisitRemarkVo">
  621. SELECT DISTINCT
  622. ccr.id AS remarksId, ccr.remarks,s.name AS spName, ccr.addTime,ccr.questionMan,
  623. csr.leaderId AS leaderId,IFNULL(ccr.consultType,'') AS
  624. consult,ccr.clubType,ccr.pinceSensitve,ccr.satisfied,ccr.followup,ccr.extra,
  625. (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID = ccr.serviceProviderId) AS serviceName,
  626. (SELECT NAME FROM serviceprovider s WHERE s.serviceProviderID = csr.leaderId) AS leaderName,
  627. (SELECT mainImage FROM product p WHERE p.productID= ccre.productID) AS productMainImage,
  628. (SELECT NAME FROM product p WHERE p.productID= ccre.productID) AS proName,
  629. ccre.reportText AS reportText,ccre.status AS reportStatus,ccre.auditName,ccre.auditTime AS auditTime,p.mainImage
  630. AS mainImage,p.name AS productName,sh.name AS shopName
  631. FROM cm_visitor_remarks ccr
  632. LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
  633. LEFT JOIN cm_serviceTeam_group csg ON ccr.serviceProviderId = csg.serviceId
  634. LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
  635. LEFT JOIN cm_club_report ccre ON ccre.Id= ccr.reportID
  636. LEFT JOIN product p ON p.productID = ccr.productID
  637. LEFT JOIN shop sh ON sh.shopID = p.shopID
  638. LEFT JOIN club c ON c.clubID = ccr.clubID
  639. <where>
  640. <if test="remarks != null and remarks !=''">
  641. AND ccr.remarks LIKE concat('%',#{remarks},'%')
  642. </if>
  643. <if test="leaderId != null">
  644. and csr.leaderId = #{leaderId}
  645. </if>
  646. <if test="serviceProviderId != null">
  647. and csg.serviceId = #{serviceProviderId}
  648. </if>
  649. <if test="startAddTime != '' and startAddTime != null">
  650. and ccr.addTime <![CDATA[ > ]]> #{startAddTime}
  651. </if>
  652. <if test="endAddTime != '' and endAddTime != null">
  653. and ccr.addTime <![CDATA[ < ]]> #{endAddTime}
  654. </if>
  655. <if test="reportID !=null">
  656. and ccr.reportID=#{reportID}
  657. </if>
  658. <if test="newDeal !=null">
  659. and c.newDeal=#{newDeal}
  660. </if>
  661. and ccr.remarks IS NOT NULL
  662. </where>
  663. ORDER BY ADDTIME DESC
  664. </select>
  665. <select id="visitorRemarksConut" resultType="integer">
  666. SELECT COUNT(*)
  667. FROM cm_visitor_remarks
  668. WHERE reportID = #{reportID}
  669. </select>
  670. <select id="clubRemarksConut" resultType="integer">
  671. SELECT COUNT(*)
  672. FROM cm_club_remarks
  673. WHERE reportID = #{reportID}
  674. </select>
  675. <update id="updateAuditRemarks">
  676. UPDATE cm_club_report
  677. SET status=#{status},
  678. auditName=#{auditName},
  679. auditText=#{auditText},
  680. auditTime=now()
  681. WHERE id = #{reportID}
  682. </update>
  683. <update id="updateClubRemarks">
  684. UPDATE cm_club_remarks
  685. SET reportID=null
  686. WHERE id = #{remarksId}
  687. </update>
  688. <update id="updateVisitorRemarks">
  689. UPDATE cm_visitor_remarks
  690. SET reportID=null
  691. WHERE id = #{remarksId}
  692. </update>
  693. <delete id="deleteClubRemarks">
  694. DELETE
  695. FROM cm_club_report
  696. WHERE id = #{reportID}
  697. </delete>
  698. <insert id="addRecordLinkage">
  699. INSERT INTO `record_link`(`describe`, `link`, clubId, addTime)
  700. VALUES (#{describe}, #{link}, #{clubId}, now())
  701. </insert>
  702. <select id="recordLinkage" resultType="string">
  703. SELECT link
  704. from record_link
  705. where clubId = #{clubId}
  706. ORDER BY id DESC
  707. LIMIT 1
  708. </select>
  709. <select id="recordDescribe" resultType="string">
  710. SELECT `describe`
  711. from record_link
  712. where clubId = #{clubId}
  713. ORDER BY id DESC
  714. LIMIT 1
  715. </select>
  716. <select id="selRegisterIP" resultType="com.caimei.modules.user.entity.CmBehaviorRecord">
  717. SELECT u.registerIP, u.ipAddress AS region, u.registerTime
  718. FROM USER u
  719. LEFT JOIN club c ON u.userID = c.userID
  720. WHERE c.clubID = #{clubId}
  721. </select>
  722. <select id="selStatisticsList" resultType="com.caimei.modules.user.entity.ClubStatistics">
  723. SELECT
  724. u.userId,
  725. c.clubID,
  726. c.name,
  727. c.linkMan,
  728. c.contractMobile,
  729. c.linkManIdentity,
  730. c.address,
  731. c.businessLicenseImage,
  732. u.userIdentity,
  733. c.sname,
  734. c.contractEmail,
  735. c.contractPhone,
  736. c.fax,
  737. c.headpic,
  738. c.socialCreditCode,
  739. c.info,
  740. (CASE WHEN c.linkManIdentity=1 THEN '老板'
  741. WHEN c.linkManIdentity=2 THEN '采购'
  742. WHEN c.linkManIdentity=3 THEN '运营'
  743. WHEN c.linkManIdentity=4 THEN '其他'
  744. END) AS linkManStatus,
  745. (CASE WHEN c.status = 1 THEN '待审核'
  746. WHEN c.status=91 THEN '已下线'
  747. WHEN c.status=90 THEN '已上线'
  748. WHEN c.status=92 THEN '审核未通过'
  749. WHEN c.status=93 THEN '已确认'
  750. ELSE '已冻结' END) AS clubStatus,
  751. (CASE WHEN u.userIdentity=2 THEN '资质机构'
  752. ELSE '个人机构' END) AS clubRank,
  753. (CASE WHEN c.firstClubType=1 THEN '医美'
  754. WHEN c.firstClubType=2 THEN '生美'
  755. WHEN c.firstClubType=3 THEN '项目公司'
  756. WHEN c.firstClubType=4 THEN '个人'
  757. ELSE '其他' END) AS firstClubType,
  758. (CASE WHEN c.secondClubType=1 THEN '诊所'
  759. WHEN c.secondClubType=2 THEN '门诊'
  760. WHEN c.secondClubType=3 THEN '医院'
  761. WHEN c.secondClubType=5 THEN '美容院'
  762. WHEN c.secondClubType=6 THEN '养生馆'
  763. WHEN c.secondClubType=7 THEN '其他'
  764. END) AS classify,
  765. c.addTime AS addTime,
  766. IF(csu.delFlag = '0' AND NOW() <![CDATA[ < ]]> csu.endTime,1,0) AS svipUserFlag,
  767. case sp.status when 91 then '采美默认协销经理(官方账号)' else sp.linkMan end AS spName,
  768. IFNULL(orderMonth.payTotalMonth,0) AS payTotalMonth,
  769. IFNULL(orderMonth.orderCountMonth,0) AS orderCountMonth,
  770. IFNULL(orderYesr.payTotalYesr,0) AS payTotalYear,
  771. IFNULL(orderYesr.orderCountYesr,0) AS orderCountYear,
  772. IFNULL(orderTotal.payTotal,0) AS payTotal,
  773. ordr.lastOrderTime AS lastOrderTime
  774. FROM club c
  775. # LEFT JOIN cm_order cor ON c.userID = cor.userID
  776. LEFT JOIN USER u ON u.userId=c.userId
  777. LEFT JOIN cm_svip_user csu ON csu.userId = u.userID
  778. LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
  779. LEFT JOIN
  780. (SELECT userId,SUM(co.payTotalFee) AS payTotalMonth,
  781. COUNT(co.orderid) AS orderCountMonth
  782. FROM cm_order co
  783. <where>
  784. co.status NOT IN (0,6,7)
  785. <if test="monthStartTime != null and monthStartTime != '' and monthEndTime != null and monthEndTime != ''">
  786. AND co.orderTime BETWEEN #{monthStartTime} AND #{monthEndTime}
  787. </if>
  788. </where>
  789. GROUP BY co.userid) AS orderMonth ON c.userId=orderMonth.userId
  790. LEFT JOIN
  791. (SELECT userId,SUM(co.payTotalFee) AS payTotalYesr,
  792. COUNT(co.orderid) AS orderCountYesr
  793. FROM cm_order co
  794. <where>
  795. co.status NOT IN (0,6,7)
  796. <if test="yearStartTime != null and yearStartTime != '' and yearEndTime != null and yearEndTime != ''">
  797. AND co.orderTime BETWEEN #{yearStartTime} AND #{yearEndTime}
  798. </if>
  799. </where>
  800. GROUP BY co.userid) AS orderYesr ON c.userId=orderYesr.userId
  801. LEFT JOIN
  802. (SELECT userId,SUM(co.payTotalFee) AS payTotal,
  803. COUNT(co.orderid) AS 21OrderCount
  804. FROM cm_order co
  805. <where>
  806. co.status NOT IN (0,6,7)
  807. <if test="customStartTime != null and customStartTime != ''">
  808. AND (co.orderTime > #{customStartTime} or co.orderTime = #{customStartTime})
  809. </if>
  810. <if test="customEndTime != null and customEndTime != ''">
  811. AND co.orderTime <![CDATA[ <= ]]> #{customEndTime}
  812. </if>
  813. </where>
  814. GROUP BY co.userid) AS orderTotal ON c.userId=orderTotal.userId
  815. LEFT JOIN (
  816. SELECT userID, MAX(orderTime) AS lastOrderTime FROM cm_order GROUP BY userID
  817. ) AS ordr ON c.userID = ordr.userID
  818. <where>
  819. <if test="registerStartTime != null and registerStartTime != ''">
  820. AND (c.addTime > #{registerStartTime} or c.addTime = #{registerStartTime} )
  821. </if>
  822. <if test="registerEndTime != null and registerEndTime != ''">
  823. AND c.addTime <![CDATA[ <= ]]> #{registerEndTime}
  824. </if>
  825. <if test="searchStartTime != null and searchStartTime != ''">
  826. AND (ordr.lastOrderTime > #{searchStartTime} or ordr.lastOrderTime = #{searchStartTime} )
  827. </if>
  828. <if test=" searchEndTime != null and searchEndTime != ''">
  829. AND ordr.lastOrderTime <![CDATA[ <= ]]> #{searchEndTime}
  830. </if>
  831. <if test="customerValue != null and customerValue != ''">
  832. AND c.firstClubType = #{customerValue}
  833. </if>
  834. <if test="searchUserIdentity != null and searchUserIdentity != '' and searchUserIdentity != '8'.toString()">
  835. AND u.userIdentity = #{searchUserIdentity}
  836. </if>
  837. <if test="searchUserIdentity != null and searchUserIdentity != '' and searchUserIdentity == '8'.toString()">
  838. AND csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
  839. </if>
  840. <if test="searchStatus != null and searchStatus != ''">
  841. AND c.status = #{searchStatus}
  842. </if>
  843. <if test="linkManIdentity != null and linkManIdentity != ''">
  844. AND c.linkManIdentity = #{linkManIdentity}
  845. </if>
  846. <if test="payTotalMonth != null and payTotalMonth != ''">
  847. <if test="payTotalMonth==1">
  848. AND orderMonth.payTotalMonth <![CDATA[ < ]]> 10000
  849. </if>
  850. <if test="payTotalMonth==2">
  851. AND orderMonth.payTotalMonth BETWEEN 10000 AND 100000
  852. </if>
  853. <if test="payTotalMonth==3">
  854. AND orderMonth.payTotalMonth BETWEEN 100000 AND 1000000
  855. </if>
  856. <if test="payTotalMonth==4">
  857. AND orderMonth.payTotalMonth <![CDATA[ > ]]> 1000000
  858. </if>
  859. </if>
  860. <if test="payTotalYear != null and payTotalYear != ''">
  861. <if test="payTotalYear==1">
  862. AND orderYesr.payTotalYesr <![CDATA[ < ]]> 10000
  863. </if>
  864. <if test="payTotalYear==2">
  865. AND orderYesr.payTotalYesr BETWEEN 10000 AND 100000
  866. </if>
  867. <if test="payTotalYear==3">
  868. AND orderYesr.payTotalYesr BETWEEN 100000 AND 1000000
  869. </if>
  870. <if test="payTotalYear==4">
  871. AND orderYesr.payTotalYesr <![CDATA[ > ]]> 1000000
  872. </if>
  873. </if>
  874. <if test="payTotal != null and payTotal != ''">
  875. <if test="payTotal==1">
  876. AND orderTotal.payTotal <![CDATA[ < ]]> 10000
  877. </if>
  878. <if test="payTotal==2">
  879. AND orderTotal.payTotal BETWEEN 10000 AND 100000
  880. </if>
  881. <if test="payTotal==3">
  882. AND orderTotal.payTotal BETWEEN 100000 AND 1000000
  883. </if>
  884. <if test="payTotal==4">
  885. AND orderTotal.payTotal <![CDATA[ > ]]> 1000000
  886. </if>
  887. </if>
  888. </where>
  889. GROUP BY c.userID ORDER BY
  890. <if test="payTotalMonthType == null and orderCountMonthType == null and payTotalYearType == null and orderCountYearType == null and payTotalType == null">
  891. ordr.lastOrderTime DESC
  892. </if>
  893. <if test="orderCountMonthType != null">
  894. <if test="orderCountMonthType == 0">
  895. orderMonth.orderCountMonth
  896. </if>
  897. <if test="orderCountMonthType == 1">
  898. orderMonth.orderCountMonth DESC
  899. </if>
  900. </if>
  901. <if test="orderCountYearType != null">
  902. <if test="orderCountYearType == 0">
  903. orderYesr.orderCountYesr
  904. </if>
  905. <if test="orderCountYearType == 1">
  906. orderYesr.orderCountYesr DESC
  907. </if>
  908. </if>
  909. <if test="payTotalMonthType != null">
  910. <if test="payTotalMonthType == 0">
  911. orderMonth.payTotalMonth
  912. </if>
  913. <if test="payTotalMonthType == 1">
  914. orderMonth.payTotalMonth DESC
  915. </if>
  916. </if>
  917. <if test="payTotalYearType != null">
  918. <if test="payTotalYearType == 0">
  919. orderYesr.payTotalYesr
  920. </if>
  921. <if test="payTotalYearType == 1">
  922. orderYesr.payTotalYesr DESC
  923. </if>
  924. </if>
  925. <if test="payTotalType != null">
  926. <if test="payTotalType == 0">
  927. orderTotal.payTotal
  928. </if>
  929. <if test="payTotalType == 1">
  930. orderTotal.payTotal DESC
  931. </if>
  932. </if>
  933. </select>
  934. <select id="selPageLable" resultType="com.caimei.modules.user.entity.CmBehaviorRecord">
  935. SELECT c.userID, COUNT(pageType) AS number, cbr.pageLabel
  936. FROM club c
  937. LEFT JOIN cm_behavior_record cbr ON cbr.userID = c.userID
  938. WHERE cbr.userID = c.userID
  939. AND cbr.pageType in (8, 9)
  940. GROUP BY c.userID, cbr.pageLabel
  941. </select>
  942. <select id="findExcelList" resultType="com.caimei.modules.user.entity.easyExcel">
  943. SELECT
  944. u.userId,
  945. c.clubID,
  946. c.name,
  947. c.linkMan,
  948. c.contractMobile,
  949. c.linkManIdentity,
  950. c.address,
  951. c.businessLicenseImage,
  952. u.userIdentity,
  953. c.sname,
  954. c.contractEmail,
  955. c.contractPhone,
  956. c.fax,
  957. c.headpic,
  958. c.socialCreditCode,
  959. c.info,
  960. (CASE WHEN c.linkManIdentity=1 THEN '老板'
  961. WHEN c.linkManIdentity=2 THEN '采购'
  962. WHEN c.linkManIdentity=3 THEN '运营'
  963. WHEN c.linkManIdentity=4 THEN '其他'
  964. END) AS linkManStatus,
  965. (CASE WHEN c.status = 1 THEN '待审核'
  966. WHEN c.status=91 THEN '已下线'
  967. WHEN c.status=90 THEN '已上线'
  968. WHEN c.status=92 THEN '审核未通过'
  969. WHEN c.status=93 THEN '已确认'
  970. ELSE '已冻结' END) AS clubStatus,
  971. (CASE WHEN u.userIdentity=2 THEN '资质机构'
  972. ELSE '个人机构' END) AS clubRank,
  973. (CASE WHEN c.firstClubType=1 THEN '医美'
  974. WHEN c.firstClubType=2 THEN '生美'
  975. WHEN c.firstClubType=3 THEN '项目公司'
  976. WHEN c.firstClubType=4 THEN '个人'
  977. ELSE '其他' END) AS firstClubType,
  978. (CASE WHEN c.secondClubType=1 THEN '诊所'
  979. WHEN c.secondClubType=2 THEN '门诊'
  980. WHEN c.secondClubType=3 THEN '医院'
  981. WHEN c.secondClubType=5 THEN '美容院'
  982. WHEN c.secondClubType=6 THEN '养生馆'
  983. WHEN c.secondClubType=7 THEN '其他'
  984. END) AS classify,
  985. c.addTime AS addTime,
  986. IF(csu.delFlag = '0' AND NOW() <![CDATA[ < ]]> csu.endTime,1,0) AS svipUserFlag,
  987. case sp.status when 91 then '采美默认协销经理(官方账号)' else sp.linkMan end AS spName,
  988. IFNULL(orderMonth.payTotalMonth,0) AS payTotalMonth,
  989. IFNULL(orderMonth.orderCountMonth,0) AS orderCountMonth,
  990. IFNULL(orderYesr.payTotalYesr,0) AS payTotalYear,
  991. IFNULL(orderYesr.orderCountYesr,0) AS orderCountYear,
  992. IFNULL(orderTotal.payTotal,0) AS payTotal,
  993. pb.pageLabel,
  994. ordr.lastOrderTime AS lastOrderTime
  995. FROM club c
  996. # LEFT JOIN cm_order cor ON c.userID = cor.userID
  997. LEFT JOIN USER u ON u.userId=c.userId
  998. LEFT JOIN cm_svip_user csu ON csu.userId = u.userID
  999. LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
  1000. LEFT JOIN
  1001. (SELECT userId,SUM(co.payTotalFee) AS payTotalMonth,
  1002. COUNT(co.orderid) AS orderCountMonth
  1003. FROM cm_order co
  1004. <where>
  1005. co.status NOT IN (0,6,7)
  1006. <if test="monthStartTime != null and monthStartTime != '' and monthEndTime != null and monthEndTime != ''">
  1007. AND co.orderTime BETWEEN #{monthStartTime} AND #{monthEndTime}
  1008. </if>
  1009. </where>
  1010. GROUP BY co.userid) AS orderMonth ON c.userId=orderMonth.userId
  1011. LEFT JOIN
  1012. (SELECT userId,SUM(co.payTotalFee) AS payTotalYesr,
  1013. COUNT(co.orderid) AS orderCountYesr
  1014. FROM cm_order co
  1015. <where>
  1016. co.status NOT IN (0,6,7)
  1017. <if test="yearStartTime != null and yearStartTime != '' and yearEndTime != null and yearEndTime != ''">
  1018. AND co.orderTime BETWEEN #{yearStartTime} AND #{yearEndTime}
  1019. </if>
  1020. </where>
  1021. GROUP BY co.userid) AS orderYesr ON c.userId=orderYesr.userId
  1022. LEFT JOIN
  1023. (SELECT userId,SUM(co.payTotalFee) AS payTotal,
  1024. COUNT(co.orderid) AS 21OrderCount
  1025. FROM cm_order co
  1026. <where>
  1027. co.status NOT IN (0,6,7)
  1028. <if test="customStartTime != null and customStartTime != ''">
  1029. AND (co.orderTime > #{customStartTime} or co.orderTime = #{customStartTime})
  1030. </if>
  1031. <if test="customEndTime != null and customEndTime != ''">
  1032. AND co.orderTime <![CDATA[ <= ]]> #{customEndTime}
  1033. </if>
  1034. </where>
  1035. GROUP BY co.userid) AS orderTotal ON c.userId=orderTotal.userId
  1036. LEFT JOIN
  1037. (
  1038. SELECT c.userID, COUNT(cbr.pageLabel), cbr.pageLabel
  1039. FROM cm_behavior_record cbr
  1040. LEFT JOIN club c ON cbr.userID = c.userID
  1041. <where>cbr.userID = c.userID</where>
  1042. GROUP BY cbr.pageLabel) AS pb ON c.userID = pb.userID
  1043. LEFT JOIN (
  1044. SELECT userID, MAX(orderTime) AS lastOrderTime FROM cm_order GROUP BY userID
  1045. ) AS ordr ON c.userID = ordr.userID
  1046. <where>
  1047. <if test="registerStartTime != null and registerStartTime != ''">
  1048. AND (c.addTime > #{registerStartTime} or c.addTime = #{registerStartTime} )
  1049. </if>
  1050. <if test="registerEndTime != null and registerEndTime != ''">
  1051. AND c.addTime <![CDATA[ <= ]]> #{registerEndTime}
  1052. </if>
  1053. <if test="searchStartTime != null and searchStartTime != ''">
  1054. AND (ordr.lastOrderTime > #{searchStartTime} or ordr.lastOrderTime = #{searchStartTime} )
  1055. </if>
  1056. <if test=" searchEndTime != null and searchEndTime != ''">
  1057. AND ordr.lastOrderTime <![CDATA[ <= ]]> #{searchEndTime}
  1058. </if>
  1059. <if test="customerValue != null and customerValue != ''">
  1060. AND c.firstClubType = #{customerValue}
  1061. </if>
  1062. <if test="searchUserIdentity != null and searchUserIdentity != '' and searchUserIdentity != '8'.toString()">
  1063. AND u.userIdentity = #{searchUserIdentity}
  1064. </if>
  1065. <if test="searchUserIdentity != null and searchUserIdentity != '' and searchUserIdentity == '8'.toString()">
  1066. AND csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
  1067. </if>
  1068. <if test="searchStatus != null and searchStatus != ''">
  1069. AND c.status = #{searchStatus}
  1070. </if>
  1071. <if test="linkManIdentity != null and linkManIdentity != ''">
  1072. AND c.linkManIdentity = #{linkManIdentity}
  1073. </if>
  1074. <if test="searchStatus != null and searchStatus != ''">
  1075. AND c.status = #{searchStatus}
  1076. </if>
  1077. <if test="payTotalMonth != null and payTotalMonth != ''">
  1078. <if test="payTotalMonth==1">
  1079. AND orderMonth.payTotalMonth <![CDATA[ < ]]> 10000
  1080. </if>
  1081. <if test="payTotalMonth==2">
  1082. AND orderMonth.payTotalMonth BETWEEN 10000 AND 100000
  1083. </if>
  1084. <if test="payTotalMonth==3">
  1085. AND orderMonth.payTotalMonth BETWEEN 100000 AND 1000000
  1086. </if>
  1087. <if test="payTotalMonth==4">
  1088. AND orderMonth.payTotalMonth <![CDATA[ > ]]> 1000000
  1089. </if>
  1090. </if>
  1091. <if test="payTotalYear != null and payTotalYear != ''">
  1092. <if test="payTotalYear==1">
  1093. AND orderYesr.payTotalYesr <![CDATA[ < ]]> 10000
  1094. </if>
  1095. <if test="payTotalYear==2">
  1096. AND orderYesr.payTotalYesr BETWEEN 10000 AND 100000
  1097. </if>
  1098. <if test="payTotalYear==3">
  1099. AND orderYesr.payTotalYesr BETWEEN 100000 AND 1000000
  1100. </if>
  1101. <if test="payTotalYear==4">
  1102. AND orderYesr.payTotalYesr <![CDATA[ > ]]> 1000000
  1103. </if>
  1104. </if>
  1105. <if test="payTotal != null and payTotal != ''">
  1106. <if test="payTotal==1">
  1107. AND orderTotal.payTotal <![CDATA[ < ]]> 10000
  1108. </if>
  1109. <if test="payTotal==2">
  1110. AND orderTotal.payTotal BETWEEN 10000 AND 100000
  1111. </if>
  1112. <if test="payTotal==3">
  1113. AND orderTotal.payTotal BETWEEN 100000 AND 1000000
  1114. </if>
  1115. <if test="payTotal==4">
  1116. AND orderTotal.payTotal <![CDATA[ > ]]> 1000000
  1117. </if>
  1118. </if>
  1119. </where>
  1120. GROUP BY c.userID ORDER BY ordr.lastOrderTime DESC
  1121. </select>
  1122. </mapper>