credit_rpt_tool.c

来自「在SCO UNIX制定界面程序 可根据文件配制菜单,而不必修改源程序,非常方便」· C语言 代码 · 共 1,130 行 · 第 1/3 页

C
1,130
字号
	
	system ( cmd );
	
#if 0
	system ( "rm -f /tmp/.mer_bc_mx 2>/dev/null 1>/dev/null" );
#endif
}

void FileHead_wd_mx ( WD_RPT_ITEM *w_r_item )
{
	if ( (print_enable&WD_MX) == 0 ) return ;

	if ( wd_mx_fp == NULL ) {
		wd_mx_fp = fopen ( "/tmp/.wd_mx.rpt" , "w+" );
		
		if ( wd_mx_fp == NULL ) 
			return ;
	}

	fp = wd_mx_fp;

	fprintf(fp, "%-15.15s%-8.8s%6.6s%08ld |%35s中国银行BTS系统%6.6s\n", w_r_item->m_id, "00000000", "000000", line++%100000000, " ", rpt_head);
	fprintf(fp, "%-15.15s%-8.8s%6.6s%08ld |%35s网点交易明细报表\n", w_r_item->m_id, "00000000", "000000", line++%100000000, " ");
	fprintf(fp, "%-15.15s%-8.8s%6.6s%08ld |BTS-703%52s清算日期: %s-%s\n", w_r_item->m_id, "00000000", "000000", line++%100000000, " ", s_logic_date, e_logic_date);
	get_bank_name(G_bankid, "00", bank_name);
	getdatef(cre_date, "/");
	gettimef(cre_time, ":");
	fprintf(fp, "%-15.15s%-8.8s%6.6s%08ld |%-5.5s%-66s%s %s\n%10.10s%8.8s%6.6s%08ld |\n", w_r_item->m_id, "00000000", "000000", line%100000000, G_bankid, bank_name, cre_date, cre_time, w_r_item->m_id, "00000000", "000000", (line+1)%100000000);

	line+=2;

	fprintf(fp, "-15.15s%-8.88s%6.6s%08ld |网 点 号: %s\n", w_r_item->m_id, "00000000", "000000", line++%100000000, w_r_item->m_id);
	fprintf(fp, "%-15.15s%-8.8s%6.6s%08ld |网点名称: %s\n", w_r_item->m_id, "00000000", "000000", line++%100000000, w_r_item->m_name);
	fprintf(fp, "%-15.15s%-8.8s%6.6s%08ld |------------------------------------------------------------------------------------------\n", w_r_item->m_id, "00000000", "000000", line++%100000000);

	fprintf(fp, "%-15.15s%-8.8s%6.6s%08ld |%-10s %-19s %6s %14s %-8s %-8s %-10s %-8s\n", w_r_item->m_id, "00000000", "000000", line++%100000000, "网点号", "卡  号", "授权号", "交易金额", "交易类型", "原 类 型", "交易日期", "交易时间");

	fprintf(fp, "%-15.15s%-8.8s%6.6s%08ld |------------------------------------------------------------------------------------------\n", w_r_item->m_id, "00000000", "000000", line++%100000000);
}

void FileDetail_wd_mx ()
{
char	buf[10], old[10];
char	date[9], time[7];

	if ( wd_mx_fp == NULL ) return ;
	
	fp = wd_mx_fp;

	l_type2buf(ls.tran_type, ls.void_tran_type, ls.offline_flag, buf);

	if (ls.tran_type == POS_VOID)
		l_type2buf(ls.void_tran_type, 0, ls.offline_flag, old);
	else
		old[0] = 0;

	sprintf(date, "%8.8s", ls.local_sys_date);
	sprintf(time, "%6.6s", ls.local_sys_time);

	fprintf(fp, "%-15.15s%8.8s%6.6s%08ld |%-15.15s %-19.19s %6s %14.2lf %-8s %-8s %-10s %-8s\n", ls.merchant_id, date, time, line++%100000000, ls.merchant_id, ls.card_no, ls.auth_no, ls.tran_amt, buf, old, ls.local_sys_date, ls.local_sys_time);

}

