MaTechnicianMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper
  3. PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4. "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5. <mapper namespace="com.ylx.massage.mapper.MaTechnicianMapper">
  6. <resultMap type="MaTechnician" id="MaTechnicianResult">
  7. <result property="id" column="id" />
  8. <result property="teName" column="te_name" />
  9. <result property="teNickName" column="te_nick_name" />
  10. <result property="teSex" column="te_sex" />
  11. <result property="tePhone" column="te_phone" />
  12. <result property="teAddress" column="te_address" />
  13. <result property="teAreaCode" column="te_area_code" />
  14. <result property="teAge" column="te_age" />
  15. <result property="teAvatar" column="te_avatar" />
  16. <result property="openService" column="openService" />
  17. <result property="lifePhotos" column="life_photos" />
  18. <result property="avatar" column="avatar" />
  19. <result property="teBrief" column="te_brief" />
  20. <result property="avatar" column="avatar" />
  21. <result property="idCard" column="id_card" />
  22. <result property="healthCertificate" column="health_certificate" />
  23. <result property="qualificationCertificate" column="qualification_certificate" />
  24. <result property="noCrimeRecord" column="no_crime_record" />
  25. <result property="commitmentPdf" column="commitment_pdf" />
  26. <result property="commitmentAudio" column="commitment_audio" />
  27. <result property="commitmentVideo" column="commitment_video" />
  28. <result property="serviceState" column="service_state" />
  29. <result property="nStatus2" column="n_status2" />
  30. <result property="merchantStatus" column="merchant_status" />
  31. <result property="postState" column="post_state" />
  32. <result property="techType" column="tech_type" />
  33. <result property="teIsEnable" column="te_is_enable" />
  34. <result property="auditStatus" column="audit_status" />
  35. <result property="createUser" column="create_user" />
  36. <result property="updateUser" column="update_user" />
  37. <result property="createTime" column="create_time" />
  38. <result property="updateTime" column="update_time" />
  39. <result property="isDelete" column="is_delete" />
  40. <result property="nStar" column="n_star" />
  41. <result property="nNum" column="n_num" />
  42. <result property="isRecommend" column="is_recommend" />
  43. </resultMap>
  44. <sql id="selectMaTechnicianVo">
  45. select id, te_name, te_nick_name, te_sex, te_phone, te_address, te_area_code, te_age, te_avatar,
  46. openService, life_photos, avatar, te_brief, service_state, ns_status2, merchant_status,
  47. post_state, tech_type, te_is_enable, audit_status, create_user, update_user, create_time,
  48. update_time, is_delete, n_star, n_num, is_recommend
  49. from ma_technician
  50. </sql>
  51. <select id="selectMaTechnicianList" parameterType="MaTechnician" resultMap="MaTechnicianResult">
  52. <include refid="selectMaTechnicianVo"/>
  53. <where>
  54. <if test="teName != null and teName != ''"> and te_name like concat('%', #{teName}, '%')</if>
  55. <if test="teNickName != null and teNickName != ''"> and te_nick_name like concat('%', #{teNickName}, '%')</if>
  56. <if test="teSex != null "> and te_sex = #{teSex}</if>
  57. <if test="tePhone != null and tePhone != ''"> and te_phone = #{tePhone}</if>
  58. <if test="teAddress != null and teAddress != ''"> and te_address = #{teAddress}</if>
  59. <if test="openService != null "> and openService = #{openService}</if>
  60. <if test="teAge != null "> and te_age = #{teAge}</if>
  61. <if test="teAvatar != null and teAvatar != ''"> and te_avatar = #{teAvatar}</if>
  62. <if test="lifePhotos != null and lifePhotos != ''"> and life_photos = #{lifePhotos}</if>
  63. <if test="teBrief != null and teBrief != ''"> and te_brief = #{teBrief}</if>
  64. <if test="serviceState != null "> and service_state = #{serviceState}</if>
  65. <if test="nsStatus2 != null "> and ns_status2 = #{nsStatus2}</if>
  66. <if test="merchantStatus != null and merchantStatus != ''"> and merchant_status = #{merchantStatus}</if>
  67. <if test="postState != null "> and post_state = #{postState}</if>
  68. <if test="techType != null "> and tech_type = #{techType}</if>
  69. <if test="teIsEnable != null "> and te_is_enable = #{teIsEnable}</if>
  70. <if test="auditStatus != null "> and audit_status = #{auditStatus}</if>
  71. <if test="isRecommend != null "> and is_recommend = #{isRecommend}</if>
  72. <if test="createUser != null "> and create_user = #{createUser}</if>
  73. <if test="updateUser != null "> and update_user = #{updateUser}</if>
  74. <if test="isDelete != null "> and is_delete = #{isDelete}</if>
  75. </where>
  76. </select>
  77. <select id="selectMaTechnicianById" parameterType="Long" resultMap="MaTechnicianResult">
  78. <include refid="selectMaTechnicianVo"/>
  79. where id = #{id}
  80. </select>
  81. <insert id="insertMaTechnician" parameterType="MaTechnician" useGeneratedKeys="true" keyProperty="id">
  82. insert into ma_technician
  83. <trim prefix="(" suffix=")" suffixOverrides=",">
  84. <if test="teName != null and teName != ''">te_name,</if>
  85. <if test="teNickName != null and teNickName != ''">te_nick_name,</if>
  86. <if test="teSex != null">te_sex,</if>
  87. <if test="tePhone != null and tePhone != ''">te_phone,</if>
  88. <if test="teAddress != null">te_address,</if>
  89. <if test="teAreaCode != null and teAreaCode != ''">te_area_code,</if>
  90. <if test="teAge != null">te_age,</if>
  91. <if test="teAvatar != null and teAvatar != ''">te_avatar,</if>
  92. <if test="openService != null">openService,</if>
  93. <if test="teProject != null and teProject != ''">te_project,</if>
  94. <if test="lifePhotos != null and lifePhotos != ''">life_photos,</if>
  95. <if test="avatar != null and avatar != ''">avatar,</if>
  96. <if test="teBrief != null and teBrief != ''">te_brief,</if>
  97. <if test="serviceState != null">service_state,</if>
  98. <if test="nStatus2 != null">n_status2,</if>
  99. <if test="merchantStatus != null and merchantStatus != ''">merchant_status,</if>
  100. <if test="postState != null">post_state,</if>
  101. <if test="techType != null">tech_type,</if>
  102. <if test="teIsEnable != null">te_is_enable,</if>
  103. <if test="auditStatus != null">audit_status,</if>
  104. <if test="createBy != null">create_by,</if>
  105. <if test="updateBy != null">update_by,</if>
  106. <if test="createTime != null">create_time,</if>
  107. <if test="updateTime != null">update_time,</if>
  108. <if test="isDelete != null">is_delete,</if>
  109. <if test="nStar != null">n_star,</if>
  110. <if test="nNum != null">n_num,</if>
  111. <if test="isRecommend != null">is_recommend,</if>
  112. </trim>
  113. <trim prefix="values (" suffix=")" suffixOverrides=",">
  114. <if test="teName != null and teName != ''">#{teName},</if>
  115. <if test="teNickName != null and teNickName != ''">#{teNickName},</if>
  116. <if test="teSex != null">#{teSex},</if>
  117. <if test="tePhone != null and tePhone != ''">#{tePhone},</if>
  118. <if test="teAddress != null">#{teAddress},</if>
  119. <if test="teAreaCode != null and teAreaCode != ''">#{teAreaCode},</if>
  120. <if test="teAge != null">#{teAge},</if>
  121. <if test="teAvatar != null and teAvatar != ''">#{teAvatar},</if>
  122. <if test="openService != null">#{openService},</if>
  123. <if test="teProject != null and teProject != ''">#{teProject},</if>
  124. <if test="lifePhotos != null and lifePhotos != ''">#{lifePhotos},</if>
  125. <if test="avatar != null and avatar != ''">#{avatar},</if>
  126. <if test="teBrief != null and teBrief != ''">#{teBrief},</if>
  127. <if test="serviceState != null">#{serviceState},</if>
  128. <if test="nStatus2 != null">#{nStatus2},</if>
  129. <if test="merchantStatus != null and merchantStatus != ''">#{merchantStatus},</if>
  130. <if test="postState != null">#{postState},</if>
  131. <if test="techType != null">#{techType},</if>
  132. <if test="teIsEnable != null">#{teIsEnable},</if>
  133. <if test="auditStatus != null">#{auditStatus},</if>
  134. <if test="createBy != null">#{createBy},</if>
  135. <if test="updateBy != null">#{updateBy},</if>
  136. <if test="createTime != null">#{createTime},</if>
  137. <if test="updateTime != null">#{updateTime},</if>
  138. <if test="isDelete != null">#{isDelete},</if>
  139. <if test="nStar != null">#{nStar},</if>
  140. <if test="nNum != null">#{nNum},</if>
  141. <if test="isRecommend != null">#{isRecommend},</if>
  142. </trim>
  143. </insert>
  144. <update id="updateMaTechnician" parameterType="MaTechnician">
  145. update ma_technician
  146. <trim prefix="SET" suffixOverrides=",">
  147. <if test="teName != null and teName != ''">te_name = #{teName},</if>
  148. <if test="teNickName != null and teNickName != ''">te_nick_name = #{teNickName},</if>
  149. <if test="teSex != null">te_sex = #{teSex},</if>
  150. <if test="tePhone != null and tePhone != ''">te_phone = #{tePhone},</if>
  151. <if test="teAddress != null and teAddress != ''">te_address = #{teAddress},</if>
  152. <if test="teAreaCode != null and teAreaCode != ''">te_area_code = #{teAreaCode},</if>
  153. <if test="teAge != null">te_age = #{teAge},</if>
  154. <if test="teAvatar != null and teAvatar != ''">te_avatar = #{teAvatar},</if>
  155. <if test="openService != null">openService = #{openService},</if>
  156. <if test="lifePhotos != null and lifePhotos != ''">life_photos = #{lifePhotos},</if>
  157. <if test="avatar != null and avatar != ''">avatar = #{avatar},</if>
  158. <if test="teBrief != null and teBrief != ''">te_brief = #{teBrief},</if>
  159. <if test="serviceState != null">service_state = #{serviceState},</if>
  160. <if test="nsStatus2 != null">ns_status2 = #{nsStatus2},</if>
  161. <if test="merchantStatus != null and merchantStatus != ''">merchant_status = #{merchantStatus},</if>
  162. <if test="postState != null">post_state = #{postState},</if>
  163. <if test="techType != null">tech_type = #{techType},</if>
  164. <if test="teIsEnable != null">te_is_enable = #{teIsEnable},</if>
  165. <if test="auditStatus != null">audit_status = #{auditStatus},</if>
  166. <if test="createUser != null">create_user = #{createUser},</if>
  167. <if test="updateUser != null">update_user = #{updateUser},</if>
  168. <if test="createTime != null">create_time = #{createTime},</if>
  169. <if test="updateTime != null">update_time = #{updateTime},</if>
  170. <if test="isDelete != null">is_delete = #{isDelete},</if>
  171. <if test="nStar != null">n_star = #{nStar},</if>
  172. <if test="nNum != null">n_num = #{nNum},</if>
  173. <if test="isRecommend != null">is_recommend = #{isRecommend},</if>
  174. </trim>
  175. where id = #{id}
  176. </update>
  177. <delete id="deleteMaTechnicianById" parameterType="Long">
  178. delete from ma_technician where id = #{id}
  179. </delete>
  180. <delete id="deleteMaTechnicianByIds" parameterType="String">
  181. delete from ma_technician where id in
  182. <foreach item="id" collection="array" open="(" separator="," close=")">
  183. #{id}
  184. </foreach>
  185. </delete>
  186. <resultMap type="com.ylx.massage.domain.vo.MaTechnicianMerchantListVO" id="MaTechnicianMerchantListResult">
  187. <result property="merchantId" column="merchant_id"/>
  188. <result property="teName" column="te_name"/>
  189. <result property="teNickName" column="te_nick_name"/>
  190. <result property="teSex" column="te_sex"/>
  191. <result property="teSexName" column="te_sex_name"/>
  192. <result property="teAvatar" column="te_avatar"/>
  193. <result property="tePhone" column="te_phone"/>
  194. <result property="nStar" column="n_star"/>
  195. <result property="serviceState" column="service_state"/>
  196. <result property="serviceStateName" column="service_state_name"/>
  197. <result property="nNum" column="n_num"/>
  198. <result property="onlineTime" column="online_time"/>
  199. <result property="teProject" column="te_project"/>
  200. <result property="postState" column="post_state"/>
  201. <result property="isRecommend" column="is_recommend"/>
  202. <result property="techType" column="tech_type"/>
  203. <result property="techTypeName" column="tech_type_name"/>
  204. <result property="merchantStatus" column="merchant_status"/>
  205. <result property="merchantStatusName" column="merchant_status_name"/>
  206. <result property="createTime" column="create_time"/>
  207. </resultMap>
  208. <select id="selectMerchantList" resultMap="MaTechnicianMerchantListResult">
  209. SELECT
  210. t.id AS merchant_id,
  211. t.te_name,
  212. t.te_nick_name,
  213. t.te_sex,
  214. CASE t.te_sex
  215. WHEN 0 THEN '女'
  216. WHEN 1 THEN '男'
  217. ELSE ''
  218. END AS te_sex_name,
  219. t.te_avatar,
  220. t.te_phone,
  221. t.n_star,
  222. t.service_state,
  223. CASE t.service_state
  224. WHEN 0 THEN '服务中'
  225. WHEN 1 THEN '待接单'
  226. WHEN 2 THEN '休息中'
  227. ELSE ''
  228. END AS service_state_name,
  229. t.n_num,
  230. IFNULL(sign_data.online_time, 0) AS online_time,
  231. t.te_project,
  232. t.post_state,
  233. t.is_recommend,
  234. t.tech_type,
  235. CASE t.tech_type
  236. WHEN 0 THEN '正式用户'
  237. WHEN 1 THEN '虚拟用户'
  238. ELSE ''
  239. END AS tech_type_name,
  240. t.merchant_status,
  241. CASE t.merchant_status
  242. WHEN '0' THEN '正常'
  243. WHEN '1' THEN '限制接单'
  244. WHEN '2' THEN '冻结'
  245. WHEN '3' THEN '注销'
  246. ELSE ''
  247. END AS merchant_status_name,
  248. t.create_time
  249. FROM ma_technician t
  250. LEFT JOIN (
  251. SELECT js_id, SUM(IFNULL(online_time, 0)) AS online_time
  252. FROM t_sign
  253. WHERE is_delete = 0
  254. GROUP BY js_id
  255. ) sign_data ON sign_data.js_id = t.id
  256. <where>
  257. t.is_delete = 0
  258. <if test="dto != null">
  259. <!-- 商户姓名 -->
  260. <if test="dto.teName != null and dto.teName != ''">
  261. AND t.te_name LIKE CONCAT('%', #{dto.teName}, '%')
  262. </if>
  263. <!-- 商户昵称 -->
  264. <if test="dto.teNickName != null and dto.teNickName != ''">
  265. AND t.te_nick_name LIKE CONCAT('%', #{dto.teNickName}, '%')
  266. </if>
  267. <!-- 服务类目 -->
  268. <if test="dto.openService != null">
  269. AND t.openService = #{dto.openService}
  270. </if>
  271. <!-- 手机号 -->
  272. <if test="dto.tePhone != null and dto.tePhone != ''">
  273. AND t.te_phone LIKE CONCAT('%', #{dto.tePhone}, '%')
  274. </if>
  275. <!-- 注册开始时间 -->
  276. <if test="dto.beginCreateTime != null and dto.beginCreateTime != ''">
  277. AND t.create_time &gt;= #{dto.beginCreateTime}
  278. </if>
  279. <!-- 注册结束时间 -->
  280. <if test="dto.endCreateTime != null and dto.endCreateTime != ''">
  281. AND t.create_time &lt;= #{dto.endCreateTime}
  282. </if>
  283. <!-- 上架状态 -->
  284. <if test="dto.postState != null">
  285. AND t.post_state = #{dto.postState}
  286. </if>
  287. <!-- 性别 -->
  288. <if test="dto.teSex != null">
  289. AND t.te_sex = #{dto.teSex}
  290. </if>
  291. <!-- 服务状态 -->
  292. <if test="dto.serviceState != null">
  293. AND t.service_state = #{dto.serviceState}
  294. </if>
  295. <!-- 用户类型 -->
  296. <if test="dto.techType != null">
  297. AND t.tech_type = #{dto.techType}
  298. </if>
  299. </if>
  300. </where>
  301. ORDER BY t.create_time DESC
  302. </select>
  303. <!-- 首页按摩商户推荐列表-->
  304. <select id="getMerchantRecommend" resultType="com.ylx.massage.domain.vo.MerchantVo">
  305. SELECT
  306. t.id AS merchantId,
  307. t.te_name AS teName,
  308. t.n_star AS nStar,
  309. t.n_num AS nNum,
  310. p.price AS price,
  311. ST_Distance_Sphere(
  312. POINT(a.longitude, a.latitude),
  313. POINT(#{dto.longitude}, #{dto.latitude})
  314. ) / 1000 AS distance
  315. FROM ma_technician t
  316. LEFT JOIN t_address a ON t.id = a.merchant_id
  317. LEFT JOIN(
  318. SELECT p.user_id AS user_id ,
  319. p.project_current_price AS price
  320. FROM ma_project p
  321. WHERE p.is_delete = 0
  322. ORDER BY p.project_current_price ASC
  323. LIMIT 1
  324. ) p ON t.id = p.user_d
  325. WHERE
  326. t.is_delete = 0
  327. and t.openService = 1
  328. and t.audit_status = 2
  329. and a.user_type = 2
  330. and a.type = 1
  331. and a.is_delete = 0
  332. ORDER BY t.n_num DESC
  333. LIMIT 5
  334. </select>
  335. </mapper>