TopDivideLogMapper.xml 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  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. IFNULL(COUNT(*) ,0)
  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. dl.total_pay_money) AS pay_money_total,
  239. sum(
  240. IF
  241. ( pay_status = 1, dl.deduct_money, 0 )) AS deduct_money_total,
  242. sum(
  243. dl.pay_money) AS un_pay_money_total,
  244. sum(
  245. IF
  246. ( pay_status !=1, dl.deduct_money, 0 )) AS un_deduct_money_total
  247. FROM
  248. top_divide_log dl
  249. LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
  250. WHERE
  251. 1=1
  252. <if test="divideType != null">
  253. AND dl.divide_type = #{divideType}
  254. </if>
  255. <if test="tenantId != null and tenantId != ''">
  256. AND dl.tenant_id = #{tenantId}
  257. </if>
  258. <if test="reCheckStatus == 1">
  259. AND (SELECT
  260. count(*)
  261. FROM
  262. top_divide_log bdl
  263. LEFT JOIN top_divide_order btdo ON bdl.id = btdo.divide_log_id
  264. LEFT JOIN top_old_order_check_log bcl ON btdo.order_sn = bcl.order_sn
  265. WHERE
  266. bcl.check_from = 2
  267. AND bcl.check_status = 0
  268. AND bcl.check_sign = 1
  269. <if test="roleIds != null and roleIds.size()!=0">
  270. AND bcl.role_id in
  271. <foreach collection="roleIds" item="item" index="index" open="(" close=")" separator=",">
  272. #{item}
  273. </foreach>
  274. </if>
  275. AND bdl.id = dl.id)>0
  276. </if>
  277. <if test="reCheckStatus == 2">
  278. AND (SELECT
  279. count(*)
  280. FROM
  281. top_divide_log bdl
  282. LEFT JOIN top_divide_order btdo ON bdl.id = btdo.divide_log_id
  283. LEFT JOIN top_old_order_check_log bcl ON btdo.order_sn = bcl.order_sn
  284. WHERE
  285. bcl.check_from = 2
  286. AND bcl.check_status = 0
  287. AND bcl.check_sign = 1
  288. <if test="roleIds != null and roleIds.size()!=0">
  289. AND bcl.role_id not in
  290. <foreach collection="roleIds" item="item" index="index" open="(" close=")" separator=",">
  291. #{item}
  292. </foreach>
  293. </if>
  294. AND bdl.id = dl.id)>0
  295. </if>
  296. <if test="payStatus != null and payStatus.size()!=0">
  297. AND dl.pay_status in
  298. <foreach collection="payStatus" item="item" index="index" open="(" close=")" separator=",">
  299. #{item}
  300. </foreach>
  301. </if>
  302. <if test="billType != null and billType != ''">
  303. AND st.bill_type = #{billType}
  304. </if>
  305. <if test="monthTime != null and monthTime.size()!=0">
  306. AND dl.month_time in
  307. <foreach collection="monthTime" item="item" index="index" open="(" close=")" separator=",">
  308. #{item}
  309. </foreach>
  310. </if>
  311. </select>
  312. <select id="getSellerList" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideLogQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideLogVo">
  313. SELECT
  314. dl.*,
  315. st.tenant_name,
  316. st.bill_day,
  317. (SELECT
  318. cl.role_id
  319. FROM
  320. top_divide_order tdo
  321. LEFT JOIN top_old_order_check_log cl ON tdo.order_sn = cl.order_sn
  322. WHERE
  323. cl.check_from = 3
  324. AND cl.check_sign = 1
  325. AND tdo.order_type = 1
  326. AND tdo.divide_log_id = dl.id
  327. LIMIT 1) as role_id,
  328. (SELECT
  329. r.role_name
  330. FROM
  331. top_divide_order tdo
  332. LEFT JOIN top_old_order_check_log cl ON tdo.order_sn = cl.order_sn
  333. LEFT JOIN top_sys_role r ON r.role_id = cl.role_id
  334. WHERE
  335. cl.check_from = 3
  336. AND cl.check_sign = 1
  337. AND tdo.order_type = 1
  338. AND tdo.divide_log_id = dl.id
  339. LIMIT 1) as role_name,
  340. (SELECT
  341. cl.check_reason
  342. FROM
  343. top_divide_order tdo
  344. LEFT JOIN top_old_order_check_log cl ON tdo.order_sn = cl.order_sn
  345. WHERE
  346. cl.check_from = 3
  347. AND tdo.order_type = 1
  348. AND tdo.divide_log_id = dl.id
  349. AND cl.check_status = -1
  350. ORDER BY cl.check_sort
  351. LIMIT 1) as check_reason
  352. FROM
  353. top_divide_log dl
  354. LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
  355. WHERE
  356. dl.divide_type = 2
  357. <if test="overPayDay != null ">
  358. AND dl.predict_pay_time <![CDATA[ <= ]]> #{overPayDayTime}
  359. </if>
  360. <if test="tenantId != null and tenantId != ''">
  361. AND dl.tenant_id = #{tenantId}
  362. </if>
  363. <if test="payStatus != null and payStatus.size()!=0">
  364. AND dl.pay_status in
  365. <foreach collection="payStatus" item="item" index="index" open="(" close=")" separator=",">
  366. #{item}
  367. </foreach>
  368. </if>
  369. <if test="createNo != null ">
  370. AND (dl.create_no = #{createNo} or dl.create_username like concat('%', #{createNo}, '%'))
  371. </if>
  372. <if test="monthTime != null and monthTime.size()!=0">
  373. AND dl.month_time in
  374. <foreach collection="monthTime" item="item" index="index" open="(" close=")" separator=",">
  375. #{item}
  376. </foreach>
  377. </if>
  378. <if test="tenantIds != null and tenantIds.size()!=0">
  379. AND dl.tenant_id in
  380. <foreach collection="tenantIds" item="item" index="index" open="(" close=")" separator=",">
  381. #{item}
  382. </foreach>
  383. </if>
  384. <if test="notPayStatus != null ">
  385. AND dl.pay_status != #{notPayStatus}
  386. </if>
  387. <if test="reCheckStatus == 1">
  388. AND (SELECT
  389. count(*)
  390. FROM
  391. top_divide_log bdl
  392. LEFT JOIN top_divide_order btdo ON bdl.id = btdo.divide_log_id
  393. LEFT JOIN top_old_order_check_log bcl ON btdo.order_sn = bcl.order_sn
  394. WHERE
  395. bcl.check_from = 3
  396. AND bcl.check_status = 0
  397. AND bcl.check_sign = 1
  398. <if test="roleIds != null and roleIds.size()!=0">
  399. AND bcl.role_id in
  400. <foreach collection="roleIds" item="item" index="index" open="(" close=")" separator=",">
  401. #{item}
  402. </foreach>
  403. </if>
  404. AND bdl.id = dl.id)>0
  405. </if>
  406. <if test="reCheckStatus == 2">
  407. AND (SELECT
  408. count(*)
  409. FROM
  410. top_divide_log bdl
  411. LEFT JOIN top_divide_order btdo ON bdl.id = btdo.divide_log_id
  412. LEFT JOIN top_old_order_check_log bcl ON btdo.order_sn = bcl.order_sn
  413. WHERE
  414. bcl.check_from = 3
  415. AND bcl.check_status = 0
  416. AND bcl.check_sign = 1
  417. <if test="roleIds != null and roleIds.size()!=0">
  418. AND bcl.role_id not in
  419. <foreach collection="roleIds" item="item" index="index" open="(" close=")" separator=",">
  420. #{item}
  421. </foreach>
  422. </if>
  423. AND bdl.id = dl.id)>0
  424. </if>
  425. </select>
  426. <select id="getSellerListWaitCount" parameterType="com.zhongzheng.modules.top.goods.bo.TopOldOrderQueryBo" resultType="Long">
  427. SELECT
  428. IFNULL(COUNT(*) ,0)
  429. FROM
  430. top_divide_log dl
  431. LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
  432. WHERE
  433. dl.divide_type = 2
  434. <if test="tenantId != null and tenantId != ''">
  435. AND dl.tenant_id = #{tenantId}
  436. </if>
  437. <if test="payStatus != null and payStatus.size()!=0">
  438. AND dl.pay_status in
  439. <foreach collection="payStatus" item="item" index="index" open="(" close=")" separator=",">
  440. #{item}
  441. </foreach>
  442. </if>
  443. <if test="createNo != null ">
  444. AND (dl.create_no = #{createNo} or dl.create_username like concat('%', #{createNo}, '%'))
  445. </if>
  446. <if test="monthTime != null and monthTime.size()!=0">
  447. AND dl.month_time in
  448. <foreach collection="monthTime" item="item" index="index" open="(" close=")" separator=",">
  449. #{item}
  450. </foreach>
  451. </if>
  452. <if test="tenantIds != null and tenantIds.size()!=0">
  453. AND dl.tenant_id in
  454. <foreach collection="tenantIds" item="item" index="index" open="(" close=")" separator=",">
  455. #{item}
  456. </foreach>
  457. </if>
  458. <if test="notPayStatus != null ">
  459. AND dl.pay_status != #{notPayStatus}
  460. </if>
  461. AND (SELECT
  462. count(*)
  463. FROM
  464. top_divide_log bdl
  465. LEFT JOIN top_divide_order btdo ON bdl.id = btdo.divide_log_id
  466. LEFT JOIN top_old_order_check_log bcl ON btdo.order_sn = bcl.order_sn
  467. WHERE
  468. bcl.check_from = 3
  469. AND bcl.check_status = 0
  470. AND bcl.check_sign = 1
  471. <if test="roleIds != null and roleIds.size()!=0">
  472. AND bcl.role_id in
  473. <foreach collection="roleIds" item="item" index="index" open="(" close=")" separator=",">
  474. #{item}
  475. </foreach>
  476. </if>
  477. AND bdl.id = dl.id)>0
  478. </select>
  479. <select id="getCommissionList" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideLogVo">
  480. SELECT
  481. dl.*,
  482. st.tenant_name,
  483. st.bill_day
  484. FROM
  485. top_divide_log dl
  486. LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
  487. WHERE
  488. dl.divide_type = 3
  489. <if test="tenantId != null and tenantId != ''">
  490. AND dl.tenant_id = #{tenantId}
  491. </if>
  492. <if test="payStatus != null">
  493. AND dl.pay_status = #{payStatus}
  494. </if>
  495. <if test="createNo != null ">
  496. AND dl.create_no = #{createNo}
  497. </if>
  498. <if test="monthTime != null and monthTime != ''">
  499. AND dl.month_time in
  500. <foreach collection="monthTime" item="item" index="index" open="(" close=")" separator=",">
  501. #{item}
  502. </foreach>
  503. </if>
  504. </select>
  505. </mapper>