void FileTail_wd_mx ( WD_RPT_ITEM *w_r_item )
{
	if ( wd_mx_fp == NULL ) return ;
	
	fp = wd_mx_fp;

	fprintf(fp, "%-15.15s%8.8s%6.6s%08ld |------------------------------------------------------------------------------------------\n", w_r_item->m_id, "99999999", "999999", line++%100000000);
	fprintf(fp, "%-15.15s%-8.8s%6.6s%08ld |%6s  %14s %8s %14s %8s %14s %8s\n", w_r_item->m_id, "99999999", "999999", line++%100000000, "合  计", "贷记金额", "贷记笔数", "借记金额", "借记笔数", "总金额", "总笔数");
	fprintf(fp, "%-15.15s%-8.8s%6.6s%08ld |%6s  %14.2lf %8d %14.2lf %8d %14.2lf %8d\n%-15.15s%-8.8s%6.6s%08ld |\n", w_r_item->m_id, "99999999", "999999", line%100000000, " ", w_r_item->credit_amt, w_r_item->credit_num, w_r_item->debit_amt, w_r_item->debit_num, w_r_item->credit_amt-w_r_item->debit_amt, w_r_item->credit_num+w_r_item->debit_num, w_r_item->m_id, "99999999", "999999", (line+1)%100000000);
	line+=2;

}

void create_wd_mx ()
{
	char cmd[300];

	if ( (print_enable&WD_MX) == 0 ) return;

	sprintf(cmd, "sort -n /tmp/.wd_mx.rpt 2>/dev/null | sed \"s/^.* |//g\" > %s/prt/%s/%s.wd_mx 2>/dev/null",
		getenv("WORKDIR"),
		G_bankid, rpt_file_head);
	system(cmd);

	system("rm -f /tmp/.wd_mx.rpt 2>/dev/null 1>/dev/null");
}

void FileHead_bank_up_mx ( BANK_RPT_ITEM *b_r_item )
{
	if ( cre_bank_up_mx_fp == NULL ) {
		cre_bank_up_mx_fp = fopen ( "/tmp/.cre_bank_up_mx.rpt" , "w+" );
		
		if ( cre_bank_up_mx_fp == NULL ) 
			return ;
	}

	fp = cre_bank_up_mx_fp;
	
	fprintf(fp, "%4.4s%08ld |%52s中国银行BTS系统信用卡\n", b_r_item->bank_id , line++%100000000 , " ");
	fprintf(fp, "%4.4s%08ld |%52s全辖清算上报明细报表\n", b_r_item->bank_id , line++%100000000 , " ");
	fprintf(fp, "%4.4s%08ld |BTS-601%99s清算日期: %s\n", b_r_item->bank_id , line++%100000000 , " ", ls.snd_settle_date );
	getdatef(cre_date, "/");
	gettimef(cre_time, ":");
	fprintf(fp, "%4.4s%08ld |%-5.5s%-102s%s %s\n", b_r_item->bank_id, line++%100000000 , b_r_item->bank_id, b_r_item->bank_name, cre_date, cre_time);
	fprintf(fp, "%4.4s%08ld |------------------------------------------------------------------------------------------------------------------------------\n" , b_r_item->bank_id , line++%100000000 );
	fprintf(fp, "%4.4s%08ld |%-19s %-8s %14s %6s %14s %6s %-15.15s %-8.8s %-6s %-6s %-10s %-8s\n", b_r_item->bank_id , line++%100000000 , "卡  号", "交易类型", "交易金额", "手续费", "清算金额", "授权码", "商户号", "EDC 号", "收单行", "发卡行", "交易日期", "交易时间");
	fprintf(fp, "%4.4s%08ld |------------------------------------------------------------------------------------------------------------------------------\n" , b_r_item->bank_id , line++%100000000 );

}

