TopDivideLogMapper.xml 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  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.TopDivideLogMapper">
  6. <resultMap type="com.zhongzheng.modules.top.financial.domain.TopDivideLog" id="TopDivideLogResult">
  7. <result property="id" column="id"/>
  8. <result property="year" column="year"/>
  9. <result property="month" column="month"/>
  10. <result property="payMoney" column="pay_money"/>
  11. <result property="sellerId" column="seller_id"/>
  12. <result property="status" column="status"/>
  13. <result property="createTime" column="create_time"/>
  14. <result property="updateTime" column="update_time"/>
  15. <result property="divideType" column="divide_type"/>
  16. <result property="payStatus" column="pay_status"/>
  17. <result property="remark" column="remark"/>
  18. <result property="deductMoney" column="deduct_money"/>
  19. <result property="createUsername" column="create_username"/>
  20. <result property="createSysUserId" column="create_sys_user_id"/>
  21. <result property="createNo" column="create_no"/>
  22. </resultMap>
  23. <select id="getCompanyList" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideLogQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideLogVo">
  24. SELECT
  25. dl.*,
  26. st.tenant_name,
  27. st.bill_type,
  28. st.bill_day,
  29. (SELECT
  30. cl.role_id
  31. FROM
  32. top_divide_order tdo
  33. LEFT JOIN top_old_order_check_log cl ON tdo.order_sn = cl.order_sn
  34. WHERE
  35. cl.check_from = 2
  36. AND cl.check_sign = 1
  37. AND tdo.order_type = 1
  38. AND tdo.divide_log_id = dl.id
  39. LIMIT 1) as role_id,
  40. (SELECT
  41. r.role_name
  42. FROM
  43. top_divide_order tdo
  44. LEFT JOIN top_old_order_check_log cl ON tdo.order_sn = cl.order_sn
  45. LEFT JOIN top_sys_role r ON r.role_id = cl.role_id
  46. WHERE
  47. cl.check_from = 2
  48. AND cl.check_sign = 1
  49. AND tdo.order_type = 1
  50. AND tdo.divide_log_id = dl.id
  51. LIMIT 1) as role_name,
  52. (SELECT
  53. cl.check_reason
  54. FROM
  55. top_divide_order tdo
  56. LEFT JOIN top_old_order_check_log cl ON tdo.order_sn = cl.order_sn
  57. WHERE
  58. cl.check_from = 2
  59. AND tdo.order_type = 1
  60. AND tdo.divide_log_id = dl.id
  61. AND cl.check_status = -1
  62. ORDER BY cl.check_sort
  63. LIMIT 1) as check_reason
  64. FROM
  65. top_divide_log dl
  66. LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
  67. WHERE
  68. dl.divide_type = 1
  69. <if test="tenantId != null and tenantId != ''">
  70. AND dl.tenant_id = #{tenantId}
  71. </if>
  72. <if test="billType != null and billType != ''">
  73. AND st.bill_type = #{billType}
  74. </if>
  75. <if test="payStatus != null and payStatus.size()!=0">
  76. AND dl.pay_status in
  77. <foreach collection="payStatus" item="item" index="index" open="(" close=")" separator=",">
  78. #{item}
  79. </foreach>
  80. </if>
  81. <if test="monthTime != null and monthTime.size()!=0">
  82. AND dl.month_time in
  83. <foreach collection="monthTime" item="item" index="index" open="(" close=")" separator=",">
  84. #{item}
  85. </foreach>
  86. </if>
  87. <if test="tenantIds != null and tenantIds.size()!=0">
  88. AND dl.tenant_id in
  89. <foreach collection="tenantIds" item="item" index="index" open="(" close=")" separator=",">
  90. #{item}
  91. </foreach>
  92. </if>
  93. <if test="overPayDay != null ">
  94. AND dl.predict_pay_time <![CDATA[ <= ]]> #{overPayDayTime}
  95. </if>
  96. <if test="notPayStatus != null ">
  97. AND dl.pay_status != #{notPayStatus}
  98. </if>
  99. <if test="reCheckStatus == 1">
  100. AND (SELECT
  101. count(*)
  102. FROM
  103. top_divide_log bdl
  104. LEFT JOIN top_divide_order btdo ON bdl.id = btdo.divide_log_id
  105. LEFT JOIN top_old_order_check_log bcl ON btdo.order_sn = bcl.order_sn
  106. WHERE
  107. bcl.check_from = 2
  108. AND bcl.check_status = 0
  109. AND bcl.check_sign = 1
  110. <if test="roleIds != null and roleIds.size()!=0">
  111. AND bcl.role_id in
  112. <foreach collection="roleIds" item="item" index="index" open="(" close=")" separator=",">
  113. #{item}
  114. </foreach>
  115. </if>
  116. AND bdl.id = dl.id)>0
  117. </if>
  118. <if test="reCheckStatus == 2">
  119. AND (SELECT
  120. count(*)
  121. FROM
  122. top_divide_log bdl
  123. LEFT JOIN top_divide_order btdo ON bdl.id = btdo.divide_log_id
  124. LEFT JOIN top_old_order_check_log bcl ON btdo.order_sn = bcl.order_sn
  125. WHERE
  126. bcl.check_from = 2
  127. AND bcl.check_status = 0
  128. AND bcl.check_sign = 1
  129. <if test="roleIds != null and roleIds.size()!=0">
  130. AND bcl.role_id not in
  131. <foreach collection="roleIds" item="item" index="index" open="(" close=")" separator=",">
  132. #{item}
  133. </foreach>
  134. </if>
  135. AND bdl.id = dl.id)>0
  136. </if>
  137. </select>
  138. <select id="getCompanyWaitCount" parameterType="com.zhongzheng.modules.top.goods.bo.TopOldOrderQueryBo" resultType="Long">
  139. SELECT
  140. COUNT(dl.*)
  141. FROM
  142. top_divide_log dl
  143. LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
  144. WHERE
  145. dl.divide_type = 1
  146. <if test="tenantId != null and tenantId != ''">
  147. AND dl.tenant_id = #{tenantId}
  148. </if>
  149. <if test="billType != null and billType != ''">
  150. AND st.bill_type = #{billType}
  151. </if>
  152. <if test="payStatus != null and payStatus.size()!=0">
  153. AND dl.pay_status in
  154. <foreach collection="payStatus" item="item" index="index" open="(" close=")" separator=",">
  155. #{item}
  156. </foreach>
  157. </if>
  158. <if test="monthTime != null and monthTime.size()!=0">
  159. AND dl.month_time in
  160. <foreach collection="monthTime" item="item" index="index" open="(" close=")" separator=",">
  161. #{item}
  162. </foreach>
  163. </if>
  164. <if test="tenantIds != null and tenantIds.size()!=0">
  165. AND dl.tenant_id in
  166. <foreach collection="tenantIds" item="item" index="index" open="(" close=")" separator=",">
  167. #{item}
  168. </foreach>
  169. </if>
  170. <if test="overPayDay != null ">
  171. AND dl.predict_pay_time <![CDATA[ <= ]]> #{overPayDayTime}
  172. </if>
  173. <if test="notPayStatus != null ">
  174. AND dl.pay_status != #{notPayStatus}
  175. </if>
  176. AND (SELECT
  177. count(*)
  178. FROM
  179. top_divide_log bdl
  180. LEFT JOIN top_divide_order btdo ON bdl.id = btdo.divide_log_id
  181. LEFT JOIN top_old_order_check_log bcl ON btdo.order_sn = bcl.order_sn
  182. WHERE
  183. bcl.check_from = 2
  184. AND bcl.check_status = 0
  185. AND bcl.check_sign = 1
  186. <if test="roleIds != null and roleIds.size()!=0">
  187. AND bcl.role_id in
  188. <foreach collection="roleIds" item="item" index="index" open="(" close=")" separator=",">
  189. #{item}
  190. </foreach>
  191. </if>
  192. AND bdl.id = dl.id)>0
  193. </select>
  194. <select id="getCheckList" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideLogQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideLogVo">
  195. SELECT
  196. dl.*,
  197. cl.check_status,
  198. cl.check_sign,
  199. r.role_name
  200. FROM
  201. top_divide_log dl LEFT JOIN
  202. top_old_order_check_log cl ON dl.id = cl.month_divide_id AND cl.check_sign = 1
  203. LEFT JOIN top_sys_role r ON cl.role_id = r.role_id
  204. WHERE
  205. 1 = 1
  206. <if test="tenantId != null and tenantId != ''">
  207. AND dl.tenant_id = #{tenantId}
  208. </if>
  209. <if test="divideType != null">
  210. AND dl.divide_type = #{divideType}
  211. </if>
  212. <if test="payStatus != null">
  213. AND dl.pay_status = #{payStatus}
  214. </if>
  215. <if test="roleId != null and roleId != ''">
  216. AND cl.role_id = #{roleId}
  217. </if>
  218. <if test="checkFrom != null and checkFrom != ''">
  219. AND cl.check_from = #{checkFrom}
  220. </if>
  221. <if test="checkStatus != null and checkStatus.size()!=0">
  222. AND cl.check_status in
  223. <foreach collection="checkStatus" item="item" index="index" open="(" close=")" separator=",">
  224. #{item}
  225. </foreach>
  226. </if>
  227. <if test="monthTime != null and monthTime.size()!=0">
  228. AND dl.month_time in
  229. <foreach collection="monthTime" item="item" index="index" open="(" close=")" separator=",">
  230. #{item}
  231. </foreach>
  232. </if>
  233. order by dl.id
  234. </select>
  235. <select id="getSumMoney" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideLogQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideLogVo">
  236. SELECT
  237. sum(
  238. IF
  239. ( pay_status = 1, dl.pay_money, 0 )) AS pay_money_total,
  240. sum(
  241. IF
  242. ( pay_status = 1, dl.deduct_money, 0 )) AS deduct_money_total,
  243. sum(
  244. IF
  245. ( pay_status !=1, dl.pay_money, 0 )) AS un_pay_money_total,
  246. sum(
  247. IF
  248. ( pay_status !=1, dl.deduct_money, 0 )) AS un_deduct_money_total
  249. FROM
  250. top_divide_log dl
  251. LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
  252. WHERE
  253. 1=1
  254. <if test="divideType != null">
  255. AND dl.divide_type = #{divideType}
  256. </if>
  257. <if test="tenantId != null and tenantId != ''">
  258. AND dl.tenant_id = #{tenantId}
  259. </if>
  260. <if test="payStatus != null">
  261. AND dl.pay_status = #{payStatus}
  262. </if>
  263. <if test="billType != null and billType != ''">
  264. AND st.bill_type = #{billType}
  265. </if>
  266. <if test="monthTime != null and monthTime.size()!=0">
  267. AND dl.month_time in
  268. <foreach collection="monthTime" item="item" index="index" open="(" close=")" separator=",">
  269. #{item}
  270. </foreach>
  271. </if>
  272. </select>
  273. <select id="getSellerList" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideLogQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideLogVo">
  274. SELECT
  275. dl.*,
  276. st.tenant_name,
  277. st.bill_day,
  278. (SELECT
  279. cl.role_id
  280. FROM
  281. top_divide_order tdo
  282. LEFT JOIN top_old_order_check_log cl ON tdo.order_sn = cl.order_sn
  283. WHERE
  284. cl.check_from = 3
  285. AND cl.check_sign = 1
  286. AND tdo.order_type = 1
  287. AND tdo.divide_log_id = dl.id
  288. LIMIT 1) as role_id,
  289. (SELECT
  290. r.role_name
  291. FROM
  292. top_divide_order tdo
  293. LEFT JOIN top_old_order_check_log cl ON tdo.order_sn = cl.order_sn
  294. LEFT JOIN top_sys_role r ON r.role_id = cl.role_id
  295. WHERE
  296. cl.check_from = 3
  297. AND cl.check_sign = 1
  298. AND tdo.order_type = 1
  299. AND tdo.divide_log_id = dl.id
  300. LIMIT 1) as role_name,
  301. (SELECT
  302. cl.check_reason
  303. FROM
  304. top_divide_order tdo
  305. LEFT JOIN top_old_order_check_log cl ON tdo.order_sn = cl.order_sn
  306. WHERE
  307. cl.check_from = 3
  308. AND tdo.order_type = 1
  309. AND tdo.divide_log_id = dl.id
  310. AND cl.check_status = -1
  311. ORDER BY cl.check_sort
  312. LIMIT 1) as check_reason
  313. FROM
  314. top_divide_log dl
  315. LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
  316. WHERE
  317. dl.divide_type = 2
  318. <if test="tenantId != null and tenantId != ''">
  319. AND dl.tenant_id = #{tenantId}
  320. </if>
  321. <if test="payStatus != null and payStatus.size()!=0">
  322. AND dl.pay_status in
  323. <foreach collection="payStatus" item="item" index="index" open="(" close=")" separator=",">
  324. #{item}
  325. </foreach>
  326. </if>
  327. <if test="createNo != null ">
  328. AND (dl.create_no = #{createNo} or dl.create_username like concat('%', #{createNo}, '%'))
  329. </if>
  330. <if test="monthTime != null and monthTime.size()!=0">
  331. AND dl.month_time in
  332. <foreach collection="monthTime" item="item" index="index" open="(" close=")" separator=",">
  333. #{item}
  334. </foreach>
  335. </if>
  336. <if test="tenantIds != null and tenantIds.size()!=0">
  337. AND dl.tenant_id in
  338. <foreach collection="tenantIds" item="item" index="index" open="(" close=")" separator=",">
  339. #{item}
  340. </foreach>
  341. </if>
  342. <if test="notPayStatus != null ">
  343. AND dl.pay_status != #{notPayStatus}
  344. </if>
  345. <if test="reCheckStatus == 1">
  346. AND (SELECT
  347. count(*)
  348. FROM
  349. top_divide_log bdl
  350. LEFT JOIN top_divide_order btdo ON bdl.id = btdo.divide_log_id
  351. LEFT JOIN top_old_order_check_log bcl ON btdo.order_sn = bcl.order_sn
  352. WHERE
  353. bcl.check_from = 3
  354. AND bcl.check_status = 0
  355. AND bcl.check_sign = 1
  356. <if test="roleIds != null and roleIds.size()!=0">
  357. AND bcl.role_id in
  358. <foreach collection="roleIds" item="item" index="index" open="(" close=")" separator=",">
  359. #{item}
  360. </foreach>
  361. </if>
  362. AND bdl.id = dl.id)>0
  363. </if>
  364. <if test="reCheckStatus == 2">
  365. AND (SELECT
  366. count(*)
  367. FROM
  368. top_divide_log bdl
  369. LEFT JOIN top_divide_order btdo ON bdl.id = btdo.divide_log_id
  370. LEFT JOIN top_old_order_check_log bcl ON btdo.order_sn = bcl.order_sn
  371. WHERE
  372. bcl.check_from = 3
  373. AND bcl.check_status = 0
  374. AND bcl.check_sign = 1
  375. <if test="roleIds != null and roleIds.size()!=0">
  376. AND bcl.role_id not in
  377. <foreach collection="roleIds" item="item" index="index" open="(" close=")" separator=",">
  378. #{item}
  379. </foreach>
  380. </if>
  381. AND bdl.id = dl.id)>0
  382. </if>
  383. </select>
  384. <select id="getSellerListWaitCount" parameterType="com.zhongzheng.modules.top.goods.bo.TopOldOrderQueryBo" resultType="Long">
  385. SELECT
  386. COUNT(dl.*)
  387. FROM
  388. top_divide_log dl
  389. LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
  390. WHERE
  391. dl.divide_type = 2
  392. <if test="tenantId != null and tenantId != ''">
  393. AND dl.tenant_id = #{tenantId}
  394. </if>
  395. <if test="payStatus != null and payStatus.size()!=0">
  396. AND dl.pay_status in
  397. <foreach collection="payStatus" item="item" index="index" open="(" close=")" separator=",">
  398. #{item}
  399. </foreach>
  400. </if>
  401. <if test="createNo != null ">
  402. AND (dl.create_no = #{createNo} or dl.create_username like concat('%', #{createNo}, '%'))
  403. </if>
  404. <if test="monthTime != null and monthTime.size()!=0">
  405. AND dl.month_time in
  406. <foreach collection="monthTime" item="item" index="index" open="(" close=")" separator=",">
  407. #{item}
  408. </foreach>
  409. </if>
  410. <if test="tenantIds != null and tenantIds.size()!=0">
  411. AND dl.tenant_id in
  412. <foreach collection="tenantIds" item="item" index="index" open="(" close=")" separator=",">
  413. #{item}
  414. </foreach>
  415. </if>
  416. <if test="notPayStatus != null ">
  417. AND dl.pay_status != #{notPayStatus}
  418. </if>
  419. AND (SELECT
  420. count(*)
  421. FROM
  422. top_divide_log bdl
  423. LEFT JOIN top_divide_order btdo ON bdl.id = btdo.divide_log_id
  424. LEFT JOIN top_old_order_check_log bcl ON btdo.order_sn = bcl.order_sn
  425. WHERE
  426. bcl.check_from = 3
  427. AND bcl.check_status = 0
  428. AND bcl.check_sign = 1
  429. <if test="roleIds != null and roleIds.size()!=0">
  430. AND bcl.role_id in
  431. <foreach collection="roleIds" item="item" index="index" open="(" close=")" separator=",">
  432. #{item}
  433. </foreach>
  434. </if>
  435. AND bdl.id = dl.id)>0
  436. </select>
  437. <select id="getCommissionList" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideLogVo">
  438. SELECT
  439. dl.*,
  440. st.tenant_name,
  441. st.bill_day
  442. FROM
  443. top_divide_log dl
  444. LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
  445. WHERE
  446. dl.divide_type = 3
  447. <if test="tenantId != null and tenantId != ''">
  448. AND dl.tenant_id = #{tenantId}
  449. </if>
  450. <if test="payStatus != null">
  451. AND dl.pay_status = #{payStatus}
  452. </if>
  453. <if test="createNo != null ">
  454. AND dl.create_no = #{createNo}
  455. </if>
  456. <if test="monthTime != null and monthTime != ''">
  457. AND dl.month_time in
  458. <foreach collection="monthTime" item="item" index="index" open="(" close=")" separator=",">
  459. #{item}
  460. </foreach>
  461. </if>
  462. </select>
  463. </mapper>