static int GetSysParam(const char *para,char *value) { int ret; ST_CPACK aPack,sPack; memset(&sPack,0,sizeof sPack); memset(&aPack,0,sizeof aPack); ResetNormalCPack(&sPack,0,1); SetHeadCol(&sPack,F_SNAME,F_SNAME2,0); sPack.head.RequestType = 850007; strcpy(sPack.pack.sname,"GDCT"); strcpy(sPack.pack.sname2,para); ret = ExtCall(0,g_mainsvr_drtpno,g_mainsvr_func,0,3,&sPack,&aPack,NULL); if(ret>=0) { if(aPack.head.retCode!=0) return aPack.head.retCode; strncpy(value,aPack.pack.vsvarstr0,128); return 0; } else { return -1; } }
int Pos_WriteErrCard(INNER_TRANS_REQUEST * pNode) { int ret=0; char card_id[12+1]=""; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 // ST_PACK *out_pack = &(aPack.pack); ST_CPACK sPack; // 设置发送包 ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); des2src(card_id, pNode->CardNo); //向后台发起解挂申请 ResetNormalCPack(&sPack, 0, 1); sPack.head.RequestType = 847108; SetHeadCol(&sPack, F_LVOL0,F_LSERIAL1,F_LVOL2,0); // 设置发送windows BU的头部视图信息 //memcpy(&(sPack.pack), in_pack, sizeof(sPack.pack)); //判断登陆模式,使用客户号登陆还是学工号登陆 sPack.pack.lvol0=atoi(card_id); sPack.pack.lserial1=pNode->RecvNo; sPack.pack.lvol2=TXCODE_BANK_SCHOOL; ret = ExtCall(0, g_Bank.DRTP_BRANCH, g_Bank.BCC_BASEFUNCNO, 0, g_Bank.TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0||aPack.head.retCode!=0) { writelog(LOG_ERR,"Call 847108 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return E_TRANS_UNKNOW_ERROR; } return 0; }
//char buffer[20]=""; char temp[128]=""; int ho_OpCount=0; int delay_time=0; double ho_Fee_Change=0; int ret=0; FILE *fp; TIniFile tf; int nrows=0; char path_name[128]=""; char file_name[128]=""; BANK_TRANSFER_HEAD trans_head; BANK_TRANSFER_RECORD trans_record; T_v_tif_shopdeptfee v_shopdeptfee; T_t_cif_shop t_shop; //系统正在结算,可以生成划拨文件 //sleep(1); //ret=DB_v_tif_shopdeptfee_read_sum_fee(&ho_OpCount,&ho_Fee_Change); if(ret) { writelog(LOG_ERR,"DB_v_tif_shopdeptfee_read_sum_fee err [%d]",ret); return ret; } ho_OpCount=4; ho_Fee_Change=12345.98; strcpy(path_name,"/ykt/ykt/src/bank/ftp"); sprintf(file_name,"%s/fd_%8.8s",path_name,getsysdate(NULL)); #ifdef DEBUG // strcpy(path_name,"./ftp/fd_20041009"); writelog(LOG_ALERT,"file_name2=[%s]",file_name); #endif fp = fopen(file_name,"wb"); if (fp==NULL) { writelog(LOG_ALERT,"Open indicate file fail"); return -1; } memcpy(trans_head.rmb_batch_no,BATCH_NO,sizeof(trans_head.rmb_batch_no)); fprintf(fp,"%-14.14s",trans_head.rmb_batch_no); //批量编号 memcpy(trans_head.rmb_start_seq,"000000",6); fprintf(fp,"%-6.6s",trans_head.rmb_start_seq); //填000000 trans_head.rmb_acc_status='0'; fprintf(fp,"%c",trans_head.rmb_acc_status); //记帐状态(填0) trans_head.rmb_chk_status='2'; fprintf(fp,"%c",trans_head.rmb_chk_status); //检查状态(填2) sprintf(trans_head.rmb_total_amount,"%-13d",int(ho_Fee_Change*100)); fprintf(fp,"%-13.13s",trans_head.rmb_total_amount); //总金额(11位整数2位小数,无小数点) sprintf(trans_head.rmb_total_num,"%-6d",ho_OpCount); fprintf(fp,"%-6.6s",trans_head.rmb_total_num); //总笔数 fprintf(fp,"%-13.13s",trans_head.rmb_enter_amount); //入帐金额 fprintf(fp,"%-6.6s",trans_head.rmb_enter_num); //入帐笔数 sprintf(trans_head.rmb_unit_name,"%-40s",UNIT_NAME); fprintf(fp,"%-40.40s",trans_head.rmb_unit_name); //单位名称 #ifdef DEBUG writelog(LOG_ALERT,"trans_head.rmb_unit_name=[%s]",trans_head.rmb_unit_name); #endif strcpy(trans_head.rmb_unit_account,UNIT_ACCOUNT); //sprintf(trans_head.rmb_unit_account,"%-20s"UNIT_ACCOUNT); fprintf(fp,"%-20.20s",trans_head.rmb_unit_account); //单位帐号 #ifdef DEBUG writelog(LOG_ALERT,"trans_head.rmb_unit_account=[%s]",trans_head.rmb_unit_account); #endif memcpy(trans_head.rmb_apply_date,getsysdate(NULL),sizeof(trans_head.rmb_apply_date)); fprintf(fp,"%-8.8s",trans_head.rmb_apply_date); //申请入帐日期(当天日期) //memcpy(trans_head.rmb_send_date,trans_head.rmb_apply_date,sizeof(trans_head.rmb_apply_date)); memcpy(trans_head.rmb_send_date,getsystime(NULL),sizeof(trans_head.rmb_send_date)); fprintf(fp,"%-8.8s",trans_head.rmb_send_date); //上传日期(当天日期) #ifdef DEBUG printf("[%14.14s]\n",trans_head.rmb_batch_no ); //批量编号 printf("[%6.6s]\n",trans_head.rmb_start_seq ); //填000000 printf("[%c]\n",trans_head.rmb_acc_status ); //记帐状态(填0) printf("[%c]\n",trans_head.rmb_chk_status ); //检查状态(填2) printf("[%13.13s]\n",trans_head.rmb_total_amount ); //总金额(11位整数2位小数,无小数点) printf("[%6.6s]\n",trans_head.rmb_total_num ); //总笔数 printf("[%13.13s]\n",trans_head.rmb_enter_amount ); //入帐金额(11位整数2位小数,无小数点) printf("[%6.6s]\n",trans_head.rmb_enter_num ); //入帐笔数 printf("[%40.40s]\n",trans_head.rmb_unit_name ); //单位名称 printf("[%20.20s]\n",trans_head.rmb_unit_account ); //单位帐号 printf("[%8.8s]\n",trans_head.rmb_apply_date ); //申请入帐日期(当天日期) printf("[%8.8s]\n",trans_head.rmb_send_date ); //上传日期(当天日期) #endif //写入划拨文件 // fprintf(fp,(char*)(&trans_head)); strcpy(temp,"1"); ret=DB_v_tif_shopdeptfee_open_select_by_c6_and_is_indep(temp); if(ret) { //db_chk_err(__FILE__,__LINE__,&sqlca); writelog(LOG_ALERT,"DB_v_tif_shopdeptfee_open_select_by_c6_and_is_indep[%d]",ret); return ret; } while(1) { //初始化宿主变量 ho_Fee_Change=0; memset(&v_shopdeptfee,0,sizeof(v_shopdeptfee)); memset(&t_shop,0,sizeof(t_shop)); ret=DB_v_tif_shopdeptfee_fetch_select_by_c6(&v_shopdeptfee); if(ret) { if(DB_NOTFOUND==ret) { if(0==nrows) { writelog(LOG_ERR,"DB_v_tif_shopdeptfee_fetch_select_by_c6[%d]",ret); break; } else break; //循环记录结束 } else { //db_chk_err(__FILE__,__LINE__,&sqlca); writelog(LOG_ERR,"DB_v_tif_shopdeptfee_fetch_select_by_c6[%d]",ret); return ret; } } ret=DB_t_cif_shop_read_by_shop_id(v_shopdeptfee.shop_id,&t_shop); if(ret) { //db_chk_err(__FILE__,__LINE__,&sqlca); writelog(LOG_ALERT,"DB_t_cif_shop_read_by_shop_id[%d]",ret); return ret; } strcpy(trans_record.rmb_batch_no1,BATCH_NO); sprintf(trans_record.rmb_seq_no,"%d",nrows); trans_record.rmb_acc_status1='0'; trans_record.rmb_tran_kind='2'; strncpy(trans_record.rmb_cust_name,t_shop.b_act_name,sizeof(trans_record.rmb_cust_name)); strncpy(trans_record.rmb_acc_no,t_shop.b_act_id,sizeof(trans_record.rmb_acc_no)); trans_record.rmb_cb_cr='0'; sprintf(trans_record.rmb_tran_amt,"%f",ho_Fee_Change); strcpy(trans_record.rmb_cur_code,"001"); strcpy(trans_record.rmb_host_no,"00000000"); memcpy(trans_record.rmb_ret_code," ",sizeof(trans_record.rmb_ret_code)); strcpy(trans_record.rmb_acc_date,"00000000"); strcpy(trans_record.rmb_host_no1,"000000000"); strcpy(trans_record.rmb_open_branch,"0000000"); memcpy(trans_record.rmb_vcho_kind," ",sizeof(trans_record.rmb_vcho_kind)); strcpy(trans_record.rmb_vcho_bat_no,"00"); strcpy(trans_record.rmb_vcho_no,"000000000"); strcpy(trans_record.rmb_memo," "); strcpy(trans_record.rmb_tran_info," "); fprintf(fp,(char*)(&trans_record)); nrows++; } fclose(fp); memset(pBankTrans,0,BANK_TRANS_PACKLEN); //开始银行发送清算报文 memcpy( pBankTrans->TradeCode,TRADE_BANK_BALANCE, sizeof(pBankTrans->TradeCode)); //写交易代码 //写交易日期和交易时间 getsysdate(pBankTrans->TradeDate); getsystime(pBankTrans->TradeTime); //写院校代码 sprintf(pBankTrans->CustNo,"%-16s",SCHOOL_CODE); //写银行卡号-此处约定为划拨文件名 sprintf(pBankTrans->BankCardNo,"%8.8s",getsysdate(NULL)); //写校验mac码 //写校验mac码----林钦此处应该用银行回传回来的动态密钥做mac密钥,此处改过来了 generate_mac((char*)pBankTrans,sizeof(pBankTrans),pBankTrans->MAC); //ANSIX99(mac_key,(char*)(&BankTransPak), BANK_TRANS_PACKLEN-LEN_MAC,BankTransPak.MAC); TRACE_BANK_TRANS(pBankTrans,"send transfer package"); //发送数据到银行并同时接收银行数据,此处不判断返回的mac校验 ret=send_to_and_recv_from_bank((char*)pBankTrans,BANK_TRANS_PACKLEN, (char*)pBankTrans,BANK_TRANS_PACKLEN,delay_time); if(ret) { writelog(LOG_ERR,"send_to_and_recv_from_bank error,errcode=[%d]",ret); return E_TRANS_BANK_NOANSWER; } TRACE_BANK_TRANS(pBankTrans,"recv transfer package"); //农行暂时未校验该mac,所以暂时屏蔽掉 ret=check_mac((char*)pBankTrans,BANK_TRANS_PACKLEN); if(ret) { writelog(LOG_ERR,"Receive data mac verify error,error code is [%d] ",ret); //sprintf(pNode->RetCode,"%d",E_TRANS_BANK_RECVERR); return E_TRANS_BANK_RECVERR; } writelog(LOG_INFO,"Congratulation, transer succeed!"); return 0; } */ //判断该设备是否签到过 int device_login_yes_or_no(int device_id) { int ret=0; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 // ST_PACK *out_pack = &(aPack.pack); ST_CPACK sPack; // 设置发送包 ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); ResetNormalCPack(&sPack, 0, 1); sPack.head.RequestType = 240009; SetHeadCol(&sPack, F_SORDER2, 0); // 设置发送windows BU的头部视图信息 //memcpy(&(sPack.pack), in_pack, sizeof(sPack.pack)); sprintf(sPack.pack.sorder2,"%d",device_id); ret = ExtCall(0, g_Bank.DRTP_BRANCH, g_Bank.BCC_BASEFUNCNO, 0, g_Bank.TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0||aPack.head.retCode!=0) { if(ret<0) { writelog(LOG_ERR,"Call 240009 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return E_TRANS_UNKNOW_ERROR; } else { writelog(LOG_ERR,"Call 240009 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return aPack.head.retCode; } } return 0; }
int do_update_device_state(INNER_TRANS_REQUEST * pNode) { int ret=0; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 // ST_PACK *out_pack = &(aPack.pack); ST_CPACK sPack; // 设置发送包 ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); ResetNormalCPack(&sPack, 0, 1); sPack.head.RequestType = 930057; SetHeadCol(&sPack, F_SORDER2,0); // 设置发送windows BU的头部视图信息 des2src(sPack.pack.sorder2,pNode->TerminalId); ret = ExtCall(0, g_Bank.DRTP_BRANCH, g_Bank.BCC_BASEFUNCNO, 0, g_Bank.TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0||aPack.head.retCode!=0) { if(ret<0) { writelog(LOG_ERR,"Call 930057 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return E_TRANS_UNKNOW_ERROR; } else { writelog(LOG_ERR,"Call 930057 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return aPack.head.retCode; } } return 0; }
static int elect_room_check_get_name(ST_PACK *in_pack,ST_PACK *out_pack,transfer_control_t *trans_ctl) { int ret = 0; char c_drtbranch[10]=""; char c_bccbasefuncno[10]=""; int DRTP_BRANCH =0; int BCC_BASEFUNCNO =0; trans_ctl->check_user_pwd = 0; CTcpSocket tcpsocket ; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 ST_CPACK sPack; // 设置发送包 ret=GetParameter(2501, c_drtbranch); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } ret=GetParameter(2502, c_bccbasefuncno); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } DRTP_BRANCH = atoi(c_drtbranch); BCC_BASEFUNCNO = atoi(c_bccbasefuncno); ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); ResetNormalCPack(&sPack, 0, 1); SetHeadCol(&sPack, F_SSECTYPES,F_LVOL0,F_SCUST_AUTH,0); // 设置发送windows BU的头部视图信息 sPack.head.RequestType = 847356; sPack.pack.lvol0=in_pack->lvol10;//房间号 ret = ExtCall(0, DRTP_BRANCH, BCC_BASEFUNCNO, 0, TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0||aPack.head.retCode!=0) { if(ret<0) { writelog(LOG_ERR,"Call 847356 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return ret; } else { writelog(LOG_ERR,"Call 847356 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return aPack.head.retCode; } } memcpy(out_pack->sbankname,aPack.pack.sbankname,81);//房间名称 out_pack->damt2=aPack.pack.damt0;//电价 writelog(LOG_ERR,"sbankname=[%s]",out_pack->sbankname); return 0; }
static int do_query_240204(ST_PACK *in_pack,ST_PACK *out_pack,int *pRetCode,char *szMsg) { int ret = 0; char c_drtbranch[10]=""; char c_bccbasefuncno[10]=""; int DRTP_BRANCH =0; int BCC_BASEFUNCNO =0; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 ST_CPACK sPack; // 设置发送包 ret=GetParameter(2501, c_drtbranch); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } ret=GetParameter(2502, c_bccbasefuncno); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } DRTP_BRANCH = atoi(c_drtbranch); BCC_BASEFUNCNO = atoi(c_bccbasefuncno); ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); ResetNormalCPack(&sPack, 0, 1); SetHeadCol(&sPack, F_SSECTYPES,F_LVOL0,F_SCUST_AUTH,0); // 设置发送windows BU的头部视图信息 sPack.head.RequestType = 847358; sPack.pack.lvol0=in_pack->lvol10;//房间号 ret = ExtCall(0, DRTP_BRANCH, BCC_BASEFUNCNO, 0, 10, &sPack, &aPack, &ArrayPack); if (ret < 0||aPack.head.retCode!=0) { if(ret<0) { writelog(LOG_ERR,"Call 847358 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); *pRetCode = aPack.head.retCode; return ret; } else { writelog(LOG_ERR,"Call 847358 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); strcpy(szMsg,aPack.pack.vsmess); // 错误信息 *pRetCode = aPack.head.retCode; return -1; } } memcpy(out_pack->sbankname,aPack.pack.sbankname,81);//房间名称 out_pack->damt2=aPack.pack.damt0;//电价 out_pack->damt1=aPack.pack.damt1;//房间余额 writelog(LOG_ERR,"sbankname=[%s]",out_pack->sbankname); return 0; }
int CSvrLink::ExtCallNext(int acktime, char *abuf, int &alen) { ST_CPACK rpack; memcpy(&(rpack.head),&(xcdata.ahead),sizeof(ST_PACKHEAD)); rpack.head.recCount = 0; rpack.head.firstflag = 0; alen = ModifyHead(&(rpack.head),(unsigned char *)abuf); if (xcdata.ahead.nextflag==0) { return(-3); // 表示已经取完了后续数据,不需要再提取了; } return(ExtCall(xcdata.sno,xcdata.dno,xcdata.fno,xcdata.bno,acktime,abuf,alen,abuf,alen)); }
int F249999(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 ST_PACK *out_pack = &(aPack.pack); ST_CPACK sPack; // 设置发送包 ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); ResetNormalCPack(&sPack, 0, 1); sPack.head.RequestType = 999999; SetHeadCol(&sPack, F_SCLOSE_EMP, F_SORDER2, F_SSERIAL0, F_SEMP_PWD, F_DAMT0, F_LVOL3, 0); memcpy(&(sPack.pack), rPack, sizeof(sPack.pack)); writelog(LOG_ERR,"branch_no[%d], base_funcno[%d]",g_Bank.DRTP_BRANCH,g_Bank.BCC_BASEFUNCNO); ret = ExtCall(0, g_Bank.DRTP_BRANCH, g_Bank.BCC_BASEFUNCNO, 0, g_Bank.TIMEOUT, &sPack, &aPack, &ArrayPack); writelog(LOG_ERR,"Call 999999 retCode=[%d]", ret); if (ret < 0 || aPack.head.retCode != 0) { memcpy(szMsg, aPack.pack.vsmess, sizeof(aPack.pack.vsmess) -1); if (ret < 0) { writelog(LOG_ERR,"Call 999999 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); *pRetCode = ret; return E_TRANS_UNKNOW_ERROR; } else { writelog(LOG_ERR,"Call 999999 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); *pRetCode = ret; return aPack.head.retCode; } } SetCol(handle,0); SetCol(handle,F_LVOL0,F_LVOL1,F_DAMT0,F_DAMT1,F_DAMT2,F_DAMT10,F_DAMT11,F_DAMT12,F_VSMESS,0); PutRow(handle, out_pack, pRetCode, szMsg); return 0; }
int CSvrLink::ExtCallNext(int acktime, ST_CPACK *apack, ST_PACK *pArrays) { //int rtn; if (xcdata.ahead.nextflag==0) { memcpy(&apack->head,&xcdata.ahead,sizeof(ST_PACKHEAD)); apack->head.recCount = 0; return(-3); // 表示已经取完了后续数据,不需要再提取了; } ST_CPACK rpack; memcpy(&rpack.head,&xcdata.ahead,sizeof(ST_PACKHEAD)); rpack.head.recCount = 0; rpack.head.retCode = 0; rpack.head.firstflag = 0; rpack.head.nextflag = 1; return(ExtCall(xcdata.sno,xcdata.dno,xcdata.fno,xcdata.bno,acktime,&rpack,apack,pArrays)); }
//POS登陆 240101 int Pos_Login(INNER_TRANS_REQUEST * pNode) { //double unique=0; int ret=0; // INNER_TRANS_REQUEST from_pos; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 // ST_PACK *out_pack = &(aPack.pack); ST_CPACK sPack; // 设置发送包 ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); //银行未签到成功,POS不能登陆授予密钥 //考虑银行登陆不成功也可以进行校园卡业务 //所以此处不经判断银行是否登陆成功 /* if(!BANK_LOGIN) { writelog(LOG_ERR,"System not login to bank,pos login forbidden!shm[1]=[%d]",shm[1]); return E_TRANS_BANK_NETERR; } */ ResetNormalCPack(&sPack, 0, 1); sPack.head.RequestType = 240008; SetHeadCol(&sPack, F_SORDER2, 0); // 设置发送windows BU的头部视图信息 //memcpy(&(sPack.pack), in_pack, sizeof(sPack.pack)); des2src(sPack.pack.sorder2,pNode->TerminalId); ret = ExtCall(0, g_Bank.DRTP_BRANCH, g_Bank.BCC_BASEFUNCNO, 0, g_Bank.TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0||aPack.head.retCode!=0) { writelog(LOG_ERR,"Call 240008 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return E_TRANS_SCHOOL_NETERR; } //填充应答包---pNode,返回读卡密钥和银行通讯密钥 if(BANK_LOGIN) { memcpy(pNode->BankCardPwd,shm+2+8,sizeof(pNode->BankCardPwd)); } memcpy(pNode->BankCardNewPwd,aPack.pack.scard0,sizeof(pNode->BankCardNewPwd)); // writelog(LOG_ERR,"key=[%s]",aPack.pack.scard0); return 0; }
int F260002(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg) { int ret = 0; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 ST_CPACK sPack; // 设置发送包 ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); // 向后台发写卡失败 ResetNormalCPack(&sPack, 0, 1); sPack.head.RequestType = 847304; SetHeadCol(&sPack, F_LVOL1, 0); // 设置发送windows BU的头部视图信息 memcpy(&(sPack.pack), in_pack, sizeof(sPack.pack)); writelog(LOG_ERR,"branch_no[%d], base_funcno[%d]",g_Bank.DRTP_BRANCH,g_Bank.BCC_BASEFUNCNO); ret = ExtCall(0, g_Bank.DRTP_BRANCH, g_Bank.BCC_BASEFUNCNO, 0, g_Bank.TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0 || aPack.head.retCode != 0) { if (ret < 0) { writelog(LOG_ERR,"Call 847316 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); strcpy(szMsg,"调用后台业务失败,业务终止"); goto L_retu; } else { writelog(LOG_ERR,"Call 847316 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); strcpy(szMsg,aPack.pack.vsmess); goto L_retu; } } return 0; L_retu: return -1; }
int verify_card_passwordEx(int card_id,char *stuemp_no,int cut_id,char *password, char *szMsg) { int ret=0; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 // ST_PACK *out_pack = &(aPack.pack); ST_CPACK sPack; // 设置发送包 ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); ResetNormalCPack(&sPack, 0, 1); sPack.head.RequestType = 240010; SetHeadCol(&sPack, F_SSERIAL0,F_SCUST_AUTH,F_LVOL8,F_SEMP_PWD,0); // 设置发送windows BU的头部视图信息 //memcpy(&(sPack.pack), in_pack, sizeof(sPack.pack)); sprintf(sPack.pack.sserial0,"%d",card_id); des2src(sPack.pack.scust_auth, stuemp_no); sPack.pack.lvol8 = cut_id; des2src(sPack.pack.semp_pwd,password); ret = ExtCall(0, g_Bank.DRTP_BRANCH, g_Bank.BCC_BASEFUNCNO, 0, g_Bank.TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0 || aPack.head.retCode!=0) { memcpy(szMsg, aPack.pack.vsmess, sizeof(aPack.pack.vsmess) -1); if (ret < 0) { writelog(LOG_ERR,"Call 240010 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return E_TRANS_UNKNOW_ERROR; } else { writelog(LOG_ERR,"Call 240010 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return aPack.head.retCode; } } return 0; }
int verify_sch_bank_relationship(int cut_id,int card_id,char *stuemp_no,int area_id,char *bankcard_no) { int ret=0; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 // ST_PACK *out_pack = &(aPack.pack); ST_CPACK sPack; // 设置发送包 ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); ResetNormalCPack(&sPack, 0, 1); sPack.head.RequestType = 240011; SetHeadCol(&sPack, F_LVOL8,F_SCUST_AUTH,F_LVOL0,F_SPHONE,F_LVOL1,0); // 设置发送windows BU的头部视图信息 //memcpy(&(sPack.pack), in_pack, sizeof(sPack.pack)); sPack.pack.lvol0=card_id; sPack.pack.lvol8=cut_id; sPack.pack.lvol1=area_id; des2src(sPack.pack.scust_auth,stuemp_no); des2src(sPack.pack.sphone,bankcard_no); ret = ExtCall(0, g_Bank.DRTP_BRANCH, g_Bank.BCC_BASEFUNCNO, 0, g_Bank.TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0||aPack.head.retCode!=0) { if(ret<0) { writelog(LOG_ERR,"Call 240011 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return E_TRANS_UNKNOW_ERROR; } else { writelog(LOG_ERR,"Call 240011 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return aPack.head.retCode; } } return 0; }
int do_mobile_transfer(ST_PACK *in_pack,TRUSERID *handle,int *pRetCode,char *szMsg) { int ret=0; char device_id[10+1]=""; char card_id[12+1]=""; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 // ST_PACK *out_pack = &(aPack.pack); ST_CPACK sPack; // 设置发送包 ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); //向后台发水控转账 ResetNormalCPack(&sPack, 0, 1); sPack.head.RequestType = 847316; SetHeadCol(&sPack, F_LVOL1,F_LVOL2,F_SCUST_LIMIT,F_LVOL6,F_LVOL7, 0); // 设置发送windows BU的头部视图信息 memcpy(&(sPack.pack), in_pack, sizeof(sPack.pack)); ret = ExtCall(0, g_Bank.DRTP_BRANCH, g_Bank.BCC_BASEFUNCNO, 0, g_Bank.TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0 || aPack.head.retCode != 0) { if (ret < 0) { writelog(LOG_ERR,"Call 847317 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return E_TRANS_UNKNOW_ERROR; } else { writelog(LOG_ERR,"Call 847317 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return aPack.head.retCode; } } return 0; }
int Pos_ChangePwd(INNER_TRANS_REQUEST * pNode) { int ret=0; char device_id[10+1]=""; char card_id[12+1]=""; char card_pwd[6+1]=""; char card_pwd_new[6+1]=""; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 //ST_PACK *out_pack = &(aPack.pack); ST_CPACK sPack; // 设置发送包 memset(&sPack,0,sizeof sPack); ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); des2src(card_pwd,pNode->AccountPwd); des2src(card_pwd_new,pNode->AccountNewPwd); des2src(device_id,pNode->TerminalId); des2src(card_id, pNode->CardNo); //判断设备是否登录 writelog(LOG_ERR,"pwd1=[%6s],pwd2=[%6s]",card_pwd,card_pwd_new); ret=device_login_yes_or_no(atoi(device_id)); if(ret) { if(ret<0) { writelog(LOG_ERR,"device_login_yes_or_no faild,=[%s]",device_id); return E_TRANS_SCHOOL_NETERR; } else { writelog(LOG_INFO,"Device has not signed in!device_id=[%s],background ret=[%d]",device_id,ret); return E_TRANS_TERM_NOLOGIN; } } //判断输入密码是否正确 ret=verify_card_password(atoi(card_id),"",0, pNode->AccountPwd); if(ret) { writelog(LOG_INFO,"Verify card password faild!card_id=[%s]",card_id); return ret; } //向后台发起修改密码的申请 ResetNormalCPack(&sPack, 0, 1); sPack.head.firstflag=1; sPack.head.nextflag = 0; sPack.head.RequestType = 847111; SetHeadCol(&sPack, F_LVOL0,F_SCUST_NO, 0); // 设置发送windows BU的头部视图信息 //memcpy(&(sPack.pack), in_pack, sizeof(sPack.pack)); sPack.pack.lvol0=atoi(card_id); des2src(sPack.pack.scust_no,card_pwd_new); ret = ExtCall(0, g_Bank.DRTP_BRANCH, g_Bank.BCC_BASEFUNCNO, 0, g_Bank.TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0||aPack.head.retCode!=0) { writelog(LOG_ERR,"Call 847111 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return E_TRANS_UNKNOW_ERROR; } return 0; }
int F260006(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg) { int ret = 0; FILE *fp = NULL; BANK_COMPARE_RECODE compare_record; // 对账文件记录描述 memset(&compare_record, 0, sizeof(compare_record)); char comp_file_path[256] = ""; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 ST_CPACK sPack; // 设置发送包 ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); // 向后台发写卡失败 ResetNormalCPack(&sPack, 0, 1); sPack.head.RequestType = 240007; SetHeadCol(&sPack, F_LVOL0, F_LVOL1, F_SCUST_AUTH, F_SCUST_AUTH2, F_SORDER0, F_SEMP_NO, F_SCUST_TYPE, F_SORDER1, F_SCARD1, 0); // 设置发送windows BU的头部视图信息 memcpy(&(sPack.pack), in_pack, sizeof(sPack.pack)); des2src(comp_file_path, in_pack->vsvarstr0); // 对账文件路径名:BANK0320080414.txt writelog(LOG_ERR,"branch_no[%d], base_funcno[%d]",g_Bank.DRTP_BRANCH,g_Bank.BCC_BASEFUNCNO); if ((fp = fopen(comp_file_path, "rb")) == NULL) { writelog(LOG_ERR,"Open indirect file error,file=[%s]", comp_file_path); goto L_retu; } while (1) { if (NULL == fgets((char *)(&compare_record), sizeof(BANK_COMPARE_RECODE), fp)) // 获取对账文件的数据记录 { writelog(LOG_ERR,"fgets error local_sn=[%s]", compare_record.LocalSn); break; } sPack.pack.lvol0 = 0; des2src(sPack.pack.scust_auth, compare_record.BankCard); des2src(sPack.pack.scust_auth2, compare_record.BankSn); des2src(sPack.pack.sorder0, compare_record.GDCAccount); des2src(sPack.pack.semp_no, compare_record.LocalSn); des2src(sPack.pack.scust_type, compare_record.TradeCode); des2src(sPack.pack.sorder1, compare_record.TransMomoy); des2src(sPack.pack.scard1, in_pack->sbank_acc); // 文件名:BANK0320080414.txt ret = ExtCall(0, g_Bank.DRTP_BRANCH, g_Bank.BCC_BASEFUNCNO, 0, g_Bank.TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0 || aPack.head.retCode != 0) { if (ret < 0) { writelog(LOG_ERR,"Call 240007 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); strcpy(szMsg,"调用后台业务失败,业务终止"); goto L_retu; } else { writelog(LOG_ERR,"Call 240007 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); strcpy(szMsg,aPack.pack.vsmess); goto L_retu; } } } sPack.pack.lvol0 = 1; des2src(sPack.pack.scard1, in_pack->sbank_acc); ret = ExtCall(0, g_Bank.DRTP_BRANCH, g_Bank.BCC_BASEFUNCNO, 0, g_Bank.TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0 || aPack.head.retCode != 0) { if (ret < 0) { writelog(LOG_ERR,"Call 240007 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); strcpy(szMsg,"调用后台业务失败,业务终止"); goto L_retu; } else { writelog(LOG_ERR,"Call 240007 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); strcpy(szMsg,aPack.pack.vsmess); goto L_retu; } } if (fclose(fp)) { writelog(LOG_ERR,"Close file error,file=[%s]", comp_file_path); goto L_retu; } SetCol(handle,0); SetCol(handle,F_VSMESS,0); PutRow(handle, &aPack.pack, pRetCode, szMsg); return 0; L_retu: return -1; }
int F851002(TRUSERID *handle, int iRequest, ST_PACK *in_pack, int *pRetCode, char *szMsg) { int ret = 0; TRUSERID answer_handle; char request_data[512]; char drtphandle[129]; int req_len,offset,t; ST_CPACK aPack; ST_CPACK sPack; ST_PACK *out_pack = &(aPack.pack); gdct_msg_t mymsg; memcpy(&answer_handle,handle,sizeof answer_handle); memset(&mymsg,0,sizeof mymsg); strcpy(mymsg.msgtype,"DCCZ"); strcpy(mymsg.msgcode,"000005"); if(strlen(in_pack->sphone3)>4) mymsg.seqno = atoi(in_pack->sphone3+4); offset = 0; memcpy(mymsg.body,g_gdct_pswd,32); // 密码 offset += 32; memcpy(mymsg.body+offset,in_pack->sbank_code2,6); // 支付方式 offset += 6; sprintf(mymsg.body+offset,"%010d",in_pack->lvol1); // 支付金额 offset += 10; // 手机号 memset(mymsg.body+offset,' ',13); t = strlen(in_pack->sbank_acc2); if(t > 13) { *pRetCode = 1000; return -1; } memcpy(mymsg.body+offset+13-t,in_pack->sbank_acc2,t); offset += 13; // 交易参考号 memset(mymsg.body+offset,' ',20); memcpy(mymsg.body+offset+6,in_pack->sphone3,14); offset += 20; // 代理商手机号 memcpy(mymsg.body+offset,g_gdct_phone_num,13); offset += 13; mymsg.bodylen = offset; // drtphandle strcpy(drtphandle,in_pack->vsvarstr1); g_LogFile.WriteLogEx(1000,"[%s][%d]",in_pack->sbank_code2,in_pack->lvol1); PackCTRequest(&mymsg,request_data,req_len); // 发请求包 ret = CTSendAndRecv(request_data,req_len,&mymsg,g_timeout); // 给后台确认 ResetNormalCPack(&sPack,0,1); sPack.head.RequestType = 850005; SetHeadCol(&sPack,F_LVOL0,F_LBANK_ACC_TYPE,F_SPHONE2,F_SPHONE3,F_SHOLDER_AC_NO, F_LVOL1,F_LVOL2,F_VSMESS,F_SBANK_ACC,0); sPack.pack.lbank_acc_type = 255; strcpy(sPack.pack.sphone3,in_pack->sphone3); if(ret!=0) { sPack.pack.lvol0 = ret; strcpy(sPack.pack.vsmess,"通讯错误"); } else { // DEBUG strcpy(mymsg.respcode,"0000"); sPack.pack.lvol0 = atoi(mymsg.respcode); TranslateErrMsg(mymsg.respcode,sPack.pack.vsmess); if(strncmp(mymsg.respcode,"0000",4)==0) { // 交易成功 offset = 0; GetRespDataAsString(&mymsg,22,10,sPack.pack.sphone2); // 讯源流水号 offset += 32; GetRespDataAsString(&mymsg,offset,14,sPack.pack.sholder_ac_no); // 讯源交易时间 offset += 14; GetRespDataAsString(&mymsg,offset,16,sPack.pack.sbank_acc); // 代理商户账户余额 offset += 16; GetRespDataAsInteger(&mymsg,offset,16,t); // 充值账户余额 sPack.pack.lvol2 = t; offset += 16; g_LogFile.WriteLogEx(1000,"支付成功,refno[%s]recvno[%s],bala[%s]",sPack.pack.sphone3 ,sPack.pack.sphone2,sPack.pack.sbank_acc); } } // 发送确认请求, aPack 中的数据返回给客户端 memset(&aPack,0,sizeof aPack); ret = ExtCall(0,g_mainsvr_drtpno,g_mainsvr_func,0,2,&sPack,&aPack,NULL); if(ret >= 0) { if(aPack.head.retCode==0) g_LogFile.WriteLogEx(1000,"发送确认成功,refno[%s]",in_pack->sphone3); else { g_LogFile.WriteLogEx(1000,"发送确认失败,refno[%s],ret[%d]",in_pack->sphone3,aPack.head.retCode); return -1; } } else { g_LogFile.WriteLogEx(1000,"发送确认失败,refno[%s],ret[%d],err[%d]" ,in_pack->sphone3,ret,aPack.head.retCode); // 确认失败 return -1; } // 给客户端应答 ResetNormalCPack(&sPack,0,1); //memcpy(sPack.head.ParmBits,aPack.head.ParmBits,sizeof sPack.head.ParmBits); memcpy(&(sPack.pack),&(aPack.pack),sizeof sPack.pack); //g_pSvrLink->SetAnswerMode(AM_CONFIRM); //SetTransHandle(&answer_handle,drtphandle); //AnswerDataEx(&answer_handle,&sPack,NULL,0,szMsg); g_pSvrLink->SetCol(handle,aPack.head.ParmBits); PutRow(handle,&(sPack.pack),pRetCode,szMsg); return 0; }
//POS转帐 int Pos_Transfer(INNER_TRANS_REQUEST * pNode) { int ret=0; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); //判断设备是否登录 //判断操作方式(AUTH_MODE),如果绑定关系,判断校园卡密码是否正确 //发起模拟入账申请 ST_CPACK sPack; // 设置发送包 ResetNormalCPack(&sPack, 0, 1); sPack.head.RequestType = 240002; SetHeadCol(&sPack, F_SORDER2,F_SCUST_AUTH,F_SEMP_PWD,F_SSERIAL0,F_LVOL5,F_LVOL0,F_LVOL6,F_LVOL1,F_LVOL2, 0); // 设置发送windows BU的头部视图信息 //memcpy(&(sPack.pack), in_pack, sizeof(sPack.pack)); des2src(sPack.pack.sorder2,pNode->TerminalId); des2src(sPack.pack.scust_auth,pNode->BankCardNo); des2src(sPack.pack.semp_pwd,pNode->AccountPwd); des2src(sPack.pack.sserial0,pNode->CardNo); sPack.pack.lvol5=atoi(pNode->TransMoney); sPack.pack.lvol0=pNode->SendNo; sPack.pack.lvol6=atoi(pNode->AccountMoney); sPack.pack.lvol1=pNode->RecvNo+1; ret = ExtCall(0, 7000, 9000, 0, 4, &sPack, &aPack, &ArrayPack); if (ret < 0) { if (-2 == ret) return E_TRANS_INNER_TIMEOUT; else return E_TRANS_INNER_TIMEOUT; } //如果后台失败,则此处返回后台返回的错误码 if(aPack.head.retCode) { return aPack.head.retCode; } //调用银行接口函数,按照不同的银行转帐接口发送报文并接受应答 //该函数为通用结构,不同银行接口按照该函数名进行封装转帐报文 // ret=Bank_Transfer(pNode); if(ret) { if(E_TRANS_BANK_NOANSWER==ret) //如果银行没有返回包,进行冲正处理 { ret=call_240003(); //DelTrans(&from_pos,temp_serial_no); if(ret) writelog(LOG_ERR,"DelTrans error,error code=[%d]",ret); return E_TRANS_BANK_NOANSWER; } else { writelog(LOG_ERR,"send_to_and_recv_from_bank error,errcode=[%d]",ret); return ret; } } //调用后台正式入账接口 ResetNormalCPack(&aPack, 0, 1); sPack.head.RequestType = 240001; ret = ExtCall(0, 7000, 9000, 0, 4, &sPack, &aPack, &ArrayPack); if (ret < 0) { if (-2 == ret) return E_TRANS_INNER_TIMEOUT; else return E_TRANS_INNER_TIMEOUT; } if(aPack.head.retCode) { return aPack.head.retCode; } sprintf(pNode->TransMoney,"%f",aPack.pack.damt1); sprintf(pNode->ExtraMoney,"%f",aPack.pack.damt2); pNode->RecvNo=aPack.pack.lvol1; pNode->MngFeeFlag='1'; //writelog(LOG_INFO,"transfer succeed!"); return 0; }
//从第三方确认手机号码的正确性 static int check_cellphone(ST_PACK *in_pack,ST_PACK *out_pack,transfer_control_t *trans_ctl) { int ret = 0; char host[16]=""; //对方机器的ip char portchar[10]=""; short port=0; //对方机器的port char rcvdata[package_len+1]=""; //接收对方的传送数据 char senddata[package_len+1]=""; //加密后的传送数据 char tempdate[package_len+1-200]=""; char c_drtbranch[10]=""; char c_bccbasefuncno[10]=""; int DRTP_BRANCH =0; int BCC_BASEFUNCNO =0; memset(tempdate,0,sizeof tempdate); trans_ctl->check_user_pwd = 0; CTcpSocket tcpsocket ; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 ST_CPACK sPack; // 设置发送包 ret=GetParameter(2104, host); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } ret=GetParameter(2105, portchar); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } ret=GetParameter(2106, c_drtbranch); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } ret=GetParameter(2107, c_bccbasefuncno); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } port = atoi(portchar); DRTP_BRANCH = atoi(c_drtbranch); BCC_BASEFUNCNO = atoi(c_bccbasefuncno); ret = packege_send_data(in_pack,1,senddata); if(ret){ writelog(LOG_ERR,"packege send data error,error code is [%d]",ret); return ret; } memcpy(tempdate,senddata,package_len-200); ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); ResetNormalCPack(&sPack, 0, 1); SetHeadCol(&sPack, F_SSECTYPES,F_LVOL0,F_SCUST_AUTH,0); // 设置发送windows BU的头部视图信息 sPack.head.RequestType = 250001; des2src(sPack.pack.ssectypes,tempdate); des2src(sPack.pack.scust_auth,host); sPack.pack.lvol0=port; ret = ExtCall(0, DRTP_BRANCH, BCC_BASEFUNCNO, 0, TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0||aPack.head.retCode!=0) { if(ret<0) { writelog(LOG_ERR,"Call 250001 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return ret; } else { writelog(LOG_ERR,"Call 250001 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return aPack.head.retCode; } } des2src(rcvdata,aPack.pack.ssectypes); /* writelog(LOG_ERR,"bengin to connect the telecom's server for cellphone check\n,host=[%s],port=[%d],senddata=[%s]",host,port,senddata); ret = tcpsocket.ConnectTcp(host, port); if(!ret) { writelog(LOG_ERR,"Connect to boss system error,error code is [%d],ip_addr[%s],port[%d] ",ret,host,port); return E_MOBILE_TRANS_CONNECT; } ret = tcpsocket.Send(senddata,326); if (ret<0) { // 发送时,端口有问题,包括被关闭 writelog(LOG_ERR,"Send to boss system error,error code is [%d] ",ret); return E_MOBILE_TRANS_REQUEST; }else if(0==ret){ // 不应该出现这种情况 writelog(LOG_ERR,"Send to boss system error,CTcpSocket.Send should not return this error,error code is[%d]!\n",ret); return E_MOBILE_TRANS_REQUEST; } ret = tcpsocket.Recv(rcvdata, 326, 180000); if (ret!=326) { writelog(LOG_ERR,"Receive from boss system error,error code is [%d] ",ret); return E_MOBILE_TRANS_TIME_OUT; // 接收时候出错,或超时 } tcpsocket.Close(); */ if(('0'==rcvdata[89])&&('0'==rcvdata[90])) { //号码正确 return 0; } else if(('0'==rcvdata[89])&&('1'==rcvdata[90])) { //mac校验出错 return E_MOBILE_CHECK_MAC; }else if(('0'==rcvdata[89])&&('2'==rcvdata[90])) { //失败 return E_MOBILE_CHECK_FAIL; }else { //未知异常 return E_MOBILE_CHECK_UNKNOW; } }
//发送正式充值请求 static int trans_request(ST_PACK *in_pack,char ext_msg[256]){ int ret = 0; char host[16]=""; //对方机器的ip char portchar[10]=""; short port=0; //对方机器的port char rcvdata[package_len+1]=""; //接收对方的传送数据 char senddata[package_len+1]=""; //加密后的传送数据 char tempdate[package_len+1-200]=""; char c_drtbranch[10]=""; char c_bccbasefuncno[10]=""; int DRTP_BRANCH =0; int BCC_BASEFUNCNO =0; // char temp[512] = ""; // int i,j; memset(tempdate,0,sizeof tempdate); CTcpSocket tcpsocket ; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 ST_CPACK sPack; // 设置发送包 ret=GetParameter(2104, host); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return E_DB_TRADESERIALERROR_R; } ret=GetParameter(2105, portchar); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return E_DB_TRADESERIALERROR_R; } ret=GetParameter(2106, c_drtbranch); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } ret=GetParameter(2107, c_bccbasefuncno); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } port = atoi(portchar); DRTP_BRANCH = atoi(c_drtbranch); BCC_BASEFUNCNO = atoi(c_bccbasefuncno); ret = packege_send_data(in_pack,2,senddata); if(ret){ writelog(LOG_ERR,"packege send data error,error code is [%d]",ret); return ret; } memcpy(tempdate,senddata,package_len-200); ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); ResetNormalCPack(&sPack, 0, 1); SetHeadCol(&sPack, F_SSECTYPES,F_LVOL0,F_LVOL1,F_SCUST_AUTH,0); // 设置发送windows BU的头部视图信息 sPack.head.RequestType = 250001; des2src(sPack.pack.ssectypes,tempdate); des2src(sPack.pack.scust_auth,host); sPack.pack.lvol0=port; sPack.pack.lvol1=1; ret = ExtCall(0, DRTP_BRANCH, BCC_BASEFUNCNO, 0, TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0||aPack.head.retCode!=0) { if(ret<0) { writelog(LOG_ERR,"Call 250001 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return ret; } else { writelog(LOG_ERR,"Call 250001 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return aPack.head.retCode; } } des2src(rcvdata,aPack.pack.ssectypes); /* ret = tcpsocket.ConnectTcp(host, port); if(!ret) { writelog(LOG_ERR,"Connect to boss system error,error code is [%d],ip_addr[%s],port[%d] ",ret,host,port); return E_MOBILE_TRANS_CONNECT; } ret = tcpsocket.Send(senddata,326); if (ret<0) { // 发送时,端口有问题,包括被关闭 writelog(LOG_ERR,"Send to boss system error,error code is [%d] ",ret); return E_MOBILE_TRANS_REQUEST; }else if(0==ret){ // 不应该出现这种情况 writelog(LOG_ERR,"Send to boss system error,CTcpSocket.Send should not return this error,error code is[%d]!\n",ret); return E_MOBILE_TRANS_REQUEST; } tcpsocket.Recv(rcvdata, 326, 1000); tcpsocket.Close(); */ return 0; }
int F240024(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; int request_type = 2401; int drtp_branch = 0; int base_funcno = 0; int bcc_timeout = 0; char bankcode[3] = ""; ST_CPACK bPack; ST_PACK *out_pack = &(bPack.pack); ResetNormalCPack(&bPack,0,1); SetCol(handle,0); SetCol(handle,F_DAMT0,0); ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 ST_CPACK sPack; // 设置发送包 T_t_card card; memset(&card,0x00,sizeof card); T_t_bankcard bankcard; memset(&bankcard,0,sizeof bankcard); T_t_device device; memset(&device,0x00,sizeof device); ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); ResetNormalCPack(&sPack, 0, 1); sPack.head.RequestType = request_type; SetHeadCol(&sPack,F_LCERT_CODE,F_SCUST_AUTH,F_LVOL0,F_LVOL1,F_SDATE0, F_SHOLDER_AC_NO,F_SPHONE,F_SPHONE3,F_SCUST_LIMIT,F_SCUST_LIMIT2,F_SCUST_AUTH,F_SCUST_AUTH2,F_DAMT0,F_SBANK_PWD, F_VSVARSTR0,F_VSVARSTR1,F_SORDER2,0); ret = DB_t_bankcard_read_by_bankcardno(rPack->scust_auth, &bankcard); if(ret) { strcpy(szMsg,"您的校园卡号和银行卡号未绑定"); return E_DB_BANKCARD_R; } ret=DB_t_card_read_by_custid_and_status(bankcard.custid, "1", &card); if(ret) { strcpy(szMsg,"校园卡已经注销"); return E_DB_CARD_N; } //校验绑定关系 ret = DB_t_bankcard_read_by_custid(card.custid, &bankcard); if(ret) { writelog(LOG_ERR,"DB_t_bankcard_read_by_custid err,errcode=[%d]",ret); if(DB_NOTFOUND==ret) { strcpy(szMsg,"学工号和银行卡号未绑定"); return E_DB_BANKCARD_N; } else { return E_DB_BANKCARD_R; } } ret = DB_t_bankcard_read_by_custid_and_bankcardno(card.custid,rPack->scust_auth, &bankcard); if(ret) { strcpy(szMsg,"学工号和银行卡号没绑定"); return E_DB_BANKCARD_R; } des2src(bankcode,bankcard.bankcode); T_t_cfgbank cfgbank; memset(&cfgbank,0,sizeof cfgbank); ret = DB_t_cfgbank_read_by_bankcode(bankcode,&cfgbank); if(ret) { return E_DB_CFGBANK_R; } if(strncmp(getsystime(NULL),cfgbank.bankstarttime,6) < 0 || strncmp(getsystime(NULL),cfgbank.bankendtime,6) > 0) { return E_OUT_BANKTIME; } T_t_customer customer; memset(&customer,0,sizeof customer); ret = DB_t_customer_read_by_custid(card.custid, &customer); if(ret) { return E_DB_CUSTOMER_R; } ret=DB_t_device_read_by_deviceid(rPack->lcert_code, &device); if(ret) { return E_DB_DEVICE_R; } drtp_branch = cfgbank.bccdrtpno; // drtp 编号 base_funcno = cfgbank.bccfuncno; // 前置主功能号 bcc_timeout = cfgbank.bcctimeout; // 前置超时时间 sPack.pack.lcert_code = 240100; // 交易码 des2src(sPack.pack.scust_limit2,cfgbank.bankip); // 银行ip sPack.pack.lvol0 = cfgbank.bankport; // 银行端口 sPack.pack.lvol1 = cfgbank.banktimeout; // 银行超时时间 GetNewRefno(sPack.pack.sholder_ac_no); // 一卡通交易参考号 db_commit(); des2src(sPack.pack.sdate0,getsysdate(NULL)); // 交易日期 des2src(sPack.pack.scust_limit,customer.custname); // 姓名 des2src(sPack.pack.scust_auth2,customer.idno); // 身份证号 des2src(sPack.pack.scust_auth,rPack->scust_auth); // 银行卡号 des2src(sPack.pack.sphone3,rPack->sphone3); //银行卡密码,ansi加密处理过 des2src(sPack.pack.vsvarstr0, rPack->vsvarstr0); //二磁道数据 des2src(sPack.pack.vsvarstr1, rPack->vsvarstr1); //三磁道数据 des2src(sPack.pack.sorder2,device.devphyid); //设备物理ID if(bcc_timeout<5) bcc_timeout=5; ret = ExtCall(0, drtp_branch, base_funcno, 0, bcc_timeout, &sPack, &aPack, &ArrayPack); if (ret < 0 || aPack.head.retCode != 0) { writelog(LOG_ERR,"extcall 2401 ret[%d],retcode[%d] timeout[%d] ",ret,aPack.head.retCode,bcc_timeout); if (ret < 0) // 通讯错误,要冲正的 { writelog(LOG_ERR,"调用后台业务失败,业务终止"); return E_BCC_NETWORK; } else // 收到前置返回的错误 { writelog(LOG_ERR,"%s",aPack.pack.vsmess); strcpy(szMsg,aPack.pack.vsmess); return E_COMMON_ERR; } } if(aPack.pack.lvol1 != 1) // 前置解包错误 { writelog(LOG_ERR,"接收银行数据错误"); return E_BCC_NETWORK; } out_pack->damt0=aPack.pack.damt0; PutRow(handle,out_pack,pRetCode,szMsg); return 0; }
int CSvrLink::RACall(int acktime, ST_CPACK *rpack, ST_CPACK *apack, ST_PACK *pArrays) { return(ExtCall(INTSOURCENO,0xFFFF,0,0,acktime,rpack,apack,pArrays)); }
int Pos_UnlostCard(INNER_TRANS_REQUEST * pNode) { int ret=0; char device_id[10+1]=""; char card_id[12+1]=""; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 // ST_PACK *out_pack = &(aPack.pack); ST_CPACK sPack; // 设置发送包 ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); des2src(device_id,pNode->TerminalId); des2src(card_id, pNode->CardNo); //判断设备是否登录 ret=device_login_yes_or_no(atoi(device_id)); if(ret) { if(ret<0) { writelog(LOG_ERR,"device_login_yes_or_no faild,=[%s]",device_id); return E_TRANS_SCHOOL_NETERR; } else { writelog(LOG_INFO,"Device has not signed in!device_id=[%s],background ret=[%d]",device_id,ret); return E_TRANS_TERM_NOLOGIN; } } //判断输入密码是否正确 ret=verify_card_password(atoi(card_id),"",0, pNode->AccountPwd); if(ret) { writelog(LOG_ERR,"Verify card password faild!card_id=[%s]",card_id); return ret; } //向后台发起解挂申请 ResetNormalCPack(&sPack, 0, 1); sPack.head.RequestType = 847103; SetHeadCol(&sPack, F_LVOL1,F_LVOL2,F_SCUST_LIMIT,F_LVOL6,F_LVOL7, 0); // 设置发送windows BU的头部视图信息 //memcpy(&(sPack.pack), in_pack, sizeof(sPack.pack)); //判断登陆模式,使用客户号登陆还是学工号登陆 sPack.pack.lvol1=atoi(card_id); sPack.pack.lvol2=0; des2src(sPack.pack.scust_limit,OPER_SYSTEM_KEY); sPack.pack.lvol6=0; sPack.pack.lvol7=atoi(device_id); ret = ExtCall(0, g_Bank.DRTP_BRANCH, g_Bank.BCC_BASEFUNCNO, 0, g_Bank.TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0||aPack.head.retCode!=0) { if(ret<0) { writelog(LOG_ERR,"Call 847103 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return E_TRANS_UNKNOW_ERROR; } else { writelog(LOG_ERR,"Call 847103 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return aPack.head.retCode; } } return 0; }
static int elect_room_check(ST_PACK *in_pack,ST_PACK *out_pack,transfer_control_t *trans_ctl) { int ret = 0; char host[16]=""; //对方机器的ip char portchar[10]=""; short port=0; //对方机器的port char senddata[elec_len+1]=""; //加密后的传送数据 char c_drtbranch[10]=""; char c_bccbasefuncno[10]=""; int DRTP_BRANCH =0; int BCC_BASEFUNCNO =0; trans_ctl->check_user_pwd = 0; CTcpSocket tcpsocket ; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 ST_CPACK sPack; // 设置发送包 ret=GetParameter(2301, host); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } ret=GetParameter(2302, portchar); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } ret=GetParameter(2303, c_drtbranch); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } ret=GetParameter(2304, c_bccbasefuncno); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } port = atoi(portchar); DRTP_BRANCH = atoi(c_drtbranch); BCC_BASEFUNCNO = atoi(c_bccbasefuncno); ret = packege_elec_request(in_pack,1,senddata); if(ret){ writelog(LOG_ERR,"packege send data error,error code is [%d]",ret); return ret; } ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); ResetNormalCPack(&sPack, 0, 1); SetHeadCol(&sPack, F_SSECTYPES,F_LVOL0,F_SCUST_AUTH,0); // 设置发送windows BU的头部视图信息 sPack.head.RequestType = 250002; des2src(sPack.pack.ssectypes,senddata); des2src(sPack.pack.scust_auth,host); sPack.pack.lvol0=port; ret = ExtCall(0, DRTP_BRANCH, BCC_BASEFUNCNO, 0, TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0||aPack.head.retCode!=0) { if(ret<0) { writelog(LOG_ERR,"Call 250002 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return ret; } else { writelog(LOG_ERR,"Call 250002 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return aPack.head.retCode; } } memcpy(out_pack->saddr,aPack.pack.saddr,20); writelog(LOG_ERR,"saddr=[%s]",out_pack->saddr); return 0; /* memset(&ElectTrans,0,sizeof(ElectTrans)); memcpy(&ElectTrans, aPack.pack.ssectypes,141); if(strncmp(ElectTrans.retnum,"0001",4)==0){ //房间存在 writelog(LOG_INFO,"query success ret[%s] ",ElectTrans.retnum); return 0; }else if(strncmp(ElectTrans.retnum,"0400",4)){ writelog(LOG_ERR,"query falied ret[%s] ",ElectTrans.retnum); return E_ELEC_DATA; }else if(strncmp(ElectTrans.retnum,"0401",4)){ writelog(LOG_ERR,"query falied ret[%s] ",ElectTrans.retnum); return E_ELEC_DB_CONN; }else if(strncmp(ElectTrans.retnum,"0402",4)){ //一卡通帐号与房间不对应 writelog(LOG_INFO,"query success but ret[%s] ",ElectTrans.retnum); sprintf(out_pack->saddr,ElectTrans.room,sizeof(ElectTrans.room)); return 0; }else if(strncmp(ElectTrans.retnum,"0403",4)){ writelog(LOG_ERR,"query falied ret[%s] ",ElectTrans.retnum); return E_ELEC_ROOM; }else if(strncmp(ElectTrans.retnum,"0404",4)){ writelog(LOG_ERR,"query falied ret[%s] ",ElectTrans.retnum); return E_ELEC_WORKSTAT; }else if(strncmp(ElectTrans.retnum,"0406",4)){ writelog(LOG_ERR,"query falied ret[%s] ",ElectTrans.retnum); return E_ELEC_DATA_LOSS; }else if(strncmp(ElectTrans.retnum,"0407",4)){ writelog(LOG_ERR,"query falied ret[%s] ",ElectTrans.retnum); return E_ELEC_UNKNOW; } */ }
int elec_room_deposit_search(ST_PACK *in_pack,ST_PACK *out_pack){ int ret = 0; char host[16]=""; //对方机器的ip char portchar[10]=""; short port=0; //对方机器的port char senddata[elec_search_len+1]=""; //加密后的传送数据 char c_drtbranch[10]=""; char c_bccbasefuncno[10]=""; int DRTP_BRANCH =0; int BCC_BASEFUNCNO =0; CTcpSocket tcpsocket ; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 ST_CPACK sPack; // 设置发送包 ret=GetParameter(2301, host); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } ret=GetParameter(2302, portchar); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } ret=GetParameter(2303, c_drtbranch); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } ret=GetParameter(2304, c_bccbasefuncno); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } port = atoi(portchar); DRTP_BRANCH = atoi(c_drtbranch); BCC_BASEFUNCNO = atoi(c_bccbasefuncno); ret = packege_search_data(in_pack,senddata); if(ret){ writelog(LOG_ERR,"packege send data error,error code is [%d]",ret); return ret; } ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); ResetNormalCPack(&sPack, 0, 1); SetHeadCol(&sPack, F_SSECTYPES,F_LVOL0,F_SCUST_AUTH,0); // 设置发送windows BU的头部视图信息 sPack.head.RequestType = 250004; des2src(sPack.pack.ssectypes,senddata); des2src(sPack.pack.scust_auth,host); sPack.pack.lvol0=port; ret = ExtCall(0, DRTP_BRANCH, BCC_BASEFUNCNO, 0, TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0||aPack.head.retCode!=0) { if(ret<0) { writelog(LOG_ERR,"Call 250004 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return ret; } else { writelog(LOG_ERR,"Call 250004 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return aPack.head.retCode; } } memcpy(out_pack->sstation0,aPack.pack.sstation0,17); memcpy(out_pack->sstation1,aPack.pack.sstation1,17); memcpy(out_pack->sbank_acc,aPack.pack.sbank_acc,17); writelog(LOG_ERR,"electrity depelemoney =[%17s]",out_pack->sstation0); writelog(LOG_ERR,"electrity depelect =[%17s]",out_pack->sstation1); writelog(LOG_ERR,"electrity depmoney =[%17s]",out_pack->sbank_acc); return 0; }
int Pos_Transfer(INNER_TRANS_REQUEST * pNode) { int ret=0; // double bank_balance=0; char device_id[10+1]=""; char card_id[12+1]=""; char bankcard_no[30+1]=""; char card_pwd[6+1]=""; int cur_serial_no=0; des2src(card_id,pNode->CardNo); des2src(device_id,pNode->TerminalId); des2src(bankcard_no,pNode->BankCardNo); des2src(card_pwd,pNode->AccountPwd); ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 // ST_PACK *out_pack = &(aPack.pack); ST_CPACK sPack; // 设置发送包 ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); //判断设备是否登录 ret=device_login_yes_or_no(atoi(device_id)); if(ret) { if(ret<0) { writelog(LOG_ERR,"device_login_yes_or_no faild,=[%s]",device_id); return E_TRANS_SCHOOL_NETERR; } else { writelog(LOG_INFO,"Device has not signed in!device_id=[%s],background ret=[%d]",device_id,ret); return E_TRANS_TERM_NOLOGIN; } } //判断操作方式(AUTH_MODE),如果绑定关系,判断校园卡密码是否正确 if(AUTH_MODE_SCHOOLPWD==g_Bank.AUTH_MODE) { //判断绑定对应关系是否相符 ret=verify_sch_bank_relationship(0,atoi(card_id),"",0,bankcard_no); if(ret) { writelog(LOG_INFO,"verify_sch_bank_relationship error!card_id=[%s],bankcard_id=[%s]",card_id,bankcard_no); return E_TRANS_RELATION_ERR; } ret=verify_card_password(atoi(card_id),"", 0,card_pwd); if(ret) { writelog(LOG_ERR,"Verify card password faild!card_id=[%s]",card_id); return ret; } } //循环操作,从配置文件中判断上传银行卡号对应的银行以及对应的银行科目帐号 int flag=0; for(int i=0;i<=g_Bank.BankCount;i++) { if(i==g_Bank.BankCount) { writelog(LOG_ERR,"E_TRANS_BANK_CARD_NONSUPPORT,i=[%d]!g_Bank.BankCount=[%d]",i,g_Bank.BankCount); return E_TRANS_BANK_CARD_NONSUPPORT; } for(int j=0;j<MAX_RANGE;j++) { //printf("i=[%d],j=[%d],bankcard=[%s],range=[%s],len=[%d]]\n",i,j,pNode->BankCardNo,g_Bank.BankUnit[i].szBankCardRange[j],strlen(g_Bank.BankUnit[i].szBankCardRange[j])); if(0==strlen(g_Bank.BankUnit[i].szBankCardRange[j])) break; if(0==memcmp(pNode->BankCardNo,g_Bank.BankUnit[i].szBankCardRange[j] ,strlen(g_Bank.BankUnit[i].szBankCardRange[j]))) { flag=1; g_Bank.cur_bankid=i; break; } } if(flag==1) break; } //发起模拟入账申请 ResetNormalCPack(&sPack, 0, 1); sPack.head.RequestType = 240002; SetHeadCol(&sPack, F_SORDER2,F_SCUST_AUTH,F_SEMP_PWD,F_SSERIAL0,F_SSTATION0,F_LVOL5,F_LVOL0,F_LVOL6,F_LVOL1,F_LVOL2, 0); // 设置发送windows BU的头部视图信息 //memcpy(&(sPack.pack), in_pack, sizeof(sPack.pack)); des2src(sPack.pack.sorder2,pNode->TerminalId); des2src(sPack.pack.scust_auth,pNode->BankCardNo); des2src(sPack.pack.semp_pwd,pNode->AccountPwd); des2src(sPack.pack.sserial0,pNode->CardNo); sPack.pack.lvol5=atoi(pNode->TransMoney); sPack.pack.lvol0=pNode->SendNo; sPack.pack.lvol6=atoi(pNode->AccountMoney); sPack.pack.lvol1=pNode->RecvNo; sPack.pack.lvol2=g_Bank.BankUnit[g_Bank.cur_bankid].iBankID; des2src(sPack.pack.sstation0,g_Bank.BankUnit[g_Bank.cur_bankid].szBankAccountNO); //des2src(sPack.pack.sstation0,"1021"); writelog(LOG_ERR,"g_Bank.BankUnit[g_Bank.cur_bankid].szBankAccountNO=[%s]",g_Bank.BankUnit[g_Bank.cur_bankid].szBankAccountNO); ret = ExtCall(0, g_Bank.DRTP_BRANCH, g_Bank.BCC_BASEFUNCNO, 0, g_Bank.TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0) { if (-2 == ret) return E_TRANS_INNER_TIMEOUT; else return E_TRANS_INNER_TIMEOUT; } //如果后台失败,则此处返回后台返回的错误码 if(aPack.head.retCode) { return aPack.head.retCode; } //调用银行接口函数,按照不同的银行转帐接口发送报文并接受应答 //该函数为通用结构,不同银行接口按照该函数名进行封装转帐报文 // cur_serial_no=aPack.pack.lvol1; ret=Bank_Transfer(pNode,cur_serial_no); if(ret) { writelog(LOG_ERR,"Bank_Transfer error,errcode=[%d]",ret); if(E_TRANS_BANK_NOANSWER==ret) //如果银行没有返回包,进行冲正处理 { ResetNormalCPack(&sPack, 0, 1); sPack.head.RequestType = 240003; SetHeadCol(&sPack, F_SORDER2,F_SCUST_AUTH,F_SEMP_PWD,F_SSERIAL0,F_LVOL5,F_LVOL0,F_LVOL6,F_LVOL1,F_LVOL2, 0); // 设置发送windows BU的头部视图信息 //memcpy(&(sPack.pack), in_pack, sizeof(sPack.pack)); des2src(sPack.pack.sorder2,pNode->TerminalId); des2src(sPack.pack.scust_auth,pNode->BankCardNo); des2src(sPack.pack.semp_pwd,pNode->AccountPwd); des2src(sPack.pack.sserial0,pNode->CardNo); sPack.pack.lvol5=atoi(pNode->TransMoney); sPack.pack.lvol0=cur_serial_no; sPack.pack.lvol6=atoi(pNode->AccountMoney); sPack.pack.lvol1=pNode->RecvNo; sPack.pack.lvol2=g_Bank.BankUnit[g_Bank.cur_bankid].iBankID; ret = ExtCall(0, g_Bank.DRTP_BRANCH, g_Bank.BCC_BASEFUNCNO, 0, g_Bank.TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0||aPack.head.retCode!=0) { writelog(LOG_ERR,"Call 240003 error,ret=[%d],retCode=[%d]",ret,aPack.head.retCode); } return E_TRANS_BANK_NOANSWER; } else return ret; } //调用后台正式入账接口 ResetNormalCPack(&aPack, 0, 1); sPack.head.RequestType = 240001; SetHeadCol(&sPack, F_SORDER2,F_SCUST_AUTH,F_SEMP_PWD,F_SSERIAL0,F_SSTATION0,F_LVOL5,F_LVOL0,F_LVOL6,F_LVOL1,F_LVOL2,F_LVOL7,0); // 设置发送windows BU的头部视图信息 //外部系统标识,标识哪个银行 sPack.pack.lvol2=g_Bank.BankUnit[g_Bank.cur_bankid].iBankID; des2src(sPack.pack.sstation0,g_Bank.BankUnit[g_Bank.cur_bankid].szBankAccountNO); sPack.pack.lvol7=cur_serial_no; //模拟入账返回的流水号,用此流水号正式入账 ret = ExtCall(0, g_Bank.DRTP_BRANCH, g_Bank.BCC_BASEFUNCNO, 0, g_Bank.TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0) { if (-2 == ret) return E_TRANS_INNER_TIMEOUT; else return E_TRANS_INNER_TIMEOUT; } if(aPack.head.retCode) { return aPack.head.retCode; } sprintf(pNode->TransMoney,"%f",aPack.pack.damt1); sprintf(pNode->ExtraMoney,"%f",aPack.pack.damt2); sprintf(pNode->AccountMoney,"%d",aPack.pack.lvol2); pNode->RecvNo=aPack.pack.lvol1; pNode->MngFeeFlag='1'; //writelog(LOG_INFO,"transfer succeed!"); return 0; }
static int elect_request(ST_PACK *in_pack,char ext_msg[256]){ int ret = 0; char host[16]=""; //对方机器的ip char portchar[10]=""; short port=0; //对方机器的port char senddata[elec_len+1]=""; //加密后的传送数据 char c_drtbranch[10]=""; char c_bccbasefuncno[10]=""; int DRTP_BRANCH =0; int BCC_BASEFUNCNO =0; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 ST_CPACK sPack; // 设置发送包 ret=GetParameter(2301, host); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } ret=GetParameter(2302, portchar); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } ret=GetParameter(2303, c_drtbranch); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } ret=GetParameter(2304, c_bccbasefuncno); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } port = atoi(portchar); DRTP_BRANCH = atoi(c_drtbranch); BCC_BASEFUNCNO = atoi(c_bccbasefuncno); ret = packege_elec_request(in_pack,2,senddata); if(ret){ writelog(LOG_ERR,"packege send data error,error code is [%d]",ret); return ret; } ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); ResetNormalCPack(&sPack, 0, 1); SetHeadCol(&sPack, F_SSECTYPES,F_LVOL0,F_LVOL1,F_SCUST_AUTH,0); // 设置发送windows BU的头部视图信息 sPack.head.RequestType = 250002; des2src(sPack.pack.ssectypes,senddata); des2src(sPack.pack.scust_auth,host); sPack.pack.lvol0=port; sPack.pack.lvol1=1; ret = ExtCall(0, DRTP_BRANCH, BCC_BASEFUNCNO, 0, TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0||aPack.head.retCode!=0) { if(ret<0) { writelog(LOG_ERR,"Call 250002 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return ret; } else { writelog(LOG_ERR,"Call 250002 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return aPack.head.retCode; } } return 0; /* memset(&ElectTrans,0,sizeof(ElectTrans)); memcpy(&ElectTrans, aPack.pack.ssectypes,141); if(strncmp(ElectTrans.retnum,"0001",4)==0){ //成功 writelog(LOG_INFO,"trans success ret[%s] ",ElectTrans.retnum); return 0; }else if(strncmp(ElectTrans.retnum,"0400",4)){ writelog(LOG_ERR,"trans falied ret[%s] ",ElectTrans.retnum); return E_ELEC_DATA; }else if(strncmp(ElectTrans.retnum,"0401",4)){ writelog(LOG_ERR,"trans falied ret[%s] ",ElectTrans.retnum); return E_ELEC_DB_CONN; }else if(strncmp(ElectTrans.retnum,"0403",4)){ writelog(LOG_ERR,"trans falied ret[%s] ",ElectTrans.retnum); return E_ELEC_ROOM; }else if(strncmp(ElectTrans.retnum,"0404",4)){ writelog(LOG_ERR,"trans falied ret[%s] ",ElectTrans.retnum); return E_ELEC_WORKSTAT; }else if(strncmp(ElectTrans.retnum,"0406",4)){ writelog(LOG_ERR,"trans falied ret[%s] ",ElectTrans.retnum); return E_ELEC_DATA_LOSS; }else if(strncmp(ElectTrans.retnum,"0407",4)){ writelog(LOG_ERR,"trans falied ret[%s] ",ElectTrans.retnum); return E_ELEC_UNKNOW; } return -1; */ }
static int elect_request_changzhou(ST_PACK *in_pack,char ext_msg[256]){ int ret = 0; char c_drtbranch[10]=""; char c_bccbasefuncno[10]=""; int DRTP_BRANCH =0; int BCC_BASEFUNCNO =0; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 ST_CPACK sPack; // 设置发送包 int card_id; T_t_cif_customer tCustomer; T_t_pif_spefee tSpeFee; T_t_aif_account tAccount; T_t_pif_card tCard; memset(&tCustomer,0,sizeof(tCustomer)); memset(&tSpeFee,0,sizeof(tSpeFee)); memset(&tAccount,0,sizeof(tAccount)); memset(&tCard,0,sizeof(tCard)); card_id=in_pack->lvol0; ret=DB_t_pif_card_read_by_card_id(card_id, &tCard); if(ret) { if(DB_NOTFOUND==ret) ret=E_CARDNO_NOT_EXIST; else ret=E_DB_CARD_R; return ret; } ret=DB_t_cif_customer_read_lock_by_cur_and_cut_id(tCard.cosumer_id, &tCustomer); if(ret) { writelog(LOG_ERR,"cut_id[%d]",tCard.cosumer_id); if(DB_NOTFOUND==ret) ret= E_CUSTOMER_NOT_EXIST; else ret= E_DB_CUSTOMER_R; return ret; } ret=GetParameter(2501, c_drtbranch); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } ret=GetParameter(2502, c_bccbasefuncno); if(ret){ writelog(LOG_ERR,"get_parameter error,error code=[%d]",ret); return ret; } DRTP_BRANCH = atoi(c_drtbranch); BCC_BASEFUNCNO = atoi(c_bccbasefuncno); ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); ResetNormalCPack(&sPack, 0, 1); SetHeadCol(&sPack, F_SSECTYPES,F_LVOL0,F_LVOL1,F_SORDER0,F_SCUST_AUTH,0); // 设置发送windows BU的头部视图信息 sPack.head.RequestType = 847357; sPack.pack.lvol0=in_pack->lvol10;//房间号 sPack.pack.lvol1=D2I(in_pack->damt1*100);//转账金额(分) memcpy(sPack.pack.sorder0,tCustomer.cut_name,11); ret = ExtCall(0, DRTP_BRANCH, BCC_BASEFUNCNO, 0, TIMEOUT, &sPack, &aPack, &ArrayPack); if (ret < 0||aPack.head.retCode!=0) { if(ret<0) { writelog(LOG_ERR,"Call 847357 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return ret; } else { writelog(LOG_ERR,"Call 847357 error,errcode=[%d],retCode=[%d]",ret,aPack.head.retCode); return aPack.head.retCode; } } return 0; }
static int DoQueryBala(int tradecode,ST_PACK *rPack,ST_PACK *out_pack,char *szMsg) { int ret = 0; int request_type = 2401; int drtp_branch = 0; int base_funcno = 0; int bcc_timeout = 0; int termid=rPack->lcert_code; int cardno=rPack->lvol0; int custid = rPack->lvol1; char sdatetime[15]=""; char custidstr[50]=""; T_t_card tCard; T_t_bankcard bankcard; T_t_cfgbank cfgbank; T_t_customer tCust; memset(&cfgbank,0,sizeof cfgbank); memset(&bankcard,0,sizeof bankcard); memset(&tCard,0,sizeof(tCard)); memset(&tCust,0,sizeof tCust); char bankcode[3] = ""; ST_PACK ArrayPack; // 设置返回包 ST_CPACK aPack; // 设置应答包 ST_CPACK sPack; // 设置发送包 ResetNormalCPack(&aPack, 0, 1); memset(&ArrayPack, 0, sizeof(ArrayPack)); ResetNormalCPack(&sPack, 0, 1); sPack.head.RequestType = request_type; SetHeadCol(&sPack,F_STX_PWD, F_LCERT_CODE,F_SCUST_AUTH,F_LVOL0,F_LVOL1,F_LVOL2,F_LVOL6,F_SDATE0,F_STIME0,F_SPHONE2, F_SHOLDER_AC_NO,F_SPHONE,F_SCUST_LIMIT,F_SCUST_LIMIT2,F_SCUST_AUTH2,F_SEMP_PWD,0); if(custid<1) { if(cardno>0) { ret=DB_t_card_read_by_cardno(cardno,&tCard); if(ret) { if(DB_NOTFOUND==ret) return E_NOTEXIST_CARDNO; else return E_DB_CARD_R; } if(tCard.status[0]!=STATUS_NORMAL) { return ERRINFO(E_CARD_LOGOUT,cardno); } if('1'==tCard.frozeflag[0]) { return ERRINFO(E_CARD_FREEZE,cardno); } if('1'==tCard.lossflag[0]) { return ERRINFO(E_CARD_LOST,cardno); } if('1'==tCard.badflag[0]) { return ERRINFO(E_CARD_BADRECORD,cardno); } if('1'==tCard.lockflag[0]) { return ERRINFO(E_CARDNO_LOCKED,cardno); } custid=tCard.custid; } else { return E_NOTEXIST_CARDNO; } } if(custid>0) { ret = DB_t_customer_read_by_custid(custid, &tCust); if(ret) { return E_DB_CUSTOMER_R; } ret = DB_t_bankcard_read_by_custid(custid, &bankcard); if(ret) { return E_DB_BANKCARD_R; } des2src(bankcode,bankcard.bankcode); } ret = DB_t_cfgbank_read_by_bankcode(bankcode,&cfgbank); if(ret) { return E_DB_CFGBANK_R; } CAccTrans *pAccTrans=CAccTrans::getInstance(); if(strncmp(pAccTrans->trans.acctime,cfgbank.bankstarttime,6) < 0 || strncmp(pAccTrans->trans.acctime,cfgbank.bankendtime,6) > 0) { return E_OUT_BANKTIME; } T_t_area area; memset(&area,0,sizeof area); ret=DB_t_area_read_by_areacode(tCust.areacode,&area); if (ret) { writelog(LOG_ERR,"read area err custid[%d] ",tCust.custid); // return E_DB_AREA_R; } drtp_branch = cfgbank.bccdrtpno; // drtp 编号 base_funcno = cfgbank.bccfuncno; // 前置主功能号 bcc_timeout = cfgbank.bcctimeout; // 前置超时时间 sPack.pack.lcert_code = tradecode; // 交易码 des2src(sPack.pack.scust_auth,cfgbank.bankip); // 银行ip sPack.pack.lvol0 = cfgbank.bankport; // 银行端口 sPack.pack.lvol1 = cfgbank.banktimeout*1000; // 银行超时时间 sPack.pack.lvol2 = custid; // 客户号 getsysdatetime(sdatetime); memcpy(sPack.pack.sdate0,sdatetime,8); // 交易日期 memcpy(sPack.pack.stime0,sdatetime+8,6); // 交易时间 // des2src(sPack.pack.sholder_ac_no,transdtl->refno); // 一卡通交易参考号 des2src(sPack.pack.sphone,tCust.stuempno); // 学工号 des2src(sPack.pack.scust_limit,tCust.custname); // 姓名 des2src(sPack.pack.scust_auth2,tCust.idno); // 身份证号 des2src(sPack.pack.scust_limit2,bankcard.bankcardno); // 银行卡号 des2src(sPack.pack.sphone2,area.remark); sPack.pack.lvol6 = termid; // 终端号 if(bcc_timeout<5) bcc_timeout=5; // 云交职-云南省农村信用接口: 个人校验码,非银行密码 des2src(sPack.pack.semp_pwd,rPack->semp_pwd); ret = ExtCall(0, drtp_branch, base_funcno, 0, bcc_timeout, &sPack, &aPack, &ArrayPack); if (ret < 0 || aPack.head.retCode != 0) { writelog(LOG_ERR,"extcall 2401 ret[%d],retcode[%d] timeout[%d] ",ret,aPack.head.retCode,bcc_timeout); if (ret < 0) // 通讯错误 { strcpy(szMsg,"调用后台业务失败,业务终止"); return E_BCC_NETWORK; } else // 收到前置返回的错误 { strcpy(szMsg,aPack.pack.vsmess); return E_COMMON_ERR; } } if(aPack.pack.lvol1 != 1) // 前置解包错误 { strcpy(szMsg,"接收银行数据错误"); return E_BCC_NETWORK; } des2src(out_pack->sall_name,aPack.pack.sall_name); //客户号 out_pack->damt0 = aPack.pack.damt0; // 账户余额 out_pack->damt1 = aPack.pack.damt1; // 可用余额 return 0; }