| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520 |
- <?xml version="1.0" encoding="UTF-8" ?>
- <!DOCTYPE mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.zhongzheng.modules.top.financial.mapper.TopDivideLogMapper">
- <resultMap type="com.zhongzheng.modules.top.financial.domain.TopDivideLog" id="TopDivideLogResult">
- <result property="id" column="id"/>
- <result property="year" column="year"/>
- <result property="month" column="month"/>
- <result property="payMoney" column="pay_money"/>
- <result property="sellerId" column="seller_id"/>
- <result property="status" column="status"/>
- <result property="createTime" column="create_time"/>
- <result property="updateTime" column="update_time"/>
- <result property="divideType" column="divide_type"/>
- <result property="payStatus" column="pay_status"/>
- <result property="remark" column="remark"/>
- <result property="deductMoney" column="deduct_money"/>
- <result property="createUsername" column="create_username"/>
- <result property="createSysUserId" column="create_sys_user_id"/>
- <result property="createNo" column="create_no"/>
- </resultMap>
- <select id="getCompanyList" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideLogQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideLogVo">
- SELECT
- dl.*,
- st.tenant_name,
- st.bill_type,
- st.bill_day,
- (SELECT
- cl.role_id
- FROM
- top_divide_order tdo
- LEFT JOIN top_old_order_check_log cl ON tdo.order_sn = cl.order_sn
- WHERE
- cl.check_from = 2
- AND cl.check_sign = 1
- AND tdo.order_type = 1
- AND tdo.divide_log_id = dl.id
- LIMIT 1) as role_id,
- (SELECT
- r.role_name
- FROM
- top_divide_order tdo
- LEFT JOIN top_old_order_check_log cl ON tdo.order_sn = cl.order_sn
- LEFT JOIN top_sys_role r ON r.role_id = cl.role_id
- WHERE
- cl.check_from = 2
- AND cl.check_sign = 1
- AND tdo.order_type = 1
- AND tdo.divide_log_id = dl.id
- LIMIT 1) as role_name,
- (SELECT
- cl.check_reason
- FROM
- top_divide_order tdo
- LEFT JOIN top_old_order_check_log cl ON tdo.order_sn = cl.order_sn
- WHERE
- cl.check_from = 2
- AND tdo.order_type = 1
- AND tdo.divide_log_id = dl.id
- AND cl.check_status = -1
- ORDER BY cl.check_sort
- LIMIT 1) as check_reason
- FROM
- top_divide_log dl
- LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
- WHERE
- dl.divide_type = 1
- <if test="tenantId != null and tenantId != ''">
- AND dl.tenant_id = #{tenantId}
- </if>
- <if test="billType != null and billType != ''">
- AND st.bill_type = #{billType}
- </if>
- <if test="payStatus != null and payStatus.size()!=0">
- AND dl.pay_status in
- <foreach collection="payStatus" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="monthTime != null and monthTime.size()!=0">
- AND dl.month_time in
- <foreach collection="monthTime" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="tenantIds != null and tenantIds.size()!=0">
- AND dl.tenant_id in
- <foreach collection="tenantIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="overPayDay != null ">
- AND dl.predict_pay_time <![CDATA[ <= ]]> #{overPayDayTime}
- </if>
- <if test="notPayStatus != null ">
- AND dl.pay_status != #{notPayStatus}
- </if>
- <if test="reCheckStatus == 1">
- AND (SELECT
- count(*)
- FROM
- top_divide_log bdl
- LEFT JOIN top_divide_order btdo ON bdl.id = btdo.divide_log_id
- LEFT JOIN top_old_order_check_log bcl ON btdo.order_sn = bcl.order_sn
- WHERE
- bcl.check_from = 2
- AND bcl.check_status = 0
- AND bcl.check_sign = 1
- <if test="roleIds != null and roleIds.size()!=0">
- AND bcl.role_id in
- <foreach collection="roleIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- AND bdl.id = dl.id)>0
- </if>
- <if test="reCheckStatus == 2">
- AND (SELECT
- count(*)
- FROM
- top_divide_log bdl
- LEFT JOIN top_divide_order btdo ON bdl.id = btdo.divide_log_id
- LEFT JOIN top_old_order_check_log bcl ON btdo.order_sn = bcl.order_sn
- WHERE
- bcl.check_from = 2
- AND bcl.check_status = 0
- AND bcl.check_sign = 1
- <if test="roleIds != null and roleIds.size()!=0">
- AND bcl.role_id not in
- <foreach collection="roleIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- AND bdl.id = dl.id)>0
- </if>
- </select>
- <select id="getCompanyWaitCount" parameterType="com.zhongzheng.modules.top.goods.bo.TopOldOrderQueryBo" resultType="Long">
- SELECT
- IFNULL(COUNT(*) ,0)
- FROM
- top_divide_log dl
- LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
- WHERE
- dl.divide_type = 1
- <if test="tenantId != null and tenantId != ''">
- AND dl.tenant_id = #{tenantId}
- </if>
- <if test="billType != null and billType != ''">
- AND st.bill_type = #{billType}
- </if>
- <if test="payStatus != null and payStatus.size()!=0">
- AND dl.pay_status in
- <foreach collection="payStatus" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="monthTime != null and monthTime.size()!=0">
- AND dl.month_time in
- <foreach collection="monthTime" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="tenantIds != null and tenantIds.size()!=0">
- AND dl.tenant_id in
- <foreach collection="tenantIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="overPayDay != null ">
- AND dl.predict_pay_time <![CDATA[ <= ]]> #{overPayDayTime}
- </if>
- <if test="notPayStatus != null ">
- AND dl.pay_status != #{notPayStatus}
- </if>
- AND (SELECT
- count(*)
- FROM
- top_divide_log bdl
- LEFT JOIN top_divide_order btdo ON bdl.id = btdo.divide_log_id
- LEFT JOIN top_old_order_check_log bcl ON btdo.order_sn = bcl.order_sn
- WHERE
- bcl.check_from = 2
- AND bcl.check_status = 0
- AND bcl.check_sign = 1
- <if test="roleIds != null and roleIds.size()!=0">
- AND bcl.role_id in
- <foreach collection="roleIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- AND bdl.id = dl.id)>0
- </select>
- <select id="getCheckList" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideLogQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideLogVo">
- SELECT
- dl.*,
- cl.check_status,
- cl.check_sign,
- r.role_name
- FROM
- top_divide_log dl LEFT JOIN
- top_old_order_check_log cl ON dl.id = cl.month_divide_id AND cl.check_sign = 1
- LEFT JOIN top_sys_role r ON cl.role_id = r.role_id
- WHERE
- 1 = 1
- <if test="tenantId != null and tenantId != ''">
- AND dl.tenant_id = #{tenantId}
- </if>
- <if test="divideType != null">
- AND dl.divide_type = #{divideType}
- </if>
- <if test="payStatus != null">
- AND dl.pay_status = #{payStatus}
- </if>
- <if test="roleId != null and roleId != ''">
- AND cl.role_id = #{roleId}
- </if>
- <if test="checkFrom != null and checkFrom != ''">
- AND cl.check_from = #{checkFrom}
- </if>
- <if test="checkStatus != null and checkStatus.size()!=0">
- AND cl.check_status in
- <foreach collection="checkStatus" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="monthTime != null and monthTime.size()!=0">
- AND dl.month_time in
- <foreach collection="monthTime" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- order by dl.id
- </select>
- <select id="getSumMoney" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideLogQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideLogVo">
- SELECT
- sum(
- dl.total_pay_money) AS pay_money_total,
- sum(
- IF
- ( pay_status = 1, dl.deduct_money, 0 )) AS deduct_money_total,
- sum(
- dl.pay_money) AS un_pay_money_total,
- sum(
- IF
- ( pay_status !=1, dl.deduct_money, 0 )) AS un_deduct_money_total
- FROM
- top_divide_log dl
- LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
- WHERE
- 1=1
- <if test="divideType != null">
- AND dl.divide_type = #{divideType}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND dl.tenant_id = #{tenantId}
- </if>
- <if test="reCheckStatus == 1">
- AND (SELECT
- count(*)
- FROM
- top_divide_log bdl
- LEFT JOIN top_divide_order btdo ON bdl.id = btdo.divide_log_id
- LEFT JOIN top_old_order_check_log bcl ON btdo.order_sn = bcl.order_sn
- WHERE
- bcl.check_from = 2
- AND bcl.check_status = 0
- AND bcl.check_sign = 1
- <if test="roleIds != null and roleIds.size()!=0">
- AND bcl.role_id in
- <foreach collection="roleIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- AND bdl.id = dl.id)>0
- </if>
- <if test="reCheckStatus == 2">
- AND (SELECT
- count(*)
- FROM
- top_divide_log bdl
- LEFT JOIN top_divide_order btdo ON bdl.id = btdo.divide_log_id
- LEFT JOIN top_old_order_check_log bcl ON btdo.order_sn = bcl.order_sn
- WHERE
- bcl.check_from = 2
- AND bcl.check_status = 0
- AND bcl.check_sign = 1
- <if test="roleIds != null and roleIds.size()!=0">
- AND bcl.role_id not in
- <foreach collection="roleIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- AND bdl.id = dl.id)>0
- </if>
- <if test="payStatus != null and payStatus.size()!=0">
- AND dl.pay_status in
- <foreach collection="payStatus" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="billType != null and billType != ''">
- AND st.bill_type = #{billType}
- </if>
- <if test="monthTime != null and monthTime.size()!=0">
- AND dl.month_time in
- <foreach collection="monthTime" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </select>
- <select id="getSellerList" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideLogQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideLogVo">
- SELECT
- dl.*,
- st.tenant_name,
- st.bill_day,
- (SELECT
- cl.role_id
- FROM
- top_divide_order tdo
- LEFT JOIN top_old_order_check_log cl ON tdo.order_sn = cl.order_sn
- WHERE
- cl.check_from = 3
- AND cl.check_sign = 1
- AND tdo.order_type = 1
- AND tdo.divide_log_id = dl.id
- LIMIT 1) as role_id,
- (SELECT
- r.role_name
- FROM
- top_divide_order tdo
- LEFT JOIN top_old_order_check_log cl ON tdo.order_sn = cl.order_sn
- LEFT JOIN top_sys_role r ON r.role_id = cl.role_id
- WHERE
- cl.check_from = 3
- AND cl.check_sign = 1
- AND tdo.order_type = 1
- AND tdo.divide_log_id = dl.id
- LIMIT 1) as role_name,
- (SELECT
- cl.check_reason
- FROM
- top_divide_order tdo
- LEFT JOIN top_old_order_check_log cl ON tdo.order_sn = cl.order_sn
- WHERE
- cl.check_from = 3
- AND tdo.order_type = 1
- AND tdo.divide_log_id = dl.id
- AND cl.check_status = -1
- ORDER BY cl.check_sort
- LIMIT 1) as check_reason
- FROM
- top_divide_log dl
- LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
- WHERE
- dl.divide_type = 2
- <if test="overPayDay != null ">
- AND dl.predict_pay_time <![CDATA[ <= ]]> #{overPayDayTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND dl.tenant_id = #{tenantId}
- </if>
- <if test="payStatus != null and payStatus.size()!=0">
- AND dl.pay_status in
- <foreach collection="payStatus" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="createNo != null ">
- AND (dl.create_no = #{createNo} or dl.create_username like concat('%', #{createNo}, '%'))
- </if>
- <if test="monthTime != null and monthTime.size()!=0">
- AND dl.month_time in
- <foreach collection="monthTime" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="tenantIds != null and tenantIds.size()!=0">
- AND dl.tenant_id in
- <foreach collection="tenantIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="notPayStatus != null ">
- AND dl.pay_status != #{notPayStatus}
- </if>
- <if test="reCheckStatus == 1">
- AND (SELECT
- count(*)
- FROM
- top_divide_log bdl
- LEFT JOIN top_divide_order btdo ON bdl.id = btdo.divide_log_id
- LEFT JOIN top_old_order_check_log bcl ON btdo.order_sn = bcl.order_sn
- WHERE
- bcl.check_from = 3
- AND bcl.check_status = 0
- AND bcl.check_sign = 1
- <if test="roleIds != null and roleIds.size()!=0">
- AND bcl.role_id in
- <foreach collection="roleIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- AND bdl.id = dl.id)>0
- </if>
- <if test="reCheckStatus == 2">
- AND (SELECT
- count(*)
- FROM
- top_divide_log bdl
- LEFT JOIN top_divide_order btdo ON bdl.id = btdo.divide_log_id
- LEFT JOIN top_old_order_check_log bcl ON btdo.order_sn = bcl.order_sn
- WHERE
- bcl.check_from = 3
- AND bcl.check_status = 0
- AND bcl.check_sign = 1
- <if test="roleIds != null and roleIds.size()!=0">
- AND bcl.role_id not in
- <foreach collection="roleIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- AND bdl.id = dl.id)>0
- </if>
- </select>
- <select id="getSellerListWaitCount" parameterType="com.zhongzheng.modules.top.goods.bo.TopOldOrderQueryBo" resultType="Long">
- SELECT
- IFNULL(COUNT(*) ,0)
- FROM
- top_divide_log dl
- LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
- WHERE
- dl.divide_type = 2
- <if test="tenantId != null and tenantId != ''">
- AND dl.tenant_id = #{tenantId}
- </if>
- <if test="payStatus != null and payStatus.size()!=0">
- AND dl.pay_status in
- <foreach collection="payStatus" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="createNo != null ">
- AND (dl.create_no = #{createNo} or dl.create_username like concat('%', #{createNo}, '%'))
- </if>
- <if test="monthTime != null and monthTime.size()!=0">
- AND dl.month_time in
- <foreach collection="monthTime" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="tenantIds != null and tenantIds.size()!=0">
- AND dl.tenant_id in
- <foreach collection="tenantIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="notPayStatus != null ">
- AND dl.pay_status != #{notPayStatus}
- </if>
- AND (SELECT
- count(*)
- FROM
- top_divide_log bdl
- LEFT JOIN top_divide_order btdo ON bdl.id = btdo.divide_log_id
- LEFT JOIN top_old_order_check_log bcl ON btdo.order_sn = bcl.order_sn
- WHERE
- bcl.check_from = 3
- AND bcl.check_status = 0
- AND bcl.check_sign = 1
- <if test="roleIds != null and roleIds.size()!=0">
- AND bcl.role_id in
- <foreach collection="roleIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- AND bdl.id = dl.id)>0
- </select>
- <select id="getCommissionList" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideLogVo">
- SELECT
- dl.*,
- st.tenant_name,
- st.bill_day
- FROM
- top_divide_log dl
- LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
- WHERE
- dl.divide_type = 3
- <if test="tenantId != null and tenantId != ''">
- AND dl.tenant_id = #{tenantId}
- </if>
- <if test="payStatus != null">
- AND dl.pay_status = #{payStatus}
- </if>
- <if test="createNo != null ">
- AND dl.create_no = #{createNo}
- </if>
- <if test="monthTime != null and monthTime != ''">
- AND dl.month_time in
- <foreach collection="monthTime" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- </select>
- </mapper>
|