⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cms050.sqc

📁 一整套完整的银行卡系统源代码
💻 SQC
字号:
/******************************************************************** **   源码文件名称 : cms050.SQC **   所属子系统   : CMS  **   当前文件版本 : 4.0.0.0 **   作者         : Feng **   版本创建日期 : 2005/11/23 **   功能描述     : 根据客户号和客户帐号获取客户的所有帐号信息 **   修改记录     : **   修改人       修改日期     修改日期*********************************************************************/#include "code.h"#include "attrdef.h"#include "sysdef.h"#include "pubcom.h"#include "cmscode.h"#include "pubinq.h"#include "ciscustomerinfo.h"#include "ciscustaccinfo.h"#include "dpsaccountinfo.h"#include "dpsacctlink.h"#include "dpssaveaccdyninfo.h"#include "dpstermaccdyninfo.h"#include "errlog.h"EXEC SQL INCLUDE SQLCA;int cmsGetAcctByCustomId( PUBCOM *pstPubcom ){	/*定义局部变量*/	struct	ciscustomerinfo		stCisCustInfo;	/* 客户基本信息表	*/	struct	ciscustaccinfo		stCisCustAcct;	/* 客户帐户对照表	*/	struct	dpsaccountinfo		stDpsAcctInfo;	/* 存款静态信息表	*/	struct	dpsacctlink			stDpsAcctLink;	/* 存款关系信息表	*/	struct	dpssaveaccdyninfo	stDpsSaveDyn;	/* 存款动态信息表	*/	struct	dpstermaccdyninfo	stDpsTermDyn;	/* 存款动态信息表	*/	int		iRtn;								/* 函数返回值		*/	double	dBal;								/* 余额				*/	double	dAvailBal;							/* 可用余额			*/	char	acCustomId[ CUSTNO_LEN + 1 ];		/* 客户号			*/	char	acAcctNo[ ACCT_LEN + 1 ];			/* 客户帐号			*/	char	acSubAcct[ ACCT_LEN + 1 ];			/* 款项帐号			*/	char	acCcy[ CCY_LEN + 1 ];				/* 币种    			*/	char	acPrdCode[ PRDCODE_LEN + 1 ];		/* 产品代码			*/	char	acProfitBrc[ BRC_LEN + 1 ];			/* 核算机构 		*/	char	acFlag[ FLAG_LEN + 1 ];				/* 活定标志			*/	int     iCount=0;                           /* 计数器       */	FILE    *fp;								/* 文件指针     */	char    acFileName[FILENAME_LEN + 1];       /* 文件名称     */	char    acTableName[PRDCODE_LEN + 1];       /* 表名称       */	int		iFileFlag=0;						/* 文件打开标志 */	int		iCurFlag=0;							/* 游标打开标志 */	strcpy( g_acRspCode,  RSP_OK );	strcpy( g_acTrcMsg, "子交易: 获取客户的帐户信息开始.." );	TRCLOG4	/* 初始化 */	memset( &stCisCustInfo,	0x00, sizeof( struct ciscustomerinfo ) );	memset( acAcctNo,		0x00, sizeof( acAcctNo ) );	memset( acSubAcct,		0x00, sizeof( acSubAcct ) );	memset( acCcy,			0x00, sizeof( acCcy ) );	memset( acPrdCode,		0x00, sizeof( acPrdCode ) );	memset( acProfitBrc,	0x00, sizeof( acProfitBrc ) );	memset( acFlag,			0x00, sizeof( acFlag ) );	memset( acFileName,		0x00, sizeof( acFileName ) );	memset( acTableName,	0x00, sizeof( acTableName ) );	/* 取数据字典值 */	getstring( "AcctNo",	acAcctNo	);	getstring( "CustomId",	acCustomId	);	getstring( "Flag",	acFlag	);	strpack( acAcctNo );	strpack( acCustomId );	sprintf( g_acTrcMsg,"AcctNo[%s]CustomId[%s]",acAcctNo,acCustomId );	TRCLOG3	/* 按客户号获取客户信息 CIS API */	strcpy( stCisCustInfo.customid, acCustomId );	iRtn = pubReadCiscustomerinfo( &stCisCustInfo );	if ( iRtn )	{		if ( SQLCODE == SQLNOTFOUND )			sprintf( g_acRspMsg, "客户号[%s]不存在", acCustomId );		ERRLOG		goto Exit;	}	if ( !strlen( acAcctNo ) )	{		strcpy( acTableName, "cms050" );		sprintf(acFileName, "%s%s%s", acTableName, pstPubcom->acBrc,								  pstPubcom->acTeller);		fp = (FILE *)BeginFile( pstPubcom, acFileName );		if ( fp == NULL )		{			ERRLOG		    goto Exit;		}		iFileFlag = 1;		/*组织查询字典*/		if (GetInqDict( fp , "210050" ))		{			ERRLOG			goto Exit ;		}		/* 无客户帐号 */		memset( &stCisCustAcct,	0x00, sizeof( struct ciscustaccinfo ) );		strcpy( ciscustaccinfo_customid, acCustomId );		/* 从客户帐户对照表获取记录 */		EXEC SQL	DECLARE	acccif	CURSOR	FOR					SELECT	*					FROM	ciscustaccinfo					WHERE	customid = :ciscustaccinfo_customid					ORDER BY acctno;		SQLOPENCUR( acccif, "acccif")		if ( SQLCODE )		{			strcpy( g_acRspCode, "CMS111" );			pubCrtRspInfo("ciscustaccinfo",SQLCODE );			ERRLOG			goto Exit;		}		iCurFlag = 1;		while ( 1 )		{			memset( &stCisCustAcct,	0x00, sizeof( struct ciscustaccinfo ) );			memset( acAcctNo,		0x00, sizeof( acAcctNo ) );			memset( acSubAcct,		0x00, sizeof( acSubAcct ) );			memset( acCcy,			0x00, sizeof( acCcy ) );			memset( acPrdCode,		0x00, sizeof( acPrdCode ) );			memset( acProfitBrc,	0x00, sizeof( acProfitBrc ) );			memset( acFlag,			0x00, sizeof( acFlag ) );			pubInitCiscustaccinfo();			EXEC SQL	FETCH	acccif						INTO	R_CISCUSTACCINFO;			if ( SQLCODE == SQLNOTFOUND )				break;			else if ( SQLCODE )			{				strcpy( g_acRspCode, "CMS112" );				pubCrtRspInfo("ciscustaccinfo",SQLCODE );				ERRLOG				goto Exit;			}			pubVtoSCiscustaccinfo( &stCisCustAcct );			/* 非存款帐户 */			if ( strcmp(stCisCustAcct.subsys, STR_DPS ) )				continue;			memset( &stDpsAcctInfo,	0x00, sizeof( struct dpsaccountinfo ) );			/* 获取存款静态信息 */			strcpy( stDpsAcctInfo.acctno,	stCisCustAcct.acctno );			strcpy( acAcctNo,	stCisCustAcct.acctno );			if ( pubReadDpsaccountinfo( &stDpsAcctInfo ) )			{				ERRLOG				goto Exit;			}			/* 已有卡帐户 */			if ( stDpsAcctInfo.crdflg[ BIT1_LEN ] == '1' )				continue;			/* 帐户无效 */			if ( stDpsAcctInfo.accstat[ BIT1_LEN ] == '1' )				continue;			/* 总户无效 */			if ( stDpsAcctInfo.sigaccflg[ BIT1_LEN ] == '0' )				continue;			memset( &stDpsAcctLink, 0x00, sizeof( struct dpsacctlink ) );			EXEC SQL	SELECT	*						INTO	R_DPSACCTLINK						FROM	dpsacctlink						WHERE	acctno = :dpsaccountinfo_acctno						AND		( baseflag = '1' OR 								  opnflag = '1' )						AND		flag = '0';			if ( SQLCODE && SQLCODE != SQLNOTFOUND )			{				sprintf( g_acRspCode, "CMS113" );				sprintf( g_acRspMsg, "表dpsacctlink读取错误[%d]", SQLCODE );				ERRLOG				goto Exit;			}			else if ( SQLCODE == SQLNOTFOUND )				continue;			pubVtoSDpsacctlink( &stDpsAcctLink );			strcpy( acSubAcct,	stDpsAcctLink.subacct );			/* 获取存款动态信息 */			if ( stDpsAcctLink.opnflag[ BIT1_LEN ] == '0' 					&& acFlag[ BIT1_LEN ] != '1' )			{				memset( &stDpsSaveDyn, 0x00, sizeof(struct dpssaveaccdyninfo) );				strcpy( stDpsSaveDyn.subacct,	stDpsAcctLink.subacct );				if ( pubReadDpssaveaccdyninfo( &stDpsSaveDyn ) )				{					ERRLOG					goto Exit;				}				/* 帐户无效 */				if ( stDpsSaveDyn.accstat[ BIT1_LEN ] != '0' )					continue;				strcpy( acCcy,			stDpsSaveDyn.ccy );				strcpy( acPrdCode,		stDpsSaveDyn.prdcode );				strcpy( acProfitBrc,	stDpsSaveDyn.profitbrc );				if( dpsGetAvlBal( pstPubcom, &stDpsSaveDyn, NULL,						stCisCustAcct.acctno, 0.0, &dAvailBal, &dBal ) )				{					ERRLOG					goto Exit;				}			}			else if ( stDpsAcctLink.opnflag[ BIT1_LEN ] == '1' 					&& acFlag[ BIT1_LEN ] != '0' )			{				memset( &stDpsTermDyn, 0x00, sizeof(struct dpstermaccdyninfo) );				strcpy( stDpsTermDyn.subacct,	stDpsAcctLink.subacct );				if ( pubReadDpstermaccdyninfo( &stDpsTermDyn ) )				{					ERRLOG					goto Exit;				}				/* 帐户无效 */				if ( stDpsTermDyn.accstat[ BIT1_LEN ] != '0' )					continue;				strcpy( acCcy,			stDpsTermDyn.ccy );				strcpy( acPrdCode,		stDpsTermDyn.prdcode );				strcpy( acProfitBrc,	stDpsTermDyn.profitbrc );				/* 计算帐户可用余额 */				if( dpsGetAvlBal( pstPubcom, NULL, &stDpsTermDyn, 						stCisCustAcct.acctno, 0.0, &dAvailBal, &dBal ) )				{					ERRLOG					goto Exit;				}				acFlag[ BIT1_LEN ] = '1'; /* 定期 */			}			else 				continue;			fprintf( fp, "\"%s\"~\"%s\"~\"%s\"~\"%s\"~\"%s\"~"						"%.2lf~%.2lf\n", acAcctNo, acSubAcct, acCcy, acPrdCode,						acProfitBrc, dBal, dAvailBal );			iCount ++;		}		SQLCLOSECUR( acccif,"acccif")		iCurFlag = 0;		EndFile( fp );		iFileFlag = 0;		if ( iCount == 0 )		{			strcpy( g_acRspCode, "CMS1B7" );			pubCrtRspInfo( "客户号查询帐号");			ERRLOG			return FAILED;		}		setpubstring("FileFlag","2");		SetInqFormid(pstPubcom, "210050") ;	}	else	{		/* 有客户帐号 */		memset( &stCisCustAcct,	0x00, sizeof( struct ciscustaccinfo ) );		pubInitCiscustaccinfo( );		strcpy( ciscustaccinfo_customid, acCustomId );		strcpy( ciscustaccinfo_acctno, acAcctNo );		/* 从客户帐户对照表获取记录 */		EXEC SQL	SELECT	*					INTO	R_CISCUSTACCINFO					FROM	ciscustaccinfo					WHERE	customid = :ciscustaccinfo_customid					AND		acctno = :ciscustaccinfo_acctno;		if ( SQLCODE )		{			strcpy( g_acRspCode, "CMS113" );			pubCrtRspInfo("ciscustaccinfo",SQLCODE );			if ( SQLCODE == SQLNOTFOUND )				sprintf( g_acRspMsg, "帐户[%s]不属于客户[%s]", acAcctNo,									acCustomId );			ERRLOG			goto Exit;		}		pubVtoSCiscustaccinfo( &stCisCustAcct );		/* 非存款帐户 */		if ( strcmp(stCisCustAcct.subsys, STR_DPS ) )		{			strcpy( g_acRspCode, "CMS113" );			sprintf( g_acRspMsg, "[%s]非存款帐户", acAcctNo );			ERRLOG			goto Exit;		}		memset( &stDpsAcctInfo,	0x00, sizeof( struct dpsaccountinfo ) );		/* 获取存款静态信息 */		strcpy( stDpsAcctInfo.acctno,	stCisCustAcct.acctno );		if ( pubReadDpsaccountinfo( &stDpsAcctInfo ) )		{			ERRLOG			goto Exit;		}		/* 已有卡帐户 */		if ( stDpsAcctInfo.crdflg[ BIT1_LEN ] == '1' )		{			strcpy( g_acRspCode, "CMS113" );			sprintf( g_acRspMsg, "帐户[%s]已经关联卡", acAcctNo );			ERRLOG			goto Exit;		}		/* 帐户无效 */		if ( stDpsAcctInfo.accstat[ BIT1_LEN ] == '1' )		{			strcpy( g_acRspCode, "CMS113" );			sprintf( g_acRspMsg, "帐户[%s]已经无效", acAcctNo );			ERRLOG			goto Exit;		}		/* 总户无效 */		if ( stDpsAcctInfo.sigaccflg[ BIT1_LEN ] == '0' )		{			strcpy( g_acRspCode, "CMS113" );			sprintf( g_acRspMsg, "帐户[%s]为总户,不能关联卡", acAcctNo );			ERRLOG			goto Exit;		}		memset( &stDpsAcctLink, 0x00, sizeof( struct dpsacctlink ) );		EXEC SQL	SELECT	*					INTO	R_DPSACCTLINK					FROM	dpsacctlink					WHERE	acctno = :dpsaccountinfo_acctno					AND		baseflag = '1'					AND		flag = '0';		if ( SQLCODE && SQLCODE != SQLNOTFOUND )		{			sprintf( g_acRspCode, "CMS113" );			sprintf( g_acRspMsg, "表dpsacctlink读取错误[%d]", SQLCODE );			ERRLOG			goto Exit;		}		else if ( SQLCODE == SQLNOTFOUND )		{			strcpy( g_acRspCode, "CMS113" );			sprintf( g_acRspMsg, "帐户[%s]已经无效", acAcctNo );			ERRLOG			goto Exit;		}		pubVtoSDpsacctlink( &stDpsAcctLink );		strcpy( acSubAcct,	stDpsAcctLink.subacct );		/* 获取存款动态信息 */		if ( stDpsAcctLink.opnflag[ BIT1_LEN ] == '0' )		{			memset( &stDpsSaveDyn, 0x00, sizeof(struct dpssaveaccdyninfo) );			strcpy( stDpsSaveDyn.subacct,	stDpsAcctLink.subacct );			if ( pubReadDpssaveaccdyninfo( &stDpsSaveDyn ) )			{				ERRLOG				goto Exit;			}			/* 帐户无效 */			if ( stDpsSaveDyn.accstat[ BIT1_LEN ] != '0' )			{				strcpy( g_acRspCode, "CMS113" );				sprintf( g_acRspMsg, "帐户[%s]已经无效", acAcctNo );				ERRLOG				goto Exit;			}			if ( acFlag[ BIT1_LEN ] == '1' )			{				strcpy( g_acRspCode, "CMS113" );				sprintf( g_acRspMsg, "帐户[%s]非定期帐户", acAcctNo );				ERRLOG				goto Exit;			}			strcpy( acCcy,			stDpsSaveDyn.ccy );			strcpy( acPrdCode,		stDpsSaveDyn.prdcode );			strcpy( acProfitBrc,	stDpsSaveDyn.profitbrc );			if( dpsGetAvlBal( pstPubcom, &stDpsSaveDyn, NULL,					stCisCustAcct.acctno, 0.0, &dAvailBal, &dBal ) )			{				ERRLOG				goto Exit;			}		}		else		{			memset( &stDpsTermDyn, 0x00, sizeof(struct dpstermaccdyninfo) );			strcpy( stDpsTermDyn.subacct,	stDpsAcctLink.subacct );			if ( pubReadDpstermaccdyninfo( &stDpsTermDyn ) )			{				ERRLOG				goto Exit;			}			/* 帐户无效 */			if ( stDpsTermDyn.accstat[ BIT1_LEN ] != '0' )			{				strcpy( g_acRspCode, "CMS113" );				sprintf( g_acRspMsg, "帐户[%s]已经无效", acAcctNo );				ERRLOG				goto Exit;			}			if ( acFlag[ BIT1_LEN ] == '0' )			{				strcpy( g_acRspCode, "CMS113" );				sprintf( g_acRspMsg, "帐户[%s]非活期帐户", acAcctNo );				ERRLOG				goto Exit;			}			strcpy( acCcy,			stDpsTermDyn.ccy );			strcpy( acPrdCode,		stDpsTermDyn.prdcode );			strcpy( acProfitBrc,	stDpsTermDyn.profitbrc );			/* 计算帐户可用余额 */			if( dpsGetAvlBal( pstPubcom, NULL, &stDpsTermDyn, 					stCisCustAcct.acctno, 0.0, &dAvailBal, &dBal ) )			{				ERRLOG				goto Exit;			}		}		/* 子交易出口 */ 		setstring( "AcctNo",	acAcctNo );			/* 客户账号		*/		setstring( "SubAcct",	acSubAcct );		/* 款项代码		*/		setstring( "Ccy",		acCcy );			/* 币种			*/		setstring( "PrdCode",	acPrdCode );		/* 产品代码		*/		setdouble( "Bal",		&dBal );			/* 余额			*/		setdouble( "AvailBal",	&dAvailBal );		/* 可用余额		*/		setstring( "ProfitBrc", acProfitBrc ); 	  	/* 发卡机构码*/	}Exit:	if ( iFileFlag )		EndFile( fp );	if ( iCurFlag )		SQLCLOSECUR( acccif,"acccif")	strcpy( g_acTrcMsg, "子交易: 按客户获取账户信息结束.." );	TRCLOG4	if( !strcmp( g_acRspCode, RSP_OK ) )		return SUCCESS;	else		return FAILED ;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -