LawyerConsultationOrderMapper.xml 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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="shop.alien.mapper.LawyerConsultationOrderMapper">
  4. <!-- 通用查询映射结果 -->
  5. <resultMap id="BaseResultMap" type="shop.alien.entity.store.LawyerConsultationOrder">
  6. <id column="id" property="id" />
  7. <result column="order_number" property="orderNumber" />
  8. <result column="client_user_id" property="clientUserId" />
  9. <result column="lawyer_user_id" property="lawyerUserId" />
  10. <result column="problem_scenario_id" property="problemScenarioId" />
  11. <result column="problem_description" property="problemDescription" />
  12. <result column="order_amount" property="orderAmount" />
  13. <result column="consultation_fee" property="consultationFee" />
  14. <result column="start_time" property="startTime" />
  15. <result column="end_time" property="endTime" />
  16. <result column="order_status" property="orderStatus" />
  17. <result column="payment_status" property="paymentStatus" />
  18. <result column="order_time" property="orderTime" />
  19. <result column="payment_time" property="paymentTime" />
  20. <result column="validity_period" property="validityPeriod" />
  21. <result column="rating" property="rating" />
  22. <result column="comment" property="comment" />
  23. <result column="delete_flag" property="deleteFlag" />
  24. <result column="created_time" property="createdTime" />
  25. <result column="created_user_id" property="createdUserId" />
  26. <result column="updated_time" property="updatedTime" />
  27. <result column="updated_user_id" property="updatedUserId" />
  28. <result column="alipay_no" property="alipayNo" />
  29. </resultMap>
  30. <!-- 通用查询结果列 -->
  31. <sql id="Base_Column_List">
  32. id, order_number, client_user_id, lawyer_user_id, problem_scenar_id, problem_description,
  33. order_amount, consultation_fee, start_time, end_time, order_status, payment_status,
  34. order_time,payment_time, validity_period, rating, comment, delete_flag, created_time,
  35. created_user_id, updated_time, updated_user_id, alipay_no
  36. </sql>
  37. <!-- 訂單VO結果映射,包含律師信息 -->
  38. <resultMap id="OrderVOWithLawyerResultMap" type="shop.alien.entity.store.vo.LawyerConsultationOrderVO">
  39. <!-- 訂單基本信息 -->
  40. <id column="id" property="id" />
  41. <result column="order_number" property="orderNumber" />
  42. <result column="client_user_id" property="clientUserId" />
  43. <result column="lawyer_user_id" property="lawyerUserId" />
  44. <result column="problem_scenario_id" property="problemScenarId" />
  45. <result column="problem_description" property="problemDescription" />
  46. <result column="order_amount" property="orderAmount" />
  47. <result column="consultation_fee" property="consultationFee" />
  48. <result column="start_time" property="startTime" />
  49. <result column="end_time" property="endTime" />
  50. <result column="order_status" property="orderStatus" />
  51. <result column="payment_status" property="paymentStatus" />
  52. <result column="order_time" property="orderTime" />
  53. <result column="payment_time" property="paymentTime" />
  54. <result column="validity_period" property="validityPeriod" />
  55. <result column="rating" property="rating" />
  56. <result column="comment" property="comment" />
  57. <result column="created_time" property="createdTime" />
  58. <!-- 律師信息 -->
  59. <result column="lawyer_name" property="lawyerName" />
  60. <result column="lawyer_phone" property="lawyerPhone" />
  61. <result column="lawyer_email" property="lawyerEmail" />
  62. <result column="lawyer_certificate_no" property="lawyerCertificateNo" />
  63. <result column="law_firm" property="lawFirm" />
  64. <result column="practice_years" property="practiceYears" />
  65. <result column="specialty_fields" property="specialtyFields" />
  66. <result column="certification_status" property="certificationStatus" />
  67. <result column="service_score" property="serviceScore" />
  68. <result column="service_count" property="serviceCount" />
  69. <result column="lawyer_consultation_fee" property="lawyerConsultationFee" />
  70. <result column="province" property="province" />
  71. <result column="city" property="city" />
  72. <result column="district" property="district" />
  73. <result column="address" property="address" />
  74. <result column="head_img" property="headImg" />
  75. <result column="nick_name" property="nickName" />
  76. <result column="personal_introduction" property="personalIntroduction" />
  77. <result column="expertise_area_info" property="expertiseAreaInfo" />
  78. </resultMap>
  79. <!-- 分頁查詢訂單列表,聯查律師信息 -->
  80. <select id="getConsultationOrderListWithLawyer" resultMap="OrderVOWithLawyerResultMap">
  81. SELECT
  82. o.id,
  83. o.order_number,
  84. o.client_user_id,
  85. o.lawyer_user_id,
  86. o.problem_scenario_id,
  87. o.problem_description,
  88. o.order_amount,
  89. o.consultation_fee,
  90. o.start_time,
  91. o.end_time,
  92. o.order_status,
  93. o.payment_status,
  94. o.order_time,
  95. o.payment_time,
  96. o.validity_period,
  97. o.rating,
  98. o.comment,
  99. o.created_time,
  100. -- 律師信息
  101. l.name AS lawyer_name,
  102. l.phone AS lawyer_phone,
  103. l.email AS lawyer_email,
  104. l.lawyer_certificate_no,
  105. l.law_firm,
  106. l.practice_years,
  107. l.specialty_fields,
  108. l.certification_status,
  109. l.service_score,
  110. l.service_count,
  111. l.consultation_fee AS lawyer_consultation_fee,
  112. l.province,
  113. l.city,
  114. l.district,
  115. l.address,
  116. l.head_img,
  117. l.nick_name,
  118. l.personal_introduction
  119. FROM lawyer_consultation_order o
  120. LEFT JOIN lawyer_user l ON o.lawyer_user_id = l.id AND l.delete_flag = 0
  121. WHERE o.delete_flag = 0
  122. <if test="orderNumber != null and orderNumber != ''">
  123. AND o.order_number = #{orderNumber}
  124. </if>
  125. <if test="clientUserId != null">
  126. AND o.client_user_id = #{clientUserId}
  127. </if>
  128. <if test="lawyerUserId != null">
  129. AND o.lawyer_user_id = #{lawyerUserId}
  130. </if>
  131. <if test="lawyerUserIds != null and lawyerUserIds.size() > 0">
  132. AND o.lawyer_user_id IN
  133. <foreach collection="lawyerUserIds" item="id" open="(" separator="," close=")">
  134. #{id}
  135. </foreach>
  136. </if>
  137. <if test="lawyerName != null and lawyerName != '' and (lawyerUserIds == null or lawyerUserIds.size() == 0)">
  138. AND l.name LIKE CONCAT('%', #{lawyerName}, '%')
  139. </if>
  140. <if test="orderStatus != null">
  141. AND o.order_status = #{orderStatus}
  142. </if>
  143. ORDER BY o.created_time DESC
  144. </select>
  145. <!-- 根据用户ID查询订单列表 -->
  146. <select id="getConsultationOrderListById" resultMap="OrderVOWithLawyerResultMap">
  147. SELECT
  148. lco.id,
  149. lco.order_number,
  150. lco.client_user_id,
  151. lco.lawyer_user_id,
  152. lco.problem_scenario_id,
  153. lco.problem_description,
  154. ROUND(IFNULL(lco.order_amount, 0) / 100, 2) as order_amount,
  155. lco.consultation_fee,
  156. lco.start_time,
  157. lco.end_time,
  158. lco.order_status,
  159. lco.payment_status,
  160. lco.order_time,
  161. lco.payment_time,
  162. lco.validity_period,
  163. lco.rating,
  164. lco.comment,
  165. lco.created_time,
  166. lu.name AS lawyer_name,
  167. lu.phone AS lawyer_phone,
  168. lu.email AS lawyer_email,
  169. lu.lawyer_certificate_no,
  170. lu.law_firm,
  171. lu.practice_years,
  172. lu.specialty_fields,
  173. lu.certification_status,
  174. lu.service_score,
  175. lu.service_count,
  176. lu.consultation_fee AS lawyer_consultation_fee,
  177. lu.province,
  178. lu.city,
  179. lu.district,
  180. lu.address,
  181. lu.head_img,
  182. lu.nick_name,
  183. lu.personal_introduction,
  184. lea.expertise_area_info
  185. FROM lawyer_consultation_order lco
  186. LEFT JOIN lawyer_user lu ON lco.lawyer_user_id = lu.id AND lu.delete_flag = 0
  187. left join lawyer_expertise_area lea on lea.id = lu.lawyer_expertise_area_id and lea.delete_flag = 0
  188. WHERE lco.delete_flag = 0
  189. <if test="userId != null and userId !=''">
  190. AND lco.client_user_id = #{userId}
  191. </if>
  192. <if test="lawyerUserIds != null and lawyerUserIds.size() > 0">
  193. AND lco.lawyer_user_id IN
  194. <foreach collection="lawyerUserIds" item="id" open="(" separator="," close=")">
  195. #{id}
  196. </foreach>
  197. </if>
  198. <if test="orderStatus != null and orderStatus !=''">
  199. AND lco.order_status = #{orderStatus}
  200. </if>
  201. ORDER BY lco.created_time DESC
  202. </select>
  203. </mapper>