TopDivideOrderMapper.xml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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.financial.mapper.TopDivideOrderMapper">
  6. <resultMap type="com.zhongzheng.modules.top.financial.domain.TopDivideOrder" id="TopDivideOrderResult">
  7. <result property="id" column="id"/>
  8. <result property="divideLogId" column="divide_log_id"/>
  9. <result property="orderSn" column="order_sn"/>
  10. <result property="orderType" column="order_type"/>
  11. <result property="status" column="status"/>
  12. <result property="createTime" column="create_time"/>
  13. <result property="updateTime" column="update_time"/>
  14. </resultMap>
  15. <select id="getFinishList" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideOrderVo">
  16. SELECT
  17. tdo.*,
  18. st.tenant_name ,
  19. cl.check_status,
  20. dl.pay_status,
  21. dl.divide_type,
  22. oo.buy_time as order_time,
  23. oo.remark,
  24. oo.divide_company_money,
  25. oo.divide_seller_money,
  26. oo.brokerage,
  27. oo.pretax_brokerage,
  28. oo.order_price,
  29. oo.order_from,
  30. oo.create_time as order_create_time,
  31. r.role_name,
  32. r.role_id
  33. FROM
  34. top_divide_order tdo
  35. LEFT JOIN top_divide_log dl ON tdo.divide_log_id = dl.id
  36. LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
  37. LEFT JOIN v_top_order oo ON tdo.order_sn = oo.order_sn
  38. LEFT JOIN
  39. top_old_order_check_log cl ON (dl.divide_type+1) = cl.check_from AND cl.check_sign = 1 AND tdo.order_sn = cl.order_sn
  40. LEFT JOIN top_sys_role r ON cl.role_id = r.role_id
  41. WHERE
  42. tdo.order_type = 1
  43. AND tdo.divide_log_id = #{divideLogId}
  44. <if test="startPrice != null and startPrice != ''">
  45. AND (oo.order_price - oo.pretax_brokerage) <![CDATA[ >= ]]> #{startPrice}
  46. </if>
  47. <if test="endPrice != null and endPrice != ''">
  48. AND (oo.order_price - oo.pretax_brokerage) <![CDATA[ <= ]]> #{endPrice}
  49. </if>
  50. <if test="orderSn != null and orderSn != ''">
  51. AND oo.order_sn = #{orderSn}
  52. </if>
  53. <if test="accomplishStartTime != null ">
  54. AND oo.accomplish_time <![CDATA[ >= ]]> #{accomplishStartTime}
  55. </if>
  56. <if test="accomplishEndTime != null ">
  57. AND oo.accomplish_time <![CDATA[ <= ]]> #{accomplishEndTime}
  58. </if>
  59. <if test="checkStatus != null and checkStatus == 0">
  60. AND ocl.check_status <![CDATA[ <= ]]> 0
  61. </if>
  62. <if test="checkStatus != null and checkStatus == 1">
  63. AND ocl.check_status <![CDATA[ >= ]]> 1
  64. </if>
  65. </select>
  66. <select id="getRefundList" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideOrderVo">
  67. SELECT
  68. tdo.*,
  69. st.tenant_name,
  70. dl.pay_status,
  71. dl.divide_type,
  72. oo.remark,
  73. oo.order_price,
  74. oo.brokerage,
  75. oo.pretax_brokerage,
  76. tor.divide_money,
  77. tor.refund_time as order_time,
  78. oo.create_time as order_create_time
  79. FROM
  80. top_divide_order tdo
  81. LEFT JOIN top_divide_log dl ON tdo.divide_log_id = dl.id
  82. LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
  83. LEFT JOIN v_top_order oo ON tdo.order_sn = oo.order_sn
  84. LEFT JOIN top_old_order_refund tor ON tdo.order_sn = tor.order_sn
  85. WHERE
  86. tdo.order_type = 2
  87. AND tdo.divide_log_id = #{divideLogId}
  88. <if test="startPrice != null and startPrice != ''">
  89. AND (oo.order_price - oo.pretax_brokerage) <![CDATA[ >= ]]> #{startPrice}
  90. </if>
  91. <if test="endPrice != null and endPrice != ''">
  92. AND (oo.order_price - oo.pretax_brokerage) <![CDATA[ <= ]]> #{endPrice}
  93. </if>
  94. <if test="orderSn != null and orderSn != ''">
  95. AND oo.order_sn = #{orderSn}
  96. </if>
  97. <if test="accomplishStartTime != null ">
  98. AND tor.refund_time <![CDATA[ >= ]]> #{accomplishStartTime}
  99. </if>
  100. <if test="accomplishEndTime != null ">
  101. AND tor.refund_time <![CDATA[ <= ]]> #{accomplishEndTime}
  102. </if>
  103. <if test="checkStatus != null and checkStatus == 0">
  104. AND 1=0
  105. </if>
  106. </select>
  107. <select id="getBusinessList" parameterType="String" resultType="String">
  108. SELECT
  109. business_name
  110. FROM
  111. v_top_order_business
  112. WHERE
  113. order_sn = #{orderSn}
  114. GROUP BY
  115. business_name
  116. </select>
  117. <select id="getMonthFinishAllTenant" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="String">
  118. SELECT
  119. v.tenant_id
  120. FROM
  121. v_top_order v
  122. WHERE
  123. 1 = 1
  124. AND v.finish_status = 1
  125. <if test="divideModel != null and divideModel != ''">
  126. AND v.divide_model = #{divideModel}
  127. </if>
  128. <if test="accomplishStartTime != null and accomplishStartTime != ''">
  129. AND v.accomplish_time BETWEEN #{accomplishStartTime} and #{accomplishEndTime}
  130. </if>
  131. <if test="tenantId != null and tenantId != ''">
  132. AND v.tenant_id = #{tenantId}
  133. </if>
  134. GROUP BY v.tenant_id
  135. </select>
  136. <select id="getMonthFinishList" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideOrderVo">
  137. SELECT
  138. v.order_sn,
  139. v.divide_company_money,
  140. v.divide_seller_money,
  141. v.tenant_id,
  142. v.create_no,
  143. v.create_username,
  144. v.brokerage
  145. FROM
  146. v_top_order v
  147. WHERE
  148. 1 = 1
  149. AND v.finish_status = 1
  150. <if test="divideModel != null and divideModel != ''">
  151. AND v.divide_model = #{divideModel}
  152. </if>
  153. <if test="accomplishStartTime != null and accomplishStartTime != ''">
  154. AND v.accomplish_time BETWEEN #{accomplishStartTime} and #{accomplishEndTime}
  155. </if>
  156. <if test="tenantId != null and tenantId != ''">
  157. AND v.tenant_id = #{tenantId}
  158. </if>
  159. <if test="createNo != null and createNo != ''">
  160. AND v.create_no = #{createNo}
  161. </if>
  162. </select>
  163. <select id="getMonthCreditList" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideOrderVo">
  164. SELECT
  165. v.order_sn,
  166. v.divide_company_money,
  167. v.divide_seller_money,
  168. v.tenant_id,
  169. v.create_no,
  170. v.create_username,
  171. v.brokerage
  172. FROM
  173. top_old_order v
  174. WHERE
  175. 1 = 1
  176. <if test="accomplishStartTime != null and accomplishStartTime != ''">
  177. AND v.credit_time BETWEEN #{accomplishStartTime} and #{accomplishEndTime}
  178. </if>
  179. <if test="tenantId != null and tenantId != ''">
  180. AND v.tenant_id = #{tenantId}
  181. </if>
  182. <if test="createNo != null and createNo != ''">
  183. AND v.create_no = #{createNo}
  184. </if>
  185. </select>
  186. <select id="getMonthRefundList" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideOrderVo">
  187. SELECT
  188. tor.order_sn,
  189. tor.divide_money,
  190. tor.tenant_id,
  191. tor.refund_sn,
  192. v.create_no,
  193. v.create_username
  194. FROM
  195. top_old_order_refund tor
  196. LEFT JOIN v_top_order v on tor.order_sn = v.order_sn
  197. WHERE
  198. 1 = 1
  199. AND tor.period_status = 3
  200. <if test="divideModel != null and divideModel != ''">
  201. AND tor.divide_model = #{divideModel}
  202. </if>
  203. <if test="refundTimeStartTime != null and refundTimeStartTime != ''">
  204. AND tor.refund_time BETWEEN #{refundTimeStartTime} and #{refundTimeEndTime}
  205. </if>
  206. <if test="tenantId != null and tenantId != ''">
  207. AND tor.tenant_id = #{tenantId}
  208. </if>
  209. <if test="createNo != null and createNo != ''">
  210. AND v.create_no = #{createNo}
  211. </if>
  212. </select>
  213. <select id="getMonthBadSum" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="BigDecimal">
  214. SELECT
  215. IFNULL(SUM(too.order_uncollected),0)
  216. FROM
  217. top_old_order too
  218. WHERE
  219. too.status=1
  220. AND too.check_status = 1
  221. <if test="buyStartTime != null and buyStartTime != ''">
  222. AND too.check_time <![CDATA[ >= ]]> #{buyStartTime}
  223. </if>
  224. <if test="buyEndTime != null and buyEndTime != ''">
  225. AND too.check_time <![CDATA[ <= ]]> #{buyEndTime}
  226. </if>
  227. <if test="tenantId != null and tenantId != ''">
  228. AND too.tenant_id = #{tenantId}
  229. </if>
  230. </select>
  231. <select id="getMonthFinishAllSeller" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopCreateUserVo">
  232. SELECT
  233. v.create_no,
  234. v.create_username,
  235. v.tenant_id
  236. FROM
  237. v_top_order v
  238. WHERE
  239. 1 = 1
  240. AND v.finish_status = 1
  241. <if test="divideModel != null and divideModel != ''">
  242. AND v.divide_model = #{divideModel}
  243. </if>
  244. <if test="accomplishStartTime != null and accomplishStartTime != ''">
  245. AND v.accomplish_time BETWEEN #{accomplishStartTime} and #{accomplishEndTime}
  246. </if>
  247. <if test="tenantId != null and tenantId != ''">
  248. AND v.tenant_id = #{tenantId}
  249. </if>
  250. <if test="createNo != null and createNo != ''">
  251. AND v.create_no = #{createNo}
  252. </if>
  253. GROUP BY v.create_no,v.create_username,v.tenant_id
  254. </select>
  255. <select id="getByOrderSn" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideOrderVo">
  256. SELECT
  257. tdo.*
  258. FROM
  259. top_divide_order tdo
  260. LEFT JOIN top_divide_log dl on tdo.divide_log_id = dl.id
  261. WHERE
  262. 1 = 1
  263. AND tdo.order_type = 1
  264. <if test="divideType != null and divideType != ''">
  265. AND dl.divide_type = #{divideType}
  266. </if>
  267. <if test="orderSn != null and orderSn != ''">
  268. AND tdo.order_sn = #{orderSn}
  269. </if>
  270. LIMIT 1
  271. </select>
  272. <update id="updateCheckStatusById" parameterType="com.zhongzheng.modules.top.order.domain.TopOrderBankPay" >
  273. UPDATE top_divide_order tdo
  274. LEFT JOIN top_divide_log dl ON tdo.divide_log_id = dl.id
  275. LEFT JOIN top_old_order_check_log cl ON ( dl.divide_type + 1 ) = cl.check_from
  276. AND cl.check_sign = 1
  277. AND tdo.order_sn = cl.order_sn
  278. <set>
  279. cl.check_status = 3
  280. </set>
  281. where
  282. tdo.order_type = 1
  283. AND tdo.divide_log_id = #{divideLogId}
  284. AND cl.check_status = 2
  285. </update>
  286. </mapper>