TopOldOrderMapper.xml 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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.zhongzheng.modules.top.goods.mapper.TopOldOrderMapper">
  6. <resultMap type="com.zhongzheng.modules.top.goods.domain.TopOldOrder" id="TopOrderResult">
  7. <result property="orderId" column="order_id"/>
  8. <result property="orderSn" column="order_sn"/>
  9. <result property="userId" column="user_id"/>
  10. <result property="orderPrice" column="order_price"/>
  11. <result property="orderGeneral" column="order_general"/>
  12. <result property="orderStatus" column="order_status"/>
  13. <result property="createTime" column="create_time"/>
  14. <result property="updateTime" column="update_time"/>
  15. <result property="payTime" column="pay_time"/>
  16. <result property="payType" column="pay_type"/>
  17. <result property="transid" column="transid"/>
  18. <result property="cancelTime" column="cancel_time"/>
  19. <result property="finishTime" column="finish_time"/>
  20. <result property="orderType" column="order_type"/>
  21. <result property="payPrice" column="pay_price"/>
  22. <result property="orderFrom" column="order_from"/>
  23. <result property="createUsername" column="create_username"/>
  24. <result property="status" column="status"/>
  25. <result property="createSysUserId" column="create_sys_user_id"/>
  26. <result property="inputOrderSn" column="input_order_sn"/>
  27. <result property="payStatus" column="pay_status"/>
  28. <result property="checkStatus" column="check_status"/>
  29. <result property="refundStatus" column="refund_status"/>
  30. <result property="creditStatus" column="credit_status"/>
  31. <result property="invoiceStatus" column="invoice_status"/>
  32. <result property="orderProfit" column="order_profit"/>
  33. <result property="orderCost" column="order_cost"/>
  34. <result property="orderRefund" column="order_refund"/>
  35. <result property="orderRefunded" column="order_refunded"/>
  36. <result property="orderUncollected" column="order_uncollected"/>
  37. <result property="orderReceived" column="order_received"/>
  38. <result property="remark" column="remark"/>
  39. <result property="orderBusiness" column="order_business"/>
  40. <result property="costJson" column="cost_json"/>
  41. <result property="buyTime" column="buy_time"/>
  42. </resultMap>
  43. <select id="queryList" parameterType="com.zhongzheng.modules.top.goods.bo.TopOldOrderQueryBo" resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderVo">
  44. SELECT
  45. vto.*
  46. FROM
  47. ( SELECT DISTINCT order_sn
  48. <if test="businessFullName != null and businessFullName != '' and (userCard == null or userCard == '')">
  49. FROM `v_top_order_business` where business_full_name = #{businessFullName}
  50. </if>
  51. <if test="userCard != null and userCard != '' and (businessFullName == null and businessFullName == '')">
  52. FROM `v_top_order_card` where user_card = #{userCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}
  53. </if>
  54. <if test="userCard != null and userCard != '' and businessFullName != null and businessFullName != ''">
  55. FROM (
  56. SELECT
  57. DISTINCT order_sn
  58. FROM
  59. ( SELECT order_sn FROM v_top_order_business WHERE business_full_name = #{businessFullName} UNION ALL SELECT order_sn FROM v_top_order_card
  60. WHERE user_card = #{userCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}) b
  61. ) m
  62. </if>
  63. <if test="(userCard == null or userCard == '') and (businessFullName == null or businessFullName == '')">
  64. FROM (
  65. SELECT
  66. DISTINCT order_sn
  67. FROM
  68. ( SELECT order_sn FROM v_top_order_business UNION ALL SELECT order_sn FROM v_top_order_card) b
  69. ) m
  70. </if>
  71. ) a
  72. LEFT JOIN v_top_order vto ON a.order_sn = vto.order_sn
  73. WHERE vto.`status` = 1
  74. <if test="checkStatus != null and checkStatus != ''">
  75. AND vto.check_status = #{checkStatus}
  76. </if>
  77. <if test="refundStatusList != null and refundStatusList.size()!=0 ">
  78. AND vto.refund_status in
  79. <foreach collection="refundStatusList" item="item" index="index" open="(" close=")" separator=",">
  80. #{item}
  81. </foreach>
  82. </if>
  83. <if test="creditStatus != null and creditStatus != ''">
  84. AND vto.check_staus = #{checkStaus}
  85. </if>
  86. <if test="invoiceStatus != null and invoiceStatus != ''">
  87. AND vto.invoice_status = #{invoiceStatus}
  88. </if>
  89. <if test="startTime != null and startTime != ''">
  90. AND vto.create_time <![CDATA[ >= ]]> #{startTime}
  91. </if>
  92. <if test="endTime != null and endTime != ''">
  93. AND vto.create_time <![CDATA[ <= ]]> #{endTime}
  94. </if>
  95. <if test="keyword != null and keyword != ''">
  96. AND (
  97. vto.create_org LIKE CONCAT( '%', #{keyword}, '%' )
  98. OR vto.order_sn LIKE CONCAT( '%', #{keyword}, '%' )
  99. OR vto.create_no LIKE CONCAT( '%', #{keyword}, '%' )
  100. OR vto.order_org LIKE CONCAT( '%', #{keyword}, '%' ))
  101. </if>
  102. </select>
  103. <select id="queryById" parameterType="java.lang.String" resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderVo">
  104. SELECT * FROM v_top_order WHERE order_sn = #{orderSn}
  105. </select>
  106. <select id="queryBusinessBySn" parameterType="java.lang.String" resultType="java.lang.String">
  107. SELECT business_name FROM v_top_order_business WHERE order_sn = #{orderSn}
  108. </select>
  109. <select id="queryByOrderSns" parameterType="java.lang.String" resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderVo">
  110. SELECT business_name FROM v_top_order_business WHERE 1 =1
  111. <if test="orderSnList != null and orderSnList.size()!=0 ">
  112. AND order_sn in
  113. <foreach collection="orderSnList" item="item" index="index" open="(" close=")" separator=",">
  114. #{item}
  115. </foreach>
  116. </if>
  117. </select>
  118. <select id="queryReceiveList" parameterType="com.zhongzheng.modules.top.goods.bo.TopOldOrderQueryBo" resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderVo">
  119. SELECT
  120. too.*,
  121. st.tenant_name,
  122. rn.id as note_id,
  123. rn.note_type,
  124. rn.day_time,
  125. rn.week_time,
  126. rn.month_time,
  127. rn.last_time
  128. FROM
  129. top_old_order too
  130. LEFT JOIN sys_tenant st ON too.tenant_id = st.tenant_id
  131. LEFT JOIN top_order_rec_note rn ON too.tenant_id = rn.tenant_id and too.order_sn = rn.order_sn
  132. where 1=1
  133. <if test="startTime != null and startTime != ''">
  134. AND too.create_time <![CDATA[ >= ]]> #{startTime}
  135. </if>
  136. <if test="endTime != null and endTime != ''">
  137. AND too.create_time <![CDATA[ <= ]]> #{endTime}
  138. </if>
  139. <if test="keyNo != null and keyNo != ''">
  140. AND (too.tenant_id like concat('%', #{keyNo}, '%') or too.create_no like concat('%', #{keyNo}, '%'))
  141. </if>
  142. <if test="creditStatus != null and creditStatus != ''">
  143. AND too.credit_status = #{creditStatus}
  144. </if>
  145. ORDER BY too.order_id DESC
  146. </select>
  147. <select id="queryListAll" resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderVo">
  148. SELECT * FROM v_top_order
  149. </select>
  150. <select id="getOrderBySn" parameterType="java.lang.String" resultType="com.zhongzheng.modules.top.goods.domain.TopOldOrder">
  151. SELECT * FROM top_old_order WHERE order_sn = #{orderSn}
  152. </select>
  153. </mapper>