/** ***************************************************************************** * @ingroup icp_hal * * @description * Get the CPU Type and product maj/min revisions, and return * the CPU type, and the combined maj and min revision. * * @assumptions * None * @sideEffects * None * @blocking * No * @reentrant * No * @threadSafe * Yes * * @param prodType - IN A pointer to the location of product type * @param prodRev - IN A pointer to the location of product revision * * @retval HALAE_SUCCESS Operation was successful * @retval HALAE_BADLIB Bad HAL library which wasn't initialized * @retval HALAE_BADARG Bad function argument * @retval HALAE_FAIL Operation failed * * *****************************************************************************/ int halAe_GetProdInfo(icp_firml_handle_t *handle, unsigned int *prodType, unsigned int *prodRev) { if(!handle || !prodType || !prodRev) { ERRINFO(("handle=0x%p, prodType=0x%p, prodRev=0x%p\n", handle, prodType, prodRev)); return (HALAE_BADARG); } HALAE_VERIFY_LIB(handle); switch(handle->halHandle->PrdMinType) { case HWID_ACCEL_COMP: *prodType = ACCEL_COMP_TYPE; *prodRev = (handle->halHandle->PrdMajRev << PID_MAJOR_REV_BITPOS) | handle->halHandle->PrdMinRev; break; case HWID_ACCEL_COMP_C: *prodType = ACCELCOMP_C_CPU_TYPE; *prodRev = (handle->halHandle->PrdMajRev << PID_MAJOR_REV_BITPOS) | handle->halHandle->PrdMinRev; break; case HWID_ACCEL_COMP_B: *prodType = ACCELCOMP_B_CPU_TYPE; *prodRev = (handle->halHandle->PrdMajRev << PID_MAJOR_REV_BITPOS) | handle->halHandle->PrdMinRev; break; case HWID_ACCEL_COMP_RS: *prodType = ACCELCOMP_RS_CPU_TYPE; *prodRev = (handle->halHandle->PrdMajRev << PID_MAJOR_REV_BITPOS) | handle->halHandle->PrdMinRev; break; case HWID_ACCEL_COMP_R: *prodType = ACCELCOMP_R_CPU_TYPE; *prodRev = (handle->halHandle->PrdMajRev << PID_MAJOR_REV_BITPOS) | handle->halHandle->PrdMinRev; break; default: ERRINFO(("PrdMinType=0x%x\n", handle->halHandle->PrdMinType)); return (HALAE_FAIL); } return (HALAE_SUCCESS); }
/** ***************************************************************************** * @ingroup uclo * * @description * * * @param pAeData - IN * @param hwAeNum - IN * * @retval UCLO_SUCCESS, UCLO_MEMFAIL, UCLO_BADARG * * *****************************************************************************/ int UcLo_AssignHalPages(icp_firml_handle_t *handle, uclo_aedata_t *pAeData, unsigned int hwAeNum) { int ii=0, halPageNum=0, numPages=0, cc=0; unsigned int ss=0; if(pAeData == NULL) { ERRINFO(("bad argument, pAeData is NULL\n")); return (UCLO_BADARG); } for(ss = 0; ss < pAeData->numSlices; ss++) { numPages += pAeData->aeSlice[ss].encapImage->imagePtr->numOfPages; } pAeData->numPageXref = numPages; if(numPages == 0) { return (UCLO_SUCCESS); } if(!(pAeData->pageXref = (uclo_pagexref_t *)osalMemAlloc(sizeof(uclo_pagexref_t) * pAeData->numPageXref))) { ERRINFO(("malloc error\n")); return (UCLO_MEMFAIL); } osalMemSet(pAeData->pageXref, (UINT8)cc, sizeof(uclo_pagexref_t) * pAeData->numPageXref); halAe_SetNumPages(handle, (unsigned char)hwAeNum, pAeData->numPageXref); for(ss = 0; ss < pAeData->numSlices; ss++) { for(ii = 0; ii < pAeData->aeSlice[ss].encapImage->imagePtr->numOfPages; ii++) { halAe_SetPageData(handle, (unsigned char)hwAeNum, halPageNum, pAeData->aeSlice[ss].pages[ii].encapPage->begVirtAddr, pAeData->aeSlice[ss].pages[ii].encapPage->begPhyAddr, pAeData->aeSlice[ss].pages[ii].encapPage->numMicroWords); pAeData->aeSlice[ss].pages[ii].halPageNum = halPageNum; pAeData->pageXref[halPageNum].aeSliceIndex = ss; pAeData->pageXref[halPageNum].pageNum = ii; halPageNum++; } } return (UCLO_SUCCESS); }
static int doAccount(TRANS& trans) { int ret=0; T_t_account tCardAccount; memset(&tCardAccount,0,sizeof(tCardAccount)); ret=DB_t_account_read_lock_by_c0_and_accno(trans.cardaccno,&tCardAccount); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CARDACCNO,trans.cardaccno); else return E_DB_ACCOUNT_R; } if(tCardAccount.status[0]!=STATUS_NORMAL) { DB_t_account_free_lock_by_c0(); return E_CARDACC_LOGOUT; } if(amtcmp(tCardAccount.balance,0)!=0) { writelog(LOG_ERR,"balance[%.2lf]",tCardAccount.balance); DB_t_account_free_lock_by_c0(); return ERRINFO(E_CARDACC_BALANCE_NOZERO,tCardAccount.balance); } if(amtcmp(tCardAccount.foregift,0)!=0) { writelog(LOG_ERR,"foregift[%.2lf]",tCardAccount.foregift); DB_t_account_free_lock_by_c0(); return ERRINFO(E_CARDACC_FOREGIFT_NOZERO,tCardAccount.foregift); } tCardAccount.status[0]=STATUS_DELETE; tCardAccount.lastcardbal=trans.cardbefbal; tCardAccount.lastpaycnt=trans.paycnt-1; tCardAccount.paycnt=trans.paycnt; tCardAccount.cardbal=0; tCardAccount.frozebal=0; tCardAccount.subsidybal=0; tCardAccount.availbal=0; strcpy(tCardAccount.closedate,trans.accdate); ret=DB_t_account_update_lock_by_c0(&tCardAccount); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CARDACCNO,tCardAccount.accno); else return E_DB_ACCOUNT_U; } return 0; }
static int doCard(T_t_card& tCard) { int ret=0; CAccTrans *pAccTrans=CAccTrans::getInstance(); TRANS& trans=pAccTrans->trans; ret=DB_t_card_read_by_cardno(trans.cardno,&tCard); if(ret) { writelog(LOG_ERR,"cardno[%d]",trans.cardno); if(DB_NOTFOUND==ret) return E_NOTEXIST_CARDNO; else return E_DB_CARD_R; } trans.cardtype=tCard.cardtype; trans.feetype=tCard.feetype; if(tCard.status[0]!=STATUS_NORMAL) { return ERRINFO(E_CARD_LOGOUT,trans.cardno); } if('1'==tCard.frozeflag[0]) { return ERRINFO(E_CARD_FREEZE,trans.cardno); } if('1'==tCard.lossflag[0]) { return ERRINFO(E_CARD_LOST,trans.cardno); } if('1'==tCard.badflag[0]) { return ERRINFO(E_CARD_BADRECORD,trans.cardno); } if('1'==tCard.lockflag[0]) { return ERRINFO(E_CARDNO_LOCKED,trans.cardno); } //比较卡物理ID是否相同 if(strcmp(tCard.cardphyid,trans.cardphyid)!=0) { writelog(LOG_ERR,"db cardphyid[%s],input cardphyid[%s]",tCard.cardphyid,trans.cardphyid); return E_CARD_PHYNO_DIFFER; } //检查卡的有效期 if(strcmp(tCard.expiredate,trans.transdate)<=0) return E_CARD_EXPIRED; return 0; }
// speed set. u8 ParseCmd_P(char * pCmdStr, CMD_ST *pstCmd) { ACTION_ST stAction; if(pCmdStr == NULL) { return 0; } fprintf(stderr,"\t%s:\t开始解析\n",pCmdStr); if (HfnParseActionP(pCmdStr,&stAction) == false) { ERRINFO("P指令解析错误"); return 0; } fprintf(stderr,"\t设置目标速度:%d\n",stAction.m_stActionSpeed.m_slSpeed); // 执行速度切换的动作. pstCmd->m_astNodeChain[pstCmd->m_ucLen].m_stCond.m_ucCondtionType = COND_TYPE_ONCE; pstCmd->m_astNodeChain[pstCmd->m_ucLen].m_stAction = stAction; pstCmd->m_ucLen++; fprintf(stderr,"\t解析完成,命令ID = %u\n",(unsigned)pstCmd->m_ucLen); return 1; }
/** ***************************************************************************** * @ingroup uclo * * @description * Free resources associated with Overlay AE data * * @param pAeData - IN * * @retval UCLO_SUCCESS, UCLO_BADARGG * * *****************************************************************************/ int UcLo_FreeAeData(uclo_aedata_t *pAeData) { unsigned int ss=0; if(pAeData == NULL) { ERRINFO(("bad argument, pAeData is NULL\n ")); return (UCLO_BADARG); } for(ss=0; ss < pAeData->numSlices; ss++) { if(pAeData->aeSlice[ss].regions) { osalMemFree(pAeData->aeSlice[ss].regions); } pAeData->aeSlice[ss].regions = NULL; if(pAeData->aeSlice[ss].pages) { osalMemFree(pAeData->aeSlice[ss].pages); } pAeData->aeSlice[ss].pages = NULL; } if(pAeData->pageXref) { osalMemFree(pAeData->pageXref); } pAeData->pageXref = NULL; pAeData->relocUstoreDram = 0; return (UCLO_SUCCESS); }
// 设置IO. / shM7. // 信号名称 - shM7. // 格式: setio = sh + pos + sigName // = sl + pos + sigName. u8 ParseCmd_S(char * pCmdStr, CMD_ST *pstCmd) { static s8 s_ascSigBuf[40]; ACTION_ST stAction; if (HfnParseActionS(pCmdStr,&stAction) == false) { ERRINFO("S命令解析错误: %s\n",pCmdStr); return false; } GetSigNameByID(stAction.m_stActionSig.m_ucRid,(char *)s_ascSigBuf); // sh/sl. fprintf(stderr,"\t设置信号:%s 为 %d,位置:%d\n", s_ascSigBuf,stAction.m_stActionSig.m_slSetVal,stAction.m_stActionSig.m_slPos); pstCmd->m_astNodeChain[pstCmd->m_ucLen].m_stCond.m_ucCondtionType = COND_TYPE_ONCE; pstCmd->m_astNodeChain[pstCmd->m_ucLen].m_stAction.m_iActionType = ACTION_TYPE_SIG; pstCmd->m_astNodeChain[pstCmd->m_ucLen].m_stAction = stAction; pstCmd->m_ucLen++; fprintf(stderr,"\t解析完成,命令ID = %u\n",(unsigned)pstCmd->m_ucLen); return 1; }
static int checklosecardacc(int cardno,T_t_card *tCard,T_t_account *tAccount) { int ret = DB_t_card_read_by_cardno(cardno, tCard); if(tCard->status[0]!=STATUS_NORMAL) { DB_t_card_free_lock_by_cur(); return ERRINFO(E_CARD_LOGOUT,cardno); } /* if('1'==tCard->frozeflag[0]) { DB_t_card_free_lock_by_cur(); return ERRINFO(E_CARD_FREEZE,cardno); } if('1'==tCard->badflag[0]) { DB_t_card_free_lock_by_cur(); return ERRINFO(E_CARD_BADRECORD,cardno); } // 只有挂失状态才能无卡退 if('1'!=tCard->lossflag[0]) { DB_t_card_free_lock_by_cur(); return ERRINFO(E_CARDNO_NOLOST,cardno); } */ ret=DB_t_account_read_by_accno(tCard->accno,tAccount); if(ret) { writelog(LOG_ERR,"accno[%s]",tCard->accno); if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_ACCNO,tCard->accno); else return E_DB_ACCOUNT_R; } if(tAccount->status[0]!=STATUS_NORMAL) { return ERRINFO(E_CARDACC_LOGOUT,tAccount->accno); } return 0; }
int F240000(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; CAccTrans *pAccTrans=CAccTrans::getInstance(); TRANS& trans=pAccTrans->trans; trans.termid=atoi(rPack->sorder2); char seed_key[17] = ""; char sInputPwd[33] = ""; //存放加密前的卡密钥 char sCryptPwd[33] = ""; //存放加密后的卡密钥 T_t_card card; memset(&card,0,sizeof(card)); ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LVOL0,F_DAMT0,F_DAMT1,F_DAMT2,F_LVOL1,F_LVOL2,F_SDATE0,0); trans.cardno=rPack->lvol0; if(trans.cardno<1) trans.cardno=atoi(rPack->sserial0); ret=DB_t_card_read_by_cardno(trans.cardno,&card); if(ret) { writelog(LOG_ERR,"Create serial_no error,error code=[%d]",ret); return ERRINFO(E_CARD_LOGOUT,trans.cardno); } if(card.status[0]!=STATUS_NORMAL) { return ERRINFO(E_CARD_LOGOUT,trans.cardno); } if('1'==card.frozeflag[0]) { return ERRINFO(E_CARD_FREEZE,trans.cardno); } if('1'==card.lossflag[0]) { return ERRINFO(E_CARD_LOST,trans.cardno); } if('1'==card.badflag[0]) { return ERRINFO(E_CARD_BADRECORD,trans.cardno); } if('1'==card.lockflag[0]) { return ERRINFO(E_CARDNO_LOCKED,trans.cardno); } des2src(sInputPwd,rPack->scust_limit); //卡密码 strcpy(seed_key,STATIC_SEED_KEY); //种子密钥 EncodePwd(seed_key,sInputPwd,sCryptPwd,0); //加密 if(strcmp(sCryptPwd,card.cardpwd)!=0) { writelog(LOG_ERR,"card err input[%s]db[%s]",sCryptPwd,card.cardpwd); return E_CARDPWD; } PutRow(handle,out_pack,pRetCode,szMsg); return 0; }
int F847318(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg) { int cardno=0; int custid,ret; custid = in_pack->lvol0; if(custid == 0 ) { return E_INPUT_DATA_INVAILD; } if(in_pack->lvol1 >0) cardno = in_pack->lvol1; else { ret = get_cardno_by_custid(custid,&cardno); if(ret) { return ret; } } T_t_card tCard; memset(&tCard,0,sizeof tCard); ret = DB_t_card_read_by_cardno(cardno,&tCard); if(ret) { if(DB_NOTFOUND == ret) return ERRINFO(E_NOTEXIST_CARDNO,cardno); else return E_DB_CARD_R; } // 检查卡密码 if(strcmp(in_pack->sstatus0,TYPE_YES) == 0) { ret = CheckUserPswd(in_pack->semp_pwd,tCard.cardpwd); if(ret) { return E_CARDPWD; } } des2src(in_pack->semp,in_pack->scust_limit); in_pack->lwithdraw_flag = in_pack->lvol6; in_pack->lvol0=tCard.cardno; in_pack->sstatus1[0]='1'; ret = F846307(handle,iRequest,in_pack,pRetCode,szMsg); if(ret) return ret; return 0; }
static int doAccount(TRANS& trans,char *cardaccno) { int ret=0; T_t_account tCardAccount; memset(&tCardAccount,0,sizeof(tCardAccount)); ret=DB_t_account_read_lock_by_c0_and_accno(cardaccno,&tCardAccount); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CARDACCNO,cardaccno); else return E_DB_ACCOUNT_R; } if(tCardAccount.status[0]!=STATUS_NORMAL) { DB_t_account_free_lock_by_c0(); return ERRINFO(E_CARDACC_LOGOUT,tCardAccount.accno); } if(amtcmp(tCardAccount.balance,0)!=0) { DB_t_account_free_lock_by_c0(); return ERRINFO(E_CARDACC_BALANCE_NOZERO,tCardAccount.balance); } tCardAccount.availbal=0; tCardAccount.frozebal=0; tCardAccount.lastcardbal=0; ret=DB_t_account_update_lock_by_c0(&tCardAccount); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CARDACCNO,cardaccno); else return E_DB_ACCOUNT_U; } return 0; }
static int CheckCardStatus() { CAccTrans& ats = CAccTrans::GetInst(); TRANS& trans = ats.trans; T_t_card tCard; memset(&tCard, 0, sizeof(tCard)); int ret = 0; ret = DB_t_card_read_by_cardno(trans.cardno, &tCard); if(ret) { writelog(LOG_ERR, "cardno[%d]", trans.cardno); if(DB_NOTFOUND == ret) return ERRINFO(E_NOTEXIST_CARDNO, trans.cardno); else return E_DB_CARD_R; } if(tCard.status[0] != STATUS_NORMAL) { return ERRINFO(E_CARD_LOGOUT, trans.cardno); } if('1' == tCard.frozeflag[0]) { return ERRINFO(E_CARD_FREEZE, trans.cardno); } if('1' == tCard.lossflag[0]) { return ERRINFO(E_CARD_LOST, trans.cardno); } if('1' == tCard.badflag[0]) { return ERRINFO(E_CARD_BADRECORD, trans.cardno); } //检查卡的有效期 if(strcmp(tCard.expiredate, trans.transdate) <= 0) return E_CARD_EXPIRED; trans.cardphytype = tCard.cardphytype; return 0; }
bool HfnParseActionP(char * pCmdStr, ACTION_ST * pstAction) { s32 slSpdSeq = 0; if (pCmdStr == NULL || (*pCmdStr != 'P' && *pCmdStr != 'p')) { return false; } pCmdStr++;// 跳过字符[pP] if (GetDigit(pCmdStr,&slSpdSeq) == false) { ERRINFO("速度指针解析错误"); return false; } pstAction->m_iActionType = ACTION_TYPE_SPD; pstAction->m_stActionPos.m_slPos = slSpdSeq; return true; }
/** ***************************************************************************** * @ingroup uclo * * @description * Initialize UcLo_AeData structure as unused * * @param pAeData - IN * * @retval UCLO_SUCCESS, UCLO_BADARG * * *****************************************************************************/ int UcLo_ClearAeData(uclo_aedata_t *pAeData) { unsigned int ss = 0; if(pAeData == NULL) { ERRINFO(("bad argument, pAeData is NULL\n")); return (UCLO_BADARG); } for(ss=0; ss < pAeData->numSlices; ss++) { pAeData->aeSlice[ss].regions = NULL; pAeData->aeSlice[ss].pages = NULL; pAeData->aeSlice[ss].encapImage = NULL; } pAeData->numSlices = 0; pAeData->numPageXref = 0; pAeData->pageXref = NULL; pAeData->relocUstoreDram = (unsigned int)-1; return (UCLO_SUCCESS); }
//取消换卡 static int DoCardInsteadCancel(TRUSERID *handle,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; CAccTrans *pAccTrans=CAccTrans::getInstance(); TRANS& trans=pAccTrans->trans; ST_CPACK aPack; ST_PACK *outPack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LVOL1,F_LSAFE_LEVEL2,F_LVOL4,F_LVOL5, F_SALL_NAME,F_SPAGER,F_SCERT_NO, F_SEMAIL2,F_SMARKET_CODE,F_SDATE0, F_LVOL0,F_STX_PWD,F_LVOL8,F_LVOL6,F_LSAFE_LEVEL,F_SMARKET_CODE2,F_SHOLDER_AC_NO, F_SORDER0,F_SEMP,F_SDATE3,F_STIME3,F_LVOL11,F_LVOL12, F_LWITHDRAW_FLAG,F_LSERIAL1,F_VSMESS,F_SNAME2,0); T_t_card tCard; memset(&tCard,0,sizeof(tCard)); ret=DB_t_card_read_by_cardno(trans.cardno,&tCard); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CARDNO,trans.cardno); else return E_DB_CARD_R; } if(tCard.status[0]!=STATUS_NORMAL) { return ERRINFO(E_CARD_LOGOUT,trans.cardno); } if('1'==tCard.frozeflag[0]) { return ERRINFO(E_CARD_FREEZE,trans.cardno); } if('1'==tCard.lossflag[0]) { return ERRINFO(E_CARD_LOST,trans.cardno); } if('1'==tCard.badflag[0]) { return ERRINFO(E_CARD_BADRECORD,trans.cardno); } T_t_account tCardAccount; memset(&tCardAccount,0,sizeof(tCardAccount)); ret=DB_t_account_read_by_accno(tCard.accno,&tCardAccount); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CARDACCNO,tCard.accno); else return E_DB_ACCOUNT_R; } T_t_customer customer; memset(&customer,0,sizeof(customer)); if(tCard.custid) { ret=DB_t_customer_read_by_custid(tCard.custid,&customer); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CUSTOMER,tCard.custid); else return E_DB_CUSTOMER_R; } } char cardpwd[33]=""; char key[17]=""; strcpy(key,STATIC_SEED_KEY); EncodePwd(key,cardpwd,tCard.cardpwd, 1); T_t_cardinsteaddtl cardinsteaddtl; memset(&cardinsteaddtl,0,sizeof(cardinsteaddtl)); ret=DB_t_cardinsteaddtl_read_lock_by_c0_and_cardno(trans.cardno,&cardinsteaddtl); if(ret) { if(DB_NOTFOUND==ret) return E_DB_CARDINSTEADDTL_N; else return E_DB_CARDINSTEADDTL_R; } if(cardinsteaddtl.status[0]==STATUS_NORMAL) { T_t_transdtl transdtl; memset(&transdtl,0,sizeof(transdtl)); des2src(transdtl.transdate,trans.transdate); des2src(transdtl.transtime,trans.transtime); des2src(transdtl.accdate,pAccTrans->trans.accdate); des2src(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.cardcnt=cardinsteaddtl.oldcardcnt; transdtl.cardbefbal=cardinsteaddtl.oldcardbal; transdtl.cardaftbal=transdtl.cardbefbal; transdtl.managefee=trans.totalfeeamt; transdtl.amount=trans.totaltransamt; transdtl.custid=tCard.custid; des2src(transdtl.custname,customer.custname); des2src(transdtl.stuempno,customer.stuempno); des2src(transdtl.opercode,trans.opercode); transdtl.status[0]=DTLSTATUS_SUCCESS; des2src(transdtl.showcardno,cardinsteaddtl.oldshowcardno); ret=DB_t_transdtl_add(&transdtl); if(ret) { if(DB_REPEAT==ret) return E_DB_TRANSDTL_E; else return E_DB_TRANSDTL_I; } outPack->lvol1=tCard.custid; outPack->lsafe_level2=customer.custtype; outPack->lvol5=tCard.feetype; des2src(outPack->sall_name,customer.custname); des2src(outPack->spager,customer.stuempno); des2src(outPack->scert_no,customer.deptcode); des2src(outPack->semail2,customer.idno); des2src(outPack->smarket_code,customer.sex); des2src(outPack->sdate0,tCard.expiredate); sprintf(outPack->sholder_ac_no,"%d",10); //发行方标识 des2src(outPack->smarket_code2,customer.idtype); des2src(outPack->sname2,tCard.cardverno); outPack->lsafe_level=tCard.cardtype; outPack->lvol0=tCard.cardno; outPack->lvol8=(int)(cardinsteaddtl.oldcardbal*100); outPack->lvol4=cardinsteaddtl.oldsubsidyno; outPack->lvol11=D4U5(tCardAccount.singlemaxamt*100,0); outPack->lvol12=D4U5(tCardAccount.daycostmaxamt*100,0); outPack->lvol6=cardinsteaddtl.oldcardcnt; des2src(outPack->sorder0,tCard.showcardno); des2src(outPack->sdate3,pAccTrans->trans.accdate); des2src(outPack->stime3,pAccTrans->trans.acctime); des2src(outPack->semp,trans.opercode); outPack->lwithdraw_flag=trans.termid; outPack->lserial1=trans.termseqno; des2src(outPack->stx_pwd,cardpwd); PutRow(handle,outPack,pRetCode,szMsg); return 0; } if(cardinsteaddtl.revflag[0]=='1') { return E_CARDINSTEAD_CANCEL; } T_t_card cardtmp; memset(&cardtmp,0,sizeof(cardtmp)); ret=DB_t_card_read_by_cardphyid_and_status(trans.cardphyid,"1",&cardtmp); if(ret!=DB_NOTFOUND) { if(DB_SUCCESS==ret) return ERRINFO(E_EXIST_CARDPHYID,trans.cardphyid); else return E_DB_CARD_R; } if(pAccTrans->sysPara.bEnableCardMgr) { ret=DB_t_card_read_by_showcardno_and_status(trans.showcardno,"1",&tCard); if(ret!=DB_NOTFOUND) { if(DB_SUCCESS==ret) return ERRINFO(E_EXIST_SHOWCARDNO,trans.showcardno); else return E_DB_CARD_R; } //回收卡 ret=UseShowCardNoBack(trans.opercode,cardinsteaddtl.showcardno); if(ret) { return ret; } T_t_carddtl carddtl; memset(&carddtl,0,sizeof(carddtl)); des2src(carddtl.accdate,pAccTrans->trans.accdate); des2src(carddtl.acctime,trans.acctime); carddtl.termid=trans.termid; carddtl.termseqno=trans.termseqno; des2src(carddtl.opercode,trans.opercode); carddtl.cardtype=trans.cardtype; carddtl.usetype=CARDUSETYPE_REUSE; carddtl.inoutflag=INOUTFLAG_IN; carddtl.transcnt=1; strcpy(carddtl.summary,"换卡撤销(新卡回收)"); des2src(carddtl.cardphyid,cardinsteaddtl.cardphyid); des2src(carddtl.showcardno,cardinsteaddtl.showcardno); ret=DB_t_carddtl_add(&carddtl); if(ret) { if(DB_REPEAT==ret) return E_DB_CARDDTL_E; else return E_DB_CARDDTL_I; } //使用原卡 int cardtype=0; ret=UseShowCardNo(trans.opercode,cardinsteaddtl.oldshowcardno,cardtype); if(ret) { return ret; } memset(&carddtl,0,sizeof(carddtl)); des2src(carddtl.accdate,pAccTrans->trans.accdate); des2src(carddtl.acctime,trans.acctime); carddtl.termid=trans.termid; carddtl.termseqno=trans.termseqno; des2src(carddtl.opercode,trans.opercode); carddtl.cardtype=cardinsteaddtl.oldcardtype; carddtl.usetype=CARDUSETYPE_USE; carddtl.inoutflag=INOUTFLAG_OUT; carddtl.transcnt=1; strcpy(carddtl.summary,"换卡撤销(重发原卡)"); des2src(carddtl.cardphyid,cardinsteaddtl.oldcardphyid); des2src(carddtl.showcardno,cardinsteaddtl.oldshowcardno); ret=DB_t_carddtl_add(&carddtl); if(ret) { if(DB_REPEAT==ret) return E_DB_CARDDTL_E; else return E_DB_CARDDTL_I; } } //更新卡信息 memset(&tCard,0,sizeof(tCard)); ret=DB_t_card_read_lock_by_cur_and_cardno(trans.cardno,&tCard); if(ret) { if(DB_NOTFOUND==ret) return E_NOTEXIST_CARDNO; else return E_DB_CARD_R; } if(tCard.status[0]!=STATUS_NORMAL) { DB_t_card_free_lock_by_cur(); return E_CARD_LOGOUT; } tCard.cardtype=cardinsteaddtl.oldcardtype; des2src(tCard.cardphyid,cardinsteaddtl.oldcardphyid); des2src(tCard.showcardno,cardinsteaddtl.oldshowcardno); ret=DB_t_card_update_lock_by_cur(&tCard); if(ret) { if(DB_NOTFOUND==ret) return E_NOTEXIST_CARDNO; else return E_DB_CARD_U; } T_t_transdtl transdtl; memset(&transdtl,0,sizeof(transdtl)); 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.cardcnt=cardinsteaddtl.oldcardcnt; transdtl.cardbefbal=cardinsteaddtl.oldcardbal; transdtl.cardaftbal=transdtl.cardbefbal; transdtl.managefee=trans.totalfeeamt; transdtl.amount=trans.totaltransamt; transdtl.custid=tCard.custid; des2src(transdtl.custname,customer.custname); des2src(transdtl.stuempno,customer.stuempno); des2src(transdtl.opercode,trans.opercode); transdtl.status[0]=DTLSTATUS_SUCCESS; des2src(transdtl.showcardno,cardinsteaddtl.oldshowcardno); ret=DB_t_transdtl_add(&transdtl); if(ret) { if(DB_REPEAT==ret) return E_DB_TRANSDTL_E; else return E_DB_TRANSDTL_I; } outPack->lvol1=tCard.custid; outPack->lsafe_level2=customer.custtype; outPack->lvol5=trans.feetype; des2src(outPack->sall_name,customer.custname); des2src(outPack->spager,customer.stuempno); des2src(outPack->scert_no,customer.deptcode); des2src(outPack->semail2,customer.idno); des2src(outPack->smarket_code,customer.sex); des2src(outPack->sdate0,tCard.expiredate); des2src(outPack->smarket_code2,customer.idtype); sprintf(outPack->sholder_ac_no,"%d",10); //发行方标识 des2src(outPack->sname2,tCard.cardverno); outPack->lsafe_level=tCard.cardtype; outPack->lvol0=tCard.cardno; outPack->lvol4=cardinsteaddtl.oldsubsidyno; outPack->lvol8=(int)(cardinsteaddtl.oldcardbal*100); outPack->lvol11=D4U5(tCardAccount.singlemaxamt*100,0); outPack->lvol12=D4U5(tCardAccount.daycostmaxamt*100,0); outPack->lvol6=cardinsteaddtl.oldcardcnt; des2src(outPack->sorder0,tCard.showcardno); des2src(outPack->sdate3,pAccTrans->trans.accdate); des2src(outPack->stime3,pAccTrans->trans.acctime); des2src(outPack->semp,trans.opercode); des2src(outPack->stx_pwd,cardpwd); outPack->lwithdraw_flag=trans.termid; outPack->lserial1=trans.termseqno; PutRow(handle,outPack,pRetCode,szMsg); return 0; }
static int DoCardInstead(TRUSERID *handle,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; CAccTrans *pAccTrans=CAccTrans::getInstance(); TRANS& trans=pAccTrans->trans; ST_CPACK aPack; ST_PACK *outPack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LVOL1,F_LSAFE_LEVEL2,F_LVOL4,F_LVOL5, F_SALL_NAME,F_SPAGER,F_SCERT_NO,F_LSAFE_LEVEL,F_SMARKET_CODE2,F_SHOLDER_AC_NO, F_SEMAIL2,F_SMARKET_CODE,F_SDATE0, F_LVOL0,F_STX_PWD,F_LVOL8,F_LVOL6, F_SORDER0,F_SEMP,F_SDATE3,F_STIME3,F_LVOL11,F_LVOL12, F_LWITHDRAW_FLAG,F_LSERIAL1,F_VSMESS,F_SNAME2,0); T_t_card tCard; memset(&tCard,0,sizeof(tCard)); ret=DB_t_card_read_lock_by_cur_and_cardno(trans.cardno,&tCard); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CARDNO,trans.cardno); else return E_DB_CARD_R; } if(tCard.status[0]!=STATUS_NORMAL) { DB_t_card_free_lock_by_cur(); return ERRINFO(E_CARD_LOGOUT,trans.cardno); } if('1'==tCard.frozeflag[0]) { DB_t_card_free_lock_by_cur(); return ERRINFO(E_CARD_FREEZE,trans.cardno); } if('1'==tCard.lossflag[0]) { DB_t_card_free_lock_by_cur(); return ERRINFO(E_CARD_LOST,trans.cardno); } if('1'==tCard.badflag[0]) { DB_t_card_free_lock_by_cur(); return ERRINFO(E_CARD_BADRECORD,trans.cardno); } tCard.status[0]=STATUS_DELETE; des2src(tCard.closedate,trans.transdate); ret=DB_t_card_update_lock_by_cur(&tCard); if(ret) { return E_DB_CARD_U; } memset(tCard.closedate,0,sizeof(tCard.closedate)); tCard.status[0]=STATUS_NORMAL; T_t_account tCardAccount; memset(&tCardAccount,0,sizeof(tCardAccount)); ret=DB_t_account_read_by_accno(tCard.accno,&tCardAccount); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CARDACCNO,tCard.accno); else return E_DB_ACCOUNT_R; } int existflag=0; ret=IsExistUnGetSubsidy(tCard.cardno,&existflag); if(ret) { return ret; } if(existflag) { ERRTIP("有未领补助,请领取补助后再换卡"); return E_COMMON_ERR; } T_t_customer customer; memset(&customer,0,sizeof(customer)); if(tCard.custid) { ret=DB_t_customer_read_by_custid(tCard.custid,&customer); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CUSTOMER,tCard.custid); else return E_DB_CUSTOMER_R; } des2src(trans.stuempno,customer.stuempno); des2src(trans.custname,customer.custname); trans.custid=customer.custid; } char cardpwd[33]=""; char key[17]=""; strcpy(key,STATIC_SEED_KEY); EncodePwd(key,cardpwd,tCard.cardpwd, 1); T_t_cardinsteaddtl cardinsteaddtl; memset(&cardinsteaddtl,0,sizeof(cardinsteaddtl)); ret=DB_t_cardinsteaddtl_read_lock_by_c0_and_cardno(trans.cardno,&cardinsteaddtl); if(ret) { if(DB_NOTFOUND==ret) return E_DB_CARDINSTEADDTL_N; else return E_DB_CARDINSTEADDTL_R; } //核对登记信息与卡表是否一致 if(strcmp(cardinsteaddtl.oldcardphyid,tCard.cardphyid)!=0) { DB_t_cardinsteaddtl_free_lock_by_c0(); strcpy(szMsg,"保存的卡信息与原卡物理ID不一致"); return E_CARD_PHYNO_DIFFER; } //核对原物理ID是否一致 if(strcmp(cardinsteaddtl.oldcardphyid,rPack->scust_no)!=0) { DB_t_cardinsteaddtl_free_lock_by_c0(); return E_CARD_PHYNO_DIFFER; } if(cardinsteaddtl.revflag[0]=='1') { DB_t_cardinsteaddtl_free_lock_by_c0(); return E_CARDINSTEAD_CANCEL; } if(cardinsteaddtl.status[0]=='2') { DB_t_cardinsteaddtl_free_lock_by_c0(); if(strcmp(cardinsteaddtl.cardphyid,trans.cardphyid)!=0) { return ERRINFO(E_CARD_PHYNO_DIFFER,trans.cardphyid,cardinsteaddtl.cardphyid); } outPack->lvol1=tCard.custid; outPack->lsafe_level2=customer.custtype; outPack->lvol5=tCard.feetype; des2src(outPack->sall_name,customer.custname); des2src(outPack->spager,customer.stuempno); des2src(outPack->scert_no,customer.deptcode); des2src(outPack->semail2,customer.idno); des2src(outPack->smarket_code,customer.sex); des2src(outPack->sdate0,tCard.expiredate); sprintf(outPack->sholder_ac_no,"%d",10); //发行方标识 des2src(outPack->smarket_code2,customer.idtype); outPack->lsafe_level=tCard.cardtype; des2src(outPack->sname2,tCard.cardverno); outPack->lvol0=tCard.cardno; outPack->lvol8=(int)(cardinsteaddtl.oldcardbal*100); outPack->lvol11=D4U5(tCardAccount.singlemaxamt*100,0); outPack->lvol12=D4U5(tCardAccount.daycostmaxamt*100,0); outPack->lvol6=cardinsteaddtl.oldcardcnt; outPack->lvol4=cardinsteaddtl.oldsubsidyno; des2src(outPack->sorder0,tCard.showcardno); des2src(outPack->sdate3,pAccTrans->trans.accdate); des2src(outPack->semp,trans.opercode); des2src(outPack->stx_pwd,cardpwd); outPack->lwithdraw_flag=trans.termid; outPack->lserial1=trans.termseqno; PutRow(handle,outPack,pRetCode,szMsg); return 0; } cardinsteaddtl.status[0]=STATUS_DELETE; des2src(cardinsteaddtl.cardphyid,trans.cardphyid); des2src(cardinsteaddtl.showcardno,trans.showcardno); ret=DB_t_cardinsteaddtl_update_lock_by_c0(&cardinsteaddtl); if(ret) { return E_DB_CARDINSTEADDTL_U; } //检查新卡物理id T_t_card cardtmp; memset(&cardtmp,0,sizeof(cardtmp)); ret=DB_t_card_read_by_cardphyid_and_status(trans.cardphyid,"1",&cardtmp); if(ret!=DB_NOTFOUND) { if(DB_SUCCESS==ret) return ERRINFO(E_EXIST_CARDPHYID,trans.cardphyid); else return E_DB_CARD_R; } if(pAccTrans->sysPara.bEnableCardMgr) { ret=DB_t_card_read_by_showcardno_and_status(trans.showcardno,"1",&cardtmp); if(ret!=DB_NOTFOUND) { if(DB_SUCCESS==ret) return ERRINFO(E_EXIST_SHOWCARDNO,trans.showcardno); else return E_DB_CARD_R; } //回收旧卡 ret=UseShowCardNoBack(trans.opercode,tCard.showcardno); if(ret) return ret; T_t_carddtl carddtl; memset(&carddtl,0,sizeof(carddtl)); des2src(carddtl.accdate,pAccTrans->trans.accdate); des2src(carddtl.acctime,trans.acctime); carddtl.termid=trans.termid; carddtl.termseqno=trans.termseqno; des2src(carddtl.opercode,trans.opercode); carddtl.cardtype=tCard.cardtype; carddtl.usetype=CARDUSETYPE_REUSE; carddtl.inoutflag=INOUTFLAG_IN; carddtl.transcnt=1; strcpy(carddtl.summary,"换卡(回收旧卡)"); des2src(carddtl.cardphyid,cardinsteaddtl.oldcardphyid); des2src(carddtl.showcardno,cardinsteaddtl.oldshowcardno); ret=DB_t_carddtl_add(&carddtl); if(ret) { if(DB_REPEAT==ret) return E_DB_CARDDTL_E; else return E_DB_CARDDTL_I; } } ////添加卡版本号记录 // T_t_cardver cardver; // // memset(&cardver,0,sizeof(cardver)); // cardver.cardno=trans.cardno; // des2src(cardver.accdate,pAccTrans->sysPara.sSettleDate); // cardver.termid=trans.termid; // cardver.termseqno=trans.termseqno; // cardver.status[0]=STATUS_NORMAL; // des2src(cardver.cardphyid,cardinsteaddtl.oldcardphyid); // des2src(cardver.stuempno,trans.stuempno); // cardver.cardvertype=CARDVERTYPE_CARDINSTEADOLD; // // 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; // } if(pAccTrans->sysPara.bEnableCardMgr) { int cardtype=0; //使用新卡 ret=UseShowCardNo(trans.opercode,trans.showcardno,cardtype); if(ret) { return ret; } if(cardtype!=tCard.cardtype) { if(CARDTYPE_TEMP==tCard.cardtype||CARDTYPE_TEMP==cardtype) { ERRTIP("过渡临时卡与其他卡不能互换"); return E_COMMON_ERR; } } tCard.cardtype=cardtype; T_t_cardtyperight cardtyperight; memset(&cardtyperight,0,sizeof(cardtyperight)); ret=DB_t_cardtyperight_read_by_cardtype_and_feetype(tCard.cardtype,tCard.feetype,&cardtyperight); if (ret) { writelog(LOG_ERR,"cardtype[%d]feetype[%d]",tCard.cardtype,tCard.feetype); if (DB_NOTFOUND==ret) return ERRINFO(E_NOCARDTYPERIGHT,tCard.feetype,tCard.cardtype); else return E_DB_CARDTYPERIGHT_R; } T_t_carddtl carddtl; memset(&carddtl,0,sizeof(carddtl)); des2src(carddtl.accdate,pAccTrans->trans.accdate); des2src(carddtl.acctime,trans.acctime); carddtl.termid=trans.termid; carddtl.termseqno=trans.termseqno; des2src(carddtl.opercode,trans.opercode); carddtl.cardtype=tCard.cardtype; carddtl.usetype=CARDUSETYPE_USE; carddtl.inoutflag=INOUTFLAG_OUT; carddtl.transcnt=1; strcpy(carddtl.summary,"换卡(发行新卡)"); des2src(carddtl.cardphyid,cardinsteaddtl.cardphyid); des2src(carddtl.showcardno,cardinsteaddtl.showcardno); ret=DB_t_carddtl_add(&carddtl); if(ret) { if(DB_REPEAT==ret) return E_DB_CARDDTL_E; else return E_DB_CARDDTL_I; } } ret = getNewUniqNo(KEYTYPE_CARDNO,&tCard.cardno); //获取最大卡号 if(ret) { return ret; } T_t_cardver cardver; memset(&cardver,0,sizeof(cardver)); cardver.cardno=tCard.cardno; des2src(cardver.accdate,pAccTrans->trans.accdate); cardver.termid=trans.termid; cardver.termseqno=trans.termseqno; cardver.status[0]=STATUS_NORMAL; des2src(cardver.cardphyid,cardinsteaddtl.oldcardphyid); des2src(cardver.stuempno,trans.stuempno); cardver.cardvertype=CARDVERTYPE_CARDINSTEADNEW; 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; } //使用卡片 des2src(tCard.cardphyid,trans.cardphyid); des2src(tCard.showcardno,trans.showcardno); des2src(tCard.lastsaved,trans.sysdatetime); des2src(tCard.cardverno,cardver.cardverno); tCard.status[0]=STATUS_NORMAL; ret=DB_t_card_add(&tCard); if(ret) { if(DB_NOTFOUND==ret) return E_NOTEXIST_CARDNO; else return E_DB_CARD_U; } tCardAccount.cardno=tCard.cardno; tCardAccount.dpscnt=0; tCardAccount.paycnt=0; strcpy(tCardAccount.transtime,trans.sysdatetime); ret=DB_t_account_update_by_accno(tCard.accno,&tCardAccount); if(ret) { if(DB_NOTFOUND==ret) return E_DB_ACCOUNT_N; else return E_DB_ACCOUNT_R; } //插入卡位图表 T_t_cardbitmap tCardBitmap; memset(&tCardBitmap,0,sizeof(tCardBitmap)); tCardBitmap.cardno=tCard.cardno; tCardBitmap.baseno=0; memset(tCardBitmap.bitmap0,'0',sizeof(tCardBitmap.bitmap0)-1); memset(tCardBitmap.bitmap1,'0',sizeof(tCardBitmap.bitmap1)-1); memset(tCardBitmap.bitmap2,'0',sizeof(tCardBitmap.bitmap2)-1); memset(tCardBitmap.bitmap3,'0',sizeof(tCardBitmap.bitmap3)-1); memset(tCardBitmap.bitmap4,'0',sizeof(tCardBitmap.bitmap4)-1); memset(tCardBitmap.bitmap5,'0',sizeof(tCardBitmap.bitmap5)-1); memset(tCardBitmap.bitmap6,'0',sizeof(tCardBitmap.bitmap6)-1); memset(tCardBitmap.bitmap7,'0',sizeof(tCardBitmap.bitmap7)-1); memset(tCardBitmap.bitmap8,'0',sizeof(tCardBitmap.bitmap8)-1); memset(tCardBitmap.bitmap9,'0',sizeof(tCardBitmap.bitmap9)-1); ret=DB_t_cardbitmap_add(&tCardBitmap); if (ret) { if (DB_REPEAT==ret) return E_DB_CARDBITMAP_E; else return E_DB_CARDBITMAP_I; } T_t_transdtl transdtl; memset(&transdtl,0,sizeof(transdtl)); 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.exttype=EXTTYPE_NEWCARD; sprintf(transdtl.extdata,"%d",tCard.cardno); transdtl.purseno=trans.purseno; transdtl.cardcnt=cardinsteaddtl.oldcardcnt; transdtl.cardbefbal=cardinsteaddtl.oldcardbal; transdtl.cardaftbal=cardinsteaddtl.oldcardbal; transdtl.managefee=trans.totalfeeamt; transdtl.amount=trans.totaltransamt; transdtl.custid=tCard.custid; des2src(transdtl.custname,customer.custname); des2src(transdtl.stuempno,customer.stuempno); des2src(transdtl.opercode,trans.opercode); transdtl.status[0]=DTLSTATUS_SUCCESS; des2src(transdtl.showcardno,tCard.showcardno); ret=DB_t_transdtl_add(&transdtl); if(ret) { if(DB_REPEAT==ret) return E_DB_TRANSDTL_E; else return E_DB_TRANSDTL_I; } outPack->lvol1=tCard.custid; outPack->lsafe_level2=customer.custtype; outPack->lvol5=tCard.feetype; des2src(outPack->sall_name,customer.custname); des2src(outPack->spager,customer.stuempno); des2src(outPack->scert_no,customer.deptcode); des2src(outPack->semail2,customer.idno); des2src(outPack->smarket_code,customer.sex); des2src(outPack->sdate0,tCard.expiredate); sprintf(outPack->sholder_ac_no,"%d",10); //发行方标识 des2src(outPack->smarket_code2,customer.idtype); outPack->lsafe_level=tCard.cardtype; outPack->lvol0=tCard.cardno; outPack->lvol4=cardinsteaddtl.oldsubsidyno; outPack->lvol8=(int)(cardinsteaddtl.oldcardbal*100); outPack->lvol11=D4U5(tCardAccount.singlemaxamt*100,0); outPack->lvol12=D4U5(tCardAccount.daycostmaxamt*100,0); outPack->lvol6=cardinsteaddtl.oldcardcnt; des2src(outPack->sorder0,tCard.showcardno); des2src(outPack->stx_pwd,cardpwd); des2src(outPack->sdate3,pAccTrans->trans.accdate); des2src(outPack->stime3,pAccTrans->trans.acctime); des2src(outPack->semp,trans.opercode); outPack->lwithdraw_flag=trans.termid; outPack->lserial1=trans.termseqno; des2src(outPack->sname2,cardver.cardverno); PutRow(handle,outPack,pRetCode,szMsg); return 0; }
static int SaveOldCardInfo(TRUSERID *handle,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; CAccTrans *pAccTrans=CAccTrans::getInstance(); TRANS& trans=pAccTrans->trans; T_t_card tCard; memset(&tCard,0,sizeof(tCard)); ret=DB_t_card_read_by_cardno(trans.cardno,&tCard); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CARDNO,trans.cardno); else return E_DB_CARD_R; } if(tCard.status[0]!=STATUS_NORMAL) { return ERRINFO(E_CARD_LOGOUT,trans.cardno); } if('1'==tCard.frozeflag[0]) { return ERRINFO(E_CARD_FREEZE,trans.cardno); } if('1'==tCard.lossflag[0]) { return ERRINFO(E_CARD_LOST,trans.cardno); } if('1'==tCard.badflag[0]) { return ERRINFO(E_CARD_BADRECORD,trans.cardno); } //比较卡物理ID是否相同 if(strcmp(tCard.cardphyid,trans.cardphyid)!=0) { writelog(LOG_ERR,"db cardphyid[%s],input cardphyid[%s]",tCard.cardphyid,trans.cardphyid); return E_CARD_PHYNO_DIFFER; } T_t_account tCardAccount; memset(&tCardAccount,0,sizeof(tCardAccount)); ret=DB_t_account_read_by_accno(tCard.accno,&tCardAccount); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CARDACCNO,tCard.accno); else return E_DB_ACCOUNT_R; } int existflag=0; ret=IsExistUnGetSubsidy(tCard.cardno,&existflag); if(ret) { return ret; } if(existflag) { ERRTIP("有未领补助,请领取补助后再换卡"); return E_COMMON_ERR; } ret=DB_t_cardinsteaddtl_del_by_cardno(trans.cardno); if(ret) { if(DB_NOTFOUND!=ret) return E_DB_CARDINSTEADDTL_R; } T_t_cardinsteaddtl cardinsteaddtl; memset(&cardinsteaddtl,0,sizeof(cardinsteaddtl)); des2src(cardinsteaddtl.accdate,pAccTrans->trans.accdate); cardinsteaddtl.termid = trans.termid; cardinsteaddtl.termseqno = trans.termseqno; cardinsteaddtl.cardno = trans.cardno; cardinsteaddtl.oldcardtype=tCard.cardtype; des2src(cardinsteaddtl.oldcardphyid,trans.cardphyid); des2src(cardinsteaddtl.oldshowcardno,tCard.showcardno); cardinsteaddtl.oldcardcnt = trans.paycnt; cardinsteaddtl.oldcardbal = trans.cardbefbal; cardinsteaddtl.oldsubsidyno=trans.cardsubsidyno; cardinsteaddtl.revflag[0]='0'; cardinsteaddtl.status[0]=STATUS_NORMAL; ret=DB_t_cardinsteaddtl_add(&cardinsteaddtl); if(ret) { if(DB_REPEAT==ret) return E_DB_CARDINSTEADDTL_E; else return E_DB_CARDINSTEADDTL_I; } T_t_cardver cardver; memset(&cardver,0,sizeof(cardver)); cardver.cardno=tCard.cardno; des2src(cardver.accdate,pAccTrans->trans.accdate); cardver.termid=trans.termid; cardver.termseqno=trans.termseqno; cardver.status[0]=STATUS_NORMAL; des2src(cardver.cardphyid,cardinsteaddtl.cardphyid); des2src(cardver.stuempno,trans.stuempno); cardver.cardvertype=CARDVERTYPE_CARDINSTEADOLD; 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; } ST_CPACK aPack; ST_PACK *outPack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LWITHDRAW_FLAG,F_LSERIAL1,F_VSMESS,F_SDATE3,F_STIME3,0); des2src(outPack->semp,trans.opercode); des2src(outPack->sdate3,pAccTrans->trans.accdate); des2src(outPack->stime3,pAccTrans->trans.acctime); outPack->lwithdraw_flag=trans.termid; outPack->lserial1=trans.termseqno; PutRow(handle,outPack,pRetCode,szMsg); return 0; }
int F846310(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; CAccTrans *pAccTrans=CAccTrans::getInstance(); // ret=pAccTrans->checkCfgUpdate(); // if(ret) // return ret; des2src(pAccTrans->trans.opercode,rPack->semp); pAccTrans->trans.transcode=TC_CARDRETURN; ret=pAccTrans->InitTrans(); if(ret) return ret; TRANS& trans=pAccTrans->trans; char anonymflag[2]=""; int returnForgiftFlag=0; ST_CPACK aPack; ST_PACK *outPack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); //检查客户 trans.cardflag=1; trans.usecardflag=1; trans.cardno=rPack->lvol0; trans.purseno=PURSE_NO_ONE; trans.paycnt = rPack->lvol6+1; trans.cardbefbal=rPack->lvol7/100.0; trans.cardaftbal=trans.cardbefbal; des2src(trans.cardphyid,rPack->sstation0); T_t_card tCard; memset(&tCard,0,sizeof(tCard)); ret=doCard(trans,tCard); if(ret) { return ret; } ret=UpdateCardBitmap(trans.cardno,trans.paycnt,CARDBITMAPTYPE_SYS_ONLINE); if(ret) return ret; T_t_account tCardAccount; memset(&tCardAccount,0,sizeof(tCardAccount)); ret=DB_t_account_read_by_accno(tCard.accno,&tCardAccount); if(ret) { writelog(LOG_ERR,"cardno[%d]",tCard.cardno); if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CARDACCNO,tCard.accno); else return E_DB_ACCOUNT_R; } if(tCardAccount.status[0]!=STATUS_NORMAL) { return ERRINFO(E_CARDACC_LOGOUT,tCardAccount.accno); } if(amtcmp(tCardAccount.balance,0)<0) { ERRTIP("账户余额小于0不能直接回收"); return E_COMMON_ERR; } else if(amtcmp(tCardAccount.balance,0)==0) { trans.cardaftbal=0; } else { strcpy(trans.cardaccno,tCardAccount.accno); trans.feetype=tCard.feetype; trans.inputamt=tCardAccount.balance; trans.unusedamt = trans.inputamt; ret=pAccTrans->doTrans(); if(ret) return ret; ret=pAccTrans->doTransEnd(); if(ret) return ret; //修改帐户 ret=doAccount(trans,tCardAccount.accno); if(ret) return ret; } T_t_customer tCustomer; memset(&tCustomer,0,sizeof(tCustomer)); if(tCard.custid>0) { ret=DB_t_customer_read_by_custid(tCard.custid,&tCustomer); if(ret) { if(DB_NOTFOUND==ret) return E_NOTEXIST_CUSTOMER; else return E_DB_CUSTOMER_R; } } T_t_transdtl transdtl; memset(&transdtl,0,sizeof(transdtl)); strcpy(transdtl.transdate,trans.transdate); strcpy(transdtl.transtime,trans.transtime); strcpy(transdtl.accdate,trans.accdate); strcpy(transdtl.acctime,trans.acctime); transdtl.termid=trans.termid; transdtl.termseqno=trans.termseqno; // des2src(transdtl.collectdate,rPack->sdate1); // des2src(transdtl.collecttime,rPack->stime1); transdtl.transcode=trans.transcode; // transdtl.paytype=rPack->lvol9; // des2src(transdtl.voucherno,rPack->scust_auth2); transdtl.cardno=trans.cardno; transdtl.purseno=PURSE_NO_ONE; transdtl.transflag=TF_PAY; transdtl.cardcnt=trans.paycnt; transdtl.cardbefbal=trans.cardbefbal; transdtl.cardaftbal=trans.cardaftbal; transdtl.amount=trans.totaltransamt; transdtl.managefee=trans.totalfeeamt; //// transdtl.frontno=0; //des2src(transdtl.devphyid,rPack->sname); //transdtl.devseqno=rPack->lserial0; //des2src(transdtl.bankcode,rPack->sbank_code); //des2src(transdtl.bankcardno,rPack->scard0); //des2src(transdtl.mobile,rPack->sphone2); des2src(transdtl.opercode,trans.opercode); transdtl.status[0]=DTLSTATUS_SUCCESS; transdtl.revflag[0]='0'; transdtl.errcode=0; transdtl.custid=tCardAccount.custid; des2src(transdtl.showcardno,tCard.showcardno); GetCustBaseInfoByCustID(transdtl.custid,transdtl.custname,transdtl.stuempno,NULL); ret=DB_t_transdtl_add(&transdtl); if(ret) { if(DB_REPEAT==ret) return E_DB_TRANSDTL_E; else return E_DB_TRANSDTL_I; } SetCol(handle,F_LVOL1,F_LSAFE_LEVEL2,F_LVOL5,F_LVOL6, F_SALL_NAME,F_SPAGER,F_SCERT_NO,F_SHOLDER_AC_NO,F_LSAFE_LEVEL,F_SMARKET_CODE2, F_SEMAIL2,F_SMARKET_CODE,F_SDATE0,F_SNOTE, F_SSTAT_TYPE,F_SSTAT_TYPE2,F_SNATION_CODE,F_SBRANCH_CODE0, F_LVOL0,F_STX_PWD,F_LVOL8,F_LVOL11,F_LVOL12, F_SORDER0,F_SORDER1,F_SORDER2,F_SDATE3,F_STIME3,F_SEMP, F_LWITHDRAW_FLAG,F_LSERIAL1,F_VSMESS,F_SNAME2,0); outPack->lvol1=tCustomer.custid; outPack->lsafe_level2=tCustomer.custtype; outPack->lvol5=tCard.feetype; des2src(outPack->sall_name,tCustomer.custname); des2src(outPack->spager,tCustomer.stuempno); des2src(outPack->scert_no,tCustomer.deptcode); des2src(outPack->semail2,tCustomer.idno); des2src(outPack->smarket_code,tCustomer.sex); des2src(outPack->smarket_code2,tCustomer.idtype); outPack->lsafe_level=tCard.cardtype; des2src(outPack->sdate0,tCard.expiredate); outPack->lvol0=tCard.cardno; outPack->lvol6=trans.paycnt; des2src(outPack->stx_pwd,tCard.cardpwd); des2src(outPack->sorder0,tCard.showcardno); des2src(outPack->sname2,tCard.cardverno); // des2src(outPack->sorder0,tCard.showcardno); strcpy(outPack->snote,CARD_STRUCT_VERSION); //制卡版本号 strcpy(outPack->sorder1,CARD_REGISTER_PUBLISH_CODE); //发卡注册标识号 strcpy(outPack->sorder2,CARD_REGISTER_SERVICE_CODE); //服务注册标识号 outPack->lvol8=D4U5(pAccTrans->trans.cardaftbal*100,0); outPack->lvol11=D4U5(tCardAccount.singlemaxamt*100,0); outPack->lvol12=D4U5(tCardAccount.daycostmaxamt*100,0); sprintf(outPack->sholder_ac_no,"%d",tCustomer.custid); //客户号 des2src(outPack->sstat_type,tCustomer.idtype); //证件类型 des2src(outPack->snation_code,tCustomer.country); //国籍 des2src(outPack->sstat_type2,tCustomer.nation); //民族 des2src(outPack->sbranch_code0,tCustomer.areacode); //院校代码 des2src(outPack->sdate3,pAccTrans->trans.accdate); des2src(outPack->stime3,pAccTrans->trans.acctime); des2src(outPack->semp,trans.opercode); outPack->lwithdraw_flag=trans.termid; outPack->lserial1=trans.termseqno; sprintf(trans.remark,"%s卡余额%.2lf元",pAccTrans->remark.c_str(),pAccTrans->trans.cardaftbal); des2src(outPack->vsmess,trans.remark); PutRow(handle,outPack,pRetCode,szMsg); return 0; }
static int doCard(TRANS& trans,T_t_card& tCard) { int ret=0; ret=DB_t_card_read_lock_by_cur_and_cardno(trans.cardno,&tCard); if(ret) { writelog(LOG_ERR,"cardno[%d]",trans.cardno); if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CARDNO,trans.cardno); else return E_DB_CARD_R; } if(tCard.status[0]!=STATUS_NORMAL) { DB_t_card_free_lock_by_cur(); return ERRINFO(E_CARD_LOGOUT,trans.cardno); } if('1'==tCard.frozeflag[0]) { DB_t_card_free_lock_by_cur(); return ERRINFO(E_CARD_FREEZE,trans.cardno); } if('1'==tCard.lossflag[0]) { DB_t_card_free_lock_by_cur(); return ERRINFO(E_CARD_LOST,trans.cardno); } if('1'==tCard.badflag[0]) { DB_t_card_free_lock_by_cur(); return ERRINFO(E_CARD_BADRECORD,trans.cardno); } //比较卡物理ID是否相同 if(strcmp(tCard.cardphyid,trans.cardphyid)!=0) { writelog(LOG_ERR,"db cardphyid[%s],input cardphyid[%s]",tCard.cardphyid,trans.cardphyid); DB_t_card_free_lock_by_cur(); return ERRINFO(E_CARD_PHYNO_DIFFER,trans.cardphyid,tCard.cardphyid); } //回收卡 T_t_cardtype tCardType; memset(&tCardType,0,sizeof(tCardType)); ret=DB_t_cardtype_read_by_cardtype(tCard.cardtype,&tCardType); if(tCardType.recycleable[0]!='1') { DB_t_card_free_lock_by_cur(); return ERRINFO(E_CARDTYPE_CANNOT_REUSE,tCardType.cardtype); } if(tCardType.fixdaycnt<1) { DB_t_card_free_lock_by_cur(); return ERRINFO(E_NOSET_CARDTYPE_VALIDDAYS,tCardType.cardtype); } ret=calcEndDate(trans.transdate,tCardType.fixdaycnt,tCard.expiredate); if(ret) { DB_t_card_free_lock_by_cur(); return ret; } char cardpwd[33]=""; char key[17]=""; get_init_passwd_by_man_id("",cardpwd); strcpy(key,STATIC_SEED_KEY); EncodePwd(key,cardpwd,tCard.cardpwd, 0); // memset(tCard.cardstatus,'0',sizeof(tCard.cardstatus)); des2src(tCard.lastsaved,trans.sysdatetime); ret=DB_t_card_update_lock_by_cur(&tCard); if(ret) { if(DB_NOTFOUND==ret) return E_DB_CARD_N; else return E_DB_CARD_U; } //用来输出卡密码 strcpy(tCard.cardpwd,cardpwd); /* //添加卡片回收明细记录 T_t_carddtl tCarddtl; memset(&tCarddtl,0,sizeof(tCarddtl)); /////////////////////////////////rPack2TableStuct//////////////////////// des2src(tCarddtl.accdate,pAccTrans->sysPara.sSettleDate); tCarddtl.termid=trans.termid; tCarddtl.termseqno=trans.termseqno; tCarddtl.cardtype=tCard.cardtype; des2src(tCarddtl.showcardno,tCard.showcardno); des2src(tCarddtl.cardphyid,tCard.cardphyid); tCarddtl.cardusetype=CARDUSETYPE_RETURNCARD; des2src(tCarddtl.opercode,trans.opercode); ret=DB_t_carddtl_add(&tCarddtl); if(ret) { if(DB_REPEAT==ret) return E_DB_CARDDTL_E; else return E_DB_CARDDTL_I; } */ return 0; }
int F846340(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; CAccTrans *pAccTrans=CAccTrans::getInstance(); TRANS& trans=pAccTrans->trans; trans.transcode=TC_EACC2SHOP; trans.transtype = TRANSTYPE_EACCPAYMENT; // 支付交易 //trans.termid=TERMID_WEB; trans.termid=rPack->lcert_code; // 使用支付网关的注册ID ret=pAccTrans->InitTrans(); if(ret) return ret; trans.inputamt=D4U5(rPack->damt0,2); trans.unusedamt = trans.inputamt; trans.transamt=trans.inputamt; if(amtcmp(trans.inputamt,0)==0) return E_INPUT_AMT_NULL; if(amtcmp(trans.inputamt,0)<0) return E_INPUT_AMT; //查询电子钱包帐户 T_t_netacc tNetAccount; memset(&tNetAccount,0,sizeof(tNetAccount)); ret=DB_t_netacc_read_by_accno(rPack->scust_no,&tNetAccount); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_EACCNO,rPack->scust_no); else return E_DB_ACCOUNT_R; } //检查电子钱包密码 if(rPack->lvol1 == 0) { // 检查电子账户密码 检查账户余额 if(strcmp(rPack->snote2,tNetAccount.paypwd)!=0) return E_EACCPWD; } if(tNetAccount.status[0]!=STATUS_NORMAL) // 账户状态 return ERRINFO(E_EACCNO_LOGOUT,tNetAccount.accno); if(tNetAccount.stoppayflag[0]=='1') // 止付标志 return ERRINFO(E_EACC_STOPPAY,tNetAccount.accno); if(rPack->lvol1 == 0) { // 检查电子账户密码 检查账户余额 if(amtcmp(trans.inputamt,tNetAccount.balance)>0) return ERRINFO(E_EACC_BALANCE_SHORTAGE,trans.inputamt-tNetAccount.balance); } /* 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); */ des2src(trans.draccno,tNetAccount.accno); trans.custid=tNetAccount.custid; des2src(trans.custname,tNetAccount.accname); // 支付转账 T_t_shop shop; memset(&shop,0,sizeof(shop)); ret=DB_t_shop_read_by_shopid(rPack->lvol0,&shop); if(ret) { if(DB_NOTFOUND==ret) return E_NOTEXIST_SHOPID; else return E_DB_SHOP_R; } if(shop.status[0]!=STATUS_NORMAL) return E_SHOP_LOGOUT; if(shop.shoptype!=SHOPTYPE_ESHOP) return ERRIF_SHOP_TYPE; des2src(trans.craccno,shop.accno); // 产生交易参考号 T_t_refno tRefno; memset(&tRefno,0,sizeof(tRefno)); get_random(tRefno.mac); ret= GetNewRefno(tRefno.refno); if(ret) return ret; des2src(tRefno.lastsaved,trans.sysdatetime); des2src(tRefno.accdate,trans.accdate); tRefno.termid = trans.termid; tRefno.termseqno = trans.termseqno; tRefno.status = RS_SUCC; ret=DB_t_refno_add(&tRefno); if(ret) { if(DB_REPEAT==ret) return E_DB_REFNO_E; else return E_DB_REFNO_I; } des2src(trans.refno, tRefno.refno); ret=pAccTrans->doTrans(); if(ret) return ret; // 添加电子账户支付信息 T_t_epay_record t_epay_record; memset(&t_epay_record,0,sizeof(t_epay_record)); des2src(t_epay_record.refno, tRefno.refno); t_epay_record.shopid = shop.shopid; des2src(t_epay_record.oid, rPack->sbankname); des2src(t_epay_record.accno,tNetAccount.accno); des2src(t_epay_record.accname,tNetAccount.accname); t_epay_record.amount = trans.inputamt; des2src(t_epay_record.currency,rPack->sstock_code); des2src(t_epay_record.epay_date,trans.accdate); des2src(t_epay_record.epay_time,trans.acctime); t_epay_record.status = 1; // 交易成功 t_epay_record.transcode = trans.transcode; des2src(t_epay_record.remark,rPack->snote); ret=DB_t_epay_record_add(&t_epay_record); if(ret) return ret; // 添加交易流水 T_t_transdtl transdtl; memset(&transdtl,0,sizeof(transdtl)); des2src(transdtl.refno,tRefno.refno); // 交易参考号 des2src(transdtl.transdate,trans.accdate); des2src(transdtl.transtime,trans.acctime); strcpy(transdtl.accdate,trans.accdate); strcpy(transdtl.acctime,trans.acctime); transdtl.termid=trans.termid; transdtl.termseqno=trans.termseqno; transdtl.transcode=trans.transcode; transdtl.transflag=TF_PAY; transdtl.managefee=trans.totalfeeamt; des2src(transdtl.custname,tNetAccount.accname); transdtl.amount = trans.inputamt; des2src(transdtl.opercode,trans.opercode); transdtl.cardbefbal = trans.draccbefbal; transdtl.cardaftbal = trans.draccaftbal; des2src(transdtl.coldate,trans.accdate); des2src(transdtl.coltime,trans.acctime); transdtl.status[0]=DTLSTATUS_SUCCESS; transdtl.revflag[0]='0'; transdtl.custid=tNetAccount.custid; 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; } ST_CPACK aPack; ST_PACK *outPack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LVOL0,F_SCUST_NO, F_SDATE0,F_STIME0, F_DAMT0,F_SPHONE3,F_SADDR,F_VSMESS,0); outPack->lvol0=shop.shopid; des2src(outPack->scust_no,tNetAccount.accno); des2src(outPack->sdate0,trans.accdate); des2src(outPack->stime0,trans.acctime); des2src(outPack->sphone3,tRefno.refno); // 一卡通流水号,冲正使用 des2src(outPack->saddr,tRefno.mac); // MAC 冲正使用 outPack->damt0=trans.draccaftbal; // 余额 char temp[128]=""; sprintf(temp,"%s 支付成功,电子钱包余额:%.2f", tNetAccount.accname, trans.draccaftbal); pAccTrans->remark+=temp; strcpy(outPack->vsmess,pAccTrans->remark.c_str()); des2src(trans.remark,outPack->vsmess); PutRow(handle,outPack,pRetCode,szMsg); return 0; }
int F850020(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; CAccTrans *pAccTrans=CAccTrans::getInstance(); TRANS& trans=pAccTrans->trans; 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); trans.cardflag=1; trans.usecardflag=1; trans.cardno=rPack->lvol0; trans.purseno=PURSE_NO_ONE; trans.dpscnt=rPack->lvol5+1; trans.cardbefbal=rPack->lvol7/100.0; trans.cardaftbal=trans.cardbefbal; des2src(trans.cardphyid,rPack->sstation1); double waterbefbal = D4U5(rPack->lsafe_level/100.0); double wateraftbal = 0; trans.inputamt= waterbefbal; T_t_pursetype pursetype; memset(&pursetype,0,sizeof(pursetype)); pursetype.pursetype=rPack->lvol1; if(pursetype.pursetype<1) { ERRTIP("请输入小钱包类型"); return E_COMMON_ERR; } ret=DB_t_pursetype_read_by_pursetype(pursetype.pursetype,&pursetype); if(ret) { if(DB_NOTFOUND==ret) { ERRTIP("钱包类型[%d]不存在",pursetype.pursetype); return E_COMMON_ERR; } else return E_DB_PURSETYPE_R; } if(!pursetype.enableflag) { ERRTIP("钱包类型[%d]未启用",pursetype.pursetype); return E_COMMON_ERR; } if(!pursetype.refundflag) { ERRTIP("钱包类型[%d]不允许退款",pursetype.pursetype); return E_COMMON_ERR; } if(amtcmp(trans.inputamt,pursetype.pursemaxbal)>0) trans.inputamt=pursetype.pursemaxbal; T_t_card tCard; memset(&tCard,0,sizeof(tCard)); T_t_account tAccount; memset(&tAccount,0,sizeof(tAccount)); ret=pAccTrans->CheckAcc(&tCard,&tAccount); if(ret) { writelog(LOG_ERR,"检查状态失败"); return ret; } T_t_cardbalance cardbalance; memset(&cardbalance,0,sizeof(cardbalance)); ret=DB_t_cardbalance_read_lock_by_c0_and_accno_and_pursetype(tAccount.accno,pursetype.pursetype,&cardbalance); if(ret) { if(DB_NOTFOUND==ret) return E_DB_CARDBALANCE_N; else return E_DB_CARDBALANCE_R; } if(rPack->lvol2) { //有卡 if(amtcmp(trans.inputamt,cardbalance.balance)>0) trans.inputamt=cardbalance.balance; } else { //无卡 if(amtcmp(cardbalance.cardbal,cardbalance.balance)>0) trans.inputamt=cardbalance.balance; else trans.inputamt=cardbalance.cardbal; } cardbalance.balance =D4U5(cardbalance.balance - trans.inputamt); cardbalance.cardbal=0; // cardbalance.paycnt; if(rPack->lvol4) cardbalance.paycnt = rPack->lvol4-1; des2src(cardbalance.transdate,trans.transdate); des2src(cardbalance.transtime,trans.transtime); ret=DB_t_cardbalance_update_lock_by_c0(&cardbalance); if(ret) { return E_DB_CARDBITMAP_U; } double CardMaxBal=0; ret=GetPurseMaxBal(PURSE_NO_ONE,CardMaxBal); if(ret) return ret; if(amtcmp(trans.cardbefbal+rPack->lsafe_level,CardMaxBal)>0) return ERRINFO(E_AMT_EXCEED_MAX,CardMaxBal); trans.feetype=tCard.feetype; trans.custid=tCard.custid; trans.transamt=trans.inputamt; trans.unusedamt = trans.inputamt; if(pursetype.onlineflag) { //联机水控退款 pAccTrans->trans.transtype=TRANSTYPE_WATERREFUND; ret=pAccTrans->DoTransByTransType(); if(ret) return ret; ret=pAccTrans->doTransEnd(); if(ret) return ret; } else { if(pursetype.shopid<1) { ERRTIP("钱包类型[%d]没有设置对应的水控商户",pursetype.pursetype); return E_COMMON_ERR; } //否则脱机水控 int shoptype=0; char shopstatus[2]={0}; ret=ShopAccReadbyShopid(pursetype.shopid,trans.shopaccno,&shoptype,shopstatus); if(ret) { writelog(LOG_ERR,"shopid[%d]",pursetype.shopid); return ret; } if(shopstatus[0]!=STATUS_NORMAL) return ERRIF_SHOP_CLOSE; if(shoptype!=SHOPTYPE_COSUMESHOP) return ERRIF_SHOP_TYPE; pAccTrans->trans.transtype=TRANSTYPE_SHOPREFUND; ret=pAccTrans->DoTransByTransType(); if(ret) return ret; ret=pAccTrans->doTransEnd(); if(ret) return ret; } 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.transflag= TF_DPS; transdtl.cardcnt=trans.dpscnt; 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; } T_t_pursetransdtl pursetransdtl; memset(&pursetransdtl,0,sizeof(pursetransdtl)); des2src(pursetransdtl.refno,transdtl.refno); des2src(pursetransdtl.transdate,transdtl.transdate); des2src(pursetransdtl.transtime,transdtl.transtime); strcpy(pursetransdtl.accdate,transdtl.accdate); strcpy(pursetransdtl.acctime,transdtl.acctime); pursetransdtl.termid=transdtl.termid; pursetransdtl.termseqno=transdtl.termseqno; pursetransdtl.transcode=transdtl.transcode; pursetransdtl.cardno=transdtl.cardno; pursetransdtl.pursetype=pursetype.pursetype; pursetransdtl.transflag= TF_PAY; pursetransdtl.cardcnt=cardbalance.paycnt; pursetransdtl.cardbefbal=waterbefbal; pursetransdtl.cardaftbal=wateraftbal; pursetransdtl.amount=transdtl.amount; pursetransdtl.custid=transdtl.custid; des2src(pursetransdtl.custname,transdtl.custname); des2src(pursetransdtl.opercode,transdtl.opercode); pursetransdtl.status[0]=transdtl.status[0]; des2src(pursetransdtl.showcardno,trans.showcardno); des2src(pursetransdtl.stuempno,transdtl.stuempno); ret=DB_t_pursetransdtl_add(&pursetransdtl); if(ret) { if(DB_REPEAT==ret) return E_DB_PURSETRANSDTL_E; else return E_DB_PURSETRANSDTL_I; } outPack->lvol0=tCard.cardno; outPack->lvol9=D4U5(pAccTrans->trans.cardaftbal*100,0); outPack->lvol8=D4U5(pAccTrans->trans.totaltransamt*100,0); outPack->lsafe_level=D4U5(wateraftbal*100,0); outPack->lsafe_level2=0; des2src(outPack->sdate3,pAccTrans->trans.accdate); des2src(outPack->stime3,pAccTrans->trans.acctime); des2src(outPack->semp,trans.opercode); outPack->lwithdraw_flag=trans.termid; outPack->lserial1=trans.termseqno; sprintf(trans.remark,"%s卡余额%.2lf元",pAccTrans->remark.c_str(),pAccTrans->trans.cardaftbal); des2src(outPack->vsmess,trans.remark); PutRow(handle,outPack,pRetCode,szMsg); return 0; }
const char *SocketErrorDesc(int code) { switch(code) { #define ERRINFO(code, desc) case code: return desc " (" #code ")"; ERRINFO(WSAEINTR, "Interrupted function call.") ERRINFO(WSAEACCES, "Permission denied.") ERRINFO(WSAEFAULT, "Bad address.") ERRINFO(WSAEINVAL, "Invalid argument.") ERRINFO(WSAEMFILE, "Too many open files.") ERRINFO(WSAEWOULDBLOCK, "Resource temporarily unavailable.") ERRINFO(WSAEINPROGRESS, "Operation now in progress.") ERRINFO(WSAEALREADY, "Operation already in progress.") ERRINFO(WSAENOTSOCK, "Socket operation on nonsocket.") ERRINFO(WSAEDESTADDRREQ, "Destination address required.") ERRINFO(WSAEMSGSIZE, "Message too long.") ERRINFO(WSAEPROTOTYPE, "Protocol wrong type for socket.") ERRINFO(WSAENOPROTOOPT, "Bad protocol option.") ERRINFO(WSAEPROTONOSUPPORT, "Protocol not supported.") ERRINFO(WSAESOCKTNOSUPPORT, "Socket type not supported.") ERRINFO(WSAEOPNOTSUPP, "Operation not supported.") ERRINFO(WSAEPFNOSUPPORT, "Protocol family not supported.") ERRINFO(WSAEAFNOSUPPORT, "Address family not supported by protocol family.") ERRINFO(WSAEADDRINUSE, "Address already in use.") ERRINFO(WSAEADDRNOTAVAIL, "Cannot assign requested address.") ERRINFO(WSAENETDOWN, "Network is down.") ERRINFO(WSAENETUNREACH, "Network is unreachable.") ERRINFO(WSAENETRESET, "Network dropped connection on reset.") ERRINFO(WSAECONNABORTED, "Software caused connection abort.") ERRINFO(WSAECONNRESET, "Connection reset by peer.") ERRINFO(WSAENOBUFS, "No buffer space available.") ERRINFO(WSAEISCONN, "Socket is already connected.") ERRINFO(WSAENOTCONN, "Socket is not connected.") ERRINFO(WSAESHUTDOWN, "Cannot send after socket shutdown.") ERRINFO(WSAETIMEDOUT, "Connection timed out.") ERRINFO(WSAECONNREFUSED, "Connection refused.") ERRINFO(WSAEHOSTDOWN, "Host is down.") ERRINFO(WSAEHOSTUNREACH, "No route to host.") ERRINFO(WSAEPROCLIM, "Too many processes.") ERRINFO(WSASYSNOTREADY, "Network subsystem is unavailable.") ERRINFO(WSAVERNOTSUPPORTED, "Winsock.dll version out of range.") ERRINFO(WSANOTINITIALISED, "Successful WSAStartup not yet performed.") ERRINFO(WSAEDISCON, "Graceful shutdown in progress.") ERRINFO(WSATYPE_NOT_FOUND, "Class type not found.") ERRINFO(WSAHOST_NOT_FOUND, "Host not found.") ERRINFO(WSATRY_AGAIN, "Nonauthoritative host not found.") ERRINFO(WSANO_RECOVERY, "This is a nonrecoverable error.") ERRINFO(WSANO_DATA, "Valid name, no data record of requested type.") //ERRINFO(WSA_INVALID_HANDLE, "Specified event object handle is invalid.") //ERRINFO(WSA_INVALID_PARAMETER, "One or more parameters are invalid.") //ERRINFO(WSA_IO_INCOMPLETE, "Overlapped I/O event object not in signaled state.") //ERRINFO(WSA_IO_PENDING, "Overlapped operations will complete later.") //ERRINFO(WSA_NOT_ENOUGH_MEMORY, "Insufficient memory available.") //ERRINFO(WSA_OPERATION_ABORTED, "Overlapped operation aborted.") //ERRINFO(WSAINVALIDPROCTABLE, "Invalid procedure table from service provider.") //ERRINFO(WSAINVALIDPROVIDER, "Invalid service provider version number.") //ERRINFO(WSAPROVIDERFAILEDINIT, "Unable to initialize a service provider.") ERRINFO(WSASYSCALLFAILURE, "System call failure.") #undef ERRINFO default: return "Unknown error code."; } }
int F846322(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; CAccTrans *pAccTrans=CAccTrans::getInstance(); TRANS& trans=pAccTrans->trans; des2src(pAccTrans->trans.opercode,rPack->semp); if(strlen(pAccTrans->trans.opercode)<1) { pAccTrans->trans.termid=rPack->lwithdraw_flag; } pAccTrans->trans.transcode=TC_CARDBALMOD; ret=pAccTrans->InitTrans(); if(ret) return ret; des2src(pAccTrans->trans.chkopercode,rPack->semp_no); ret=chk_oper_pwd(pAccTrans->trans.chkopercode,rPack->scust_limit); if(ret) return ret; trans.cardflag=1; trans.usecardflag=1; trans.cardno=rPack->lvol0; pAccTrans->SetCardCntAndCardBal(rPack->lvol5,rPack->lvol6,rPack->lvol7); des2src(trans.cardphyid,rPack->sstation1); if(rPack->lbank_acc_type>0) { trans.transamt=rPack->damt0; trans.transflag=TF_DPS; trans.aftdpscnt++; } else { trans.transamt=-rPack->damt0; trans.transflag=TF_PAY; trans.aftpaycnt++; } if(amtcmp(trans.transamt,0)==0) { ERRTIP("调整金额不能为0"); return E_COMMON_ERR; } trans.cardaftbal= D4U5(trans.cardbefbal+trans.transamt); T_t_card tCard; memset(&tCard,0,sizeof(tCard)); ret=doCard(trans,tCard); if(ret) { return ret; } trans.feetype=tCard.feetype; trans.cardtype=tCard.cardtype; T_t_account tCardAccount; memset(&tCardAccount,0,sizeof(tCardAccount)); ret=DB_t_account_read_lock_by_c0_and_accno(tCard.accno,&tCardAccount); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CARDACCNO,tCard.accno); else return E_DB_ACCOUNT_R; } if(tCardAccount.status[0]!=STATUS_NORMAL) { DB_t_account_free_lock_by_c0(); return ERRINFO(E_CARDACC_LOGOUT,tCardAccount.accno); } if(amtcmp(trans.cardbefbal,tCardAccount.availbal)==0) { DB_t_account_free_lock_by_c0(); ERRTIP("该卡余额与账户余额一致,不需要调整"); return E_COMMON_ERR; } if(amtcmp(trans.cardbefbal,tCardAccount.balance)==0) { DB_t_account_free_lock_by_c0(); ERRTIP("该卡余额与账户余额一致,不需要调整"); return E_COMMON_ERR; } if(amtcmp(trans.cardaftbal,tCardAccount.balance)>0) { DB_t_account_free_lock_by_c0(); ERRTIP("调整后卡余额不能大于账户余额"); return E_COMMON_ERR; } tCardAccount.dpscnt=trans.dpscnt; tCardAccount.paycnt=trans.paycnt; if(rPack->lbank_acc_type>0) tCardAccount.dpscnt=trans.aftdpscnt; if(rPack->lbank_acc_type<0) tCardAccount.paycnt=trans.aftpaycnt; tCardAccount.cardbal=trans.cardaftbal; strcpy(tCardAccount.transtime,trans.sysdatetime); ret=DB_t_account_update_lock_by_c0(&tCardAccount); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CARDACCNO,tCard.accno); else return E_DB_ACCOUNT_U; } trans.custid=tCard.custid; T_t_transdtl transdtl; memset(&transdtl,0,sizeof(transdtl)); 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.cardbefbal=trans.cardbefbal; transdtl.amount=trans.transamt; transdtl.managefee=trans.totalfeeamt; transdtl.cardaftbal=trans.cardaftbal; transdtl.custid=trans.custid; des2src(transdtl.opercode,trans.opercode); des2src(transdtl.showcardno,tCard.showcardno); GetCustBaseInfoByCustID(transdtl.custid,transdtl.custname,transdtl.stuempno,NULL); transdtl.status[0]=DTLSTATUS_SUCCESS; transdtl.transflag = trans.transflag; if(TF_DPS==transdtl.transflag) { transdtl.cardcnt=trans.aftdpscnt; } else { transdtl.cardcnt=trans.aftpaycnt; ret=UpdateCardBitmap(trans.cardno,transdtl.cardcnt,CARDBITMAPTYPE_SYS_ONLINE); if(ret) return ret; } ret=SaveCardTransInfo(); if(ret) { writelog(LOG_ERR,"SaveCardTransInfo ret=%d",ret); } ret=DB_t_transdtl_add(&transdtl); if(ret) { if(DB_REPEAT==ret) return E_DB_TRANSDTL_E; else return E_DB_TRANSDTL_I; } ST_CPACK aPack; ST_PACK *outPack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,F_LVOL0,F_LVOL8,F_SDATE0, F_SDATE3,F_STIME3,F_SEMP,F_LWITHDRAW_FLAG,F_LSERIAL1,F_VSMESS,0); outPack->lvol0=tCard.cardno; outPack->lvol8=D4U5(pAccTrans->trans.cardaftbal*100,0); des2src(outPack->sdate3,pAccTrans->trans.accdate); des2src(outPack->stime3,pAccTrans->trans.acctime); des2src(outPack->semp,trans.opercode); outPack->lwithdraw_flag=trans.termid; outPack->lserial1=trans.termseqno; sprintf(trans.remark,"%s卡余额%.2lf元",pAccTrans->remark.c_str(),pAccTrans->trans.cardaftbal); des2src(outPack->vsmess,trans.remark); PutRow(handle,outPack,pRetCode,szMsg); return 0; }
static int DoCheck(ST_PACK *rPack,T_t_shopcard& tShopCard,T_t_shop& tShop) { //检查卡是否已经使用 int ret=0; CAccTrans *pAccTrans=CAccTrans::getInstance(); TRANS& trans=pAccTrans->trans; des2src(tShopCard.cardphyid,rPack->sbank_acc); des2src(tShopCard.showcardno,rPack->sorder0); des2src(tShopCard.expiredate,rPack->sdate0); des2src(tShopCard.opendate,trans.accdate); des2src(tShopCard.lastsaved,trans.sysdatetime); tShopCard.status[0]=STATUS_NORMAL; tShopCard.lossflag[0]='0'; tShopCard.shopid =rPack->lvol0; if(!strlen(tShopCard.cardphyid)) return E_INPUT_CARDPHYID; if(!strlen(tShopCard.expiredate)) return E_INPUT_EXPIREDATE; //判断到期日期 ret=IsInvalidDateTime(tShopCard.expiredate,"YYYYMMDD"); if (ret) return ERRINFO(E_INPUT_EXPIREDATE,tShopCard.expiredate); if (strncmp(tShopCard.expiredate,trans.accdate,8)<0) return ERRINFO(E_INPUT_EXPIREDATE,tShopCard.expiredate); //检查商户 ret=DB_t_shop_read_by_shopid(tShopCard.shopid,&tShop); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_SHOPID,tShopCard.shopid); else return E_DB_SHOPCARD_R; } if(tShop.status[0]!=STATUS_NORMAL) { return ERRINFO(E_SHOP_LOGOUT,tShop.shopid); } char cardpwd[33]={0}; char key[17]={0}; get_init_passwd_by_man_id(tShop.idno,cardpwd); strcpy(key,STATIC_SEED_KEY); EncodePwd(key,cardpwd,tShopCard.cardpwd, 0); strcpy(trans.cardpwd,cardpwd);//临时保存密码 //检查是否存在商户卡 T_t_shopcard tShopCardCheck; memset(&tShopCardCheck,0,sizeof(tShopCardCheck)); ret=DB_t_shopcard_read_by_shopid_and_status(tShopCard.shopid,tShopCard.status,&tShopCardCheck); if(ret) { if(DB_NOTFOUND!=ret) return E_DB_SHOPCARD_R; } else { ERRTIP("该商户商户卡已发行"); return E_COMMON_ERR; } ret=DB_t_shopcard_read_by_cardphyid_and_status(tShopCard.cardphyid,tShopCard.status,&tShopCardCheck); if (ret!=DB_NOTFOUND) { if (DB_SUCCESS==ret) return ERRINFO(E_EXIST_CARDPHYID,tShopCard.cardphyid); else return E_DB_CARD_R; } return 0; }
int F846326(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; CAccTrans *pAccTrans=CAccTrans::getInstance(); TRANS& trans=pAccTrans->trans; des2src(pAccTrans->trans.opercode,rPack->semp); if(strlen(pAccTrans->trans.opercode)<1) { pAccTrans->trans.termid=rPack->lwithdraw_flag; } pAccTrans->trans.transcode=TC_WATERCARDBALMOD; ret=pAccTrans->InitTrans(); if(ret) return ret; des2src(pAccTrans->trans.chkopercode,rPack->semp_no); ret=chk_oper_pwd(pAccTrans->trans.chkopercode,rPack->scust_limit); if(ret) return ret; if(rPack->lbank_acc_type>0) trans.transamt=rPack->damt0; else trans.transamt=-rPack->damt0; trans.cardflag=1; trans.usecardflag=1; trans.cardno=rPack->lvol0; trans.purseno=PURSE_NO_TWO; trans.cardbefbal=rPack->lvol7/100.0; trans.cardaftbal= D4U5(trans.cardbefbal+trans.transamt); des2src(trans.cardphyid,rPack->sstation1); if(amtcmp(trans.transamt,0)==0) { ERRTIP("调整金额不能为0"); return E_COMMON_ERR; } double CardMaxBal=0; ret=GetPurseMaxBal(PURSE_NO_TWO,CardMaxBal); if(ret) return ret; if(amtcmp(trans.cardaftbal,CardMaxBal)>0) return ERRINFO(E_AMT_EXCEED_MAX,CardMaxBal); T_t_card tCard; memset(&tCard,0,sizeof(tCard)); ret=doCard(trans,tCard); if(ret) { return ret; } trans.feetype=tCard.feetype; trans.cardtype=tCard.cardtype; T_t_account tCardAccount; memset(&tCardAccount,0,sizeof(tCardAccount)); ret=DB_t_account_read_by_accno(tCard.accno,&tCardAccount); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CARDACCNO,tCard.accno); else return E_DB_ACCOUNT_R; } if(tCardAccount.status[0]!=STATUS_NORMAL) { return ERRINFO(E_CARDACC_LOGOUT,tCardAccount.accno); } trans.custid=tCard.custid; T_t_transdtl transdtl; memset(&transdtl,0,sizeof(transdtl)); 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.cardbefbal=trans.cardbefbal; transdtl.amount=trans.transamt; transdtl.managefee=trans.totalfeeamt; transdtl.cardaftbal=trans.cardaftbal; transdtl.custid=tCardAccount.custid; des2src(transdtl.custname,tCardAccount.accname); des2src(transdtl.opercode,trans.opercode); transdtl.showcardno=atol(tCard.showcardno); transdtl.status[0]=DTLSTATUS_SUCCESS; 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; } ST_CPACK aPack; ST_PACK *outPack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,F_LVOL0,F_LVOL8,F_LVOL10,F_LVOL11,F_LVOL12,F_SDATE0, F_SDATE3,F_STIME3,F_SEMP,F_LWITHDRAW_FLAG,F_LSERIAL1,F_VSMESS,0); int price1=0; int price2=0; int price3=0; ret=GetWaterPrice(price1,price2,price3); if(ret) { writelog(LOG_ERR,"读水价失败ret=%d",ret); return ret; } outPack->lvol10=price1; outPack->lvol11=price2; outPack->lvol12=price3; outPack->lvol0=tCard.cardno; outPack->lvol8=D4U5(pAccTrans->trans.cardaftbal*100,0); des2src(outPack->sdate0,pAccTrans->trans.accdate); des2src(outPack->sdate3,pAccTrans->trans.accdate); des2src(outPack->stime3,pAccTrans->trans.acctime); des2src(outPack->semp,trans.opercode); outPack->lwithdraw_flag=trans.termid; outPack->lserial1=trans.termseqno; sprintf(trans.remark,"%s卡余额%.2lf元",pAccTrans->remark.c_str(),pAccTrans->trans.cardaftbal); des2src(outPack->vsmess,trans.remark); PutRow(handle,outPack,pRetCode,szMsg); return 0; }
int F950043(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg) { int ret=0; int shopid=0; int rows=0; T_t_device tDevice; T_t_cfgshopfee cfgshopfee; char sysdate[9]; char systime[7]; ST_CPACK aPack; ST_PACK *out_pack; out_pack = &(aPack.pack); memset(&tDevice,0,sizeof tDevice); memset(sysdate,0,sizeof sysdate); memset(systime,0,sizeof systime); memset(&aPack,0,sizeof aPack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LVOL1,F_LVOL2,0); writelog(LOG_INFO,"950043 cpack:[%s]",CAccTrans::getInstance()->cpackdata); ret = DB_t_device_read_by_deviceid(in_pack->lvol0,&tDevice); if(ret) { if(DB_NOTFOUND == ret) return ERRINFO(E_NOTEXIST_DEVICE,in_pack->lvol0); else return E_DB_DEVICE_R; } if(tDevice.status[0]!=STATUS_NORMAL) return E_DEVICE_LOGOUT; int existcnt=0; getsysdate(sysdate); getsystime(systime); writelog(LOG_DEBUG,"device[%d]devphyid[%s],date[%s]time[%s]",in_pack->lvol0,tDevice.devphyid,sysdate,systime); ret = GetShopidByDevphyid(tDevice.devphyid,sysdate,systime,tDevice.deviceid,shopid); if(ret) { return ret; } ret=IsShopFeeCfgExist(shopid,existcnt); if(ret) return ret; if(!existcnt) { shopid=0; writelog(LOG_INFO,"该商户%d搭伙费参数不存在,取通用搭伙费参数",shopid); } ret = DB_t_cfgshopfee_open_select_by_c1_and_shopid(shopid); if(ret) { return E_DB_PREPARE; } while(1) { memset(&cfgshopfee,0,sizeof cfgshopfee); ret = DB_t_cfgshopfee_fetch_select_by_c1(&cfgshopfee); if(ret) { if(DB_NOTFOUND == ret) { if(!rows) return E_DB_CFGSHOPFEE_N; break; } else { return E_DB_CFGSHOPFEE_R; } } rows++; out_pack->lvol1 = cfgshopfee.feetype; out_pack->lvol2 = D4U5(cfgshopfee.feerate*100,0); PutRow(handle,out_pack,pRetCode,szMsg); writelog(LOG_INFO,"feetype[%d]feerate[%.4lf]", cfgshopfee.feetype,cfgshopfee.feerate); } return 0; }
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 F846336(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; CAccTrans *pAccTrans=CAccTrans::getInstance(); des2src(pAccTrans->trans.opercode,rPack->semp); int transflag=rPack->lvol3;; if(transflag) { pAccTrans->trans.transcode=TC_EACC2CARD; } else { pAccTrans->trans.transcode=TC_CARD2EACC; } 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); char key[17]=""; char pwd_plain[33]=""; char pwd_crypt[33]=""; strcpy(key,STATIC_SEED_KEY); des2src(pwd_plain,rPack->scust_limit); EncodePwd(key,pwd_plain,pwd_crypt, 0); trans.cardflag=1; pAccTrans->trans.usecardflag=1; trans.cardno=rPack->lvol0; trans.purseno=PURSE_NO_ONE; trans.cardcnt=rPack->lvol6+1; trans.cardbefbal=rPack->lvol7/100.0; trans.cardaftbal=trans.cardbefbal; trans.inputamt=D4U5(rPack->damt0,2); // transdtl.cardaftbal=rPack->lvol8; // transdtl.siteno=rPack->lcert_code; // transdtl.frontno=0; //des2src(transdtl.devphyid,rPack->sname); //transdtl.devseqno=rPack->lserial0; //des2src(transdtl.bankcode,rPack->sbank_code); //des2src(transdtl.bankcardno,rPack->scard0); //des2src(transdtl.mobile,rPack->sphone2); // des2src(transdtl.remark,rPack->ssectypes); //检查客户 des2src(trans.cardphyid,rPack->sstation0); T_t_card tCard; memset(&tCard,0,sizeof(tCard)); ret=doCard(tCard); if(ret) { return ret; } //查询卡帐户 T_t_account tCardAccount; memset(&tCardAccount,0,sizeof(tCardAccount)); ret=DB_t_account_read_by_cardno_and_purseno(trans.cardno,trans.purseno,&tCardAccount); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_CARDNO_PURSENO_NOACCNO,trans.cardno,trans.purseno); else return E_DB_ACCOUNT_R; } if(tCardAccount.status[0]!=STATUS_NORMAL) { return ERRINFO(E_CARDACC_LOGOUT,tCardAccount.accno); } //根据客户号查询电子钱包帐户 T_t_netacc tNetAccount; memset(&tNetAccount,0,sizeof(tNetAccount)); ret=DB_t_netacc_read_by_custid(tCardAccount.custid,&tNetAccount); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_EACCNO,tCardAccount.custid); else return E_DB_ACCOUNT_R; } if(tNetAccount.status[0]!=STATUS_NORMAL) return ERRINFO(E_EACCNO_LOGOUT,tNetAccount.accno); strcpy(trans.cardaccno,tCardAccount.accno); pAccTrans->trans.feetype=tCard.feetype; pAccTrans->trans.custid=tCard.custid; strcpy(pAccTrans->trans.cardaccno,tCardAccount.accno); strcpy(pAccTrans->trans.eaccno,tNetAccount.accno); if(TC_CARD2EACC==trans.transcode) { //检查卡密码 if(strcmp(tCard.cardpwd,pwd_crypt)!=0) { return E_CARDPWD; } if(amtcmp(pAccTrans->trans.inputamt,trans.cardbefbal)>0) return ERRINFO(E_CARD_BALANCE_SHORTAGE,trans.cardbefbal-pAccTrans->trans.inputamt); strcpy(pAccTrans->trans.draccno,tCardAccount.accno); strcpy(pAccTrans->trans.craccno,tNetAccount.accno); } else { char inpwd_crypt[65]=""; char seedkey[33]=""; 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,tNetAccount.accpwd,dbpwd_plain); if(ret) return E_PWD_DECRYPT; if(strcmp(inpwd_plain,dbpwd_plain)!=0) return E_EACCPWD; if(tNetAccount.stoppayflag[0]=='1') return ERRINFO(E_EACC_STOPPAY,tNetAccount.accno); if(amtcmp(pAccTrans->trans.inputamt,tNetAccount.balance)>0) return ERRINFO(E_EACC_BALANCE_SHORTAGE,pAccTrans->trans.inputamt-tNetAccount.balance); if(amtcmp(pAccTrans->trans.inputamt+trans.cardbefbal,tCardAccount.cardmaxbal)>0) return ERRINFO(E_AMT_EXCEED_MAX,tCardAccount.cardmaxbal); strcpy(pAccTrans->trans.draccno,tNetAccount.accno); strcpy(pAccTrans->trans.craccno,tCardAccount.accno); } pAccTrans->trans.feetype=0; pAccTrans->trans.usecardflag=1; pAccTrans->trans.custid=tCard.custid; ret=pAccTrans->doTrans(); if(ret) return ret; T_t_transdtl transdtl; memset(&transdtl,0,sizeof(transdtl)); des2src(transdtl.transdate,trans.sysdate); des2src(transdtl.transtime,trans.systime); strcpy(transdtl.accdate,trans.sysdate); strcpy(transdtl.acctime,trans.systime); transdtl.termid=trans.termid; transdtl.termseqno=trans.termseqno; transdtl.transcode=trans.transcode; transdtl.cardno=trans.cardno; transdtl.purseno=trans.purseno; transdtl.cardcnt=trans.cardcnt; transdtl.cardbefbal=trans.cardbefbal; transdtl.cardaftbal=pAccTrans->trans.cardaftbal; transdtl.managefee=trans.totalfeeamt; transdtl.amount=trans.totalfeeamt; des2src(transdtl.opercode,trans.opercode); transdtl.status[0]=DTLSTATUS_SUCCESS; transdtl.revflag[0]='0'; transdtl.showcardno=atol(tCard.showcardno); ret=DB_t_transdtl_add(&transdtl); if(ret) { if(DB_REPEAT==ret) return E_DB_TRANSDTL_E; else return E_DB_TRANSDTL_I; } SetCol(handle,F_LVOL0,F_LVOL8,F_SDATE0, F_SDATE3,F_SEMP,F_LWITHDRAW_FLAG,F_LSERIAL1,F_VSMESS,0); outPack->lvol0=tCard.cardno; outPack->lvol8=D4U5(pAccTrans->trans.cardaftbal*100,0); des2src(outPack->sdate3,pAccTrans->trans.sysdate); des2src(outPack->semp,trans.opercode); outPack->lwithdraw_flag=trans.termid; outPack->lserial1=trans.termseqno; char temp[128]=""; sprintf(temp,"卡余额:%.2f",pAccTrans->trans.cardaftbal); pAccTrans->remark+=temp; strcpy(outPack->vsmess,pAccTrans->remark.c_str()); des2src(trans.remark,outPack->vsmess); PutRow(handle,outPack,pRetCode,szMsg); return 0; }
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 F846323(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; CAccTrans& ats=CAccTrans::GetInst(); TRANS& trans=ats.trans; des2src(ats.trans.opercode,rPack->semp); if(strlen(ats.trans.opercode)<1) { ats.trans.termid=rPack->lwithdraw_flag; } ats.trans.transcode=TC_WATERCARDBALMOD; ret=ats.InitTrans(); if(ret) return ret; trans.transamt=rPack->damt0; trans.cardflag=1; trans.usecardflag=1; trans.cardno=rPack->lvol0; trans.purseno=PURSE_NO_THREE; trans.cardbefbal=rPack->lvol7/100.0; trans.cardaftbal= D4U5(trans.cardbefbal+trans.transamt); des2src(trans.cardphyid,rPack->sstation1); if(amtcmp(trans.transamt,0)==0) { ERRTIP("充值金额不能为0"); return E_COMMON_ERR; } T_t_card tCard; memset(&tCard,0,sizeof(tCard)); ret=doCard(trans,tCard); if(ret) { return ret; } trans.feetype=tCard.feetype; trans.cardtype=tCard.cardtype; T_t_account tCardAccount; memset(&tCardAccount,0,sizeof(tCardAccount)); ret=DB_t_account_read_by_accno(tCard.accno,&tCardAccount); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CARDACCNO,tCard.accno); else return E_DB_ACCOUNT_R; } if(tCardAccount.status[0]!=STATUS_NORMAL) { return ERRINFO(E_CARDACC_LOGOUT,tCardAccount.accno); } trans.custid=tCard.custid; T_t_transdtl transdtl; memset(&transdtl,0,sizeof(transdtl)); 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.cardbefbal=trans.cardbefbal; transdtl.amount=trans.transamt; transdtl.managefee=trans.totalfeeamt; transdtl.cardaftbal=trans.cardaftbal; transdtl.custid=tCardAccount.custid; des2src(transdtl.custname,tCardAccount.accname); des2src(transdtl.opercode,trans.opercode); des2src(transdtl.showcardno,tCard.showcardno); transdtl.status[0]=DTLSTATUS_SUCCESS; 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; } ST_CPACK aPack; ST_PACK *outPack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,F_LVOL0,F_LVOL8,F_SDATE0, F_SDATE3,F_SEMP,F_LWITHDRAW_FLAG,F_LSERIAL1,F_VSMESS,0); outPack->lvol0=tCard.cardno; outPack->lvol8=D4U5(ats.trans.cardaftbal*100,0); des2src(outPack->sdate3,ats.trans.accdate); des2src(outPack->semp,trans.opercode); outPack->lwithdraw_flag=trans.termid; outPack->lserial1=trans.termseqno; sprintf(trans.remark,"%s卡余额%.2lf元",ats.remark.c_str(),ats.trans.cardaftbal); des2src(outPack->vsmess,trans.remark); PutRow(handle,outPack,pRetCode,szMsg); return 0;