MaTechnicianMapper.xml 17 KB

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