LifeUserOrderMapper.xml 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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="shop.alien.mapper.LifeUserOrderMapper">
  6. <!-- 通用查询映射结果 -->
  7. <resultMap id="BaseResultMap" type="shop.alien.entity.store.vo.LifeUserOrderVo">
  8. <id column="id" property="id" />
  9. <result column="order_no" property="orderNo"/>
  10. <result column="created_time" property="createdTime"/>
  11. <result column="price" property="price"/>
  12. <result column="final_price" property="finalPrice"/>
  13. <result column="coupon_name" property="couponName"/>
  14. <result column="nominal_value" property="nominalValue"/>
  15. <result column="user_phone" property="userPhone"/>
  16. <result column="commission_rate" property="commissionRate"/>
  17. <result column="img_url" property="imgUrl"/>
  18. <result column="pay_method" property="payMethod"/>
  19. <result column="buy_time" property="buyTime"/>
  20. <result column="cancel_time" property="cancelTime"/>
  21. <result column="pay_time" property="payTime"/>
  22. <result column="finish_time" property="finishTime"/>
  23. <result column="coupon_type" property="couponType"/>
  24. <result column="coupon_id" property="couponId"/>
  25. <result column="offprice" property="offprice"/>
  26. <result column="store_id" property="storeId"/>
  27. <result column="store_name" property="storeName"/>
  28. <result column="commission_rate" property="commissionRate"/>
  29. <result column="img_url" property="imgUrl"/>
  30. <result column="user_name" property="userName"/>
  31. <result column="order_status" property="status"/>
  32. <result column="dist" property="dist"/>
  33. <result column="store_address" property="storeAddress"/>
  34. <result column="effective_date_type" property="effectiveDateType"/>
  35. <result column="effective_date_value" property="effectiveDateValue"/>
  36. <result column="use_rules" property="useRules"/>
  37. <result column="applicable_num" property="applicableNum"/>
  38. <result column="quota_type" property="quotaType"/>
  39. <result column="quota_value" property="quotaValue"/>
  40. <result column="store_tel" property="storeTel"/>
  41. <result column="quan_id" property="quanId"/>
  42. <result column="total_refund_time" property="totalRefundTime"/>
  43. <result column="business_status" property="businessStatus"/>
  44. <result column="type" property="type"/>
  45. <result column="store_type" property="storeType"/>
  46. <result column="store_status" property="storeStatus"/>
  47. <result column="business_type" property="businessType"/>
  48. <result column="collect_num" property="collectNum"/>
  49. <result column="business_date" property="businessDate"/>
  50. <result column="start_time" property="startTime"/>
  51. <result column="end_time" property="endTime"/>
  52. <result column="end_date" property="endDate"/>
  53. <result column="reservation_rules" property="reservationRules"/>
  54. <result column="original_price" property="originalPrice"/>
  55. <result column="order_str" property="orderStr"/>
  56. <result column="store_user_tel" property="storeUserTel"/>
  57. <result column="expert_order_id" property="expertOrderId"/>
  58. <result column="order_appraise" property="orderAppraise"/>
  59. <collection property="orderCouponMiddleList" ofType="shop.alien.entity.store.vo.OrderCouponMiddleVo">
  60. <id column="ocmId" property="id" />
  61. <result column="status" property="status"/>
  62. <result column="coupon_code" property="couponCode"/>
  63. <result column="refund_time" property="refundTime"/>
  64. <result column="refund_reason" property="refundReason"/>
  65. <result column="refundPrice" property="price"/>
  66. <result column="used_time" property="usedTime"/>
  67. </collection>
  68. </resultMap>
  69. <!-- 查询用户订单详情 -->
  70. <select id="queryUserOrderDetail" resultMap="BaseResultMap">
  71. with total_coupon as(
  72. select id coupon_id,2 coupon_type,lgbm.group_name coupon_name,preferential_price offprice,original_price, SUBSTRING_INDEX(image_id, ',', 1) AS image_id,
  73. effective_date_type,effective_date_value,use_rules,reservation_rules,applicable_num,quota_type,quota_value,inventory_num single_qty
  74. from life_group_buy_main lgbm where lgbm.delete_flag = 0
  75. union all
  76. select id coupon_id,1 coupon_type,lc.name coupon_name,lc.offprice offprice,price original_price,SUBSTRING_INDEX(image_path, ',', 1) AS image_id,
  77. 0 effective_date_type,expiration_date effective_date_value,use_rule use_rules,reservation_rules,applicable_num,1 quota_type,buy_limit quota_value,single_qty
  78. from life_coupon lc where lc.delete_flag = 0
  79. )
  80. select luo.id,luo.order_no,luo.created_time , luo.price ,
  81. CASE
  82. WHEN luo.final_price IS NOT NULL AND luo.final_price != '' THEN
  83. FORMAT(CAST(luo.final_price AS DECIMAL(10,2)), 2)
  84. ELSE '0.00'
  85. END as final_price,
  86. luo.order_str,
  87. luo.pay_method,luo.buy_time,luo.cancel_time,luo.pay_time,luo.finish_time,luo.status order_status,luo.quan_id,luo.refund_time total_refund_time,luo.expert_order_id,
  88. tc.*,
  89. ldc.nominal_value,ldc.type,
  90. lu.user_phone,lu.user_name,lu.id user_id,
  91. ocm.id ocmId,ocm.status,ocm.coupon_code,ocm.refund_time,ocm.refund_reason,ocm.price refundPrice,
  92. si.id store_id,si.store_name,si.commission_rate,si.store_address,si.store_tel,si.business_status,si.collect_num,si.business_section store_type,si.store_status,
  93. su.phone store_user_tel,
  94. <if test="position != null and position != ''">
  95. ROUND(
  96. ST_Distance_Sphere(
  97. ST_GeomFromText(CONCAT('POINT(', REPLACE(#{position}, ',', ' '), ')')),
  98. ST_GeomFromText(CONCAT('POINT(', REPLACE(si.store_position, ',', ' '), ')'))
  99. ) / 1000,
  100. 2
  101. ) AS dist,
  102. </if>
  103. simg.img_url,
  104. sbi.business_type,sbi.business_date,sbi.start_time,sbi.end_time
  105. from life_user_order luo
  106. left join store_info si on si.id = luo.store_id and si.delete_flag = 0
  107. left join order_coupon_middle ocm on ocm.order_id = luo.id and ocm.delete_flag = 0
  108. left join total_coupon tc on tc.coupon_id = ocm.coupon_id and tc.coupon_type = luo.coupon_type
  109. left join life_discount_coupon_user ldcu on ldcu.id = luo.quan_id and ldcu.delete_flag = 0
  110. left join life_discount_coupon ldc on ldc.id = ldcu.coupon_id and ldc.delete_flag = 0
  111. left join life_user lu on lu.id = luo.user_id and lu.delete_flag = 0
  112. left join store_img simg on simg.id = tc.image_id and simg.delete_flag = 0
  113. left join store_business_info sbi on sbi.store_id = si.id and sbi.delete_flag = 0
  114. left join store_user su on su.store_id = si.id and su.delete_flag = 0
  115. where luo.id = #{orderId}
  116. order by luo.created_time desc
  117. </select>
  118. <select id="selectRefundList" resultMap="BaseResultMap">
  119. with total_coupon as(
  120. select id coupon_id,2 coupon_type,lgbm.group_name coupon_name,preferential_price offprice,SUBSTRING_INDEX(image_id, ',', 1) AS image_id,
  121. effective_date_type,effective_date_value,use_rules,reservation_rules,applicable_num,quota_type,quota_value,inventory_num single_qty,end_time end_date
  122. from life_group_buy_main lgbm where lgbm.delete_flag = 0
  123. union all
  124. select id coupon_id,1 coupon_type,lc.name coupon_name,lc.offprice offprice,SUBSTRING_INDEX(image_path, ',', 1) AS image_id,
  125. 0 effective_date_type,expiration_date effective_date_value,use_rule use_rules,reservation_rules,applicable_num,1 quota_type,buy_limit quota_value,single_qty,end_date
  126. from life_coupon lc where lc.delete_flag = 0
  127. )
  128. select luo.id,luo.order_no,luo.created_time , luo.price ,luo.final_price
  129. ,luo.pay_method,luo.buy_time,luo.cancel_time,luo.pay_time,luo.finish_time,luo.status order_status,luo.quan_id,
  130. tc.*,
  131. ldc.nominal_value,
  132. lu.user_phone,lu.user_name,lu.id user_id,
  133. ocm.id ocmId,ocm.status,ocm.coupon_code,ocm.refund_time,ocm.refund_reason,ocm.price refundPrice,
  134. si.id store_id,si.store_name,si.commission_rate,si.store_address,si.store_tel,
  135. simg.img_url,
  136. sbi.business_type,sbi.business_date,sbi.start_time,sbi.end_time
  137. from life_user_order luo
  138. left join store_info si on si.id = luo.store_id and si.delete_flag = 0
  139. left join order_coupon_middle ocm on ocm.order_id = luo.id and ocm.delete_flag = 0
  140. inner join total_coupon tc on tc.coupon_id = ocm.coupon_id and tc.coupon_type = luo.coupon_type
  141. left join life_discount_coupon_user ldcu on ldcu.id = luo.quan_id and ldcu.delete_flag = 0
  142. left join life_discount_coupon ldc on ldc.id = ldcu.coupon_id and ldc.delete_flag = 0
  143. left join life_user lu on lu.id = luo.user_id and lu.delete_flag = 0
  144. left join store_img simg on simg.id = tc.image_id and simg.delete_flag = 0
  145. left join store_business_info sbi on sbi.store_id = si.id and sbi.delete_flag = 0
  146. <where>
  147. <!-- 引用 LambdaQueryWrapper 构建的条件 -->
  148. ${ew.sqlSegment}
  149. </where>
  150. order by luo.created_time desc
  151. </select>
  152. </mapper>