NewCmClubMapper.xml 12 KB

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