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

📄 cmstrack.sqc

📁 一整套完整的银行卡系统源代码
💻 SQC
📖 第 1 页 / 共 2 页
字号:
/******************************************************* **   源码文件名称 : cmstrack.SQC **   所属子系统   : 卡管理 **   功能描述     : 生成制卡信息 **   当前文件版本 : 4.0.0.0 **   作        者 : guoyun   **   版本创建日期 : 2004/09/15 **   修改记录     : **   修改人       修改日期     修改位置 **	  Feng			2006-01-09  修改函数cmsApiGenMakeCardInfo **	  Feng			2006-01-09  修改函数cmsCardVerify **	  Feng			2006-01-09  增加函数cmsGenCardCovInfo **	  Feng			2006-01-09  增加函数cmsGenCardTrack2Info **	  Feng			2006-01-09  增加函数cmsGenCardTrack3Info **	  Feng			2006-01-09  增加函数cmsCardVerifyHRB*******************************************************/#include "sysdefine.h"#include "code.h"#include "attrdef.h"#include "pubcom.h"#include "cmscode.h"#include "errlog.h"#include "cmsfunc.h"#include "cmscardinitparam.h"#include "cmscardinfo.h"EXEC SQL	INCLUDE SQLCA;/* int EncryptPkg( char * in,char * out,int size);*//******************************************************* **	  函数名称:cmsApiGenCardTrackInfo **   功能描述:按卡号、卡片初始化参数表生成卡的磁道信息 **  			(包括二、三磁道) **   输入参数: **   			pcCardNo					----	卡号 **   			pstCmsCardInitParam			----	卡片初始化参数表 **   输出参数: **   			pcTrack1					----	一磁道 **   			pcTrack2					----	二磁道 **   			pcTrack3					----	三磁道 **   返回结果:int **   			0				----	成功 **   			-1				----	失败*******************************************************/int	cmsApiGenCardTrackInfo( pcCardNo, pstCmsCardInitParam, pcTrack1, pcTrack2, 						    pcTrack3 )char					*	pcCardNo;			/* 卡号	*/struct cmscardinitparam *	pstCmsCardInitParam;/* 卡片初始化参数表	*/char					*	pcTrack1;			/* 一磁道			*/char					*	pcTrack2;			/* 二磁道			*/char					*	pcTrack3;			/* 三磁道			*/{	/* 定义 局部变量 */	int					iRtn;					/* 函数返回值		*/	int					iOffLen;				/* 偏移长度			*/	int					iLen;					/* 长度				*/	int					iFlag;					/* 标志				*/	char  				acBuf[CONDITION_LEN];	/* 临时存储区		*/	char  				acBuf1[CONDITION_LEN];	/* 临时存储区		*/	char  				acBuf2[CONDITION_LEN];	/* 临时存储区		*/	char  				acKh[CARDNO_LEN+1];	/* 临时存储区		*/	sprintf( g_acTrcMsg, "cmsApiGenCardTrackInfo begin " );	TRCLOG2	strcpy ( acKh, pcCardNo );	sprintf( g_acTrcMsg, "卡号:[%s] len[%d]", acKh, strlen(acKh) );	TRCLOG2	/* 计算CVN校验值 */	memset( acBuf1, 0, sizeof( acBuf1 ));	memset( acBuf2, 0, sizeof( acBuf2 ));	strcpy( acBuf1, acKh);	memcpy( acBuf1 + strlen( acBuf1 ), pstCmsCardInitParam->track2msg+atoi(pstCmsCardInitParam->expoffset), atoi(pstCmsCardInitParam->explen));	memcpy( acBuf1 + strlen( acBuf1 ), pstCmsCardInitParam->track2msg+atoi(pstCmsCardInitParam->srvcodeoffset), atoi(pstCmsCardInitParam->srvcodelen));	sprintf( g_acTrcMsg, acBuf1 );	TRCLOG2	iRtn =  cmsGenCVN( acBuf1 , "678012DEF345ABC9", "DEF01234ABC56798", acBuf2);	if ( iRtn )	{		strcpy( g_acRspCode , "999999" );		strcpy( g_acRspMsg , "生成磁道校验信息错!" );		return FAILED;	}	sprintf( g_acTrcMsg ,"CNV[%s]kh[%s][%s]",acBuf2,acKh,pstCmsCardInitParam->track1msg );	TRCLOG2    /* 第一磁道信息 */	memset( pcTrack1, 0x00, sizeof( pcTrack1 ) );	sprintf( g_acTrcMsg ,"CNV[%s]kh[%s][%s]",acBuf2,acKh,pcTrack1 );	TRCLOG2	strcpy ( pcTrack1, pstCmsCardInitParam->track1msg	);	sprintf( g_acTrcMsg ,"CNV[%s]kh[%s][%s]",acBuf2,acKh,pcTrack1 );	TRCLOG2    /* 第二磁道信息 */	memset( acBuf, 0, sizeof( acBuf ));	strcpy ( acBuf, pstCmsCardInitParam->track2msg);	sprintf( g_acTrcMsg ,"CNV[%s]kh[%s]",acBuf2,acKh );	TRCLOG2    iOffLen = atoi(pstCmsCardInitParam->offlen2);    iLen = atoi(pstCmsCardInitParam->vallen2);	memcpy( acBuf + iOffLen, pcCardNo, iLen);	sprintf( g_acTrcMsg ,"CNV[%s]kh[%s]",acBuf2,acKh );	TRCLOG2	/* 判断密码校验值是否存在 */	if (pstCmsCardInitParam->passwdid[BIT1_LEN] == EXISTTRACK23 ||		pstCmsCardInitParam->passwdid[BIT1_LEN] == EXISTTRACK2  )	{    	iOffLen = atoi(pstCmsCardInitParam->pswdofflen2);    	iLen = atoi(pstCmsCardInitParam->pswdvallen2);		memcpy( acBuf + iOffLen, acBuf2, iLen);	}	strcpy ( pcTrack2, acBuf );	sprintf( g_acTrcMsg ,"Track2[%s]",pcTrack2 );	TRCLOG2    /* 第三磁道信息 */	memset( acBuf, 0, sizeof( acBuf ));	strcpy ( acBuf, pstCmsCardInitParam->track3msg);    iOffLen = atoi(pstCmsCardInitParam->offlen3);    iLen = atoi(pstCmsCardInitParam->vallen3);	memcpy( acBuf + iOffLen, pcCardNo, iLen);	/* 判断密码校验值是否存在 */	if (pstCmsCardInitParam->passwdid[BIT1_LEN] == EXISTTRACK23 ||		pstCmsCardInitParam->passwdid[BIT1_LEN] == EXISTTRACK3 )	{		/* 计算密码校验值 */    	iOffLen = atoi(pstCmsCardInitParam->pswdofflen3);    	iLen = atoi(pstCmsCardInitParam->pswdvallen3);		memcpy( acBuf + iOffLen, acBuf2, iLen);	}	strcpy ( pcTrack3, acBuf );	sprintf( g_acTrcMsg, "cmsApiGenCardTrackInfo end " );	TRCLOG2	return SUCCESS;}/******************************************************* **	  函数名称:cmsApiGenMakeCardInfo **   功能描述:按制卡格式生成卡的制卡信息 **   输入参数: **   			pcCardNo					----	卡号 **   			pcBankFg					----	银行标志 **   			pcCustInf					----	客户信息 **   			pcValidDate					----	有效期 **   			pstCmsCardInitParam			----	卡片初始化参数表 **   输出参数: **   			pcTrack1					----	一磁道 **   			pcTrack2					----	二磁道 **   			pcTrack3					----	三磁道 **   			pcCardCover					----	卡面 **   返回结果:int **   			0				----	成功 **   			-1				----	失败*******************************************************/int	cmsApiGenMakeCardInfo( pcCardNo, pcBankFg, pcCustInf, pcValidDate, pcVouNo, pstCmsCardInitParam, pcTrack1, pcTrack2, pcTrack3, pcCardCover )char					*	pcCardNo;			/* 卡号	*/char					*	pcBankFg;			/* 银行标志	*/char					*	pcCustInf;			/* 客户信息 */char					*	pcValidDate;		/* 有效期 */char					*	pcVouNo;			/* 凭证号码 */struct cmscardinitparam *	pstCmsCardInitParam;/* 卡片初始化参数表	*/char					*	pcTrack1;			/* 一磁道			*/char					*	pcTrack2;			/* 二磁道			*/char					*	pcTrack3;			/* 三磁道			*/char					*	pcCardCover;		/* 卡面			*/{	/* 定义 局部变量 */	int					iRtn;					/* 函数返回值		*/	int					iLen;					/* 长度				*/	int					iFlag;					/* 标志				*/	int					iNum, iNum1, iNum2, iNum3, iNum4;	char  				acBuf[CONDITION_LEN];	/* 临时存储区		*/	char  				acBuf1[CONDITION_LEN];	/* 临时存储区		*/	int	i, ifound=0;	int (*nppfunc)( char *, char *, char *, char *, char *,char *,char *, char *, char * );	sprintf( g_acTrcMsg, "cmsApiGenMakeCardInfo begin " );	TRCLOG2	iRtn = cmsApiGenCardTrackInfo( pcCardNo, pstCmsCardInitParam, pcTrack1, pcTrack2, pcTrack3);	if (iRtn < 0)	{		return -1;	}	/* 获取数据库中配置的卡面信息 */	strpack( pstCmsCardInitParam->cardinitmsgfunc );	if ( strlen( pstCmsCardInitParam->cardinitmsgfunc ) )	{		i = 0 ;		while ( strcmp( nfunc_call[i].name, "NULL" ) )		{			if ( !strcmp ( nfunc_call[i].name, pstCmsCardInitParam->cardinitmsgfunc ) )			{				nppfunc	= nfunc_call[i].pfunc;				ifound = 1;				break;			}			i++ ;		}		if ( ifound == 0 )		{			strcpy( g_acRspCode , "999999" );			strcpy( g_acRspMsg , "卡面函数没有配置!" );			return FAILED;		}		iRtn = ( *nppfunc) ( pcCardNo, pcBankFg, pcCustInf, pcValidDate, pcVouNo, pcCardCover, pcTrack1, pcTrack2, pcTrack3 );		if ( iRtn )		{			strcpy( g_acRspCode , "999999" );			strcpy( g_acRspMsg , "生成卡面信息错!" );			return FAILED;		}	}	else 	{		memset( acBuf, 0, sizeof( acBuf ));		strcpy ( acBuf, pstCmsCardInitParam->cardinitmsg);		iLen = strlen(pstCmsCardInitParam->cardinitmsg);		iNum = iNum1 = iNum2 = iNum3 = iNum4 = 0;			for (iNum=0; iNum < iLen; iNum ++) 		{			/* 赋卡号 */			if (acBuf[iNum] == '@')			{				if (iNum1 >= strlen(pcCardNo))				{					acBuf[iNum] = ' ';				}				else				{					acBuf[iNum] = pcCardNo[iNum1];				}				iNum1 ++;			}				/* 赋银行标志 */			if (acBuf[iNum] == '$')			{				if (iNum2 >= strlen(pcBankFg))				{					acBuf[iNum] = ' ';				}				else				{					acBuf[iNum] = pcBankFg[iNum2];				}				iNum2 ++;			}				/* 赋客户信息 */			if (acBuf[iNum] == '*')			{				if (iNum3 >= strlen(pcCustInf))				{					acBuf[iNum] = ' ';				}				else				{					acBuf[iNum] = pcCustInf[iNum3];				}				iNum3 ++;			}				/* 赋有效期 */			if (acBuf[iNum] == '^')			{				if (iNum4 >= strlen(pcValidDate))				{					acBuf[iNum] = ' ';				}				else				{					acBuf[iNum] = pcValidDate[iNum4];				}				iNum4 ++;			}		}		strcpy( pcCardCover, acBuf);	}		/* 获取数据库中配置的二磁道补充信息 */	strpack( pstCmsCardInitParam->track2msgfunc );	if ( strlen( pstCmsCardInitParam->track2msgfunc ) )	{		ifound=0;		i = 0 ;		while ( strcmp( nfunc_call[i].name, "NULL" ) )		{			if ( !strcmp ( nfunc_call[i].name, pstCmsCardInitParam->track2msgfunc ) )			{				nppfunc	= nfunc_call[i].pfunc;				ifound = 1;				break;			}			i++ ;		}		if ( ifound == 0 )		{			strcpy( g_acRspCode , "999999" );			strcpy( g_acRspMsg , "卡二磁道函数没有配置!" );			return FAILED;		}		iRtn = ( *nppfunc) ( pcCardNo, pcBankFg, pcCustInf, pcValidDate, pcVouNo, pcCardCover, pcTrack1, pcTrack2, pcTrack3 );		if ( iRtn )		{			strcpy( g_acRspCode , "999999" );			strcpy( g_acRspMsg , "生成卡二磁道信息错!" );			return FAILED;		}	}	/* 获取数据库中配置的三磁道补充信息 */	strpack( pstCmsCardInitParam->track3msgfunc );	if ( strlen( pstCmsCardInitParam->track3msgfunc ) )	{		ifound=0;		i = 0 ;		while ( strcmp( nfunc_call[i].name, "NULL" ) )		{			if ( !strcmp ( nfunc_call[i].name, pstCmsCardInitParam->track3msgfunc ) )			{				nppfunc	= nfunc_call[i].pfunc;				ifound = 1;				break;			}			i++ ;		}		if ( ifound == 0 )		{			strcpy( g_acRspCode , "999999" );			strcpy( g_acRspMsg , "卡三磁道函数没有配置!" );			return FAILED;		}		iRtn = ( *nppfunc) ( pcCardNo, pcBankFg, pcCustInf, pcValidDate, pcVouNo, pcCardCover, pcTrack1, pcTrack2, pcTrack3 );		if ( iRtn )		{			strcpy( g_acRspCode , "999999" );			strcpy( g_acRspMsg , "生成卡三磁道信息错!" );			return FAILED;		}	}	sprintf( g_acTrcMsg, "cmsApiGenMakeCardInfo end " );	TRCLOG2	return SUCCESS;}/******************************************************* **	  函数名称:cmsGenCardCovInfo **   功能描述:按制卡格式生成卡的卡面信息(哈尔滨) **   输入参数: **   			pcCardNo					----	卡号 **   			pcBankFg					----	银行标志 **   			pcCustInf					----	客户信息 **   			pcValidDate					----	有效期 **   			pcVouNo						----	凭证号码 **   输出参数: **   			pcCardCover					----	卡面 **   			pcTrack1					----	磁道一 **   			pcTrack2					----	磁道二 **   			pcTrack3					----	磁道三 **   返回结果:int **   			0				----	成功 **   			-1				----	失败*******************************************************/int	cmsGenCardCovInfo( pcCardNo, pcBankFg, pcCustInf, pcValidDate, pcVouNo, pcCardCover, pcTrack1, pcTrack2, pcTrack3  )char					*	pcCardNo;			/* 卡号	*/char					*	pcBankFg;			/* 银行标志	*/char					*	pcCustInf;			/* 客户信息 */char					*	pcValidDate;		/* 有效期 */char					*	pcVouNo;			/* 凭证号码 */char					*	pcCardCover;		/* 卡面			*/char					*	pcTrack1;		/* 卡磁道一		*/

⌨️ 快捷键说明

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