void FileDetail_bank_up_mx ( BANK_RPT_ITEM *b_r_item )
{
	char	buf[10];
	char tmp_date[11];	/* YYYY/MM/DD */
	char tmp_time[9];	/* hh:mm:ss */

	if ( cre_bank_up_mx_fp == NULL ) return ;
	
	fp = cre_bank_up_mx_fp;
	
	str2date(tmp_date, ls.local_sys_date, "/");
	str2time(tmp_time, ls.local_sys_time, ":");

	l_type2buf(ls.tran_type, ls.void_tran_type, ls.offline_flag, buf);
	fprintf(fp, "%4.4s%08ld |%-19.19s %-8s %14.2lf %6.2lf %14.2lf %6s %-15.15s %-8.8s %-6.6s %-6.6s %-10s %-8s\n", b_r_item->bank_id , line++%100000000 , ls.card_no, buf, ls.tran_amt, fabs(cre_tip), ls.tran_amt + cre_tip, ls.auth_no, ls.merchant_id, ls.terminal_id, ls.acq_bank_id, ls.iss_bank_id, tmp_date, tmp_time);

}

void FileTail_bank_up_mx ( BANK_RPT_ITEM *b_r_item )
{
char	buf[10];

	if ( cre_bank_up_mx_fp == NULL ) return ;
	
	fp = cre_bank_up_mx_fp;
	
	fprintf(fp, "%4.4s%08ld |------------------------------------------------------------------------------------------------------------------------------\n" , b_r_item->bank_id , line++%100000000 );

	fprintf(fp, "%4.4s%08ld |%s %s %14.2lf %s %6d %s %14.2lf %s %6d %s %14.2lf %s %6d\n%4.4s%08ld |\n", b_r_item->bank_id, line%100000000 , "总  计", "贷记金额", b_r_item->up_credit_amt, "贷记笔数", b_r_item->up_credit_num, "借记金额", b_r_item->up_debit_amt,  "借记笔数", b_r_item->up_debit_num, "轧差金额", b_r_item->up_credit_amt-b_r_item->up_debit_amt, "笔数", b_r_item->up_credit_num+b_r_item->up_debit_num , b_r_item->bank_id , (line+1)%100000000 );
	
	line+=2;

}

void create_cre_bank_up_mx ()
{
	char cmd[160];

	if (mx1[0]) {
		sprintf(cmd, "sort -n /tmp/.cre_bank_up_mx.rpt 2>/dev/null | sed \"s/^.* |//g\" > %s 2>/dev/null", mx1);
		system(cmd);
	}
	
	system("rm -f /tmp/.cre_bank_up_mx.rpt 2>/dev/null 1>/dev/null");
}

void FileHead_bank_down_mx ( BANK_RPT_ITEM *b_r_item )
{
	if ( cre_bank_down_mx_fp == NULL ) {
		cre_bank_down_mx_fp = fopen ( "/tmp/.cre_bank_down_mx.rpt" , "w+" );
		
		if ( cre_bank_down_mx_fp == NULL ) 
			return ;
	}

	fp = cre_bank_down_mx_fp;
	
	fprintf(fp, "%4.4s%08ld |%52s中国银行BTS系统信用卡\n", b_r_item->bank_id , line++%100000000 , " ");
	fprintf(fp, "%4.4s%08ld |%52s全辖清算下划明细报表\n", b_r_item->bank_id , line++%100000000 , " ");
	fprintf(fp, "%4.4s%08ld |BTS-603%99s清算日期: %s\n", b_r_item->bank_id , line++%100000000 , " ", ls.snd_settle_date );
	getdatef(cre_date, "/");
	gettimef(cre_time, ":");
	fprintf(fp, "%4.4s%08ld |%-5.5s%-102s%s %s\n", b_r_item->bank_id, line++%100000000 , b_r_item->bank_id, b_r_item->bank_name, cre_date, cre_time);
	fprintf(fp, "%4.4s%08ld |------------------------------------------------------------------------------------------------------------------------------\n" , b_r_item->bank_id , line++%100000000 );
	fprintf(fp, "%4.4s%08ld |%-19s %-8s %14s %6s %14s %6s %-15.15s %-8.8s %-6s %-6s %-10s %-8s\n", b_r_item->bank_id , line++%100000000 , "卡  号", "交易类型", "交易金额", "手续费", "清算金额", "授权码", "商户号", "EDC 号", "收单行", "发卡行", "交易日期", "交易时间");
	fprintf(fp, "%4.4s%08ld |------------------------------------------------------------------------------------------------------------------------------\n" , b_r_item->bank_id , line++%100000000 );

}

