客户对账去掉重复的sql

dev
wuwenxiong 2022-01-12 12:04:19 +08:00
parent 3bad26ca6b
commit 4dc76bea7c
1 changed files with 0 additions and 39 deletions

View File

@ -98,45 +98,6 @@ public class CustomerStatService {
paraList.add(querytm);
paraList.add(querytm);
sql = "select \n" +
" t.customer_id id,\n" +
" c.`name`,\n" +
" t.surplus,\n" +
" a.total_price,\n" +
" a.total_weight,\n" +
" a.total_cnt,\n" +
" b.amount,\n" +
" b.refund_amount,\n" +
" ifnull(p.presell_amount,0) presell_amount,\n" +
" b.amount - ifnull(a.total_price,0) - b.refund_amount - ifnull(p.presell_amount,0) then_surplus" +
" from prepay_customer t\n" +
" left join customer c on c.id= t.customer_id\n" +
" left join (\n" + tempSql + " ) a on a.customer_id = t.customer_id\n" +
" left join(\n" +
" select a.customer_id, a.amount, ifnull(b.amount, 0) refund_amount\n" +
" from(\n" +
" select t.customer_id, sum(t.amount) amount\n" +
" from prepay_detail t\n" +
" where t.state= 2\n" +
" and t.verify_time <= ?\n" +
" group by t.customer_id\n" +
" ) a\n" +
" left join(\n" +
" select t.customer_id, sum(t.amount) amount from refund_detail t\n" +
" left join (\n" +
" select max(t.change_time) confirm_time, t.refund_detail_id \n" +
" from refund_detail_state_history t \n" +
" where t.state = 3 \n" +
" group by t.refund_detail_id\n" +
" ) a on t.id = a.refund_detail_id\n" +
" where t.state = 3\n" +
" and a.confirm_time <= ?\n" +
" group by t.customer_id\n" +
" ) b on b.customer_id= a.customer_id\n" +
" ) b on b.customer_id= t.customer_id\n" +
" left join (select customer_id, ifnull(sum(presell_amount), 0) presell_amount from presell_order where del = 0 group by customer_id) p\n" +
" on p.customer_id = t.customer_id";
if (customer_type_id != null) { // 客户对账不管临散订单
sql += " where c.customer_type_id = ? \n";
paraList.add(customer_type_id);