CmSpMapper.xml 6.3 KB

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