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 TestTrans(TRUSERID *handle,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; ST_CPACK aPack; ST_PACK *outPack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LVOL0,F_LVOL1,F_LVOL8,F_LVOL10,F_LVOL11,F_LVOL12,F_SDATE0,F_SPHONE3,F_SADDR,F_LSAFE_LEVEL2, F_SDATE3,F_STIME3,F_SEMP,F_LWITHDRAW_FLAG,F_LSERIAL1,F_VSMESS,0); CAccTrans *pAccTrans=CAccTrans::getInstance(); TRANS& trans=pAccTrans->trans; trans.transcode=TC_CARDPAYMENT; des2src(trans.opercode,rPack->semp); trans.termid=rPack->lwithdraw_flag; ret=pAccTrans->InitTrans(); if(ret) return ret; int paycode=rPack->lcert_code; trans.cardno=rPack->lvol0; if(trans.cardno<1) { return E_INPUTNULL_CARDNO; } trans.cardflag=1; trans.usecardflag=1; trans.purseno=PURSE_NO_ONE; trans.paycnt=rPack->lvol6+1; des2src(trans.cardphyid,rPack->sstation1); trans.inputamt= D4U5(rPack->lvol1/100.0); trans.unusedamt = trans.inputamt; trans.cardbefbal=rPack->lvol7/100.0; trans.cardaftbal=trans.cardbefbal - trans.inputamt; if(amtcmp(trans.inputamt,0)<=0) { ERRTIP("交易金额不能为0"); return E_COMMON_ERR; } if(amtcmp(trans.inputamt,trans.cardbefbal)>0) { return ERRINFO(E_CARD_BALANCE_SHORTAGE,trans.cardbefbal); } 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_INFO,"检查状态失败"); return ret; } if(amtcmp(trans.cardbefbal-tAccount.balance,MAXAMT_CARDGTACC)>0) { writelog(LOG_ERR,"卡余额[%.2lf]错误",trans.cardbefbal); return ERRIF_CARDBAL_EXCEPT; } if(strlen(rPack->stx_pwd)) { ret=check_card_pwd_by_card(trans.cardno,rPack->stx_pwd); if(ret) return ret; } if(tCard.custid>0) { ret=GetCustBaseInfoByCustID(trans.custid,trans.custname,trans.stuempno,NULL); if(ret) return ret; } CPaymentBase *payment; payment = CPaymentBase::find_payment(paycode); if(NULL == payment) { return E_TRANS_FUNC_NONSUPPORT; } ret = payment->init(handle,&aPack,rPack); if(ret) { writelog(LOG_ERR,"trade[%d],ret[%d]",paycode,ret); return ret; } int waterflag=0; double waterbefbal=0; double wateraftbal=0; if(paycode/1000==1)//水控 { waterflag=1; } if(waterflag) { switch(rPack->lvol1) { case 500: case 1000: case 1500: case 2000: break; default: ERRTIP("交易金额只能为5、10、15、20元"); return E_COMMON_ERR; } waterbefbal = rPack->lsafe_level/100.0; wateraftbal = D4U5(waterbefbal+trans.inputamt); double CardMaxBal=0; ret=GetPurseMaxBal(PURSE_NO_TWO,CardMaxBal); if(ret) return ret; if(amtcmp(wateraftbal,CardMaxBal)>0) return ERRINFO(E_AMT_EXCEED_MAX,CardMaxBal); if(1061==paycode) { 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; } } // 保持第三方账号 T_t_transdtl transdtl; memset(&transdtl,0,sizeof(transdtl)); transdtl.exttype = paycode; if(waterflag) { sprintf(transdtl.extdata,"%.2lf",wateraftbal); } else { des2src(transdtl.extdata,rPack->sbank_acc); } ret = pAccTrans->GenTransdtl(&transdtl,DTLSTATUS_INIT); if(ret) { writelog(LOG_ERR,"GenTransdtl ret=%d",ret); return ret; } ret=db_commit(); if(ret) { return ret; } trans.cardaftbal=trans.cardbefbal; ret=pAccTrans->doTrans(); if(ret) { writelog(LOG_ERR,"doTrans err=%d",ret); return ret; } ret=pAccTrans->doTransEnd(); if(ret) { writelog(LOG_ERR,"doTransEnd err=%d",ret); return ret; } if(amtcmp(trans.cardaftbal,transdtl.cardaftbal)!=0) { ERRTIP("卡余额计算有误"); return E_COMMON_ERR; } ret=db_rollback(); if(ret) { writelog(LOG_ERR,"db_rollback err"); return ret; } // 输出参数 outPack->lvol0=tCard.cardno; outPack->lvol1=D4U5(trans.inputamt*100,0); outPack->lvol8=D4U5(transdtl.cardaftbal*100,0); outPack->lsafe_level2=D4U5(wateraftbal*100,0); des2src(outPack->sdate3,trans.accdate); des2src(outPack->stime3,trans.acctime); des2src(outPack->semp,trans.opercode); outPack->lwithdraw_flag=trans.termid; outPack->lserial1=trans.termseqno; des2src(outPack->sphone3,trans.refno); des2src(outPack->saddr,trans.cardpwd); //mac sprintf(trans.remark,"%s卡余额%.2lf元",pAccTrans->remark.c_str(),pAccTrans->trans.cardaftbal); des2src(outPack->vsmess,trans.remark); if(payment->payment_.onlinepay>0&&payment->payment_.paychkflag>0) { rPack->lwithdraw_flag=outPack->lwithdraw_flag; rPack->lserial1=outPack->lserial1; rPack->lvol0=outPack->lvol0; rPack->lvol1=outPack->lvol1; rPack->lvol8=outPack->lvol8; rPack->lsafe_level2=outPack->lsafe_level2; des2src(rPack->sdate3,outPack->sdate3); des2src(rPack->stime3,outPack->stime3); des2src(rPack->sphone3,outPack->sphone3); des2src(rPack->saddr,outPack->saddr); //mac des2src(rPack->semp,outPack->semp); ret=payment->qry_acc(handle,rPack,outPack); if(ret) return ret; if(payment->pushflag_ != 1) PutRow(handle,outPack,pRetCode,szMsg); } else { PutRow(handle,outPack,pRetCode,szMsg); } return 0; }
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; }
int F846312(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_CARDDEPOSIT; 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); trans.cardflag=1; trans.usecardflag=1; trans.cardno=rPack->lvol0; trans.purseno=PURSE_NO_ONE; trans.cardbefbal=rPack->lvol7/100.0; trans.cardaftbal=trans.cardbefbal; trans.dpscnt=rPack->lvol5+1; if(trans.dpscnt<=1) { if(amtcmp(trans.cardbefbal,0)>0) trans.dpscnt=rPack->lvol6+1; //考虑兼容性 } des2src(trans.cardphyid,rPack->sstation0); trans.fundtype=rPack->lvol9; if(!trans.fundtype) return E_INPUTNULL_PAYTYPE; des2src(trans.voucherno,rPack->scust_auth2); trans.inputamt=rPack->damt0; trans.unusedamt = trans.inputamt; if(amtcmp(trans.inputamt,500)>0) { ERRTIP("单笔充值不能超过500元"); 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; // ret=UpdateCardBitmap(trans.cardno,trans.cardcnt,CARDBITMAPTYPE_INC,0); // 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) { 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); } 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; if(trans.custid) { ret=GetCustBaseInfoByCustID(trans.custid,trans.custname,trans.stuempno,NULL); if(ret) return ret; } des2src(trans.cardaccno,tCardAccount.accno); ret=pAccTrans->doFeeTrans(); if(ret) return ret; des2src(trans.craccno,tCardAccount.accno); ret=pAccTrans->doMainTrans(); if(ret) return ret; ret=pAccTrans->doTransEnd(); if(ret) return ret; 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.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,trans.custname); des2src(transdtl.stuempno,trans.stuempno); des2src(transdtl.opercode,trans.opercode); des2src(transdtl.showcardno,tCard.showcardno); 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; } SetCol(handle,F_LVOL0,F_LVOL8,F_SDATE0,F_STIME0, F_SDATE3,F_SEMP,F_LWITHDRAW_FLAG,F_LSERIAL1,F_VSMESS,F_STIME3,0); outPack->lvol0=tCard.cardno; outPack->lvol8=D4U5(pAccTrans->trans.cardaftbal*100,0); des2src(outPack->sdate0,transdtl.transdate); des2src(outPack->stime0,transdtl.transtime); 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 F240020(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; CAccTrans *pAccTrans=CAccTrans::getInstance(); pAccTrans->trans.transcode=TC_BANKTRANS; TRANS& trans=pAccTrans->trans; trans.termid=rPack->lcert_code; ret=pAccTrans->InitTrans(); if(ret) return ret; trans.inputamt = rPack->lvol5/100.0; trans.unusedamt=trans.inputamt; trans.cardflag=1; trans.usecardflag=1; trans.cardbefbal=rPack->lvol6/100.00; trans.dpscnt=rPack->lvol1+1; //充值次数 trans.cardaftbal=trans.cardbefbal; //转账不允许转小数金额 if((rPack->lvol5)%100>0) { writelog(LOG_ERR,"trans money is not a integer!,transmoney=[%f]",rPack->lvol5/100.0); strcpy(szMsg,"转账金额必须是整数"); return E_TRANS_TRANSMONEY_OUTRANGE; } if(rPack->lvol5<1) { writelog(LOG_ERR,"trans money is not a integer!,transmoney=[%f]",rPack->lvol5/100.0); strcpy(szMsg,"转账金额不能为0"); return E_TRANS_TRANSMONEY_OUTRANGE; } T_t_account tAccount; //帐户表 T_t_card card; T_t_bankcard bankcard; T_t_cfgbank cfgbank; T_t_device device; memset(&cfgbank,0,sizeof cfgbank); memset(&tAccount,0,sizeof(tAccount)); memset(&card,0,sizeof(card)); memset(&bankcard,0,sizeof(bankcard)); memset(&device,0,sizeof device); ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_SCUST_AUTH,F_SNAME,F_SNAME2,F_LSERIAL0,F_STX_PWD,F_LVOL5,F_LVOL6,0); /*判断设备是否登陆 if(0!=device_login_yes_or_no(trans.termid)) { writelog(LOG_ERR,"Device don't login"); return E_TRANS_TERM_NOLOGIN; } */ /* char buffer[16]=""; //判断是否处于日终结算状态 ret=GetSysParaVal(GLOBE_FLAG_BALANCE,buffer); if(ret) { writelog(LOG_ERR,"GetSysParaVal error,errcode=[%d]",ret); return E_TRANS_UNKNOW_ERROR; } else if(strncmp(buffer,"0",1)!=0) { writelog(LOG_ERR,"System is balance now!"); return E_TRANS_BANK_SERVICE_NOEXIT; } */ ret=DB_t_device_read_by_deviceid(trans.termid, &device); if(ret) { writelog(LOG_ERR,"DB_t_device_read_by_deviceid err,errcode=[%d],device_id=[%d]",ret,trans.termid); return E_DB_DEVICE_R; } trans.cardno=rPack->lvol0; ret=pAccTrans->CheckAcc(&card,&tAccount); if(ret) return ret; if(amtcmp(trans.cardbefbal-tAccount.balance,MAXAMT_CARDGTACC)>=0) { writelog(LOG_ERR,"cardbefbal[%.2lf]account balance[%.2lf]",trans.cardbefbal,tAccount.balance); return ERRIF_CARDBAL_EXCEPT; } 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.feetype=card.feetype; trans.cardtype=card.cardtype; trans.custid=card.custid; // if(tAccount.lastdpscnt>trans.dpscnt) // { // return ERRINFO(E_CARDCNT_LT_LASTCARDCNT,trans.dpscnt,tAccount.lastdpscnt); // } //校验绑定关系 ret = DB_t_bankcard_read_by_custid(card.custid, &bankcard); if(ret) { if(DB_NOTFOUND==ret) { strcpy(szMsg,"学工号和银行卡号未绑定"); return E_DB_BANKCARD_N; } else { return E_DB_BANKCARD_R; } } ret = DB_t_cfgbank_read_by_bankcode(bankcard.bankcode,&cfgbank); if(ret) { return E_DB_CFGBANK_R; } if(strncmp(trans.acctime,cfgbank.bankstarttime,6) < 0 || strncmp(trans.acctime,cfgbank.bankendtime,6) > 0) { return E_OUT_BANKTIME; } //取流水号 ret=pAccTrans->GetTermSeqno(); if(ret) { writelog(LOG_ERR,"GetTermSeqno error,error code=[%d]",ret); return ret; } 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.transdate); tRefno.termid = trans.termid; tRefno.termseqno = trans.termseqno; ret=DB_t_refno_add(&tRefno); if(ret) { if(DB_REPEAT==ret) return E_DB_REFNO_E; else return E_DB_REFNO_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.cardno=trans.cardno; transdtl.purseno=trans.purseno; transdtl.transflag = TF_DPS; transdtl.cardcnt=trans.dpscnt; transdtl.cardbefbal=trans.cardbefbal; transdtl.amount=trans.inputamt; transdtl.cardaftbal=trans.cardaftbal; transdtl.custid=tAccount.custid; //transdtl.sysid= rPack->lvol2; transdtl.exttype=EXTTYPE_BANKCARD; des2src(transdtl.extdata,bankcard.bankcardno); des2src(transdtl.showcardno,card.showcardno); transdtl.status[0]=DTLSTATUS_INIT; des2src(transdtl.refno,tRefno.refno); des2src(transdtl.devphyid,device.devphyid); GetCustBaseInfoByCustID(card.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; } des2src(out_pack->scust_auth,bankcard.bankcardno); // 银行卡号 des2src(out_pack->sname,transdtl.stuempno); // 学工号 des2src(out_pack->sname2,transdtl.refno); // 交易参考号 des2src(out_pack->stx_pwd,tRefno.mac); // 随机数 out_pack->lserial0=trans.termseqno; // 终端流水号 out_pack->lvol5 = D2I(trans.inputamt*100); // 交易金额 (分) out_pack->lvol6 = D2I(trans.cardbefbal*100); // 入卡值(分) writelog(LOG_INFO,"bankcardno[%s],stuempno[%s],refno[%s],termseqno[%d],inputamt[%d],befbal[%d]",out_pack->scust_auth, out_pack->sname,out_pack->sname2,out_pack->lserial0,out_pack->lvol5,out_pack->lvol6); PutRow(handle,out_pack,pRetCode,szMsg); return 0; }
static int NormalTrans(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_LVOL0,F_LVOL1,F_LVOL2,F_LVOL8,F_LVOL10,F_LVOL11,F_LVOL12,F_SDATE0,F_SPHONE3,F_SADDR,F_LSAFE_LEVEL2, F_SDATE3,F_STIME3,F_SEMP,F_LWITHDRAW_FLAG,F_LSERIAL1,F_VSMESS,0); if(rPack->lvol0<1) { ERRTIP("请输入付款方卡号"); return E_COMMON_ERR; } if(rPack->lvol2<1) { ERRTIP("请输入收款方卡号"); return E_COMMON_ERR; } des2src(trans.refno,rPack->sphone3); //交易参考号 if(strlen(trans.refno)!=14) { ERRTIP("交易参考号错误"); return E_COMMON_ERR; } T_t_refno tRefno; memset(&tRefno,0,sizeof(tRefno)); ret=DB_t_refno_read_by_refno(trans.refno,&tRefno); if(ret) { if(DB_NOTFOUND==ret) return E_DB_REFNO_N; else return E_DB_REFNO_R; } if(strncmp(tRefno.mac,rPack->saddr,8)!=0) { ERRTIP("交易参考号MAC校验错误"); return E_COMMON_ERR; } if(RS_FAIL==tRefno.status) { ERRTIP("交易已失败"); return E_COMMON_ERR; } T_t_transdtl transdtl; memset(&transdtl,0,sizeof(transdtl)); ret=DB_t_transdtl_read_by_accdate_and_termid_and_termseqno(tRefno.accdate,tRefno.termid,tRefno.termseqno,&transdtl); if(ret) { if(DB_NOTFOUND==ret) return E_NOTEXIST_TRANSDTL; else return E_DB_TRANSDTL_R; } if(RS_SUCC==tRefno.status) { outPack->lvol0=transdtl.cardno; outPack->lvol1=D4U5(transdtl.amount*100,0); outPack->lvol8=D4U5(transdtl.cardaftbal*100,0); outPack->lsafe_level2=rPack->lsafe_level+D4U5(transdtl.amount*100,0); des2src(outPack->sdate3,transdtl.transdate); des2src(outPack->stime3,transdtl.transtime); des2src(outPack->semp,transdtl.opercode); outPack->lwithdraw_flag=transdtl.termid; outPack->lserial1=transdtl.termseqno; des2src(outPack->sphone3,transdtl.refno); PutRow(handle,outPack,pRetCode,szMsg); return 0; } int cardno=atoi(transdtl.voucherno); if(rPack->lvol2!=cardno) { ERRTIP("收款方卡号错误"); return E_COMMON_ERR; } if(transdtl.status[0]!=DTLSTATUS_INIT) { ERRTIP("交易流水表状态错误"); return E_COMMON_ERR; } des2src(trans.opercode,transdtl.opercode); trans.termid=transdtl.termid; trans.termseqno=transdtl.termseqno; trans.cardflag=0; trans.usecardflag=0; trans.transcode=transdtl.transcode; trans.cardno=transdtl.cardno; trans.purseno=transdtl.purseno; trans.paycnt=transdtl.cardcnt; trans.cardbefbal=transdtl.cardbefbal; trans.cardaftbal=transdtl.cardaftbal; trans.inputamt= transdtl.amount; trans.unusedamt = trans.inputamt; T_t_card tOutCard; memset(&tOutCard,0,sizeof(tOutCard)); T_t_card tInCard; memset(&tInCard,0,sizeof(tInCard)); ret=DB_t_card_read_by_cardno(trans.cardno,&tOutCard); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CARDNO,trans.cardno); else return E_DB_CARD_R; } ret=DB_t_card_read_by_cardno(rPack->lvol2,&tInCard); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CARDNO,rPack->lvol2); else return E_DB_CARD_R; } trans.feetype=tOutCard.feetype; trans.custid=tOutCard.custid; // trans.cardaftbal=trans.cardbefbal; strcpy(pAccTrans->trans.draccno,tOutCard.accno); strcpy(pAccTrans->trans.craccno,tInCard.accno); ret=pAccTrans->doTrans(); if(ret) return ret; ret=pAccTrans->doTransEnd(); if(ret) return ret; transdtl.status[0]=DTLSTATUS_SUCCESS; ret=DB_t_transdtl_update_by_accdate_and_termid_and_termseqno(tRefno.accdate,tRefno.termid,tRefno.termseqno,&transdtl); if(ret) { if(DB_NOTFOUND==ret) return E_DB_TRANSDTL_N; else return E_DB_TRANSDTL_U; } tRefno.status=RS_SUCC; des2src(tRefno.lastsaved,trans.sysdatetime); ret=DB_t_refno_update_by_refno(tRefno.refno,&tRefno); if(ret) { if(DB_NOTFOUND==ret) return E_DB_REFNO_N; else return E_DB_REFNO_U; } ///////////////////////////////////////////////////////////////////////////////////////////////// //记录转入卡的卡交易流水 pAccTrans->Reset(); trans.termid=transdtl.termid; trans.dpscnt=rPack->lvol3+1; trans.cardbefbal=rPack->lsafe_level/100.0; trans.cardaftbal=(rPack->lvol1+rPack->lsafe_level)/100.0; trans.cardno=atoi(transdtl.voucherno); if(trans.cardno!=rPack->lvol2) { ERRTIP("收款卡号不符"); return E_COMMON_ERR; } ret=GetCustBaseInfoByCustID(tInCard.custid,trans.custname,trans.stuempno,trans.remark); if(ret) return ret; ret=pAccTrans->GetTermSeqno(); if(ret) { return ret; } T_t_transdtl transdtl2; memset(&transdtl2,0,sizeof(transdtl2)); des2src(transdtl2.refno,transdtl.refno); des2src(transdtl2.transdate,transdtl.transdate); des2src(transdtl2.transtime,transdtl.transtime); strcpy(transdtl2.accdate,transdtl.accdate); strcpy(transdtl2.acctime,transdtl.acctime); transdtl2.termid=trans.termid; transdtl2.termseqno=trans.termseqno; transdtl2.transcode=transdtl.transcode; sprintf(transdtl2.voucherno,"%d",transdtl.cardno); transdtl2.cardno=trans.cardno; transdtl2.purseno=trans.purseno; transdtl2.transflag =TF_DPS; transdtl2.cardcnt=trans.dpscnt; transdtl2.cardbefbal=trans.cardbefbal; transdtl2.cardaftbal=trans.cardaftbal; transdtl2.amount= transdtl.amount; transdtl2.managefee=0; transdtl2.custid=tInCard.custid; des2src(transdtl2.custname,trans.custname); des2src(transdtl2.opercode,trans.opercode); transdtl2.status[0]=DTLSTATUS_SUCCESS; des2src(transdtl2.showcardno,tInCard.showcardno); des2src(transdtl2.stuempno,trans.stuempno); transdtl2.exttype=EXTTYPE_OPPSNO; des2src(transdtl2.extdata,transdtl.stuempno); sprintf(transdtl2.remark,"由(%s)转出",transdtl.custname); ret=DB_t_transdtl_add(&transdtl2); if(ret) { if(DB_REPEAT==ret) return E_DB_TRANSDTL_E; else return E_DB_TRANSDTL_I; } T_t_account OutAccount; memset(&OutAccount,0,sizeof(OutAccount)); ret=DB_t_account_read_lock_by_c0_and_accno(tOutCard.accno,&OutAccount); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CARDACCNO,tOutCard.accno); else return E_DB_ACCOUNT_R; } OutAccount.paycnt=transdtl.cardcnt; OutAccount.cardbal=transdtl.cardaftbal; OutAccount.lastpaycnt=transdtl.cardcnt-1; OutAccount.lastcardbal=transdtl.cardbefbal; strcpy(OutAccount.lastaccdate,transdtl.transdate); ret=DB_t_account_update_lock_by_c0(&OutAccount); if(ret) { writelog(LOG_ERR,"更新付款方账户表错误ret=%d",ret); return E_DB_ACCOUNT_U; } T_t_account InAccount; memset(&InAccount,0,sizeof(InAccount)); ret=DB_t_account_read_lock_by_c0_and_accno(tInCard.accno,&InAccount); if(ret) { if(DB_NOTFOUND==ret) return ERRINFO(E_NOTEXIST_CARDACCNO,tInCard.accno); else return E_DB_ACCOUNT_R; } InAccount.dpscnt=transdtl2.cardcnt; InAccount.cardbal=transdtl2.cardaftbal; InAccount.lastdpscnt=transdtl2.cardcnt-1; InAccount.lastcardbal=transdtl2.cardbefbal; strcpy(InAccount.lastaccdate,transdtl2.transdate); ret=DB_t_account_update_lock_by_c0(&InAccount); if(ret) { writelog(LOG_ERR,"更新收款方账户表错误ret=%d",ret); return E_DB_ACCOUNT_U; } outPack->lvol0=transdtl.cardno; outPack->lvol2=transdtl2.cardno; outPack->lvol1=D4U5(transdtl.amount*100,0); outPack->lvol8=D4U5(transdtl.cardaftbal*100,0); outPack->lsafe_level2=D4U5(transdtl2.cardaftbal*100,0); des2src(outPack->sdate3,trans.accdate); des2src(outPack->stime3,trans.acctime); des2src(outPack->semp,trans.opercode); outPack->lwithdraw_flag=transdtl.termid; outPack->lserial1=transdtl.termseqno; des2src(outPack->sphone3,transdtl.refno); des2src(outPack->vsmess,trans.remark); PutRow(handle,outPack,pRetCode,szMsg); return 0; }
int F846314(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_CARDDRAW; 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); 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; // trans.fundtype=PAYTYPE_CASH; des2src(trans.cardphyid,rPack->sstation0); trans.inputamt=rPack->damt0; trans.unusedamt = trans.inputamt; if(amtcmp(trans.inputamt,trans.cardbefbal)>0) { return ERRINFO(E_CARD_BALANCE_SHORTAGE,trans.cardbefbal); } T_t_card tCard; memset(&tCard,0,sizeof(tCard)); ret=doCard(trans,tCard); if(ret) { return ret; } trans.custid=tCard.custid; if(trans.custid) { ret=GetCustBaseInfoByCustID(trans.custid,trans.custname,trans.stuempno,NULL); 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(tCardAccount.lastpaycnt>trans.paycnt) { return ERRINFO(E_CARDCNT_LT_LASTCARDCNT,trans.paycnt,tCardAccount.lastpaycnt); } strcpy(trans.cardaccno,tCardAccount.accno); trans.feetype=tCard.feetype; trans.custid=tCard.custid; strcpy(trans.draccno,tCardAccount.accno); ret=pAccTrans->doTrans(); if(ret) return ret; ret=pAccTrans->doTransEnd(); if(ret) return ret; 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.transflag =TF_PAY; transdtl.cardcnt=trans.paycnt; 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.stuempno,trans.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; } SetCol(handle,F_LVOL0,F_LVOL8,F_SDATE0, F_SDATE3,F_SEMP,F_LWITHDRAW_FLAG,F_LSERIAL1,F_VSMESS,F_STIME3,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; }
int F240002(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; CAccTrans *pAccTrans=CAccTrans::getInstance(); pAccTrans->trans.transcode=TC_BANKTRANS; TRANS& trans=pAccTrans->trans; trans.termid=atoi(rPack->sorder2); ret=pAccTrans->InitTrans(); if(ret) return ret; trans.inputamt = rPack->lvol5/100.0; trans.unusedamt=trans.inputamt; trans.cardflag=1; trans.usecardflag=1; trans.cardbefbal=rPack->lvol6/100.00; trans.dpscnt=rPack->lvol1+1; trans.cardaftbal=trans.cardbefbal; //转账不允许转小数金额 if((rPack->lvol5)%100>0) { writelog(LOG_ERR,"trans money is not a integer!,transmoney=[%f]",rPack->lvol5/100.0); strcpy(szMsg,"转账金额必须是整数"); return E_TRANS_TRANSMONEY_OUTRANGE; } if(rPack->lvol5<1) { writelog(LOG_ERR,"trans money is not a integer!,transmoney=[%f]",rPack->lvol5/100.0); strcpy(szMsg,"转账金额不能为0"); return E_TRANS_TRANSMONEY_OUTRANGE; } T_t_account tAccount; //帐户表 T_t_card card; memset(&tAccount,0,sizeof(tAccount)); memset(&card,0,sizeof(card)); ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_DAMT0,F_DAMT1,F_DAMT2,F_LVOL1,F_LVOL2,F_LSERIAL0,F_SNAME2,0); //判断设备是否登陆 if(0!=device_login_yes_or_no(trans.termid)) { writelog(LOG_ERR,"Device don't login"); return E_TRANS_TERM_NOLOGIN; } trans.cardno=atoi(rPack->sserial0); ret=pAccTrans->CheckAcc(&card,&tAccount); if(ret) return ret; if(amtcmp(trans.cardbefbal-tAccount.balance,MAXAMT_CARDGTACC)>=0) { writelog(LOG_ERR,"cardbefbal[%.2lf]account balance[%.2lf]",trans.cardbefbal,tAccount.balance); return ERRIF_CARDBAL_EXCEPT; } 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.feetype=card.feetype; trans.cardtype=card.cardtype; trans.custid=card.custid; des2src(trans.cardaccno,tAccount.accno); //贷方帐户,持卡人账户 des2src(trans.draccno,rPack->sstation0); //借方帐号,由前置机上传 ret=pAccTrans->doFeeTrans(); if(ret) return ret; ret=pAccTrans->doMainTrans(); if(ret) return ret; ret=pAccTrans->doTransEnd(); if(ret) return ret; //业务结束后,回滚事务 ret=db_rollback(); if(ret) { writelog(LOG_ERR,"db_rollback error,error code=[%d]",ret); return E_DB_ROLLBACK; } //重新取流水号 ret=pAccTrans->GetTermSeqno(); if(ret) { writelog(LOG_ERR,"GetTermSeqno error,error code=[%d]",ret); return ret; } 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.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=card.custid; //transdtl.sysid= rPack->lvol2; transdtl.exttype=EXTTYPE_BANKCARD; des2src(transdtl.extdata,rPack->scust_auth); des2src(transdtl.showcardno,card.showcardno); transdtl.status[0]=DTLSTATUS_FAIL; ret=GetNewRefno(transdtl.refno); if(ret) { ERRTIP("取交易参考号失败"); return ret; } GetCustBaseInfoByCustID(card.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; } char sMsg[255]=""; char sDebugMsg[255]=""; sprintf(sDebugMsg,"流水号:%d ",trans.termseqno); sprintf(sMsg,"充值前卡余额:%.2lf 转帐后卡余额:%.2lf ",trans.cardbefbal,trans.cardaftbal); strcat(sDebugMsg,sMsg); writelog(LOG_DEBUG,sDebugMsg); des2src(out_pack->sname2,transdtl.refno); out_pack->lserial0=trans.termseqno; out_pack->damt0=trans.cardaftbal; out_pack->damt1=transdtl.amount; out_pack->damt2=transdtl.managefee; out_pack->lvol1=transdtl.termseqno; out_pack->lvol2=D2I(trans.cardaftbal*100); PutRow(handle,out_pack,pRetCode,szMsg); return 0; }