CmClubMapper.xml 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  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.bulkpurchase.dao.CmClubDao">
  4. <resultMap id="resultClub" type="CmClub">
  5. <result column="clubID" property="id"/>
  6. <result column="name" property="name"/>
  7. <result column="address" property="address"/>
  8. <result column="contractPhone" property="contractPhone"/>
  9. <result column="contractMobile" property="contractMobile"/>
  10. <result column="linkMan" property="linkMan"/>
  11. </resultMap>
  12. <sql id="cmClubColumns">
  13. a.clubID AS "id",
  14. a.userID AS "userID",
  15. a.name AS "name",
  16. a.logo AS "logo",
  17. a.townID as townID,
  18. a.address as address,
  19. a.legalPerson AS "legalPerson",
  20. a.linkMan AS "linkMan",
  21. a.contractPhone AS "contractPhone",
  22. a.contractMobile AS "contractMobile",
  23. a.fax AS "fax",
  24. a.info AS "info",
  25. a.addTime AS "addTime",
  26. a.auditTime AS "auditTime",
  27. a.auditNote AS "auditNote",
  28. a.status AS "status",
  29. a.businessLicenseImage AS "businessLicenseImage",
  30. a.defaultServiceProviderID AS "defaultServiceProviderID",
  31. a.defaultServiceProviderUpdTime AS "defaultServiceProviderUpdTime",
  32. a.sname AS "sname",
  33. a.flag AS "flag",
  34. a.scanFlag AS "scanFlag",
  35. a.mainServiceProviderID AS "mainServiceProviderID",
  36. a.spID AS "spID",
  37. a.mainpro AS "mainpro",
  38. a.provinceID AS "provinceID",
  39. a.cityID AS "cityID",
  40. a.inviterName AS "inviterName",
  41. a.inviterBindID AS "inviterBindID",
  42. a.scanTime AS "scanTime",
  43. a.headpic AS "headpic"
  44. </sql>
  45. <sql id="cmClubJoins">
  46. </sql>
  47. <select id="get" resultType="CmClub">
  48. SELECT
  49. <include refid="cmClubColumns"/>
  50. FROM club a
  51. <include refid="cmClubJoins"/>
  52. WHERE a.clubid = #{id}
  53. </select>
  54. <select id="findList" resultType="CmClub">
  55. SELECT
  56. <include refid="cmClubColumns"/>
  57. ,d.name province,c.name city,b.name town,f.userMoney userMoney,f.ableUserMoney ableUserMoney,
  58. if(csu.id is not null,1,0) as svipFlag
  59. FROM club a
  60. LEFT JOIN town b ON b.townID=a.townID
  61. LEFT JOIN city c ON c.cityID=b.cityID
  62. LEFT JOIN province d ON d.provinceID=c.provinceID
  63. LEFT JOIN user f on a.userID = f.userID
  64. LEFT JOIN cm_svip_user csu on a.userID = csu.userId and now() <![CDATA[ < ]]> csu.endTime and csu.delFlag = '0'
  65. <where>
  66. <if test="id != null and id != ''">
  67. AND a.clubID = #{id}
  68. </if>
  69. <if test="userID != null and userID != ''">
  70. AND a.userID = #{userID}
  71. </if>
  72. <if test="name != null and name != ''">
  73. AND a.name LIKE concat('%',#{name},'%')
  74. </if>
  75. AND a.status in (90,40,1,92)
  76. </where>
  77. <choose>
  78. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  79. ORDER BY ${page.orderBy}
  80. </when>
  81. <otherwise>
  82. </otherwise>
  83. </choose>
  84. </select>
  85. <select id="findAllList" resultType="CmClub">
  86. SELECT
  87. <include refid="cmClubColumns"/>
  88. FROM club a
  89. <include refid="cmClubJoins"/>
  90. <where>
  91. </where>
  92. <choose>
  93. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  94. ORDER BY ${page.orderBy}
  95. </when>
  96. <otherwise>
  97. </otherwise>
  98. </choose>
  99. </select>
  100. <insert id="insert" parameterType="CmClub" keyProperty="id" useGeneratedKeys="true">
  101. INSERT INTO club(
  102. userID,
  103. name,
  104. logo,
  105. legalPerson,
  106. townID,
  107. address,
  108. linkMan,
  109. contractPhone,
  110. contractMobile,
  111. fax,
  112. info,
  113. addTime,
  114. auditTime,
  115. auditNote,
  116. status,
  117. businessLicenseImage,
  118. defaultServiceProviderID,
  119. defaultServiceProviderUpdTime,
  120. sname,
  121. flag,
  122. scanFlag,
  123. mainServiceProviderID,
  124. spID,
  125. mainpro,
  126. provinceID,
  127. cityID,
  128. inviterName,
  129. inviterBindID,
  130. scanTime,
  131. headpic
  132. ) VALUES (
  133. #{userID},
  134. #{name},
  135. #{logo},
  136. #{legalPerson},
  137. #{townID},
  138. #{address},
  139. #{linkMan},
  140. #{contractPhone},
  141. #{contractMobile},
  142. #{fax},
  143. #{info},
  144. #{addTime},
  145. #{auditTime},
  146. #{auditNote},
  147. #{status},
  148. #{businessLicenseImage},
  149. #{defaultServiceProviderID},
  150. #{defaultServiceProviderUpdTime},
  151. #{sname},
  152. #{flag},
  153. #{scanFlag},
  154. #{mainServiceProviderID},
  155. #{spID},
  156. #{mainpro},
  157. #{provinceID},
  158. #{cityID},
  159. #{inviterName},
  160. #{inviterBindID},
  161. #{scanTime},
  162. #{headpic}
  163. )
  164. </insert>
  165. <update id="update">
  166. UPDATE club SET
  167. userID = #{userID},
  168. name = #{name},
  169. logo = #{logo},
  170. legalPerson = #{legalPerson},
  171. townID = #{townID},
  172. address = #{address},
  173. linkMan = #{linkMan},
  174. contractPhone = #{contractPhone},
  175. contractMobile = #{contractMobile},
  176. fax = #{fax},
  177. info = #{info},
  178. addTime = #{addTime},
  179. auditTime = #{auditTime},
  180. auditNote = #{auditNote},
  181. status = #{status},
  182. <if test="businessLicenseImage != null and businessLicenseImage != 'null' and businessLicenseImage != ''">
  183. businessLicenseImage = #{businessLicenseImage},
  184. </if>
  185. <if test="headpic != null and headpic != 'null' and headpic != ''">
  186. headpic = #{headpic},
  187. </if>
  188. defaultServiceProviderID = #{defaultServiceProviderID},
  189. defaultServiceProviderUpdTime = #{defaultServiceProviderUpdTime},
  190. sname = #{sname},
  191. flag = #{flag},
  192. scanFlag =#{scanFlag},
  193. mainServiceProviderID = #{mainServiceProviderID},
  194. spID = #{spID},
  195. mainpro = #{mainpro},
  196. provinceID = #{provinceID},
  197. cityID = #{cityID},
  198. inviterName = #{inviterName},
  199. inviterBindID = #{inviterBindID},
  200. scanTime = #{scanTime},
  201. newDeal=1
  202. WHERE clubid = #{id}
  203. </update>
  204. <delete id="delete">
  205. DELETE FROM club
  206. WHERE clubid = #{id}
  207. </delete>
  208. <select id="findClubById" resultType="CmClub">
  209. SELECT
  210. <include refid="cmClubColumns"/>
  211. , CONCAT(d.name,c.name ,b.name ,a.`address` ) address FROM town b LEFT JOIN city c
  212. ON b.cityID=c.cityID JOIN province d ON c.`provinceID` =d.`provinceID`
  213. JOIN club a ON a.townID =b.townID WHERE a.clubID=#{clubId}
  214. </select>
  215. <update id="updateServiceProvider">
  216. UPDATE `cm_club_report`
  217. SET serviceProviderId=#{newSpId}
  218. WHERE clubId = #{clubId}
  219. AND serviceProviderId = #{oldSpId}
  220. </update>
  221. </mapper>