int F847352(TRUSERID *handle, int iRequest, ST_PACK *in_pack, int *pRetCode, char *szMsg) { int error_code = 0; int money = 0; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack, 0, 1); Save_Info save_info; memset(&save_info, 0, sizeof(save_info)); SetCol(handle,0); SetCol(handle, F_LVOL0, F_LVOL1, F_DAMT0, F_DAMT1, F_SPHONE, F_LVOL10, 0); if (1 == in_pack->lvol3) { // 连接第三方数据库 if (error_code = InitDB()) { error_code = DLLFUN_ERR_TRANSFER_THIRD_PART_FAIL; goto L_RETU; } // 检测第三方帐号 CheckAccountNo(in_pack->lvol4, &money, &error_code); if (0 != error_code) { error_code = DLLFUN_ERR_CHECK_ACC_THIRD_PART_FAIL; } out_pack->lvol0 = money; goto L_RETU; } save_info.cut_id = in_pack->lvol0; save_info.save_Money = in_pack->lvol1; save_info.save_type = in_pack->lvol2; SaveInfo(&save_info, &error_code); if (error_code != 0) { g_LogFile.WriteLogEx(1001, "客户号[%d]--转帐金额[%d]--转账类型[%d]--错误码[%d]--序号[%d]", save_info.cut_id, save_info.save_Money, save_info.save_type, error_code, ++count1); error_code = DLLFUN_ERR_TRANSFER_FAIL; } L_RETU: out_pack->lvol1 = error_code; *pRetCode = error_code; PutRow(handle, out_pack, pRetCode, szMsg); return error_code; }
int F846313(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; cpu_trade_t cpu_trade; ST_CPACK aPack; ST_PACK *outPack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LVOL0,F_SSTOCK_CODE2,F_LSERIAL1,F_SEMAIL,0); memset(&cpu_trade,0,sizeof cpu_trade); cpu_trade.trade_type=rPack->lsafe_level; des2src(cpu_trade.random_key,rPack->sstock_code); des2src(cpu_trade.cardphyid,rPack->sstation1); cpu_trade.tradeamt = rPack->lvol1; cpu_trade.tradecnt = rPack->lvol6; // 必须是交易前次数 cpu_trade.balance = rPack->lvol7; cpu_trade.termsno = rPack->lserial0; des2src(cpu_trade.termno,rPack->sserial0); // 终端号 strncpy(cpu_trade.tx_datetime,rPack->sdate0,8); strncpy(cpu_trade.tx_datetime+8,rPack->stime0,6); des2src(outPack->sstock_code2,rPack->sstock_code2); // MAC1,只在移动规范中使用 // 计算出 MAC2 if(rPack->lvol5 == 2) { ret = calc_cpucard_mac(&cpu_trade,outPack->semail,rPack->lvol5); } else { ret = calc_cpucard_mac(&cpu_trade,outPack->sstock_code2,rPack->lvol5); } if(ret) { writelog(LOG_ERR,"doCheckMac err[%d]",ret); return ret; } outPack->lvol0 = rPack->lvol0; //交易卡号 outPack->lserial1=rPack->lserial1; // 交易流水号 PutRow(handle,outPack,pRetCode,szMsg); return 0; }
int F240008(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; T_t_device device; T_t_syspara t_syspara; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_SCARD0,0); memset(&device,0,sizeof(device)); memset(&t_syspara,0,sizeof(t_syspara)); ret=DB_t_syspara_read_by_paraid(GLOBLE_SYSPARA_STATIC_KEY, &t_syspara); if(ret) { writelog(LOG_ERR,"DB_t_syspara_read_by_paraid error,error code=[%d]",ret); if(DB_NOTFOUND==ret) return E_DB_SYSPARA_N; else return E_DB_SYSPARA_R; } ret=DB_t_device_read_lock_by_c0_and_deviceid(atoi(rPack->sorder2),&device); if(ret) { if(ret==DB_NOTFOUND) { writelog(LOG_ERR,"DB_t_device_read_lock_by_c0_and_deviceid error,error code=[%d]",ret); return E_NOTEXIST_DEVICE; } else { writelog(LOG_ERR,"DB_t_device_read_lock_by_c0_and_deviceid error,error code=[%d]",ret); return E_DB_DEVICE_R; } } device.runstatus[0]=DEVRUNSTATUS_ONLINE; //更改设备注册表状态为在线状态 ret=DB_t_device_update_lock_by_c0(&device); if(ret) { writelog(LOG_ERR,"DB_t_device_update_lock_by_c0 error,error code=[%d]",ret); return E_DB_DEVICE_U; } des2src(out_pack->scard0,t_syspara.paraval); PutRow(handle,out_pack,pRetCode,szMsg); return 0; }
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 F240024(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_DAMT0,F_DAMT1,F_SALL_NAME,0); ret = DoQueryBala(BANK_QUERYBALA,rPack,out_pack,szMsg); if(ret) return ret; PutRow(handle,out_pack,pRetCode,szMsg); return 0; }
int F240004(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; T_t_tif_tradeserial tradeserial; //卡操作流水表,用做冲正用 memset(&tradeserial,0,sizeof tradeserial); ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); SetCol(handle,0); SetCol(handle,F_SCLOSE_EMP,F_SORDER0,F_SORDER1,F_SSERIAL1,F_LVOL0,F_LVOL1,F_SDATE0,F_STIME0,F_SDATE1,F_STIME1,F_SCUST_NO,F_SCHANGE_EMP,F_SSERIAL0,F_LVOL2,F_SCUST_AUTH,F_SSTATUS1,F_SEMP_PWD,F_SEMP_PWD2,F_SSTATION0,F_SSTATION1,F_SORDER2,0); ret = DB_t_tif_tradeserial_next_flush(&tradeserial); if(ret) { if(ret==DB_NOTFOUND) { *pRetCode=E_DB_TRADESERIAL_N; goto L_RETU; } else { *pRetCode=E_DB_TRADESERIAL_R; writelog(LOG_ERR,"读取冲正记录失败,errcode=[%d]",ret); goto L_RETU; } } sprintf(out_pack->sorder0,"%-9d", int(tradeserial.trade_fee)); Strncpy_t(out_pack->sdate0,tradeserial.operate_date,sizeof(out_pack->sdate0)); Strncpy_t(out_pack->stime0,tradeserial.operate_time,sizeof(out_pack->stime0)); sprintf(out_pack->sserial0,"%-10d",tradeserial.cardno); Strncpy_t(out_pack->scust_auth,tradeserial.b_act_id,sizeof(out_pack->scust_auth)); out_pack->lvol0=tradeserial.reviseserial_no; out_pack->lvol1=tradeserial.serial_no; out_pack->lvol2=tradeserial.deviceid; PutRow(handle,out_pack,pRetCode,szMsg); return 0; L_RETU: return ret; }
int F820522(TRUSERID * handle, int iRequest, ST_PACK * in_pack, int *pRetCode, char *szMsg) { int ret; CAccTrans& ats=CAccTrans::GetInst(); ret=ats.Reset(); if(ret) return ret; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack, 0, 1); SetCol(handle, F_VSMESS, F_SDATE0, F_SDATE1, F_SDATE2, F_SDATE3, F_SSTATUS0, F_STIME0, 0); sprintf(out_pack->sdate0,"%d",ats.hostdate); sprintf(out_pack->stime0,"%06d",ats.hosttime); sprintf(out_pack->sdate1,"%d",ats.settledate); calcEndDate(out_pack->sdate1,-1,out_pack->sdate2); calcEndDate(out_pack->sdate1,1,out_pack->sdate3); PutRow(handle, out_pack, pRetCode, szMsg); return 0; }
int F849009(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg) { int ret; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); memset(&aPack,0,sizeof aPack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LVOL0,F_LVOL1,F_LVOL2,F_DAMT0,0); ret = do_849009(in_pack,szMsg,out_pack,1); if(ret) { *pRetCode = ret; goto L_RETU; } PutRow(handle,out_pack,pRetCode,szMsg); return 0; L_RETU: return -1; }
// 函数名: CSvrLink::Err_Deal // 编程 : 陈永华 2004-2-22 16:36:05 // 描述 : 清除原来准备的应答信息,并且在运行时跟踪文件中记录(错误)信息(为了与集中交易兼容) // 返回 : int SendMsg返回信息 // 参数 : char *emsg // 参数 : int retcode int CSvrLink::Err_Deal(char *emsg, int retcode) { /* ****** Updated by CHENYH at 2004-3-12 13:49:50 ****** unsigned char pb[PARMBYTES]; int rtn; memset(pb,0,sizeof(pb)); rtn = SetCol(NULL,pb); */ head.recCount = 0; memset(head.ParmBits,0,sizeof(head.ParmBits)); SetParmBit(&head,F_VSMESS); iLastRetCode = retcode; strcpy(eMsg,emsg); ST_PACK pack; strcpy(pack.vsmess,emsg); return(PutRow(&ruserid,&pack,retcode,emsg)); /* ****** Updated by CHENYH at 2004-3-12 13:46:02 ****** rtn = AnswerData(&user,retcode,emsg,0); // 不容许有后续数据返回了,只有一条结果记录(emsg应该是有值的) return(rtn); */ }
/* static int waternobalareturn(CAccTrans *pAccTrans,ST_PACK *rPack,ST_PACK *outPack) { int ret =0; T_t_card tCard; T_t_pursetype pursetype; memset(&pursetype,0,sizeof(pursetype)); memset(&tCard,0,sizeof(tCard)); pAccTrans->trans.transcode=TC_WATERNOBALARET; des2src(pAccTrans->trans.opercode,rPack->semp); pAccTrans->trans.termid=rPack->lwithdraw_flag; ret=pAccTrans->InitTrans(); if(ret) return ret; TRANS& trans=pAccTrans->trans; trans.cardno=rPack->lvol0; trans.purseno=PURSE_NO_TWO; ret = DB_t_card_read_by_cardno(trans.cardno, &tCard); if(ret) return E_DB_CARD_R; trans.feetype=tCard.feetype; trans.custid=tCard.custid; trans.transamt=trans.inputamt; trans.unusedamt = trans.inputamt; trans.cardbefbal=trans.inputamt; trans.cardaftbal=0; pursetype.pursetype=rPack->lvol1; ret=DB_t_pursetype_read_by_pursetype(pursetype.pursetype,&pursetype); if(ret) { return E_DB_PURSETYPE_R; } writelog(LOG_INFO,"transamt[%f],pursetype[%d],onlineflag[%d]",trans.transamt,pursetype.pursetype,pursetype.onlineflag); if(pursetype.onlineflag) { pAccTrans->trans.transtype=TRANSTYPE_WATERNOBALAREFUND; ret=pAccTrans->DoTransByTransType(); if(ret) return ret; ret=pAccTrans->doTransEnd(); if(ret) return ret; } else // 脱机水控不支持 { return 0; } T_t_transdtl transdtl; memset(&transdtl,0,sizeof(transdtl)); des2src(transdtl.refno,trans.refno); des2src(transdtl.transdate,trans.transdate); des2src(transdtl.transtime,trans.transtime); strcpy(transdtl.accdate,trans.accdate); strcpy(transdtl.acctime,trans.acctime); transdtl.termid=trans.termid; transdtl.termseqno=trans.termseqno; transdtl.transcode=trans.transcode; transdtl.cardno=trans.cardno; transdtl.purseno=trans.purseno; transdtl.cardbefbal=trans.cardbefbal; transdtl.cardaftbal=trans.cardaftbal; transdtl.amount=trans.totaltransamt; transdtl.managefee=trans.totalfeeamt; transdtl.custid=trans.custid; des2src(transdtl.custname,trans.custname); des2src(transdtl.opercode,trans.opercode); transdtl.status[0]=DTLSTATUS_SUCCESS; des2src(transdtl.showcardno,trans.showcardno); GetStuempnoByCustid(transdtl.custid,transdtl.stuempno); ret=DB_t_transdtl_add(&transdtl); if(ret) { if(DB_REPEAT==ret) return E_DB_TRANSDTL_E; else return E_DB_TRANSDTL_I; } return 0; } */ int F850020(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; CAccTrans *pAccTrans=CAccTrans::getInstance(); pAccTrans->trans.transcode=TC_WATERBALRETURN; des2src(pAccTrans->trans.opercode,rPack->semp); pAccTrans->trans.termid=rPack->lwithdraw_flag; ret=pAccTrans->InitTrans(); if(ret) return ret; ST_CPACK aPack; ST_PACK *outPack = &(aPack.pack); memset(&aPack,0,sizeof(aPack)); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LVOL0,F_LVOL1,F_LVOL2,F_LVOL3,F_LVOL8,F_SDATE0,F_SPHONE3,F_SADDR,F_LVOL5,F_LVOL9,F_LSAFE_LEVEL,F_LSAFE_LEVEL2, F_SDATE3,F_STIME3,F_SEMP,F_LWITHDRAW_FLAG,F_LSERIAL1,F_VSMESS,0); ret = waterbalareturn(pAccTrans,rPack,outPack); if(ret) return ret; /* if(amtcmp(outPack->damt0, 0)>0 ) // 小钱包卡库不平 { pAccTrans->Reset(); pAccTrans->trans.inputamt= outPack->damt0; ret = waternobalareturn(pAccTrans,rPack,outPack); if(ret) return ret; } */ if(iRequest != 846305) // 补办卡时,不返回结果 { PutRow(handle,outPack,pRetCode,szMsg); } return 0; }
int F950006(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; ST_CPACK aPack; ST_PACK* out_pack = &(aPack.pack); char buf[256] = ""; char static_key[17]="4343232323231111"; if(0!=strncmp(static_key,rPack->scust_limit,sizeof(static_key))) { int sysid = rPack->lcert_code; ret = CheckGatewayDynKey(sysid,rPack->scust_limit); if(ret) { writelog(LOG_ERR,"动态密钥错误"); *pRetCode = ret; goto L_RETU; } } ret = GetParameter(rPack->lvol0,buf); writelog(LOG_DEBUG,"请求参数parameter[%d]",rPack->lvol0); if(ret) { writelog(LOG_ERR,"获取参数失败[%d]",rPack->lvol0); *pRetCode = ret; goto L_RETU; } ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_SCARD0,0); des2src(out_pack->scard0,buf); PutRow(handle,out_pack,pRetCode,szMsg); return 0; L_RETU: return -1; }
int F847150(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret =0; char accno[21]=""; char accflag=0; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_SBANKNAME,0); des2src(accno,rPack->sbank_acc); int subjflag=rPack->lvol1; if(subjflag) { //查询科目全称 T_t_subject subject; memset(&subject,0,sizeof(subject)); ret=DB_t_subject_read_by_subjno(accno,&subject); if(ret) { if(DB_NOTFOUND==ret) return E_DB_SUBJECT_N; else return E_DB_SUBJECT_R; } strcpy(out_pack->sbankname,subject.subjfullname); PutRow(handle,out_pack,pRetCode,szMsg); return 0; } if(strlen(accno)<10) { accflag=ACCFLAG_INNER; } else { if('1'==accno[0]) accflag=ACCFLAG_CARD; else if('2'==accno[0]) accflag=ACCFLAG_SHOP; else if('3'==accno[0]) accflag=ACCFLAG_EACC; else { return ERRINFO(E_NOTEXIST_ACCNO,accno); } } switch(accflag) { case ACCFLAG_CARD: { T_t_account tAccount; memset(&tAccount,0,sizeof(tAccount)); ret=DB_t_account_read_by_accno(accno, &tAccount); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CARDACCNO,accno); else return E_DB_ACCOUNT_R; } strcpy(out_pack->sbankname,tAccount.accname); } break; case ACCFLAG_SHOP: { T_t_shopacc tShopAcc; memset(&tShopAcc,0,sizeof(tShopAcc)); ret=DB_t_shopacc_read_by_accno(accno, &tShopAcc); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_SHOPACCNO,accno); else return E_DB_ACCOUNT_R; } strcpy(out_pack->sbankname,tShopAcc.accname); } break; case ACCFLAG_EACC: { T_t_netacc tNetAcc; memset(&tNetAcc,0,sizeof(tNetAcc)); ret=DB_t_netacc_read_by_accno(accno, &tNetAcc); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_EACCNO,accno); else return E_DB_ACCOUNT_R; } strcpy(out_pack->sbankname,tNetAcc.accname); } break; case ACCFLAG_INNER: { T_t_inneracc tInnerAcc; memset(&tInnerAcc,0,sizeof(tInnerAcc)); ret=DB_t_inneracc_read_by_accno(accno, &tInnerAcc); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_INNERACCNO,accno); else return E_DB_ACCOUNT_R; } strcpy(out_pack->sbankname,tInnerAcc.accname); } break; } PutRow(handle,out_pack,pRetCode,szMsg); return 0; }
int F930021(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg) { int ret = 0; int cnt=0; int mesid=0; T_t_tif_meslist tMesList; T_t_pif_device tDevice; T_t_pif_device tPDev; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_VSVARSTR0,0); memset(&tMesList,0,sizeof(tMesList)); memset(&tDevice,0,sizeof(tDevice)); memset(&tPDev,0,sizeof tPDev); if(strlen(in_pack->sdate0)==0) { *pRetCode=E_DEVPHYID_NULL; goto L_RETU; } ret=get_devinfo_by_phyid(in_pack->sdate0,&tDevice); if(ret) { *pRetCode=ret; writelog(LOG_ERR,"get_devinfo_by_phyid err[%d]",ret); goto L_RETU; } if((ret = get_devinfo_by_phyid(tDevice.fdev_id,&tPDev))) { *pRetCode = ret; goto L_RETU; } AddXmlItemStr(tMesList.incontent,XML_KEY_DEV999_ID, tDevice.dev999_id); AddXmlItemInt(tMesList.incontent,XML_KEY_DEV999_NO, tDevice.dev999_no); AddXmlItemStr(tMesList.incontent,XML_KEY_DEVTYPE,tDevice.devtype); AddXmlItemStr(tMesList.incontent,XML_KEY_DEVVERSION, tDevice.devversion); AddXmlItemStr(tMesList.incontent,XML_KEY_CARDSTR, tDevice.cardstr); AddXmlItemStr(tMesList.incontent,XML_KEY_VCARDSET, tDevice.cardtype); AddXmlItemInt(tMesList.incontent, XML_KEY_PORTCOUNT, tDevice.portcount); AddXmlItemStr(tMesList.incontent, XML_KEY_FDEVPHY_ID, tPDev.dev999_id); AddXmlItemInt(tMesList.incontent, XML_KEY_PORTNO,tDevice.portno); AddXmlItemInt(tMesList.incontent, XML_KEY_STATE_ID, tDevice.state_id); AddXmlItemInt(tMesList.incontent,XML_KEY_JOINMODE,tDevice.joinmode); AddXmlItemStr(tMesList.incontent, XML_KEY_COMADD, tDevice.comadd); AddXmlItemStr(tMesList.incontent, XML_KEY_PORT, tDevice.port); AddXmlItemInt(tMesList.incontent, XML_KEY_BAUDRATE, tDevice.baudrate); AddXmlItemInt(tMesList.incontent, XML_KEY_COMTYPE,tDevice.comtype); AddXmlItemStr(tMesList.incontent, XML_KEY_NOTVALIDITY, tDevice.bsheetvdate); AddXmlItemStr(tMesList.incontent, XML_KEY_VERNUM,tDevice.bsheetver); AddXmlItemInt(tMesList.incontent, XML_KEY_LASTTRASERNO, tDevice.lasttraserno); AddXmlItemStr(tMesList.incontent, XML_KEY_LASTTRADATE, tDevice.lasttradate); AddXmlItemInt(tMesList.incontent, XML_KEY_LASTSHUTSERNO, tDevice.lastshutserno); AddXmlItemStr(tMesList.incontent, XML_KEY_LASTSHUTDATE, tDevice.lastshutdate); tMesList.devid = tDevice.device_id; tMesList.funid = 930021; tMesList.level = 3; ret=AddMsgLst(&tMesList); if(ret) { *pRetCode=ret; writelog(LOG_ERR,"AddMsgLst err[%d]",ret); goto L_RETU; } if(iRequest!=tMesList.funid) return 0; ret=db_commit(); if(ret) { writelog(LOG_ERR,"db_commit ret[%d]",ret); *pRetCode=E_DB_COMMIT; goto L_RETU; } mesid=tMesList.mesid; des2src(out_pack->sdate0,in_pack->sdate0); for(cnt=0;(cnt<10)&&(tMesList.ecode!=0);cnt++) { sleep(1); memset(&tMesList,0,sizeof(tMesList)); ret=DB_t_tif_meslist_read_by_mesid(mesid, &tMesList); if(ret) { writelog(LOG_ERR,"DB_t_tif_meslist_read_by_mesid err[%d]",ret); *pRetCode=E_DB_MESLIST_R; goto L_RETU; } } switch(tMesList.ecode) { case 0: //成功 des2src(out_pack->vsvarstr0,"成功"); break; case 9999: //交易未处理 des2src(out_pack->vsvarstr0,"前置机无应答"); break; default: //交易已经处理,但结果是失败 des2src(out_pack->vsvarstr0,tMesList.emsg); break; } PutRow(handle,out_pack,pRetCode,szMsg); return 0; L_RETU: return -1; }
int F950041(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret; T_t_pif_device tDevice; T_t_cif_shop_pos tShopPos; T_t_cif_shop tShop; T_t_tif_meslist tMsg; int rate = 0; int retries = 0; int msgid; memset(&tDevice,0,sizeof tDevice); ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_VSVARSTR0,0); if(rPack->lcert_code < 1) { *pRetCode = E_DEVICE_NOT_EXIST; } else if((ret = DB_t_pif_device_read_by_device_id(rPack->lcert_code,&tDevice))) { *pRetCode = ret; } else if(tDevice.state_id == DEVISTAT_LOGOUT) { *pRetCode = E_DEVICE_NOT_EXIST; } else if((ret = DB_t_cif_shop_pos_open_select_by_c0_and_device_id(rPack->lcert_code))) { *pRetCode = ret; } else { while(1) { memset(&tShopPos,0,sizeof tShopPos); memset(&tShop,0,sizeof tShop); if((ret = DB_t_cif_shop_pos_fetch_select_by_c0(&tShopPos))) { *pRetCode = ret; if(ret == DB_NOTFOUND) *pRetCode = 0; break; } if((ret = DB_t_cif_shop_read_by_shop_id(tShopPos.shop_id,&tShop))) { *pRetCode = ret; break; } if('1' == tShop.is_leaf[0] && '1' == tShop.is_getfee[0] && amtcmp(tShop.ratio,0.00)>0 ) { int newrate = (int)tShop.ratio * 100; if(newrate > rate) rate = newrate; } } } if(*pRetCode) return -1; memset(&tMsg,0,sizeof tMsg); tMsg.funid = 950041; //des2src(tMsg.devphy999_id,tDevice.devphy999_id); tMsg.devid = tDevice.device_id; AddXmlItemInt(tMsg.incontent,XML_KEY_FEE,rate); tMsg.max_send_cnt = 5; if((ret = AddMsgLst(&tMsg))) { *pRetCode = ret; } else { if(db_commit()) { *pRetCode = E_DB_COMMIT; return -1; } retries = 3; msgid = tMsg.mesid; while(retries-- > 0) { memset(&tMsg,0,sizeof tMsg); ret = DB_t_tif_meslist_read_by_mesid(msgid,&tMsg); des2src(out_pack->vsvarstr0,tMsg.emsg); if(!ret && !tMsg.ecode) { break; } // 等待1秒 sleep(1); } PutRow(handle,out_pack,pRetCode,szMsg); AnswerData(handle,*pRetCode,szMsg); return 0; } return -1; }
//查询校园卡转帐流水 int Pos_QuerySerial(INNER_TRANS_REQUEST * pNode,TRUSERID *handle,int *pRetCode,char *szMsg) { char key[32+1]=""; char pwd[32+1]=""; //char account_id[16+1]=""; char account_pwd[6+1]=""; int ret=0; int cnt=0; //double unique=0.0; INNER_TRANS_REQUEST from_pos; T_t_tif_tradeserial tradeserial; //卡操作流水表 T_t_aif_account account; T_t_pif_card card; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); memset(&from_pos,0,sizeof(from_pos)); memset(&account,0,sizeof(account)); memset(&card,0,sizeof(card)); memcpy(&from_pos,pNode,sizeof(from_pos)); //判断设备是否登陆 if(0!=device_login_yes_or_no(atoi(from_pos.TerminalId))) { writelog(LOG_ERR,"Device don't login"); return E_TRANS_TERM_NOLOGIN; } ret=DB_t_pif_card_read_by_card_id(atoi(from_pos.CardNo),&card); if(ret) { writelog(LOG_ERR,"DB_t_pif_card_read_lock_by_cur_and_card_id error,errcode=[%d]",ret); //sprintf(pNode->RetCode,"%d",E_TRANS_UNKNOW_ERROR); return E_TRANS_SCHACC_NOEXIT; } strcpy(key,STATIC_SEED_KEY); Strncpy_t(account_pwd, from_pos.AccountPwd,sizeof(account_pwd)); EncodePwd(key,account_pwd,pwd, 0); //判断卡密码是否正确 if(0!=memcmp(pwd,card.password,sizeof(pwd))) { writelog(LOG_ERR,"Card password error,clear_pwd[%s],input_pwd=[%s],db_pwd=[%s]",account_pwd,pwd,card.password); //sprintf(pNode->RetCode,"%d",E_TRANS_SCHCARD_PWDERR); return E_TRANS_SCHCARD_PWDERR; } if(strncmp(card.state_id,TYPE_YES,1)!=0) { DB_t_pif_card_free_lock_by_cur(); writelog(LOG_ERR,"card_state=[%s]",card.state_id); return E_TRANS_SCHACC_DESTORY; } if(STATE_TRUE==card.state_id[CARDSTAT_TYPE_LOST]) { DB_t_pif_card_free_lock_by_cur(); writelog(LOG_ERR,"card_state=[%s]",card.state_id); return E_TRANS_SCHCARD_LOSTING; } if(STATE_TRUE==card.state_id[CARDSTAT_TYPE_FREEZE]) { DB_t_pif_card_free_lock_by_cur(); writelog(LOG_ERR,"card_state=[%s]",card.state_id); return E_TRANS_SCHCARD_FREEZE; } ret=DB_t_tif_tradeserial_open_select_by_cur3_and_serial_type_and_card_id(TRADE_INNER_TRANS,card.card_id); if(ret) { db_chk_err(__FILE__,__LINE__,&sqlca); writelog(LOG_ALERT,"declare cursor err sqlcode[%d]",ret); return E_TRANS_UNKNOW_ERROR; } SetCol(handle,0); SetCol(handle,F_SCLOSE_EMP,F_SORDER0,F_SORDER1,F_SSERIAL1,F_LVOL0,F_LVOL1,F_SDATE0,F_STIME0,F_SDATE1,F_STIME1,F_SCUST_NO,F_SCHANGE_EMP,F_SSERIAL0,F_LVOL2,F_SCUST_AUTH,F_SSTATUS1,F_SEMP_PWD,F_SEMP_PWD2,F_SSTATION0,F_SSTATION1,F_SORDER2,0); while(1) { ret=DB_t_tif_tradeserial_fetch_select_by_cur3(&tradeserial); if(ret) { DB_t_tif_tradeserial_close_select_by_cur3(); if(ret==DB_NOTFOUND) { if(cnt==0) { writelog(LOG_DEBUG,"There havn't record from t_tif_tradeserial table!"); break; } else break; } else return E_TRANS_UNKNOW_ERROR; } cnt++; memcpy(from_pos.TradeDate,tradeserial.operate_date,sizeof(from_pos.TradeDate)); memcpy(from_pos.TradeTime,tradeserial.operate_time,sizeof(from_pos.TradeTime)); sprintf(from_pos.CardNo,"%d",tradeserial.card_id); memcpy(from_pos.BankCardNo,tradeserial.b_act_id,sizeof(from_pos.BankCardNo)); sprintf(from_pos.TransMoney,"%d",int(tradeserial.trade_fee)*100); if(tradeserial.serial_state!=2) { sprintf(from_pos.RetCode,"%s","失败"); } else sprintf(from_pos.RetCode,"%s","成功"); //开始返回应答包 Strncpy_t(out_pack->sclose_emp,from_pos.TradeCode,sizeof(out_pack->sclose_emp)); Strncpy_t(out_pack->sorder0,from_pos.TransMoney,sizeof(out_pack->sorder0)); Strncpy_t(out_pack->sorder1,from_pos.ExtraMoney,sizeof(out_pack->sorder1)); Strncpy_t(out_pack->sserial1,from_pos.AccountMoney,sizeof(out_pack->sserial1)); out_pack->lvol0=from_pos.SendNo; out_pack->lvol1=from_pos.RecvNo; memcpy(out_pack->sdate0,from_pos.TradeDate,sizeof(from_pos.TradeDate)); memcpy(out_pack->stime0,from_pos.TradeTime,sizeof(from_pos.TradeTime)); memcpy(out_pack->sdate1,from_pos.BankDate,sizeof(from_pos.BankDate)); memcpy(out_pack->stime1,from_pos.BankTime,sizeof(from_pos.BankTime)); Strncpy_t(out_pack->scust_no,from_pos.Balance,sizeof(out_pack->scust_no)); Strncpy_t(out_pack->schange_emp,from_pos.RetCode,sizeof(out_pack->schange_emp)); Strncpy_t(out_pack->sserial0,from_pos.CardNo,sizeof(out_pack->sserial0)); out_pack->lvol2=from_pos.Notecase; Strncpy_t(out_pack->scust_auth,from_pos.BankCardNo,sizeof(out_pack->scust_auth)); sprintf(out_pack->sstatus1,"%c",from_pos.MngFeeFlag); Strncpy_t(out_pack->semp_pwd,from_pos.AccountPwd,sizeof(out_pack->semp_pwd)); Strncpy_t(out_pack->semp_pwd2,from_pos.AccountNewPwd,sizeof(out_pack->semp_pwd2)); Strncpy_t(out_pack->sstation0,from_pos.BankCardPwd,sizeof(out_pack->sstation0)); Strncpy_t(out_pack->sstation1,from_pos.BankCardNewPwd,sizeof(out_pack->sstation1)); Strncpy_t(out_pack->sorder2,from_pos.TerminalId,sizeof(out_pack->sorder2)); // printf("LINE:%d\n",__LINE__); PutRow(handle,out_pack,pRetCode,szMsg); if(cnt>=10) { DB_t_tif_tradeserial_close_select_by_cur3(); break; } } // printf("LINE:%d\n",__LINE__); T_t_tif_tradeserial_his tradeserial_his; memset(&tradeserial_his,0,sizeof(tradeserial_his)); if(cnt<10) { ret=DB_t_tif_tradeserial_his_open_select_by_cur1_and_serial_type_and_card_id(TRADE_INNER_TRANS,card.card_id); if(ret) { db_chk_err(__FILE__,__LINE__,&sqlca); writelog(LOG_ALERT,"declare cursor err sqlcode[%d]",ret); return E_TRANS_UNKNOW_ERROR; } // printf("LINE:%d\n",__LINE__); while(1) { ret=DB_t_tif_tradeserial_his_fetch_select_by_cur1(&tradeserial_his); if(ret) { DB_t_tif_tradeserial_his_close_select_by_cur1(); if(ret==DB_NOTFOUND) { writelog(LOG_DEBUG,"There havn't record from t_tif_tradeserial_his table!"); break; } else return E_TRANS_UNKNOW_ERROR; } cnt++; memcpy(from_pos.TradeDate,tradeserial_his.operate_date,sizeof(from_pos.TradeDate)); memcpy(from_pos.TradeTime,tradeserial_his.operate_time,sizeof(from_pos.TradeTime)); sprintf(from_pos.CardNo,"%d",tradeserial_his.card_id); memcpy(from_pos.BankCardNo,tradeserial_his.b_act_id,sizeof(from_pos.BankCardNo)); sprintf(from_pos.TransMoney,"%d",int(tradeserial_his.trade_fee)*100); if(tradeserial_his.serial_state!=2) { sprintf(from_pos.RetCode,"%s","失败"); } else sprintf(from_pos.RetCode,"%s","成功"); //开始返回应答包 Strncpy_t(out_pack->sclose_emp,from_pos.TradeCode,sizeof(out_pack->sclose_emp)); Strncpy_t(out_pack->sorder0,from_pos.TransMoney,sizeof(out_pack->sorder0)); Strncpy_t(out_pack->sorder1,from_pos.ExtraMoney,sizeof(out_pack->sorder1)); Strncpy_t(out_pack->sserial1,from_pos.AccountMoney,sizeof(out_pack->sserial1)); out_pack->lvol0=from_pos.SendNo; out_pack->lvol1=from_pos.RecvNo; Strncpy_t(out_pack->sdate0,from_pos.TradeDate,sizeof(out_pack->sdate0)); Strncpy_t(out_pack->stime0,from_pos.TradeTime,sizeof(out_pack->stime0)); Strncpy_t(out_pack->sdate1,from_pos.BankDate,sizeof(out_pack->sdate1)); Strncpy_t(out_pack->stime1,from_pos.BankTime,sizeof(out_pack->stime1)); Strncpy_t(out_pack->scust_no,from_pos.Balance,sizeof(out_pack->scust_no)); Strncpy_t(out_pack->schange_emp,from_pos.RetCode,sizeof(out_pack->schange_emp)); Strncpy_t(out_pack->sserial0,from_pos.CardNo,sizeof(out_pack->sserial0)); out_pack->lvol2=from_pos.Notecase; Strncpy_t(out_pack->scust_auth,from_pos.BankCardNo,sizeof(out_pack->scust_auth)); sprintf(out_pack->sstatus1,"%c",from_pos.MngFeeFlag); Strncpy_t(out_pack->semp_pwd,from_pos.AccountPwd,sizeof(out_pack->semp_pwd)); Strncpy_t(out_pack->semp_pwd2,from_pos.AccountNewPwd,sizeof(out_pack->semp_pwd2)); Strncpy_t(out_pack->sstation0,from_pos.BankCardPwd,sizeof(out_pack->sstation0)); Strncpy_t(out_pack->sstation1,from_pos.BankCardNewPwd,sizeof(out_pack->sstation1)); Strncpy_t(out_pack->sorder2,from_pos.TerminalId,sizeof(out_pack->sorder2)); PutRow(handle,out_pack,pRetCode,szMsg); if(cnt>=10) { DB_t_tif_tradeserial_his_close_select_by_cur1(); break; } } } writelog(LOG_INFO,"query trans record succeed!"); return 0; }
int F240157(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int i=0; int ret =0; char logicdate[11]=""; //业务日期 char sysdate[11]=""; char systime[9]=""; InAcc IA; double dUniqno = 0; int card_id=0; int iSerialno=0; char physical_no[41]=""; char sMaxCardBalance[20]=""; char sMsg[256]=""; double dMaxCardBalance=0; T_t_pif_card tCard; T_t_cif_customer tCustomer; T_t_pif_spefee tSpeFee; T_t_aif_account tAccount; //帐户表 T_t_tif_tradeserial tradeserial; T_t_tif_diff_transfer tDiffTransfer; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); memset(&tCard,0,sizeof(tCard)); memset(&tCustomer,0,sizeof(tCustomer)); memset(&tSpeFee,0,sizeof(tSpeFee)); memset(&tAccount,0,sizeof(tAccount)); memset(&tDiffTransfer,0,sizeof(tDiffTransfer)); memset(&tradeserial,0,sizeof(tradeserial)); memset(&IA,0,sizeof(IA)); ResetNormalCPack(&aPack,0,1); if(amtcmp(rPack->damt1,0)==0) { *pRetCode=E_INPUT_AMT; goto L_RETU; } trim(rPack->scust_limit); trim(rPack->scust_limit2); trim(rPack->semp_pwd); if(strlen(rPack->scust_limit)==0) { *pRetCode=E_OPER_NOT_EXIST; goto L_RETU; } if(strlen(rPack->scust_limit2)==0) { *pRetCode=E_INPUT_AUTH_OPER_NULL; goto L_RETU; } if(strcmp(rPack->scust_limit,rPack->scust_limit2)==0) { writelog(LOG_ERR,"oper[%s]auth_oper[%s]",rPack->scust_limit,rPack->scust_limit2); *pRetCode=E_OPER_AND_AUTH_OPER_EQ; goto L_RETU; } ret=chk_oper_pwd(rPack->scust_limit2,rPack->semp_pwd); if(ret) { if(E_OPER_NOT_EXIST==ret) *pRetCode=E_AUTH_OPER_NOT_EXIST; else if(E_PASSWORD_WRONG==ret) *pRetCode=E_AUTH_OPER_PWD; else *pRetCode=ret; goto L_RETU; } card_id=rPack->lvol0; des2src(physical_no, rPack->sbank_acc); //物理卡号 getsysdate(sysdate); getsystime(systime); ret=GetLogicDate(logicdate); //业务日期 if(ret) { *pRetCode=ret; goto L_RETU; } ret=DB_t_pif_card_read_by_card_id(card_id, &tCard); if(ret) { writelog(LOG_ERR,"card_id[%d]",card_id); if(DB_NOTFOUND==ret) *pRetCode=E_CARDNO_NOT_EXIST; else *pRetCode=E_DB_CARD_R; goto L_RETU; } if(card_id!=tCard.card_id) { writelog(LOG_ERR,"card_id[%d] db card_id[%d]",card_id,tCard.card_id); *pRetCode=E_DB_CARD_R; goto L_RETU; } if(strncmp(tCard.state_id,CARDSTAT_REG,4)!=0) { if('2'==tCard.state_id[CARDSTAT_TYPE_REG]) *pRetCode=E_CARDNO_LOGOUT; else if('3'==tCard.state_id[CARDSTAT_TYPE_REG]) *pRetCode=E_CARD_CHANGE; else if(STATE_TRUE==tCard.state_id[CARDSTAT_TYPE_LOST]) *pRetCode=E_CARDNO_LOST; else if(STATE_TRUE==tCard.state_id[CARDSTAT_TYPE_FREEZE]) *pRetCode=E_CARDNO_FREEZE; else if(STATE_TRUE==tCard.state_id[CARDSTAT_TYPE_WFAIL]) *pRetCode=E_CARDNO_WFAIL; goto L_RETU; } trim(physical_no); trim(tCard.physical_no); if(strcmp(tCard.physical_no,physical_no)!=0) { writelog(LOG_ERR,"db physical_no[%s],input physical_no[%s]",tCard.physical_no,physical_no); *pRetCode= E_CARD_PHYNO_DIFFER; goto L_RETU; } iSerialno=rPack->lserial0; ret=DB_t_tif_diff_transfer_read_lock_by_c0_and_op_date_and_local_sn(rPack->sdate0,iSerialno,&tDiffTransfer); if(ret) { writelog(LOG_ERR,"operater_date[%s]Serialno[%d]",rPack->sdate0,iSerialno); if(DB_NOTFOUND==ret) *pRetCode=E_SERIALNO_NOT_EXIST; else *pRetCode=E_DB_TRADESERIAL_R; goto L_RETU; } if(card_id!=tDiffTransfer.card_id) { writelog(LOG_ERR,"input card_id [%d],DiffTransfer card_id[%d]",card_id,tDiffTransfer.card_id); DB_t_tif_diff_transfer_free_lock_by_c0(); *pRetCode=E_CARDNO_SERIAL_NE; goto L_RETU; } if(SERISTAT_NODEBT!=tDiffTransfer.status) { DB_t_tif_diff_transfer_free_lock_by_c0(); *pRetCode=E_TX_SERIAL_CANNOT_CZ; goto L_RETU; } if(amtcmp(tDiffTransfer.diff_amt,rPack->damt1)!=0) { DB_t_tif_diff_transfer_free_lock_by_c0(); *pRetCode=E_INPUT_AMT; goto L_RETU; } tDiffTransfer.status=SERISTAT_DEBT; ret=DB_t_tif_diff_transfer_update_lock_by_c0(&tDiffTransfer); if(ret) { *pRetCode=E_DB_DIFF_TRANSFER_U; goto L_RETU; } DB_t_tif_diff_transfer_free_lock_by_c0(); //根据卡号和钱包号得到消费者账号(借方) ret=DB_t_aif_account_read_by_card_id_and_purse_id(card_id, PURSE_NO_ONE,&tAccount); if(ret) { writelog(LOG_ERR,"DB_t_aif_account_read_by_card_id_and_purse_id ret[%d]card_id[%d]",ret,card_id); if(DB_NOTFOUND==ret) *pRetCode=E_ACTNO_NOT_EXIST; else *pRetCode=E_DB_ACCOUNT_R; goto L_RETU; } ret=GetParameter(GLOBE_MAXCARDBALANCE,sMaxCardBalance); if(ret) { *pRetCode=ret; goto L_RETU; } dMaxCardBalance=atof(sMaxCardBalance); tradeserial.trade_fee = rPack->damt1; //充值金额 if(amtcmp(tAccount.cur_bala+tradeserial.trade_fee,dMaxCardBalance)>0) { *pRetCode= E_AMT_EXCEED_MAX; goto L_RETU; } 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) *pRetCode= E_CUSTOMER_NOT_EXIST; else *pRetCode= E_DB_CUSTOMER_R; goto L_RETU; } //得到收费类别 if(tCustomer.fee_type<1) { ret=DB_t_pif_spefee_read_by_dept_code_and_cut_type(tCustomer.classdept_no, tCustomer.cut_type,&tSpeFee); if(ret) { if(DB_NOTFOUND==ret) { tCustomer.fee_type=tCustomer.cut_type; } else { DB_t_cif_customer_free_lock_cur(); *pRetCode=E_DB_SPEFEE_R; goto L_RETU; } } else { tCustomer.fee_type=tSpeFee.fee_type; } //更新客户表的收费类别字段 ret=DB_t_cif_customer_update_lock_by_cur(&tCustomer); if(ret) { if(DB_NOTFOUND==ret) *pRetCode= E_CUSTOMER_NOT_EXIST; else *pRetCode= E_DB_CUSTOMER_U; goto L_RETU; } } DB_t_cif_customer_free_lock_cur(); ret = getNewUniqNo(KEYTYPE_TRADESERIAL,&dUniqno); //获得最大流水号 if(ret) { *pRetCode = ret; writelog(LOG_ERR," ERRCODE = [%d]",ret); goto L_RETU; } tradeserial.serial_no = (int)dUniqno; //流水号 tradeserial.other_seri_no = 0; //上传端流水号 tradeserial.serial_type = TXCODE_MAKEUPSERIAL; tradeserial.serial_state = SERISTAT_DEBT; //流水状态 des2src(tradeserial.operate_date,sysdate); //发生日期 des2src(tradeserial.operate_time,systime); //发生时间 des2src(tradeserial.collect_date,sysdate); //采集日期 des2src(tradeserial.collect_time,systime); //采集时间 des2src(tradeserial.enteract_date,logicdate); //处理日期 des2src(tradeserial.enteract_time,systime); //处理时间 tradeserial.maindevice_id = rPack->lvol6; //上传工作站标识 // tradeserial.device_id = rPack->lvol7; //采集设备标识 tradeserial.card_id =card_id; //卡号 tradeserial.purse_id = PURSE_NO_ONE; //钱包号 tradeserial.customer_id = tCard.cosumer_id; //客户标识 tradeserial.in_balance=rPack->damt0; //入卡值 tradeserial.trade_count=rPack->lvol1+1; //交易次数 des2src(tradeserial.oper_code,rPack->scust_limit); //操作员代码 tradeserial.sys_id = 0; //外部系统标识 des2src(IA.sArrInActno[0],tAccount.account_id); //帐户 IA.iCardNo=tCard.card_id; IA.iFeeType=tCustomer.fee_type; IA.dArrInAmt[0]=tradeserial.trade_fee; IA.iArrInFeeSwitch[0]=rPack->lvol0; IA.iArrInFeeSwitch[1]=rPack->lvol1; IA.iArrInFeeSwitch[2]=rPack->lvol2; IA.iArrInFeeSwitch[3]=rPack->lvol3; IA.iArrInFeeSwitch[4]=rPack->lvol4; IA.iArrInFeeSwitch[5]=rPack->lvol5; ret=process(&IA,&tradeserial); if(ret) { writelog(LOG_ERR,"process ret[%d]",ret); *pRetCode=ret; goto L_RETU; } sprintf(out_pack->vsmess,"流水号:%d ",IA.iSerialNo); for(i=1;i<=IA.iOutTxTypeCnt;i++) { switch(IA.iArrOutTxType[i]) { case TXTYPE_TOLL_DEPOSIT: case TXTYPE_DEDUCT_DEPOSIT: case TXTYPE_RETURN_DEPOSIT: tradeserial.deposit_fee=IA.dArrOutAmt[i]; break; case TXTYPE_PRE_TOLL_BOARD: case TXTYPE_TOLL_BOARD: case TXTYPE_DEDUCT_BOARD: case TXTYPE_RETURN_BOARD: tradeserial.boardfee=IA.dArrOutAmt[i]; break; case TXTYPE_TOLL_CHARGE: tradeserial.in_fee=IA.dArrOutAmt[i]; break; default: break; } if(amtcmp(IA.dArrOutAmt[i],0)!=0) { sprintf(sMsg,"%s:%.2lf元 ",IA.sArrOutTxName[i],IA.dArrOutAmt[i]); strcat(out_pack->vsmess,sMsg); } } writelog(LOG_DEBUG,out_pack->vsmess); SetCol(handle,0); SetCol(handle,F_LSERIAL1,F_DAMT2,F_DAMT3,F_DAMT4,F_VSMESS,0); out_pack->lserial1=tradeserial.serial_no; //流水号 out_pack->damt2=tradeserial.trade_fee; //充值金额 out_pack->damt3=tradeserial.boardfee; //搭伙费 out_pack->damt4=tradeserial.out_balance; //出卡值 ret = DB_t_tif_tradeserial_add(&tradeserial); if (ret) { writelog(LOG_ERR,"ret[%d]",ret); if(DB_REPEAT==ret) *pRetCode = E_DB_TRADESERIAL_E; else *pRetCode = E_DB_TRADESERIAL_I; goto L_RETU; } PutRow(handle,out_pack,pRetCode,szMsg); return 0; L_RETU: return -1; }
int F847104(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret =0; int len = 0; int i=0; int hi_cutid=0; char h_showcardid[11] = ""; //显示卡号 char h_password[7] = ""; //卡密码 double h_temp_Card_id = 0; //卡号 double dSerialNo=0; char seed_key[17] = ""; //种子密钥 char card_endtime[8 + 1] = ""; //卡的有效截至日期 char logicdate[11]=""; //业务日期 char sysdate[11]=""; char systime[9]=""; char sEndDate[9]=""; char sMsg[256]=""; char sMaxCardBalance[20]=""; char lost_date[11]=""; char buf[64] = ""; int write_failed = 0; double dMaxCardBalance=0; int lost_card_id=0; T_t_pif_card tCard; T_t_pif_card tOldCard; T_t_cif_customer tCustomer; T_t_pif_spefee tSpeFee; // T_t_pif_cardlossinfo tCardLossInfo; T_t_tif_tradeserial tradeserial; T_t_aif_account tAccount; InAcc IA; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LVOL0,F_LVOL1,F_LVOL5, F_SCUST_NO, F_SCUST_NO2,F_SCUST_AUTH,F_SCUST_AUTH2, F_SDATE0,F_SNAME,F_SNAME2, F_SOPEN_EMP,F_SSTATUS0, F_DAMT2,F_LSERIAL1,F_VSMESS,0); memset(&tCard,0,sizeof(tCard)); memset(&tOldCard,0,sizeof(tOldCard)); memset(&tCustomer,0,sizeof(tCustomer)); memset(&tSpeFee,0,sizeof(tSpeFee)); // memset(&tCardLossInfo,0,sizeof(tCardLossInfo)); memset(&tAccount,0,sizeof(tAccount)); memset(&tradeserial,0,sizeof(tradeserial)); memset(&IA,0,sizeof(IA)); getsysdate(sysdate); getsystime(systime); ret=GetLogicDate(logicdate); //业务日期 if(ret) { *pRetCode=ret; goto L_RETU; } //检查客户信息,判断是否可以发行卡 hi_cutid=rPack->lvol0; //客户号 des2src(tCard.physical_no, rPack->sbank_acc); //物理卡号 trim(h_showcardid); ret=IsExistFreezeCardByCustomId(hi_cutid); if(ret) { *pRetCode = ret; goto L_RETU; } ret=IsExistNoLostCardByCustomId(hi_cutid); if(ret) { *pRetCode = ret; goto L_RETU; } if(strlen(h_showcardid)) { ret=IsExistShowCardNo(h_showcardid); if(ret) { *pRetCode = ret; goto L_RETU; } } ret=IsExistCardByPhyCardNo(tCard.physical_no); if(ret) { *pRetCode = ret; goto L_RETU; } ret=GetLostCardIdByCustomId_TypeId(hi_cutid,CT_NORMAL,&lost_card_id); if(ret) { writelog(LOG_ERR,"customer[%d]tCard type_id[%d]",hi_cutid,CT_NORMAL); *pRetCode = ret; goto L_RETU; } /* ret=DB_t_pif_cardlossinfo_read_by_card_id_and_state_id(lost_card_id, STATE_VALID, &tCardLossInfo); if(ret) { writelog(LOG_ERR,"lost_card_id[%d]",lost_card_id); if(DB_NOTFOUND==ret) *pRetCode = E_CARDNO_NOT_EXIST; else *pRetCode = E_DB_CARD_R; goto L_RETU; } */ ret=get_latest_lost_date_by_card_no(lost_card_id,lost_date); if(ret) { writelog(LOG_ERR,"lost_card_id[%d]",lost_card_id); *pRetCode =ret; goto L_RETU; } //先检查客户的挂失的正式卡是否到了补办日期 ret=GetLostCardValiddate(lost_date,sEndDate); if(ret) { *pRetCode =ret; goto L_RETU; } if(strncmp(sEndDate,sysdate,8)>0) { writelog(LOG_ERR,"lost_normal_card_id[%d]lost_date[%s]end_date[%s]",lost_card_id,lost_date,sEndDate); *pRetCode = E_NORMALCARD_NOT_REACH_ENDDATE; goto L_RETU; } /* //更新卡挂失日期表中该卡状态为无效 ret=UpdateCardLossInfoState(lost_card_id,STATE_VALID,STATE_INVALID); if(ret) { *pRetCode = ret; goto L_RETU; } */ //注销原卡 ret=DB_t_pif_card_read_lock_by_cur_and_card_id(lost_card_id,&tOldCard); if(ret) { writelog(LOG_ERR,"lost_card_id[%d]",lost_card_id); if(DB_NOTFOUND==ret) *pRetCode = E_CARDNO_NOT_EXIST; else *pRetCode = E_DB_CARD_R; goto L_RETU; } if(tOldCard.state_id[CARDSTAT_TYPE_WFAIL] == STATE_TRUE && tOldCard.is_managefee[0] == CARDWFAIL_WATER ) { // 转账的时候写卡失败 write_failed = 1; } else { des2src(tCard.state_id,CARDSTAT_REG); //卡状态 } des2src(tOldCard.state_id,CARDSTAT_LOGOUT); //注销 des2src(tOldCard.end_time,sysdate); //注销日期 ret=DB_t_pif_card_update_lock_by_cur(&tOldCard); if(ret) { writelog(LOG_ERR,"lost_card_id[%d]",lost_card_id); if(DB_NOTFOUND==ret) *pRetCode = E_CARDNO_NOT_EXIST; else *pRetCode = E_DB_CARD_R; goto L_RETU; } DB_t_pif_card_free_lock_by_cur(); if(write_failed) { ret = GetXmlValue(tOldCard.comments,sizeof buf,XML_KEY_SERIALNO2,buf); if(ret) { *pRetCode = ret; goto L_RETU; } AddXmlItemStr(tCard.comments,XML_KEY_SERIALNO2,buf); ret = GetXmlValue(tOldCard.comments,sizeof buf,XML_KEY_OPERATEDATE2,buf); if(ret) { *pRetCode = ret; goto L_RETU; } AddXmlItemStr(tCard.comments,XML_KEY_OPERATEDATE2,buf); ret = GetXmlValue(tOldCard.comments,sizeof buf,XML_KEY_TRADECODE2,buf); if(ret) { *pRetCode = ret; goto L_RETU; } AddXmlItemStr(tCard.comments,XML_KEY_TRADECODE2,buf); tCard.is_managefee[0] = CARDWFAIL_WATER; } ret=DB_t_cif_customer_read_lock_by_cur_and_cut_id(hi_cutid, &tCustomer); if(ret) { writelog(LOG_ERR,"cut_id[%d]",hi_cutid); if(DB_NOTFOUND==ret) *pRetCode= E_CUSTOMER_NOT_EXIST; else *pRetCode= E_DB_CUSTOMER_R; goto L_RETU; } //得到收费类别 if(tCustomer.fee_type<1) { ret=DB_t_pif_spefee_read_by_dept_code_and_cut_type(tCustomer.classdept_no, tCustomer.cut_type,&tSpeFee); if(ret) { if(DB_NOTFOUND==ret) { tCustomer.fee_type=tCustomer.cut_type; } else { DB_t_cif_customer_free_lock_cur(); *pRetCode=E_DB_SPEFEE_R; goto L_RETU; } } else { tCustomer.fee_type=tSpeFee.fee_type; } //更新客户表的收费类别字段 ret=DB_t_cif_customer_update_lock_by_cur(&tCustomer); if(ret) { if(DB_NOTFOUND==ret) *pRetCode= E_CUSTOMER_NOT_EXIST; else *pRetCode= E_DB_CUSTOMER_U; goto L_RETU; } } DB_t_cif_customer_free_lock_cur(); tradeserial.trade_fee =D4U5(rPack->damt0,2); // 准备数据插入卡信息表 memcpy(seed_key,STATIC_SEED_KEY,16); //读种子密钥 if(strlen(tCustomer.can_time)==8) { ret=IsInvalidDateTime(tCustomer.can_time,"YYYYMMDD"); if(ret) { *pRetCode=E_TB_CUSTOMER_ENDTIME; goto L_RETU; } if(strncmp(tCustomer.can_time,sysdate,8)<=0) { *pRetCode=E_TB_CUSTOMER_ENDTIME; goto L_RETU; } des2src(card_endtime,tCustomer.can_time); } else if(strlen(rPack->sdate0)==0) { *pRetCode=E_TB_CUSTOMER_NO_ENDTIME; goto L_RETU; } else { ret=IsInvalidDateTime(rPack->sdate0,"YYYYMMDD"); if(ret) { *pRetCode = E_INPUT_DATE; goto L_RETU; } if(strncmp(rPack->sdate0,sysdate,8)<=0) { *pRetCode=E_INPUT_DATE; goto L_RETU; } des2src(card_endtime,rPack->sdate0); } tradeserial.trade_fee = rPack->damt0; //金额 tradeserial.other_seri_no = 0; //上传端流水号 tradeserial.serial_state = SERISTAT_DEBT; //流水状态 des2src(tradeserial.operate_date,sysdate); //发生日期 des2src(tradeserial.operate_time,systime); //发生时间 des2src(tradeserial.collect_date,sysdate); //采集日期 des2src(tradeserial.collect_time,systime); //采集时间 des2src(tradeserial.enteract_date,logicdate); //处理日期 des2src(tradeserial.enteract_time,systime); //处理时间 tradeserial.maindevice_id = rPack->lvol6; //上传工作站标识 tradeserial.device_id = rPack->lvol7; //采集设备标识 tradeserial.purse_id = PURSE_NO_ONE; //钱包号 tradeserial.customer_id = tCustomer.cut_id; //客户标识 tradeserial.sys_id = 0; //外部系统标识 des2src(tradeserial.oper_code, rPack->scust_limit); //操作员号 len=strlen(tCustomer.man_id) ; if (len >= 6) { strncpy(h_password,&(tCustomer.man_id[len-6]),6); if(h_password[5]>'9'||h_password[5]<'0') h_password[5]='0'; } else { strcpy(h_password,"666666"); } ret = getNewUniqNo(KEYTYPE_CARD_ID,&h_temp_Card_id); //获取最大卡号 if(ret) { *pRetCode = ret; goto L_RETU; } tCard.card_id = (int)h_temp_Card_id; //卡号 des2src(tCard.showid,h_showcardid); //显示卡号 des2src(tCard.is_main,TYPE_YES); //是否为主卡 tCard.type_id = CT_NORMAL; //卡类别 EncodePwd(seed_key,h_password,tCard.password,0); //卡密码 tCard.cosumer_id = hi_cutid; //客户标识 tCard.account_count = ACCOUNT_COUNT_ONE; //卡对应帐户个数 des2src(tCard.begin_time,sysdate); //注册时间 des2src(tCard.end_time, card_endtime); //截至时间 tCard.phytype = PHYTYPE_NO_ONE; //设备物理型号;默认为1 // 插入卡信息 ret = DB_t_pif_card_add(&tCard); if (ret) { if(DB_REPEAT==ret) *pRetCode = E_DB_CARD_E; else *pRetCode = E_DB_CARD_I; goto L_RETU; } //修改帐户表中对应的卡号,类型,状态 ret=DB_t_aif_account_read_lock_by_c0_and_card_id_and_purse_id(lost_card_id,PURSE_NO_ONE,&tAccount); if (ret) { writelog(LOG_ERR,"normalcard_account_id[%s]",lost_card_id); if(DB_NOTFOUND==ret) *pRetCode = E_ACTNO_NOT_EXIST; else *pRetCode = E_DB_ACCOUNT_R; } if(tAccount.current_state!=1) { *pRetCode=E_ACTNO_LOGOUT; goto L_RETU; } tAccount.card_id=tCard.card_id; tAccount.card_balance=tAccount.cur_freebala; //更新卡余额与库余额一致 tAccount.consume_count=0; ret=DB_t_aif_account_update_lock_by_c0(&tAccount); if (ret) { writelog(LOG_ERR,"DB_t_aif_account_update_lock_by_cur4 ret[%d]account_id[%s]",ret,tAccount.account_id); if(DB_NOTFOUND==ret) *pRetCode = E_ACTNO_EXIST; else *pRetCode = E_DB_ACCOUNT_U; } DB_t_aif_account_free_lock_c0(); ret = getNewUniqNo(KEYTYPE_TRADESERIAL,&dSerialNo); //获得最大流水号 if(ret) { *pRetCode=ret; goto L_RETU; } tradeserial.serial_no=(int)dSerialNo; tradeserial.serial_type=TXCODE_CHANGE_CARD; tradeserial.card_id=tCard.card_id; //新卡号 des2src(tradeserial.showid,tCard.showid); //显示卡号 strcpy(IA.sArrInActno[0],tAccount.account_id); //账号 IA.dArrInAmt[0]=tradeserial.trade_fee; //交易金额 IA.iUseCardFlag=USE_CARD_TYPE_ONLINE; //联机交易 IA.dInCardBala=tAccount.cur_freebala; //入卡值 IA.iTxCnt=1; IA.iCardNo=tCard.card_id; IA.iFeeType=tCustomer.fee_type; IA.iArrInFeeSwitch[0]=rPack->lvol0; IA.iArrInFeeSwitch[1]=rPack->lvol1; IA.iArrInFeeSwitch[2]=rPack->lvol2; IA.iArrInFeeSwitch[3]=rPack->lvol3; IA.iArrInFeeSwitch[4]=rPack->lvol4; IA.iArrInFeeSwitch[5]=rPack->lvol5; IA.iArrInFeeSwitch[6]=rPack->lvol6; IA.iArrInFeeSwitch[7]=rPack->lvol7; IA.iArrInFeeSwitch[8]=rPack->lvol8; IA.iArrInFeeSwitch[9]=rPack->lvol9; IA.iArrInFeeSwitch[10]=rPack->lvol10; ret=process(&IA,&tradeserial); if(ret) { writelog(LOG_ERR,"process ret[%d]",ret); *pRetCode=ret; goto L_RETU; } sprintf(out_pack->vsmess,"流水号:%d 卡号:%d ",IA.iSerialNo,IA.iCardNo); for(i=1;i<=IA.iOutTxTypeCnt;i++) { switch(IA.iArrOutTxType[i]) { case TXTYPE_TOLL_DEPOSIT: case TXTYPE_DEDUCT_DEPOSIT: case TXTYPE_RETURN_DEPOSIT: tradeserial.deposit_fee=IA.dArrOutAmt[i]; break; case TXTYPE_PRE_TOLL_BOARD: case TXTYPE_TOLL_BOARD: case TXTYPE_DEDUCT_BOARD: case TXTYPE_RETURN_BOARD: tradeserial.boardfee=IA.dArrOutAmt[i]; break; case TXTYPE_TOLL_CHARGE: tradeserial.in_fee=IA.dArrOutAmt[i]; break; case TXTYPE_TOLL_CARDCOST: tradeserial.cost_fee=IA.dArrOutAmt[i]; break; default: break; } if(amtcmp(IA.dArrOutAmt[i],0)!=0) { sprintf(sMsg,"%s:%.2lf元 ",IA.sArrOutTxName[i],IA.dArrOutAmt[i]); strcat(out_pack->vsmess,sMsg); } } sprintf(sMsg,"卡当前余额:%.2lf元",tradeserial.out_balance); strcat(out_pack->vsmess,sMsg); writelog(LOG_DEBUG,out_pack->vsmess); ret = DB_t_tif_tradeserial_add(&tradeserial); if (ret) { writelog(LOG_ERR,"ret[%d]",ret); if(DB_REPEAT==ret) *pRetCode = E_DB_TRADESERIAL_E; else *pRetCode = E_DB_TRADESERIAL_I; goto L_RETU; } if(amtcmp(tradeserial.out_balance,0)<0) { *pRetCode=E_ENTER_ACCOUNT; goto L_RETU; } //检查金额是否超过最大额度 ret=GetParameter(GLOBE_MAXCARDBALANCE,sMaxCardBalance); if(ret) { *pRetCode=ret; goto L_RETU; } dMaxCardBalance=atof(sMaxCardBalance); if(amtcmp(tradeserial.out_balance,dMaxCardBalance)>0) { writelog(LOG_ERR,"tradeserial.out_balance[%lf]",tradeserial.out_balance); *pRetCode=E_AMT_EXCEED_MAX; goto L_RETU; } // 增加发行新卡时的门禁名单表检查 ret = CheckNewCardHook(&tCustomer, tCard.card_id); if(ret) { *pRetCode = ret; goto L_RETU; } //返回卡号\密码\显示卡号\客户类型\图书证号\有效截至日期 out_pack->lvol0 = (int)h_temp_Card_id; //交易卡号 out_pack->lvol1 = tCustomer.cut_type; //客户类别 out_pack->lvol5 = tCustomer.fee_type; //收费类别 des2src(out_pack->scust_no,h_showcardid); //显示卡号 des2src(out_pack->scust_no2,tCustomer.classdept_no); //部门号 des2src(out_pack->scust_auth,tCustomer.stuemp_no); //学号 des2src(out_pack->scust_auth2,tCustomer.man_id); //身份证号 des2src(out_pack->sname,tCustomer.cut_name); //客户姓名 des2src(out_pack->sname2,tCustomer.lib_cardid); //图书证号 des2src(out_pack->sstatus0,tCustomer.sex); //性别 des2src(out_pack->sopen_emp,h_password); //卡密码 des2src(out_pack->sdate0,card_endtime); //有效截至日期 out_pack->damt2=tradeserial.out_balance; //出卡值 out_pack->lserial1=tradeserial.serial_no; //流水号 // add by 汤成 2005-8-8 // 增加向名单表写入记录 ret = InsertToBlkList((int)h_temp_Card_id,CHCARD_BLACKLIST); if(ret) { *pRetCode = ret; goto L_RETU; } PutRow(handle,out_pack,pRetCode,szMsg); return 0; L_RETU: return -1; }
int F847116(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int hi_cutid = 0; //客户ID int hi_cuttype = 0; //客户类型 int i=0; int ret = 0; int len = 0; char h_showcardid[11] = ""; //显示卡号 char h_password[7] = ""; //卡密码 double h_temp_Card_id = 0; //卡号 char seed_key[17] = ""; //种子密钥 char card_endtime[27 + 1] = ""; //卡的有效截至日期 char logicdate[11]=""; char sysdate[11]=""; char systime[9]=""; char sMsg[256]=""; char sMaxCardBalance[20]=""; double dMaxCardBalance=0; T_t_cif_customer tCustomer; T_t_pif_spefee tSpeFee; T_t_pif_card tCard; T_t_aif_account tAccount; T_t_tif_tradeserial tradeserial; InAcc IA; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LVOL0,F_LVOL1,F_LVOL5, F_SCUST_NO, F_SCUST_NO2,F_SCUST_AUTH,F_SCUST_AUTH2, F_SDATE0,F_SNAME,F_SNAME2, F_SOPEN_EMP,F_SSTATUS0, F_DAMT2,F_DAMT3,F_LSERIAL1,F_VSMESS,0); memset(&IA,0,sizeof(IA)); memset(&tCustomer,0,sizeof(tCustomer)); memset(&tCard, 0, sizeof(tCard)); memset(&tAccount,0,sizeof(tAccount)); memset(&tradeserial,0,sizeof(tradeserial)); memset(&tSpeFee,0,sizeof(tSpeFee)); #ifdef DEBUG writelog(LOG_DEBUG,"rPack->damt0[%lf]",rPack->damt0); writelog(LOG_DEBUG,"rPack->scust_auth2[%s]",rPack->scust_auth2); #endif hi_cutid = rPack->lvol0; //客户ID hi_cuttype = rPack->lvol3; //客户类别 tradeserial.trade_fee=rPack->damt0; //发生额 des2src(h_showcardid,rPack->scust_no); //显示卡号 getsysdate(sysdate); getsystime(systime); ret=GetLogicDate(logicdate); //业务日期 if(ret) { *pRetCode=ret; goto L_RETU; } ret=IsExistShowCardNo(h_showcardid); if(ret) { *pRetCode = ret; goto L_RETU; } // 检查客户信息,判断是否可以发行临时卡 ret = IsExistNoLostCardByCustomId(hi_cutid); if (ret) { writelog(LOG_ERR,"hi_cutid[%d]",hi_cutid); *pRetCode = ret; goto L_RETU; } des2src(tCard.physical_no, rPack->sbank_acc); //物理卡号 ret=IsExistCardByPhyCardNo(tCard.physical_no); //物理卡号 if(ret) { writelog(LOG_ERR,"physical_no[%s]",tCard.physical_no); *pRetCode = ret; goto L_RETU; } ret=DB_t_cif_customer_read_lock_by_cur_and_cut_id(hi_cutid, &tCustomer); if(ret) { writelog(LOG_ERR,"cut_id[%d]",hi_cutid); if(DB_NOTFOUND==ret) *pRetCode= E_CUSTOMER_NOT_EXIST; else *pRetCode= E_DB_CUSTOMER_R; goto L_RETU; } //得到收费类别 if(tCustomer.fee_type<1) { ret=DB_t_pif_spefee_read_by_dept_code_and_cut_type(tCustomer.classdept_no, tCustomer.cut_type,&tSpeFee); if(ret) { if(DB_NOTFOUND==ret) { tCustomer.fee_type=tCustomer.cut_type; } else { DB_t_cif_customer_free_lock_cur(); *pRetCode=E_DB_SPEFEE_R; goto L_RETU; } } else { tCustomer.fee_type=tSpeFee.fee_type; } //更新客户表的收费类别字段 ret=DB_t_cif_customer_update_lock_by_cur(&tCustomer); if(ret) { if(DB_NOTFOUND==ret) *pRetCode= E_CUSTOMER_NOT_EXIST; else *pRetCode= E_DB_CUSTOMER_U; goto L_RETU; } } DB_t_cif_customer_free_lock_cur(); //检查金额是否超过最大额度 ret=GetParameter(GLOBE_MAXCARDBALANCE,sMaxCardBalance); if(ret) { *pRetCode=ret; goto L_RETU; } dMaxCardBalance=atof(sMaxCardBalance); if(amtcmp(tradeserial.trade_fee,dMaxCardBalance)>0) { writelog(LOG_ERR,"tradeserial.trade_fee[%lf]",tradeserial.trade_fee); *pRetCode=E_AMT_EXCEED_MAX; goto L_RETU; } // 准备数据插入卡信息表 memcpy(seed_key,STATIC_SEED_KEY,sizeof(seed_key)); //读种子密钥 // 默认密码, 初始取身份证的后6位, 没有身份证号用666666. trim(rPack->sname2); len=strlen(rPack->sname2) ; if (len >= 6) { strncpy(h_password,&(rPack->sname2[len-6]),6); if(h_password[5]>'9'||h_password[5]<'0') h_password[5]='0'; } else { strcpy(h_password,"666666"); } ret = getNewUniqNo(KEYTYPE_CARD_ID,&h_temp_Card_id); //获取最大卡号 if(ret) { *pRetCode = ret; writelog(LOG_ERR,"ret[%d]",ret); goto L_RETU; } tCard.card_id = (int)h_temp_Card_id; //卡号 des2src(tCard.showid,h_showcardid); //显示卡号 des2src(tCard.is_main,TYPE_YES); //是否为主卡 des2src(tCard.state_id,CARDSTAT_REG); //卡状态 tCard.type_id = CT_TEMP; //卡类别 EncodePwd(seed_key,h_password,tCard.password,0); //卡密码 tCard.cosumer_id = hi_cutid; //客户标识 tCard.account_count = ACCOUNT_COUNT_ONE; //卡对应帐户个数 des2src(tCard.begin_time,logicdate); //注册时间 ret = GetTempCardValiddate(GLOBE_TMPCARDVALIDDATE,logicdate,card_endtime); //计算卡的有效期 if (ret) { *pRetCode = ret; goto L_RETU; } des2src(tCard.end_time, card_endtime); //截至时间 tCard.phytype = PHYTYPE_NO_ONE; //设备物理型号;默认为1 // 插入卡信息 ret = DB_t_pif_card_add(&tCard); if (ret) { if(DB_REPEAT==ret) *pRetCode = E_DB_CARD_E; else *pRetCode = E_DB_CARD_I; goto L_RETU; } // 准备数据插入帐户信息表 ret = getNewActno(tAccount.account_id); //获得最大帐号 if (ret) { *pRetCode = ret; goto L_RETU; } des2src(tAccount.open_date,logicdate); //开户时间 des2src(tAccount.open_time,systime); tAccount.current_state = ACCOUNTSTAT_REGIST; //当前状态 tAccount.act_type = ACCTYPE_PERMAIN; //帐号类别 tAccount.customer_id = rPack->lvol0; //客户号 des2src(tAccount.cut_name,rPack->sname); //客户名称 tAccount.cut_type = hi_cuttype; //客户类别 des2src(tAccount.stuemp_no,rPack->scust_auth2); //客户学号或员工号 tAccount.card_id = (int)h_temp_Card_id; //关联卡号 tAccount.purse_id = PURSE_NO_ONE; //关联卡钱包号 tAccount.card_type = CT_TEMP; //卡类别 des2src(tAccount.subno,SUBJECT_INDIVIDUALSAVING); //所属科目 des2src(tAccount.isautotra,TYPE_NO); //是否自动转帐 // 插入帐户信息表 ret = DB_t_aif_account_add(&tAccount); if (ret) { if(DB_REPEAT==ret) *pRetCode = E_DB_ACCOUNT_E; else *pRetCode = E_DB_ACCOUNT_I; goto L_RETU; } // 准备数据插入交易流水表 double h_temp_Serial_no = 0; ret = getNewUniqNo(KEYTYPE_TRADESERIAL,&h_temp_Serial_no); //获得最大流水号 if(ret) { *pRetCode = ret; goto L_RETU; } tradeserial.serial_no = (int)h_temp_Serial_no; //流水号 tradeserial.other_seri_no = 0; //上传端流水号 tradeserial.serial_type = TXCODE_TEMPCARD_OPEN; //交易代码 tradeserial.serial_state = SERISTAT_DEBT; //流水状态 des2src(tradeserial.operate_date,sysdate); //发生日期 des2src(tradeserial.operate_time,systime); //发生时间 des2src(tradeserial.collect_date,sysdate); //采集日期 des2src(tradeserial.collect_time,systime); //采集时间 des2src(tradeserial.enteract_date,logicdate); //处理日期 des2src(tradeserial.enteract_time,systime); //处理时间 tradeserial.maindevice_id = rPack->lvol6; //上传工作站标识 tradeserial.device_id = rPack->lvol7; //采集设备标识 tradeserial.card_id = tCard.card_id; //卡号 des2src(tradeserial.showid,tCard.showid); //显示卡号 tradeserial.purse_id = PURSE_NO_ONE; //钱包号 tradeserial.customer_id = rPack->lvol0; //客户标识 des2src(tradeserial.oper_code,rPack->scust_limit); //操作员代码 tradeserial.sys_id = 0; //外部系统标识 tradeserial.trade_count=1; //当前卡交易次数 des2src(IA.sArrInActno[0],tAccount.account_id); //帐户 IA.iCardNo=tCard.card_id; IA.iFeeType=tCustomer.fee_type; IA.dArrInAmt[0]=tradeserial.trade_fee; IA.iArrInFeeSwitch[0]=rPack->lvol0; IA.iArrInFeeSwitch[1]=rPack->lvol1; IA.iArrInFeeSwitch[2]=rPack->lvol2; IA.iArrInFeeSwitch[3]=rPack->lvol3; IA.iArrInFeeSwitch[4]=rPack->lvol4; IA.iArrInFeeSwitch[5]=rPack->lvol5; IA.iArrInFeeSwitch[6]=rPack->lvol6; IA.iArrInFeeSwitch[7]=rPack->lvol7; IA.iArrInFeeSwitch[8]=rPack->lvol8; IA.iArrInFeeSwitch[9]=rPack->lvol9; IA.iArrInFeeSwitch[10]=rPack->lvol10; // 调用入账子模块 ret=process(&IA,&tradeserial); if(ret) { *pRetCode=ret; writelog(LOG_ERR,"process ret[%d]",ret); goto L_RETU; } sprintf(out_pack->vsmess,"流水号:%d 卡号:%d ",IA.iSerialNo,IA.iCardNo); for(i=1;i<=IA.iOutTxTypeCnt;i++) { switch(IA.iArrOutTxType[i]) { case TXTYPE_TOLL_DEPOSIT: case TXTYPE_DEDUCT_DEPOSIT: case TXTYPE_RETURN_DEPOSIT: tradeserial.deposit_fee=IA.dArrOutAmt[i]; break; case TXTYPE_PRE_TOLL_BOARD: case TXTYPE_TOLL_BOARD: case TXTYPE_DEDUCT_BOARD: case TXTYPE_RETURN_BOARD: tradeserial.boardfee=IA.dArrOutAmt[i]; break; case TXTYPE_TOLL_CHARGE: tradeserial.in_fee=IA.dArrOutAmt[i]; break; case TXTYPE_TOLL_CARDCOST: tradeserial.cost_fee=IA.dArrOutAmt[i]; break; default: break; } if(amtcmp(IA.dArrOutAmt[i],0)!=0) { sprintf(sMsg,"%s:%.2lf元 ",IA.sArrOutTxName[i],IA.dArrOutAmt[i]); strcat(out_pack->vsmess,sMsg); } } sprintf(sMsg,"卡当前余额:%.2lf元",tradeserial.out_balance); strcat(out_pack->vsmess,sMsg); writelog(LOG_DEBUG,out_pack->vsmess); // 插入交易流水表 ret = DB_t_tif_tradeserial_add(&tradeserial); if (ret) { if(DB_REPEAT==ret) *pRetCode = E_DB_TRADESERIAL_E; else *pRetCode = E_DB_TRADESERIAL_I; goto L_RETU; } if(amtcmp(tradeserial.out_balance,0)<0) { *pRetCode=E_ENTER_ACCOUNT; goto L_RETU; } // 返回卡号\密码\显示卡号\客户类型\图书证号\有效截至日期 out_pack->lvol0 = (int)h_temp_Card_id; //交易卡号 out_pack->lvol1 = tCustomer.cut_type; //客户类别 out_pack->lvol5 = tCustomer.fee_type; //收费类别 des2src(out_pack->scust_no,h_showcardid); //显示卡号 des2src(out_pack->scust_no2,tCustomer.classdept_no); //部门号 des2src(out_pack->scust_auth,tCustomer.stuemp_no); //学号 des2src(out_pack->scust_auth2,tCustomer.man_id); //身份证号 des2src(out_pack->sname,tCustomer.cut_name); //客户姓名 des2src(out_pack->sname2,tCustomer.lib_cardid); //图书证号 des2src(out_pack->sstatus0,tCustomer.sex); //性别 des2src(out_pack->sopen_emp,h_password); //卡密码 des2src(out_pack->sdate0,card_endtime); //有效截至日期 out_pack->damt2=tradeserial.out_balance; //出卡值 out_pack->damt3=tradeserial.boardfee; //搭伙费 out_pack->lserial1=tradeserial.serial_no; //流水号 // add by 汤成 2005-8-8 // 增加向名单表写入记录 ret = InsertToBlkList((int)h_temp_Card_id,CHCARD_BLACKLIST); if(ret) { *pRetCode = ret; goto L_RETU; } PutRow(handle,out_pack,pRetCode,szMsg); return 0; L_RETU: return -1; }
/** SamplesToCoefficients.<br> Implement the algorithm that converts the image samples into B-spline coefficients. This efficient procedure essentially relies on the three papers cited above; data are processed in-place. Even though this algorithm is robust with respect to quantization, we advocate the use of a floating-point format for the data. @param Image Input / Output image (in-place processing) @param Width Width of the image @param Height Height of the image @param spline_degree Degree of the spline model @return Returns true if success, false otherwise */ static bool SamplesToCoefficients(double *Image, long Width, long Height, long spline_degree) { double *Line; double Pole[2]; long NbPoles; long x, y; // recover the poles from a lookup table switch (spline_degree) { case 2L: NbPoles = 1L; Pole[0] = sqrt(8.0) - 3.0; break; case 3L: NbPoles = 1L; Pole[0] = sqrt(3.0) - 2.0; break; case 4L: NbPoles = 2L; Pole[0] = sqrt(664.0 - sqrt(438976.0)) + sqrt(304.0) - 19.0; Pole[1] = sqrt(664.0 + sqrt(438976.0)) - sqrt(304.0) - 19.0; break; case 5L: NbPoles = 2L; Pole[0] = sqrt(135.0 / 2.0 - sqrt(17745.0 / 4.0)) + sqrt(105.0 / 4.0) - 13.0 / 2.0; Pole[1] = sqrt(135.0 / 2.0 + sqrt(17745.0 / 4.0)) - sqrt(105.0 / 4.0) - 13.0 / 2.0; break; default: // Invalid spline degree return false; } // convert the image samples into interpolation coefficients // in-place separable process, along x Line = (double *)malloc(Width * sizeof(double)); if (Line == NULL) { // Row allocation failed return false; } for (y = 0L; y < Height; y++) { GetRow(Image, y, Line, Width); ConvertToInterpolationCoefficients(Line, Width, Pole, NbPoles, DBL_EPSILON); PutRow(Image, y, Line, Width); } free(Line); // in-place separable process, along y Line = (double *)malloc(Height * sizeof(double)); if (Line == NULL) { // Column allocation failed return false; } for (x = 0L; x < Width; x++) { GetColumn(Image, Width, x, Line, Height); ConvertToInterpolationCoefficients(Line, Height, Pole, NbPoles, DBL_EPSILON); PutColumn(Image, Width, x, Line, Height); } free(Line); return true; }
int F930008(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg) { int ret = 0; int cnt=0; int msgid=0; T_t_msglist tMsgList; T_t_device tDevice; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_VSVARSTR0,0); memset(&tMsgList,0,sizeof(tMsgList)); memset(&tDevice,0,sizeof tDevice); if(strlen(in_pack->sdate0)==0) { *pRetCode=E_DEVPHYID_NULL; goto L_RETU; } if((ret = get_devinfo_by_phyid(in_pack->sdate0,&tDevice))) { *pRetCode = ret; goto L_RETU; } tMsgList.deviceid = tDevice.deviceid; tMsgList.funcno = 930008; tMsgList.msglevel = 2; ret=AddMsgLst(&tMsgList); if(ret) { *pRetCode=ret; writelog(LOG_ERR,"AddMsgLst err[%d]",ret); goto L_RETU; } if(iRequest!=tMsgList.funcno) return 0; ret=db_commit(); if(ret) { writelog(LOG_ERR,"db_commit ret[%d]",ret); *pRetCode=E_DB_COMMIT; goto L_RETU; } msgid=tMsgList.msgid; des2src(out_pack->sdate0,in_pack->sdate0); for(cnt=0;(cnt<10)&&(tMsgList.errcode!=0);cnt++) { sleep(1); memset(&tMsgList,0,sizeof(tMsgList)); ret=DB_t_msglist_read_by_msgid(msgid, &tMsgList); if(ret) { writelog(LOG_ERR,"DB_t_msglist_read_by_msgid err[%d]",ret); *pRetCode=E_DB_MSGLIST_R; goto L_RETU; } } switch(tMsgList.errcode) { case 0: //成功 des2src(out_pack->vsvarstr0,"成功"); break; case 9999: //交易未处理 des2src(out_pack->vsvarstr0,"前置机无应答"); break; default: //交易已经处理,但结果是失败 des2src(out_pack->vsvarstr0,tMsgList.errmsg); break; } PutRow(handle,out_pack,pRetCode,szMsg); return 0; L_RETU: return -1; }
int F950032(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { // 设备物理ID char(20) sphon3 // 机号 int lvol0 // POS机日期 char(8) sdate0 // POS机时间 char(6) stime0 // 子系统ID int lcert_code // 动态密钥 char(20) scust_limit2 // // 参数 类型 CPACK字段 // 商户号 int lvol0 // 系统日期 char(8) sdate0 // 系统时间 char(6) stime0 // POS机工作开始时间 char(6) stime1 // POS机工作结束时间 char(6) stime2 // 设备类型 char(4) semp // 设备工作密钥 char(16) scert_addr int ret=0; ST_CPACK aPack; ST_PACK* out_pack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LVOL0,F_SDATE0,F_STIME0,F_STIME1,F_STIME2,F_SEMP,F_SCERT_ADDR,0); char devphyid[31]=""; char sysdate[9]=""; char systime[7]=""; ret=db_getsysdatetime(sysdate,systime); if(ret) { writelog(LOG_ERR,"db_getsysdatetime err=%d",ret); return ERRIF_DATABASE_DIS; } int sysid = rPack->lcert_code; int deviceid = rPack->lwithdraw_flag; int db_deviceid=0; des2src(devphyid,rPack->sphone3); writelog(LOG_INFO,"devphyid %s login start",devphyid); ret = ChkDynKey(sysid,rPack->scust_limit2); if(ret) { writelog(LOG_ERR,"chk_dyn_key sysid[%d] err=%d",sysid,ret); return ret; } ret=GetDeviceidByDevphyid(devphyid,&db_deviceid); if(ret) { return ret; } if(deviceid!=db_deviceid) { return ERRIF_POS_TERMID; } char devstatus[2]=""; devstatus[0]=DEVRUNSTATUS_ONLINE; ret=UpdDevRunstatusByDeviceid(deviceid,devstatus); if(ret) return ret; int shopid=0; ret=GetShopidByDeviceid(deviceid,sysdate,systime,&shopid); if(ret) { return ret; } ret=GetDevtypecodeByDeviceid(deviceid,out_pack->semp); if(ret) return ret; out_pack->lvol0=shopid; strcpy(out_pack->sdate0,sysdate+2); strcpy(out_pack->stime0,systime); ret=GetSysParaVal(GLOBLE_SYSPARA_STATIC_KEY,out_pack->scert_addr); if(ret) { writelog(LOG_ERR,"get static key err=%d",ret); return ERRIF_DATABASE_QRY; } //签到时查询流水号控制表,如果没有该设备则添加一条 T_t_seqnoctl tSeqnoctl; memset(&tSeqnoctl,0,sizeof(tSeqnoctl)); ret=DB_t_seqnoctl_read_by_termid(deviceid,&tSeqnoctl); if(ret) { if(DB_NOTFOUND==ret) { tSeqnoctl.termid=deviceid; tSeqnoctl.termseqno=0; tSeqnoctl.accdate=atoi(sysdate); ret=DB_t_seqnoctl_add(&tSeqnoctl); if(ret) { if(DB_REPEAT==ret) return E_DB_SEQNOCTL_E; else return E_DB_SEQNOCTL_I; } return 0; } else return E_DB_SEQNOCTL_R; } PutRow(handle,out_pack,pRetCode,szMsg); writelog(LOG_INFO,"devphyid %s login success",devphyid); return 0; }
int F846332(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; CAccTrans *pAccTrans=CAccTrans::getInstance(); des2src(pAccTrans->trans.opercode,rPack->semp); pAccTrans->trans.transcode=TC_EACCCLOSE; ret=pAccTrans->InitTrans(); if(ret) return ret; TRANS& trans=pAccTrans->trans; ST_CPACK aPack; ST_PACK *outPack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); des2src(trans.eaccno,rPack->sbank_acc); if(!strlen(trans.eaccno)) return E_INPUTNULL_ACCNO; //去帐户信息 T_t_netacc eaccount; memset(&eaccount,0,sizeof(eaccount)); ret=DB_t_netacc_read_by_accno(trans.eaccno,&eaccount); if(ret) { writelog(LOG_ERR,"accno[%s]",trans.eaccno); if(DB_NOTFOUND==ret) return E_NOTEXIST_EACCNO; else return E_DB_ACCOUNT_R; } if(eaccount.status[0]!=STATUS_NORMAL) { return E_CARDACC_LOGOUT; } char seedkey[33]=""; char inpwd_crypt[65]=""; char inpwd_plain[65]=""; char dbpwd_plain[65]=""; des2src(inpwd_crypt,rPack->snote2); if(!strlen(inpwd_crypt)) return E_PWD_NULL; ret=GetSysParaVal(GLOBLE_SYSPARA_STATIC_KEY,seedkey); if(ret) return ret; ret=decrypt_elec_card_pwd(0,seedkey,inpwd_crypt,inpwd_plain); if(ret) return E_EACCPWD; ret=decrypt_elec_card_pwd(0,seedkey,eaccount.accpwd,dbpwd_plain); if(ret) return E_PWD_DECRYPT; if(strcmp(inpwd_plain,dbpwd_plain)!=0) return E_EACCPWD; //检查客户 T_t_customer tCustomer; memset(&tCustomer,0,sizeof(tCustomer)); ret=doCustomer(eaccount.custid,tCustomer); if(ret) return ret; // 创建账号 pAccTrans->trans.custid=eaccount.custid; pAccTrans->trans.inputamt=eaccount.balance; trans.unusedamt = trans.inputamt; strcpy(pAccTrans->trans.eaccno,eaccount.accno); ret=pAccTrans->doTrans(); if(ret) return ret; //注销帐户 ret=doAccount(trans); if(ret) return ret; SetCol(handle,F_LVOL0,F_LVOL8,F_SDATE3,F_SEMP,F_LWITHDRAW_FLAG,F_LSERIAL1,F_VSMESS,0); des2src(outPack->sdate3,pAccTrans->trans.accdate); des2src(outPack->semp,trans.opercode); outPack->lwithdraw_flag=trans.termid; outPack->lserial1=trans.termseqno; sprintf(outPack->vsmess,"客户[%s]电子钱包销户成功",eaccount.accname); strcat(outPack->vsmess,pAccTrans->remark.c_str()); des2src(trans.remark,outPack->vsmess); PutRow(handle,outPack,pRetCode,szMsg); return 0; }
int F930007(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg) { int ret = 0; int cnt=0; int mesid=0; T_t_tif_meslist tMesList; T_t_pif_device tDevice; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_VSVARSTR0,0); memset(&tMesList,0,sizeof(tMesList)); memset(&tDevice,0,sizeof(tDevice)); des2src(tMesList.devphy999_id, in_pack->sdate0); trim(tMesList.devphy999_id); if(strlen(tMesList.devphy999_id)==0) { *pRetCode=E_DEVPHYID_NULL; goto L_RETU; } ret=get_devinfo_by_phyid(tMesList.devphy999_id,&tDevice); if(ret) { *pRetCode=ret; writelog(LOG_ERR,"get_devinfo_by_phyid err[%d]",ret); goto L_RETU; } AddXmlItemInt(tMesList.incontent, XML_KEY_DEV999_NO, tDevice.dev999_no); //机号 AddXmlItemStr(tMesList.incontent, XML_KEY_DEV999_ID, tDevice.dev999_id); //注册号 AddXmlItemInt(tMesList.incontent, XML_KEY_BAUDRATE, tDevice.baudrate); //波特率 AddXmlItemStr(tMesList.incontent, XML_KEY_SYSPWD, tDevice.syspwd); //系统员密码 AddXmlItemStr(tMesList.incontent, XML_KEY_ADMPWD,tDevice.admpwd); //管理员密码 AddXmlItemInt(tMesList.incontent, XML_KEY_PWDONOFF,tDevice.pwdonoff); //密码开关 AddXmlItemStr(tMesList.incontent, XML_KEY_CARDSTR, "100"); //卡片结构 AddXmlItemInt(tMesList.incontent, XML_KEY_CARDUSENUM,tDevice.cardusenum); //卡的最大使用次数\允许最大消费次数 AddXmlItemInt(tMesList.incontent, XML_KEY_MAXDEPOSIT, tDevice.maxdeposit); //钱包最高存款限额 AddXmlItemInt(tMesList.incontent, XML_KEY_MINDEPOSIT, tDevice.mindeposit); //钱包最低剩余款限额 AddXmlItemInt(tMesList.incontent, XML_KEY_RATION, tDevice.ration); //定值收费方式使用的定值额\定值金额 AddXmlItemStr(tMesList.incontent, XML_KEY_PUSERNO, tDevice.puserno); //钱包代码\钱包号 AddXmlItemInt(tMesList.incontent, XML_KEY_MAXTRADE, tDevice.maxtrade); //每次交易最高额\大额消费限额 AddXmlItemStr(tMesList.incontent, XML_KEY_VCARDSET, tDevice.cardtype); //终端机适用用户卡类别 AddXmlItemStr(tMesList.incontent, XML_KEY_FUNONOFF, tDevice.funonoff); //收费机增强功能开关 AddXmlItemInt(tMesList.incontent, XML_KEY_FEETYPE, tDevice.feetype); //收费方式 tMesList.funid = 930007; tMesList.level = 2; ret=AddMsgLst(&tMesList); if(ret) { *pRetCode=ret; writelog(LOG_ERR,"AddMsgLst err[%d]",ret); goto L_RETU; } if(iRequest!=tMesList.funid) return 0; ret=db_commit(); if(ret) { writelog(LOG_ERR,"db_commit ret[%d]",ret); *pRetCode=E_DB_COMMIT; goto L_RETU; } mesid=tMesList.mesid; des2src(out_pack->sdate0,in_pack->sdate0); for(cnt=0;(cnt<10)&&(tMesList.ecode!=0);cnt++) { sleep(1); memset(&tMesList,0,sizeof(tMesList)); ret=DB_t_tif_meslist_read_by_mesid(mesid, &tMesList); if(ret) { writelog(LOG_ERR,"DB_t_tif_meslist_read_by_mesid err[%d]",ret); *pRetCode=E_DB_MESLIST_R; goto L_RETU; } } switch(tMesList.ecode) { case 0: //成功 des2src(out_pack->vsvarstr0,"成功"); break; case 9999: //交易未处理 des2src(out_pack->vsvarstr0,"前置机无应答"); break; default: //交易已经处理,但结果是失败 des2src(out_pack->vsvarstr0,tMesList.emsg); break; } PutRow(handle,out_pack,pRetCode,szMsg); return 0; L_RETU: return -1; }
int F900077(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg) { int ret=0; char tradecode[6+1]=""; // 此处检查银行登陆状态,可能过于严格,可转移到switch中需要银行登陆的功能中 if(!BANK_LOGIN) { *pRetCode=E_TRANS_BANK_NETERR; return *pRetCode; } INNER_TRANS_REQUEST from_pos,to_pos; //BANK_TRANS_REQUEST from_bank; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); // 用于根据请求包整理本CPACK包的头清空包头位图和包体中的数据 ResetNormalCPack(&aPack,0,1); //初始化交换结构 memset(&from_pos,0,sizeof(from_pos)); //从输入cpack中提取数据,填充到通用交换数据结构中 memcpy(from_pos.TradeCode,in_pack->sclose_emp,sizeof(from_pos.TradeCode)); //交易代码 memcpy(from_pos.TransMoney,in_pack->sorder0,sizeof(from_pos.TransMoney)); //交易金额 memcpy(from_pos.ExtraMoney,in_pack->sorder1,sizeof(from_pos.ExtraMoney)); //附加交易金额 Strncpy_t(from_pos.AccountMoney,in_pack->sserial1,sizeof(from_pos.AccountMoney)); //校园卡帐户金额 from_pos.SendNo=in_pack->lvol0; //发起方流水号 from_pos.RecvNo=in_pack->lvol1; //接受方流水号 memcpy(from_pos.TradeDate,in_pack->sdate0,sizeof(from_pos.TradeDate)); //交易日期 YYYYMMDD memcpy(from_pos.TradeTime,in_pack->stime0,sizeof(from_pos.TradeTime)); //交易时间 HHMMSS memcpy(from_pos.BankDate,in_pack->sdate1,sizeof(from_pos.BankDate)); //银行处理日期 memcpy(from_pos.BankTime,in_pack->stime1,sizeof(from_pos.BankTime)); //银行处理时间 memcpy(from_pos.Balance,in_pack->scust_no,sizeof(from_pos.Balance)); //银行卡余额 memcpy(from_pos.RetCode,in_pack->schange_emp,sizeof(from_pos.RetCode)); //交易结果 memcpy(from_pos.CardNo,in_pack->sserial0,sizeof(from_pos.CardNo)); //校园卡卡号 from_pos.Notecase=in_pack->lvol2; //校园卡对应钱包号 memcpy(from_pos.BankCardNo,in_pack->scust_auth,sizeof(from_pos.BankCardNo)); //银行卡号 from_pos.MngFeeFlag=atoi(in_pack->sstatus1); //手续费标志 memcpy(from_pos.AccountPwd,in_pack->semp_pwd,sizeof(from_pos.AccountPwd)); //校园账户密码 memcpy(from_pos.AccountNewPwd,in_pack->semp_pwd2,sizeof(from_pos.AccountNewPwd)); //校园账户新密码 memcpy(from_pos.BankCardPwd,in_pack->sstation0,sizeof(from_pos.BankCardPwd)); //银行账户密码 memcpy(from_pos.BankCardNewPwd,in_pack->sstation1,sizeof(from_pos.BankCardNewPwd)); //银行账户新密码 memcpy(from_pos.TerminalId,in_pack->sorder2,sizeof(from_pos.TerminalId)); //终端编号 //判断交易代码,进行相应处理 //switch(241031) //int temp=atoi(from_pos.TradeCode); //printf("this is test record:atoi(from_pos.TradeCode)=[%d]\n",temp); SetCol(handle,0); SetCol(handle,F_SCLOSE_EMP,F_SORDER0,F_SORDER1,F_SSERIAL1,F_LVOL0,F_LVOL1,F_SDATE0,F_STIME0,F_SDATE1,F_STIME1,F_SCUST_NO,F_SCHANGE_EMP,F_SSERIAL0,F_LVOL2,F_SCUST_AUTH,F_SSTATUS1,F_SEMP_PWD,F_SEMP_PWD2,F_SSTATION0,F_SSTATION1,F_SORDER2,0); memcpy(tradecode,from_pos.TradeCode,sizeof(from_pos.TradeCode)); tradecode[6]=0; writelog(LOG_INFO,"Trade start,trade code=[%6.6s],card_id=[%s],bankcardno=[%s],TerminalId=[%s]!",tradecode,from_pos.CardNo,from_pos.BankCardNo,from_pos.TerminalId); switch(atoi(tradecode)) { case TRADE_INNER_QUERYBANK: ret=Pos_QueryBank(&from_pos); if(ret) { *pRetCode=ret; goto L_RETU; } memcpy(&to_pos,&from_pos,sizeof(to_pos)); break; case TRADE_INNER_TRANS: ret=Pos_Transfer(&from_pos); if(ret) { *pRetCode=ret; goto L_RETU; } memcpy(&to_pos,&from_pos,sizeof(to_pos)); break; case TRADE_INNER_FEE: ret=Pos_Fee(&from_pos); if(ret) { *pRetCode=ret; goto L_RETU; } memcpy(&to_pos,&from_pos,sizeof(to_pos)); break; case TRADE_INNER_ADDRELATION: ret=Pos_AddRelation(&from_pos); if(ret) { *pRetCode=ret; goto L_RETU; } memcpy(&to_pos,&from_pos,sizeof(to_pos)); break; case TRADE_INNER_DELRELATION: ret=Pos_DelRelation(&from_pos); if(ret) { *pRetCode=ret; goto L_RETU; } memcpy(&to_pos,&from_pos,sizeof(to_pos)); break; case TRADE_INNER_POSLOGIN: ret=Pos_Login(&from_pos); if(ret) { *pRetCode=ret; goto L_RETU; } memcpy(&to_pos,&from_pos,sizeof(to_pos)); break; case TRADE_INNER_QUERYINNER: ret=Pos_QuerySchool(&from_pos); if(ret) { *pRetCode=ret; goto L_RETU; } memcpy(&to_pos,&from_pos,sizeof(to_pos)); break; case TRADE_INNER_CHANGEPWD: ret=Pos_ChangePwd(&from_pos); if(ret) { *pRetCode=ret; goto L_RETU; } memcpy(&to_pos,&from_pos,sizeof(to_pos)); break; case TRADE_INNER_LOST: ret=Pos_LostCard(&from_pos); if(ret) { *pRetCode=ret; goto L_RETU; } memcpy(&to_pos,&from_pos,sizeof(to_pos)); break; case TRADE_INNER_UNLOST: ret=Pos_UnlostCard(&from_pos); if(ret) { *pRetCode=ret; goto L_RETU; } memcpy(&to_pos,&from_pos,sizeof(to_pos)); break; case TRADE_INNER_QUERYSERIAL: ret=Pos_QuerySerial(&from_pos,handle,pRetCode,szMsg); if(ret) { *pRetCode=ret; goto L_RETU; } return 0; case TRADE_INNER_WRITEERRCARD: ret=Pos_WriteErrCard(&from_pos); if(ret) { *pRetCode=ret; goto L_RETU; } break; //前台发起部分,包括签到、签退、对帐等 case TRADE_INNER_LOGIN: writelog(LOG_ERR,"start inner login!"); break; //查询补助信息 case TRADE_INNER_QUERYSUBSIDY: ret=query_subsidy(in_pack,handle,pRetCode,szMsg); if(ret) { *pRetCode=ret; goto L_RETU; } return 0; //领取补助 case TRADE_INNER_GETSUBSIDY: ret=get_subsidy(in_pack,handle,pRetCode,szMsg); if(ret) { *pRetCode=ret; goto L_RETU; } return 0; default: writelog(LOG_INFO,"This trade can't supplied,tradecode=[%d]!",atoi(tradecode)); *pRetCode=E_TRANS_FUNC_NONSUPPORT; goto L_RETU; } Strncpy_t(out_pack->sclose_emp,to_pos.TradeCode,sizeof(out_pack->sclose_emp)); Strncpy_t(out_pack->sorder0,to_pos.TransMoney,sizeof(out_pack->sorder0)); Strncpy_t(out_pack->sorder1,to_pos.ExtraMoney,sizeof(out_pack->sorder1)); Strncpy_t(out_pack->sserial1,to_pos.AccountMoney,sizeof(out_pack->sserial1)); out_pack->lvol0=to_pos.SendNo; out_pack->lvol1=to_pos.RecvNo; Strncpy_t(out_pack->sdate0,to_pos.TradeDate,sizeof(out_pack->sdate0)); Strncpy_t(out_pack->stime0,to_pos.TradeTime,sizeof(out_pack->stime0)); Strncpy_t(out_pack->sdate1,to_pos.BankDate,sizeof(out_pack->sdate1)); Strncpy_t(out_pack->stime1,to_pos.BankTime,sizeof(out_pack->stime1)); Strncpy_t(out_pack->scust_no,to_pos.Balance,sizeof(out_pack->scust_no)); Strncpy_t(out_pack->schange_emp,to_pos.RetCode,sizeof(out_pack->schange_emp)); Strncpy_t(out_pack->sserial0,to_pos.CardNo,sizeof(out_pack->sserial0)); out_pack->lvol2=to_pos.Notecase; Strncpy_t(out_pack->scust_auth,to_pos.BankCardNo,sizeof(out_pack->scust_auth)); sprintf(out_pack->sstatus1,"%c",to_pos.MngFeeFlag); Strncpy_t(out_pack->semp_pwd,to_pos.AccountPwd,sizeof(out_pack->semp_pwd)); Strncpy_t(out_pack->semp_pwd2,to_pos.AccountNewPwd,sizeof(out_pack->semp_pwd2)); Strncpy_t(out_pack->sstation0,to_pos.BankCardPwd,sizeof(out_pack->sstation0)); Strncpy_t(out_pack->sstation1,to_pos.BankCardNewPwd,sizeof(out_pack->sstation1)); Strncpy_t(out_pack->sorder2,to_pos.TerminalId,sizeof(out_pack->sorder2)); PutRow(handle,out_pack,pRetCode,szMsg); writelog(LOG_INFO,"Trade succeed,trade code=[%6.6s]!",to_pos.TradeCode); return 0; L_RETU: //writelog(LOG_ERR,"Trade faild,trade code=[%s],return code=[%d]!",to_pos.TradeCode,*pRetCode); return *pRetCode; L_RET_BANK_NOT_LOGIN: writelog(LOG_ERR,"Trade faild,trade code=[%s],return code=[%d]!",to_pos.TradeCode,*pRetCode); *pRetCode=E_TRANS_BANK_NETERR; return *pRetCode; }
int F950052(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret =0; //writelog(LOG_INFO,"start pos deposit"); cpu_trade_t cpu_trade; CAccTrans *pAccTrans=CAccTrans::getInstance(); TRANS& trans=pAccTrans->trans; ret=pAccTrans->CheckCfgUpdate(); if(ret) return ret; T_t_authcard tAuthCard; T_t_transdtl transdtl; T_t_dpsoper tDepositOper; T_t_dpsoperpos tDepositOperpos; T_t_dpsshoppos tDepositShoppos; T_t_shop tDepositShop; T_t_account tAccount; //帐户表 T_t_device tDevice; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); memset(&tAuthCard,0,sizeof(tAuthCard)); memset(&tDepositOper,0,sizeof(tDepositOper)); memset(&tDepositOperpos,0,sizeof(tDepositOperpos)); memset(&tDepositShoppos,0,sizeof(tDepositShoppos)); memset(&tDepositShop,0,sizeof(tDepositShop)); memset(&tAccount,0,sizeof(tAccount)); memset(&transdtl,0,sizeof(transdtl)); int opercardno=rPack->lvol3; //操作员号 if(!opercardno) return E_INPUTNULL_CARDNO; trans.cardflag=1; trans.usecardflag=1; trans.cardno=rPack->lvol5; trans.purseno=PURSE_NO_ONE; trans.cardbefbal=rPack->lvol9/100.0; //入卡金额 trans.dpscnt= rPack->lvol7; //入卡金额 trans.inputamt= rPack->lvol8/100.0; //充值金额 trans.unusedamt = trans.inputamt; trans.fundtype=1; transdtl.sysid= rPack->lcert_code; //上传工作站标识(前置机注册号) des2src(transdtl.devphyid, rPack->sdate1); //物理设备ID transdtl.devseqno=rPack->lvol4; //上传端流水号 ret=GetDevIdByDevPhyId(&(trans.termid),transdtl.devphyid); if (ret) { writelog(LOG_ERR,"GetDevIdByDevPhyId err[%d] devphy999_id[%s]",ret,transdtl.devphyid); return ret; } ret = DB_t_device_read_by_deviceid(trans.termid,&tDevice); if(ret) { writelog(LOG_ERR," DB_t_device_read_by_deviceid err[%d]",ret); return E_DB_DEVICE_R; } //writelog(LOG_DEBUG,"trans.inputamt[%d]",trans.inputamt); T_t_card tCard; memset(&tCard,0,sizeof(tCard)); ret=doCard(trans,tCard); if(ret) { return ret; } memset(&cpu_trade,0,sizeof cpu_trade); des2src(cpu_trade.random_key,rPack->sstock_code);//fixme cpu_trade.tradeamt = rPack->lvol8; cpu_trade.balance = rPack->lvol9; cpu_trade.termsno = rPack->lvol4; sprintf(cpu_trade.termno,"%012d",tDevice.deviceno); // 终端号 cpu_trade.tradecnt = trans.dpscnt; sprintf(cpu_trade.tx_datetime,"%s%s",rPack->spost_code,rPack->spost_code2); ret = doCheckMac(&cpu_trade,NULL,out_pack->sstock_code2); if(ret) { writelog(LOG_ERR,"doCheckMac err[%d]",ret); return ret; } trans.feetype=tCard.feetype; trans.cardtype=tCard.cardtype; // ret=UpdateCardBitmap(trans.cardno,trans.cardcnt,CARDBITMAPTYPE_INC,0); // if(ret) // return ret; // 读取操作员号 ret = DB_t_authcard_read_by_cardno(opercardno,&tAuthCard); if(ret) { writelog(LOG_ERR,"get operator code from auth card error, auth_card_id[%d]",opercardno); if(DB_NOTFOUND == ret) return E_DB_AUTHCARD_N; else return E_DB_OPERATOR_R; } if(tAuthCard.status[0]!=STATUS_NORMAL) { return E_OPERLOGON_UNREG; } des2src(trans.opercode,tAuthCard.opercode); ret=DB_t_dpsoper_read_lock_by_c0_and_opercode(trans.opercode,&tDepositOper); if(ret) { if(DB_NOTFOUND==ret) return E_DB_DEPOSITOPER_R; else return E_DB_DEPOSITOPER_N; } if(tDepositOper.status[0]!=STATUS_NORMAL) { DB_t_dpsoper_free_lock_by_c0(); return E_DEPOSITOPER_STOP; } //判断是否是重复交易 if(tDepositOper.lastdevseqno==transdtl.devseqno) { DB_t_dpsoper_free_lock_by_c0(); ret=DB_t_transdtl_read_by_accdate_and_devphyid_and_devseqno( trans.transdate,tDepositOper.lastdevphyid,tDepositOper.lastdevseqno, &transdtl); if(ret) { if(DB_NOTFOUND==ret) return E_DB_TRANSDTL_N; else return E_DB_TRANSDTL_R; } //if(transdtl.revflag[0]=='1') // return E_TRANSDTL_REV; ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LVOL5,F_LVOL10,F_LCERT_CODE,0); out_pack->lvol5 = transdtl.cardno; out_pack->lvol10 = (int)D4U5(transdtl.cardaftbal*100,0); out_pack->lcert_code = transdtl.termseqno; writelog(LOG_INFO,"该交易已成功,卡号[%d]充值金额[%.2lf]卡余额[%.2lf]",transdtl.cardno, transdtl.amount,transdtl.cardaftbal); PutRow(handle,out_pack,pRetCode,szMsg); return 0; } if(strncmp(tDepositOper.lasttransdate,trans.transdate,8)!=0) { des2src(tDepositOper.lasttransdate,trans.transdate); tDepositOper.depositcnt=0; tDepositOper.depositamt=0; } tDepositOper.depositcnt++; tDepositOper.depositamt+=trans.inputamt; tDepositOper.lastdevseqno=transdtl.devseqno; des2src(tDepositOper.lastdevphyid,transdtl.devphyid); des2src(tDepositOper.lastsaved,trans.sysdatetime); if(amtcmp(tDepositOper.maxdepositamt,0)>0) { DB_t_dpsoper_free_lock_by_c0(); if(amtcmp(tDepositOper.depositamt,tDepositOper.maxdepositamt)>0) { return E_OPER_OVER_MAX_DEPOSIT_AMT; } } ret=DB_t_dpsoper_update_lock_by_c0(&tDepositOper); if(ret) { return E_DB_DEPOSITOPER_U; } ret=DB_t_dpsshoppos_read_by_deviceid(trans.termid, &tDepositShoppos); if(ret) { if(DB_NOTFOUND==ret) { writelog(LOG_INFO,"PosDeposit termid[%d] ",trans.termid); trans.transcode = TC_POSDEPOSIT; } else { return E_DB_DEPOSITSHOPPOS_R; } } else { writelog(LOG_INFO,"ShopPosDeposit termid[%d] ",trans.termid); trans.transcode = TC_SHOPPOSDEPOSIT; ret=DB_t_shop_read_by_shopid(tDepositShoppos.shopid, &tDepositShop); if(ret) { if(DB_NOTFOUND==ret) return E_DB_SHOP_N; else return E_DB_SHOP_R; } if(tDepositShop.status[0]!=STATUS_NORMAL) { return E_SHOP_LOGOUT; } des2src(trans.draccno,tDepositShop.accno); } ret=pAccTrans->InitTrans(); if(ret) return ret; //根据卡号和钱包号得到消费者账号(借方) ret=DB_t_account_read_by_accno(tCard.accno,&tAccount); if(ret) { writelog(LOG_ERR,"DB_t_account_read_by_accno ret[%d]cardno[%d]",ret,trans.cardno); if(DB_NOTFOUND==ret) return E_NOTEXIST_ACCNO; else return E_DB_ACCOUNT_R; } double CardMaxBal=0; ret=GetPurseMaxBal(PURSE_NO_ONE,CardMaxBal); if(ret) return ret; if(amtcmp(trans.inputamt+trans.cardbefbal,CardMaxBal)>=0) return ERRINFO(E_AMT_EXCEED_MAX,CardMaxBal); trans.custid=tCard.custid; des2src(trans.cardaccno,tAccount.accno); ret=pAccTrans->doTrans(); if(ret) return ret; des2src(transdtl.transdate,trans.transdate); des2src(transdtl.transtime,trans.transtime); strcpy(transdtl.accdate,trans.accdate); strcpy(transdtl.acctime,trans.acctime); transdtl.termid=trans.termid; transdtl.termseqno=trans.termseqno; transdtl.transcode=trans.transcode; transdtl.paytype=trans.fundtype; des2src(transdtl.voucherno,trans.voucherno); transdtl.cardno=trans.cardno; transdtl.purseno=trans.purseno; transdtl.transflag = TF_DPS; transdtl.cardcnt=trans.dpscnt; transdtl.cardbefbal=trans.cardbefbal; transdtl.amount=trans.totaltransamt; transdtl.managefee=trans.totalfeeamt; transdtl.cardaftbal=trans.cardaftbal; transdtl.custid=trans.custid; des2src(transdtl.custname,tAccount.accname); des2src(transdtl.opercode,trans.opercode); transdtl.status[0]=DTLSTATUS_SUCCESS; ret=DB_t_transdtl_add(&transdtl); if(ret) { if(DB_REPEAT==ret) return E_DB_TRANSDTL_E; else return E_DB_TRANSDTL_I; } sprintf(trans.remark,"卡号%d 充值前卡余额:%.2lf元 卡当前余额:%.2lf元",trans.cardno,trans.cardbefbal,trans.cardaftbal); writelog(LOG_INFO,trans.remark); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LVOL5,F_LVOL10,F_LCERT_CODE,F_SSTOCK_CODE2,0); out_pack->lvol5 = trans.cardno; out_pack->lvol10 = (int)D4U5(trans.cardaftbal*100,0); out_pack->lcert_code = trans.termseqno; PutRow(handle,out_pack,pRetCode,szMsg); return 0; }
int F847226(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret; int card_id; char oper_code[11] = ""; char sysdate[9] = ""; char systime[7] = ""; char work_key[51] = ""; T_t_pif_operator tOper; T_t_pif_oper_authcard tAuthCard; T_t_tif_tradeserial tSerial; double uni_no = 0.0; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); memset(&tOper,0,sizeof tOper); memset(&tAuthCard,0,sizeof tAuthCard); memset(&tSerial,0,sizeof tSerial); memset(&aPack,0,sizeof aPack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LVOL0,F_LVOL1,F_SCUST_LIMIT,F_SCUST_LIMIT2,F_SDATE2,F_SBANK_ACC,0); des2src(oper_code,rPack->sname2); if(strlen(oper_code) == 0) { *pRetCode = E_OPER_NOT_EXIST; goto L_RETU; } if(strlen(rPack->scust_limit) == 0) { *pRetCode = E_INPUT_OPER_NULL; goto L_RETU; } if((ret = IsInvalidDateTime(rPack->sdate2,"YYYYMMDD"))) { *pRetCode = ret; goto L_RETU; } ret = DB_t_pif_operator_read_by_oper_code(oper_code,&tOper); if(ret) { if(DB_NOTFOUND == ret) *pRetCode = E_OPER_NOT_EXIST; else *pRetCode = E_DB_OPERATOR_R; goto L_RETU; } if(strcmp(OPERATOR_LOGOUT,tOper.status) == 0) { writelog(LOG_ERR,"操作员[%s]已注销",oper_code); *pRetCode = E_OPERLOGON_UNREG; goto L_RETU; } //todo:判断如果该操作员持有该卡已经发行过,那么系统允许重复发行,但是不计流水 //todo:用于解决操作员发行卡失败后,必须回收卡才能继续处理的问题 ret=is_already_publish_authcard(rPack->sname,oper_code,&card_id); if(!ret) { //writelog(LOG_ERR,"physical_no=[%s],oper_code=[%s],card_id=[%d]",rPack->sname,oper_code,card_id); ret = DB_t_pif_oper_authcard_read_by_card_id(card_id,&tAuthCard); if(ret) { if(DB_NOTFOUND == ret) *pRetCode = E_AUTHCARD_NOT_EXISTS; else *pRetCode = E_DB_OPER_AUTHCARD_R; goto L_RETU; } out_pack->lvol0 = tAuthCard.card_id; out_pack->lvol1 = tAuthCard.privilege; des2src(out_pack->sdate2,tAuthCard.expired_date); des2src(out_pack->scust_limit,tAuthCard.oper_code); des2src(out_pack->sbank_acc,work_key); des2src(out_pack->scust_limit2,tOper.oper_name); PutRow(handle,out_pack,pRetCode,szMsg); return 0; } if((ret = is_oper_has_authcard(oper_code))) { if(ret == 1) *pRetCode = E_OPER_ALREADY_HAS_AUTHCARD; else *pRetCode = ret; goto L_RETU; } ret=is_physical_no_in_use(rPack->sname); if(ret) { *pRetCode = ret; goto L_RETU; } ret=GetParameter(GLOBE_999_DEVAUTHKEY,work_key); if( ret) { *pRetCode= ret; goto L_RETU; } ret = getNewUniqNo(KEYTYPE_CARD_ID,&uni_no); if(ret) { *pRetCode = ret; goto L_RETU; } tAuthCard.card_id = D2I(uni_no); ret = getNewUniqNo(KEYTYPE_TRADESERIAL,&uni_no); if(ret) { *pRetCode = ret; goto L_RETU; } tSerial.serial_no = D2I(uni_no); getsysdate(sysdate); getsystime(systime); des2src(tAuthCard.issue_date,sysdate); des2src(tAuthCard.issue_time,systime); des2src(tAuthCard.oper_code,oper_code); des2src(tAuthCard.card_phyid,rPack->sname); des2src(tAuthCard.expired_date,rPack->sdate2); tAuthCard.privilege = rPack->lvol0; tAuthCard.status = AUTHCARD_STATUS_NORMAL; // TODO : 检查物理卡号是否已经存在 ret = DB_t_pif_oper_authcard_add(&tAuthCard); if(ret) { if(DB_REPEAT == ret) { writelog(LOG_ERR,"授权卡交易卡号已存在[%d]",tAuthCard.card_id); *pRetCode = E_DB_OPER_AUTHCARD_E; } else *pRetCode = E_DB_OPER_AUTHCARD_I; goto L_RETU; } tSerial.card_id = tAuthCard.card_id; tSerial.serial_state = SERISTAT_NONEEDDEBT; tSerial.serial_type = TXCODE_ISSUE_AUTHCARD; des2src(tSerial.operate_date,sysdate); des2src(tSerial.operate_time,systime); des2src(tSerial.enteract_date,sysdate); des2src(tSerial.enteract_time,systime); des2src(tSerial.collect_date,sysdate); des2src(tSerial.collect_time,systime); des2src(tSerial.oper_code,rPack->scust_limit); ret = DB_t_tif_tradeserial_add(&tSerial); if(ret) { if(DB_REPEAT == ret) { writelog(LOG_ERR,"记录流水表失败!"); *pRetCode = E_DB_TRADESERIAL_E; } else *pRetCode = E_DB_TRADESERIAL_I; goto L_RETU; } writelog(LOG_DEBUG,"发行授权卡成功,操作员[%s]交易卡号[%d]流水号[%d]" ,tAuthCard.oper_code,tAuthCard.card_id,tSerial.serial_no); out_pack->lvol0 = tAuthCard.card_id; out_pack->lvol1 = tAuthCard.privilege; des2src(out_pack->sdate2,tAuthCard.expired_date); des2src(out_pack->scust_limit,tAuthCard.oper_code); des2src(out_pack->sbank_acc,work_key); des2src(out_pack->scust_limit2,tOper.oper_name); PutRow(handle,out_pack,pRetCode,szMsg); return 0; L_RETU: return -1; }
int F847230(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; CAccTrans *pAccTrans=CAccTrans::getInstance(); des2src(pAccTrans->trans.opercode,rPack->semp); pAccTrans->trans.transcode=TC_AUTHCARDUNLOSS; ret=pAccTrans->InitTrans(); if(ret) return ret; TRANS& trans=pAccTrans->trans; ST_CPACK aPack; ST_PACK *outPack = &(aPack.pack); memset(&aPack,0,sizeof(aPack)); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LVOL0,F_SSERIAL0,0); trans.cardno= rPack->lvol0; if(trans.cardno<= 0) { return E_INPUT_CARDNO; } if(strlen(rPack->scust_limit) == 0) { return E_INPUT_OPER_NULL; } T_t_authcard tAuthCard; memset(&tAuthCard,0,sizeof(tAuthCard)); ret = DB_t_authcard_read_by_cardno(trans.cardno,&tAuthCard); if(ret) { if(DB_NOTFOUND == ret) return E_NOTEXIST_AUTHCARD; else return E_DB_AUTHCARD_R; } if(tAuthCard.status[0]==STATUS_DELETE) { writelog(LOG_ERR,"auth card has been cancel ,card id[%d]",tAuthCard.cardno); return E_AUTHCARD_LOGOUT; } if(tAuthCard.lossflag[0]=='0') { return E_AUTHCARD_NOLOST; } T_t_operator tOper; memset(&tOper,0,sizeof tOper); ret = DB_t_operator_read_by_opercode(tAuthCard.opercode,&tOper); if(ret) { if(DB_NOTFOUND == ret) { writelog(LOG_ERR,"operator does not exists, oper [%s]",tAuthCard.opercode); return E_DB_OPERATOR_N; } else return E_DB_OPERATOR_R; } sprintf(trans.remark,"操作员[%s]授权卡卡号[%d]解挂",tAuthCard.opercode,tAuthCard.cardno); if(tOper.status[0]==STATUS_DELETE) { writelog(LOG_ERR,"operator [%s] has been logout ",tAuthCard.opercode); return E_OPERLOGON_UNREG; } ret=chk_oper_pwd(tAuthCard.opercode,rPack->semp_pwd); if(ret) { writelog(LOG_ERR,"operator password error, operator [%s]",tAuthCard.opercode); if(E_NOTEXIST_OPER==ret) return E_NOTEXIST_AUTHOPER; else if(E_OPERPWD==ret) return E_AUTH_OPER_PWD; else return ret; } tAuthCard.lossflag[0]='0'; strcpy(tAuthCard.lossdate,""); ret = DB_t_authcard_update_by_cardno(tAuthCard.cardno,&tAuthCard); if(ret) { writelog(LOG_ERR,"update operator auth card information error, card id[%d]",tAuthCard.cardno); return E_DB_AUTHCARD_U; } // 插入黑名单表 T_t_cardver cardver; memset(&cardver,0,sizeof(cardver)); cardver.cardno=tAuthCard.cardno; des2src(cardver.accdate,pAccTrans->trans.accdate); cardver.termid=pAccTrans->trans.termid; cardver.termseqno=pAccTrans->trans.termseqno; cardver.cardno=tAuthCard.cardno; des2src(cardver.cardphyid,tAuthCard.cardphyid); cardver.cardvertype=CARDVERTYPE_CARDUNLOSS; cardver.adddelflag[0]=ADDDELFLAG_DEL; cardver.status[0]=STATUS_NORMAL; ret=getCardVerNo(cardver.cardverno); if(ret) return ret; ret=DB_t_cardver_add(&cardver); if(ret) { if(DB_REPEAT==ret) return E_DB_CARDVER_E; else return E_DB_CARDVER_I; } outPack->lvol0=tAuthCard.cardno; des2src(outPack->sserial0,cardver.cardverno); PutRow(handle,outPack,pRetCode,szMsg); return 0; }
int F847132(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; int i=0; int iTotalCnt=0; double dTotalAmt=0.0; double dSerialNo = 0; char logicdate[11]=""; //业务日期 char sysdate[11]=""; char systime[9]=""; char sMsg[256]=""; T_t_tif_tradeserial tradeserial; T_t_tif_savdtl tSavdtl; T_t_tif_subsidy tSubsidy; InAcc IA; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); T_t_tif_meslist tMesList; T_t_pif_device t_device; T_t_pif_syskey tSyskey; memset(&t_device,0,sizeof t_device); memset(&tMesList,0,sizeof tMesList); memset(&tSavdtl,0,sizeof(tSavdtl)); memset(&tSubsidy,0,sizeof(tSubsidy)); memset(&tSyskey,0,sizeof tSyskey); memset(&tradeserial,0,sizeof(tradeserial)); memset(&IA,0,sizeof(IA)); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_VSMESS,0); getsysdate(sysdate); getsystime(systime); ret=GetLogicDate(logicdate); //业务日期 if(ret) { *pRetCode=ret; goto L_RETU; } if(strlen(rPack->scust_limit)<1) { *pRetCode=E_INPUT_BATCH_NO; goto L_RETU; } if(strlen(rPack->scust_no)<1) { *pRetCode=E_INPUT_OPER_NULL; goto L_RETU; } //允许补助负金额 if(amtcmp(rPack->damt0,0)==0) { *pRetCode=E_INPUT_AMT; goto L_RETU; } des2src(tSubsidy.summary,rPack->semail); //补助摘要 if(strlen(rPack->semail)<1) { *pRetCode=E_INPUT_SUMMARY; goto L_RETU; } des2src(tSubsidy.batch_no,rPack->scust_limit); tSubsidy.bill_type=rPack->lvol2; //票据类型 des2src(tSubsidy.bill_no,rPack->scust_auth2); //票据号码 tSubsidy.amount=rPack->damt0; //补助金额 des2src(tSubsidy.subsidytype,rPack->smain_flag);//补助标志(0增值1减值) des2src(tSubsidy.subsidytype,"1"); //补助标志(0增值1减值) des2src(tSubsidy.broker_id,rPack->sname); //经办人身份证号 des2src(tSubsidy.broker_name,rPack->semail2); //经办人姓名 IA.dArrInAmt[0]=tradeserial.trade_fee; switch(tSubsidy.bill_type) { case TYPE_CASH: //现金 IA.iArrInFeeSwitch[1]=1; break; case TYPE_BILL: //支票 IA.iArrInFeeSwitch[2]=1; break; case TYPE_FUNDBOOK: //经费本 IA.iArrInFeeSwitch[3]=1; break; default: *pRetCode=E_INPUT_DEPOSIT_TYPE; goto L_RETU; } /* ret=get_batch_no_by_subsidy_no(tSubsidy.subsidy_no,tSubsidy.batch_no); if(ret) { *pRetCode = E_DB_SUBSIDYTMP_R; goto L_RETU; } */ // 下发补助时才生成批次号 /* ret=judge_with_max_subsidy_no_within_new(tSubsidy.subsidy_no); if(ret) { *pRetCode = E_SUBSIDY_DOWN_ERROR; goto L_RETU; } */ ret=stat_subsidy_amount_by_batch_no(tSubsidy.batch_no, &iTotalCnt,&dTotalAmt); if(ret) { *pRetCode = ret; writelog(LOG_ERR,"ret[%d]",ret); goto L_RETU; } if(iTotalCnt!=rPack->lvol3) { strcpy(szMsg,"补助人数与导入的数据不符"); *pRetCode=E_INPUT_DATA_INVAILD; goto L_RETU; } if(amtcmp(dTotalAmt,rPack->damt0)!=0) { strcpy(szMsg,"补助总金额与导入的补助数据不符"); *pRetCode=E_INPUT_DATA_INVAILD; goto L_RETU; } writelog(LOG_DEBUG,"download subsidy batch_no : %s",tSubsidy.batch_no); des2src(tSubsidy.tx_date,sysdate); des2src(tSubsidy.tx_time,systime); ret = getNewUniqNo(KEYTYPE_TRADESERIAL,&dSerialNo); //获得最大流水号 if(ret) { *pRetCode = ret; writelog(LOG_ERR,"ret[%d]",ret); goto L_RETU; } tradeserial.serial_no = D2I(dSerialNo); //流水号 tradeserial.other_seri_no = 0; //上传端流水号 if(amtcmp(dTotalAmt,0.0)>0) tradeserial.serial_type = TXCODE_SET_SUBSIDY; else tradeserial.serial_type = TXCODE_DESUBSIDY_DOWN; tradeserial.serial_state = SERISTAT_DEBT; //流水状态 des2src(tradeserial.operate_date,sysdate); //发生日期 des2src(tradeserial.operate_time,systime); //发生时间 des2src(tradeserial.collect_date,sysdate); //采集日期 des2src(tradeserial.collect_time,systime); //采集时间 des2src(tradeserial.enteract_date,logicdate); //处理日期 des2src(tradeserial.enteract_time,systime); //处理时间 tradeserial.maindevice_id = rPack->lvol6; //上传工作站标识 tradeserial.device_id = rPack->lvol7; //采集设备标识 des2src(tradeserial.oper_code , rPack->scust_no); //操作员代码 tradeserial.sys_id = 0; //外部系统标识 // 设置发生金额 tradeserial.trade_fee = dTotalAmt; switch(tSubsidy.bill_type) { case TYPE_CASH: //现金 break; case TYPE_BILL: //支票 case TYPE_FUNDBOOK: //经费本 tSavdtl.amount=rPack->damt0; //发生额 if(amtcmp(tSavdtl.amount,0)==0) break; des2src(tSavdtl.bill_no,tSubsidy.bill_no); //票据号码 if(strlen(tSavdtl.bill_no)<1) { *pRetCode=E_INPUT_BILLNO; goto L_RETU; } tSavdtl.card_no=0; //卡号 des2src(tSavdtl.oper_no,rPack->scust_limit); //操作员 tSavdtl.seqno=tradeserial.serial_no; //流水号 des2src(tSavdtl.tx_date,sysdate); //发生日期 des2src(tSavdtl.tx_time,systime); //发生时间 tSavdtl.cnt=1; //票据数量 tSavdtl.bill_type=tSubsidy.bill_type; //票据类型 tSavdtl.tx_code=tradeserial.serial_type; //交易码 ret=DB_t_tif_savdtl_add(&tSavdtl); if(ret) { if(DB_REPEAT==ret) *pRetCode = E_DB_SAVDTL_E; else *pRetCode = E_DB_SAVDTL_I; goto L_RETU; } break; default: *pRetCode=E_INPUT_DEPOSIT_TYPE; goto L_RETU; } IA.iFeeType=1; //默认值 //支持负金额扣款 if(tradeserial.trade_fee<0) tradeserial.trade_fee=-tradeserial.trade_fee; IA.dArrInAmt[0]=tradeserial.trade_fee; IA.iArrInFeeSwitch[0]=rPack->lvol0; IA.iArrInFeeSwitch[5]=rPack->lvol5; IA.iArrInFeeSwitch[6]=rPack->lvol6; IA.iArrInFeeSwitch[7]=rPack->lvol7; IA.iArrInFeeSwitch[8]=rPack->lvol8; IA.iArrInFeeSwitch[9]=rPack->lvol9; IA.iArrInFeeSwitch[10]=rPack->lvol10; // 记入账户信息 ret=process(&IA,&tradeserial,&tSubsidy); if(ret) { writelog(LOG_ERR,"process ret[%d]",ret); *pRetCode=ret; goto L_RETU; } sprintf(out_pack->vsmess,"流水号:%d ",IA.iSerialNo); // writelog(LOG_DEBUG,"out tx type count %d",IA.iOutTxTypeCnt); /* for(i=1;i<=IA.iOutTxTypeCnt;i++) { if(amtcmp(IA.dArrOutAmt[i],0)!=0) { sprintf(sMsg,"%s:%.2lf元 ",IA.sArrOutTxName[i],IA.dArrOutAmt[i]); strcat(out_pack->vsmess,sMsg); } } */ sprintf(sMsg,",共%d笔",iTotalCnt); strcat(out_pack->vsmess,sMsg); // strcat(out_pack->vsmess,sMsg); // writelog(LOG_DEBUG,out_pack->vsmess); ret = DB_t_tif_tradeserial_add(&tradeserial); if (ret) { writelog(LOG_ERR,"ret[%d]",ret); if(DB_REPEAT==ret) *pRetCode = E_DB_TRADESERIAL_E; else *pRetCode = E_DB_TRADESERIAL_I; goto L_RETU; } // 广播下载补助名单任务 memset(&tMesList,0,sizeof tMesList); tMesList.funid=930077; tMesList.level = MESLIST_PRIORITY_REALTIME; tMesList.msgtype = MESLIST_TYPE_NORMAL; tMesList.max_send_cnt = 5; ret=AddMsgLst(&tMesList); if(ret) { *pRetCode=E_DB_MESLIST_I; writelog(LOG_ERR,"AddMsgLst err[%d]",ret); return ret; } ////////////////////////新增 ret=DB_t_pif_device_open_select_by_c5_and_devtype_and_phytype("5301",1001); if(ret) { writelog(LOG_ERR,"DB_t_pif_device_open_select_by_c5_and_devtype_and_phytype error,ret=[%d]",ret); *pRetCode = E_DB_DEVICE_R; goto L_RETU; } while(1) { // 初始化宿主变量 ret=DB_t_pif_device_fetch_select_by_c5(&t_device); if (ret) { DB_t_pif_device_close_select_by_c5(); db_chk_err(__FILE__,__LINE__,&sqlca); if(DB_NOTFOUND==ret) { break; } else { *pRetCode=E_DB_DEVICE_R; writelog(LOG_ERR,"DB_t_pif_device_fetch_select_by_c5 err [%d]",ret); goto L_RETU; } } if(t_device.state_id == DEVISTAT_LOGOUT) //设备已经注销 continue; tMesList.devid = t_device.device_id; tMesList.device_id= t_device.subsystem_id; ret=AddMsgLst(&tMesList); if(ret) { *pRetCode=E_DB_MESLIST_I; DB_t_pif_device_close_select_by_c5(); writelog(LOG_ERR,"AddMsgLst err[%d]",ret); return ret; } } // 锁住批次号 ret = DB_t_pif_syskey_read_lock_by_cur_and_key_code(KEYTYPE_TIF_SUBSIDY_NO,&tSyskey); if(ret) { if(DB_NOTFOUND == ret) *pRetCode = E_DB_SYSKEY_N; else *pRetCode = E_DB_SYSKEY_R; goto L_RETU; } ret = calc_import_max_subsidy_no(tSubsidy.batch_no,tSubsidy.oper_code,&tSubsidy.subsidy_no); if(ret) { DB_t_tif_subsidy_close_select_by_c4(); return ret; } writelog(LOG_DEBUG,"download subsidy no[%d]",tSubsidy.subsidy_no); ret=update_subsidy_info_by_batch_no(&tSubsidy); if(ret) { *pRetCode = ret; DB_t_pif_syskey_free_lock_cur(); writelog(LOG_ERR,"ret[%d]",ret); goto L_RETU; } // 释放批次号 DB_t_pif_syskey_free_lock_cur(); PutRow(handle,out_pack,pRetCode,szMsg); return 0; L_RETU: return -1; }
int F841606(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; int i=0; int iCnt=0; int flag=0; T_t_cif_customer_tmp tCustomerTmp; T_t_cif_customer_tmp tCustomerTmpOut; ST_CPACK aPack; ST_PACK InPack; ST_PACK *out_pack = &(aPack.pack); memset(&tCustomerTmp,0,sizeof(tCustomerTmp)); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_SCUST_LIMIT,F_VSMESS,0); #ifdef DEBUG writelog(LOG_DEBUG,"stuemp_no :scust_auth [%s]",rPack->scust_auth); writelog(LOG_DEBUG,"cut_name :semail [%s]",rPack->semail); writelog(LOG_DEBUG,"cut_type :lvol0 [%d]",rPack->lvol0); writelog(LOG_DEBUG,"fee_type :lvol2 [%d]",rPack->lvol2); writelog(LOG_DEBUG,"sex :smarket_code [%s]",rPack->smarket_code); writelog(LOG_DEBUG,"man_id :scust_auth2 [%s]",rPack->scust_auth2); writelog(LOG_DEBUG,"phone :sphome [%s]",rPack->sphome); writelog(LOG_DEBUG,"area :lvol1 [%d]",rPack->lvol1); writelog(LOG_DEBUG,"dept_no :sname2 [%s]",rPack->sname2); writelog(LOG_DEBUG,"s_code :scust_no2 [%s]",rPack->scust_no2); writelog(LOG_DEBUG,"in_school_date :sdate0 [%s]",rPack->sdate0); writelog(LOG_DEBUG,"out_school_date:sdate1 [%s]",rPack->sdate1); writelog(LOG_DEBUG,"card_type :lvol3 [%d]",rPack->lvol3); writelog(LOG_DEBUG,"oper_code :sorder0 [%s]",rPack->sorder0); writelog(LOG_DEBUG,"status :scust_type [%s]",rPack->scust_type); #endif tCustomerTmp.seqno=rPack->lvol4; if(1==tCustomerTmp.seqno) { flag=1; //取批次号 getsysdatetime(tCustomerTmp.batch_no); ret=DynamicStmtExecute("delete from ykt_cur.t_cif_customer_tmp "); if(ret) { if(ret != DB_NOTFOUND) { writelog(LOG_DEBUG,"导入人员信息失败[%d]",ret); *pRetCode=E_DYNAMIC_STMT_EXECUTE; goto L_RETU; } } } else { des2src(tCustomerTmp.batch_no,rPack->scust_limit); if(strlen(tCustomerTmp.batch_no)!=14) { *pRetCode=E_INPUT_BATCH_NO; goto L_RETU; } } des2src(tCustomerTmp.stuemp_no,rPack->scust_auth); des2src(tCustomerTmp.cut_name,rPack->semail); tCustomerTmp.cut_type=rPack->lvol0; tCustomerTmp.fee_type=rPack->lvol2; des2src(tCustomerTmp.sex,rPack->smarket_code); des2src(tCustomerTmp.man_id,rPack->scust_auth2); des2src(tCustomerTmp.phone,rPack->sphone); tCustomerTmp.area=rPack->lvol1; des2src(tCustomerTmp.dept_no,rPack->sname2); des2src(tCustomerTmp.s_code,rPack->scust_no2); des2src(tCustomerTmp.in_school_date,rPack->sdate0); des2src(tCustomerTmp.out_school_date,rPack->sdate1); tCustomerTmp.card_type=rPack->lvol3; des2src(tCustomerTmp.oper_code,rPack->sorder0); des2src(tCustomerTmp.status,rPack->scust_type); des2src(tCustomerTmp.class_no,rPack->sorder0); ret=DB_t_cif_customer_tmp_add(&tCustomerTmp); if(SQLCODE) { if(DB_REPEAT==SQLCODE) { if(1==tCustomerTmp.seqno) { //如果插入有冲突,则再重新生成新的批次号 for(i=0;i<3;i++) { sleep(1); getsysdatetime(tCustomerTmp.batch_no); ret=DB_t_cif_customer_tmp_add(&tCustomerTmp); if(ret) { if(DB_REPEAT==SQLCODE) continue; else { *pRetCode=E_DB_CUSTOMER_TMP_I; goto L_RETU; } } break; } if(i>=3) { writelog(LOG_ERR,"batch_no[%s]seqno[%d]",tCustomerTmp.batch_no,tCustomerTmp.seqno); *pRetCode=E_DB_CUSTOMER_TMP_E; goto L_RETU; } } else { writelog(LOG_ERR,"batch_no[%s]seqno[%d]",tCustomerTmp.batch_no,tCustomerTmp.seqno); *pRetCode=E_DB_CUSTOMER_TMP_E; goto L_RETU; } } else { writelog(LOG_ERR,"batch_no[%s]seqno[%d]",tCustomerTmp.batch_no,tCustomerTmp.seqno); *pRetCode=E_DB_CUSTOMER_TMP_I; goto L_RETU; } } if(tCustomerTmp.status[0]=='1') { //最后一条,开始把临时表数据导入到客户表 writelog(LOG_DEBUG,"导入第%d记录,批次号:%s,客户姓名:%s",tCustomerTmp.seqno,tCustomerTmp.batch_no,tCustomerTmp.cut_name); iCnt=0; ret=DB_t_cif_customer_tmp_open_select_by_c0_and_batch_no(tCustomerTmp.batch_no); while(1) { memset(&tCustomerTmpOut,0,sizeof(tCustomerTmpOut)); memset(&InPack,0,sizeof(InPack)); ret=DB_t_cif_customer_tmp_fetch_select_by_c0(&tCustomerTmpOut); if(ret) { if(DB_NOTFOUND==ret) break; else { *pRetCode=E_DB_CUSTOMER_TMP_R; goto L_RETU; } } InPack.lvol3=tCustomerTmpOut.cut_type; InPack.lvol5=tCustomerTmpOut.fee_type; des2src(InPack.sname,tCustomerTmpOut.cut_name); InPack.lvol0=tCustomerTmpOut.area; des2src(InPack.scust_auth2, tCustomerTmpOut.stuemp_no); des2src(InPack.scust_no,tCustomerTmpOut.dept_no); des2src(InPack.scust_auth,tCustomerTmpOut.man_id); des2src(InPack.smarket_code,tCustomerTmpOut.sex); des2src(InPack.sphone,tCustomerTmpOut.phone); des2src(InPack.sphone3,tCustomerTmpOut.out_school_date); des2src(InPack.scust_no2,tCustomerTmpOut.s_code); des2src(InPack.scust_limit,tCustomerTmpOut.batch_no); des2src(InPack.sorder0,tCustomerTmpOut.class_no); ret=F841601(handle,iRequest,&InPack,pRetCode,szMsg); if(ret) { writelog(LOG_ERR,"F841601 EXEC ERR"); DB_t_cif_customer_tmp_close_select_by_c0(); sprintf(szMsg,"批次号%s,第%d条姓名为%s的记录有误,不能导入.",tCustomerTmpOut.batch_no,tCustomerTmpOut.seqno,tCustomerTmpOut.cut_name); goto L_RETU; } ++iCnt; } sprintf(out_pack->vsmess,"批次号:%s,共成功导入%d条客户信息",tCustomerTmp.batch_no,iCnt); flag=2; } if(flag!=2) { sprintf(out_pack->vsmess,"导入第%d记录,批次号:%s,客户姓名:%s",tCustomerTmp.seqno,tCustomerTmp.batch_no,tCustomerTmp.cut_name); } des2src(out_pack->scust_limit,tCustomerTmp.batch_no); PutRow(handle,out_pack,pRetCode,szMsg); writelog(LOG_DEBUG,out_pack->vsmess); return 0; L_RETU: return -1; }
int F950041(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret; T_t_pif_device tDevice; T_t_cif_shop_pos tShopPos; T_t_cif_shop tShop; T_t_tif_meslist tMsg; T_t_pif_feetype tFeeType; int rate = 0; int retries = 0; int msgid; unsigned char buf[32] = ""; char cardlist[100] = ""; int rows = 0; int i,j; memset(&tDevice,0,sizeof tDevice); memset(&tFeeType,0,sizeof tFeeType); ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); memset(&aPack,0,sizeof aPack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_VSVARSTR0,F_VSMESS,0); if(rPack->lcert_code < 1) { *pRetCode = E_DEVICE_NOT_EXIST; } else if((ret = DB_t_pif_device_read_by_device_id(rPack->lcert_code,&tDevice))) { if(DB_NOTFOUND == ret) *pRetCode = E_DB_DEVICE_N; else *pRetCode = E_DB_DEVICE_R; } else if(tDevice.state_id == DEVISTAT_LOGOUT) { *pRetCode = E_DEVICE_NOT_EXIST; } // 如果是 39 的充值机 else if(strcmp(tDevice.devtype,"0201") == 0 && tDevice.phytype == 1000) { des2src(rPack->sdate0,tDevice.devphy999_id); ret = F930006(handle,iRequest,rPack,pRetCode,szMsg); if(ret) { goto LRet; } return 0; } else if((ret = DB_t_cif_shop_pos_open_select_by_c0_and_device_id(rPack->lcert_code))) { *pRetCode = E_DB_SHOP_POS_R; } else { while(1) { memset(&tShopPos,0,sizeof tShopPos); memset(&tShop,0,sizeof tShop); if((ret = DB_t_cif_shop_pos_fetch_select_by_c0(&tShopPos))) { if(ret == DB_NOTFOUND) { writelog(LOG_DEBUG,"shop doesn't find [%d]!"); *pRetCode = 0; } else *pRetCode = E_DB_SHOP_POS_R; break; } writelog(LOG_DEBUG,"find shop [%d]",tShopPos.shop_id); if((ret = DB_t_cif_shop_read_by_shop_id(tShopPos.shop_id,&tShop))) { *pRetCode = ret; break; } if('1' == tShop.is_leaf[0] && '1' == tShop.is_getfee[0] && amtcmp(tShop.ratio,0.00)>0 ) { writelog(LOG_DEBUG,"shop rate [%.02f]",tShop.ratio); int newrate = D2I(tShop.ratio * 100); if(newrate > rate) rate = newrate; } } } if(*pRetCode) return -1; ret = DB_t_pif_feetype_open_select_by_cur1(); if(ret) { if(DB_NOTFOUND == ret) *pRetCode = E_DB_FEETYPE_N; else *pRetCode = E_DB_FEETYPE_R; return -1; } memset(buf,0,sizeof buf); while(1) { memset(&tFeeType,0,sizeof &tFeeType); ret = DB_t_pif_feetype_fetch_select_by_cur1(&tFeeType); if(ret) { if(DB_NOTFOUND == ret) { if(rows > 0) break; *pRetCode = E_DB_FEETYPE_N; } else *pRetCode = E_DB_FEETYPE_R; } rows++; if(tFeeType.fee_type < 0 || tFeeType.fee_type > 255 || tFeeType.is_outfee[0] != '1' ) continue; writelog(LOG_DEBUG,"fee[%s][%d][%c]",tFeeType.fee_name,tFeeType.fee_type ,tFeeType.is_outfee[0]); _SET_BIT(buf,tFeeType.fee_type-1); } //writelog(LOG_DEBUG,"bit length %d",BIT_LENGTH); memset(&tMsg,0,sizeof tMsg); tMsg.funid = 950041; tMsg.level = 1; tMsg.devid = tDevice.device_id; for(i = 0,j = 0;i < sizeof buf;++i) { j += sprintf(cardlist+j,"%02x",buf[i]); } AddXmlItemInt(tMsg.incontent,XML_KEY_FEE,rate); AddXmlItemStr(tMsg.incontent,XML_KEY_CARDRIGHTTYPE,cardlist); tMsg.max_send_cnt = 5; if((ret = AddMsgLst(&tMsg))) { *pRetCode = ret; } else { if(db_commit()) { *pRetCode = E_DB_COMMIT; return -1; } retries = 10; msgid = tMsg.mesid; for(retries=0;(retries<10)&&(tMsg.ecode!=0);retries++) { memset(&tMsg,0,sizeof tMsg); ret = DB_t_tif_meslist_read_by_mesid(msgid,&tMsg); if(ret) { strcpy(out_pack->vsvarstr0,"读取指令失败"); *pRetCode=E_DB_MESLIST_R; strcpy(szMsg,"读取指令失败"); return -1; } // 等待1秒 sleep(1); } switch(tMsg.ecode) { case 0: //成功 des2src(out_pack->vsmess,"成功"); strcpy(szMsg,"成功"); break; case 9999: //交易未处理 des2src(out_pack->vsmess,"前置机无应答"); strcpy(szMsg,"前置机无应答"); goto LRet; default: //交易已经处理,但结果是失败 des2src(out_pack->vsmess,tMsg.emsg); goto LRet; } PutRow(handle,out_pack,pRetCode,szMsg); AnswerData(handle,*pRetCode,szMsg); return 0; } LRet: return -1; }