CmSpMapper.xml 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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.CmSpDao">
  4. <sql id="newCmSpColumns">
  5. a.serviceProviderID AS "serviceProviderID",
  6. a.userID AS "userID",
  7. a.name AS "name",
  8. a.linkMan AS "linkMan",
  9. a.contractMobile AS "contractMobile",
  10. a.contractPhone AS "contractPhone",
  11. a.contractEmail AS "contractEmail",
  12. a.duty AS "duty",
  13. a.auditStatus AS "auditStatus",
  14. a.auditTime AS "auditTime",
  15. a.auditNote AS "auditNote",
  16. a.validFlag AS "validFlag",
  17. a.status AS "status",
  18. a.addTime AS "addTime",
  19. a.mainServiceProviderID AS "mainServiceProviderID"
  20. </sql>
  21. <select id="get" resultType="NewCmSp">
  22. SELECT
  23. <include refid="newCmSpColumns"/>
  24. FROM serviceprovider a
  25. WHERE a.serviceProviderID = #{id}
  26. </select>
  27. <select id="findList" resultType="NewCmSp">
  28. SELECT
  29. <include refid="newCmSpColumns"/>
  30. , c_userTypeName AS "spIdentity", c_serviceProviderStatusName AS "spStatusName"
  31. FROM serviceprovider a
  32. JOIN USER u ON a.userID = u.userID
  33. LEFT JOIN c_usertype c ON a.userID = u.userID and u.registerUserTypeID = c.c_userTypeID
  34. LEFT JOIN c_serviceproviderstatus cs ON a.`status` = cs.c_serviceProviderStatusID
  35. <where>
  36. organizeID = 0
  37. <if test="serviceProviderID != null and serviceProviderID != ''">
  38. AND a.serviceProviderID = #{serviceProviderID}
  39. </if>
  40. <if test="userID != null and userID != ''">
  41. AND a.userID = #{userID}
  42. </if>
  43. <if test="name != null and name != ''">
  44. AND a.name LIKE
  45. <if test="dbName == 'oracle'">'%'||#{name}||'%'</if>
  46. <if test="dbName == 'mssql'">'%'+#{name}+'%'</if>
  47. <if test="dbName == 'mysql'">concat('%',#{name},'%')</if>
  48. </if>
  49. <if test="contractMobile != null and contractMobile != ''">
  50. AND a.contractMobile = #{contractMobile}
  51. </if>
  52. <if test="linkMan != null and linkMan != ''">
  53. AND a.linkMan LIKE concat('%',#{linkMan},'%')
  54. </if>
  55. <if test="validFlag != null and validFlag != ''">
  56. AND a.validFlag = #{validFlag}
  57. </if>
  58. <if test="status != null and status != ''">
  59. AND a.status = #{status}
  60. </if>
  61. </where>
  62. <choose>
  63. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  64. ORDER BY ${page.orderBy}
  65. </when>
  66. <otherwise>
  67. ORDER BY a.serviceProviderID DESC
  68. </otherwise>
  69. </choose>
  70. </select>
  71. <select id="findAllList" resultType="NewCmSp">
  72. SELECT
  73. <include refid="newCmSpColumns"/>
  74. FROM serviceprovider a
  75. <where>
  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. <insert id="insert" parameterType="NewCmSp" keyProperty="serviceProviderID" useGeneratedKeys="true">
  86. INSERT INTO serviceprovider(
  87. userID,
  88. name,
  89. contractPhone,
  90. contractMobile,
  91. duty,
  92. contractEmail,
  93. linkMan,
  94. auditStatus,
  95. auditTime,
  96. auditNote,
  97. validFlag,
  98. status,
  99. addTime,
  100. mainServiceProviderID
  101. ) VALUES (
  102. #{userID},
  103. #{name},
  104. #{contractPhone},
  105. #{contractMobile},
  106. #{duty},
  107. #{contractEmail},
  108. #{linkMan},
  109. #{auditStatus},
  110. #{auditTime},
  111. #{auditNote},
  112. #{validFlag},
  113. #{status},
  114. #{addTime},
  115. #{mainServiceProviderID}
  116. )
  117. </insert>
  118. <update id="update">
  119. UPDATE serviceprovider SET
  120. userID = #{userID},
  121. organizeID = 0,
  122. name = #{name},
  123. contractPhone = #{contractPhone},
  124. contractMobile = #{contractMobile},
  125. contractEmail = #{contractEmail},
  126. linkMan = #{linkMan},
  127. duty = #{duty},
  128. auditStatus = #{auditStatus},
  129. auditTime = #{auditTime},
  130. auditNote = #{auditNote},
  131. validFlag = #{validFlag},
  132. status = #{status},
  133. addTime = #{addTime},
  134. mainServiceProviderID = #{mainServiceProviderID}
  135. WHERE serviceProviderID = #{serviceProviderID}
  136. </update>
  137. <delete id="delete">
  138. DELETE FROM serviceprovider
  139. WHERE serviceProviderID = #{serviceProviderID}
  140. </delete>
  141. <delete id="deleteManager">
  142. DELETE FROM cm_serviceteam_manager
  143. </delete>
  144. <select id="findSpManager" resultType="com.caimei.modules.user.entity.NewCmSp">
  145. select
  146. <include refid="newCmSpColumns"/>
  147. FROM serviceprovider a
  148. JOIN user u on a.userID = u.userID
  149. where u.registerUserTypeID = 2
  150. </select>
  151. <select id="findSelectList" resultType="com.caimei.modules.user.entity.NewCmSp">
  152. SELECT
  153. <include refid="newCmSpColumns"/>
  154. , c_userTypeName AS "spIdentity", c_serviceProviderStatusName AS "spStatusName"
  155. FROM serviceprovider a
  156. JOIN USER u ON a.userID = u.userID
  157. LEFT JOIN c_usertype c ON a.userID = u.userID and u.registerUserTypeID = c.c_userTypeID
  158. LEFT JOIN c_serviceproviderstatus cs ON a.`status` = cs.c_serviceProviderStatusID
  159. <where>
  160. a.organizeId = 0
  161. <if test="status != null and status != ''">
  162. AND a.status = #{status}
  163. </if>
  164. <if test="contractMobile != null and contractMobile != ''">
  165. AND a.contractMobile = #{contractMobile}
  166. </if>
  167. <if test="linkMan != null and linkMan != ''">
  168. AND a.linkMan LIKE concat('%',#{linkMan},'%')
  169. </if>
  170. </where>
  171. <choose>
  172. <when test="page !=null and page.orderBy != null and page.orderBy != ''">
  173. ORDER BY ${page.orderBy}
  174. </when>
  175. <otherwise>
  176. ORDER BY a.serviceProviderID DESC
  177. </otherwise>
  178. </choose>
  179. </select>
  180. <update id="updateSpManager">
  181. UPDATE serviceprovider SET
  182. mainServiceProviderID = #{spManagerID}
  183. </update>
  184. <insert id="choseManager">
  185. insert into cm_serviceteam_manager (serviceProviderId,delflag)
  186. values (#{serviceProviderID},0)
  187. </insert>
  188. <select id="findByUserId" resultType="com.caimei.modules.user.entity.NewCmSp">
  189. SELECT
  190. <include refid="newCmSpColumns"/>
  191. FROM serviceprovider a
  192. WHERE a.userID = #{userId}
  193. </select>
  194. <select id="findTeam" resultType="com.caimei.modules.user.entity.CmSaleMan">
  195. select leaderId,s.name as leaderName
  196. from cm_serviceteam_role csr
  197. left join serviceprovider s on csr.leaderId = s.serviceProviderID
  198. where csr.delflag = 0
  199. </select>
  200. <select id="findManagerInfo" resultType="com.caimei.modules.user.entity.NewCmSp">
  201. select csm.serviceProviderId as serviceProviderID,s.name
  202. from cm_serviceteam_manager csm
  203. left join serviceprovider s on csm.serviceProviderId=s.serviceProviderID
  204. </select>
  205. </mapper>