SellerMapper.xml 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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.caimei365.user.mapper.SellerMapper">
  4. <select id="getLoginSellerByMobile" resultType="com.caimei365.user.model.vo.UserLoginVo">
  5. select u.userID as userId,
  6. u.clubID as clubId,
  7. u.shopID as shopId,
  8. u.userName as userName,
  9. u.name as name,
  10. u.mobile as mobile,
  11. u.bindMobile as bindMobile,
  12. u.email as email,
  13. u.guideFlag as guideFlag,
  14. u.userIdentity as userIdentity,
  15. u.serviceProviderID as serviceProviderId,
  16. u.serviceProviderStatus as serviceStatus,
  17. u.password as password
  18. from user u
  19. where u.mobile = #{mobile}
  20. and u.userIdentity = 1
  21. and u.validFlag = 1
  22. </select>
  23. <update id="updateServiceProviderByUserId">
  24. update serviceprovider
  25. set openid = #{openId},
  26. unionId = #{unionId}
  27. where userID = #{userId}
  28. </update>
  29. <select id="findClubTemporary" resultType="com.caimei365.user.model.vo.ClubTemporaryVo">
  30. SELECT
  31. `id`,
  32. `userId`,
  33. `name`,
  34. `shortName`,
  35. `bindMobile`,
  36. `contractEmail`,
  37. `linkMan`,
  38. `provinceId`,
  39. `cityId`,
  40. `townId`,
  41. `address`,
  42. `shopPhoto`,
  43. `businessLicense`,
  44. `socialCreditCode`,
  45. `firstClubType`,
  46. `secondClubType`,
  47. `department`,
  48. `medicalPracticeLicense`,
  49. `mainProduct`,
  50. `isAgreed`
  51. FROM
  52. club_temporary
  53. WHERE
  54. userId = #{userId}
  55. <if test="searchName != null and searchName != ''">
  56. AND (name LIKE CONCAT('%',#{searchName},'%') OR linkMan LIKE CONCAT('%',#{searchName},'%'))
  57. </if>
  58. ORDER BY
  59. id DESC
  60. </select>
  61. <update id="updateClubTemporary">
  62. UPDATE
  63. `club_temporary`
  64. SET `name` = #{name},
  65. `shortName` = #{shortName},
  66. `bindMobile` = #{bindMobile},
  67. `contractEmail` = #{contractEmail},
  68. `linkMan` = #{linkMan},
  69. `provinceId` = #{provinceId},
  70. `cityId` = #{cityId},
  71. `townId` = #{townId},
  72. `address` = #{address},
  73. `shopPhoto` = #{shopPhoto},
  74. `businessLicense` = #{businessLicense},
  75. `socialCreditCode` = #{socialCreditCode},
  76. `firstClubType` = #{firstClubType},
  77. `secondClubType` = #{secondClubType},
  78. `department` = #{department},
  79. `medicalPracticeLicense` = #{medicalPracticeLicense},
  80. `mainProduct` = #{mainProduct},
  81. `isAgreed` = #{isAgreed}
  82. WHERE `id` = #{id}
  83. </update>
  84. <delete id="deleteTemporaryClub">
  85. DELETE
  86. FROM `club_temporary`
  87. WHERE `id` = #{id}
  88. </delete>
  89. <select id="findOrderNum" resultType="integer">
  90. SELECT
  91. COUNT(*)
  92. FROM
  93. cm_order
  94. WHERE
  95. userID = #{userId}
  96. AND orderSubmitType IN (0, 1, 2)
  97. <if test="lastCheckOrderDate != null">
  98. AND orderTime > #{lastCheckOrderDate}
  99. </if>
  100. </select>
  101. <select id="findClubs" resultType="com.caimei365.user.model.vo.ClubVo">
  102. select DISTINCT c.clubID as clubId, c.userID as userId, c.name, c.sname as shortName, c.contractMobile,
  103. c.contractEmail as contractEmail,
  104. c.contractPhone, c.linkMan, c.provinceID as proviceId, c.cityID as cityId, c.townID as townId,
  105. c.address, c.headpic as shopPhoto, c.businessLicenseImage as businessLicense, c.socialCreditCode,
  106. c.firstClubType, c.secondClubType, c.department, c.medicalPracticeLicenseImg as medicalPracticeLicense,
  107. c.mainpro as mainProduct, c.fax, c.info as profile, c.spID as serviceProviderId, c.addTime, c.status,
  108. c.lastCheckOrderDate,
  109. u.userIdentity,c.newDeal as newDeal,IF(r.id IS NOT NULL,1,0) AS recordCount,
  110. sp.name AS serviceName,
  111. covs.activeState AS activeState,
  112. covs.customerValue AS customerValue
  113. from club c
  114. left join user u on c.userID = u.userID
  115. LEFT JOIN record_link r ON r.`clubId`=c.`clubID`
  116. LEFT JOIN cm_organ_value_system covs ON covs.userID = u.userID
  117. LEFT JOIN serviceprovider sp ON c.spID = sp.serviceProviderID
  118. where
  119. <if test="1 == type">
  120. c.spID = #{serviceProviderId}
  121. </if>
  122. <if test="2 == type">
  123. c.spID in
  124. <foreach collection="serviceIds" item="id" index="index" open="(" separator="," close=")">
  125. #{id}
  126. </foreach>
  127. </if>
  128. <if test="3 == type">
  129. r.clubId IS NOT NULL
  130. AND c.spId=1342
  131. </if>
  132. <if test="status != null and status != 66">
  133. AND c.status = #{status}
  134. </if>
  135. <if test="status == 66">
  136. AND c.status IN (1,90,92,93)
  137. </if>
  138. <if test="name != null and name != ''">
  139. AND (c.name LIKE CONCAT('%',#{name},'%') OR c.linkMan LIKE CONCAT('%',#{name},'%') OR c.contractMobile LIKE CONCAT('%',#{name},'%'))
  140. </if>
  141. <if test="userIdentity != null">
  142. AND u.userIdentity = #{userIdentity}
  143. </if>
  144. AND covs.stage = 0 AND covs.delType = 1
  145. order by c.clubID desc
  146. </select>
  147. <select id="getAllClubList" resultType="com.caimei365.user.model.vo.ClubVo">
  148. SELECT DISTINCT c.clubID as clubId, c.userID as userId, c.name, c.sname as shortName, c.contractMobile,
  149. c.contractEmail as contractEmail,
  150. c.contractPhone, c.linkMan, c.provinceID as proviceId, c.cityID as cityId, c.townID as townId,
  151. c.address, c.headpic as shopPhoto, c.businessLicenseImage as businessLicense, c.socialCreditCode,
  152. c.firstClubType, c.secondClubType, c.department, c.medicalPracticeLicenseImg as medicalPracticeLicense,
  153. c.mainpro as mainProduct, c.fax, c.info as profile, c.spID as serviceProviderId, c.addTime, c.status,
  154. c.lastCheckOrderDate,
  155. u.userIdentity
  156. FROM club c
  157. LEFT JOIN user u ON c.userID=u.userID
  158. WHERE u.userOrganizeID = 0 AND c.status = '90'
  159. <if test="searchWord != null and searchWord != ''">
  160. and (
  161. c.name LIKE CONCAT('%',#{searchWord},'%') or
  162. c.linkMan LIKE CONCAT('%',#{searchWord},'%') or
  163. c.contractMobile LIKE CONCAT('%',#{searchWord},'%')
  164. )
  165. </if>
  166. </select>
  167. <select id="getSellerByUserId" resultType="com.caimei365.user.model.po.ServiceProviderPo">
  168. select serviceProviderID AS serviceProviderId,
  169. status,
  170. userID AS userId,
  171. openid,
  172. unionId,
  173. name,
  174. contractMobile,
  175. linkMan,
  176. duty,
  177. contractEmail,
  178. auditStatus,
  179. auditTime,
  180. auditNote,
  181. validFlag,
  182. addTime,
  183. mainServiceProviderID AS mainServiceProviderId
  184. from serviceprovider
  185. where userID = #{userId}
  186. </select>
  187. <select id="findManager" resultType="java.lang.Integer">
  188. SELECT IF(csm.serviceProviderId IS NULL, 2, 1) AS manager
  189. FROM cm_serviceteam_manager csm
  190. LEFT JOIN serviceprovider s ON csm.serviceProviderId = s.serviceProviderId
  191. LEFT JOIN USER u ON s.userId = u.userId
  192. WHERE u.bindmobile = #{mobile}
  193. OR u.mobile = #{mobile}
  194. </select>
  195. <select id="findManagerByUser" resultType="java.lang.Integer">
  196. SELECT IF(csm.serviceProviderId IS NULL, 2, 1) AS manager
  197. FROM cm_serviceteam_manager csm
  198. LEFT JOIN serviceprovider s ON csm.serviceProviderId = s.serviceProviderId
  199. WHERE s.userID = #{userId}
  200. </select>
  201. <select id="findLeaderId" resultType="java.lang.Integer">
  202. SELECT leaderId
  203. FROM cm_serviceteam_role csr
  204. LEFT JOIN serviceprovider s ON s.serviceProviderId = csr.leaderId
  205. WHERE s.userId = #{userId}
  206. </select>
  207. <select id="findLeaderIdByServiceId" resultType="java.lang.Integer">
  208. select leaderId
  209. FROM cm_serviceteam_role
  210. WHERE leaderId = #{serviceProviderId}
  211. </select>
  212. <select id="findmanagerIdByServiceId" resultType="java.lang.Integer">
  213. SELECT serviceProviderId
  214. FROM cm_serviceteam_manager
  215. where serviceProviderId = #{serviceProviderId}
  216. </select>
  217. <select id="findServiceIds" resultType="java.lang.Integer">
  218. SELECT csg.serviceId
  219. FROM cm_serviceteam_group csg
  220. LEFT JOIN cm_serviceteam_role csr ON csr.id = csg.teamId
  221. WHERE csr.leaderId = #{serviceProviderId}
  222. AND csg.serviceId != #{serviceProviderId}
  223. </select>
  224. <select id="findAllServiceIds" resultType="java.lang.Integer">
  225. SELECT csg.serviceId
  226. FROM cm_serviceteam_group csg
  227. WHERE csg.serviceId != #{serviceProviderId}
  228. </select>
  229. <select id="findServices" resultType="com.caimei365.user.model.vo.ServiceProviderVo">
  230. SELECT csg.serviceId as serviceProviderId,s.linkMan as name
  231. FROM cm_serviceteam_group csg
  232. LEFT JOIN cm_serviceteam_role csr ON csr.id=csg.teamId
  233. left join serviceprovider s on csg.serviceId=s.serviceProviderID
  234. WHERE csr.leaderId = #{spId} and s.organizeID = 0
  235. <if test="status == 1">
  236. AND csg.serviceId != #{spId}
  237. </if>
  238. </select>
  239. <select id="findAllServices" resultType="com.caimei365.user.model.vo.ServiceProviderVo">
  240. SELECT csg.serviceId AS serviceProviderId,s.linkMan AS NAME
  241. FROM cm_serviceteam_group csg
  242. LEFT JOIN serviceprovider s ON csg.serviceId=s.serviceProviderID
  243. <where>
  244. s.organizeID = 0
  245. <if test="status == 1">
  246. and csg.serviceId != #{spId}
  247. </if>
  248. </where>
  249. </select>
  250. </mapper>