CmClubMapper.xml 6.1 KB

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