void FileDetail_bank_down_mx ( BANK_RPT_ITEM *b_r_item )
{
	char	buf[10];
	char tmp_date[11];	/* YYYY/MM/DD */
	char tmp_time[9];	/* hh:mm:ss */

	if ( cre_bank_down_mx_fp == NULL ) return ;
	
	fp = cre_bank_down_mx_fp;
	
	str2date(tmp_date, ls.local_sys_date, "/");
	str2time(tmp_time, ls.local_sys_time, ":");

	l_type2buf(ls.tran_type, ls.void_tran_type, ls.offline_flag, buf);
	fprintf(fp, "%4.4s%08ld |%-19.19s %-8s %14.2lf %6.2lf %14.2lf %6s %-15.15s %-8.8s %-6.6s %-6.6s %-10s %-8s\n", b_r_item->bank_id , line++%100000000 , ls.card_no, buf, ls.tran_amt, fabs(cre_tip), ls.tran_amt + cre_tip, ls.auth_no, ls.merchant_id, ls.terminal_id, ls.acq_bank_id, ls.iss_bank_id, tmp_date, tmp_time);

}

void FileTail_bank_down_mx ( BANK_RPT_ITEM *b_r_item )
{
char	buf[10];

	if ( cre_bank_down_mx_fp == NULL ) return ;
	
	fp = cre_bank_down_mx_fp;
	
	fprintf(fp, "%4.4s%08ld |------------------------------------------------------------------------------------------------------------------------------\n" , b_r_item->bank_id , line++%100000000 );

	fprintf(fp, "%4.4s%08ld |%s %s %14.2lf %s %6d %s %14.2lf %s %6d %s %14.2lf %s %6d\n%4.4s%08ld |\n", b_r_item->bank_id, line%100000000 , "总  计", "贷记金额", b_r_item->down_credit_amt, "贷记笔数", b_r_item->down_credit_num, "借记金额", b_r_item->down_debit_amt,  "借记笔数", b_r_item->down_debit_num, "轧差金额", b_r_item->down_credit_amt-b_r_item->down_debit_amt, "笔数", b_r_item->down_credit_num+b_r_item->down_debit_num, b_r_item->bank_id , (line+1)%100000000 );

	line+=2;

}

void create_cre_bank_down_mx ()
{
	char cmd[160];

	if (mx2[0]) {
		sprintf(cmd, "sort -n /tmp/.cre_bank_down_mx.rpt 2>/dev/null | sed \"s/^.* |//g\" > %s 2>/dev/null", mx2);
		system(cmd);
	}
	
	system("rm -f /tmp/.cre_bank_down_mx.rpt 2>/dev/null 1>/dev/null");
}

