| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519 |
- <?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.TopDivideOrderMapper">
- <resultMap type="com.zhongzheng.modules.top.financial.domain.TopDivideOrder" id="TopDivideOrderResult">
- <result property="id" column="id"/>
- <result property="divideLogId" column="divide_log_id"/>
- <result property="orderSn" column="order_sn"/>
- <result property="orderType" column="order_type"/>
- <result property="status" column="status"/>
- <result property="createTime" column="create_time"/>
- <result property="updateTime" column="update_time"/>
- </resultMap>
- <select id="getFinishList" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideOrderVo">
- SELECT
- tdo.*,
- st.tenant_name ,
- cl.check_status,
- dl.pay_status,
- dl.divide_type,
- oo.accomplish_time as order_time,
- oo.remark,
- IFNULL(oo.divide_company_money,0) divide_company_money,
- IFNULL(oo.divide_seller_money,0) divide_seller_money,
- IFNULL(oo.brokerage,0) brokerage,
- IFNULL(oo.pretax_brokerage,0) pretax_brokerage,
- IFNULL(oo.order_price,0) order_price,
- oo.order_from,
- oo.create_time as order_create_time,
- r.role_name,
- r.role_id,
- oo.create_sys_user_id,
- oo.create_username,
- oo.create_no
- FROM
- top_divide_order tdo
- LEFT JOIN top_divide_log dl ON tdo.divide_log_id = dl.id
- LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
- LEFT JOIN v_top_order oo ON tdo.order_sn = oo.order_sn
- LEFT JOIN
- 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
- LEFT JOIN top_sys_role r ON cl.role_id = r.role_id
- WHERE
- tdo.order_type = 1
- AND tdo.divide_log_id = #{divideLogId}
- <if test="startPrice != null and startPrice != ''">
- AND (oo.order_price - oo.pretax_brokerage) <![CDATA[ >= ]]> #{startPrice}
- </if>
- <if test="endPrice != null and endPrice != ''">
- AND (oo.order_price - oo.pretax_brokerage) <![CDATA[ <= ]]> #{endPrice}
- </if>
- <if test="orderSn != null and orderSn != ''">
- AND oo.order_sn = #{orderSn}
- </if>
- <if test="accomplishStartTime != null ">
- AND oo.accomplish_time <![CDATA[ >= ]]> #{accomplishStartTime}
- </if>
- <if test="accomplishEndTime != null ">
- AND oo.accomplish_time <![CDATA[ <= ]]> #{accomplishEndTime}
- </if>
- <if test="checkStatus != null and checkStatus == 0">
- AND cl.check_status <![CDATA[ <= ]]> 0
- </if>
- <if test="checkStatus != null and checkStatus == 1">
- AND cl.check_status <![CDATA[ >= ]]> 1
- </if>
- </select>
- <select id="getFinishCount" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideOrderVo">
- SELECT
- SUM(oo.order_price) as order_price,
- SUM(oo.divide_company_money) as divide_company_money,
- SUM(oo.divide_seller_money) as divide_seller_money,
- SUM(oo.pretax_brokerage) as pretax_brokerage
- FROM
- top_divide_order tdo
- LEFT JOIN top_divide_log dl ON tdo.divide_log_id = dl.id
- LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
- LEFT JOIN v_top_order oo ON tdo.order_sn = oo.order_sn
- LEFT JOIN
- 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
- LEFT JOIN top_sys_role r ON cl.role_id = r.role_id
- WHERE
- tdo.order_type = 1
- AND tdo.divide_log_id = #{divideLogId}
- <if test="startPrice != null and startPrice != ''">
- AND (oo.order_price - oo.pretax_brokerage) <![CDATA[ >= ]]> #{startPrice}
- </if>
- <if test="endPrice != null and endPrice != ''">
- AND (oo.order_price - oo.pretax_brokerage) <![CDATA[ <= ]]> #{endPrice}
- </if>
- <if test="orderSn != null and orderSn != ''">
- AND oo.order_sn = #{orderSn}
- </if>
- <if test="accomplishStartTime != null ">
- AND oo.accomplish_time <![CDATA[ >= ]]> #{accomplishStartTime}
- </if>
- <if test="accomplishEndTime != null ">
- AND oo.accomplish_time <![CDATA[ <= ]]> #{accomplishEndTime}
- </if>
- <if test="checkStatus != null and checkStatus == 0">
- AND cl.check_status <![CDATA[ <= ]]> 0
- </if>
- <if test="checkStatus != null and checkStatus == 1">
- AND cl.check_status <![CDATA[ >= ]]> 1
- </if>
- </select>
- <select id="getRefundList" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideOrderVo">
- SELECT
- tdo.*,
- st.tenant_name,
- dl.pay_status,
- dl.divide_type,
- oo.remark,
- IFNULL(oo.order_price,0) order_price,
- IFNULL(oo.brokerage,0) brokerage,
- IFNULL(oo.pretax_brokerage,0) pretax_brokerage,
- IFNULL(tor.divide_money,0) divide_money,
- tor.refund_time as order_time,
- oo.create_time as order_create_time,
- oo.create_sys_user_id,
- oo.create_username,
- oo.create_no
- FROM
- top_divide_order tdo
- LEFT JOIN top_divide_log dl ON tdo.divide_log_id = dl.id
- LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
- LEFT JOIN v_top_order oo ON tdo.order_sn = oo.order_sn
- LEFT JOIN top_old_order_refund tor ON tdo.order_sn = tor.order_sn
- WHERE
- tdo.order_type = 2
- AND tdo.divide_log_id = #{divideLogId}
- <if test="startPrice != null and startPrice != ''">
- AND (oo.order_price - oo.pretax_brokerage) <![CDATA[ >= ]]> #{startPrice}
- </if>
- <if test="endPrice != null and endPrice != ''">
- AND (oo.order_price - oo.pretax_brokerage) <![CDATA[ <= ]]> #{endPrice}
- </if>
- <if test="orderSn != null and orderSn != ''">
- AND oo.order_sn = #{orderSn}
- </if>
- <if test="accomplishStartTime != null ">
- AND tor.refund_time <![CDATA[ >= ]]> #{accomplishStartTime}
- </if>
- <if test="accomplishEndTime != null ">
- AND tor.refund_time <![CDATA[ <= ]]> #{accomplishEndTime}
- </if>
- <if test="checkStatus != null and checkStatus == 0">
- AND 1=0
- </if>
- </select>
- <select id="getRefundCount" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideOrderVo">
- SELECT
- SUM(tor.divide_money) as divide_money
- FROM
- top_divide_order tdo
- LEFT JOIN top_divide_log dl ON tdo.divide_log_id = dl.id
- LEFT JOIN sys_tenant st ON dl.tenant_id = st.tenant_id
- LEFT JOIN v_top_order oo ON tdo.order_sn = oo.order_sn
- LEFT JOIN top_old_order_refund tor ON tdo.order_sn = tor.order_sn
- WHERE
- tdo.order_type = 2
- AND tdo.divide_log_id = #{divideLogId}
- <if test="startPrice != null and startPrice != ''">
- AND (oo.order_price - oo.pretax_brokerage) <![CDATA[ >= ]]> #{startPrice}
- </if>
- <if test="endPrice != null and endPrice != ''">
- AND (oo.order_price - oo.pretax_brokerage) <![CDATA[ <= ]]> #{endPrice}
- </if>
- <if test="orderSn != null and orderSn != ''">
- AND oo.order_sn = #{orderSn}
- </if>
- <if test="accomplishStartTime != null ">
- AND tor.refund_time <![CDATA[ >= ]]> #{accomplishStartTime}
- </if>
- <if test="accomplishEndTime != null ">
- AND tor.refund_time <![CDATA[ <= ]]> #{accomplishEndTime}
- </if>
- <if test="checkStatus != null and checkStatus == 0">
- AND 1=0
- </if>
- </select>
- <select id="getBusinessList" parameterType="String" resultType="String">
- SELECT
- business_name
- FROM
- v_top_order_business
- WHERE
- order_sn = #{orderSn}
- GROUP BY
- business_name
- </select>
- <select id="getMonthFinishAllTenant" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="String">
- SELECT
- v.tenant_id
- FROM
- v_top_order v
- WHERE
- 1 = 1
- AND v.finish_status = 1
- <if test="divideModel != null and divideModel != ''">
- AND v.divide_model = #{divideModel}
- </if>
- <if test="accomplishStartTime != null and accomplishStartTime != ''">
- AND v.accomplish_time BETWEEN #{accomplishStartTime} and #{accomplishEndTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND v.tenant_id = #{tenantId}
- </if>
- GROUP BY v.tenant_id
- </select>
- <select id="getMonthFinishList" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideOrderVo">
- SELECT
- v.order_sn,
- IFNULL(v.divide_company_money,0) divide_company_money,
- IFNULL(v.divide_seller_money,0) divide_seller_money,
- v.tenant_id,
- v.create_no,
- v.create_username,
- IFNULL(v.brokerage,0) brokerage
- FROM
- v_top_order v
- WHERE
- 1 = 1
- AND v.finish_status = 1
- <if test="divideModel != null and divideModel != ''">
- AND v.divide_model = #{divideModel}
- </if>
- <if test="accomplishStartTime != null and accomplishStartTime != ''">
- AND v.accomplish_time BETWEEN #{accomplishStartTime} and #{accomplishEndTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND v.tenant_id = #{tenantId}
- </if>
- <if test="createNo != null and createNo != ''">
- AND v.create_no = #{createNo}
- </if>
- <if test="createSysUserId != null and createSysUserId !=0">
- AND v.create_sys_user_id = #{createSysUserId}
- </if>
- <if test="createSysUserId == 0">
- AND (v.create_sys_user_id is null or v.create_sys_user_id = 0)
- </if>
- </select>
- <select id="getMonthCreditList" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideOrderVo">
- SELECT
- v.order_sn,
- v.create_time,
- v.purchase_org,
- v.divide_company_money,
- v.divide_seller_money,
- v.tenant_id,
- v.create_no,
- v.create_username,
- v.brokerage,
- v.brokerage_type,
- v.brokerage_bank_account,
- v.brokerage_bank_name,
- v.brokerage_bank,
- v.order_price,
- st.tenant_name,
- v.pretax_brokerage,
- r.role_name,
- r.role_id,
- cl.check_status,
- v.pretax,
- bp.pay_type,
- bp.to_bank_acount,
- bp.to_bank_name,
- bp.to_bank_type_name,
- bp.create_time as pay_time,
- (SELECT
- ocl.check_reason
- FROM
- top_old_order_check_log ocl
- WHERE
- ocl.check_from = 4
- AND ocl.order_sn = v.order_sn
- AND ocl.check_status = -1
- ORDER BY ocl.check_sort
- LIMIT 1) as check_reason
- FROM
- top_old_order v
- LEFT JOIN sys_tenant st ON v.tenant_id = st.tenant_id
- LEFT JOIN
- top_old_order_check_log cl ON cl.check_from = 4 AND cl.check_sign = 1 AND v.order_sn = cl.order_sn
- LEFT JOIN top_sys_role r ON cl.role_id = r.role_id
- LEFT JOIN top_order_bank_pay bp ON bp.type = 4 AND bp.order_sn = v.order_sn AND bp.result_status = 1
- WHERE
- 1 = 1
- <if test="accomplishStartTime != null and accomplishStartTime != ''">
- AND v.accomplish_time BETWEEN #{accomplishStartTime} and #{accomplishEndTime}
- </if>
- <if test="buyStartTime != null and buyStartTime != ''">
- AND v.create_time BETWEEN #{buyStartTime} and #{buyEndTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND v.tenant_id = #{tenantId}
- </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="tenantIds != null and tenantIds.size()!=0">
- AND v.tenant_id in
- <foreach collection="tenantIds" item="item" index="index" open="(" close=")" separator=",">
- #{item}
- </foreach>
- </if>
- <if test="createNo != null and createNo != ''">
- AND (v.create_no = #{createNo} or v.create_username like concat('%', #{createNo}, '%'))
- </if>
- <if test="orderSn != null and orderSn != ''">
- AND v.order_sn = #{orderSn}
- </if>
- AND v.finish_status = 1
- AND v.brokerage > 0
- <if test="reCheckStatus == 1">
- AND (SELECT
- count(*)
- FROM
- top_old_order_check_log bcl
- WHERE
- bcl.check_from = 4
- 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 bcl.order_sn = v.order_sn)>0
- </if>
- <if test="reCheckStatus == 2">
- AND (SELECT
- count(*)
- FROM
- top_old_order_check_log bcl
- WHERE
- bcl.check_from = 4
- 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 bcl.order_sn = v.order_sn)>0
- </if>
- order by v.create_time
- </select>
- <select id="getMonthCreditWaitCount" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="Long">
- SELECT
- count(*)
- FROM
- top_old_order v
- LEFT JOIN sys_tenant st ON v.tenant_id = st.tenant_id
- LEFT JOIN
- top_old_order_check_log cl ON cl.check_from = 4 AND cl.check_sign = 1 AND v.order_sn = cl.order_sn
- LEFT JOIN top_sys_role r ON cl.role_id = r.role_id
- LEFT JOIN top_order_bank_pay bp ON bp.type = 4 AND bp.order_sn = v.order_sn AND bp.result_status = 1
- WHERE
- 1 = 1
- <if test="accomplishStartTime != null and accomplishStartTime != ''">
- AND v.accomplish_time BETWEEN #{accomplishStartTime} and #{accomplishEndTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND v.tenant_id = #{tenantId}
- </if>
- <if test="createNo != null and createNo != ''">
- AND (v.create_no = #{createNo} or v.create_username like concat('%', #{createNo}, '%'))
- </if>
- <if test="orderSn != null and orderSn != ''">
- AND v.order_sn = #{orderSn}
- </if>
- AND v.finish_status = 1
- AND v.brokerage > 0
- AND (SELECT
- count(*)
- FROM
- top_old_order_check_log bcl
- WHERE
- bcl.check_from = 4
- 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 bcl.order_sn = v.order_sn)>0
- </select>
- <select id="getMonthRefundList" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideOrderVo">
- SELECT
- tor.order_sn,
- tor.divide_money,
- tor.tenant_id,
- tor.refund_sn,
- v.create_no,
- v.create_username
- FROM
- top_old_order_refund tor
- LEFT JOIN v_top_order v on tor.order_sn = v.order_sn
- WHERE
- 1 = 1
- AND tor.period_status = 3
- <if test="divideModel != null and divideModel != ''">
- AND tor.divide_model = #{divideModel}
- </if>
- <if test="refundTimeStartTime != null and refundTimeStartTime != ''">
- AND tor.refund_time BETWEEN #{refundTimeStartTime} and #{refundTimeEndTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND tor.tenant_id = #{tenantId}
- </if>
- <if test="createNo != null and createNo != ''">
- AND v.create_no = #{createNo}
- </if>
- <if test="createSysUserId != null and createSysUserId !=0">
- AND v.create_sys_user_id = #{createSysUserId}
- </if>
- <if test="createSysUserId == 0">
- AND (v.create_sys_user_id is null or v.create_sys_user_id = 0)
- </if>
- </select>
- <select id="getMonthBadSum" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="BigDecimal">
- SELECT
- IFNULL(SUM(too.order_uncollected),0)
- FROM
- top_old_order too
- WHERE
- too.status=1
- AND too.check_status = 1
- <if test="buyStartTime != null and buyStartTime != ''">
- AND too.check_time <![CDATA[ >= ]]> #{buyStartTime}
- </if>
- <if test="buyEndTime != null and buyEndTime != ''">
- AND too.check_time <![CDATA[ <= ]]> #{buyEndTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND too.tenant_id = #{tenantId}
- </if>
- </select>
- <select id="getMonthFinishAllSeller" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopCreateUserVo">
- SELECT
- v.create_sys_user_id,
- any_value (v.create_username) create_username,
- v.tenant_id
- FROM
- v_top_order v
- WHERE
- 1 = 1
- AND v.finish_status = 1
- <if test="divideModel != null and divideModel != ''">
- AND v.divide_model = #{divideModel}
- </if>
- <if test="accomplishStartTime != null and accomplishStartTime != ''">
- AND v.accomplish_time BETWEEN #{accomplishStartTime} and #{accomplishEndTime}
- </if>
- <if test="tenantId != null and tenantId != ''">
- AND v.tenant_id = #{tenantId}
- </if>
- <if test="createNo != null and createNo != ''">
- AND v.create_no = #{createNo}
- </if>
- GROUP BY v.create_sys_user_id,v.tenant_id
- </select>
- <select id="getByOrderSn" parameterType="com.zhongzheng.modules.top.financial.bo.TopDivideOrderQueryBo" resultType="com.zhongzheng.modules.top.financial.vo.TopDivideOrderVo">
- SELECT
- tdo.*
- FROM
- top_divide_order tdo
- LEFT JOIN top_divide_log dl on tdo.divide_log_id = dl.id
- WHERE
- 1 = 1
- AND tdo.order_type = 1
- <if test="divideType != null and divideType != ''">
- AND dl.divide_type = #{divideType}
- </if>
- <if test="orderSn != null and orderSn != ''">
- AND tdo.order_sn = #{orderSn}
- </if>
- LIMIT 1
- </select>
- <update id="updateCheckStatusById" parameterType="com.zhongzheng.modules.top.order.domain.TopOrderBankPay" >
- UPDATE top_divide_order tdo
- LEFT JOIN top_divide_log dl ON tdo.divide_log_id = dl.id
- LEFT JOIN 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
- <set>
- cl.check_status = 3
- </set>
- where
- tdo.order_type = 1
- AND tdo.divide_log_id = #{divideLogId}
- AND cl.check_status = 2
- </update>
- </mapper>
|