伯俊BOS2.0店铺收入对账功能设计

一、客户需求

  通过导入银行POS机流水,将流水与ERP系统的零售付款数据进行对比,统一差异!

  

二、功能设计

  1、新增“POS机号对应表单”,用于维护POS机与erp店仓对应

  

  2、新增“POS机流水导入窗口”,用于记录银行POS流水

  

  3、新增“对账功能”试图,展现结果

  

 4、写试图语句

  

  1 create or replace view store_statements as
  2 select rownum id,
  3        hs.ad_client_id,
  4        hs.ad_org_id,
  5        hs.billdate,
  6        hs.c_store_id,
  7        sum(nvl(tot_amt2,0)) as tot_amt2,
  8        sum(nvl(tot_amt9,0)) as tot_amt9,
  9        sum(nvl(tot_amt16,0)) as tot_amt16,
 10        sum(nvl(tot_amt4,0)) as tot_amt4,
 11        sum(nvl(tot_amt11,0)) as tot_amt11,
 12        sum(nvl(tot_amt18,0)) as tot_amt18,
 13        sum(nvl(tot_amt3,0)) as tot_amt3,
 14        sum(nvl(tot_amt17,0)) as tot_amt17,
 15        sum(nvl(tot_amt10,0)) as tot_amt10,
 16        sum(nvl(tot_amt15,0)) as tot_amt15,
 17        sum(nvl(tot_amt13,0)) as tot_amt13,
 18        sum(nvl(tot_amt6,0)) as tot_amt6,
 19        sum(nvl(tot_amt8,0)) as tot_amt8,
 20        sum(nvl(tot_amt19,0)) as tot_amt19,
 21        sum(nvl(tot_amt24,0)) as tot_amt24,
 22        sum(nvl(tot_amt25,0)) as tot_amt25,
 23        sum(nvl(tot_amt23,0)) as tot_amt23,
 24        sum(nvl(tot_amt21,0)) as tot_amt21,
 25        sum(nvl(tot_amt27,0)) as tot_amt27,
 26        sum(nvl(tot_amt17,0)) as tot_amt28,
 27        sum(nvl(tot_amt22,0)) as tot_amt22
 28   from (
 29   --零售付款明细
 30   select a.ad_client_id,
 31                a.ad_org_id,
 32                c.billdate,
 33                c.c_store_id,
 34                sum(decode(a.c_payway_id, 2, nvl(a.payamount, 0))) as tot_amt2,
 35                sum(decode(a.c_payway_id, 5, nvl(a.payamount, 0))) as tot_amt9,
 36                sum(decode(a.c_payway_id, 4, nvl(a.payamount, 0))) as tot_amt16,
 37                 sum(decode(a.c_payway_id, 3, nvl(a.payamount, 0))) as tot_amt19,
 38                 sum(decode(a.c_payway_id, 8, nvl(a.payamount, 0))) as tot_amt24,
 39                 sum(decode(a.c_payway_id, 7, nvl(a.payamount, 0))) as tot_amt25
 40           from m_retailpayitem a, m_retail c
 41          where a.m_retail_id = c.id
 42            --and c.billdate > '20200331'
 43         --and c.c_store_id = 917
 44          group by a.ad_client_id, a.ad_org_id, c.billdate, c.c_store_id) hs
 45 
 46     left join
 47          --零售其它付款明细
 48   (select a.ad_client_id,
 49                a.ad_org_id,
 50                c.billdate,
 51                c.c_store_id,
 52                sum(nvl(a.payamount, 0)) as tot_amt22
 53           from m_retailpayitem a, m_retail c
 54          where a.m_retail_id = c.id
 55         and a.c_payway_id not in (2,3,4,5,7,8)
 56            --and c.billdate > '20200331'
 57         --and c.c_store_id = 917
 58          group by a.ad_client_id, a.ad_org_id, c.billdate, c.c_store_id) qt on  hs.c_store_id = qt.c_store_id   and hs.billdate = qt.billdate
 59   left join
 60   --充值付款明细
 61   (select b.ad_client_id,
 62                     b.ad_org_id,
 63                     b.billdate,
 64                     b.c_store_id,
 65                     sum(decode(a.c_payway_id, 2, nvl(a.payamount, 0))) as tot_amt4,
 66                     sum(decode(a.c_payway_id, 5, nvl(a.payamount, 0))) as tot_amt11,
 67                     sum(decode(a.c_payway_id, 4, nvl(a.payamount, 0))) as tot_amt18,
 68                     sum( nvl(b.tot_amt_actual, 0)) as tot_amt21
 69                from b_vipmoney_payitem a, b_vipmoney b
 70               where a.b_vipmoney_id = b.id
 71                -- and b.billdate > '20200331'
 72                 and b.status = 2
 73              --and b.c_store_id = 917
 74               group by b.ad_client_id, b.ad_org_id, b.billdate, b.c_store_id
 75              union all
 76              select b.ad_client_id,
 77                     b.ad_org_id,
 78                     b.billdate,
 79                     b.c_store_id,
 80                     sum(decode(a.c_payway_id, 2, nvl(a.payamount, 0))) as tot_amt4,
 81                     sum(decode(a.c_payway_id, 5, nvl(a.payamount, 0))) as tot_amt11,
 82                     sum(decode(a.c_payway_id, 4, nvl(a.payamount, 0))) as tot_amt18,
 83                     sum( nvl(b.tot_amt_actual, 0)) as tot_amt21
 84                from b_vip_money_payitem a, b_vip_money b
 85               where a.b_vip_money_id = b.id
 86                 --and b.billdate > '20200331'
 87                 and b.status = 2
 88              --and b.c_store_id = 917
 89               group by b.ad_client_id, b.ad_org_id, b.billdate, b.c_store_id) gs    on hs.c_store_id = gs.c_store_id   and hs.billdate = gs.billdate
 90   left join
 91   --订金付款明细
 92   (select b.ad_client_id,
 93                     b.ad_org_id,
 94                     b.billdate,
 95                     b.c_store_id,
 96                     sum(decode(a.c_payway_id, 2, nvl(a.payamount, 0))) as tot_amt3,
 97                     sum(decode(a.c_payway_id, 5, nvl(a.payamount, 0))) as tot_amt10,
 98                     sum(decode(a.c_payway_id, 4, nvl(a.payamount, 0))) as tot_amt17,
 99                     sum(decode(a.c_payway_id, 3, nvl(a.payamount, 0))) as tot_amt23
100                from m_receipts_payitem a, m_receipts b
101               where a.m_receipts_id = b.id
102                -- and b.billdate > '20200331'
103              --and b.c_store_id = 917
104               group by b.ad_client_id, b.ad_org_id, b.billdate, b.c_store_id) ts    on hs.c_store_id = ts.c_store_id   and hs.billdate = ts.billdate
105 
106                 left join
107   --订金付款明细
108   (select b.ad_client_id,
109                     b.ad_org_id,
110                     b.billdate,
111                     b.c_store_id,
112                     sum( nvl(b.tot_amt, 0)) as tot_amt27
113                from  m_receipts_item b
114               where b.type in('退订','订金')
115                -- and b.billdate > '20200331'
116              --and b.c_store_id = 917
117               group by b.ad_client_id, b.ad_org_id, b.billdate, b.c_store_id) ds    on hs.c_store_id = ds.c_store_id   and hs.billdate = ds.billdate
118   left join
119   --银行流水明细
120    (select 37as ad_client_id,
121                     27 as ad_org_id,
122                     b.c_store_id,
123                     to_number(to_char(to_date(a.trading_hours,
124                                               'yyyy-mm-dd,hh24:mi:ss'),
125                                       'yyyymmdd')) as billdate,
126                     sum(decode(a.payment_channels,
127                                '微信' , nvl(a.total_amount,0))) as TOT_AMT13,
128                     sum(decode(a.payment_channels,
129                                '微信' , nvl(a.poundage,0))) as TOT_AMT15,
130                     sum(decode(a.payment_channels,
131                                '刷卡支付' , nvl(a.total_amount,0))) as TOT_AMT6,
132                     sum(decode(a.payment_channels,
133                                '刷卡支付' , nvl(a.poundage,0))) as TOT_AMT8
134                from merchants_statementsitem a
135                left join shop_pos b
136                  on a.terminal_no = b.pos_no
137               group by 37,
138                        27,
139                        to_char(to_date(a.trading_hours,
140                                        'yyyy-mm-dd,hh24:mi:ss'),
141                                'yyyymmdd'),
142                        b.c_store_id) ls    on hs.c_store_id = ls.c_store_id and hs.billdate = ls.billdate
143  group by rownum, hs.ad_client_id, hs.ad_org_id, hs.billdate, hs.c_store_id
144  order by hs.c_store_id desc, hs.billdate
145 ;

  

猜你喜欢

转载自www.cnblogs.com/zhrw0628/p/12703387.html