|
@@ -66,4 +66,67 @@
|
|
|
order by settleDate DESC
|
|
|
</select>
|
|
|
|
|
|
+ <!--资产业务我的提成-->
|
|
|
+ <select id="myAssetsIncome" resultType="com.dayou.vo.UserCommissionProdVO">
|
|
|
+ SELECT
|
|
|
+ bpd.id,
|
|
|
+ fc.claim_amount as realAmount,
|
|
|
+ ap.production_no,
|
|
|
+ IF ( fc.claim_datetime > ap.save_file_date, fc.claim_datetime, ap.save_file_date ) AS settleDate,
|
|
|
+ ap.created,
|
|
|
+ dd.NAME AS businessCate,
|
|
|
+ cd.ratio AS ratio,
|
|
|
+ bpd.member_id,
|
|
|
+ bpd.performance_distribution AS allotRatio,
|
|
|
+ IF ( bcr.low_limit_amount > fc.claim_amount, fc.claim_amount * ( cd.ratio / 100 ) * bpd.performance_distribution, bcr.low_limit_amount * ( cd.ratio / 100 ) * bpd.performance_distribution) AS commissionAmount,
|
|
|
+ IF ( bcr.low_limit_amount > fc.claim_amount, fc.claim_amount * ( cd.ratio / 100 ), bcr.low_limit_amount * ( cd.ratio / 100 )) AS commissionAmount,
|
|
|
+ u.name as userName,
|
|
|
+ (case bpd.user_type when 'EVALUATE' then '评估人员' else '市场人员' end) as userType
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ claim_amount,
|
|
|
+ order_fund_id,
|
|
|
+ production_fund_id,
|
|
|
+ claim_datetime
|
|
|
+ FROM
|
|
|
+ finance_claim
|
|
|
+ WHERE
|
|
|
+ deleted = 0
|
|
|
+ AND production_fund_id IS NOT NULL
|
|
|
+ AND claim_datetime >= #{vo.startDate}
|
|
|
+ AND claim_datetime <= #{vo.endDate}
|
|
|
+ UNION ALL
|
|
|
+ SELECT
|
|
|
+ allot_amount AS claim_amount,
|
|
|
+ order_fund_id,
|
|
|
+ production_fund_id,
|
|
|
+ created AS claim_datetime
|
|
|
+ FROM
|
|
|
+ order_fund_allot
|
|
|
+ WHERE
|
|
|
+ deleted = 0
|
|
|
+ AND created >= #{vo.startDate}
|
|
|
+ AND created <= #{vo.endDate}
|
|
|
+ ) fc
|
|
|
+ INNER JOIN ( SELECT id,order_fund_id, business_id, production_no FROM production_fund WHERE business_type = 'ASSET_BUSINESS' AND deleted = 0 ) pf ON ( pf.id = fc.production_fund_id AND pf.order_fund_id = fc.order_fund_id )
|
|
|
+ INNER JOIN ( SELECT id, business_id, production_no, production_type, save_file_date, delivery,created FROM assets_production WHERE deleted = 0 ) ap ON ap.production_no = pf.production_no
|
|
|
+ LEFT JOIN assets a ON a.id = ap.business_id
|
|
|
+ INNER JOIN ( SELECT id,business_id, production_id, business_type ,commission_rate_id, ratio FROM commission_declare WHERE deleted = 0 AND declare_result = '审核通过' ) cd ON (
|
|
|
+ cd.business_id = a.id
|
|
|
+ AND ( cd.production_id IS NULL OR cd.production_id = ap.id ))
|
|
|
+ LEFT JOIN business_commission_rate bcr ON bcr.id = cd.commission_rate_id
|
|
|
+ LEFT JOIN dict_data dd ON dd.id = bcr.business_cate_id
|
|
|
+ LEFT JOIN ( SELECT id,business_id,user_type, report_no, member_id, performance_distribution ,declare_id FROM business_performance_distribution WHERE deleted = 0 ) bpd
|
|
|
+ ON ( bpd.business_id = a.id and (bpd.report_no is null or bpd.report_no = ap.id )
|
|
|
+ and if(bpd.user_type='MARKET','COMMISSION_DECLARE_ASSET_MARKET','COMMISSION_DECLARE_ASSET_EVALUATE') = cd.business_type
|
|
|
+ )
|
|
|
+ and if(bpd.user_type='MARKET',ap.delivery = true, ap.save_file_date is not null)
|
|
|
+ left join user u on u.id = bpd.member_id
|
|
|
+
|
|
|
+ WHERE
|
|
|
+ u.id= #{vo.userId}
|
|
|
+ order by settleDate DESC
|
|
|
+ </select>
|
|
|
+
|
|
|
</mapper>
|