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

📄 dpsttodeposit.pc

📁 proc业务处理程序
💻 PC
📖 第 1 页 / 共 2 页
字号:
EXEC SQL INCLUDE SQLCA;
EXEC SQL WHENEVER NOTFOUND continue;
EXEC SQL WHENEVER SQLERROR continue;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "dpstTodeposit.h"

int main(int argc, char *argv[]) {
	int retval;
	WORKFLOW_RECORD workflow;
	DPST_RECORD my_dpst;
	my_dpst.next=NULL;
	workflow.next=NULL;
	DEPOSITRECORD g_depositrec;
	char s_usrpwd[60];

	if (argc!=2) {
		printf("格式:%s usr/pwd \n", argv[0]);
		exit(0);
	}

	/* 初始化程序变量 */
	bzero(s_usrpwd, sizeof(s_usrpwd));

	/*读入参数*/
	strcpy(s_usrpwd, argv[1]);

	printf("The program named %s started!\n\n",argv[0]);

	retval = l_CheckIfStartup_All(argc,argv);
	if(retval<0)
	{
		sprintf(szmsg,"程序 %s 已启动\n",argv[0]);
		ShowMsg(0,"PZZ",szmsg);
		Exit_Process();
	}

	printf("Checked whether the same program started !\n\n");

	Open_File();

	/*联结数据库*/
	retval=l_db_connect(argv[1]);

	if(retval==0)
	{
		sprintf(szmsg,"连接数据库成功.......");
		ShowMsg(2,"RZZ",szmsg);
	}
	else
	{
		sprintf(szmsg,"密码%s连接数据库失败(已改为二次登陆).......",argv[1]);
		ShowMsg(2,"PZZ",szmsg);
		Exit_Process();
	}

	while (1) {
		EXEC SQL DECLARE cur_emp CURSOR for
		select subscrbid,areaid,deposit,transn from tab_subscrbdpst a
		where DPSTRTNDATE<=sysdate and flag='02' and dpsttypeid in(20,30) and stat!='0';
		if (sqlca.sqlcode !=0) {/*== 1403) {*/
			printf("QUERY TAB_subscrbdpst ERROR! SQLCODE: %d\n", sqlca.sqlcode);
			fprintf(gfp_err,"QUERY TAB_subscrbdpst ERROR! SQLCODE: %d\n");
			fflush(gfp_err);
			EXEC SQL ROLLBACK;
			exit(0);
		}
		EXEC SQL OPEN cur_emp;
		EXEC SQL for :MAX_STR_NUM FETCH cur_emp into
		:my_dpst.subscrbid,
		:my_dpst.areaid,
		:my_dpst.deposit,
		:my_dpst.transn;
		my_dpst.rownum = sqlca.sqlerrd[2];
		printf("dpst->rownum:%d\n", my_dpst.rownum);
		if (my_dpst.rownum>0) {
			dpstTodeposit(&my_dpst, &g_depositrec);
			back_dpst(&my_dpst, &g_depositrec, &workflow);
			l_db_upd_subscrbdpst(&my_dpst);
		}
		EXEC SQL CLOSE cur_emp;
		EXEC SQL commit work /*release*/;
		Write_Log(&my_dpst);
		sprintf(szmsg,"今日处理完成,明天继续处理.......");
		ShowMsg(2,"RZZ",szmsg);
		sleep(5);
		/*sleep(24*60*60);*/
	}
	Close_File();
	/*EXEC SQL ROLLBACK WORK RELEASE;*/
	/*EXEC SQL commit work release;*/
	return 0;
}

