NewCmClubMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626
  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. a.clubTypeID AS "clubTypeID",
  8. u.name AS "name",
  9. a.sname AS "sname",
  10. a.nameEn AS "nameEn",
  11. a.site AS "site",
  12. a.logo AS "logo",
  13. a.level AS "level",
  14. a.score AS "score",
  15. a.subClubCount AS "subClubCount",
  16. a.legalPerson AS "legalPerson",
  17. a.provinceID AS "provinceID",
  18. a.cityID AS "cityID",
  19. a.townID AS "townID",
  20. a.agreement AS "agreement",
  21. a.flag AS "flag",
  22. a.inviterBindID AS "inviterBindID",
  23. a.inviterName AS "inviterName",
  24. a.spID AS "spID",
  25. a.mainServiceProviderID AS "mainServiceProviderID",
  26. a.scanTime AS "scanTime",
  27. a.checkTime AS "checkTime",
  28. a.address AS "address",
  29. a.registeredCapital AS "registeredCapital",
  30. a.mainClubID AS "mainClubID",
  31. a.turnover AS "turnover",
  32. a.linkMan AS "linkMan",
  33. a.contractPhone AS "contractPhone",
  34. a.contractMobile AS "contractMobile",
  35. a.fax AS "fax",
  36. a.zipCode AS "zipCode",
  37. a.linkMan1 AS "linkMan1",
  38. a.duty1 AS "duty1",
  39. a.contractPhone1 AS "contractPhone1",
  40. a.contractMobile1 AS "contractMobile1",
  41. a.contractQQ1 AS "contractQQ1",
  42. a.wechat1 AS "wechat1",
  43. a.contractEmail1 AS "contractEmail1",
  44. a.linkMan2 AS "linkMan2",
  45. a.duty2 AS "duty2",
  46. a.contractPhone2 AS "contractPhone2",
  47. a.contractMobile2 AS "contractMobile2",
  48. a.contractQQ2 AS "contractQQ2",
  49. a.wechat2 AS "wechat2",
  50. a.contractEmail2 AS "contractEmail2",
  51. a.scope AS "scope",
  52. a.info AS "info",
  53. a.lng AS "lng",
  54. a.lat AS "lat",
  55. a.addTime AS "addTime",
  56. a.favoriteTimes AS "favoriteTimes",
  57. a.payFlag1 AS "payFlag1",
  58. a.auditTime AS "auditTime",
  59. a.auditNote AS "auditNote",
  60. a.status AS "status",
  61. a.clubInvitationStatus AS "clubInvitationStatus",
  62. a.recAddress AS "recAddress",
  63. a.businessLicenseImage AS "businessLicenseImage",
  64. a.sortIndex AS "sortIndex",
  65. a.recTownID AS "recTownID",
  66. a.defaultServiceProviderID AS "defaultServiceProviderID",
  67. a.defaultServiceProviderUpdTime AS "defaultServiceProviderUpdTime",
  68. a.firstServiceProviderFlag AS "firstServiceProviderFlag",
  69. a.scale AS "scale",
  70. a.empnum AS "empnum",
  71. a.mainpro AS "mainpro",
  72. a.remark AS "remark",
  73. a.scanFlag AS "scanFlag",
  74. a.headpic AS "headpic",
  75. a.socialCreditCode AS "socialCreditCode",
  76. a.lastModify AS "lastModify",
  77. a.firstClubType AS "firstClubType",
  78. a.secondClubType AS "secondClubType",
  79. a.department AS "department",
  80. a.medicalPracticeLicenseImg AS "medicalPracticeLicenseImg"
  81. </sql>
  82. <sql id="otherColumns">
  83. ,case sp.status when 91 then '采美默认协销经理(官方账号)' else sp.linkMan1 end AS "spName",
  84. d.name AS "province",
  85. c.name AS "city",
  86. b.name AS "town",
  87. u.account AS "account",
  88. u.registerTime AS "registerTime",
  89. u.registerIP AS "registerIP",
  90. u.userName AS "userName",
  91. u.userLevelID AS "userLevelID",
  92. u.smsFlag AS "smsFlag",
  93. u.bindMobile AS "bindMobile",
  94. u.email AS "email",
  95. u.userOrganizeID AS "userOrganizeID",
  96. u.userIdentity AS "userIdentity"
  97. </sql>
  98. <sql id="newCmClubJoins">
  99. LEFT JOIN user u ON u.userID = a.userID
  100. LEFT JOIN serviceprovider sp ON sp.serviceProviderID = a.spID
  101. LEFT JOIN town b ON b.townID=a.townID
  102. LEFT JOIN city c ON c.cityID=b.cityID
  103. LEFT JOIN province d ON d.provinceID=c.provinceID
  104. </sql>
  105. <select id="get" resultType="NewCmClub">
  106. SELECT
  107. <include refid="newCmClubColumns"/>
  108. <include refid="otherColumns"/>
  109. FROM club a
  110. <include refid="newCmClubJoins"/>
  111. WHERE a.clubID = #{id}
  112. </select>
  113. <select id="getclubByUserId" resultType="NewCmClub">
  114. SELECT
  115. <include refid="newCmClubColumns"/>
  116. FROM club a
  117. <include refid="newCmClubJoins"/>
  118. WHERE a.userID = #{userID}
  119. </select>
  120. <select id="findList" resultType="NewCmClub">
  121. SELECT
  122. <include refid="newCmClubColumns"/>
  123. <include refid="otherColumns"/>,u.userPermission,u.source
  124. FROM club a
  125. <include refid="newCmClubJoins"/>
  126. <where>
  127. <if test="clubID != null and clubID != ''">
  128. AND a.clubID = #{clubID}
  129. </if>
  130. <if test="userID != null and userID != ''">
  131. AND a.userID = #{userID}
  132. </if>
  133. <if test="account != null and account != ''">
  134. AND u.account = #{account}
  135. </if>
  136. <if test="name != null and name != ''">
  137. AND u.name LIKE concat('%',#{name},'%')
  138. </if>
  139. <if test="userName != null and userName != ''">
  140. AND u.userName LIKE concat('%',#{userName},'%')
  141. </if>
  142. <if test="userLevelID != null and userLevelID != ''">
  143. AND u.userLevelID = #{userLevelID}
  144. </if>
  145. <if test="townID != null and townID != ''">
  146. AND d.provinceID = #{provinceID}
  147. </if>
  148. <if test="cityID != null and cityID != ''">
  149. AND c.cityID = #{cityID}
  150. </if>
  151. <if test="townID != null and townID != ''">
  152. AND b.townID = #{townID}
  153. </if>
  154. <if test="status != null and status != ''">
  155. AND a.status = #{status}
  156. </if>
  157. <if test="bindMobile != null and bindMobile != ''">
  158. AND u.bindMobile LIKE concat('%',#{bindMobile},'%')
  159. </if>
  160. <if test="email != null and email != ''">
  161. AND u.email LIKE concat('%',#{email},'%')
  162. </if>
  163. <if test="linkMan != null and linkMan != ''">
  164. AND a.linkMan LIKE concat('%',#{linkMan},'%')
  165. </if>
  166. <if test="startTime != null and startTime != ''">
  167. AND (u.registerTime &gt; #{startTime} OR u.registerTime = #{startTime})
  168. </if>
  169. <if test="endTime != null and endTime != ''">
  170. AND (u.registerTime &lt; #{endTime} OR u.registerTime = #{endTime})
  171. </if>
  172. <if test="userIdentity != null and userIdentity != ''">
  173. AND u.userIdentity = #{userIdentity}
  174. </if>
  175. AND (u.userOrganizeID IN(0,1) or u.clubStatus != 92)
  176. </where>
  177. <choose>
  178. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  179. ORDER BY ${page.orderBy}
  180. </when>
  181. <otherwise>
  182. ORDER BY case when a.status = 91 then 0 else 1 end desc, a.addTime DESC
  183. </otherwise>
  184. </choose>
  185. </select>
  186. <select id="findAllList" resultType="NewCmClub">
  187. SELECT
  188. <include refid="newCmClubColumns"/>
  189. <include refid="otherColumns"/>
  190. FROM club a
  191. <include refid="newCmClubJoins"/>
  192. <where>
  193. </where>
  194. <choose>
  195. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  196. ORDER BY ${page.orderBy}
  197. </when>
  198. <otherwise>
  199. </otherwise>
  200. </choose>
  201. </select>
  202. <insert id="insert" parameterType="NewCmClub" keyProperty="clubID" useGeneratedKeys="true">
  203. INSERT INTO club(
  204. userID,
  205. name,
  206. sname,
  207. nameEn,
  208. site,
  209. logo,
  210. level,
  211. score,
  212. subClubCount,
  213. legalPerson,
  214. provinceID,
  215. cityID,
  216. townID,
  217. agreement,
  218. flag,
  219. inviterBindID,
  220. inviterName,
  221. spID,
  222. mainServiceProviderID,
  223. scanTime,
  224. checkTime,
  225. address,
  226. registeredCapital,
  227. mainClubID,
  228. turnover,
  229. linkMan,
  230. contractPhone,
  231. contractMobile,
  232. fax,
  233. zipCode,
  234. linkMan1,
  235. duty1,
  236. contractPhone1,
  237. contractMobile1,
  238. contractQQ1,
  239. wechat1,
  240. contractEmail1,
  241. linkMan2,
  242. duty2,
  243. contractPhone2,
  244. contractMobile2,
  245. contractQQ2,
  246. wechat2,
  247. contractEmail2,
  248. scope,
  249. info,
  250. lng,
  251. lat,
  252. addTime,
  253. favoriteTimes,
  254. payFlag1,
  255. auditTime,
  256. auditNote,
  257. status,
  258. clubInvitationStatus,
  259. recAddress,
  260. businessLicenseImage,
  261. sortIndex,
  262. recTownID,
  263. defaultServiceProviderID,
  264. defaultServiceProviderUpdTime,
  265. firstServiceProviderFlag,
  266. scale,
  267. empnum,
  268. mainpro,
  269. remark,
  270. scanFlag,
  271. headpic,
  272. lastModify,
  273. firstClubType,
  274. socialCreditCode,
  275. secondClubType,
  276. department,
  277. medicalPracticeLicenseImg
  278. ) VALUES (
  279. #{userID},
  280. #{name},
  281. #{sname},
  282. #{nameEn},
  283. #{site},
  284. #{logo},
  285. #{level},
  286. #{score},
  287. #{subClubCount},
  288. #{legalPerson},
  289. #{provinceID},
  290. #{cityID},
  291. #{townID},
  292. #{agreement},
  293. #{flag},
  294. #{inviterBindID},
  295. #{inviterName},
  296. #{spID},
  297. #{mainServiceProviderID},
  298. #{scanTime},
  299. #{checkTime},
  300. #{address},
  301. #{registeredCapital},
  302. #{mainClubID},
  303. #{turnover},
  304. #{linkMan},
  305. #{contractPhone},
  306. #{contractMobile},
  307. #{fax},
  308. #{zipCode},
  309. #{linkMan1},
  310. #{duty1},
  311. #{contractPhone1},
  312. #{contractMobile1},
  313. #{contractQQ1},
  314. #{wechat1},
  315. #{contractEmail1},
  316. #{linkMan2},
  317. #{duty2},
  318. #{contractPhone2},
  319. #{contractMobile2},
  320. #{contractQQ2},
  321. #{wechat2},
  322. #{contractEmail2},
  323. #{scope},
  324. #{info},
  325. #{lng},
  326. #{lat},
  327. #{addTime},
  328. #{favoriteTimes},
  329. #{payFlag1},
  330. #{auditTime},
  331. #{auditNote},
  332. #{status},
  333. #{clubInvitationStatus},
  334. #{recAddress},
  335. #{businessLicenseImage},
  336. #{sortIndex},
  337. #{recTownID},
  338. #{defaultServiceProviderID},
  339. #{defaultServiceProviderUpdTime},
  340. #{firstServiceProviderFlag},
  341. #{scale},
  342. #{empnum},
  343. #{mainpro},
  344. #{remark},
  345. #{scanFlag},
  346. #{headpic},
  347. #{lastModify},
  348. #{firstClubType},
  349. #{socialCreditCode},
  350. #{secondClubType},
  351. #{department},
  352. #{medicalPracticeLicenseImg}
  353. )
  354. </insert>
  355. <update id="update">
  356. UPDATE club SET
  357. <if test="name != null and name != ''">
  358. name = #{name},
  359. </if>
  360. <if test="sname != null">
  361. sname = #{sname},
  362. </if>
  363. <if test="nameEn != null and nameEn != ''">
  364. nameEn = #{nameEn},
  365. </if>
  366. <if test="site != null and site != ''">
  367. site = #{site},
  368. </if>
  369. <if test="logo != null and logo != ''">
  370. logo = #{logo},
  371. </if>
  372. <if test="level != null and level != ''">
  373. level = #{level},
  374. </if>
  375. <if test="score != null and score != ''">
  376. score = #{score},
  377. </if>
  378. <if test="subClubCount != null and subClubCount != ''">
  379. subClubCount = #{subClubCount},
  380. </if>
  381. <if test="legalPerson != null and legalPerson != ''">
  382. legalPerson = #{legalPerson},
  383. </if>
  384. <if test="provinceID != null and provinceID != ''">
  385. provinceID = #{provinceID},
  386. </if>
  387. <if test="cityID != null and cityID != ''">
  388. cityID = #{cityID},
  389. </if>
  390. <if test="townID != null and townID != ''">
  391. townID = #{townID},
  392. </if>
  393. <if test="agreement != null and agreement != ''">
  394. agreement = #{agreement},
  395. </if>
  396. <if test="flag != null and flag != ''">
  397. flag = #{flag},
  398. </if>
  399. <if test="inviterBindID != null and inviterBindID != ''">
  400. inviterBindID = #{inviterBindID},
  401. </if>
  402. <if test="inviterName != null and inviterName != ''">
  403. inviterName = #{inviterName},
  404. </if>
  405. <if test="spID != null and spID != ''">
  406. spID = #{spID},
  407. </if>
  408. <if test="mainServiceProviderID != null and mainServiceProviderID != ''">
  409. mainServiceProviderID = #{mainServiceProviderID},
  410. </if>
  411. <if test="scanTime != null">
  412. scanTime = #{scanTime},
  413. </if>
  414. <if test="checkTime != null and checkTime != ''">
  415. checkTime = #{checkTime},
  416. </if>
  417. <if test="address != null and address != ''">
  418. address = #{address},
  419. </if>
  420. <if test="registeredCapital != null and registeredCapital != ''">
  421. registeredCapital = #{registeredCapital},
  422. </if>
  423. <if test="mainClubID != null and mainClubID != ''">
  424. mainClubID = #{mainClubID},
  425. </if>
  426. <if test="turnover != null and turnover != ''">
  427. turnover = #{turnover},
  428. </if>
  429. <if test="linkMan != null and linkMan != ''">
  430. linkMan = #{linkMan},
  431. </if>
  432. <if test="contractPhone != null and contractPhone != ''">
  433. contractPhone = #{contractPhone},
  434. </if>
  435. <if test="contractMobile != null and contractMobile != ''">
  436. contractMobile = #{contractMobile},
  437. </if>
  438. <if test="fax != null and fax != ''">
  439. fax = #{fax},
  440. </if>
  441. <if test="zipCode != null and zipCode != ''">
  442. zipCode = #{zipCode},
  443. </if>
  444. <if test="linkMan1 != null and linkMan1 != ''">
  445. linkMan1 = #{linkMan1},
  446. </if>
  447. <if test="duty1 != null and duty1 != ''">
  448. duty1 = #{duty1},
  449. </if>
  450. <if test="contractPhone1 != null and contractPhone1 != ''">
  451. contractPhone1 = #{contractPhone1},
  452. </if>
  453. <if test="contractMobile1 != null and contractMobile1 != ''">
  454. contractMobile1 = #{contractMobile1},
  455. </if>
  456. <if test="contractQQ1 != null and contractQQ1 != ''">
  457. contractQQ1 = #{contractQQ1},
  458. </if>
  459. <if test="wechat1 != null and wechat1 != ''">
  460. wechat1 = #{wechat1},
  461. </if>
  462. <if test="contractEmail1 != null and contractEmail1 != ''">
  463. contractEmail1 = #{contractEmail1},
  464. </if>
  465. <if test="linkMan2 != null and linkMan2 != ''">
  466. linkMan2 = #{linkMan2},
  467. </if>
  468. <if test="duty2 != null and duty2 != ''">
  469. duty2 = #{duty2},
  470. </if>
  471. <if test="contractPhone2 != null and contractPhone2 != ''">
  472. contractPhone2 = #{contractPhone2},
  473. </if>
  474. <if test="contractMobile2 != null and contractMobile2 != ''">
  475. contractMobile2 = #{contractMobile2},
  476. </if>
  477. <if test="contractQQ2 != null and contractQQ2 != ''">
  478. contractQQ2 = #{contractQQ2},
  479. </if>
  480. <if test="wechat2 != null and wechat2 != ''">
  481. wechat2 = #{wechat2},
  482. </if>
  483. <if test="contractEmail2 != null and contractEmail2 != ''">
  484. contractEmail2 = #{contractEmail2},
  485. </if>
  486. <if test="scope != null and scope != ''">
  487. scope = #{scope},
  488. </if>
  489. <if test="info != null and info != ''">
  490. info = #{info},
  491. </if>
  492. <if test="lng != null and lng != ''">
  493. lng = #{lng},
  494. </if>
  495. <if test="lat != null and lat != ''">
  496. lat = #{lat},
  497. </if>
  498. <if test="addTime != null">
  499. addTime = #{addTime},
  500. </if>
  501. <if test="favoriteTimes != null">
  502. favoriteTimes = #{favoriteTimes},
  503. </if>
  504. <if test="payFlag1 != null and payFlag1 != ''">
  505. payFlag1 = #{payFlag1},
  506. </if>
  507. <if test="auditTime != null">
  508. auditTime = #{auditTime},
  509. </if>
  510. <if test="auditNote != null and auditNote != ''">
  511. auditNote = #{auditNote},
  512. </if>
  513. <if test="status != null and status != ''">
  514. status = #{status},
  515. </if>
  516. <if test="clubInvitationStatus != null and clubInvitationStatus != ''">
  517. clubInvitationStatus = #{clubInvitationStatus},
  518. </if>
  519. <if test="recAddress != null and recAddress != ''">
  520. recAddress = #{recAddress},
  521. </if>
  522. <if test="businessLicenseImage != null">
  523. businessLicenseImage = #{businessLicenseImage},
  524. </if>
  525. <if test="socialCreditCode != null and socialCreditCode != ''">
  526. socialCreditCode = #{socialCreditCode},
  527. </if>
  528. <if test="sortIndex != null and sortIndex != ''">
  529. sortIndex = #{sortIndex},
  530. </if>
  531. <if test="recTownID != null and recTownID != ''">
  532. recTownID = #{recTownID},
  533. </if>
  534. <if test="defaultServiceProviderID != null and defaultServiceProviderID != ''">
  535. defaultServiceProviderID = #{defaultServiceProviderID},
  536. </if>
  537. <if test="defaultServiceProviderUpdTime != null and defaultServiceProviderUpdTime != ''">
  538. defaultServiceProviderUpdTime = #{defaultServiceProviderUpdTime},
  539. </if>
  540. <if test="firstServiceProviderFlag != null and firstServiceProviderFlag != ''">
  541. firstServiceProviderFlag = #{firstServiceProviderFlag},
  542. </if>
  543. <if test="scale != null and scale != ''">
  544. scale = #{scale},
  545. </if>
  546. <if test="empnum != null and empnum != ''">
  547. empnum = #{empnum},
  548. </if>
  549. <if test="mainpro != null and mainpro != ''">
  550. mainpro = #{mainpro},
  551. </if>
  552. <if test="remark != null and remark != ''">
  553. remark = #{remark},
  554. </if>
  555. <if test="scanFlag != null and scanFlag != ''">
  556. scanFlag = #{scanFlag},
  557. </if>
  558. <if test="headpic != null">
  559. headpic = #{headpic},
  560. </if>
  561. <if test="lastModify != null and lastModify != ''">
  562. lastModify = DATE_FORMAT(#{lastModify},'%Y-%m-%d %H:%i:%s'),
  563. </if>
  564. <if test="firstClubType != null and firstClubType != ''">
  565. firstClubType=#{firstClubType},
  566. </if>
  567. <if test="secondClubType != null and secondClubType != ''">
  568. secondClubType=#{secondClubType},
  569. </if>
  570. <if test="department != null and department != ''">
  571. department=#{department},
  572. </if>
  573. <if test="medicalPracticeLicenseImg != null and medicalPracticeLicenseImg != ''">
  574. medicalPracticeLicenseImg=#{medicalPracticeLicenseImg},
  575. </if>
  576. userID = #{userID}
  577. WHERE clubID = #{clubID}
  578. </update>
  579. <delete id="delete">
  580. DELETE FROM club
  581. WHERE clubID = #{clubID}
  582. </delete>
  583. <select id="findClubById" resultType="NewCmClub">
  584. SELECT
  585. <include refid="newCmClubColumns"/>
  586. , CONCAT(d.name,c.name ,b.name ,a.`address` ) address
  587. FROM club a
  588. LEFT JOIN user u ON u.userID = a.userID
  589. LEFT JOIN town b ON a.townID =b.townID
  590. LEFT JOIN city c ON b.cityID=c.cityID
  591. JOIN province d ON c.`provinceID` =d.`provinceID`
  592. WHERE a.clubID=#{clubID}
  593. </select>
  594. <select id="findSpId" resultType="java.lang.Integer">
  595. select serviceProviderID from serviceprovider where serviceProviderID = #{spID} and status = 90
  596. </select>
  597. <insert id="insertBeansHistory">
  598. INSERT INTO `user_beans_history` (
  599. `userId`, `type`, `beansType`, `orderId`,
  600. `num`, `pushStatus`, `addTime`, delFlag
  601. )
  602. VALUES
  603. (
  604. #{userId}, #{type}, #{beansType}, #{orderId},
  605. #{num}, #{pushStatus}, #{addTime}, 0
  606. )
  607. </insert>
  608. </mapper>