TopOldOrderMapper.xml 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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 != '' and creditStatus == 0">
  84. AND vto.order_received <![CDATA[ < ]]> vto.pay_price
  85. </if>
  86. <if test="creditStatus != null and creditStatus != '' and creditStatus == 1">
  87. AND vto.pay_price = vto.order_received
  88. </if>
  89. <if test="invoiceStatus != null and invoiceStatus != ''">
  90. AND vto.invoice_status = #{invoiceStatus}
  91. </if>
  92. <if test="startTime != null and startTime != ''">
  93. AND vto.create_time <![CDATA[ >= ]]> #{startTime}
  94. </if>
  95. <if test="endTime != null and endTime != ''">
  96. AND vto.create_time <![CDATA[ <= ]]> #{endTime}
  97. </if>
  98. <if test="orderSn != null and orderSn != ''">
  99. AND vto.order_sn = #{orderSn}
  100. </if>
  101. <if test="orderSnList != null and orderSnList.size()!=0 ">
  102. AND vto.order_sn in
  103. <foreach collection="orderSnList" item="item" index="index" open="(" close=")" separator=",">
  104. #{item}
  105. </foreach>
  106. </if>
  107. <if test="keyword != null and keyword != ''">
  108. AND (
  109. vto.create_org LIKE CONCAT( '%', #{keyword}, '%' )
  110. -- OR vto.course_org LIKE CONCAT( '%', #{keyword}, '%' )
  111. OR vto.order_org LIKE CONCAT( '%', #{keyword}, '%' ))
  112. </if>
  113. </select>
  114. <!-- <select id="queryList_COUNT" resultType="Long">-->
  115. <!-- SELECT-->
  116. <!-- count(distinct vto.order_id )-->
  117. <!-- FROM-->
  118. <!-- ( SELECT DISTINCT order_sn-->
  119. <!-- <if test="businessFullName != null and businessFullName != '' and (userCard == null or userCard == '')">-->
  120. <!-- FROM `v_top_order_business` where business_full_name = #{businessFullName}-->
  121. <!-- </if>-->
  122. <!-- <if test="userCard != null and userCard != '' and (businessFullName == null and businessFullName == '')">-->
  123. <!-- FROM `v_top_order_card` where user_card = #{userCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}-->
  124. <!-- </if>-->
  125. <!-- <if test="userCard != null and userCard != '' and businessFullName != null and businessFullName != ''">-->
  126. <!-- FROM (-->
  127. <!-- SELECT-->
  128. <!-- DISTINCT order_sn-->
  129. <!-- FROM-->
  130. <!-- ( SELECT order_sn FROM v_top_order_business WHERE business_full_name = #{businessFullName} UNION ALL SELECT order_sn FROM v_top_order_card-->
  131. <!-- WHERE user_card = #{userCard,typeHandler=com.zhongzheng.common.type.EncryptHandler}) b-->
  132. <!-- ) m-->
  133. <!-- </if>-->
  134. <!-- <if test="(userCard == null or userCard == '') and (businessFullName == null or businessFullName == '')">-->
  135. <!-- FROM (-->
  136. <!-- SELECT-->
  137. <!-- DISTINCT order_sn-->
  138. <!-- FROM-->
  139. <!-- ( SELECT order_sn FROM v_top_order_business UNION ALL SELECT order_sn FROM v_top_order_card) b-->
  140. <!-- ) m-->
  141. <!-- </if>-->
  142. <!-- ) a-->
  143. <!-- LEFT JOIN v_top_order vto ON a.order_sn = vto.order_sn-->
  144. <!-- WHERE vto.`status` = 1-->
  145. <!-- <if test="checkStatus != null and checkStatus != ''">-->
  146. <!-- AND vto.check_status = #{checkStatus}-->
  147. <!-- </if>-->
  148. <!-- <if test="refundStatusList != null and refundStatusList.size()!=0 ">-->
  149. <!-- AND vto.refund_status in-->
  150. <!-- <foreach collection="refundStatusList" item="item" index="index" open="(" close=")" separator=",">-->
  151. <!-- #{item}-->
  152. <!-- </foreach>-->
  153. <!-- </if>-->
  154. <!-- <if test="creditStatus != null and creditStatus != '' and creditStatus == 0">-->
  155. <!-- AND vto.order_received <![CDATA[ < ]]> vto.pay_price-->
  156. <!-- </if>-->
  157. <!-- <if test="creditStatus != null and creditStatus != '' and creditStatus == 1">-->
  158. <!-- AND vto.pay_price = vto.order_received-->
  159. <!-- </if>-->
  160. <!-- <if test="invoiceStatus != null and invoiceStatus != ''">-->
  161. <!-- AND vto.invoice_status = #{invoiceStatus}-->
  162. <!-- </if>-->
  163. <!-- <if test="startTime != null and startTime != ''">-->
  164. <!-- AND vto.create_time <![CDATA[ >= ]]> #{startTime}-->
  165. <!-- </if>-->
  166. <!-- <if test="endTime != null and endTime != ''">-->
  167. <!-- AND vto.create_time <![CDATA[ <= ]]> #{endTime}-->
  168. <!-- </if>-->
  169. <!-- <if test="keyword != null and keyword != ''">-->
  170. <!-- AND (-->
  171. <!-- vto.create_org LIKE CONCAT( '%', #{keyword}, '%' )-->
  172. <!-- OR vto.order_sn LIKE CONCAT( '%', #{keyword}, '%' )-->
  173. <!-- OR vto.create_no LIKE CONCAT( '%', #{keyword}, '%' )-->
  174. <!-- OR vto.order_org LIKE CONCAT( '%', #{keyword}, '%' ))-->
  175. <!-- </if>-->
  176. <!-- </select>-->
  177. <select id="queryById" parameterType="java.lang.String" resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderVo">
  178. SELECT * FROM v_top_order WHERE order_sn = #{orderSn}
  179. </select>
  180. <select id="queryBusinessBySn" parameterType="java.lang.String" resultType="java.lang.String">
  181. SELECT business_name FROM v_top_order_business WHERE order_sn = #{orderSn}
  182. </select>
  183. <select id="queryByOrderSns" parameterType="java.lang.String" resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderVo">
  184. SELECT * FROM v_top_order WHERE 1 =1
  185. <if test="orderSnList != null and orderSnList.size()!=0 ">
  186. AND order_sn in
  187. <foreach collection="orderSnList" item="item" index="index" open="(" close=")" separator=",">
  188. #{item}
  189. </foreach>
  190. </if>
  191. </select>
  192. <select id="queryReceiveList" parameterType="com.zhongzheng.modules.top.goods.bo.TopOldOrderQueryBo" resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderVo">
  193. SELECT
  194. too.*,
  195. st.tenant_name,
  196. rn.id as note_id,
  197. rn.note_type,
  198. rn.day_time,
  199. rn.week_time,
  200. rn.month_time,
  201. rn.last_time
  202. FROM
  203. top_old_order too
  204. LEFT JOIN sys_tenant st ON too.tenant_id = st.tenant_id
  205. LEFT JOIN top_order_rec_note rn ON too.tenant_id = rn.tenant_id and too.order_sn = rn.order_sn
  206. where 1=1
  207. <if test="startTime != null and startTime != ''">
  208. AND too.create_time <![CDATA[ >= ]]> #{startTime}
  209. </if>
  210. <if test="endTime != null and endTime != ''">
  211. AND too.create_time <![CDATA[ <= ]]> #{endTime}
  212. </if>
  213. <if test="keyNo != null and keyNo != ''">
  214. AND (too.tenant_id like concat('%', #{keyNo}, '%') or too.create_no like concat('%', #{keyNo}, '%'))
  215. </if>
  216. <if test="creditStatus != null and creditStatus != ''">
  217. AND too.credit_status = #{creditStatus}
  218. </if>
  219. ORDER BY too.order_id DESC
  220. </select>
  221. <select id="queryDivSellerList" parameterType="com.zhongzheng.modules.top.goods.bo.TopOldOrderQueryBo" resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderVo">
  222. SELECT
  223. too.*,
  224. st.tenant_name,
  225. r.role_name,
  226. cl.check_status as divide_check_status
  227. FROM
  228. v_top_order too
  229. LEFT JOIN sys_tenant st ON too.tenant_id = st.tenant_id
  230. LEFT JOIN top_old_order_check_log cl ON too.order_sn = cl.order_sn
  231. AND cl.check_sign = 1
  232. AND ( too.divide_model + 1 ) = cl.check_from
  233. LEFT JOIN top_sys_role r ON cl.role_id = r.role_id
  234. where 1=1 AND too.divide_model = 2
  235. <if test="startTime != null and startTime != ''">
  236. AND too.create_time <![CDATA[ >= ]]> #{startTime}
  237. </if>
  238. <if test="endTime != null and endTime != ''">
  239. AND too.create_time <![CDATA[ <= ]]> #{endTime}
  240. </if>
  241. <if test="keyNo != null and keyNo != ''">
  242. AND (too.tenant_id like concat('%', #{keyNo}, '%') or too.create_no like concat('%', #{keyNo}, '%'))
  243. </if>
  244. <if test="divideStatusList != null and divideStatusList.size()!=0 ">
  245. AND too.divide_status in
  246. <foreach collection="divideStatusList" item="item" index="index" open="(" close=")" separator=",">
  247. #{item}
  248. </foreach>
  249. </if>
  250. <if test="divideStatus != null and divideStatus != ''">
  251. AND too.divide_status = #{divideStatus}
  252. </if>
  253. <if test="roleId != null and roleId != ''">
  254. AND cl.role_id = #{roleId}
  255. </if>
  256. ORDER BY too.order_id DESC
  257. </select>
  258. <select id="queryTenantList" parameterType="com.zhongzheng.modules.top.goods.bo.TopOldOrderQueryBo" resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderVo">
  259. SELECT
  260. too.*,
  261. st.tenant_name,
  262. r.role_name,
  263. cl.check_status as divide_check_status
  264. FROM
  265. top_old_order too
  266. LEFT JOIN sys_tenant st ON too.tenant_id = st.tenant_id
  267. LEFT JOIN top_old_order_check_log cl ON too.order_sn = cl.order_sn
  268. AND cl.check_sign = 1
  269. AND ( too.divide_model + 1 ) = cl.check_from
  270. LEFT JOIN top_sys_role r ON cl.role_id = r.role_id
  271. where 1=1 AND too.divide_model = 1
  272. <if test="startTime != null and startTime != ''">
  273. AND too.create_time <![CDATA[ >= ]]> #{startTime}
  274. </if>
  275. <if test="endTime != null and endTime != ''">
  276. AND too.create_time <![CDATA[ <= ]]> #{endTime}
  277. </if>
  278. <if test="keyNo != null and keyNo != ''">
  279. AND (too.tenant_id like concat('%', #{keyNo}, '%') or too.create_no like concat('%', #{keyNo}, '%'))
  280. </if>
  281. <if test="divideStatusList != null and divideStatusList.size()!=0 ">
  282. AND too.divide_status in
  283. <foreach collection="divideStatusList" item="item" index="index" open="(" close=")" separator=",">
  284. #{item}
  285. </foreach>
  286. </if>
  287. <if test="divideStatus != null and divideStatus != ''">
  288. AND too.divide_status = #{divideStatus}
  289. </if>
  290. <if test="tenantId != null and tenantId != ''">
  291. AND too.tenant_id = #{tenantId}
  292. </if>
  293. <if test="roleId != null and roleId != ''">
  294. AND cl.role_id = #{roleId}
  295. </if>
  296. ORDER BY too.order_id DESC
  297. </select>
  298. <select id="tenantMoneyTotal" parameterType="com.zhongzheng.modules.top.goods.bo.TopOldOrderQueryBo" resultType="BigDecimal">
  299. SELECT
  300. IFNULL( SUM( too.divide_company_money ), 0 )
  301. FROM
  302. v_top_order too
  303. WHERE
  304. too.divide_model = 1
  305. AND too.divide_status = 5
  306. </select>
  307. <select id="tenantSellerTotal" parameterType="com.zhongzheng.modules.top.goods.bo.TopOldOrderQueryBo" resultType="BigDecimal">
  308. SELECT
  309. IFNULL( SUM( too.divide_seller_money ), 0 )
  310. FROM
  311. v_top_order too
  312. WHERE
  313. too.divide_model = 2
  314. AND too.divide_status = 5
  315. </select>
  316. <select id="queryListAll" resultType="com.zhongzheng.modules.top.goods.vo.TopOldOrderVo">
  317. SELECT * FROM v_top_order
  318. </select>
  319. <select id="getOrderBySn" parameterType="java.lang.String" resultType="com.zhongzheng.modules.top.goods.domain.TopOldOrder">
  320. SELECT * FROM v_top_order WHERE order_sn = #{orderSn}
  321. </select>
  322. <select id="logList" parameterType="com.zhongzheng.modules.top.financial.bo.TopOrderLogQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopOrderLogVo">
  323. SELECT * FROM top_order_log WHERE order_sn = #{orderSn}
  324. </select>
  325. </mapper>