void dpstTodeposit(DPST_RECORD * mdpst, DEPOSITRECORD * depositrec) {
	DPST_RECORD *dpst;
	dpst = mdpst;
	DEPOSITRECORD *p_deposit;
	long l_count;
	gp_deposit=p_deposit=depositrec;
	bzero(p_deposit, sizeof(DEPOSITRECORD));

	EXEC SQL BEGIN DECLARE SECTION;
	Char_15 s_paydate;
	Char_17 s_paysn;
	Char_17 s_predepositsn;
	Char_17 s_transn;
	Char_12 l_svcnum;
	Char_3 l_svcid;/*业务类型*/
	Char_7 s_areaid;
	long l_acctid=0;
	Char_3 s_subscrbchrtid;
	char s_svcid[3];
	char s_svcstat[3];
	char s_opendate[9];
	Char_9 s_opendpt;

	Char_12 optrid;
	Char_9 s_acptsiteid;
	EXEC SQL END DECLARE SECTION;

	bzero(s_paydate, sizeof(s_paydate));
	bzero(s_paysn,sizeof(s_paysn));
	bzero(s_predepositsn,sizeof(s_predepositsn));
	bzero(s_transn,sizeof(s_transn));
	bzero(s_areaid,sizeof(s_areaid));
	bzero(s_subscrbchrtid,sizeof(s_subscrbchrtid));
	bzero(s_svcid,sizeof(s_svcid));
	bzero(s_opendate,sizeof(s_opendate));
	bzero(s_svcstat,sizeof(s_svcstat));

	/*得到预交日期*/
	EXEC SQL select to_char(sysdate,'yyyymmddhh24miss')
	into :s_paydate from dual;
	if(sqlca.sqlcode!=0)
	{
		fprintf(gfp_err,"Get the date failed with error_code %d\n",sqlca.sqlcode);
		fflush(gfp_err);
		printf("Get the date failed with error_code %d\n",sqlca.sqlcode);
		exit(0);
	}

	int j = dpst->rownum;
	int i = 0;

	while (j>i) {
		/*printf("subscrbid=%d,transn=%s\n", dpst->subscrbid[i], dpst->transn[i]);*/
		/* 得到流水号 */
		EXEC SQL
		select to_char(sysdate,'yymmdd')||lpad(to_char(payseq.nextval),10,'0'),
		to_char(sysdate,'yymmdd')||lpad(to_char(prepayseq.nextval),10,'0'),
				to_char(sysdate,'yymmdd')||lpad(to_char(transeq.nextval),10,'0')
						into :s_paysn,:s_predepositsn,:s_transn from dual;
						if (sqlca.sqlcode!=0) {
							fprintf(gfp_err,"Get the sequence number failed with error_code %d\n",sqlca.sqlcode);
							fflush(gfp_err);
							printf("Get the sequence number failed with error_code %d\n",
									sqlca.sqlcode);
							exit(0);
						}
						/*printf("s_paysn=%s,s_predepositsn=%s,s_transn=%s\n",s_paysn,s_predepositsn,s_transn);*/

						EXEC SQL
						select optrid,acptsiteid
						into :optrid,:s_acptsiteid from tab_workflow a
						where a.subscrbid=:dpst->subscrbid[i] and a.transn=:dpst->transn[i];

						if (sqlca.sqlcode!=0) {
							fprintf(gfp_err,"Get the tab_workflow transn failed with error_code %d\n",sqlca.sqlcode);
							fprintf(gfp_err,"tab_workflow中不存在的transn: %s\n",dpst->transn[i]);
							fflush(gfp_err);
							printf("Get the tab_workflow transn failed with error_code %d\n",
									sqlca.sqlcode);
							printf("tab_workflow中不存在的transn: %s\n",dpst->transn[i]);
							exit(0);
						}
						printf("optrid=%s,s_acptsiteid=%s\n",optrid,s_acptsiteid);

						bzero(l_svcid, sizeof(l_svcid));
						EXEC SQL SELECT svcnum,nvl(s.areaid,' '),
						nvl(s.SUBSCRBCHRTID,'10'), to_char(opendate,'yyyymmdd'),svcstat,svcid,opendpt
										INTO :l_svcnum,:s_areaid,:s_subscrbchrtid,:s_opendate,:s_svcstat,:l_svcid,:s_opendpt
										FROM tab_subscrb s
										WHERE s.svcstat<>'9' and s.svcid in ('10','20')
												AND s.subscrbid=:dpst->subscrbid[i];
												if (sqlca.sqlcode==1403) {
													fprintf(gfp_err,"不存在用户: %d\n",
															dpst->subscrbid[i]);
													fflush(gfp_err);
													printf("不存在用户: %d\n",
															dpst->subscrbid[i]);

													continue;
												} else if (sqlca.sqlcode!=0) {
													fprintf(gfp_err,"Get the customer information failed with error_code %d\n",sqlca.sqlcode);
													fprintf(gfp_err,"The svcnum failed is %d \n",dpst->subscrbid[i]);
													fflush(gfp_err);
													printf("Get the customer information failed with error_code %d\n",
															sqlca.sqlcode);
													printf(
															"The svcnum failed is %d \n",
															dpst->subscrbid[i]);
													exit(0);
												}

												EXEC SQL SELECT nvl(a.acctid,0)
												INTO :l_acctid
												FROM tab_acctrelation a
												WHERE
												(a.expdate is null OR a.expdate>sysdate)
												AND
												a.subscrbid=:dpst->subscrbid[i]
												AND
												(a.ACCTITMTYPEID=-1 or a.ACCTITMTYPEID=1)
												;

												if (sqlca.sqlcode==1403) {
													fprintf(gfp_err,"不存在用户: %d\n",dpst->subscrbid[i]);
													fflush(gfp_err);
													printf("不存在用户: %d\n",dpst->subscrbid[i]);
													continue;
												} else if (sqlca.sqlcode!=0) {
													fprintf(gfp_err,"Get the acct information failed with error_code %d\n",sqlca.sqlcode);
													fprintf(gfp_err,"The svcnum failed is %d \n",dpst->subscrbid[i]);
													fflush(gfp_err);
													printf(
															"Get the acct information failed with error_code %d\n",
															sqlca.sqlcode);
													printf(
															"The svcnum failed is %d \n",
															dpst->subscrbid[i]);
													exit(0);
												}
												printf("l_acctid=%d,svcnum=%s,s_predepositsn=%s\n", l_acctid, l_svcnum,s_predepositsn);

												strcpy(dpst->opendpt[i],s_opendpt);

												/*置值*/
												p_deposit->subscrbid[i] =dpst->subscrbid[i];
												p_deposit->acctid[i] =l_acctid;
												p_deposit->predeposittypeid[i]=10;/*预存款类型,现金预存款*/

												strcpy(p_deposit->areaid[i],s_areaid);
												strcpy(p_deposit->predepositsn[i],s_predepositsn);
												strcpy(p_deposit->recordtype[i],"01");

												p_deposit->balance[i] = (double)dpst->deposit[i];
												strcpy(p_deposit->paysn[i],s_paysn);
												/*strcpy(p_deposit->accptareaid[p_deposit->rows], );*/
												strcpy(p_deposit->paydate[i],s_paydate);
												strcpy(p_deposit->paymode[i],"10");
												strcpy(p_deposit->optrtype[i],"10");
												strcpy(p_deposit->optrsn[i],s_transn);
												strcpy(p_deposit->optrid[i],optrid);
												p_deposit->amnt[i]=(double)dpst->deposit[i];

												p_deposit->acptsitetype[i]=20;
												strcpy(p_deposit->acptsiteid[i],s_acptsiteid);

												strcpy(p_deposit->recstat[i],"1");
												strcpy(p_deposit->transn[i],s_transn);
												strcpy(p_deposit->feeid[i],"118");
												strcpy(p_deposit->state[i],"0");
												strcpy(p_deposit->ordertype[i],"10");

												strcpy(p_deposit->servitm[i],"107");
												strcpy(p_deposit->servdtal[i],"押金转预存款");
												p_deposit->rows=++i;
											}

											l_db_ins_pay();
											l_db_ins_paydetail();
											l_db_ins_predeposit();
											l_db_ins_predepositdtal();
											l_db_ins_serv_history("107","押金转预存款");
										}

void back_dpst(DPST_RECORD * mdpst, DEPOSITRECORD * depositrec,
		WORKFLOW_RECORD *workflow) {
	DPST_RECORD *dpst;
	dpst = mdpst;

	DEPOSITRECORD *p_deposit;
	/*bzero(p_deposit, sizeof(p_deposit)); 此处这样写会出问题,因为押金结构体已经初始化过了*/
	p_deposit=depositrec;

	WORKFLOW_RECORD *p_workflow;
	p_workflow=workflow;

	EXEC SQL BEGIN DECLARE SECTION;
	Char_15 s_paydate;
	Char_17 s_paysn;
	Char_17 s_predepositsn;

	Char_17 s_transn;
	Char_12 l_svcnum;
	Char_3 l_svcid;/*业务类型*/
	Char_7 s_areaid;
	long l_acctid=0;
	Char_3 s_subscrbchrtid;
	char s_svcid[3];
	char s_svcstat[3];
	char s_opendate[9];

	Char_12 optrid;

⌨️ 快捷键说明

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