NewCmClubMapper.xml 46 KB

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