void FileHead_edc_bhz ( MER_RPT_ITEM *m_r_item )
{
	if ( (print_enable&EDC_BHZ) == 0 ) return ;

	if ( edc_bhz_fp == NULL ) {
		edc_bhz_fp = fopen ( "/tmp/.edc_bhz" , "w+" );
		
		if ( edc_bhz_fp == NULL ) 
			return ;
	}
	
	fp = edc_bhz_fp;
	
	fprintf(fp, "%-15.15s%-8.8s%08ld%08ld |%45s中国银行BTS系统%6.6s\n", m_r_item->m_id, "00000000", 0, line++%100000000,  " ", rpt_head);
	fprintf(fp, "%-15.15s%-8.8s%08ld%08ld |%45sEDC交易批次统计报表\n", m_r_item->m_id, "00000000", 0, line++%100000000, " ");
	fprintf(fp, "%-15.15s%-8.8s%08ld%08ld |BTS-300%65s清算日期: %s-%s\n", m_r_item->m_id, "00000000", 0, line++%100000000, " ", s_logic_date, e_logic_date);
	get_bank_name(G_bankid, "00", bank_name);
	getdatef(cre_date, "/");
	gettimef(cre_time, ":");
	fprintf(fp, "%-15.15s%-8.8s%08ld%08ld |%-5.5s%-79s%s %s\n", m_r_item->m_id, "00000000", 0, line++%10000000, G_bankid, bank_name, cre_date, cre_time);

	fprintf(fp, "%-15.15s%-8.8s%08ld%08ld |商户号: %-15.15s 商户名称: %s\n", m_r_item->m_id, "00000000", 0, line++%100000000, m_r_item->m_id, m_r_item->m_name);
	fprintf(fp, "%-15.15s%-8.8s%08ld%08ld |-----------------------------------------------------------------------------------------------------------------\n", m_r_item->m_id, "00000000", 0, line++%100000000);

	fprintf(fp, "%-15.15s%-8.8s%08ld%08ld |%-8s %7s %14s %8s %14s %8s %14s %14s %8s\n", m_r_item->m_id, "00000000", 0, line++%100000000, "EDC 号", "批次号", "交易金额", "交易笔数", "退货金额", "退货笔数", "手续费", "总金额", "总笔数");

	fprintf(fp, "%-15.15s%-8.8s%08ld%08ld |-----------------------------------------------------------------------------------------------------------------\n", m_r_item->m_id, "00000000", 0, line++%100000000);

}

void FileDetail_edc_bhz ( MER_RPT_ITEM *m_r_item , TER_RPT_ITEM *t_item )
{
	if ( edc_bhz_fp == NULL ) return;
	
	fp = edc_bhz_fp;

	fprintf(fp, "%-15.15s%-8.8s%08ld%08ld |%-8s %7ld %14.2lf %8d %14.2lf %8d %14.2lf %14.2lf %8d\n", m_r_item->m_id, t_item->t_id, t_item->batch_no, line++%100000000, t_item->t_id, t_item->batch_no, t_item->pur_amt, t_item->pur_num, t_item->refund_amt, t_item->refund_num, t_item->fee, t_item->pur_amt-t_item->refund_amt-t_item->fee, t_item->pur_num+t_item->refund_num);

}

void FileTail_edc_bhz ( MER_RPT_ITEM *m_r_item )
{
	if ( edc_bhz_fp == NULL ) return;
	
	fp = edc_bhz_fp;

	fprintf(fp, "%-15.15s%-8.8s%08ld%08ld |-----------------------------------------------------------------------------------------------------------------\n", m_r_item->m_id, "99999999", 0, line++%100000000);

	fprintf(fp, "%-15.15s%-8.8s%08ld%08ld |%-16s %14.2lf %8d %14.2lf %8d %14.2lf %14.2lf %8d\n", m_r_item->m_id, "99999999", 0, line++%100000000, "合  计", m_r_item->pur_amt, m_r_item->pur_num, m_r_item->refund_amt, m_r_item->refund_num, m_r_item->fee, m_r_item->pur_amt-m_r_item->refund_amt-m_r_item->fee, m_r_item->pur_num+m_r_item->refund_num);
	fprintf(fp, "%-15.15s%-8.8s%08ld%08ld |\n", m_r_item->m_id, "99999999", 0, line++%100000000);
	fprintf(fp, "%-15.15s%-8.8s%08ld%08ld |\n", m_r_item->m_id, "99999999", 0, line++%100000000);
	fprintf(fp, "%-15.15s%-8.8s%08ld%08ld |\n", m_r_item->m_id, "99999999", 0, line++%100000000);
}

