模拟批量修改 BIZ008\BIZ020 计价规则,取明细统计多条
This commit is contained in:
parent
78f2359c5f
commit
890d052ddb
@ -31,41 +31,54 @@ public class BIZ008Processor extends AbstractBusinessProcessor {
|
||||
// 更新经办人员数据
|
||||
String updateJbSql =
|
||||
"UPDATE marketing_performance mp " +
|
||||
"JOIN (" +
|
||||
" SELECT " +
|
||||
" branch_id," +
|
||||
" marketer_code," +
|
||||
" total_count AS online_payment_count," +
|
||||
" self_marketing_count * COALESCE(pricing_rule, 1) + " +
|
||||
" other_marketing_count * COALESCE(pricing_rule, 1) * COALESCE(jb_percent, 1) AS online_payment_amount" +
|
||||
" FROM (" +
|
||||
" SELECT " +
|
||||
" e.dept_category AS branch_id," +
|
||||
" a.jb_id AS marketer_code," +
|
||||
" COUNT(1) AS total_count," +
|
||||
" COUNT(CASE WHEN a.yx_id = a.jb_id THEN 1 END) AS self_marketing_count," +
|
||||
" COUNT(CASE WHEN a.yx_id <> a.jb_id THEN 1 END) AS other_marketing_count," +
|
||||
" MAX(COALESCE(g.pricing_rule, 1)) AS pricing_rule," +
|
||||
" MAX(COALESCE(f.jb_percent, 1)) AS jb_percent" +
|
||||
" FROM mps_market a" +
|
||||
" LEFT JOIN sys_dept e ON a.dept_id = e.dept_id " +
|
||||
" LEFT JOIN business_percentage f ON e.dept_category = f.branch_id" +
|
||||
" LEFT JOIN business_subcategory g ON a.subcategory_id = g.type_id" +
|
||||
" WHERE " +
|
||||
" a.subcategory_id = 'BIZ008' and a.del_flag='0' " +
|
||||
" AND SUBSTR(a.entry_date, 1, 7)=? " +
|
||||
" GROUP BY " +
|
||||
" e.dept_category," +
|
||||
" a.jb_id " +
|
||||
" ) summary " +
|
||||
") AS source_data" +
|
||||
" ON mp.branch_id = source_data.branch_id " +
|
||||
" AND mp.marketer_code = source_data.marketer_code" +
|
||||
" SET " +
|
||||
" mp.online_payment_count = source_data.online_payment_count," +
|
||||
" mp.online_payment_amount = source_data.online_payment_amount" +
|
||||
" WHERE " +
|
||||
" mp.record_date = ?";
|
||||
"JOIN ( " +
|
||||
" SELECT " +
|
||||
" branch_id, " +
|
||||
" marketer_code, " +
|
||||
" SUM(channel_count) AS total_channel_count, " +
|
||||
" SUM( " +
|
||||
" CASE " +
|
||||
" WHEN is_self_marketing = 1 " +
|
||||
" THEN channel_count * pricing_rule " +
|
||||
" ELSE channel_count * pricing_rule * jb_percent " +
|
||||
" END " +
|
||||
" ) AS total_bonus_amount, " +
|
||||
" SUM(CASE WHEN is_self_marketing = 1 THEN channel_count ELSE 0 END) AS self_marketing_channels, " +
|
||||
" SUM(CASE WHEN is_self_marketing = 0 THEN channel_count ELSE 0 END) AS other_marketing_channels, " +
|
||||
" MAX(pricing_rule) AS pricing_rule, " +
|
||||
" MAX(jb_percent) AS jb_percent " +
|
||||
" FROM ( " +
|
||||
" SELECT " +
|
||||
" e.dept_category AS branch_id, " +
|
||||
" a.jb_id AS marketer_code, " +
|
||||
" a.yx_id, " +
|
||||
" (LENGTH(a.internet_channel) - LENGTH(REPLACE(a.internet_channel, ',', '')) + 1) AS channel_count, " +
|
||||
" CASE WHEN a.yx_id = a.jb_id THEN 1 ELSE 0 END AS is_self_marketing, " +
|
||||
" COALESCE(g.pricing_rule, 1) AS pricing_rule, " +
|
||||
" CASE " +
|
||||
" WHEN a.yx_id <> a.jb_id THEN COALESCE(f.jb_percent, 1) " +
|
||||
" ELSE 1 " +
|
||||
" END AS jb_percent " +
|
||||
" FROM mps_market a " +
|
||||
" LEFT JOIN sys_dept e ON a.dept_id = e.dept_id " +
|
||||
" LEFT JOIN business_subcategory g ON a.subcategory_id = g.type_id " +
|
||||
" LEFT JOIN business_percentage f ON e.dept_category = f.branch_id AND a.yx_id <> a.jb_id " +
|
||||
" WHERE " +
|
||||
" a.subcategory_id = 'BIZ008' " +
|
||||
" AND SUBSTR(a.entry_date, 1, 7)= ? " +
|
||||
" AND a.del_flag='0' " +
|
||||
" ) channel_data " +
|
||||
" GROUP BY " +
|
||||
" branch_id, " +
|
||||
" marketer_code " +
|
||||
") AS source_data " +
|
||||
"ON mp.branch_id = source_data.branch_id " +
|
||||
" AND mp.marketer_code = source_data.marketer_code " +
|
||||
"SET " +
|
||||
" mp.online_payment_count = source_data.total_channel_count, " +
|
||||
" mp.online_payment_amount = source_data.total_bonus_amount " +
|
||||
"WHERE " +
|
||||
" mp.record_date = ? ";
|
||||
|
||||
int jbUpdateCount = executeParameterizedSql(connection, updateJbSql, batchMonth, batchDate);
|
||||
totalProcessedCount += jbUpdateCount;
|
||||
@ -73,31 +86,42 @@ public class BIZ008Processor extends AbstractBusinessProcessor {
|
||||
// 更新营销人员数据
|
||||
String updateYxSql =
|
||||
"UPDATE marketing_performance mp " +
|
||||
"JOIN (" +
|
||||
" SELECT " +
|
||||
" e.dept_category AS branch_id," +
|
||||
" a.yx_id AS marketer_code," +
|
||||
" COUNT(1) AS online_payment_count," +
|
||||
" COUNT(1) * MAX(COALESCE(g.pricing_rule, 1)) * MAX(COALESCE(f.yx_percent, 1)) AS online_payment_amount" +
|
||||
" FROM mps_market a" +
|
||||
" LEFT JOIN sys_dept e ON a.dept_id = e.dept_id " +
|
||||
" LEFT JOIN business_percentage f ON e.dept_category = f.branch_id" +
|
||||
" LEFT JOIN business_subcategory g ON a.subcategory_id = g.type_id" +
|
||||
" WHERE " +
|
||||
" a.subcategory_id = 'BIZ008' and a.del_flag='0' " +
|
||||
" AND SUBSTR(a.entry_date, 1, 7)=? " +
|
||||
" AND a.yx_id <> a.jb_id" +
|
||||
" GROUP BY " +
|
||||
" e.dept_category," +
|
||||
" a.yx_id " +
|
||||
") AS source_data" +
|
||||
" ON mp.branch_id = source_data.branch_id " +
|
||||
" AND mp.marketer_code = source_data.marketer_code" +
|
||||
" SET " +
|
||||
" mp.online_payment_count = source_data.online_payment_count," +
|
||||
" mp.online_payment_amount = source_data.online_payment_amount" +
|
||||
" WHERE " +
|
||||
" mp.record_date = ?";
|
||||
"JOIN ( " +
|
||||
" SELECT " +
|
||||
" branch_id, " +
|
||||
" marketer_code, " +
|
||||
" SUM(channel_count) AS total_channel_count, " +
|
||||
" SUM(channel_count * pricing_rule * yx_percent) AS total_bonus_amount, " +
|
||||
" MAX(pricing_rule) AS pricing_rule, " +
|
||||
" MAX(yx_percent) AS jb_percent " +
|
||||
" FROM ( " +
|
||||
" SELECT " +
|
||||
" e.dept_category AS branch_id, " +
|
||||
" a.yx_id AS marketer_code, " +
|
||||
" (LENGTH(a.internet_channel) - LENGTH(REPLACE(a.internet_channel, ',', '')) + 1) AS channel_count, " +
|
||||
" COALESCE(g.pricing_rule, 1) AS pricing_rule, " +
|
||||
" COALESCE(f.yx_percent, 1) AS yx_percent " +
|
||||
" FROM mps_market a " +
|
||||
" LEFT JOIN sys_dept e ON a.dept_id = e.dept_id " +
|
||||
" LEFT JOIN business_subcategory g ON a.subcategory_id = g.type_id " +
|
||||
" LEFT JOIN business_percentage f ON e.dept_category = f.branch_id " +
|
||||
" WHERE " +
|
||||
" a.subcategory_id = 'BIZ008' " +
|
||||
" AND SUBSTR(a.entry_date, 1, 7)= ? " +
|
||||
" AND a.yx_id <> a.jb_id " +
|
||||
" AND a.del_flag='0' " +
|
||||
" ) channel_data " +
|
||||
" GROUP BY " +
|
||||
" branch_id, " +
|
||||
" marketer_code " +
|
||||
") AS source_data " +
|
||||
"ON mp.branch_id = source_data.branch_id " +
|
||||
" AND mp.marketer_code = source_data.marketer_code " +
|
||||
"SET " +
|
||||
" mp.online_payment_count = source_data.total_channel_count, " +
|
||||
" mp.online_payment_amount = source_data.total_bonus_amount " +
|
||||
"WHERE " +
|
||||
" mp.record_date = ? ";
|
||||
|
||||
int yxUpdateCount = executeParameterizedSql(connection, updateYxSql, batchMonth, batchDate);
|
||||
totalProcessedCount += yxUpdateCount;
|
||||
|
@ -48,6 +48,7 @@ public class BIZ020Processor extends AbstractBusinessProcessor {
|
||||
" MAX(COALESCE(g.pricing_rule, 1)) AS pricing_rule," +
|
||||
" MAX(COALESCE(f.jb_percent, 1)) AS jb_percent" +
|
||||
" FROM mps_market a" +
|
||||
" LEFT JOIN mps_traffic b ON a.traffic_id=b.traffic_id" +
|
||||
" LEFT JOIN sys_dept e ON a.dept_id = e.dept_id " +
|
||||
" LEFT JOIN business_percentage f ON e.dept_category = f.branch_id" +
|
||||
" LEFT JOIN business_subcategory g ON a.subcategory_id = g.type_id" +
|
||||
@ -81,6 +82,7 @@ public class BIZ020Processor extends AbstractBusinessProcessor {
|
||||
" COUNT(1) * MAX(COALESCE(g.pricing_rule, 1)) * MAX(COALESCE(f.yx_percent, 1)) AS traffic_fine_collection_amount" +
|
||||
" FROM mps_market a" +
|
||||
" LEFT JOIN sys_dept e ON a.dept_id = e.dept_id " +
|
||||
" LEFT JOIN mps_traffic b ON a.traffic_id=b.traffic_id" +
|
||||
" LEFT JOIN business_percentage f ON e.dept_category = f.branch_id" +
|
||||
" LEFT JOIN business_subcategory g ON a.subcategory_id = g.type_id" +
|
||||
" WHERE " +
|
||||
|
Loading…
Reference in New Issue
Block a user