PageRenderTime 30ms CodeModel.GetById 22ms RepoModel.GetById 0ms app.codeStats 0ms

/sh/BillingCHK.sh_940315bk

http://cport.googlecode.com/
Korn Shell | 747 lines | 723 code | 22 blank | 2 comment | 7 complexity | a52a68022d526bc35f7ea38222d366b1 MD5 | raw file
  1. #! /bin/ksh
  2. . /osms_d1/ratedata/.profile
  3. cd /osms_d1/ratedata/BILLING/CHK
  4. echo "cd /osms_d1/ratedata/BILLING/CHK"
  5. chktime=$(gawk 'BEGIN {printf("%s\n",strftime("%Y%m%d",systime()))}');
  6. exec 1> /osms_d1/ratedata/BILLING/CHK/BillingCHK$chktime.log
  7. exec 2> /osms_d1/ratedata/BILLING/CHK/BillingCHK$chktime.err
  8. if (( $#!=5 )); then
  9. echo "*********************************************************************************"
  10. echo "* Author: ?? *****"
  11. echo "* Object: For Check Billing Data *"
  12. echo "* BillingCHK.sh billing_period billing_cycle BillingBeginDate BillingEndDate DB*"
  13. echo "* BillingCHK.sh 200207 02 20020625 20020724 *"
  14. echo "*********************************************************************************"
  15. exit
  16. elif (( $#==5 )); then
  17. billing_period=$1
  18. billing_cycle=$2
  19. BeginDate=$3
  20. EndDate=$4
  21. DB=$5
  22. BegingDatetime="$BeginDate 00:00:00"
  23. EndDatetime="$EndDate 23:59:59"
  24. fi
  25. if [[ $DB = PROD ]]; then
  26. connectStr="fibills/fibills@osms"
  27. elif [[ $DB = DEMO ]]; then
  28. connectStr="fibills/billsdemo@demo"
  29. elif [[ $DB = ITTEST ]]; then
  30. connectStr="fibills/itosms02@itosms02"
  31. elif [[ $DB = DEMO2 ]]; then
  32. connectStr="fibills/demo2@demo2"
  33. fi
  34. echo $connectStr
  35. ##sqlplus "fibills/billsdemo@demo" <<END
  36. sqlplus "$connectStr" <<END
  37. set verify off
  38. set pagesize 50000
  39. set time on
  40. --set linesize 200
  41. spool $BILLING/CHK/BillingCHK$chktime.txt
  42. ---?????? Begin ---
  43. ---??ID???????? ---'
  44. select b.subscr_nbr, b.phone_nbr, b.cust_id, b.user_catg
  45. from cw_tb_subscr_mbl b
  46. where b.user_catg in ('BUS','PVPN')
  47. and ((length(b.cust_id) != 8) or ( nvl(sex_indic,'x') <> 'C'));
  48. --- ??ID???????? ---'
  49. select a.subscr_nbr, a.phone_nbr, a.cust_id, a.user_catg, a.sex_indic
  50. from cw_tb_subscr_mbl a
  51. where a.user_catg = 'CITIZ'
  52. and ( length(a.cust_id) != 10
  53. or decode(substr(a.cust_id, 2, 1), '1', 'M', '2', 'F') != a.SEX_INDIC );
  54. ---?????????????????. ---'
  55. select a.subscr_nbr, a.phone_nbr, a.acct_id, a.acct_nme,
  56. a.PAYMENT_METHOD, a.PAYMENT_METHOD_ORG
  57. from cw_tb_accts a
  58. where ((a.PAYMENT_METHOD is null) or (a.PAYMENT_METHOD_ORG is null));
  59. --- ???? billing_cycle ??? 01 cycle ? ---
  60. select a.subscr_nbr, a.phone_nbr, a.cust_id, a.user_catg ,a.billing_cycle
  61. from cw_tb_subscr_mbl a
  62. where a.user_catg = 'BUS'
  63. and a.svc_status = 'ACTV'
  64. and length(a.cust_id) = 8
  65. and a.billing_cycle <> '01'
  66. and a.subscr_nbr not in ('00980676') ;
  67. ---sample18 ??ID???????? ---'
  68. select b.subscr_nbr, b.phone_nbr, b.cust_id, b.user_catg
  69. from cw_tb_subscr_mbl b
  70. where b.user_catg = 'BUS'
  71. and length(b.cust_id) != 8;
  72. ---sample19 ??ID???????? ---'
  73. select a.subscr_nbr, a.phone_nbr, a.cust_id, a.user_catg, a.sex_indic
  74. from cw_tb_subscr_mbl a
  75. where a.user_catg = 'CITIZ'
  76. and ( length(a.cust_id) != 10
  77. or decode(substr(a.cust_id, 2, 1), '1', 'M', '2', 'F') != a.SEX_INDIC );
  78. ---sample20 ??????????---'
  79. select b.subscr_nbr, b.phone_nbr, b.sex_indic , b.user_catg
  80. from cw_tb_subscr_mbl b
  81. where ( (sex_indic = 'C' and user_catg not in ('BUS','PVPN'))
  82. or (sex_indic = 'M' and user_catg in ( 'BUS','PVPN'))
  83. or (sex_indic = 'F' and user_catg in ( 'BUS','PVPN')) );
  84. ---????,???????---
  85. ---(??02 cycle ? 00980676???90??????)---
  86. select BILLING_CYCLE, USER_CATG, SEX_INDIC , COUNT(*) from cw_tb_subscr_mbl
  87. WHERE billing_cycle = '$billing_cycle'
  88. AND ((OUT_SVC_DATE IS NULL) OR (OUT_SVC_DATE > SYSDATE -90))
  89. AND SUBSCR_NBR != '00980676'
  90. GROUP BY BILLING_CYCLE, USER_CATG, SEX_INDIC
  91. ORDER BY BILLING_CYCLE, USER_CATG, SEX_INDIC ;
  92. ---sample21 ???????????,??????? ---'
  93. select b.subscr_nbr, b.phone_nbr, b.payment_method_org, b.bank_acct_nbr_org
  94. from cw_tb_accts b
  95. where b.payment_method_org != 'CASH'
  96. AND b.BANK_ACCT_NBR_org IS NULL;
  97. ---sample21_2 ???????????,??????? ---'
  98. select b.subscr_nbr, b.phone_nbr, b.payment_method, b.bank_acct_nbr
  99. from cw_tb_accts b
  100. where b.payment_method != 'CASH'
  101. AND b.BANK_ACCT_NBR IS NULL;
  102. ---sample22 ?????????,??????? ---'
  103. select b.subscr_nbr,b.phone_nbr, b.payment_method_org, b.bank_acct_nbr_org
  104. from cw_tb_accts b
  105. where b.payment_method_org = 'CASH'
  106. AND b.BANK_ACCT_NBR_org IS not NULL;
  107. ---sample22_2 ?????????,??????? ---'
  108. select b.subscr_nbr,b.phone_nbr, b.payment_method, b.bank_acct_nbr
  109. from cw_tb_accts b
  110. where b.payment_method = 'CASH'
  111. AND b.BANK_ACCT_NBR IS not NULL;
  112. ---sample23 ?????????????????????? ---'
  113. select b.subscr_nbr, a.phone_nbr, a.cust_nme, b.acct_nme
  114. from cw_tb_subscr_mbl a, cw_tb_accts b
  115. where a.subscr_nbr = b.subscr_nbr
  116. and a.cust_nme != b.acct_nme;
  117. ---??accts?mbl??
  118. select subscr_nbr from cw_tb_accts
  119. minus
  120. select subscr_nbr from cw_tb_subscr_mbl ;
  121. ---??mbl?accts??
  122. select subscr_nbr from cw_tb_subscr_mbl
  123. minus
  124. select subscr_nbr from cw_tb_accts ;
  125. ---??mbl?mon_item??
  126. select distinct subscr_nbr from cw_tb_subscr_mbl
  127. minus
  128. select distinct subscr_nbr from cw_tb_subscr_mon_item;
  129. ---??mon_item?mbl??
  130. select distinct subscr_nbr from cw_tb_subscr_mon_item
  131. minus
  132. select distinct subscr_nbr from cw_tb_subscr_mbl;
  133. ---cw_tb_subscr_plan,cw_tb_subscr_package???????? ---
  134. ---2001/07???????---
  135. --select a.subscr_nbr, a.package_cde , to_char(a.plan_eff_date,'yyyymmdd hh24:mi:ss') ,
  136. -- to_char(b.sp_eff_date,'yyyymmdd hh24:mi:ss')
  137. --from cw_tb_subscr_plan a , cw_tb_subscr_package b
  138. --where a.subscr_nbr=b.subscr_nbr
  139. -- and a.package_cde=b.package_cde
  140. -- and to_char(a.plan_eff_date,'yyyymmdd') != to_char(b.sp_eff_date, 'yyyymmdd');
  141. --?? 567???? ????---
  142. select * from cw_tb_call_dtl@dblink_rating
  143. where billing_period = '$billing_period'
  144. and billing_cycle = '$billing_cycle'
  145. and rate_area_cde in ('I23','I24')
  146. and call_duration = 0;
  147. ---????????????---
  148. SELECT cp_id, cp_sub_id, rate_seq, count(*)
  149. FROM CW_TB_MTYPE_VALUE_ADD_REC
  150. WHERE trunc(eff_date) <= TO_DATE('$EndDate','YYYYMMDD')
  151. and ((end_date is null) or (trunc(end_date) >= TO_DATE('$BeginDate','YYYYMMDD')))
  152. and cp_id||cp_sub_id||rate_seq not in (select cp_id||cp_sub_id||rate_seq
  153. from cw_tb_content
  154. where pay_type='MON')
  155. GROUP By cp_id, cp_sub_id, rate_seq;
  156. ---?????,?????---
  157. select subscr_nbr ,cp_id ,cp_sub_id ,rate_seq , cp_sub_dir_id , count(*)
  158. from CW_TB_MTYPE_VALUE_ADD_REC
  159. where end_date is null
  160. group by subscr_nbr ,cp_id ,cp_sub_id ,rate_seq , cp_sub_dir_id
  161. having count(*) >1;
  162. ---?????,????? 2 ---
  163. select count(*)
  164. from CW_TB_MTYPE_VALUE_ADD_REC a
  165. , CW_TB_MTYPE_VALUE_ADD_REC b
  166. , cw_tb_subscr_mbl c
  167. where a.subscr_nbr = b.subscr_nbr
  168. and a.cp_id = b.cp_id
  169. and a.cp_sub_id = b.cp_sub_id
  170. and nvl(a.cp_sub_dir_id,'0')=nvl(b.cp_sub_dir_id,'0')
  171. and a.rate_seq = b.rate_seq
  172. and a.end_date is not null
  173. and b.end_date is null
  174. and b.eff_date < a.end_date
  175. and b.subscr_nbr= c.subscr_nbr
  176. and a.eff_date >= to_date('$BeginDate','YYYYMMDD') ;
  177. ---?????,????? 3 ---
  178. SELECT CP_ID, CP_SUB_ID, NVL(CP_SUB_DIR_ID,'0'), SUBSCR_NBR, COUNT(*)
  179. FROM CW_TB_MTYPE_VALUE_ADD_REC
  180. WHERE END_DATE IS NULL
  181. GROUP BY CP_ID, CP_SUB_ID, NVL(CP_SUB_DIR_ID,'0'), SUBSCR_NBR
  182. HAVING COUNT(*) > 1 ;
  183. ---????????????---
  184. select distinct cp_id, cp_sub_id
  185. from cw_tb_subscr_usage_ctl
  186. where billing_period='$billing_period'
  187. and billing_cycle = '$billing_cycle'
  188. and cp_id||cp_sub_id||rate_seq not in
  189. (select cp_id||cp_sub_id||rate_seq
  190. from cw_tb_content WHERE PAY_TYPE !='MON'
  191. and trunc(service_eff_time) <= TO_DATE('$EndDate','YYYYMMDD')
  192. and (service_end_time is null
  193. or TO_DATE('$BeginDate','YYYYMMDD') <= trunc(service_end_time)));
  194. --????????????,???????--
  195. select distinct cp_id, cp_sub_id
  196. from cw_tb_subscr_usage_ctl
  197. where billing_period='$billing_period'
  198. and billing_cycle = '$billing_cycle'
  199. and cp_id||cp_sub_id||rate_seq not in
  200. (select cp_id||cp_sub_id||rate_seq
  201. from cw_tb_content WHERE PAY_TYPE !='MON');
  202. --???content???cw_tb_usage_ctl
  203. SELECT cp_id, cp_sub_id, count(*) ,sum(amount_count), sum(usage_count)
  204. FROM CW_TB_SUBSCR_USAGE_CTL A
  205. WHERE BILLING_PERIOD='$billing_period'
  206. and BILLING_CYCLE = '$billing_cycle'
  207. AND EXISTS (SELECT * FROM CW_TB_CONTENT
  208. WHERE CP_ID=A.CP_ID
  209. AND CP_SUB_ID=A.CP_SUB_ID
  210. AND RATE_SEQ=A.RATE_SEQ
  211. AND SERVICE_END_time <TO_DATE('$BeginDate','YYYYMMDD')
  212. and pay_type = 'USAGE')
  213. GROUP By cp_id, cp_sub_id;
  214. -- ???
  215. --New
  216. select area_cde,phone_nbr,si_svc_item,chgit_cde,
  217. acct_nbr,mon_rate_org,si_eff_date,si_end_date,
  218. nvl(mon_fee_day_indic,'N') mon_fee_day_indic,
  219. nvl(mon_fee_days,0) mon_fee_days,rowid
  220. from cw_tb_subscr_svcit a
  221. where subscr_nbr in (select subscr_nbr from cw_tb_subscr_mbl
  222. where billing_cycle='$billing_cycle')
  223. and a.si_eff_date <= to_date('$EndDatetime','yyyymmddhh24:mi:ss')
  224. and ((a.si_end_date >= to_date('$BegingDatetime','yyyymmddhh24:mi:ss') or (a.si_end_date is null)))
  225. and a.mon_rate_org is not null
  226. and not exists (select * from cw_tb_fix_rate
  227. where chgit_cde=a.chgit_cde
  228. and RATE_CDE=a.mon_rate_org) ;
  229. --subscr_mon_item
  230. select a.* from cw_tb_subscr_mon_item a
  231. where subscr_nbr in (select subscr_nbr from cw_tb_subscr_mbl
  232. where billing_cycle='$billing_cycle')
  233. and a.EFF_DATE <= to_date('$EndDatetime','yyyymmddhh24:mi:ss')
  234. and ((a.END_DATE >= to_date('$BegingDatetime','yyyymmddhh24:mi:ss') or (a.END_DATE is null)))
  235. and a.MON_RATE is not null
  236. and not exists (select * from cw_tb_fix_rate
  237. where chgit_cde=a.PACKAGE_TYPE
  238. and RATE_CDE=a.MON_RATE) ;
  239. -- MON_RATE IS NULL
  240. select a.* from cw_tb_subscr_mon_item a
  241. where a.MON_RATE is null;
  242. --???????,???????????
  243. select a.subscr_nbr, count(*) from cw_tb_subscr_mon_item a
  244. where subscr_nbr in (select subscr_nbr from cw_tb_subscr_mbl
  245. where billing_cycle='$billing_cycle')
  246. and a.EFF_DATE <= to_date('$EndDatetime','yyyymmddhh24:mi:ss')
  247. and ((a.END_DATE >= to_date('$BegingDatetime','yyyymmddhh24:mi:ss') or (a.END_DATE is null)))
  248. and a.MON_RATE is not null
  249. group by a.subscr_nbr
  250. having count(*) > '1' ;
  251. --??????,? billing_period ??????
  252. select count(*) from cw_tb_subscr_mbl
  253. where billing_cycle = '$billing_cycle'
  254. and subscr_nbr in ( select subscr_nbr from CW_TB_SUBSCR_BILL_ITEM
  255. where billing_period = '$billing_period' );
  256. --???,?????,? billing_period ??????
  257. select subscr_nbr, count(*) from cw_tb_subscr_mbl
  258. where billing_cycle = '$billing_cycle'
  259. and subscr_nbr in ( select subscr_nbr from CW_TB_EMP_PAY
  260. where billing_period = '$billing_period' )
  261. group by subscr_nbr
  262. having count(*) > 1 ;
  263. --?? EMAIL ??1000 ?
  264. select count(*) from cw_tb_call_dtl@dblink_rating
  265. where billing_period = '$billing_period'
  266. and billing_cycle = '$billing_cycle'
  267. and svc_item = 'EMAIL'
  268. and call_duration > '1000';
  269. --?????????
  270. --A. MBL ??????????
  271. select subscr_nbr, BILLING_CYCLE, B_CITY, B_DISTRICT, B_ADDRESS1
  272. from cw_tb_subscr_mbl
  273. where ((B_CITY is null) or (B_DISTRICT is null) or (B_ADDRESS1 is null)) ;
  274. --A_1. MBL ??????????
  275. select subscr_nbr, BILLING_CYCLE, B_CITY, B_DISTRICT, B_ADDRESS1, NVL(B_ZIP_CDE,'NULL') B_ZIP_CDE
  276. from cw_tb_subscr_mbl
  277. where ((B_CITY is null) or (B_DISTRICT is null) or (B_ADDRESS1 is null) OR (B_ZIP_CDE IS NULL));
  278. --A_2. MBL org??????????
  279. -------???,??????????.
  280. select count(*)
  281. from cw_tb_subscr_mbl m
  282. where ((m.B_CITY_ORG is null) or (m.B_DISTRICT_ORG is null) or (m.B_ADDRESS1_ORG is null) or (m.B_ZIP_CDE_ORG is null))
  283. and m.subscr_nbr in (
  284. select subscr_nbr
  285. from cw_tb_subscr_mbl
  286. where billing_cycle = '$billing_cycle'
  287. and in_svc_date <= to_date('$EndDatetime','yyyymmdd hh24:mi:ss')
  288. and ((out_svc_date is null) or (out_svc_date >= to_date('$BegingDatetime','yyyymmdd hh24:mi:ss')))
  289. union
  290. select sm.subscr_nbr
  291. from cw_tb_subscr_mbl sm, cw_tb_subscr_billing_term sbt
  292. where sm.subscr_nbr = sbt.subscr_nbr
  293. and billing_period = '$billing_period'
  294. and sm.billing_cycle = '$billing_cycle'
  295. union
  296. select subscr_nbr
  297. from cw_tb_subscr_mbl b
  298. where billing_cycle = '$billing_cycle'
  299. and out_svc_date is not null
  300. and out_svc_date < to_date('$BegingDatetime','yyyymmdd hh24:mi:ss')
  301. and exists (select 'x' from cw_tb_subscr_adj
  302. where subscr_nbr=b.subscr_nbr
  303. and billing_period='$billing_period'
  304. and adj_type is not null)
  305. union
  306. select subscr_nbr
  307. from cw_tb_subscr_mbl c
  308. where billing_cycle = 'billing_cycle'
  309. and out_svc_date is not null
  310. and out_svc_date < to_date('$BegingDatetime','yyyymmdd hh24:mi:ss')
  311. and exists (select 'x' from cw_tb_acct_payment
  312. where acct_nbr=c.acct_nbr
  313. and billing_period='$billing_period')
  314. ) ;
  315. --B. ACCTS ??????????
  316. select subscr_nbr, BILLING_CYCLE, CITY, DISTRICT, ADDRESS1
  317. from cw_tb_accts
  318. where CITY is null ;
  319. --C. ACCTS ??????????
  320. select subscr_nbr, BILLING_CYCLE, R_CITY, R_DISTRICT, R_ADDRESS1
  321. from cw_tb_accts
  322. where R_CITY is null ;
  323. --D. MBL & LOOKUP_CDE ??????
  324. select distinct B_CITY from CW_TB_SUBSCR_MBL
  325. MINUS
  326. select distinct LOOKUP_CDE from CW_TB_LOOKUP_CDE
  327. where lookup_type='CITY'
  328. and DSCR is not null ;
  329. --D_2. MBL B_CITY_ORG.ORG & LOOKUP_CDE ??????
  330. select distinct B_CITY_ORG from CW_TB_SUBSCR_MBL
  331. MINUS
  332. select distinct LOOKUP_CDE from CW_TB_LOOKUP_CDE
  333. where lookup_type='CITY'
  334. and DSCR is not null ;
  335. --D_3. MBL B_CITY_ORG.ORG & LOOKUP_CDE ??????
  336. -------???,???????? B_CITY_ORG ??
  337. select count(*)
  338. from (
  339. select distinct B_CITY_ORG from CW_TB_SUBSCR_MBL
  340. where billing_cycle = '$billing_cycle'
  341. and in_svc_date <= to_date('$EndDatetime','yyyymmdd hh24:mi:ss')
  342. MINUS
  343. select distinct LOOKUP_CDE from CW_TB_LOOKUP_CDE
  344. where lookup_type='CITY'
  345. and DSCR is not null
  346. );
  347. --D_4 ???????? 5 ? :
  348. SELECT * FROM CW_TB_SUBSCR_MBL
  349. WHERE ((length(B_ZIP_CDE) > 5) or (length(B_ZIP_CDE_org) > 5)) ;
  350. --cw_tb_invoice_autovoid ???????????--
  351. select billing_period, billing_cycle, cust_id, proc_status
  352. from cw_tb_invoice_autovoid
  353. where billing_cycle !='01'
  354. and proc_status IS NULL;
  355. --CW_TB_SUBSCR_CHGIT TAX_INDIC TAX_RATE IS NULL--
  356. --?????;??Update
  357. --
  358. select count(*)
  359. from cw_tb_subscr_chgit
  360. where billing_period = '$billing_period'
  361. and billing_cycle = '$billing_cycle'
  362. and (tax_indic is null or tax_rate is null);
  363. --Check TAX_INDIC and TAX_RATE value
  364. --?????;??Update
  365. --
  366. select distinct CHRG_CDE, TAX_INDIC, TAX_RATE from cw_tb_subscr_chgit
  367. where billing_period = '$billing_period'
  368. and billing_cycle = '$billing_cycle' ;
  369. --?????,?????????????
  370. --??insert,?????
  371. select * from cw_tb_subscr_billing_term
  372. where billing_period='$billing_period'
  373. and billing_cycle = '$billing_cycle'
  374. order by subscr_nbr ;
  375. --?????,?????????????_2
  376. --??insert,?????
  377. select subscr_nbr, count(*)
  378. from cw_tb_subscr_billing_term
  379. where billing_period='$billing_period'
  380. and billing_cycle = '$billing_cycle'
  381. group by subscr_nbr
  382. having count(*) > 1 ;
  383. -- call_dtl's "BC_CHGIT" and chrg_item's "CHGIT_CDE" not match chk --
  384. --1.
  385. select distinct BC_CHGIT from cw_tb_call_dtl@dblink_rating
  386. where billing_period = '$billing_period'
  387. and billing_cycle = '$billing_cycle'
  388. minus
  389. select CHGIT_CDE from cw_tb_chrg_item ;
  390. --2.
  391. select A.BC_CHGIT
  392. from (
  393. select distinct BC_CHGIT from cw_tb_call_dtl@dblink_rating
  394. where billing_period = '$billing_period'
  395. and billing_cycle = '$billing_cycle'
  396. union
  397. select distinct BC_CHGIT from cw_tb_smpay_call_dtl@dblink_rating
  398. where billing_period = '$billing_period'
  399. and billing_cycle = '$billing_cycle'
  400. union
  401. select distinct BC_CHGIT from cw_tb_merch_dtl@dblink_rating
  402. where billing_period = '$billing_period'
  403. and billing_cycle = '$billing_cycle'
  404. ) A
  405. minus
  406. select CHGIT_CDE from cw_tb_chrg_item ;
  407. -- ????,????????? --
  408. select count(*) from cw_tb_merch_dtl@dblink_rating
  409. where billing_period = '$billing_period'
  410. and billing_cycle = '$billing_cycle' ;
  411. ----??90?????????? ----
  412. SELECT SUBSCR_NBR , COUNT(*) FROM CW_TB_STOP_MON
  413. where smon_st_date<=to_date('$EndDatetime','yyyymmdd hh24:mi:ss')
  414. and (smon_ed_date>=to_date('$BegingDatetime','yyyymmdd hh24:mi:ss') or smon_ed_date is null)
  415. GROUP BY SUBSCR_NBR
  416. HAVING COUNT(*) > '1' ;
  417. ---- ??????,?ADJ_TYPE???????. ----
  418. select SUBSCR_NBR,BILLING_PERIOD,ADJ_TYPE,count(*) from cw_tb_subscr_adj
  419. where billing_period = '$billing_period'
  420. group by SUBSCR_NBR,BILLING_PERIOD,ADJ_TYPE
  421. having count(*) > 1 ;
  422. ---- ??????,subscr_adj ? subscr_agj_dtl ????? ----
  423. select a.subscr_nbr, a.billing_period, c.billing_cycle, a.adj_type, a.balance, b.adj_amt
  424. from (
  425. select subscr_nbr, billing_period, adj_type, sum(balance) balance from cw_tb_subscr_adj
  426. where billing_period = '$billing_period'
  427. group by subscr_nbr, billing_period, adj_type
  428. order by subscr_nbr
  429. ) a ,
  430. (
  431. select subscr_nbr, billing_period, adj_type, sum(adj_amt) adj_amt from cw_tb_subscr_adj_dtl
  432. where billing_period = '$billing_period'
  433. group by subscr_nbr, billing_period, adj_type
  434. order by subscr_nbr
  435. ) b,
  436. cw_tb_subscr_mbl c
  437. where a.subscr_nbr = b.subscr_nbr
  438. and a.billing_period = b.billing_period
  439. and a.adj_type = b.adj_type
  440. and a.balance <> b.adj_amt
  441. and a.subscr_nbr = c.subscr_nbr ;
  442. ---- ??????? ----
  443. select a.subscr_nbr,c.phone_nbr,b.billing_cycle,c.billing_cycle
  444. from cw_tb_cinf_wo a,
  445. (select subscr_nbr,billing_cycle from cw_tb_nsvc_wo) b,
  446. (select subscr_nbr,phone_nbr,billing_cycle from cw_tb_subscr_mbl) c
  447. where a.subscr_nbr=b.subscr_nbr
  448. and a.subscr_nbr=c.subscr_nbr
  449. and a.fr_cust_id is not null
  450. and a.to_cust_id is not null
  451. and trunc(a.wo_date) > sysdate-30
  452. and a.wo_issuer like 'CR%'
  453. and b.billing_cycle<>c.billing_cycle ;
  454. ---- ??????????????45? ----
  455. SELECT subscr_nbr,phone_nbr,cust_nme,cust_id,
  456. in_svc_date,package_cde,package_grp,
  457. emp_dept,emp_nbr,package_catg,svc_status
  458. FROM cw_tb_subscr_mbl
  459. WHERE cust_id = '16080042'
  460. AND package_cde !='007'
  461. AND svc_status NOT IN ('TERM','COWN','LOST','DETE','TEDE')
  462. AND SUBSCR_NBR NOT IN
  463. (
  464. '01708887','01708888','01708889','01708890','01708891',
  465. '01708892','01708893','01708894','01708895','01708896',
  466. '01708897','01708898','01708899','01708900','01708901',
  467. '01708902','01708903','01708904','01708905','01708906',
  468. '01708907','01708908','01708909','01708910','01708911',
  469. '01708912','01708913','01708914','01708915','01708919',
  470. '01708920','01708921','01708922','01708923','01708924',
  471. '01708925','01708926','01708927','01708928','01708929',
  472. '01708930','01708931','01708932','01717951','01766183'
  473. );
  474. ----????????????????? ----
  475. --SELECT SUBSCR_NBR, PACKAGE_CDE, COUNT(*) FROM CW_TB_SUBSCR_PACKAGE
  476. --where SP_EFF_DATE <= to_date('$EndDatetime','yyyymmdd hh24:mi:ss')
  477. --and ((SP_END_DATE >= to_date('$BegingDatetime','yyyymmdd hh24:mi:ss')) or (SP_END_DATE is null))
  478. --GROUP BY SUBSCR_NBR, PACKAGE_CDE
  479. --HAVING COUNT(*) > '1' ;
  480. ----????????????,????----
  481. ----???(DEMO)??????,???????----
  482. ----cw_tb_subscr_bill.unapid_amt update ? '0',???????. ----
  483. select a.subscr_nbr, b.billing_period, a.ovpay_amt, b.unpaid_amt
  484. from cw_tb_subscr_mbl a, cw_tb_subscr_bill b
  485. where a.billing_cycle='$billing_cycle'
  486. and a.subscr_nbr=b.subscr_nbr
  487. and a.billing_cycle=b.billing_cycle
  488. and a.ovpay_amt > '0'
  489. and b.unpaid_amt > '0'
  490. order by a.subscr_nbr ;
  491. ----????????????,????----
  492. ----???(DEMO)??????,???????----
  493. ----cw_tb_subscr_mbl.balance update ? '0',???????. ----
  494. select billing_cycle, subscr_nbr, balance, OVPAY_AMT
  495. from cw_tb_subscr_mbl
  496. where billing_cycle='$billing_cycle'
  497. and nvl(OVPAY_AMT,0) <> 0
  498. and nvl(balance,0) <> 0
  499. order by billing_cycle, subscr_nbr ;
  500. --RBT ???
  501. SELECT DISTINCT MONTH_FEE
  502. FROM CW_TB_SMPAY_MTYPE ;
  503. --RBT ??????????.
  504. select a.SUBSCR_NBR, a.BC_CHGIT, a.EFF_DATE, a.END_DATE
  505. from cw_tb_smpay_mtype a
  506. , (
  507. select subscr_nbr, to_date(to_char(end_date,'yyyy/mm/dd hh24'),'yyyy/mm/dd hh24') end_date , count(*) from cw_tb_smpay_mtype
  508. where service_item='RBT'
  509. and end_date is not null
  510. and end_date > to_date('$BegingDatetime','yyyymmdd hh24:mi:ss')
  511. group by subscr_nbr, end_date
  512. having count(*) > 1
  513. UNION
  514. select subscr_nbr, end_date, count(*) from cw_tb_smpay_mtype
  515. where service_item='RBT'
  516. and end_date is null
  517. group by subscr_nbr, end_date
  518. having count(*) > 1
  519. ) b
  520. where a.subscr_nbr=b.subscr_nbr
  521. order by a.subscr_nbr ;
  522. --- CHRG_CDE W10, NBRFE (??)???????. --
  523. select BILLING_CYCLE, subscr_nbr, CHRG_CDE, to_char(CHRG_DATE,'yyyy/mm/dd hh24:mi') CHRG_DATE, count(*) from cw_tb_subscr_chgit
  524. where billing_period = '$billing_period'
  525. and billing_cycle='$billing_cycle'
  526. and batch_nbr is null
  527. and chrg_cde <> 'CDRPR'
  528. GROUP BY BILLING_CYCLE, subscr_nbr, CHRG_CDE, to_char(CHRG_DATE,'yyyy/mm/dd hh24:mi')
  529. HAVING COUNT(*) > 1
  530. ORDER BY BILLING_CYCLE, subscr_nbr, CHRG_CDE;
  531. --?????? CHRG_CDE = 'PEN01'
  532. --2005/02/14 add by james
  533. select subscr_nbr
  534. from cw_tb_subscr_pen
  535. where ( (CHRG_CDE is null) or (CHRG_CDE <> 'PEN01') ) ;
  536. --????????????????
  537. --2005/02/14 add by james
  538. select subscr_nbr, count(*)
  539. from cw_tb_subscr_pen
  540. group by subscr_nbr
  541. having count(*) > 1 ;
  542. --???????????
  543. --select a.subscr_nbr, a.pen_mon, a.pen_amt
  544. --from cw_tb_subscr_pen a, cw_tb_subscr_mbl b
  545. --where a.subscr_nbr = b.subscr_nbr
  546. -- and a.billing_period = '$billing_period'
  547. -- and b.billing_cycle='$billing_cycle'
  548. -- and a.PEN_PAY_TYPE = 'OSMS';
  549. --??????
  550. select '??????? : '|| a.billing_period || ' - ' || a.billing_cycle "????" ,
  551. '???? : '||b.due_date DUE_DATE
  552. from cw_tb_aut_billing_cycle_prd a , cw_tb_billing_cycle b
  553. where a.due_date is null
  554. and a.billing_cycle=b.billing_cycle;
  555. --???????
  556. select '????? : '||GLOBAL_NAME "DB_name"
  557. from global_name ;
  558. ---?????? END ---
  559. spool off;
  560. exit;
  561. END
  562. mailx -s "${billing_period}bc${billing_cycle}${DB} BillingCHK Report" kuo@fitel.net.tw < $BILLING/CHK/BillingCHK$chktime.txt
  563. mailx -s "${billing_period}bc${billing_cycle}${DB} BillingCHK Report" jamesy2@fitel.net.tw < $BILLING/CHK/BillingCHK$chktime.txt
  564. mailx -s "${billing_period}bc${billing_cycle}${DB} BillingCHK Report" lisa@fitel.net.tw < $BILLING/CHK/BillingCHK$chktime.txt
  565. mailx -s "${billing_period}bc${billing_cycle}${DB} BillingCHK Report" sean@fitel.net.tw < $BILLING/CHK/BillingCHK$chktime.txt
  566. mailx -s "${billing_period}bc${billing_cycle}${DB} BillingCHK Report" hank@fitel.net.tw < $BILLING/CHK/BillingCHK$chktime.txt
  567. mailx -s "${billing_period}bc${billing_cycle}${DB} BillingCHK Report" eric1002@fitel.net.tw < $BILLING/CHK/BillingCHK$chktime.txt
  568. mailx -s "${billing_period}bc${billing_cycle}${DB} BillingCHK Report" grape_c@hotmail.com
  569. < $BILLING/CHK/BillingCHK$chktime.txt