- 浏览: 101078 次
- 性别:
- 来自: 深圳
文章分类
- 全部博客 (209)
- http://docs.jpush.io/server/java_sdk/ (1)
- SpingMVC ModelAndView (1)
- Model (1)
- Control以及参数传递 (1)
- https://www.alipay.com/ (1)
- 检查指定的字符串列表是否不为空。 (1)
- 转自http://my.oschina.net/rpgmakervx/blog/505434 (1)
- 压缩js (1)
- 含包含 字母数字校验 (1)
- 判断浏览器是ie (1)
- fixbox (0)
- 转自http://www.cnblogs.com/lanzi/archive/2010/10/26/1861338.html (1)
- http://dl2.iteye.com/upload/attachment/0113/2406/afbd8d53-dcad-3afc-8d78-41c1591 (0)
- IDEA (0)
- maven搭建 (0)
- http://www.jeasyuicn.com/api/docTtml/index.htm (1)
- 给tomcat添加运行内存: (1)
- JPUSH推送 (1)
- requestScope (0)
- oracle中plsql安装client10连接数据库 (1)
- 不需要安装oracle11g (1)
- tuikuan (1)
- http://www.hjxmall.com/index.php (1)
- java (1)
- 参考 (1)
- xml签名验签模拟程序 (1)
- 技术网站收集分享 (1)
- Java NIO提供了与标准IO不同的IO工作方式 ------来源于 http://www.iteye.com/magazines/132-Java-NIO (1)
- oracle表查询语句优化 (0)
- oracle (5)
- a (1)
- TenpayHttpClient (2)
- mongodb (1)
- http://www.qcloud.com/product/cmongo.html?utm_source=pcsem1&utm_medium=bdgj46&utm_campaign=baidu (1)
- SpringMVC整合MongoDB开发 (0)
- SpringMVC整合MongoDB开发 https://www.mongodb.org (1)
- Java 语言中常见问题总结 (1)
- 数据库SQL优化大总结 (1)
- 拦截器与过滤器的区别 (1)
- Struts2中拦截器与过滤器的区别及执行顺序 (1)
- Spring声明式事务管理与配置 (0)
- oracle OPERTION (1)
- java 高并发多线程开发 (1)
- Collection 与 map 接口相关集合 (1)
- 多线程开发实践 (1)
- JVM调优总结 转自 http://www.importnew.com/18694.html (1)
- redis 五种数据类型的使用场景 转自于 http://blog.csdn.net/gaogaoshan/article/details/41039581 (1)
- HttpWatch http基础 来自于http://blog.csdn.net/gaogaoshan/article/details/21237555 (1)
- maven 远程仓库 http://blog.csdn.net/gaogaoshan/article/details/40266779 (1)
- 生成Webservice客户端的4中方法 http://blog.csdn.net/gaogaoshan/article/details/8980775 (1)
- http://fgh2011.iteye.com/blog/1564283 (1)
- sleep和wait有什么区别 http://xiaowei2002.iteye.com/blog/2174188 (1)
- JDK中常用包及其类 常见的几种RuntimeException (1)
- Java的运行原理 (1)
- mybatis缓存的使用及理解 http://my.oschina.net/dxqr/blog/123163 (1)
- 软件架构设计分析 (1)
- redis技术总结 (3)
- java面试总结知识点 (1)
- ZooKeeper技术 (1)
- Hadoop (1)
- sso单点登录 (1)
- SpringIOC (1)
- 书签ssssssssssssssssssssss (1)
- spring事务的隔离级别 http://www.cnblogs.com/yangy608/archive/2011/06/29/2093478.html (1)
- 秒杀系统架构分析与实战 http://www.importnew.com/18920.html (1)
- oracle 连接plsql配置 (1)
- maven工程集成springmvc http://blog.csdn.net/fox_lht/article/details/16952683 (1)
- java类序列化与反序列化版本唯一号serialVersionUID (1)
- spring注解用法总结 (1)
- eclipse导入maven项目找不到资源文件方法 (1)
- dubbo (0)
- socket 网络编程 服务器与客户端 编程 (1)
- Thread与Runnable实现线程利用线程插队实现求和操作 (1)
- 生产者与消费者模式 (1)
- JAXB注解 java 关于xml的注解,自动生成xml文件 - @XML*** (1)
- xml 与JAVAbean转换 (1)
- MAP (2)
- decimalToString (1)
- 反编译插件 (0)
- 反编译插件 https://sourceforge.net/projects/jadclipse/?source=typ_redirect (1)
- AWX (1)
- 官网地址Dinp (1)
- public interface ExecutorService extends Executor (1)
- MAIN (1)
- 转自于 http://blog.csdn.net/lufeng20/article/details/24314381 (1)
- JaxbUtil (1)
- HttpXmlClient (0)
- Http post 请求 (1)
- URLDecoder (1)
- spdb (0)
- 订单号生成规则 (1)
- 距离0点毫秒数 (1)
- MyBatis存储过程调用java (1)
- Banks (1)
- 学习网址 (1)
- hots配置oracle数据库配置修改 (1)
- 支付宝文档 (1)
- Jadclipse (1)
- filter (0)
- Filter过滤器 (1)
- 工具类 fixbox (1)
- java quartz (0)
- java quartz 实现定时任务,每个礼拜一到礼拜五定时执行 (1)
- Thread (4)
- getResourceAsStream (1)
- BigData (1)
- 开源架构 (17)
- 架构 (0)
- 文件操作 (2)
- tools (20)
- 测试工具 (1)
- vm (1)
- mq (1)
- blog (1)
- 开源架构搭建技术 (6)
- JAVA细节技术点总结 (1)
- 优化技术 (1)
- LINUX命令使用 (1)
- spring (2)
- 大数据 (1)
- struts2 (1)
- python (1)
- pay (1)
- linux (1)
- 压力测试 (1)
- 代码检查插件 (1)
- 游戏端开发 (1)
- 微信开发相关 (1)
- 搜索引擎 (1)
- 网络技术 (1)
- 分布式部署 (1)
- 堆栈信息 (1)
最新评论
CREATE OR REPLACE PROCEDURE PROC_DAY_OVER_CALCULATE AS
V_DAY_IDX DATE;
V_COUNT NUMBER;
V_ORDER_ID VARCHAR2(50);
V_PAYMENT_ORDER_NO VARCHAR2(50);
V_ACCOUNT_NO NUMBER(16);
V_SUBJECT_DR_CR VARCHAR2(4);
V_CASH_AMOUNT NUMBER;
V_FREEZE_AMOUNT NUMBER;
V_OVERDRAFT_AMOUNT_LIMIT NUMBER;
V_CUR_DR_AMOUNT NUMBER;
V_CUR_CR_AMOUNT NUMBER;
V_DR_AMOUNT NUMBER;
V_CR_AMOUNT NUMBER;
V_YESTODAY_CASH_AMOUNT NUMBER;
V_YESTODAY_FREEZE_AMOUNT NUMBER;
V_YESTODAY_OVERDRAFT_AMOUNT NUMBER;
V_YESTODAY_DR_AMOUNT NUMBER;
V_YESTODAY_CR_AMOUNT NUMBER;
V_TEMP_BALANCE NUMBER;
V_ACCRUAL NUMBER;
V_SQL VARCHAR2(255);
V_ERRTEXT VARCHAR2(255);
V_ADJUST NUMBER;
CURSOR CUR_ACC_DR_CR(V_DAY_IDX DATE) IS
SELECT T.ORDER_ID,
R.ACCOUNT_NO,
R.PAYMENT_ORDER_NO,
R.DR_TOTAL,
R.CR_TOTAL
FROM (SELECT T_ACCOUNT_WATER.PAYMENT_ORDER_NO,
T_ACCOUNT_WATER.ACCOUNT_NO,
SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
WHEN 'DR' THEN
T_ACCOUNT_WATER.DR_CR_AMOUNT
END) DR_TOTAL,
SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
WHEN 'CR' THEN
T_ACCOUNT_WATER.DR_CR_AMOUNT
END) CR_TOTAL
FROM T_ACCOUNT_WATER
WHERE T_ACCOUNT_WATER.STATUS = 'SUCCESS'
AND T_ACCOUNT_WATER.ACCOUNT_DATE =
TO_CHAR(V_DAY_IDX, 'yyyyMMdd')
GROUP BY T_ACCOUNT_WATER.PAYMENT_ORDER_NO,
T_ACCOUNT_WATER.ACCOUNT_NO
HAVING SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
WHEN 'DR' THEN
T_ACCOUNT_WATER.DR_CR_AMOUNT
END) <> SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
WHEN 'CR' THEN
T_ACCOUNT_WATER.DR_CR_AMOUNT
END)) R
LEFT JOIN MV_TRADE T
ON R.PAYMENT_ORDER_NO = T.PAYMENT_ID;
CURSOR CUR_ACC_BALANCE(V_DAY_IDX DATE) IS
SELECT RET.ACCOUNT_NO,
RET.SUBJECT_DR_CR,
RET.CASH_AMOUNT,
RET.FREEZE_AMOUNT,
RET.OVERDRAFT_AMOUNT_LIMIT,
RET.CUR_DR_AMOUNT,
RET.CUR_CR_AMOUNT,
RET.DR_AMOUNT,
RET.CR_AMOUNT,
Y_RET.YESTODAY_CASH_AMOUNT,
Y_RET.YESTODAY_FREEZE_AMOUNT,
Y_RET.YESTODAY_OVERDRAFT_AMOUNT,
Y_RET.YESTODAY_DR_AMOUNT,
Y_RET.YESTODAY_CR_AMOUNT
FROM (SELECT T_ACCOUNT.ACCOUNT_NO,
T_ACCOUNT.SUBJECT_DR_CR,
T_ACCOUNT.CASH_AMOUNT,
T_ACCOUNT.FREEZE_AMOUNT,
T_ACCOUNT.OVERDRAFT_AMOUNT_LIMIT,
T_ACCOUNT.DR_AMOUNT CUR_DR_AMOUNT,
T_ACCOUNT.CR_AMOUNT CUR_CR_AMOUNT,
R.DR_AMOUNT,
R.CR_AMOUNT
FROM T_ACCOUNT,
(SELECT SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
WHEN 'DR' THEN
T_ACCOUNT_WATER.DR_CR_AMOUNT
END) DR_AMOUNT,
SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
WHEN 'CR' THEN
T_ACCOUNT_WATER.DR_CR_AMOUNT
END) CR_AMOUNT,
T_ACCOUNT_WATER.ACCOUNT_NO
FROM T_ACCOUNT_WATER
WHERE T_ACCOUNT_WATER.ACCOUNT_DATE =
TO_CHAR(V_DAY_IDX, 'yyyyMMdd')
AND T_ACCOUNT_WATER.STATUS = 'SUCCESS'
GROUP BY T_ACCOUNT_WATER.ACCOUNT_NO) R
WHERE T_ACCOUNT.ACCOUNT_NO = R.ACCOUNT_NO
) RET
LEFT JOIN (SELECT T_ACCOUNT_DAILY.CASH_AMOUNT YESTODAY_CASH_AMOUNT,
T_ACCOUNT_DAILY.FREEZE_AMOUNT YESTODAY_FREEZE_AMOUNT,
T_ACCOUNT_DAILY.OVERDRAFT_AMOUNT_LIMIT YESTODAY_OVERDRAFT_AMOUNT,
T_ACCOUNT_DAILY.DR_AMOUNT YESTODAY_DR_AMOUNT,
T_ACCOUNT_DAILY.CR_AMOUNT YESTODAY_CR_AMOUNT,
T_ACCOUNT_DAILY.ACCOUNT_NO
FROM T_ACCOUNT_DAILY
WHERE T_ACCOUNT_DAILY.ACCOUNT_DATE =
TO_CHAR(V_DAY_IDX - 1, 'yyyyMMdd')) Y_RET
ON RET.ACCOUNT_NO = Y_RET.ACCOUNT_NO;
BEGIN
BEGIN
--当前工作日
SELECT TO_DATE(PARAM_VALUE, 'yyyyMMdd')
INTO V_DAY_IDX
FROM T_DAY_CHANGE
WHERE T_DAY_CHANGE.PARAM_NAME = 'CUR_DAY';
--同一支付流水记账借贷是否平衡
OPEN CUR_ACC_DR_CR(V_DAY_IDX);
--T.ORDER_ID, R.ACCOUNT_NO, R.PAYMENT_ORDER_NO, R.DR_TOTAL, R.CR_TOTAL
FETCH CUR_ACC_DR_CR
INTO V_ORDER_ID,
V_ACCOUNT_NO,
V_PAYMENT_ORDER_NO,
V_DR_AMOUNT,
V_CR_AMOUNT;
WHILE CUR_ACC_DR_CR%FOUND LOOP
---订单是否需要冻结
-- UPDATE T_RECHARGE TR SET TR.SETT_STATE ='FREEZEN' WHERE TR.ORDER_ID=V_ORDER_ID
--将账户冻结
UPDATE T_ACCOUNT
SET T_ACCOUNT.ACCOUNT_STATE = 'FREEZE'
WHERE T_ACCOUNT.ACCOUNT_NO = V_ACCOUNT_NO;
--记录异常日志
INSERT INTO T_ACCOUNT_LOG
(ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
VALUES
(SEQ_ACCOUNT_LOG.NEXTVAL,
'ERROR',
'账户(' || V_ACCOUNT_NO || ')支付流水号为:' || V_PAYMENT_ORDER_NO ||
'借贷不平衡',
CURRENT_TIMESTAMP);
FETCH CUR_ACC_DR_CR
INTO V_ORDER_ID,
V_ACCOUNT_NO,
V_PAYMENT_ORDER_NO,
V_DR_AMOUNT,
V_CR_AMOUNT;
END LOOP;
CLOSE CUR_ACC_DR_CR;
----- 账户当前余额=昨日余额+当日发生额
OPEN CUR_ACC_BALANCE(V_DAY_IDX);
FETCH CUR_ACC_BALANCE
INTO V_ACCOUNT_NO,
V_SUBJECT_DR_CR,
V_CASH_AMOUNT,
V_FREEZE_AMOUNT,
V_OVERDRAFT_AMOUNT_LIMIT,
V_CUR_DR_AMOUNT,
V_CUR_CR_AMOUNT,
V_DR_AMOUNT,
V_CR_AMOUNT,
V_YESTODAY_CASH_AMOUNT,
V_YESTODAY_FREEZE_AMOUNT,
V_YESTODAY_OVERDRAFT_AMOUNT,
V_YESTODAY_DR_AMOUNT,
V_YESTODAY_CR_AMOUNT;
WHILE CUR_ACC_BALANCE%FOUND LOOP
--数据错误则冻结账户
IF V_YESTODAY_DR_AMOUNT > 0 AND V_YESTODAY_CR_AMOUNT = 0 THEN
--余额在DR方
V_TEMP_BALANCE := V_YESTODAY_DR_AMOUNT + V_DR_AMOUNT - V_CR_AMOUNT;
V_ACCRUAL := V_DR_AMOUNT - V_CR_AMOUNT;
IF V_TEMP_BALANCE > 0 THEN
--余额在DR
IF (V_CUR_CR_AMOUNT <> 0 OR V_CUR_DR_AMOUNT <> V_TEMP_BALANCE) THEN
--调整账户余额 账户当前余额=昨日余额+当日发生额
V_ADJUST := 1;
V_ERRTEXT :=V_ACCOUNT_NO||'的DR余额应为:'||V_TEMP_BALANCE||',CR余额应为:0';
CONTINUE;
END IF;
ELSIF V_TEMP_BALANCE < 0 THEN
--余额在CR
IF (V_CUR_DR_AMOUNT <> 0 OR
V_CUR_CR_AMOUNT <> V_TEMP_BALANCE * -1) THEN
--调整账户余额 账户当前余额=昨日余额+当日发生额
V_ADJUST := 1;
V_ERRTEXT :=V_ACCOUNT_NO||'的CR余额应为:'||V_TEMP_BALANCE * -1||',DR余额应为:0';
CONTINUE;
END IF;
END IF;
ELSIF V_YESTODAY_CR_AMOUNT > 0 AND V_YESTODAY_DR_AMOUNT = 0 THEN
--昨日余额在CR方
V_TEMP_BALANCE := V_YESTODAY_CR_AMOUNT + V_CR_AMOUNT - V_DR_AMOUNT;
V_ACCRUAL := V_CR_AMOUNT -V_DR_AMOUNT;
IF V_TEMP_BALANCE > 0 THEN
--余额任在CR
IF (V_CUR_DR_AMOUNT <> 0 OR V_CUR_CR_AMOUNT <> V_TEMP_BALANCE) THEN
V_ADJUST := 1;
V_ERRTEXT :=V_ACCOUNT_NO||'的CR余额应为:'||V_TEMP_BALANCE ||',DR余额应为:0';
CONTINUE;
END IF;
ELSIF V_TEMP_BALANCE < 0 THEN
--余额反向在DR
IF (V_CUR_CR_AMOUNT <> 0 OR
V_CUR_DR_AMOUNT <> V_TEMP_BALANCE * -1) THEN
V_ADJUST := 1;
V_ERRTEXT :=V_ACCOUNT_NO||'的DR余额应为:'||V_TEMP_BALANCE * -1 ||',CR余额应为:0';
CONTINUE;
END IF;
END IF;
ELSIF V_YESTODAY_CR_AMOUNT = 0 AND V_YESTODAY_DR_AMOUNT = 0 THEN
--无昨日余额
V_TEMP_BALANCE := V_CR_AMOUNT - V_DR_AMOUNT;
V_ACCRUAL := V_CR_AMOUNT - V_DR_AMOUNT;
IF V_TEMP_BALANCE > 0 THEN
--余额任在CR
IF (V_CUR_DR_AMOUNT <> 0 OR V_CUR_CR_AMOUNT <> V_TEMP_BALANCE) THEN
V_ADJUST := 1;
V_ERRTEXT :=V_ACCOUNT_NO||'的CR余额应为:'||V_TEMP_BALANCE ||',DR余额应为:0';
CONTINUE;
END IF;
ELSIF V_TEMP_BALANCE < 0 THEN
--余额反向在DR
IF (V_CUR_CR_AMOUNT <> 0 OR
V_CUR_DR_AMOUNT <> V_TEMP_BALANCE * -1) THEN
V_ADJUST := 1;
V_ERRTEXT :=V_ACCOUNT_NO||'的DR余额应为:'||V_TEMP_BALANCE * -1 ||',CR余额应为:0';
CONTINUE;
END IF;
END IF;
END IF;
IF (V_YESTODAY_CASH_AMOUNT +V_YESTODAY_FREEZE_AMOUNT+V_ACCRUAL <>V_CASH_AMOUNT + V_FREEZE_AMOUNT) THEN
V_ADJUST := 1;
V_ERRTEXT :=V_ACCOUNT_NO||'的余额错误,昨日余额为:'||(V_YESTODAY_CASH_AMOUNT +V_YESTODAY_FREEZE_AMOUNT) ||
',今日借方发生额:'||V_DR_AMOUNT||',贷方发生额'||V_CR_AMOUNT||',今日余额应为:'||(V_CASH_AMOUNT + V_FREEZE_AMOUNT);
END IF;
IF (V_ADJUST = 1) THEN
UPDATE T_ACCOUNT
SET T_ACCOUNT.ACCOUNT_STATE = 'FREEZE'
WHERE T_ACCOUNT.ACCOUNT_NO = V_ACCOUNT_NO;
--记录异常日志
INSERT INTO T_ACCOUNT_LOG
(ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
VALUES
(SEQ_ACCOUNT_LOG.NEXTVAL,
'ERROR',
V_ERRTEXT,
CURRENT_TIMESTAMP);
END IF;
FETCH CUR_ACC_BALANCE
INTO V_ACCOUNT_NO,
V_SUBJECT_DR_CR,
V_CASH_AMOUNT,
V_FREEZE_AMOUNT,
V_OVERDRAFT_AMOUNT_LIMIT,
V_CUR_DR_AMOUNT,
V_CUR_CR_AMOUNT,
V_DR_AMOUNT,
V_CR_AMOUNT,
V_YESTODAY_CASH_AMOUNT,
V_YESTODAY_FREEZE_AMOUNT,
V_YESTODAY_OVERDRAFT_AMOUNT,
V_YESTODAY_DR_AMOUNT,
V_YESTODAY_CR_AMOUNT;
END LOOP;
CLOSE CUR_ACC_BALANCE;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK WORK;
RAISE_APPLICATION_ERROR(-20001, '日切出错出错!');
RETURN;
END;
END PROC_DAY_OVER_CALCULATE;
CREATE OR REPLACE PROCEDURE PROC_ACCOUNT_DAILY AS
V_DAY_IDX VARCHAR2(8);
--V_COUNT NUMBER;
--V_SEQ_VAL NUMBER(15);
BEGIN
/**、
SELECT TO_DATE(PARAM_VALUE, 'yyyyMMdd')
INTO V_DAY_IDX
FROM T_DAY_CHANGE
WHERE T_DAY_CHANGE.PARAM_NAME = 'CUR_DAY';
SELECT COUNT(ID)
INTO V_COUNT
FROM T_ACCOUNT_DAILY
WHERE T_ACCOUNT_DAILY.ACCOUNT_DATE = TO_CHAR(V_DAY_IDX, 'yyyyMMdd');
IF V_COUNT > 0 THEN
DELETE FROM T_ACCOUNT_DAILY
WHERE T_ACCOUNT_DAILY.ACCOUNT_DATE = TO_CHAR(V_DAY_IDX, 'yyyyMMdd');
END IF;
*/
--更新日切时间
--1、保留前日切时间
--2、更新下一日切时间
--记录异常日志
INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
VALUES (SEQ_ACCOUNT_LOG.NEXTVAL, 'INFO',
'更新日切时间开始',
CURRENT_TIMESTAMP);
select t.param_value into V_DAY_IDX from t_day_change t where t.param_name='CUR_DAY';
update t_day_change t
set t.param_value = to_char(to_date(t.param_value, 'yyyyMMdd') + 1, 'yyyyMMdd'),
t.update_time = sysdate;
commit;
INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
VALUES (SEQ_ACCOUNT_LOG.NEXTVAL, 'INFO',
'更新日切时间结束',
CURRENT_TIMESTAMP);
--账户日切表
BEGIN
INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
VALUES (SEQ_ACCOUNT_LOG.NEXTVAL, 'INFO',
'账户日切开始',
CURRENT_TIMESTAMP);
INSERT INTO T_ACCOUNT_DAILY
(ID,
ACCOUNT_DATE,
ACCOUNT_TYPE,
ACCOUNT_NO,
ACCOUNT_NAME,
SUBJECT_NO,
SUBJECT_DR_CR,
ACCOUNT_STATE,
OVERDRAFT_FLAG,
DR_AMOUNT,
CR_AMOUNT,
CASH_AMOUNT,
FREEZE_AMOUNT,
OVERDRAFT_AMOUNT_LIMIT,
ALL_DR_AMOUNT,
ALL_CR_AMOUNT,
UPDATE_TIME)
SELECT SEQ_ACCOUNT_DAILY.NEXTVAL,
TO_CHAR(V_DAY_IDX, 'yyyyMMdd'),
T_ACCOUNT.ACCOUNT_TYPE,
T_ACCOUNT.ACCOUNT_NO,
T_ACCOUNT.ACCOUNT_NAME,
T_ACCOUNT.SUBJECT_NO,
T_ACCOUNT.SUBJECT_DR_CR,
T_ACCOUNT.ACCOUNT_STATE,
T_ACCOUNT.OVERDRAFT_FLAG,
T_ACCOUNT.DR_AMOUNT,
T_ACCOUNT.CR_AMOUNT,
T_ACCOUNT.CASH_AMOUNT,
T_ACCOUNT.FREEZE_AMOUNT,
T_ACCOUNT.OVERDRAFT_AMOUNT_LIMIT,
NVL(A_STAT.DR_AMOUNT, 0),
NVL(A_STAT.CR_AMOUNT, 0),
CURRENT_TIMESTAMP
FROM T_ACCOUNT
LEFT JOIN (SELECT SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
WHEN 'DR' THEN
T_ACCOUNT_WATER.DR_CR_AMOUNT
END) DR_AMOUNT,
SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
WHEN 'CR' THEN
T_ACCOUNT_WATER.DR_CR_AMOUNT
END) CR_AMOUNT,
T_ACCOUNT_WATER.ACCOUNT_NO
FROM T_ACCOUNT_WATER
WHERE T_ACCOUNT_WATER.ACCOUNT_DATE =
TO_CHAR(V_DAY_IDX, 'yyyyMMdd')
AND T_ACCOUNT_WATER.STATUS = 'SUCCESS'
GROUP BY T_ACCOUNT_WATER.ACCOUNT_NO) A_STAT
ON T_ACCOUNT.ACCOUNT_NO = A_STAT.ACCOUNT_NO;
COMMIT;
INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
VALUES (SEQ_ACCOUNT_LOG.NEXTVAL, 'INFO',
'账户日切结束',
CURRENT_TIMESTAMP);
EXCEPTION
WHEN OTHERS THEN
INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
VALUES (SEQ_ACCOUNT_LOG.NEXTVAL,
'ERROR',
'账户日切异常',
CURRENT_TIMESTAMP);
commit;
END;
----录入科目日均表
BEGIN
INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
VALUES (SEQ_ACCOUNT_LOG.NEXTVAL,
'INFO',
'科目日报表统计开始',
CURRENT_TIMESTAMP);
INSERT INTO T_SUBJECT_DAY_BANLANCE_RPT
(ID,
SUBJECT_NO,
SUBJECT_NAME,
STA_DATE,
DR_AMT,
CR_AMT,
TODAY_DR_BALANCE,
TODAY_CR_BALANCE,
PRE_DR_BALANCE,
PRE_CR_BALANCE)
SELECT SEQ_SUB_DAY_BALRPT.NEXTVAL,
T_SUBJECT.SUBJECT_NO,
T_SUBJECT.SUBJECT_NAME,
V_DAY_IDX,
NVL(RET.ALL_DR_AMOUNT, 0),
NVL(RET.ALL_CR_AMOUNT, 0),
NVL(RET.DR_AMOUNT, 0),
NVL(RET.CR_AMOUNT, 0),
NVL(RET.PRE_DR_AMOUNT, 0),
NVL(RET.PRE_CR_AMOUNT, 0)
FROM T_SUBJECT
LEFT JOIN (SELECT CUR.*,
PRE.DR_AMOUNT PRE_DR_AMOUNT,
PRE.CR_AMOUNT PRE_CR_AMOUNT
FROM (SELECT T_ACCOUNT_DAILY.SUBJECT_NO,
T_ACCOUNT_DAILY.ACCOUNT_DATE,
SUM(T_ACCOUNT_DAILY.ALL_DR_AMOUNT) ALL_DR_AMOUNT,
SUM(T_ACCOUNT_DAILY.ALL_CR_AMOUNT) ALL_CR_AMOUNT,
SUM(T_ACCOUNT_DAILY.DR_AMOUNT) DR_AMOUNT,
SUM(T_ACCOUNT_DAILY.CR_AMOUNT) CR_AMOUNT
FROM T_ACCOUNT_DAILY
WHERE T_ACCOUNT_DAILY.ACCOUNT_DATE =
TO_CHAR(V_DAY_IDX, 'yyyyMMdd')
GROUP BY T_ACCOUNT_DAILY.ACCOUNT_DATE,
T_ACCOUNT_DAILY.SUBJECT_NO) CUR
LEFT JOIN (SELECT T_ACCOUNT_DAILY.SUBJECT_NO,
T_ACCOUNT_DAILY.ACCOUNT_DATE,
SUM(T_ACCOUNT_DAILY.DR_AMOUNT) DR_AMOUNT,
SUM(T_ACCOUNT_DAILY.CR_AMOUNT) CR_AMOUNT
FROM T_ACCOUNT_DAILY
WHERE T_ACCOUNT_DAILY.ACCOUNT_DATE =
TO_CHAR(V_DAY_IDX - 1, 'yyyyMMdd')
GROUP BY T_ACCOUNT_DAILY.ACCOUNT_DATE,
T_ACCOUNT_DAILY.SUBJECT_NO) PRE
ON CUR.SUBJECT_NO = PRE.SUBJECT_NO
AND CUR.ACCOUNT_DATE = PRE.ACCOUNT_DATE) RET
ON T_SUBJECT.SUBJECT_NO = RET.SUBJECT_NO;
commit;
INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
VALUES (SEQ_ACCOUNT_LOG.NEXTVAL,
'INFO',
'科目日报表统计结束',
CURRENT_TIMESTAMP);
EXCEPTION
WHEN OTHERS THEN
INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
VALUES (SEQ_ACCOUNT_LOG.NEXTVAL,
'ERROR',
'',
CURRENT_TIMESTAMP);
commit;
END;
END PROC_ACCOUNT_DAILY;
CREATE OR REPLACE VIEW MV_TRADE AS
SELECT
T .ORDER_ID,
T .AMOUNT,
T .SUBJECT,
T .TRADE_CATEGORY,
T .TRADE_TYPE,
T .STATUS,
T .BUYER_ID,
T .BUYER_LOGIN_ID,
T .BUYER_NAME,
T .SELLER_ID,
T .SELLER_LOGIN_ID,
T .SELLER_NAME,
T .PAYMENT_ID,
T .CREATE_DATE,
T .UPDATE_USER
FROM
T_RECHARGE T
UNION
SELECT
T .ORDER_ID,
T .AMOUNT,
T .SUBJECT,
T .TRADE_CATEGORY,
T .TRADE_TYPE,
T .STATUS,
T .BUYER_ID,
T .BUYER_LOGIN_ID,
T .BUYER_NAME,
T .SELLER_ID,
T .SELLER_LOGIN_ID,
T .SELLER_NAME,
T .PAYMENT_ID,
T .CREATE_DATE,
T .UPDATE_USER
FROM
T_TRADE_ORDER T
UNION
SELECT
T .ORDER_ID,
T .AMOUNT,
T .SUBJECT,
T .TRADE_CATEGORY,
T .TRADE_TYPE,
T .STATUS,
T .BUYER_ID,
T .BUYER_LOGIN_ID,
T .BUYER_NAME,
T .SELLER_ID,
T .SELLER_LOGIN_ID,
T .SELLER_NAME,
T .PAYMENT_ID,
T .CREATE_DATE,
T .UPDATE_USER
FROM
T_WITHDRAW T;
V_DAY_IDX DATE;
V_COUNT NUMBER;
V_ORDER_ID VARCHAR2(50);
V_PAYMENT_ORDER_NO VARCHAR2(50);
V_ACCOUNT_NO NUMBER(16);
V_SUBJECT_DR_CR VARCHAR2(4);
V_CASH_AMOUNT NUMBER;
V_FREEZE_AMOUNT NUMBER;
V_OVERDRAFT_AMOUNT_LIMIT NUMBER;
V_CUR_DR_AMOUNT NUMBER;
V_CUR_CR_AMOUNT NUMBER;
V_DR_AMOUNT NUMBER;
V_CR_AMOUNT NUMBER;
V_YESTODAY_CASH_AMOUNT NUMBER;
V_YESTODAY_FREEZE_AMOUNT NUMBER;
V_YESTODAY_OVERDRAFT_AMOUNT NUMBER;
V_YESTODAY_DR_AMOUNT NUMBER;
V_YESTODAY_CR_AMOUNT NUMBER;
V_TEMP_BALANCE NUMBER;
V_ACCRUAL NUMBER;
V_SQL VARCHAR2(255);
V_ERRTEXT VARCHAR2(255);
V_ADJUST NUMBER;
CURSOR CUR_ACC_DR_CR(V_DAY_IDX DATE) IS
SELECT T.ORDER_ID,
R.ACCOUNT_NO,
R.PAYMENT_ORDER_NO,
R.DR_TOTAL,
R.CR_TOTAL
FROM (SELECT T_ACCOUNT_WATER.PAYMENT_ORDER_NO,
T_ACCOUNT_WATER.ACCOUNT_NO,
SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
WHEN 'DR' THEN
T_ACCOUNT_WATER.DR_CR_AMOUNT
END) DR_TOTAL,
SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
WHEN 'CR' THEN
T_ACCOUNT_WATER.DR_CR_AMOUNT
END) CR_TOTAL
FROM T_ACCOUNT_WATER
WHERE T_ACCOUNT_WATER.STATUS = 'SUCCESS'
AND T_ACCOUNT_WATER.ACCOUNT_DATE =
TO_CHAR(V_DAY_IDX, 'yyyyMMdd')
GROUP BY T_ACCOUNT_WATER.PAYMENT_ORDER_NO,
T_ACCOUNT_WATER.ACCOUNT_NO
HAVING SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
WHEN 'DR' THEN
T_ACCOUNT_WATER.DR_CR_AMOUNT
END) <> SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
WHEN 'CR' THEN
T_ACCOUNT_WATER.DR_CR_AMOUNT
END)) R
LEFT JOIN MV_TRADE T
ON R.PAYMENT_ORDER_NO = T.PAYMENT_ID;
CURSOR CUR_ACC_BALANCE(V_DAY_IDX DATE) IS
SELECT RET.ACCOUNT_NO,
RET.SUBJECT_DR_CR,
RET.CASH_AMOUNT,
RET.FREEZE_AMOUNT,
RET.OVERDRAFT_AMOUNT_LIMIT,
RET.CUR_DR_AMOUNT,
RET.CUR_CR_AMOUNT,
RET.DR_AMOUNT,
RET.CR_AMOUNT,
Y_RET.YESTODAY_CASH_AMOUNT,
Y_RET.YESTODAY_FREEZE_AMOUNT,
Y_RET.YESTODAY_OVERDRAFT_AMOUNT,
Y_RET.YESTODAY_DR_AMOUNT,
Y_RET.YESTODAY_CR_AMOUNT
FROM (SELECT T_ACCOUNT.ACCOUNT_NO,
T_ACCOUNT.SUBJECT_DR_CR,
T_ACCOUNT.CASH_AMOUNT,
T_ACCOUNT.FREEZE_AMOUNT,
T_ACCOUNT.OVERDRAFT_AMOUNT_LIMIT,
T_ACCOUNT.DR_AMOUNT CUR_DR_AMOUNT,
T_ACCOUNT.CR_AMOUNT CUR_CR_AMOUNT,
R.DR_AMOUNT,
R.CR_AMOUNT
FROM T_ACCOUNT,
(SELECT SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
WHEN 'DR' THEN
T_ACCOUNT_WATER.DR_CR_AMOUNT
END) DR_AMOUNT,
SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
WHEN 'CR' THEN
T_ACCOUNT_WATER.DR_CR_AMOUNT
END) CR_AMOUNT,
T_ACCOUNT_WATER.ACCOUNT_NO
FROM T_ACCOUNT_WATER
WHERE T_ACCOUNT_WATER.ACCOUNT_DATE =
TO_CHAR(V_DAY_IDX, 'yyyyMMdd')
AND T_ACCOUNT_WATER.STATUS = 'SUCCESS'
GROUP BY T_ACCOUNT_WATER.ACCOUNT_NO) R
WHERE T_ACCOUNT.ACCOUNT_NO = R.ACCOUNT_NO
) RET
LEFT JOIN (SELECT T_ACCOUNT_DAILY.CASH_AMOUNT YESTODAY_CASH_AMOUNT,
T_ACCOUNT_DAILY.FREEZE_AMOUNT YESTODAY_FREEZE_AMOUNT,
T_ACCOUNT_DAILY.OVERDRAFT_AMOUNT_LIMIT YESTODAY_OVERDRAFT_AMOUNT,
T_ACCOUNT_DAILY.DR_AMOUNT YESTODAY_DR_AMOUNT,
T_ACCOUNT_DAILY.CR_AMOUNT YESTODAY_CR_AMOUNT,
T_ACCOUNT_DAILY.ACCOUNT_NO
FROM T_ACCOUNT_DAILY
WHERE T_ACCOUNT_DAILY.ACCOUNT_DATE =
TO_CHAR(V_DAY_IDX - 1, 'yyyyMMdd')) Y_RET
ON RET.ACCOUNT_NO = Y_RET.ACCOUNT_NO;
BEGIN
BEGIN
--当前工作日
SELECT TO_DATE(PARAM_VALUE, 'yyyyMMdd')
INTO V_DAY_IDX
FROM T_DAY_CHANGE
WHERE T_DAY_CHANGE.PARAM_NAME = 'CUR_DAY';
--同一支付流水记账借贷是否平衡
OPEN CUR_ACC_DR_CR(V_DAY_IDX);
--T.ORDER_ID, R.ACCOUNT_NO, R.PAYMENT_ORDER_NO, R.DR_TOTAL, R.CR_TOTAL
FETCH CUR_ACC_DR_CR
INTO V_ORDER_ID,
V_ACCOUNT_NO,
V_PAYMENT_ORDER_NO,
V_DR_AMOUNT,
V_CR_AMOUNT;
WHILE CUR_ACC_DR_CR%FOUND LOOP
---订单是否需要冻结
-- UPDATE T_RECHARGE TR SET TR.SETT_STATE ='FREEZEN' WHERE TR.ORDER_ID=V_ORDER_ID
--将账户冻结
UPDATE T_ACCOUNT
SET T_ACCOUNT.ACCOUNT_STATE = 'FREEZE'
WHERE T_ACCOUNT.ACCOUNT_NO = V_ACCOUNT_NO;
--记录异常日志
INSERT INTO T_ACCOUNT_LOG
(ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
VALUES
(SEQ_ACCOUNT_LOG.NEXTVAL,
'ERROR',
'账户(' || V_ACCOUNT_NO || ')支付流水号为:' || V_PAYMENT_ORDER_NO ||
'借贷不平衡',
CURRENT_TIMESTAMP);
FETCH CUR_ACC_DR_CR
INTO V_ORDER_ID,
V_ACCOUNT_NO,
V_PAYMENT_ORDER_NO,
V_DR_AMOUNT,
V_CR_AMOUNT;
END LOOP;
CLOSE CUR_ACC_DR_CR;
----- 账户当前余额=昨日余额+当日发生额
OPEN CUR_ACC_BALANCE(V_DAY_IDX);
FETCH CUR_ACC_BALANCE
INTO V_ACCOUNT_NO,
V_SUBJECT_DR_CR,
V_CASH_AMOUNT,
V_FREEZE_AMOUNT,
V_OVERDRAFT_AMOUNT_LIMIT,
V_CUR_DR_AMOUNT,
V_CUR_CR_AMOUNT,
V_DR_AMOUNT,
V_CR_AMOUNT,
V_YESTODAY_CASH_AMOUNT,
V_YESTODAY_FREEZE_AMOUNT,
V_YESTODAY_OVERDRAFT_AMOUNT,
V_YESTODAY_DR_AMOUNT,
V_YESTODAY_CR_AMOUNT;
WHILE CUR_ACC_BALANCE%FOUND LOOP
--数据错误则冻结账户
IF V_YESTODAY_DR_AMOUNT > 0 AND V_YESTODAY_CR_AMOUNT = 0 THEN
--余额在DR方
V_TEMP_BALANCE := V_YESTODAY_DR_AMOUNT + V_DR_AMOUNT - V_CR_AMOUNT;
V_ACCRUAL := V_DR_AMOUNT - V_CR_AMOUNT;
IF V_TEMP_BALANCE > 0 THEN
--余额在DR
IF (V_CUR_CR_AMOUNT <> 0 OR V_CUR_DR_AMOUNT <> V_TEMP_BALANCE) THEN
--调整账户余额 账户当前余额=昨日余额+当日发生额
V_ADJUST := 1;
V_ERRTEXT :=V_ACCOUNT_NO||'的DR余额应为:'||V_TEMP_BALANCE||',CR余额应为:0';
CONTINUE;
END IF;
ELSIF V_TEMP_BALANCE < 0 THEN
--余额在CR
IF (V_CUR_DR_AMOUNT <> 0 OR
V_CUR_CR_AMOUNT <> V_TEMP_BALANCE * -1) THEN
--调整账户余额 账户当前余额=昨日余额+当日发生额
V_ADJUST := 1;
V_ERRTEXT :=V_ACCOUNT_NO||'的CR余额应为:'||V_TEMP_BALANCE * -1||',DR余额应为:0';
CONTINUE;
END IF;
END IF;
ELSIF V_YESTODAY_CR_AMOUNT > 0 AND V_YESTODAY_DR_AMOUNT = 0 THEN
--昨日余额在CR方
V_TEMP_BALANCE := V_YESTODAY_CR_AMOUNT + V_CR_AMOUNT - V_DR_AMOUNT;
V_ACCRUAL := V_CR_AMOUNT -V_DR_AMOUNT;
IF V_TEMP_BALANCE > 0 THEN
--余额任在CR
IF (V_CUR_DR_AMOUNT <> 0 OR V_CUR_CR_AMOUNT <> V_TEMP_BALANCE) THEN
V_ADJUST := 1;
V_ERRTEXT :=V_ACCOUNT_NO||'的CR余额应为:'||V_TEMP_BALANCE ||',DR余额应为:0';
CONTINUE;
END IF;
ELSIF V_TEMP_BALANCE < 0 THEN
--余额反向在DR
IF (V_CUR_CR_AMOUNT <> 0 OR
V_CUR_DR_AMOUNT <> V_TEMP_BALANCE * -1) THEN
V_ADJUST := 1;
V_ERRTEXT :=V_ACCOUNT_NO||'的DR余额应为:'||V_TEMP_BALANCE * -1 ||',CR余额应为:0';
CONTINUE;
END IF;
END IF;
ELSIF V_YESTODAY_CR_AMOUNT = 0 AND V_YESTODAY_DR_AMOUNT = 0 THEN
--无昨日余额
V_TEMP_BALANCE := V_CR_AMOUNT - V_DR_AMOUNT;
V_ACCRUAL := V_CR_AMOUNT - V_DR_AMOUNT;
IF V_TEMP_BALANCE > 0 THEN
--余额任在CR
IF (V_CUR_DR_AMOUNT <> 0 OR V_CUR_CR_AMOUNT <> V_TEMP_BALANCE) THEN
V_ADJUST := 1;
V_ERRTEXT :=V_ACCOUNT_NO||'的CR余额应为:'||V_TEMP_BALANCE ||',DR余额应为:0';
CONTINUE;
END IF;
ELSIF V_TEMP_BALANCE < 0 THEN
--余额反向在DR
IF (V_CUR_CR_AMOUNT <> 0 OR
V_CUR_DR_AMOUNT <> V_TEMP_BALANCE * -1) THEN
V_ADJUST := 1;
V_ERRTEXT :=V_ACCOUNT_NO||'的DR余额应为:'||V_TEMP_BALANCE * -1 ||',CR余额应为:0';
CONTINUE;
END IF;
END IF;
END IF;
IF (V_YESTODAY_CASH_AMOUNT +V_YESTODAY_FREEZE_AMOUNT+V_ACCRUAL <>V_CASH_AMOUNT + V_FREEZE_AMOUNT) THEN
V_ADJUST := 1;
V_ERRTEXT :=V_ACCOUNT_NO||'的余额错误,昨日余额为:'||(V_YESTODAY_CASH_AMOUNT +V_YESTODAY_FREEZE_AMOUNT) ||
',今日借方发生额:'||V_DR_AMOUNT||',贷方发生额'||V_CR_AMOUNT||',今日余额应为:'||(V_CASH_AMOUNT + V_FREEZE_AMOUNT);
END IF;
IF (V_ADJUST = 1) THEN
UPDATE T_ACCOUNT
SET T_ACCOUNT.ACCOUNT_STATE = 'FREEZE'
WHERE T_ACCOUNT.ACCOUNT_NO = V_ACCOUNT_NO;
--记录异常日志
INSERT INTO T_ACCOUNT_LOG
(ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
VALUES
(SEQ_ACCOUNT_LOG.NEXTVAL,
'ERROR',
V_ERRTEXT,
CURRENT_TIMESTAMP);
END IF;
FETCH CUR_ACC_BALANCE
INTO V_ACCOUNT_NO,
V_SUBJECT_DR_CR,
V_CASH_AMOUNT,
V_FREEZE_AMOUNT,
V_OVERDRAFT_AMOUNT_LIMIT,
V_CUR_DR_AMOUNT,
V_CUR_CR_AMOUNT,
V_DR_AMOUNT,
V_CR_AMOUNT,
V_YESTODAY_CASH_AMOUNT,
V_YESTODAY_FREEZE_AMOUNT,
V_YESTODAY_OVERDRAFT_AMOUNT,
V_YESTODAY_DR_AMOUNT,
V_YESTODAY_CR_AMOUNT;
END LOOP;
CLOSE CUR_ACC_BALANCE;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK WORK;
RAISE_APPLICATION_ERROR(-20001, '日切出错出错!');
RETURN;
END;
END PROC_DAY_OVER_CALCULATE;
CREATE OR REPLACE PROCEDURE PROC_ACCOUNT_DAILY AS
V_DAY_IDX VARCHAR2(8);
--V_COUNT NUMBER;
--V_SEQ_VAL NUMBER(15);
BEGIN
/**、
SELECT TO_DATE(PARAM_VALUE, 'yyyyMMdd')
INTO V_DAY_IDX
FROM T_DAY_CHANGE
WHERE T_DAY_CHANGE.PARAM_NAME = 'CUR_DAY';
SELECT COUNT(ID)
INTO V_COUNT
FROM T_ACCOUNT_DAILY
WHERE T_ACCOUNT_DAILY.ACCOUNT_DATE = TO_CHAR(V_DAY_IDX, 'yyyyMMdd');
IF V_COUNT > 0 THEN
DELETE FROM T_ACCOUNT_DAILY
WHERE T_ACCOUNT_DAILY.ACCOUNT_DATE = TO_CHAR(V_DAY_IDX, 'yyyyMMdd');
END IF;
*/
--更新日切时间
--1、保留前日切时间
--2、更新下一日切时间
--记录异常日志
INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
VALUES (SEQ_ACCOUNT_LOG.NEXTVAL, 'INFO',
'更新日切时间开始',
CURRENT_TIMESTAMP);
select t.param_value into V_DAY_IDX from t_day_change t where t.param_name='CUR_DAY';
update t_day_change t
set t.param_value = to_char(to_date(t.param_value, 'yyyyMMdd') + 1, 'yyyyMMdd'),
t.update_time = sysdate;
commit;
INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
VALUES (SEQ_ACCOUNT_LOG.NEXTVAL, 'INFO',
'更新日切时间结束',
CURRENT_TIMESTAMP);
--账户日切表
BEGIN
INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
VALUES (SEQ_ACCOUNT_LOG.NEXTVAL, 'INFO',
'账户日切开始',
CURRENT_TIMESTAMP);
INSERT INTO T_ACCOUNT_DAILY
(ID,
ACCOUNT_DATE,
ACCOUNT_TYPE,
ACCOUNT_NO,
ACCOUNT_NAME,
SUBJECT_NO,
SUBJECT_DR_CR,
ACCOUNT_STATE,
OVERDRAFT_FLAG,
DR_AMOUNT,
CR_AMOUNT,
CASH_AMOUNT,
FREEZE_AMOUNT,
OVERDRAFT_AMOUNT_LIMIT,
ALL_DR_AMOUNT,
ALL_CR_AMOUNT,
UPDATE_TIME)
SELECT SEQ_ACCOUNT_DAILY.NEXTVAL,
TO_CHAR(V_DAY_IDX, 'yyyyMMdd'),
T_ACCOUNT.ACCOUNT_TYPE,
T_ACCOUNT.ACCOUNT_NO,
T_ACCOUNT.ACCOUNT_NAME,
T_ACCOUNT.SUBJECT_NO,
T_ACCOUNT.SUBJECT_DR_CR,
T_ACCOUNT.ACCOUNT_STATE,
T_ACCOUNT.OVERDRAFT_FLAG,
T_ACCOUNT.DR_AMOUNT,
T_ACCOUNT.CR_AMOUNT,
T_ACCOUNT.CASH_AMOUNT,
T_ACCOUNT.FREEZE_AMOUNT,
T_ACCOUNT.OVERDRAFT_AMOUNT_LIMIT,
NVL(A_STAT.DR_AMOUNT, 0),
NVL(A_STAT.CR_AMOUNT, 0),
CURRENT_TIMESTAMP
FROM T_ACCOUNT
LEFT JOIN (SELECT SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
WHEN 'DR' THEN
T_ACCOUNT_WATER.DR_CR_AMOUNT
END) DR_AMOUNT,
SUM(CASE T_ACCOUNT_WATER.DR_CR_FLAG
WHEN 'CR' THEN
T_ACCOUNT_WATER.DR_CR_AMOUNT
END) CR_AMOUNT,
T_ACCOUNT_WATER.ACCOUNT_NO
FROM T_ACCOUNT_WATER
WHERE T_ACCOUNT_WATER.ACCOUNT_DATE =
TO_CHAR(V_DAY_IDX, 'yyyyMMdd')
AND T_ACCOUNT_WATER.STATUS = 'SUCCESS'
GROUP BY T_ACCOUNT_WATER.ACCOUNT_NO) A_STAT
ON T_ACCOUNT.ACCOUNT_NO = A_STAT.ACCOUNT_NO;
COMMIT;
INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
VALUES (SEQ_ACCOUNT_LOG.NEXTVAL, 'INFO',
'账户日切结束',
CURRENT_TIMESTAMP);
EXCEPTION
WHEN OTHERS THEN
INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
VALUES (SEQ_ACCOUNT_LOG.NEXTVAL,
'ERROR',
'账户日切异常',
CURRENT_TIMESTAMP);
commit;
END;
----录入科目日均表
BEGIN
INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
VALUES (SEQ_ACCOUNT_LOG.NEXTVAL,
'INFO',
'科目日报表统计开始',
CURRENT_TIMESTAMP);
INSERT INTO T_SUBJECT_DAY_BANLANCE_RPT
(ID,
SUBJECT_NO,
SUBJECT_NAME,
STA_DATE,
DR_AMT,
CR_AMT,
TODAY_DR_BALANCE,
TODAY_CR_BALANCE,
PRE_DR_BALANCE,
PRE_CR_BALANCE)
SELECT SEQ_SUB_DAY_BALRPT.NEXTVAL,
T_SUBJECT.SUBJECT_NO,
T_SUBJECT.SUBJECT_NAME,
V_DAY_IDX,
NVL(RET.ALL_DR_AMOUNT, 0),
NVL(RET.ALL_CR_AMOUNT, 0),
NVL(RET.DR_AMOUNT, 0),
NVL(RET.CR_AMOUNT, 0),
NVL(RET.PRE_DR_AMOUNT, 0),
NVL(RET.PRE_CR_AMOUNT, 0)
FROM T_SUBJECT
LEFT JOIN (SELECT CUR.*,
PRE.DR_AMOUNT PRE_DR_AMOUNT,
PRE.CR_AMOUNT PRE_CR_AMOUNT
FROM (SELECT T_ACCOUNT_DAILY.SUBJECT_NO,
T_ACCOUNT_DAILY.ACCOUNT_DATE,
SUM(T_ACCOUNT_DAILY.ALL_DR_AMOUNT) ALL_DR_AMOUNT,
SUM(T_ACCOUNT_DAILY.ALL_CR_AMOUNT) ALL_CR_AMOUNT,
SUM(T_ACCOUNT_DAILY.DR_AMOUNT) DR_AMOUNT,
SUM(T_ACCOUNT_DAILY.CR_AMOUNT) CR_AMOUNT
FROM T_ACCOUNT_DAILY
WHERE T_ACCOUNT_DAILY.ACCOUNT_DATE =
TO_CHAR(V_DAY_IDX, 'yyyyMMdd')
GROUP BY T_ACCOUNT_DAILY.ACCOUNT_DATE,
T_ACCOUNT_DAILY.SUBJECT_NO) CUR
LEFT JOIN (SELECT T_ACCOUNT_DAILY.SUBJECT_NO,
T_ACCOUNT_DAILY.ACCOUNT_DATE,
SUM(T_ACCOUNT_DAILY.DR_AMOUNT) DR_AMOUNT,
SUM(T_ACCOUNT_DAILY.CR_AMOUNT) CR_AMOUNT
FROM T_ACCOUNT_DAILY
WHERE T_ACCOUNT_DAILY.ACCOUNT_DATE =
TO_CHAR(V_DAY_IDX - 1, 'yyyyMMdd')
GROUP BY T_ACCOUNT_DAILY.ACCOUNT_DATE,
T_ACCOUNT_DAILY.SUBJECT_NO) PRE
ON CUR.SUBJECT_NO = PRE.SUBJECT_NO
AND CUR.ACCOUNT_DATE = PRE.ACCOUNT_DATE) RET
ON T_SUBJECT.SUBJECT_NO = RET.SUBJECT_NO;
commit;
INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
VALUES (SEQ_ACCOUNT_LOG.NEXTVAL,
'INFO',
'科目日报表统计结束',
CURRENT_TIMESTAMP);
EXCEPTION
WHEN OTHERS THEN
INSERT INTO T_ACCOUNT_LOG (ID, T_LOG_LEVEL, T_LOG_CONTENT, UPDATE_TIME)
VALUES (SEQ_ACCOUNT_LOG.NEXTVAL,
'ERROR',
'',
CURRENT_TIMESTAMP);
commit;
END;
END PROC_ACCOUNT_DAILY;
CREATE OR REPLACE VIEW MV_TRADE AS
SELECT
T .ORDER_ID,
T .AMOUNT,
T .SUBJECT,
T .TRADE_CATEGORY,
T .TRADE_TYPE,
T .STATUS,
T .BUYER_ID,
T .BUYER_LOGIN_ID,
T .BUYER_NAME,
T .SELLER_ID,
T .SELLER_LOGIN_ID,
T .SELLER_NAME,
T .PAYMENT_ID,
T .CREATE_DATE,
T .UPDATE_USER
FROM
T_RECHARGE T
UNION
SELECT
T .ORDER_ID,
T .AMOUNT,
T .SUBJECT,
T .TRADE_CATEGORY,
T .TRADE_TYPE,
T .STATUS,
T .BUYER_ID,
T .BUYER_LOGIN_ID,
T .BUYER_NAME,
T .SELLER_ID,
T .SELLER_LOGIN_ID,
T .SELLER_NAME,
T .PAYMENT_ID,
T .CREATE_DATE,
T .UPDATE_USER
FROM
T_TRADE_ORDER T
UNION
SELECT
T .ORDER_ID,
T .AMOUNT,
T .SUBJECT,
T .TRADE_CATEGORY,
T .TRADE_TYPE,
T .STATUS,
T .BUYER_ID,
T .BUYER_LOGIN_ID,
T .BUYER_NAME,
T .SELLER_ID,
T .SELLER_LOGIN_ID,
T .SELLER_NAME,
T .PAYMENT_ID,
T .CREATE_DATE,
T .UPDATE_USER
FROM
T_WITHDRAW T;
相关推荐
Oracle 9i Client (Oracle 9i 客户端) 简化版 (不安装Oracle客户端,也可以使用PLSQL Developer 不用安装Oracle客户端也可以使用PLSQL Developer 绿色! 安全! 轻便! 可靠! 1、本软件可作为简单的Oracle9i客户端...
oci.dll是Oracle Call Interface的缩写,它是Oracle数据库的一个核心组件,允许开发者使用各种编程语言与Oracle数据库进行交互。在Oracle 10G和11G版本中,oci.dll扮演了至关重要的角色,为应用程序提供了访问数据库...
Oracle JDBC驱动包是Oracle数据库与Java应用程序之间进行通信的关键组件,它使得Java程序员能够通过编写Java代码来操作Oracle数据库。标题中的"ojdbc6"指的是Oracle JDBC驱动的一个特定版本,适用于Java SE 6环境。...
cx_Oracle是Python编程语言中用于连接Oracle数据库的一个模块。该模块遵循Python数据库API规范,并且适用于Oracle 11.2和12.1版本,同时兼容Python 2.x和3.x版本。cx_Oracle模块通过使用Oracle客户端库来实现与...
首先,Oracle.ManagedDataAccess是Oracle公司提供的一个纯.NET框架的客户端驱动,它允许开发者在不安装Oracle客户端的情况下,直接与Oracle数据库进行交互。这个库包含了所有必要的组件,使得C#程序可以方便地执行...
cx_Oracle是Python数据库API规范的实现,用于访问Oracle数据库。目前,该模块经过对Oracle客户端版本11.2、12.1和12.2以及Python版本2.7、3.4、3.5和3.6的测试。cx_Oracle遵循开源的BSD许可证,这表示用户可以自由地...
Oracle Client是Oracle公司提供的数据库连接工具,用于与Oracle数据库服务器进行通信。19C是Oracle Database的一个版本,代表第19个主要版本。这个压缩包包含的Oracle Client适用于Windows和Linux操作系统,使得...
《Oracle 12c数据库基础教程》教学课件—03Oracle数据库管理工具.pdf《Oracle 12c数据库基础教程》教学课件—03Oracle数据库管理工具.pdf《Oracle 12c数据库基础教程》教学课件—03Oracle数据库管理工具.pdf《Oracle...
Dbmover for Mysql to Oracle 是高效的将Mysql导入到Oracle数据库的工具。 使用DBMover可以灵活定义Mysql和Oracle之间表和字段的对照关系,也可以在DBMover创建一个查询,把查询结果当作源表转入到Oracle中。 ...
Oracle 11g客户端是Oracle数据库的一个轻量级版本,主要供开发人员和系统管理员用于连接到Oracle数据库服务器,执行查询、管理和维护数据库任务。这个精简版在保持基本功能的同时,减少了安装体积,便于快速部署和...
Oracle各版本驱动包,有需要的可以下载使用,支持目前常用的不同版本oracle和JDK,根据自己需要调整和使用 主要包括的jar有: ojdbc5.jar 适用JDK版本:JDK 1.5 对应Oracle数据库版本:Oracle数据库版本(如Oracle ...
### Tianlesoftware Oracle 学习手册(v1.0)中的关键知识点 #### 1. ORACLE基础知识 ##### 1.1 OLAP与OLTP介绍 **1.1.1 什么是OLTP** OLTP(Online Transaction Processing,在线事务处理)是一种主要针对企业...
python-oracledb的源码和使用示例代码, python-oracledb 1.0,适用于Python versions 3.6 through 3.10. Oracle Database; This directory contains samples for python-oracledb. 1. The schemas and SQL ...
Oracle 19c是Oracle数据库的一个重要版本,尤其在Windows平台上,它提供了全面的功能和优化,使得数据库管理和开发更为高效。以下将详细讲解Oracle 19c Windows客户端的关键知识点: 1. **Oracle Client**: Oracle...
Veeam 备份恢复 Oracle 数据库详细配置文档 本文档旨在详细介绍如何使用 Veeam 备份恢复 Oracle 数据库的配置过程。该文档将指导读者从环境准备到推送 Oracle RMAN Plugin,再到创建备份作业和运行备份作业,最后...
这里提到的三本书籍——"Oracle 9i初学者指南.zip"、"Oracle专家高级编程.pdf"以及"Effective Oracle by Design.pdf"都是Oracle学习者和专业开发者的宝贵资源。 "Oracle 9i初学者指南.zip":这是一本针对Oracle 9i...
Oracle Instant Client 11.2.0.1.0是轻量级Oracle客户端,用于连接访问Oracle 9i、10g、11g 11.2.0.1.0版本的Oracle数据库。 Oracle Instant Client11.2.0.1.0 安装程序包含OCI/ OCCI、JDBC-OCI SDK(软件开发工具...
Oracle客户端是用于与Oracle数据库服务器交互的软件工具,主要功能是提供对数据库的查询、更新、管理等操作。Oracle客户端支持多种操作系统,包括Windows,且有32位和64位之分。在这个场景中,我们关注的是"Oracle...
标题中的“System.Data.OracleClient 需要 Oracle 客户端软件 8.1.7 或更高版本”是一个常见的错误提示,它涉及到在.NET环境中使用Oracle数据库时遇到的问题。这个错误表明,当你试图在应用程序中使用System.Data....
本人琢磨了下使用VS .Net 2005开发的客户端程序,需要访问oracle数据库,但不想在客户端安装oracle客户端的解决方法。终于给弄清楚了,其实根本不需要在安装oracle客户端就可以轻松实现了。方法是将相关的9个oracle...