void create_edc_bhz ()
{
char	cmd[300];

	if ( (print_enable&EDC_BHZ) == 0 ) return ;

	sprintf ( cmd , "sort -n /tmp/.edc_bhz 2>/dev/null | sed \"s/^.*|//\" >%s/prt/%s/%s.edc_bhz 2>/dev/null",
		getenv("WORKDIR"),
		G_bankid, rpt_file_head);
	system ( cmd );
	
	system ( "rm -f /tmp/.edc_bhz 2>/dev/null" );
}
	
	
void FileHead_mer_bhz ()
{
char path[128];

	if ( (print_enable&MER_BHZ) == 0 ) return ;

	if ( mer_bhz_fp == NULL ) {
		sprintf ( path , "%s/prt/%s/%s.mer_bhz",
			getenv("WORKDIR"),
			G_bankid, rpt_file_head);
		
		mer_bhz_fp = fopen ( path , "w+" );
		
		if ( mer_bhz_fp == NULL ) 
			return ;
	}
	
	fp = mer_bhz_fp;

	fprintf(fp, "%38s中国银行BTS系统%6.6s\n", " " , rpt_head );
	fprintf(fp, "%38s商户交易批次汇总报表\n", " ");
	str2date(s_logic_date1, s_logic_date, "/");
	str2date(e_logic_date1, e_logic_date, "/");
	fprintf(fp, "BTS-708%60s清算日期: %s-%s\n", " ", s_logic_date1 , e_logic_date1 );
	get_bank_name(G_bankid, "00", bank_name);
	getdatef(cre_date, "/");
	gettimef(cre_time, ":");
	fprintf(fp, "%-5.5s%-74s%s %s\n", G_bankid, bank_name, cre_date, cre_time);
	fprintf(fp, "------------------------------------------------------------------------------------------------------------\n" );

	fprintf(fp, "%-15.15s %-40.40s %14s %8s %14s %14s\n", "商户号", "商户名", "交易金额", "交易笔数", " 手续费 ", "  净额  ");

	fprintf(fp, "------------------------------------------------------------------------------------------------------------\n" );
}
	
void FileDetail_mer_bhz ( MER_RPT_ITEM *m_r_item )
{
	if ( mer_bhz_fp == NULL ) return ;
	
	fp = mer_bhz_fp;

	fprintf(fp, "%-15.15s %-40.40s %14.2lf %8d %14.2lf %14.2lf \n", m_r_item->m_id, m_r_item->m_name , m_r_item->pur_amt, m_r_item->pur_num, m_r_item->fee, m_r_item->pur_amt-m_r_item->fee );

}

void FileTail_mer_bhz ( MER_RPT_TOTAL *mer_rpt_total )
{
	if ( mer_bhz_fp == NULL ) return ;
	
	fp = mer_bhz_fp;

	fprintf(fp, "------------------------------------------------------------------------------------------------------------\n" );
	if (mer_rpt_total->pur_num)
		fprintf(fp, "%-10s %40.40s %14.2lf %8d %14.2lf %14.2lf\n", "合  计", " " , mer_rpt_total->pur_amt, mer_rpt_total->pur_num, mer_rpt_total->fee , mer_rpt_total->pur_amt-mer_rpt_total->fee );

}

void FileHead_wd_hz ( )
{
char path[128];

	if ( (print_enable&WD_HZ) == 0 ) return;

	if ( wd_hz_fp == NULL ) {
		sprintf ( path , "%s/prt/%s/%s.wd_hz",
			getenv("WORKDIR"),
			G_bankid, rpt_file_head);

		wd_hz_fp = fopen ( path , "w+" );
		
		if ( wd_hz_fp == NULL ) 
			return ;
	}
	
	fp = wd_hz_fp;

	fprintf(fp, "%33s中国银行BTS系统%6.6s\n", " " , rpt_head );
	fprintf(fp, "%33s网点交易汇总报表\n", " ");
	str2date(s_logic_date1, s_logic_date, "/");
	str2date(e_logic_date1, e_logic_date, "/");

⌨️ 快捷键说明

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