NewCmClubMapper.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  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. </sql>
  46. <sql id="otherColumns">
  47. ,case sp.status when 91 then '采美默认协销经理(官方账号)' else sp.linkMan end AS "spName",
  48. d.name AS "province",
  49. c.name AS "city",
  50. b.name AS "town",
  51. u.account AS "account",
  52. u.registerTime AS "registerTime",
  53. u.registerIP AS "registerIP",
  54. u.userName AS "userName",
  55. u.bindMobile AS "bindMobile",
  56. u.email AS "email",
  57. u.userOrganizeID AS "userOrganizeID",
  58. u.userIdentity AS "userIdentity",
  59. if(csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime,1,0) as svipUserFlag
  60. </sql>
  61. <sql id="newCmClubJoins">
  62. LEFT JOIN user u ON u.userID = a.userID
  63. LEFT JOIN cm_svip_user csu ON csu.userId = u.userID
  64. LEFT JOIN serviceprovider sp ON sp.serviceProviderID = a.spID
  65. LEFT JOIN town b ON b.townID=a.townID
  66. LEFT JOIN city c ON c.cityID=b.cityID
  67. LEFT JOIN province d ON d.provinceID=c.provinceID
  68. </sql>
  69. <select id="get" resultType="NewCmClub">
  70. SELECT
  71. <include refid="newCmClubColumns"/>
  72. <include refid="otherColumns"/>
  73. FROM club a
  74. <include refid="newCmClubJoins"/>
  75. WHERE a.clubID = #{id}
  76. </select>
  77. <select id="getclubByUserId" resultType="NewCmClub">
  78. SELECT
  79. <include refid="newCmClubColumns"/>
  80. FROM club a
  81. <include refid="newCmClubJoins"/>
  82. WHERE a.userID = #{userID}
  83. </select>
  84. <select id="findList" resultType="NewCmClub">
  85. SELECT
  86. <include refid="newCmClubColumns"/>
  87. <include refid="otherColumns"/>,u.userPermission,u.source
  88. FROM club a
  89. <include refid="newCmClubJoins"/>
  90. <where>
  91. <if test="clubID != null and clubID != ''">
  92. AND a.clubID = #{clubID}
  93. </if>
  94. <if test="userID != null and userID != ''">
  95. AND a.userID = #{userID}
  96. </if>
  97. <if test="account != null and account != ''">
  98. AND u.account = #{account}
  99. </if>
  100. <if test="name != null and name != ''">
  101. AND u.name LIKE concat('%',#{name},'%')
  102. </if>
  103. <if test="userName != null and userName != ''">
  104. AND u.userName LIKE concat('%',#{userName},'%')
  105. </if>
  106. <if test="townID != null and townID != ''">
  107. AND d.provinceID = #{provinceID}
  108. </if>
  109. <if test="cityID != null and cityID != ''">
  110. AND c.cityID = #{cityID}
  111. </if>
  112. <if test="townID != null and townID != ''">
  113. AND b.townID = #{townID}
  114. </if>
  115. <if test="status != null and status != ''">
  116. AND a.status = #{status}
  117. </if>
  118. <if test="bindMobile != null and bindMobile != ''">
  119. AND u.bindMobile LIKE concat('%',#{bindMobile},'%')
  120. </if>
  121. <if test="email != null and email != ''">
  122. AND u.email LIKE concat('%',#{email},'%')
  123. </if>
  124. <if test="linkMan != null and linkMan != ''">
  125. AND a.linkMan LIKE concat('%',#{linkMan},'%')
  126. </if>
  127. <if test="startTime != null and startTime != ''">
  128. AND (u.registerTime &gt; #{startTime} OR u.registerTime = #{startTime})
  129. </if>
  130. <if test="endTime != null and endTime != ''">
  131. AND (u.registerTime &lt; #{endTime} OR u.registerTime = #{endTime})
  132. </if>
  133. <if test="userIdentity != null and userIdentity != '' and userIdentity != '8'.toString()">
  134. AND u.userIdentity = #{userIdentity}
  135. </if>
  136. <if test="userIdentity != null and userIdentity != '' and userIdentity == '8'.toString()">
  137. AND csu.delFlag = '0' and now() <![CDATA[ < ]]> csu.endTime
  138. </if>
  139. AND (u.userOrganizeID IN(0,1) or u.clubStatus != 92)
  140. </where>
  141. <choose>
  142. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  143. ORDER BY ${page.orderBy}
  144. </when>
  145. <otherwise>
  146. ORDER BY case when a.status = 91 then 0 else 1 end desc, a.addTime DESC
  147. </otherwise>
  148. </choose>
  149. </select>
  150. <select id="findAllList" resultType="NewCmClub">
  151. SELECT
  152. <include refid="newCmClubColumns"/>
  153. <include refid="otherColumns"/>
  154. FROM club a
  155. <include refid="newCmClubJoins"/>
  156. <where>
  157. </where>
  158. <choose>
  159. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  160. ORDER BY ${page.orderBy}
  161. </when>
  162. <otherwise>
  163. </otherwise>
  164. </choose>
  165. </select>
  166. <insert id="insert" parameterType="NewCmClub" keyProperty="clubID" useGeneratedKeys="true">
  167. INSERT INTO club(
  168. userID,
  169. name,
  170. sname,
  171. logo,
  172. legalPerson,
  173. provinceID,
  174. cityID,
  175. townID,
  176. flag,
  177. inviterBindID,
  178. inviterName,
  179. spID,
  180. mainServiceProviderID,
  181. scanTime,
  182. address,
  183. linkMan,
  184. linkManIdentity,
  185. contractPhone,
  186. contractMobile,
  187. contractEmail,
  188. fax,
  189. info,
  190. addTime,
  191. auditTime,
  192. auditNote,
  193. status,
  194. businessLicenseImage,
  195. defaultServiceProviderID,
  196. defaultServiceProviderUpdTime,
  197. mainpro,
  198. scanFlag,
  199. headpic,
  200. lastModify,
  201. firstClubType,
  202. socialCreditCode,
  203. secondClubType,
  204. department,
  205. medicalPracticeLicenseImg
  206. ) VALUES (
  207. #{userID},
  208. #{name},
  209. #{sname},
  210. #{logo},
  211. #{legalPerson},
  212. #{provinceID},
  213. #{cityID},
  214. #{townID},
  215. #{flag},
  216. #{inviterBindID},
  217. #{inviterName},
  218. #{spID},
  219. #{mainServiceProviderID},
  220. #{scanTime},
  221. #{address},
  222. #{linkMan},
  223. #{linkManIdentity},
  224. #{contractPhone},
  225. #{contractMobile},
  226. #{contractEmail},
  227. #{fax},
  228. #{info},
  229. #{addTime},
  230. #{auditTime},
  231. #{auditNote},
  232. #{status},
  233. #{businessLicenseImage},
  234. #{defaultServiceProviderID},
  235. #{defaultServiceProviderUpdTime},
  236. #{mainpro},
  237. #{scanFlag},
  238. #{headpic},
  239. #{lastModify},
  240. #{firstClubType},
  241. #{socialCreditCode},
  242. #{secondClubType},
  243. #{department},
  244. #{medicalPracticeLicenseImg}
  245. )
  246. </insert>
  247. <update id="update">
  248. UPDATE club SET
  249. <if test="checkMan != null and checkMan != ''">
  250. checkMan = #{checkMan},
  251. </if>
  252. <if test="name != null and name != ''">
  253. name = #{name},
  254. </if>
  255. <if test="sname != null">
  256. sname = #{sname},
  257. </if>
  258. <if test="logo != null and logo != ''">
  259. logo = #{logo},
  260. </if>
  261. <if test="legalPerson != null and legalPerson != ''">
  262. legalPerson = #{legalPerson},
  263. </if>
  264. <if test="provinceID != null and provinceID != ''">
  265. provinceID = #{provinceID},
  266. </if>
  267. <if test="cityID != null and cityID != ''">
  268. cityID = #{cityID},
  269. </if>
  270. <if test="townID != null and townID != ''">
  271. townID = #{townID},
  272. </if>
  273. <if test="flag != null and flag != ''">
  274. flag = #{flag},
  275. </if>
  276. <if test="inviterBindID != null and inviterBindID != ''">
  277. inviterBindID = #{inviterBindID},
  278. </if>
  279. <if test="inviterName != null and inviterName != ''">
  280. inviterName = #{inviterName},
  281. </if>
  282. <if test="spID != null and spID != ''">
  283. spID = #{spID},
  284. </if>
  285. <if test="mainServiceProviderID != null and mainServiceProviderID != ''">
  286. mainServiceProviderID = #{mainServiceProviderID},
  287. </if>
  288. <if test="scanTime != null">
  289. scanTime = #{scanTime},
  290. </if>
  291. <if test="address != null and address != ''">
  292. address = #{address},
  293. </if>
  294. <if test="linkMan != null and linkMan != ''">
  295. linkMan = #{linkMan},
  296. </if>
  297. <if test="linkManIdentity != null and linkManIdentity != ''">
  298. linkManIdentity = #{linkManIdentity},
  299. </if>
  300. <if test="contractPhone != null and contractPhone != ''">
  301. contractPhone = #{contractPhone},
  302. </if>
  303. <if test="contractMobile != null and contractMobile != ''">
  304. contractMobile = #{contractMobile},
  305. </if>
  306. <if test="contractEmail != null and contractEmail != ''">
  307. contractEmail = #{contractEmail},
  308. </if>
  309. <if test="fax != null and fax != ''">
  310. fax = #{fax},
  311. </if>
  312. <if test="info != null and info != ''">
  313. info = #{info},
  314. </if>
  315. <if test="addTime != null">
  316. addTime = #{addTime},
  317. </if>
  318. <if test="auditTime != null">
  319. auditTime = #{auditTime},
  320. </if>
  321. <if test="auditNote != null and auditNote != ''">
  322. auditNote = #{auditNote},
  323. </if>
  324. <if test="status != null and status != ''">
  325. status = #{status},
  326. </if>
  327. <if test="businessLicenseImage != null">
  328. businessLicenseImage = #{businessLicenseImage},
  329. </if>
  330. <if test="socialCreditCode != null and socialCreditCode != ''">
  331. socialCreditCode = #{socialCreditCode},
  332. </if>
  333. <if test="defaultServiceProviderID != null and defaultServiceProviderID != ''">
  334. defaultServiceProviderID = #{defaultServiceProviderID},
  335. </if>
  336. <if test="defaultServiceProviderUpdTime != null and defaultServiceProviderUpdTime != ''">
  337. defaultServiceProviderUpdTime = #{defaultServiceProviderUpdTime},
  338. </if>
  339. <if test="mainpro != null and mainpro != ''">
  340. mainpro = #{mainpro},
  341. </if>
  342. <if test="scanFlag != null and scanFlag != ''">
  343. scanFlag = #{scanFlag},
  344. </if>
  345. <if test="headpic != null">
  346. headpic = #{headpic},
  347. </if>
  348. <if test="lastModify != null and lastModify != ''">
  349. lastModify = DATE_FORMAT(#{lastModify},'%Y-%m-%d %H:%i:%s'),
  350. </if>
  351. <if test="firstClubType != null and firstClubType != ''">
  352. firstClubType=#{firstClubType},
  353. </if>
  354. <if test="secondClubType != null and secondClubType != ''">
  355. secondClubType=#{secondClubType},
  356. </if>
  357. <if test="department != null and department != ''">
  358. department=#{department},
  359. </if>
  360. <if test="medicalPracticeLicenseImg != null and medicalPracticeLicenseImg != ''">
  361. medicalPracticeLicenseImg=#{medicalPracticeLicenseImg},
  362. </if>
  363. userID = #{userID}
  364. WHERE clubID = #{clubID}
  365. </update>
  366. <delete id="delete">
  367. DELETE FROM club
  368. WHERE clubID = #{clubID}
  369. </delete>
  370. <select id="findClubById" resultType="NewCmClub">
  371. SELECT
  372. <include refid="newCmClubColumns"/>
  373. , CONCAT(d.name,c.name ,b.name ,a.`address` ) address
  374. FROM club a
  375. LEFT JOIN user u ON u.userID = a.userID
  376. LEFT JOIN town b ON a.townID =b.townID
  377. LEFT JOIN city c ON b.cityID=c.cityID
  378. JOIN province d ON c.`provinceID` =d.`provinceID`
  379. WHERE a.clubID=#{clubID}
  380. </select>
  381. <select id="findSpId" resultType="java.lang.Integer">
  382. select serviceProviderID from serviceprovider where serviceProviderID = #{spID} and status = 90
  383. </select>
  384. <select id="findRemarksList" resultType="com.caimei.modules.user.entity.CmClubRemarks">
  385. select ccr.id as remarksId, remarks,s.linkMan as spName, ccr.addTime,ccr.questionMan,ccr.consultType as consult,
  386. (SELECT NAME FROM serviceprovider s WHERE s.serviceProviderID = csr.leaderId) AS leaderName
  387. from cm_club_remarks ccr
  388. left join serviceprovider s on ccr.serviceProviderId = s.serviceProviderID
  389. LEFT JOIN cm_serviceteam_group csg ON ccr.serviceProviderId=csg.serviceId
  390. LEFT JOIN cm_serviceteam_role csr ON csr.id = csg.teamId
  391. where clubId = #{clubId}
  392. order by addTime desc
  393. </select>
  394. <select id="getRemarksImageList" resultType="java.lang.String">
  395. select imageUrl
  396. from cm_club_remarks_file
  397. where remarksId = #{remarksId}
  398. and fileType = 1
  399. </select>
  400. <select id="getRemarksFileList" resultType="com.caimei.modules.user.entity.RemarksFileVo">
  401. select fileName, ossName
  402. from cm_club_remarks_file
  403. where remarksId = #{remarksId}
  404. and fileType = 2
  405. </select>
  406. <insert id="insertBeansHistory">
  407. INSERT INTO `user_beans_history` (
  408. `userId`, `type`, `beansType`, `orderId`,
  409. `num`, `pushStatus`, `addTime`, delFlag
  410. )
  411. VALUES
  412. (
  413. #{userId}, #{type}, #{beansType}, #{orderId},
  414. #{num}, #{pushStatus}, #{addTime}, 0
  415. )
  416. </insert>
  417. <update id="updateByStatus">
  418. UPDATE club SET status = #{clubStatus} WHERE userID = #{confirmUserId}
  419. </update>
  420. <select id="findLowOrder" resultType="com.caimei.modules.user.entity.UserBeansHistory">
  421. select userId, type, beansType, orderId, num, addTime
  422. from user_beans_history
  423. where orderId = #{orderId}
  424. and delFlag = 0
  425. and type = 2
  426. and num = 500
  427. </select>
  428. <select id="findRegistList" resultType="com.caimei.modules.user.entity.CmClubRemarks">
  429. SELECT ccr.id AS remarksId, ccr.remarks,s.name AS spName, ccr.addTime,ccr.questionMan,
  430. csr.leaderId AS leaderId,ifnull(ccr.consultType,'') as consult, c.Name as clubName,
  431. (SELECT NAME FROM serviceprovider s WHERE s.serviceProviderID= csr.leaderId) AS leaderName
  432. FROM cm_club_remarks ccr
  433. LEFT JOIN serviceprovider s ON ccr.serviceProviderId = s.serviceProviderID
  434. LEFT JOIN club c ON c.clubId=ccr.clubId
  435. LEFT JOIN cm_serviceTeam_role csr ON csr.leaderId = ccr.serviceProviderId
  436. LEFT JOIN cm_serviceTeam_group csg ON csr.id=csg.teamId
  437. <where>
  438. <if test="remarks != null and remarks !=''">
  439. AND ccr.remarks LIKE concat('%',#{remarks},'%')
  440. </if>
  441. <if test="clubName !=null and clubName !=''">
  442. AND c.Name like concat('%',#{clubName},'%')
  443. </if>
  444. <if test="leaderId != null">
  445. and csr.leaderId = #{leaderId}
  446. </if>
  447. <if test="serviceProviderId != null">
  448. and csg.serviceId = #{serviceProviderId}
  449. </if>
  450. <if test="startAddTime != null">
  451. and ccr.addTime <![CDATA[ > ]]> #{startAddTime}
  452. </if>
  453. <if test="endAddTime != null">
  454. and ccr.addTime <![CDATA[ < ]]> #{endAddTime}
  455. </if>
  456. </where>
  457. ORDER BY ADDTIME DESC
  458. </select>
  459. <select id="findConsults" resultType="com.caimei.modules.consult.entity.type.CmConsulttype">
  460. select id,className,createdTime from cm_consulttype
  461. where delflag = 0
  462. </select>
  463. <select id="findTeams" resultType="com.caimei.modules.user.entity.CmSaleMan">
  464. select csr.leaderId,s.name as leaderName
  465. from cm_serviceteam_role csr
  466. left join serviceprovider s on s.serviceProviderID = csr.leaderId
  467. where csr.delflag = 0
  468. </select>
  469. <select id="findGroup" resultType="com.caimei.modules.project.model.ServiceProviderModel">
  470. SELECT serviceId as serviceProviderID,s.name FROM
  471. cm_serviceteam_group csg
  472. LEFT JOIN cm_serviceTeam_role csr ON csr.id=csg.teamid
  473. LEFT JOIN serviceprovider s ON s.serviceProviderID=csg.serviceId
  474. WHERE csr.leaderId = #{leaderId}
  475. </select>
  476. <select id="findClassName" resultType="java.lang.String">
  477. select className from cm_consulttype where id = #{string}
  478. </select>
  479. </mapper>