NewCmClubMapper.xml 67 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631
  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="com.caimei.modules.user.entity.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="com.caimei.modules.user.entity.NewCmClub">
  86. SELECT u.userID AS valueID, coas.activeState, covs.customerValue
  87. FROM USER u
  88. LEFT JOIN cm_organ_value_system covs ON covs.userId = u.userId
  89. LEFT JOIN cm_organ_active_system coas ON coas.userId = u.userId
  90. WHERE covs.stage = 0 AND covs.delType = 1 AND coas.stage = 0 AND coas.delType = 1
  91. </select>
  92. <select id="findList" resultType="NewCmClub">
  93. SELECT
  94. <include refid="newCmClubColumns"/>
  95. <include refid="otherColumns"/>,u.userPermission,u.source, coas.activeState,covs.customerValue,u.loginTime
  96. FROM club a
  97. <include refid="newCmClubJoins"/>
  98. LEFT JOIN (SELECT DISTINCT clubId, createTime FROM cm_provider_record GROUP BY clubId ORDER BY id DESC ) cpr ON a.clubId = cpr.clubId
  99. LEFT JOIN (SELECT DISTINCT clubID, checkTime FROM clubchangesprecord WHERE checkStatus = 1 GROUP BY clubID ORDER BY clubChangeSpRecordID DESC )ccs ON ccs.clubId = a.clubId
  100. LEFT JOIN (SELECT userID, customerValue FROM cm_organ_value_system WHERE stage = 0 AND delType = 1) covs ON a.userID = covs.userID
  101. LEFT JOIN (SELECT userID, activeState FROM cm_organ_active_system WHERE stage = 0 AND delType = 1) AS coas ON coas.userID = a.userID
  102. <where>
  103. (u.userOrganizeID IN(0,1) or u.clubStatus != 92) and u.userOrganizeID != 4 AND u.userIdentity != 8
  104. <if test="clubID != null and clubID != ''">
  105. AND a.clubID = #{clubID}
  106. </if>
  107. <if test="clubID == 0">
  108. AND a.clubID = #{clubID}
  109. </if>
  110. <if test="userID != null and userID != ''">
  111. AND a.userID = #{userID}
  112. </if>
  113. <if test="account != null and account != ''">
  114. AND u.account = #{account}
  115. </if>
  116. <if test="name != null and name != ''">
  117. AND u.name LIKE concat('%',#{name},'%')
  118. </if>
  119. <if test="userName != null and userName != ''">
  120. AND u.userName LIKE concat('%',#{userName},'%')
  121. </if>
  122. <if test="townID != null and townID != ''">
  123. AND d.provinceID = #{provinceID}
  124. </if>
  125. <if test="cityID != null and cityID != ''">
  126. AND c.cityID = #{cityID}
  127. </if>
  128. <if test="townID != null and townID != ''">
  129. AND b.townID = #{townID}
  130. </if>
  131. <if test="status != null and status != ''">
  132. AND a.status = #{status}
  133. </if>
  134. <if test="bindMobile != null and bindMobile != ''">
  135. AND u.bindMobile LIKE concat('%',#{bindMobile},'%')
  136. </if>
  137. <if test="email != null and email != ''">
  138. AND u.email LIKE concat('%',#{email},'%')
  139. </if>
  140. <if test="linkMan != null and linkMan != ''">
  141. AND a.linkMan LIKE concat('%',#{linkMan},'%')
  142. </if>
  143. <if test="startTime != null and startTime != ''">
  144. AND (u.registerTime &gt; #{startTime} OR u.registerTime = #{startTime})
  145. </if>
  146. <if test="endTime != null and endTime != ''">
  147. AND (u.registerTime &lt; #{endTime} OR u.registerTime = #{endTime})
  148. </if>
  149. <if test="allocationStartTime != null and allocationStartTime != ''">
  150. AND (ccs.checkTime <![CDATA[ >= ]]> #{allocationStartTime}
  151. OR cpr.createTime <![CDATA[ >= ]]> #{allocationStartTime})
  152. </if>
  153. <if test="allocationEndTime != null and allocationEndTime != ''">
  154. AND (ccs.checkTime <![CDATA[ <= ]]> #{allocationEndTime}
  155. OR cpr.createTime <![CDATA[ <= ]]> #{allocationEndTime})
  156. </if>
  157. <if test="trendsLabel != null and trendsLabel != ''">
  158. AND a.clubId in (select clubId from cm_club_label where label like concat('%', #{trendsLabel}, '%') AND dynamicStatus = 0)
  159. </if>
  160. <if test="stateLabel != null and stateLabel != ''">
  161. AND a.clubId in (select clubId from cm_club_label where label like concat('%', #{stateLabel}, '%') AND dynamicStatus = 1)
  162. </if>
  163. <if test="labelStartTime != null and labelStartTime != ''">
  164. AND a.clubId in (select clubId from cm_club_label where addTime <![CDATA[ >= ]]> #{labelStartTime})
  165. </if>
  166. <if test="labelEndTime != null and labelEndTime != ''">
  167. AND a.clubId in (select clubId from cm_club_label where addTime <![CDATA[ <= ]]> #{labelEndTime})
  168. </if>
  169. <if test="startLoginTime != null and startLoginTime != ''">
  170. AND (u.loginTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) OR a.clubId in (select a.clubId
  171. FROM ((
  172. select
  173. c.clubId,ccr.addTime AS time,c.spID
  174. FROM club c
  175. LEFT JOIN user u ON u.userID = c.userID
  176. LEFT JOIN cm_club_remarks ccr ON ccr.clubId = c.clubId
  177. LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
  178. where c.status=90 and sp.status=90
  179. and ccr.addTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
  180. GROUP BY c.clubId
  181. )UNION(
  182. select c.clubId,cr.orderTime AS time,c.spID
  183. FROM club c
  184. LEFT JOIN user u ON u.userID = c.userID
  185. LEFT JOIN cm_order cr ON cr.clubId = c.clubId
  186. LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
  187. where c.status=90 and sp.status=90
  188. and cr.orderTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
  189. GROUP BY c.clubId
  190. )) a where a.time is not null
  191. and a.spID=#{spID}
  192. GROUP BY a.clubId ))
  193. </if>
  194. <if test="endLoginTime != null and endLoginTime != ''">
  195. AND (u.loginTime <![CDATA[ < ]]> DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH) or u.loginTime is null) and a.clubId not in (select a.clubId
  196. FROM ((
  197. select
  198. c.clubId,ccr.addTime AS time,c.spID
  199. FROM club c
  200. LEFT JOIN user u ON u.userID = c.userID
  201. LEFT JOIN cm_club_remarks ccr ON ccr.clubId = c.clubId
  202. LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
  203. where c.status=90 and sp.status=90
  204. and ccr.addTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
  205. GROUP BY c.clubId
  206. )UNION(
  207. select c.clubId,cr.orderTime AS time,c.spID
  208. FROM club c
  209. LEFT JOIN user u ON u.userID = c.userID
  210. LEFT JOIN cm_order cr ON cr.clubId = c.clubId
  211. LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
  212. where c.status=90 and sp.status=90
  213. and cr.orderTime >= DATE_SUB(CURRENT_DATE, INTERVAL 6 MONTH)
  214. GROUP BY c.clubId
  215. )) a where a.time is not null
  216. and a.spID=#{spID}
  217. GROUP BY a.clubId )
  218. </if>
  219. <if test="userIdentity != null and userIdentity != '' and userIdentity != '8'.toString()">
  220. AND u.userIdentity = #{userIdentity}
  221. </if>
  222. <if test="userIdentity != null and userIdentity != '' and userIdentity == '8'.toString()">
  223. AND csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
  224. </if>
  225. <if test="newDeal != null">
  226. AND a.newDeal =#{newDeal}
  227. </if>
  228. <if test="activeState != null and activeState != ''">
  229. AND coas.activeState = #{activeState}
  230. </if>
  231. <if test="customerValue != null and customerValue != ''">
  232. AND covs.customerValue = #{customerValue}
  233. </if>
  234. <if test="spID != null and spID != ''">
  235. AND sp.serviceProviderID = #{spID}
  236. </if>
  237. </where>
  238. <choose>
  239. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  240. ORDER BY ${page.orderBy}
  241. </when>
  242. <otherwise>
  243. ORDER BY case when a.status = 91 then 0 else 1 end desc, a.addTime DESC
  244. </otherwise>
  245. </choose>
  246. </select>
  247. <select id="spNameList" resultType="com.caimei.modules.project.model.ServiceProviderModel">
  248. SELECT serviceProviderID, name
  249. FROM serviceprovider
  250. WHERE NAME NOT LIKE concat('%', '测试', '%')
  251. AND validFlag = 1
  252. AND STATUS = 90
  253. </select>
  254. <select id="getClubLabel" resultType="com.caimei.modules.user.entity.CmClubLabel">
  255. SELECT label, dynamicStatus FROM cm_club_label
  256. </select>
  257. <select id="findAllList" resultType="NewCmClub">
  258. SELECT
  259. <include refid="newCmClubColumns"/>
  260. <include refid="otherColumns"/>
  261. FROM club a
  262. <include refid="newCmClubJoins"/>
  263. <where>
  264. </where>
  265. <choose>
  266. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  267. ORDER BY ${page.orderBy}
  268. </when>
  269. <otherwise>
  270. </otherwise>
  271. </choose>
  272. </select>
  273. <select id="findProviderList" resultType="NewCmClub">
  274. SELECT
  275. <include refid="newCmClubColumns"/>
  276. ,case sp.status when 91 then '采美默认协销经理(官方账号)' else sp.linkMan end AS "spName"
  277. ,u.userPermission,u.source,u.loginTime,cpr.createTime AS providerTime,
  278. u.account AS "account",
  279. u.registerTime AS "registerTime",
  280. u.registerIP AS "registerIP",
  281. u.userName AS "userName",
  282. u.bindMobile AS "bindMobile",
  283. u.email AS "email",
  284. u.userOrganizeID AS "userOrganizeID",
  285. u.userIdentity AS "userIdentity",
  286. if(csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime,1,0) as svipUserFlag
  287. from cm_provider_record cpr
  288. LEFT JOIN serviceprovider sp ON sp.serviceProviderID =cpr.spID
  289. LEFT JOIN club a ON cpr.clubId = a.clubId
  290. LEFT JOIN user u ON u.userID = a.userID
  291. LEFT JOIN cm_svip_user csu ON csu.userId = u.userID
  292. <where>
  293. (u.userOrganizeID IN(0,1) or u.clubStatus != 92) and u.userOrganizeID != 4 and sp.status=90
  294. <if test="clubID != null and clubID != ''">
  295. AND a.clubID = #{clubID}
  296. </if>
  297. <if test="clubID == 0">
  298. AND a.clubID = #{clubID}
  299. </if>
  300. <if test="userID != null and userID != ''">
  301. AND a.userID = #{userID}
  302. </if>
  303. <if test="account != null and account != ''">
  304. AND u.account = #{account}
  305. </if>
  306. <if test="name != null and name != ''">
  307. AND u.name LIKE concat('%',#{name},'%')
  308. </if>
  309. <if test="userName != null and userName != ''">
  310. AND u.userName LIKE concat('%',#{userName},'%')
  311. </if>
  312. <if test="status != null and status != ''">
  313. AND a.status = #{status}
  314. </if>
  315. <if test="bindMobile != null and bindMobile != ''">
  316. AND u.bindMobile LIKE concat('%',#{bindMobile},'%')
  317. </if>
  318. <if test="email != null and email != ''">
  319. AND u.email LIKE concat('%',#{email},'%')
  320. </if>
  321. <if test="linkMan != null and linkMan != ''">
  322. AND a.linkMan LIKE concat('%',#{linkMan},'%')
  323. </if>
  324. <if test="startTime != null and startTime != ''">
  325. AND (u.registerTime &gt; #{startTime} OR u.registerTime = #{startTime})
  326. </if>
  327. <if test="endTime != null and endTime != ''">
  328. AND (u.registerTime &lt; #{endTime} OR u.registerTime = #{endTime})
  329. </if>
  330. <if test="startLoginTime != null and startLoginTime != ''">
  331. AND (u.loginTime &gt; #{startLoginTime} OR u.loginTime = #{startLoginTime})
  332. </if>
  333. <if test="endLoginTime != null and endLoginTime != ''">
  334. AND (u.loginTime &lt; #{endLoginTime} OR u.loginTime = #{endLoginTime})
  335. </if>
  336. <if test="providerTime != null and providerTime != ''">
  337. AND cpr.id in (
  338. (SELECT max(cp.id)
  339. from cm_provider_record cp
  340. WHERE DATE(cp.createTime) = DATE(#{providerTime})
  341. group by cp.clubId))
  342. </if>
  343. <if test="userIdentity != null and userIdentity != '' and userIdentity != '8'.toString()">
  344. AND u.userIdentity = #{userIdentity}
  345. </if>
  346. <if test="userIdentity != null and userIdentity != '' and userIdentity == '8'.toString()">
  347. AND csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
  348. </if>
  349. <if test="newDeal != null">
  350. AND a.newDeal =#{newDeal}
  351. </if>
  352. <if test="spID != null and spID != ''">
  353. AND sp.serviceProviderID = #{spID}
  354. </if>
  355. </where>
  356. group by cpr.clubId
  357. <choose>
  358. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  359. ORDER BY ${page.orderBy}
  360. </when>
  361. <otherwise>
  362. ORDER BY case when a.status = 91 then 0 else 1 end desc, cpr.createTime DESC
  363. </otherwise>
  364. </choose>
  365. </select>
  366. <insert id="insert" parameterType="NewCmClub" keyProperty="clubID" useGeneratedKeys="true">
  367. INSERT INTO club(userID,
  368. name,
  369. sname,
  370. logo,
  371. legalPerson,
  372. provinceID,
  373. cityID,
  374. townID,
  375. flag,
  376. inviterBindID,
  377. inviterName,
  378. spID,
  379. mainServiceProviderID,
  380. scanTime,
  381. address,
  382. linkMan,
  383. linkManIdentity,
  384. contractPhone,
  385. contractMobile,
  386. contractEmail,
  387. fax,
  388. info,
  389. addTime,
  390. auditTime,
  391. auditNote,
  392. status,
  393. businessLicenseImage,
  394. defaultServiceProviderID,
  395. defaultServiceProviderUpdTime,
  396. mainpro,
  397. scanFlag,
  398. headpic,
  399. lastModify,
  400. firstClubType,
  401. socialCreditCode,
  402. secondClubType,
  403. department,
  404. medicalPracticeLicenseImg)
  405. VALUES (#{userID},
  406. #{name},
  407. #{sname},
  408. #{logo},
  409. #{legalPerson},
  410. #{provinceID},
  411. #{cityID},
  412. #{townID},
  413. #{flag},
  414. #{inviterBindID},
  415. #{inviterName},
  416. #{spID},
  417. #{mainServiceProviderID},
  418. #{scanTime},
  419. #{address},
  420. #{linkMan},
  421. #{linkManIdentity},
  422. #{contractPhone},
  423. #{contractMobile},
  424. #{contractEmail},
  425. #{fax},
  426. #{info},
  427. #{addTime},
  428. #{auditTime},
  429. #{auditNote},
  430. #{status},
  431. #{businessLicenseImage},
  432. #{defaultServiceProviderID},
  433. #{defaultServiceProviderUpdTime},
  434. #{mainpro},
  435. #{scanFlag},
  436. #{headpic},
  437. #{lastModify},
  438. #{firstClubType},
  439. #{socialCreditCode},
  440. #{secondClubType},
  441. #{department},
  442. #{medicalPracticeLicenseImg})
  443. </insert>
  444. <update id="update">
  445. UPDATE club SET
  446. <if test="checkMan != null and checkMan != ''">
  447. checkMan = #{checkMan},
  448. </if>
  449. <if test="name != null and name != ''">
  450. name = #{name},
  451. </if>
  452. <if test="sname != null">
  453. sname = #{sname},
  454. </if>
  455. <if test="logo != null and logo != ''">
  456. logo = #{logo},
  457. </if>
  458. <if test="legalPerson != null and legalPerson != ''">
  459. legalPerson = #{legalPerson},
  460. </if>
  461. <if test="provinceID != null and provinceID != ''">
  462. provinceID = #{provinceID},
  463. </if>
  464. <if test="cityID != null and cityID != ''">
  465. cityID = #{cityID},
  466. </if>
  467. <if test="townID != null and townID != ''">
  468. townID = #{townID},
  469. </if>
  470. <if test="flag != null and flag != ''">
  471. flag = #{flag},
  472. </if>
  473. <if test="inviterBindID != null and inviterBindID != ''">
  474. inviterBindID = #{inviterBindID},
  475. </if>
  476. <if test="inviterName != null and inviterName != ''">
  477. inviterName = #{inviterName},
  478. </if>
  479. <if test="spID != null and spID != ''">
  480. spID = #{spID},
  481. </if>
  482. <if test="mainServiceProviderID != null and mainServiceProviderID != ''">
  483. mainServiceProviderID = #{mainServiceProviderID},
  484. </if>
  485. <if test="scanTime != null">
  486. scanTime = #{scanTime},
  487. </if>
  488. <if test="address != null and address != ''">
  489. address = #{address},
  490. </if>
  491. <if test="linkMan != null and linkMan != ''">
  492. linkMan = #{linkMan},
  493. </if>
  494. <if test="linkManIdentity != null and linkManIdentity != ''">
  495. linkManIdentity = #{linkManIdentity},
  496. </if>
  497. <if test="contractPhone != null and contractPhone != ''">
  498. contractPhone = #{contractPhone},
  499. </if>
  500. <if test="contractMobile != null and contractMobile != ''">
  501. contractMobile = #{contractMobile},
  502. </if>
  503. <if test="contractEmail != null and contractEmail != ''">
  504. contractEmail = #{contractEmail},
  505. </if>
  506. <if test="fax != null and fax != ''">
  507. fax = #{fax},
  508. </if>
  509. <if test="info != null and info != ''">
  510. info = #{info},
  511. </if>
  512. <if test="addTime != null">
  513. addTime = #{addTime},
  514. </if>
  515. <if test="auditTime != null">
  516. auditTime = #{auditTime},
  517. </if>
  518. <if test="auditNote != null and auditNote != ''">
  519. auditNote = #{auditNote},
  520. </if>
  521. <if test="status != null and status != ''">
  522. status = #{status},
  523. </if>
  524. <if test="businessLicenseImage != null">
  525. businessLicenseImage = #{businessLicenseImage},
  526. </if>
  527. <if test="socialCreditCode != null and socialCreditCode != ''">
  528. socialCreditCode = #{socialCreditCode},
  529. </if>
  530. <if test="defaultServiceProviderID != null and defaultServiceProviderID != ''">
  531. defaultServiceProviderID = #{defaultServiceProviderID},
  532. </if>
  533. <if test="defaultServiceProviderUpdTime != null and defaultServiceProviderUpdTime != ''">
  534. defaultServiceProviderUpdTime = #{defaultServiceProviderUpdTime},
  535. </if>
  536. <if test="mainpro != null and mainpro != ''">
  537. mainpro = #{mainpro},
  538. </if>
  539. <if test="scanFlag != null and scanFlag != ''">
  540. scanFlag = #{scanFlag},
  541. </if>
  542. <if test="headpic != null">
  543. headpic = #{headpic},
  544. </if>
  545. <if test="lastModify != null and lastModify != ''">
  546. lastModify = DATE_FORMAT(#{lastModify},'%Y-%m-%d %H:%i:%s'),
  547. </if>
  548. <if test="firstClubType != null and firstClubType != ''">
  549. firstClubType=#{firstClubType},
  550. </if>
  551. <if test="secondClubType != null and secondClubType != ''">
  552. secondClubType=#{secondClubType},
  553. </if>
  554. <if test="department != null and department != ''">
  555. department=#{department},
  556. </if>
  557. <if test="medicalPracticeLicenseImg != null and medicalPracticeLicenseImg != ''">
  558. medicalPracticeLicenseImg=#{medicalPracticeLicenseImg},
  559. </if>
  560. userID = #{userID}
  561. WHERE (clubID = #{clubID}
  562. <if test="clubID == null or clubID == ''">or userID = #{userID}</if>
  563. )
  564. </update>
  565. <delete id="delete">
  566. DELETE
  567. FROM club
  568. WHERE clubID = #{clubID}
  569. </delete>
  570. <select id="findDistributionCLubList" resultType="com.caimei.modules.user.entity.NewCmClub">
  571. SELECT
  572. <include refid="newCmClubColumns"/>,
  573. u.registerTime,
  574. u.userName,
  575. u.bindMobile
  576. FROM club a
  577. LEFT JOIN user u ON u.userID = a.userID
  578. <where>
  579. (u.userOrganizeID IN(0,1) or u.clubStatus != 92) and u.userOrganizeID != 4 and a.status != 92
  580. <if test="clubID != null and clubID != ''">
  581. AND a.clubID = #{clubID}
  582. </if>
  583. <if test="userID != null and userID != ''">
  584. AND a.userID = #{userID}
  585. </if>
  586. <if test="account != null and account != ''">
  587. AND u.account = #{account}
  588. </if>
  589. <if test="name != null and name != ''">
  590. AND u.name LIKE concat('%',#{name},'%')
  591. </if>
  592. <if test="userName != null and userName != ''">
  593. AND u.userName LIKE concat('%',#{userName},'%')
  594. </if>
  595. <if test="status != null and status != ''">
  596. AND a.status = #{status}
  597. </if>
  598. <if test="bindMobile != null and bindMobile != ''">
  599. AND u.bindMobile LIKE concat('%',#{bindMobile},'%')
  600. </if>
  601. <if test="email != null and email != ''">
  602. AND u.email LIKE concat('%',#{email},'%')
  603. </if>
  604. <if test="linkMan != null and linkMan != ''">
  605. AND a.linkMan LIKE concat('%',#{linkMan},'%')
  606. </if>
  607. <if test="startTime != null and startTime != ''">
  608. AND (u.registerTime &gt; #{startTime} OR u.registerTime = #{startTime})
  609. </if>
  610. <if test="endTime != null and endTime != ''">
  611. AND (u.registerTime &lt; #{endTime} OR u.registerTime = #{endTime})
  612. </if>
  613. <if test="startLoginTime != null and startLoginTime != ''">
  614. AND (u.loginTime &gt; #{startLoginTime} OR u.loginTime = #{startLoginTime})
  615. </if>
  616. <if test="endLoginTime != null and endLoginTime != ''">
  617. AND (u.loginTime &lt; #{endLoginTime} OR u.loginTime = #{endLoginTime})
  618. </if>
  619. <if test="userIdentity != null and userIdentity != ''">
  620. AND u.userIdentity = #{userIdentity}
  621. </if>
  622. <if test="newDeal != null">
  623. AND a.newDeal =#{newDeal}
  624. </if>
  625. <if test="spID != null and spID != ''">
  626. AND a.spID = #{spID}
  627. </if>
  628. </where>
  629. group by a.clubId
  630. <choose>
  631. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  632. ORDER BY ${page.orderBy}
  633. </when>
  634. <otherwise>
  635. ORDER BY case when a.status = 91 then 0 else 1 end desc, u.registerTime DESC
  636. </otherwise>
  637. </choose>
  638. </select>
  639. <select id="findClubById" resultType="com.caimei.modules.user.entity.NewCmClub">
  640. SELECT
  641. <include refid="newCmClubColumns"/>
  642. , CONCAT(d.name,c.name ,b.name ,a.`address` ) address
  643. FROM club a
  644. LEFT JOIN user u ON u.userID = a.userID
  645. LEFT JOIN town b ON a.townID =b.townID
  646. LEFT JOIN city c ON b.cityID=c.cityID
  647. JOIN province d ON c.`provinceID` =d.`provinceID`
  648. WHERE a.clubID=#{clubID}
  649. </select>
  650. <select id="findSpId" resultType="java.lang.Integer">
  651. select serviceProviderID
  652. from serviceprovider
  653. where serviceProviderID = #{spID}
  654. and status = 90
  655. </select>
  656. <select id="findRemarksList" resultType="com.caimei.modules.user.entity.CmClubRemarks">
  657. select DISTINCT ccr.id as remarksId,
  658. ccr.remarks,
  659. s.linkMan as spName,
  660. ccr.addTime,
  661. ccr.questionMan,
  662. ccr.consultType as consult,
  663. ccr.clubType,
  664. ccr.pinceSensitve,
  665. ccr.satisfied,
  666. ccr.followup,
  667. ccr.extra,
  668. (SELECT NAME FROM serviceprovider s WHERE s.serviceProviderID = csr.leaderId) AS leaderName
  669. from cm_club_remarks ccr
  670. left join serviceprovider s on ccr.serviceProviderId = s.serviceProviderID
  671. LEFT JOIN cm_serviceteam_group csg ON ccr.serviceProviderId = csg.serviceId
  672. LEFT JOIN cm_serviceteam_role csr ON csr.id = csg.teamId
  673. where clubId = #{clubId}
  674. order by addTime desc
  675. </select>
  676. <select id="getRemarksImageList" resultType="java.lang.String">
  677. select imageUrl
  678. from cm_club_remarks_file
  679. where remarksId = #{remarksId}
  680. and fileType = 1
  681. </select>
  682. <select id="getRemarksFileList" resultType="com.caimei.modules.user.entity.RemarksFileVo">
  683. select fileName, ossName
  684. from cm_club_remarks_file
  685. where remarksId = #{remarksId}
  686. and fileType = 2
  687. </select>
  688. <insert id="insertBeansHistory">
  689. INSERT INTO `user_beans_history` (`userId`, `type`, `beansType`, `orderId`,
  690. `num`, `pushStatus`, `addTime`, delFlag)
  691. VALUES (#{userId}, #{type}, #{beansType}, #{orderId},
  692. #{num}, #{pushStatus}, #{addTime}, 0)
  693. </insert>
  694. <select id="findLowOrder" resultType="com.caimei.modules.user.entity.UserBeansHistory">
  695. select userId, type, beansType, orderId, num, addTime
  696. from user_beans_history
  697. where orderId = #{orderId}
  698. and delFlag = 0
  699. and type = 2
  700. and num = 500
  701. </select>
  702. <select id="findRegistList" resultType="com.caimei.modules.user.entity.CmClubRemarks">
  703. SELECT DISTINCT
  704. ccr.id AS remarksId, ccr.remarks,s.linkman AS spName, ccr.addTime,ccr.questionMan,
  705. csr.leaderId AS leaderId,IFNULL(ccr.consultType,'') AS consult, c.Name AS
  706. clubName,ccr.clubType,ccr.pinceSensitve,ccr.satisfied,ccr.followup,ccr.extra,c.newDeal,c.contractMobile,
  707. (SELECT NAME FROM serviceprovider s WHERE s.serviceProviderID= csr.leaderId) AS leaderName,
  708. (SELECT mainImage FROM product p WHERE p.productID= ccre.productID) AS productMainImage,
  709. (SELECT NAME FROM product p WHERE p.productID= ccre.productID) AS proName,
  710. # (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID= ccr.serviceProviderID) AS oldName
  711. ccre.reportText AS reportText,ccre.status AS reportStatus,ccre.auditName AS auditName,ccre.auditTime AS
  712. auditTime,p.mainImage
  713. AS mainImage,p.name AS productName,sh.name AS shopName
  714. FROM cm_club_remarks ccr
  715. LEFT JOIN serviceprovider s ON ccr.createServiceProviderId = s.serviceProviderID
  716. LEFT JOIN club c ON c.clubId=ccr.clubId
  717. # LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
  718. LEFT JOIN cm_serviceTeam_group csg ON ccr.createServiceProviderId = csg.serviceId
  719. LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
  720. LEFT JOIN cm_club_report ccre ON ccre.Id= ccr.reportID
  721. LEFT JOIN product p ON p.productID = ccr.productID
  722. LEFT JOIN shop sh ON sh.shopID = p.shopID
  723. <where>
  724. <if test="remarks != null and remarks !=''">
  725. AND ccr.remarks LIKE concat('%',#{remarks},'%')
  726. </if>
  727. <if test="clubId != null">
  728. AND c.clubID = #{clubId}
  729. </if>
  730. <if test="contractMobile != null and contractMobile != ''">
  731. AND c.contractMobile = #{contractMobile}
  732. </if>
  733. <if test="clubName !=null and clubName !=''">
  734. AND c.Name like concat('%',#{clubName},'%')
  735. </if>
  736. <if test="leaderId != null">
  737. and csr.leaderId = #{leaderId}
  738. </if>
  739. <if test="serviceProviderId != null">
  740. and csg.serviceId = #{serviceProviderId}
  741. </if>
  742. <if test="startAddTime != null and startAddTime != ''">
  743. and ccr.addTime <![CDATA[ > ]]> #{startAddTime}
  744. </if>
  745. <if test="endAddTime != null and endAddTime != ''">
  746. and ccr.addTime <![CDATA[ < ]]> #{endAddTime}
  747. </if>
  748. <if test="newDeal !=null">
  749. and c.newDeal=#{newDeal}
  750. </if>
  751. <if test="reportID !=null">
  752. and ccr.reportID=#{reportID}
  753. </if>
  754. </where>
  755. -- group by p.productID
  756. ORDER BY ADDTIME DESC
  757. <choose>
  758. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  759. ORDER BY ${page.orderBy}
  760. </when>
  761. </choose>
  762. </select>
  763. <select id="findConsults" resultType="com.caimei.modules.consult.entity.type.CmConsulttype">
  764. select id, className, createdTime
  765. from cm_consulttype
  766. where delflag = 0
  767. </select>
  768. <select id="findTeams" resultType="com.caimei.modules.user.entity.CmSaleMan">
  769. select csr.leaderId, s.name as leaderName
  770. from cm_serviceteam_role csr
  771. left join serviceprovider s on s.serviceProviderID = csr.leaderId
  772. where csr.delflag = 0
  773. </select>
  774. <select id="findGroup" resultType="com.caimei.modules.project.model.ServiceProviderModel">
  775. SELECT serviceId as serviceProviderID, s.name
  776. FROM cm_serviceteam_group csg
  777. LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamid
  778. LEFT JOIN serviceprovider s ON s.serviceProviderID = csg.serviceId
  779. WHERE csr.leaderId = #{leaderId}
  780. </select>
  781. <select id="findClassName" resultType="java.lang.String">
  782. select className
  783. from cm_consulttype
  784. where id = #{string}
  785. </select>
  786. <delete id="deleteRamarks">
  787. DELETE
  788. FROM `cm_remarks`
  789. WHERE remarksId = #{remarksId}
  790. </delete>
  791. <insert id="addRemarks">
  792. INSERT INTO `cm_remarks`(remarks, `addtime`)
  793. VALUES (#{remarks}, #{addtime})
  794. </insert>
  795. <update id="upremarks">
  796. UPDATE `cm_remarks`
  797. SET remarks = #{remarks}
  798. WHERE remarksId = #{remarksId}
  799. </update>
  800. <select id="upremakasList" resultType="java.lang.String">
  801. SELECT remarks
  802. FROM `cm_remarks`
  803. WHERE remarksId = #{remarksId}
  804. </select>
  805. <select id="ClubsIds" resultType="java.lang.Integer">
  806. select oldserviceProviderId
  807. FROM `cm_club_remarks`
  808. WHERE clubId = #{clubID}
  809. </select>
  810. <update id="oldname">
  811. UPDATE cm_club_remarks
  812. SET oldserviceProviderId = #{oldserviceProviderId},
  813. serviceProviderId=#{newSpID}
  814. WHERE clubId = #{clubID}
  815. AND serviceProviderId = #{oldSpID}
  816. </update>
  817. <update id="oldnames">
  818. UPDATE cm_club_remarks
  819. SET serviceProviderId=#{newSpID}
  820. WHERE clubId = #{clubID}
  821. AND serviceProviderId = #{oldSpID}
  822. </update>
  823. <select id="ReportList" resultType="com.caimei.modules.user.entity.CmReport">
  824. SELECT ccr.Id as reportId, p.mainImage AS mainImage,p.`name` AS productName,c.`name` AS clubName,ccr.reportName
  825. AS reportName,
  826. ccr.reportText AS reportText,ccr.addTime AS ADDTIME,ccr.status AS STATUS,ccr.auditName AS
  827. auditName,ccr.auditTime AS auditTime,c.newDeal,ccr.auditText
  828. FROM cm_club_report ccr
  829. LEFT JOIN product p ON p.productID = ccr.productID
  830. LEFT JOIN club c ON c.clubID = ccr.clubID
  831. <where>
  832. <if test="reportId!=null and reportId!=''">
  833. AND ccr.id=#{reportId}
  834. </if>
  835. <if test="productName!=null and productName!=''">
  836. AND p.name LIKE concat('%',#{productName},'%')
  837. </if>
  838. <if test="clubID != null">
  839. c.clubID = #{clubID}
  840. </if>
  841. <if test="clubName!=null and clubName!=''">
  842. AND c.name LIKE concat('%',#{clubName},'%')
  843. </if>
  844. <if test="newDeal!=null">
  845. AND c.newDeal =#{newDeal}
  846. </if>
  847. <if test="startAddTime != null and startAddTime != ''">
  848. and ccr.addTime <![CDATA[ > ]]> #{startAddTime}
  849. </if>
  850. <if test="endAddTime != null and endAddTime != ''">
  851. and ccr.addTime <![CDATA[ < ]]> #{endAddTime}
  852. </if>
  853. </where>
  854. -- group by p.productID
  855. ORDER BY ccr.`addTime` DESC
  856. </select>
  857. <select id="findRegistLists" resultType="com.caimei.modules.user.entity.VisitRemarkVo">
  858. SELECT DISTINCT
  859. ccr.id AS remarksId, ccr.remarks,s.name AS spName, ccr.addTime,ccr.questionMan,
  860. csr.leaderId AS leaderId,IFNULL(ccr.consultType,'') AS
  861. consult,ccr.clubType,ccr.pinceSensitve,ccr.satisfied,ccr.followup,ccr.extra,
  862. (SELECT linkMan FROM serviceprovider s WHERE s.serviceProviderID = ccr.serviceProviderId) AS serviceName,
  863. (SELECT NAME FROM serviceprovider s WHERE s.serviceProviderID = csr.leaderId) AS leaderName,
  864. (SELECT mainImage FROM product p WHERE p.productID= ccre.productID) AS productMainImage,
  865. (SELECT NAME FROM product p WHERE p.productID= ccre.productID) AS proName,
  866. ccre.reportText AS reportText,ccre.status AS reportStatus,ccre.auditName,ccre.auditTime AS auditTime,p.mainImage
  867. AS mainImage,p.name AS productName,sh.name AS shopName
  868. FROM cm_visitor_remarks ccr
  869. LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
  870. LEFT JOIN cm_serviceTeam_group csg ON ccr.serviceProviderId = csg.serviceId
  871. LEFT JOIN cm_serviceTeam_role csr ON csr.id = csg.teamId
  872. LEFT JOIN cm_club_report ccre ON ccre.Id= ccr.reportID
  873. LEFT JOIN product p ON p.productID = ccr.productID
  874. LEFT JOIN shop sh ON sh.shopID = p.shopID
  875. LEFT JOIN club c ON c.clubID = ccr.clubID
  876. <where>
  877. <if test="remarks != null and remarks !=''">
  878. AND ccr.remarks LIKE concat('%',#{remarks},'%')
  879. </if>
  880. <if test="leaderId != null">
  881. and csr.leaderId = #{leaderId}
  882. </if>
  883. <if test="serviceProviderId != null">
  884. and csg.serviceId = #{serviceProviderId}
  885. </if>
  886. <if test="startAddTime != '' and startAddTime != null">
  887. and ccr.addTime <![CDATA[ > ]]> #{startAddTime}
  888. </if>
  889. <if test="endAddTime != '' and endAddTime != null">
  890. and ccr.addTime <![CDATA[ < ]]> #{endAddTime}
  891. </if>
  892. <if test="reportID !=null">
  893. and ccr.reportID=#{reportID}
  894. </if>
  895. <if test="newDeal !=null">
  896. and c.newDeal=#{newDeal}
  897. </if>
  898. and ccr.remarks IS NOT NULL
  899. </where>
  900. -- group by p.productID
  901. ORDER BY ADDTIME DESC
  902. </select>
  903. <select id="visitorRemarksConut" resultType="integer">
  904. SELECT COUNT(*)
  905. FROM cm_visitor_remarks
  906. WHERE reportID = #{reportID}
  907. </select>
  908. <select id="clubRemarksConut" resultType="integer">
  909. SELECT COUNT(*)
  910. FROM cm_club_remarks
  911. WHERE reportID = #{reportID}
  912. </select>
  913. <update id="updateAuditRemarks">
  914. UPDATE cm_club_report
  915. SET status=#{status},
  916. auditName=#{auditName},
  917. auditText=#{auditText},
  918. auditTime=now()
  919. WHERE id = #{reportID}
  920. </update>
  921. <update id="updateClubRemarks">
  922. UPDATE cm_club_remarks
  923. SET reportID=null
  924. WHERE id = #{remarksId}
  925. </update>
  926. <update id="updateVisitorRemarks">
  927. UPDATE cm_visitor_remarks
  928. SET reportID=null
  929. WHERE id = #{remarksId}
  930. </update>
  931. <delete id="deleteClubRemarks">
  932. DELETE
  933. FROM cm_club_report
  934. WHERE id = #{reportID}
  935. </delete>
  936. <insert id="addRecordLinkage">
  937. INSERT INTO `record_link`(`describe`, `link`, clubId, addTime)
  938. VALUES (#{describe}, #{link}, #{clubId}, now())
  939. </insert>
  940. <select id="recordLinkage" resultType="string">
  941. SELECT link
  942. from record_link
  943. where clubId = #{clubId}
  944. ORDER BY id DESC
  945. LIMIT 1
  946. </select>
  947. <select id="recordDescribe" resultType="string">
  948. SELECT `describe`
  949. from record_link
  950. where clubId = #{clubId}
  951. ORDER BY id DESC
  952. LIMIT 1
  953. </select>
  954. <select id="selRegisterIP" resultType="com.caimei.modules.user.entity.CmBehaviorRecord">
  955. SELECT u.registerIP, u.ipAddress AS region, u.registerTime
  956. FROM USER u
  957. LEFT JOIN club c ON u.userID = c.userID
  958. WHERE c.clubID = #{clubId}
  959. </select>
  960. <select id="selStatisticsList" resultType="com.caimei.modules.user.entity.ClubStatistics">
  961. SELECT
  962. u.userId,
  963. c.clubID,
  964. c.name,
  965. c.linkMan,
  966. c.contractMobile,
  967. c.linkManIdentity,
  968. c.address,
  969. c.businessLicenseImage,
  970. u.userIdentity,
  971. c.sname,
  972. c.contractEmail,
  973. c.contractPhone,
  974. c.fax,
  975. c.headpic,
  976. c.socialCreditCode,
  977. c.info,
  978. (CASE WHEN c.linkManIdentity=1 THEN '老板'
  979. WHEN c.linkManIdentity=2 THEN '采购'
  980. WHEN c.linkManIdentity=3 THEN '运营'
  981. WHEN c.linkManIdentity=4 THEN '其他'
  982. END) AS linkManStatus,
  983. (CASE WHEN c.status = 1 THEN '待审核'
  984. WHEN c.status=91 THEN '已下线'
  985. WHEN c.status=90 THEN '已上线'
  986. WHEN c.status=92 THEN '审核未通过'
  987. WHEN c.status=93 THEN '已确认'
  988. ELSE '已冻结' END) AS clubStatus,
  989. (CASE WHEN u.userIdentity=2 THEN '资质机构'
  990. ELSE '个人机构' END) AS clubRank,
  991. (CASE WHEN c.firstClubType=1 THEN '医美'
  992. WHEN c.firstClubType=2 THEN '生美'
  993. WHEN c.firstClubType=3 THEN '项目公司'
  994. WHEN c.firstClubType=4 THEN '个人'
  995. ELSE '其他' END) AS firstClubType,
  996. (CASE WHEN c.secondClubType=1 THEN '诊所'
  997. WHEN c.secondClubType=2 THEN '门诊'
  998. WHEN c.secondClubType=3 THEN '医院'
  999. WHEN c.secondClubType=5 THEN '美容院'
  1000. WHEN c.secondClubType=6 THEN '养生馆'
  1001. WHEN c.secondClubType=7 THEN '其他'
  1002. END) AS classify,
  1003. c.addTime AS addTime,
  1004. IF(csu.delFlag = '0' AND NOW() <![CDATA[ < ]]> csu.endTime,1,0) AS svipUserFlag,
  1005. case sp.status when 91 then '采美默认协销经理(官方账号)' else sp.linkMan end AS spName,
  1006. IFNULL(orderMonth.payTotalMonth,0) AS payTotalMonth,
  1007. IFNULL(orderMonth.orderCountMonth,0) AS orderCountMonth,
  1008. IFNULL(orderYesr.payTotalYesr,0) AS payTotalYear,
  1009. IFNULL(orderYesr.orderCountYesr,0) AS orderCountYear,
  1010. IFNULL(orderTotal.payTotal,0) AS payTotal,
  1011. ordr.lastOrderTime AS lastOrderTime
  1012. FROM club c
  1013. # LEFT JOIN cm_order cor ON c.userID = cor.userID
  1014. LEFT JOIN USER u ON u.userId=c.userId
  1015. LEFT JOIN cm_svip_user csu ON csu.userId = u.userID
  1016. LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
  1017. LEFT JOIN
  1018. (SELECT userId,SUM(co.payTotalFee) AS payTotalMonth,
  1019. COUNT(co.orderid) AS orderCountMonth
  1020. FROM cm_order co
  1021. <where>
  1022. co.status NOT IN (0,6,7)
  1023. <if test="monthStartTime != null and monthStartTime != '' and monthEndTime != null and monthEndTime != ''">
  1024. AND co.orderTime BETWEEN #{monthStartTime} AND #{monthEndTime}
  1025. </if>
  1026. </where>
  1027. GROUP BY co.userid) AS orderMonth ON c.userId=orderMonth.userId
  1028. LEFT JOIN
  1029. (SELECT userId,SUM(co.payTotalFee) AS payTotalYesr,
  1030. COUNT(co.orderid) AS orderCountYesr
  1031. FROM cm_order co
  1032. <where>
  1033. co.status NOT IN (0,6,7)
  1034. <if test="yearStartTime != null and yearStartTime != '' and yearEndTime != null and yearEndTime != ''">
  1035. AND co.orderTime BETWEEN #{yearStartTime} AND #{yearEndTime}
  1036. </if>
  1037. </where>
  1038. GROUP BY co.userid) AS orderYesr ON c.userId=orderYesr.userId
  1039. LEFT JOIN
  1040. (SELECT userId,SUM(co.payTotalFee) AS payTotal,
  1041. COUNT(co.orderid) AS 21OrderCount
  1042. FROM cm_order co
  1043. <where>
  1044. co.status NOT IN (0,6,7)
  1045. <if test="customStartTime != null and customStartTime != ''">
  1046. AND (co.orderTime > #{customStartTime} or co.orderTime = #{customStartTime})
  1047. </if>
  1048. <if test="customEndTime != null and customEndTime != ''">
  1049. AND co.orderTime <![CDATA[ <= ]]> #{customEndTime}
  1050. </if>
  1051. </where>
  1052. GROUP BY co.userid) AS orderTotal ON c.userId=orderTotal.userId
  1053. LEFT JOIN (
  1054. SELECT userID, MAX(orderTime) AS lastOrderTime FROM cm_order GROUP BY userID
  1055. ) AS ordr ON c.userID = ordr.userID
  1056. <where>
  1057. u.userOrganizeID != 4
  1058. <if test="registerStartTime != null and registerStartTime != ''">
  1059. AND (c.addTime > #{registerStartTime} or c.addTime = #{registerStartTime} )
  1060. </if>
  1061. <if test="registerEndTime != null and registerEndTime != ''">
  1062. AND c.addTime <![CDATA[ <= ]]> #{registerEndTime}
  1063. </if>
  1064. <if test="searchStartTime != null and searchStartTime != ''">
  1065. AND (ordr.lastOrderTime > #{searchStartTime} or ordr.lastOrderTime = #{searchStartTime} )
  1066. </if>
  1067. <if test=" searchEndTime != null and searchEndTime != ''">
  1068. AND ordr.lastOrderTime <![CDATA[ <= ]]> #{searchEndTime}
  1069. </if>
  1070. <if test="customerValue != null and customerValue != ''">
  1071. AND c.firstClubType = #{customerValue}
  1072. </if>
  1073. <if test="searchUserIdentity != null and searchUserIdentity != '' and searchUserIdentity != '8'.toString()">
  1074. AND u.userIdentity = #{searchUserIdentity}
  1075. </if>
  1076. <if test="searchUserIdentity != null and searchUserIdentity != '' and searchUserIdentity == '8'.toString()">
  1077. AND csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
  1078. </if>
  1079. <if test="searchStatus != null and searchStatus != ''">
  1080. AND c.status = #{searchStatus}
  1081. </if>
  1082. <if test="linkManIdentity != null and linkManIdentity != ''">
  1083. AND c.linkManIdentity = #{linkManIdentity}
  1084. </if>
  1085. <if test="payTotalMonth != null and payTotalMonth != ''">
  1086. <if test="payTotalMonth==1">
  1087. AND orderMonth.payTotalMonth <![CDATA[ < ]]> 10000
  1088. </if>
  1089. <if test="payTotalMonth==2">
  1090. AND orderMonth.payTotalMonth BETWEEN 10000 AND 100000
  1091. </if>
  1092. <if test="payTotalMonth==3">
  1093. AND orderMonth.payTotalMonth BETWEEN 100000 AND 1000000
  1094. </if>
  1095. <if test="payTotalMonth==4">
  1096. AND orderMonth.payTotalMonth <![CDATA[ > ]]> 1000000
  1097. </if>
  1098. </if>
  1099. <if test="payTotalYear != null and payTotalYear != ''">
  1100. <if test="payTotalYear==1">
  1101. AND orderYesr.payTotalYesr <![CDATA[ < ]]> 10000
  1102. </if>
  1103. <if test="payTotalYear==2">
  1104. AND orderYesr.payTotalYesr BETWEEN 10000 AND 100000
  1105. </if>
  1106. <if test="payTotalYear==3">
  1107. AND orderYesr.payTotalYesr BETWEEN 100000 AND 1000000
  1108. </if>
  1109. <if test="payTotalYear==4">
  1110. AND orderYesr.payTotalYesr <![CDATA[ > ]]> 1000000
  1111. </if>
  1112. </if>
  1113. <if test="payTotal != null and payTotal != ''">
  1114. <if test="payTotal==1">
  1115. AND orderTotal.payTotal <![CDATA[ < ]]> 10000
  1116. </if>
  1117. <if test="payTotal==2">
  1118. AND orderTotal.payTotal BETWEEN 10000 AND 100000
  1119. </if>
  1120. <if test="payTotal==3">
  1121. AND orderTotal.payTotal BETWEEN 100000 AND 1000000
  1122. </if>
  1123. <if test="payTotal==4">
  1124. AND orderTotal.payTotal <![CDATA[ > ]]> 1000000
  1125. </if>
  1126. </if>
  1127. </where>
  1128. GROUP BY c.userID ORDER BY
  1129. <if test="payTotalMonthType == null and orderCountMonthType == null and payTotalYearType == null and orderCountYearType == null and payTotalType == null">
  1130. ordr.lastOrderTime DESC
  1131. </if>
  1132. <if test="orderCountMonthType != null">
  1133. <if test="orderCountMonthType == 0">
  1134. orderMonth.orderCountMonth
  1135. </if>
  1136. <if test="orderCountMonthType == 1">
  1137. orderMonth.orderCountMonth DESC
  1138. </if>
  1139. </if>
  1140. <if test="orderCountYearType != null">
  1141. <if test="orderCountYearType == 0">
  1142. orderYesr.orderCountYesr
  1143. </if>
  1144. <if test="orderCountYearType == 1">
  1145. orderYesr.orderCountYesr DESC
  1146. </if>
  1147. </if>
  1148. <if test="payTotalMonthType != null">
  1149. <if test="payTotalMonthType == 0">
  1150. orderMonth.payTotalMonth
  1151. </if>
  1152. <if test="payTotalMonthType == 1">
  1153. orderMonth.payTotalMonth DESC
  1154. </if>
  1155. </if>
  1156. <if test="payTotalYearType != null">
  1157. <if test="payTotalYearType == 0">
  1158. orderYesr.payTotalYesr
  1159. </if>
  1160. <if test="payTotalYearType == 1">
  1161. orderYesr.payTotalYesr DESC
  1162. </if>
  1163. </if>
  1164. <if test="payTotalType != null">
  1165. <if test="payTotalType == 0">
  1166. orderTotal.payTotal
  1167. </if>
  1168. <if test="payTotalType == 1">
  1169. orderTotal.payTotal DESC
  1170. </if>
  1171. </if>
  1172. </select>
  1173. <select id="selPageLable" resultType="com.caimei.modules.user.entity.CmBehaviorRecord">
  1174. SELECT c.userID, COUNT(pageType) AS number, cbr.pageLabel
  1175. FROM club c
  1176. LEFT JOIN cm_behavior_record cbr ON cbr.userID = c.userID
  1177. WHERE cbr.userID = c.userID
  1178. AND cbr.pageType in (8, 9)
  1179. GROUP BY c.userID, cbr.pageLabel
  1180. </select>
  1181. <select id="findExcelList" resultType="com.caimei.modules.user.entity.easyExcel">
  1182. SELECT
  1183. u.userId,
  1184. c.clubID,
  1185. c.name,
  1186. c.linkMan,
  1187. c.contractMobile,
  1188. c.linkManIdentity,
  1189. c.address,
  1190. c.businessLicenseImage,
  1191. u.userIdentity,
  1192. c.sname,
  1193. c.contractEmail,
  1194. c.contractPhone,
  1195. c.fax,
  1196. c.headpic,
  1197. c.socialCreditCode,
  1198. c.info,
  1199. (CASE WHEN c.linkManIdentity=1 THEN '老板'
  1200. WHEN c.linkManIdentity=2 THEN '采购'
  1201. WHEN c.linkManIdentity=3 THEN '运营'
  1202. WHEN c.linkManIdentity=4 THEN '其他'
  1203. END) AS linkManStatus,
  1204. (CASE WHEN c.status = 1 THEN '待审核'
  1205. WHEN c.status=91 THEN '已下线'
  1206. WHEN c.status=90 THEN '已上线'
  1207. WHEN c.status=92 THEN '审核未通过'
  1208. WHEN c.status=93 THEN '已确认'
  1209. ELSE '已冻结' END) AS clubStatus,
  1210. (CASE WHEN u.userIdentity=2 THEN '资质机构'
  1211. ELSE '个人机构' END) AS clubRank,
  1212. (CASE WHEN c.firstClubType=1 THEN '医美'
  1213. WHEN c.firstClubType=2 THEN '生美'
  1214. WHEN c.firstClubType=3 THEN '项目公司'
  1215. WHEN c.firstClubType=4 THEN '个人'
  1216. ELSE '其他' END) AS firstClubType,
  1217. (CASE WHEN c.secondClubType=1 THEN '诊所'
  1218. WHEN c.secondClubType=2 THEN '门诊'
  1219. WHEN c.secondClubType=3 THEN '医院'
  1220. WHEN c.secondClubType=5 THEN '美容院'
  1221. WHEN c.secondClubType=6 THEN '养生馆'
  1222. WHEN c.secondClubType=7 THEN '其他'
  1223. END) AS classify,
  1224. c.addTime AS addTime,
  1225. IF(csu.delFlag = '0' AND NOW() <![CDATA[ < ]]> csu.endTime,1,0) AS svipUserFlag,
  1226. case sp.status when 91 then '采美默认协销经理(官方账号)' else sp.linkMan end AS spName,
  1227. IFNULL(orderMonth.payTotalMonth,0) AS payTotalMonth,
  1228. IFNULL(orderMonth.orderCountMonth,0) AS orderCountMonth,
  1229. IFNULL(orderYesr.payTotalYesr,0) AS payTotalYear,
  1230. IFNULL(orderYesr.orderCountYesr,0) AS orderCountYear,
  1231. IFNULL(orderTotal.payTotal,0) AS payTotal,
  1232. pb.pageLabel,
  1233. ordr.lastOrderTime AS lastOrderTime
  1234. FROM club c
  1235. # LEFT JOIN cm_order cor ON c.userID = cor.userID
  1236. LEFT JOIN USER u ON u.userId=c.userId
  1237. LEFT JOIN cm_svip_user csu ON csu.userId = u.userID
  1238. LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
  1239. LEFT JOIN
  1240. (SELECT userId,SUM(co.payTotalFee) AS payTotalMonth,
  1241. COUNT(co.orderid) AS orderCountMonth
  1242. FROM cm_order co
  1243. <where>
  1244. co.status NOT IN (0,6,7)
  1245. <if test="monthStartTime != null and monthStartTime != '' and monthEndTime != null and monthEndTime != ''">
  1246. AND co.orderTime BETWEEN #{monthStartTime} AND #{monthEndTime}
  1247. </if>
  1248. </where>
  1249. GROUP BY co.userid) AS orderMonth ON c.userId=orderMonth.userId
  1250. LEFT JOIN
  1251. (SELECT userId,SUM(co.payTotalFee) AS payTotalYesr,
  1252. COUNT(co.orderid) AS orderCountYesr
  1253. FROM cm_order co
  1254. <where>
  1255. co.status NOT IN (0,6,7)
  1256. <if test="yearStartTime != null and yearStartTime != '' and yearEndTime != null and yearEndTime != ''">
  1257. AND co.orderTime BETWEEN #{yearStartTime} AND #{yearEndTime}
  1258. </if>
  1259. </where>
  1260. GROUP BY co.userid) AS orderYesr ON c.userId=orderYesr.userId
  1261. LEFT JOIN
  1262. (SELECT userId,SUM(co.payTotalFee) AS payTotal,
  1263. COUNT(co.orderid) AS 21OrderCount
  1264. FROM cm_order co
  1265. <where>
  1266. co.status NOT IN (0,6,7)
  1267. <if test="customStartTime != null and customStartTime != ''">
  1268. AND (co.orderTime > #{customStartTime} or co.orderTime = #{customStartTime})
  1269. </if>
  1270. <if test="customEndTime != null and customEndTime != ''">
  1271. AND co.orderTime <![CDATA[ <= ]]> #{customEndTime}
  1272. </if>
  1273. </where>
  1274. GROUP BY co.userid) AS orderTotal ON c.userId=orderTotal.userId
  1275. LEFT JOIN
  1276. (
  1277. SELECT c.userID, COUNT(cbr.pageLabel), cbr.pageLabel
  1278. FROM cm_behavior_record cbr
  1279. LEFT JOIN club c ON cbr.userID = c.userID
  1280. <where>cbr.userID = c.userID</where>
  1281. GROUP BY cbr.pageLabel) AS pb ON c.userID = pb.userID
  1282. LEFT JOIN (
  1283. SELECT userID, MAX(orderTime) AS lastOrderTime FROM cm_order GROUP BY userID
  1284. ) AS ordr ON c.userID = ordr.userID
  1285. <where>
  1286. <if test="registerStartTime != null and registerStartTime != ''">
  1287. AND (c.addTime > #{registerStartTime} or c.addTime = #{registerStartTime} )
  1288. </if>
  1289. <if test="registerEndTime != null and registerEndTime != ''">
  1290. AND c.addTime <![CDATA[ <= ]]> #{registerEndTime}
  1291. </if>
  1292. <if test="searchStartTime != null and searchStartTime != ''">
  1293. AND (ordr.lastOrderTime > #{searchStartTime} or ordr.lastOrderTime = #{searchStartTime} )
  1294. </if>
  1295. <if test=" searchEndTime != null and searchEndTime != ''">
  1296. AND ordr.lastOrderTime <![CDATA[ <= ]]> #{searchEndTime}
  1297. </if>
  1298. <if test="customerValue != null and customerValue != ''">
  1299. AND c.firstClubType = #{customerValue}
  1300. </if>
  1301. <if test="searchUserIdentity != null and searchUserIdentity != '' and searchUserIdentity != '8'.toString()">
  1302. AND u.userIdentity = #{searchUserIdentity}
  1303. </if>
  1304. <if test="searchUserIdentity != null and searchUserIdentity != '' and searchUserIdentity == '8'.toString()">
  1305. AND csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
  1306. </if>
  1307. <if test="searchStatus != null and searchStatus != ''">
  1308. AND c.status = #{searchStatus}
  1309. </if>
  1310. <if test="linkManIdentity != null and linkManIdentity != ''">
  1311. AND c.linkManIdentity = #{linkManIdentity}
  1312. </if>
  1313. <if test="searchStatus != null and searchStatus != ''">
  1314. AND c.status = #{searchStatus}
  1315. </if>
  1316. <if test="payTotalMonth != null and payTotalMonth != ''">
  1317. <if test="payTotalMonth==1">
  1318. AND orderMonth.payTotalMonth <![CDATA[ < ]]> 10000
  1319. </if>
  1320. <if test="payTotalMonth==2">
  1321. AND orderMonth.payTotalMonth BETWEEN 10000 AND 100000
  1322. </if>
  1323. <if test="payTotalMonth==3">
  1324. AND orderMonth.payTotalMonth BETWEEN 100000 AND 1000000
  1325. </if>
  1326. <if test="payTotalMonth==4">
  1327. AND orderMonth.payTotalMonth <![CDATA[ > ]]> 1000000
  1328. </if>
  1329. </if>
  1330. <if test="payTotalYear != null and payTotalYear != ''">
  1331. <if test="payTotalYear==1">
  1332. AND orderYesr.payTotalYesr <![CDATA[ < ]]> 10000
  1333. </if>
  1334. <if test="payTotalYear==2">
  1335. AND orderYesr.payTotalYesr BETWEEN 10000 AND 100000
  1336. </if>
  1337. <if test="payTotalYear==3">
  1338. AND orderYesr.payTotalYesr BETWEEN 100000 AND 1000000
  1339. </if>
  1340. <if test="payTotalYear==4">
  1341. AND orderYesr.payTotalYesr <![CDATA[ > ]]> 1000000
  1342. </if>
  1343. </if>
  1344. <if test="payTotal != null and payTotal != ''">
  1345. <if test="payTotal==1">
  1346. AND orderTotal.payTotal <![CDATA[ < ]]> 10000
  1347. </if>
  1348. <if test="payTotal==2">
  1349. AND orderTotal.payTotal BETWEEN 10000 AND 100000
  1350. </if>
  1351. <if test="payTotal==3">
  1352. AND orderTotal.payTotal BETWEEN 100000 AND 1000000
  1353. </if>
  1354. <if test="payTotal==4">
  1355. AND orderTotal.payTotal <![CDATA[ > ]]> 1000000
  1356. </if>
  1357. </if>
  1358. </where>
  1359. GROUP BY c.userID ORDER BY ordr.lastOrderTime DESC
  1360. </select>
  1361. <select id="getClubIds" resultType="String">
  1362. SELECT
  1363. a.clubID
  1364. FROM club a
  1365. <include refid="newCmClubJoins"/>
  1366. <where>
  1367. AND a.status =90 and u.userOrganizeID IN(0,1) AND u.userIdentity != 8
  1368. </where>
  1369. </select>
  1370. <select id="getActiveClubInfo" resultType="com.caimei.modules.user.entity.ActiveClub">
  1371. SELECT
  1372. DISTINCT u.userId,
  1373. coas.activeStatus,
  1374. c.clubID,
  1375. c.name,
  1376. c.linkMan,
  1377. c.contractMobile,
  1378. c.linkManIdentity,
  1379. c.address,
  1380. u.userIdentity,
  1381. u.registerTime,
  1382. c.sname,
  1383. c.info,
  1384. d.name AS province,
  1385. c.name AS city,
  1386. b.name AS town,
  1387. (CASE WHEN c.linkManIdentity=1 THEN '老板'
  1388. WHEN c.linkManIdentity=2 THEN '采购'
  1389. WHEN c.linkManIdentity=3 THEN '运营'
  1390. WHEN c.linkManIdentity=4 THEN '其他'
  1391. END) AS linkManStatus,
  1392. (CASE WHEN c.status = 1 THEN '待审核'
  1393. WHEN c.status=91 THEN '已下线'
  1394. WHEN c.status=90 THEN '已上线'
  1395. WHEN c.status=92 THEN '审核未通过'
  1396. WHEN c.status=93 THEN '已确认'
  1397. ELSE '已冻结' END) AS clubStatus,
  1398. (CASE WHEN u.userIdentity=2 THEN '资质机构'
  1399. ELSE '个人机构' END) AS clubRank,
  1400. (CASE WHEN c.firstClubType=1 THEN '医美'
  1401. WHEN c.firstClubType=2 THEN '生美'
  1402. WHEN c.firstClubType=3 THEN '项目公司'
  1403. WHEN c.firstClubType=4 THEN '个人'
  1404. ELSE '其他' END) AS firstClubType,
  1405. (CASE WHEN c.secondClubType=1 THEN '诊所'
  1406. WHEN c.secondClubType=2 THEN '门诊'
  1407. WHEN c.secondClubType=3 THEN '医院'
  1408. WHEN c.secondClubType=5 THEN '美容院'
  1409. WHEN c.secondClubType=6 THEN '养生馆'
  1410. WHEN c.secondClubType=7 THEN '其他'
  1411. END) AS classify,
  1412. c.addTime AS addTime,
  1413. IF(csu.delFlag = '0' AND NOW() <![CDATA[ < ]]> csu.endTime,1,0) AS svipUserFlag,
  1414. CASE sp.status WHEN 91 THEN '采美默认协销经理(官方账号)' ELSE sp.linkMan END AS spName,
  1415. cb.accessTime AS behaviorTime,
  1416. ccr.addTime AS recentlyTime,
  1417. cso.orderTime as lastOrderTime
  1418. FROM club c
  1419. LEFT JOIN cm_organ_active_system coas ON coas.userId = c.userID
  1420. LEFT JOIN USER u ON u.userId = c.userId
  1421. LEFT JOIN cm_svip_user csu ON csu.userId = u.userID
  1422. LEFT JOIN serviceprovider sp ON sp.serviceProviderID = c.spID
  1423. LEFT JOIN town b ON b.townID = c.townID
  1424. LEFT JOIN city ct ON ct.cityID = c.cityID
  1425. LEFT JOIN province d ON d.provinceID = c.provinceID
  1426. LEFT JOIN (SELECT userId, MAX(accessTime) AS accessTime FROM cm_behavior_record WHERE delFlag = 0 AND userId != 0 GROUP BY userId) cb ON cb.userId = c.userId
  1427. LEFT JOIN (SELECT clubId, ADDTIME FROM (SELECT clubId, ADDTIME FROM cm_club_remarks
  1428. UNION SELECT clubId, ADDTIME FROM cm_visitor_remarks WHERE clubId IS NOT NULL AND clubId != '') remark
  1429. GROUP BY remark.clubId ORDER BY remark.addTime DESC) ccr ON ccr.clubId = c.clubId
  1430. LEFT JOIN (SELECT userId, MAX(orderTime) AS orderTime FROM cm_shop_order GROUP BY userId) cso ON cso.userId = c.userId
  1431. <where>
  1432. coas.stage = 0
  1433. <if test="activeStatus == 0">
  1434. and coas.activeStatus = 0
  1435. </if>
  1436. <if test="activeStatus == 1">
  1437. and coas.activeStatus = 1
  1438. </if>
  1439. <if test="clubID != null and clubID != ''">
  1440. AND c.clubID = #{clubID}
  1441. </if>
  1442. <if test="name != null and name != ''">
  1443. AND c.name LIKE concat('%',#{name},'%')
  1444. </if>
  1445. <if test="linkMan != null and linkMan != ''">
  1446. AND c.linkMan LIKE concat('%',#{linkMan},'%')
  1447. </if>
  1448. <if test="contractMobile != null and contractMobile != ''">
  1449. AND c.contractMobile LIKE concat('%',#{contractMobile},'%')
  1450. </if>
  1451. <if test="spID != null and spID != ''">
  1452. AND c.spID = #{spID}
  1453. </if>
  1454. <if test="firstClubType != null and firstClubType != ''">
  1455. AND c.firstClubType = #{firstClubType}
  1456. </if>
  1457. <if test="linkManIdentity != null and linkManIdentity != ''">
  1458. AND c.linkManIdentity = #{linkManIdentity}
  1459. </if>
  1460. <if test="userIdentity != null and userIdentity != ''">
  1461. AND u.userIdentity = #{userIdentity}
  1462. </if>
  1463. <if test="registerStartTime != null and registerStartTime != ''">
  1464. AND u.registerTime <![CDATA[ >= ]]> #{registerStartTime}
  1465. </if>
  1466. <if test="registerEndTime != null and registerEndTime != ''">
  1467. AND u.registerTime <![CDATA[ <= ]]> #{registerEndTime}
  1468. </if>
  1469. <if test="behaviorStartTime != null and behaviorStartTime != ''">
  1470. AND cb.accessTime <![CDATA[ >= ]]> #{behaviorStartTime}
  1471. </if>
  1472. <if test="behaviorEndTime != null and behaviorEndTime != ''">
  1473. AND cb.accessTime <![CDATA[ <= ]]> #{behaviorEndTime}
  1474. </if>
  1475. <if test="recentlyStartTime != null and recentlyStartTime != ''">
  1476. AND ccr.addTime <![CDATA[ >= ]]> #{recentlyStartTime}
  1477. </if>
  1478. <if test="recentlyEndTime != null and recentlyEndTime != ''">
  1479. AND ccr.addTime <![CDATA[ <= ]]> #{recentlyEndTime}
  1480. </if>
  1481. <if test="orderStartTime != null and orderStartTime != ''">
  1482. AND cso.orderTime <![CDATA[ >= ]]> #{orderStartTime}
  1483. </if>
  1484. <if test="orderEndTime != null and orderEndTime != ''">
  1485. AND cso.orderTime <![CDATA[ <= ]]> #{orderEndTime}
  1486. </if>
  1487. </where>
  1488. <if test="orderByType == null or orderByType == 1">
  1489. ORDER BY cb.accessTime DESC
  1490. </if>
  1491. <if test="orderByType == 2">
  1492. ORDER BY cb.accessTime asc
  1493. </if>
  1494. </select>
  1495. <select id="getTouristClubInfo" resultType="com.caimei.modules.user.entity.ActiveClub">
  1496. SELECT
  1497. cvr.id,
  1498. cvr.serviceProviderId as spId,
  1499. s.linkMan as spLinkMan,
  1500. cvr.questionMan,
  1501. cvr.addTime as visAddTime
  1502. FROM cm_visitor_remarks cvr
  1503. LEFT JOIN serviceprovider s ON s.serviceProviderID = cvr.serviceProviderId
  1504. <where>
  1505. cvr.clubId IS NULL OR cvr.clubId = '' and cvr.addTime <![CDATA[ >= ]]> #{visAddTime}
  1506. <if test="recentlyStartTime != null and recentlyStartTime != ''">
  1507. AND cvr.addTime <![CDATA[ >= ]]> #{recentlyStartTime}
  1508. </if>
  1509. <if test="recentlyEndTime != null and recentlyEndTime != ''">
  1510. AND cvr.addTime <![CDATA[ <= ]]> #{recentlyEndTime}
  1511. </if>
  1512. </where>
  1513. <if test="orderByType == null or orderByType == 1">
  1514. ORDER BY cvr.addTime DESC
  1515. </if>
  1516. <if test="orderByType == 2">
  1517. ORDER BY cvr.addTime asc
  1518. </if>
  1519. </select>
  1520. <select id="getBehaviorInfo" resultType="com.caimei.modules.user.entity.CmBehaviorInfo">
  1521. SELECT
  1522. cbi.id,
  1523. cbi.operateObject,
  1524. cbi.clubId,
  1525. cbi.spId,
  1526. cbi.type,
  1527. cbi.pageType,
  1528. cbi.label,
  1529. cbi.pagePath,
  1530. cbi.productId,
  1531. cbi.shopOrderId,
  1532. cbi.allocation,
  1533. cbi.addTime,
  1534. cbi.delFlag,
  1535. (CASE WHEN c.name IS NOT NULL THEN c.name
  1536. WHEN c.name IS NULL OR c.name = '' THEN c.linkMan END) AS clubName,
  1537. s.linkMan AS spName,
  1538. (SELECT COUNT(recordId) FROM cm_behavior_record WHERE userId = c.userId AND accessDate = cbi.dateTime) AS number,
  1539. p.name AS productName
  1540. FROM cm_behavior_info cbi
  1541. LEFT JOIN club c ON c.clubId = cbi.clubId
  1542. LEFT JOIN serviceprovider s ON s.serviceProviderID = cbi.spId
  1543. LEFT JOIN product p ON p.productId = cbi.productId
  1544. <where>
  1545. cbi.delFlag = 0
  1546. <if test="operateObject != null">
  1547. and cbi.operateObject = #{operateObject}
  1548. </if>
  1549. <if test="clubId != null">
  1550. and c.clubId = #{clubId}
  1551. </if>
  1552. <if test="spId != null">
  1553. and s.serviceProviderID = #{spId}
  1554. </if>
  1555. <if test="spName != null and spName != ''">
  1556. and s.name like concat('%', #{spName}, '%')
  1557. </if>
  1558. <if test="type != null">
  1559. and cbi.type = #{type}
  1560. </if>
  1561. <if test="behaviorStartTime != null and behaviorStartTime != ''">
  1562. AND cbi.addTime <![CDATA[ >= ]]> #{behaviorStartTime}
  1563. </if>
  1564. <if test="behaviorEndTime != null and behaviorEndTime != ''">
  1565. AND cbi.addTime <![CDATA[ <= ]]> #{behaviorEndTime}
  1566. </if>
  1567. </where>
  1568. </select>
  1569. </mapper>