static int DoResponse(const T_t_cardtrans& cardtrans, TRUSERID *handle, int *pRetCode, char *szMsg) { CAccTrans& ats = CAccTrans::GetInst(); TRANS& trans = ats.trans; ST_CPACK aPack; ST_PACK *outPack = &(aPack.pack); ResetNormalCPack(&aPack, 0, 1); SetCol(handle, F_LVOL0, F_LVOL1, F_LVOL7, F_LVOL8, F_DAMT0, F_LCERT_CODE, F_SDATE0, F_STIME0, F_LWITHDRAW_FLAG, F_LSERIAL0, F_LSERIAL1, F_SNOTE, F_VSMESS, 0); outPack->lwithdraw_flag = trans.termid; outPack->lvol0 = trans.cardno; outPack->lvol7 = D4U5(trans.cardbefbal * 100, 0); outPack->lvol8 = D4U5(trans.cardaftbal * 100, 0); if(trans.errcode) { outPack->lvol1 = 1; outPack->damt0 = trans.addamt; outPack->lcert_code = trans.transcode; outPack->lserial0 = cardtrans.termid; outPack->lserial1 = cardtrans.termseqno; strcpy(outPack->sdate0, cardtrans.transdate); strcpy(outPack->stime0, cardtrans.transtime); strcpy(outPack->snote, trans.remark); } PutRow(handle, outPack, pRetCode, szMsg); return 0; }
//金额比较函数,只比较小数点前2位 int amtcmp(double amt1,double amt2) { long long lAmt1=D4U5(amt1,2)*100; long long lAmt2=D4U5(amt2,2)*100; long long lAmt=lAmt1-lAmt2; if(0==lAmt) return 0; else if(lAmt<0) return -1; else return 1; }
static int do_refundment_subsidy(T_t_aif_account *account,double *subsidy_money,char *opercode,int subsidy_no) { T_t_tif_subsidy tSubsidy; char tx_date[9]=""; char tx_time[7]=""; double total_money = 0.0; int ret; char status[2] = ""; getsysdate(tx_date); getsystime(tx_time); status[0] = SUBSIDY_STAT_NORMAL; // 按交易卡号退款 ret = DB_t_tif_subsidy_open_select_for_update_by_c3_and_cardno_and_status( account->cardno,status); if(ret) { if(DB_NOTFOUND != ret) { writelog(LOG_ERR,"open subsidy error,cardno[%d],ret[%d]",account->cardno,ret); return E_DB_SUBSIDY_R; } } else { while(1) { memset(&tSubsidy,0,sizeof tSubsidy); ret = DB_t_tif_subsidy_fetch_select_by_c3(&tSubsidy); if(ret) { if(DB_NOTFOUND == ret) break; writelog(LOG_ERR,"read subsidy error,cardno[%d],ret[%d]",account->cardno,ret); return E_DB_SUBSIDY_R; } if(subsidy_no > -1 && tSubsidy.subsidy_no < subsidy_no) { writelog(LOG_INFO,"cardid[%d]online subsidy_no[%d],db subsidy_no[%d] ignore", account->cardno,subsidy_no,tSubsidy.subsidy_no); continue; } total_money += D4U5(tSubsidy.amount,2); tSubsidy.status[0] = SUBSIDY_STAT_FINISHED; des2src(tSubsidy.get_date,tx_date); des2src(tSubsidy.get_time,tx_time); des2src(tSubsidy.opercode,opercode); ret = DB_t_tif_subsidy_update_lock_by_c3(&tSubsidy); if(ret) { writelog(LOG_ERR,"update subsidy error,cardno[%d],subsidy_no[%d],ret[%d]", tSubsidy.cardno,tSubsidy.subsidy_no,ret); return E_DB_SUBSIDY_U; } } } *subsidy_money = total_money; return 0; }
// 将浮点数转换为整型 int D2I(double value) { /* double smaller = floor(value); double bigger = ceil(value); return (int)(((bigger - value) > (value - smaller)) ? smaller : bigger); */ return (int)D4U5(value,0); }
static int do_rush_balance(T_t_tif_tradelog * tradelog,InAcc * pIA,T_t_tif_tradeserial* pSerial) { int ret; int subindex; T_t_aif_account account; // 初始化入账模块 subindex = pIA->iSubIndex; memset(pIA,0,sizeof(InAcc)); pIA->dArrInAmt[0] = tradelog->op_fee * -1; des2src(pIA->sArrInActno[0],tradelog->act_id); pIA->iSubIndex = subindex; ret = process(pIA,pSerial); if(ret) { writelog(LOG_ERR,"消费解款冲正,账号[%s]失败[%.2lf]" ,tradelog->act_id,tradelog->op_fee); return ret; } memset(&account,0,sizeof account); ret = DB_t_aif_account_read_by_account_id(tradelog->act_id,&account); if(ret) { writelog(LOG_ERR,"查询商户账户失败ret[%d]",ret); if(DB_NOTFOUND == ret) return E_DB_ACCOUNT_N; else return E_DB_ACCOUNT_R; } // 更新账户余额 account.last_bala =D4U5(account.last_bala+ tradelog->op_fee,2); account.last_freebala = D4U5(account.last_freebala+ tradelog->op_fee,2); ret = DB_t_aif_account_update_by_account_id(tradelog->act_id,&account); if(ret) { writelog(LOG_ERR,"冲正后更新账户可用解款金额失败account[%s]" ,tradelog->act_id); if(DB_NOTFOUND == ret) return E_DB_ACCOUNT_N; else return E_DB_ACCOUNT_U; } pSerial->trade_fee = D4U5(pSerial->trade_fee+tradelog->op_fee,2); return 0; }
int CardTransProcess(T_t_cardtrans& cardtrans) { CAccTrans& ats = CAccTrans::GetInst(); TRANS& trans = ats.trans; int ret = DB_t_cardtrans_read_lock_by_c0_and_cardno(trans.cardno, &cardtrans); if(ret) { if(DB_NOTFOUND == ret) return 0; else return E_DB_CARDTRANS_R; } ret = CardTransCheck(cardtrans); if(ret) { DB_t_cardtrans_free_lock_by_c0(); return ret; } if(trans.errcode) { trans.cardaftbal = cardtrans.cardaftbal; trans.addamt = D4U5(trans.cardaftbal - trans.cardbefbal); trans.transcode = cardtrans.transcode; if(trans.transcode) { T_t_transcode *_pCfgTransCode = ats.getCfgTranscode(cardtrans.transcode); if(_pCfgTransCode) strcpy(trans.remark, _pCfgTransCode->transname); } cardtrans.updcnt++; strcpy(cardtrans.updtime, trans.sysdatetime); ret = DB_t_cardtrans_update_lock_by_c0(&cardtrans); if(ret) { return E_DB_CARDTRANS_U; } } else { DB_t_cardtrans_free_lock_by_c0(); } return 0; }
//取消换卡 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; }
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 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 packege_elec_request(ST_PACK *in_pack,int flag,char *send_data){ int ret; ext_elect_req_t* elect_req_t; elect_req_t=(ext_elect_req_t*)send_data; double money=0; //充值金额 char serialno[10]=""; char sysdate[11]=""; char systime[9]=""; char sysdatetime[20]=""; unsigned char buf[106]=""; unsigned char soutmd5[16]=""; char outmd5[32]=""; T_t_pif_card tCard; memset(&tCard,0,sizeof(tCard)); if(flag==1){//房间查询不加密 memcpy(elect_req_t->prix,"0",1); }else{ memcpy(elect_req_t->prix,"1",1); } memcpy(elect_req_t->length,"0141",4); if(flag==1){ memcpy(elect_req_t->type,"0001",4); }else if(flag==2){ memcpy(elect_req_t->type,"0002",4); } memset(elect_req_t->bitery,'0',sizeof(elect_req_t->bitery)); sprintf(elect_req_t->room,"%-20s",in_pack->saddr); ret=DB_t_pif_card_read_by_card_id(in_pack->lvol0, &tCard); if(ret) { if(DB_NOTFOUND==ret) ret=E_CARDNO_NOT_EXIST; else ret=E_DB_CARD_R; return ret; } sprintf(elect_req_t->cutid,"%-22d",tCard.cosumer_id); money = in_pack->damt1; int i_money=D2I(D4U5(money*100,0)); sprintf(elect_req_t->money,"%07d",i_money); ret=get_datetime_from_db(sysdate,systime); if(ret) { writelog(LOG_ERR,"get_datetime_from_db error,error code=[%d]",ret); getsysdate(sysdate); getsystime(systime); } strcpy(sysdatetime,sysdate+4); strcat(sysdatetime,systime); memcpy(elect_req_t->datetime,sysdatetime,10); memcpy(elect_req_t->tracenum,sysdate,8); sprintf(serialno,"%010d",in_pack->lvol6); memcpy(elect_req_t->tracenum+8,serialno,10); memcpy(elect_req_t->retnum,"0000",4); memcpy(elect_req_t->clientid,"0001",4); memset(outmd5,'0',32); if(flag==1){ sprintf(elect_req_t->signcheck,"%s",outmd5); }else if(flag==2){ memcpy(buf,elect_req_t->type,105); writelog(LOG_ERR,"buf data=[%s]",buf); CalcMD5(buf,105,soutmd5); dec2hex(soutmd5,16,outmd5); writelog(LOG_ERR,"outmd5 data=[%s]",outmd5); sprintf(elect_req_t->signcheck,"%s",outmd5); } return 0; }
static int packege_send_data(ST_PACK *in_pack,int flag,char *send_data){ int ret =0; //char cellphone[31]=""; //充值手机号 double money=0; //充值金额 char sysdate[11]=""; char systime[9]=""; char sysdatetime[20]=""; char serialno[20]=""; char sMoney[20]=""; T_t_pif_card tCard; // ext_phone_trans_t phone_trans_struct; ext_phone_trans_t* phone_trans_struct; phone_trans_struct=(ext_phone_trans_t*)send_data; memset(&tCard,0,sizeof(tCard)); memset(phone_trans_struct,0,sizeof(ext_phone_trans_t)); phone_trans_struct->prix[0]=0x31; memcpy(phone_trans_struct->length,"0067",4); if(1==flag) { memcpy(phone_trans_struct->type,"0100",4); } else if(2==flag) { memcpy(phone_trans_struct->type,"0200",4); } //memcpy(phone_trans_struct->bitery,"0000000000000000",16); memset(phone_trans_struct->bitery,'0',sizeof(phone_trans_struct->bitery)); ret=DB_t_pif_card_read_by_card_id(in_pack->lvol0, &tCard); if(ret) { if(DB_NOTFOUND==ret) ret=E_CARDNO_NOT_EXIST; else ret=E_DB_CARD_R; return ret; } sprintf(phone_trans_struct->cutid,"%-22d",tCard.cosumer_id); money = in_pack->damt1; int i_money=D2I(D4U5(money*100,0)); sprintf(sMoney,"%07d",i_money); memcpy(phone_trans_struct->money,sMoney,sizeof(phone_trans_struct->money)); ret=get_datetime_from_db(sysdate,systime); if(ret) { writelog(LOG_ERR,"get_datetime_from_db error,error code=[%d]",ret); getsysdate(sysdate); getsystime(systime); } strcpy(sysdatetime,sysdate+4); strcat(sysdatetime,systime); memcpy(phone_trans_struct->datetime,sysdatetime,10); memcpy(phone_trans_struct->tracenum,sysdate,8); sprintf(serialno,"%06d",in_pack->lvol6%1000000); memcpy(phone_trans_struct->tracenum+8,serialno,6); memcpy(phone_trans_struct->phone,in_pack->sphone,strlen(in_pack->sphone)); memcpy(phone_trans_struct->retnum,"00",2); memset(phone_trans_struct->plugdata,0x20,sizeof(phone_trans_struct->plugdata)); /* memcpy(send_data,phone_trans_struct->prix,1); memcpy(send_data+1,phone_trans_struct->length,4); memcpy(send_data+5,phone_trans_struct->type,4); memcpy(send_data+9,phone_trans_struct->bitery,16); memcpy(send_data+25,phone_trans_struct->cutid,22); memcpy(send_data+47,phone_trans_struct->money,7); memcpy(send_data+54,phone_trans_struct->datetime,10); memcpy(send_data+64,phone_trans_struct->tracenum,14); memcpy(send_data+78,phone_trans_struct->phone,11); memcpy(send_data+89,phone_trans_struct->retnum,2); memcpy(send_data+91,phone_trans_struct->plugdata,36); */ writelog(LOG_ERR,"package send data=[%s]",send_data); return 0; }
int F846322(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); ats.trans.transcode = TC_CARDBALMOD; des2src(trans.cardasno, ats.reqpack->scard0); strcpy(ats.trans.samno, ats.reqpack->snote); ats.trans.termseqno=ats.reqpack->lserial0; ats.trans.termdate = atol(ats.reqpack->sdate0); ats.trans.termtime = atol(ats.reqpack->stime0); ats.SetCardCntAndCardBal(ats.reqpack->lvol5, ats.reqpack->lvol6, ats.reqpack->lvol7); des2src(trans.cardphyid, ats.reqpack->sstation1); if(ats.reqpack->lbank_acc_type > 0) { ats.trans.inputamt= D4U5(ats.reqpack->damt0 * 100.0); } else { ats.trans.inputamt = -D4U5(ats.reqpack->damt0 * 100.0); } ret = ats.ChkOper(); if(ret) return ret; ret = chk_oper_pwd(rPack->semp_no, rPack->scust_limit); if(ret) return ret; ret = GetCardIDByCardasno(trans.cardasno, &trans.cardid); if(ret) { return ret; } CCardBalUpd obj; obj.SetTrans(ats.trans); if(!obj.LockCard()) { return obj.GetErrCode(); } if(!obj.ExecBefChk()) { return obj.GetErrCode(); } if(!obj.Execute()) { return obj.GetErrCode(); } if(!obj.ExecAftChk()) { return obj.GetErrCode(); } if(!obj.SaveExecResult()) { return obj.GetErrCode(); } if(!obj.buildOutput()) { return obj.GetErrCode(); } ST_CPACK aPack; ST_PACK *outPack = &(aPack.pack); ResetNormalCPack(&aPack, 0, 1); SetCol(handle, F_LVOL0, F_LVOL8, F_SDATE0, F_SCARD0, F_SDATE3, F_STIME3, F_SEMP, F_LWITHDRAW_FLAG, F_LSERIAL0, F_VSMESS, F_SNAME2,F_SALL_NAME,F_SPHONE,0); outPack->lvol0 = obj.GetObjCard().cardno; des2src(outPack->scard0, obj.GetObjCard().cardasno); outPack->lvol8 = obj.GetAftcardbal(); sprintf(outPack->sdate3, "%d", ats.hostdate); sprintf(outPack->stime3, "%06d", ats.hosttime); des2src(outPack->semp, trans.opercode); outPack->lwithdraw_flag = trans.termid; outPack->lserial0 = trans.operseqno; strcpy(outPack->sname2,obj.GetObjCardtype().cardtypename); strcpy(outPack->sall_name,obj.GetObjCustomer().custname); strcpy(outPack->sphone,obj.GetObjCustomer().mobile); writelog(LOG_ERR, "cardno:%d,cardbal:%d,date:%s,time:%s" , outPack->lvol0 , outPack->lvol8, outPack->sdate3, outPack->stime3); sprintf(trans.remark, "余额调整%.2lf元,卡余额%.2lf元",ats.trans.inputamt/ 100.0,obj.GetAftcardbal()/ 100.0); des2src(outPack->vsmess, trans.remark); PutRow(handle, outPack, pRetCode, szMsg); return 0; }
int F847119(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; char logicdate[11]=""; char sysdate[11]=""; char systime[9]=""; char operate_date[11]=""; char sSerialno[20]=""; char physical_no[41]=""; char old_physical_no[41]=""; int iSerialno=0; int card_id=0; int serial_type=0; int flag=0; double dSerialno=0; double dAmt=0; char h_password[7] = ""; //卡密码 char seed_key[17] = ""; //种子密钥 int card_use_cnt=0; int seri_use_cnt=0; double seri_in_bala=0; double seri_out_bala=0; double seri_in_bala_next=0; double seri_out_bala_next=0; int amt_flag=0; char tx_date[11]=""; T_t_pif_card tCard; T_t_cif_customer tCustomer; T_t_pif_spefee tSpeFee; T_t_tif_tradeserial tradeserial; T_t_tif_tradeserial old_tradeserial; T_t_tif_tradeserial_his tradeserialhis; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); memset(&tCard,0,sizeof(tCard)); memset(&tCustomer,0,sizeof(tCustomer)); memset(&tSpeFee,0,sizeof(tSpeFee)); memset(&old_tradeserial,0,sizeof(old_tradeserial)); memset(&tradeserial,0,sizeof(tradeserial)); memset(&tradeserialhis,0,sizeof(tradeserialhis)); memcpy(seed_key,STATIC_SEED_KEY,sizeof(seed_key)); //读种子密钥 ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LVOL0,F_LVOL1,F_LVOL5,F_LVOL6, F_SCUST_NO, F_SCUST_NO2,F_SCUST_AUTH,F_SCUST_AUTH2, F_SDATE0,F_SNAME,F_SNAME2, F_SOPEN_EMP,F_SSTATUS0, F_DAMT2,F_LSERIAL1,F_VSMESS,0); des2src(physical_no,rPack->sbank_acc); card_id=rPack->lvol0; getsysdate(sysdate); getsystime(systime); ret=GetLogicDate(logicdate); //业务日期 if(ret) { *pRetCode=ret; goto L_RETU; } //判断卡状态是否为写卡未成功状态 ret=DB_t_pif_card_read_by_card_id(card_id, &tCard); if(ret) { writelog(LOG_ERR,"card_id[%d]",card_id); if(DB_NOTFOUND==ret) *pRetCode= E_CARDNO_NOT_EXIST; else *pRetCode= E_DB_CARD_R; goto L_RETU; } if(STATE_FALSE==tCard.state_id[CARDSTAT_TYPE_WFAIL]) { *pRetCode=E_CARDSTATE_NOTWRITEFAIL; goto L_RETU; } ret=GetXmlValue(sSerialno, sizeof(sSerialno), XML_KEY_SERIALNO, tCard.comments); if(ret) { DB_t_pif_card_free_lock_by_cur(); *pRetCode=ret; goto L_RETU; } //修改账号表中的卡状态 //根据流水号得到补卡的出卡值 ret=GetXmlValue(operate_date, sizeof(operate_date), XML_KEY_OPERATEDATE, tCard.comments); if(ret) { *pRetCode=ret; goto L_RETU; } iSerialno=atoi(sSerialno); if(strncmp(logicdate,operate_date,8)==0) { ret=DB_t_tif_tradeserial_read_by_serial_no(iSerialno,&old_tradeserial); if(ret) { writelog(LOG_ERR,"Serialno[%d]",iSerialno); if(DB_NOTFOUND==ret) *pRetCode=E_SERIALNO_NOT_EXIST; else *pRetCode=E_DB_TRADESERIAL_R; goto L_RETU; } if(card_id!=old_tradeserial.card_id) { writelog(LOG_ERR,"input card_id [%d],tradeserial card_id[%d]",card_id,old_tradeserial.card_id); *pRetCode=E_CARDNO_SERIAL_NE; goto L_RETU; } serial_type=old_tradeserial.serial_type; flag=TYPE_CUR; } else { ret=DB_t_tif_tradeserial_his_read_by_bak_date_and_serial_no(operate_date,iSerialno,&tradeserialhis); if(ret) { writelog(LOG_ERR,"operate_date[%s]Serialno[%d]",operate_date,iSerialno); if(DB_NOTFOUND==ret) *pRetCode=E_SERIALNO_NOT_EXIST; else *pRetCode=E_DB_TRADESERIAL_R; goto L_RETU; } if(card_id!=tradeserialhis.card_id) { writelog(LOG_ERR,"input card_id [%d],tradeserial card_id[%d]",card_id,tradeserialhis.card_id); *pRetCode=E_CARDNO_SERIAL_NE; goto L_RETU; } serial_type=tradeserialhis.serial_type; flag=TYPE_HIS; } if(TYPE_CUR==flag) { seri_in_bala=old_tradeserial.in_balance; seri_out_bala=old_tradeserial.out_balance; strncpy(tx_date,old_tradeserial.operate_date,sizeof(tx_date)); dAmt=D4U5(old_tradeserial.out_balance-old_tradeserial.in_balance,2); //发生额=出卡值-入卡值 } else { seri_in_bala=tradeserialhis.in_balance; seri_out_bala=tradeserialhis.out_balance; strncpy(tx_date,tradeserialhis.operate_date,sizeof(tx_date)); dAmt=D4U5(tradeserialhis.out_balance-tradeserialhis.in_balance,2); //发生额=出卡值-入卡值 } des2src(old_physical_no,tCard.physical_no); trim(physical_no); trim(old_physical_no); switch(serial_type) { //发行正式卡 case 847101: //补办正式卡 case 847104: //发行过渡临时卡 case 847116: //发行非记名临时卡 case 847124: case 847125: case 847126: if(strcmp(old_physical_no,physical_no)!=0) { ret=IsExistCardByPhyCardNo(physical_no); if(ret) { *pRetCode = ret; goto L_RETU; } //修改卡标志,置为正常状态 ret=DB_t_pif_card_read_lock_by_cur_and_card_id(card_id, &tCard); if(ret) { writelog(LOG_ERR,"card_id[%d]",card_id); if(DB_NOTFOUND==ret) *pRetCode= E_CARDNO_NOT_EXIST; else *pRetCode= E_DB_CARD_R; goto L_RETU; } des2src(tCard.physical_no,physical_no); //物理卡号 ret=DB_t_pif_card_update_lock_by_cur(&tCard); if(ret) { writelog(LOG_ERR,"card_id[%d]",card_id); if(DB_NOTFOUND==ret) *pRetCode= E_CARDNO_NOT_EXIST; else *pRetCode= E_DB_CARD_U; goto L_RETU; } DB_t_pif_card_free_lock_by_cur(); // add by 汤成 2005-8-10 // 增加向名单表写入记录 switch(serial_type) { //补办正式卡 case 847104: //发行过渡临时卡 case 847116: // 记名临时卡 //case 847124: // VIP 卡 case 847126: ret = InsertToBlkList(tCard.card_id,CHCARD_BLACKLIST); if(ret) { *pRetCode = ret; goto L_RETU; } break; default: break; } } tradeserial.in_balance=0; //入卡值 break; //银行转帐-Added by hhd at 20051225 //考虑到有可能圈存写卡成功,但是提示失败 //避免重复写卡 case 240001: //判断卡中交易次数是否等于发生错误的流水的交易次数 if(card_use_cnt==seri_use_cnt) { //判断上传入卡值是否等于发生错误的流水的入卡值 if(rPack->damt1==seri_in_bala) //入卡值等于入卡值,卡没有写上 tradeserial.in_balance=rPack->damt1; if(rPack->damt1==seri_out_bala) //入卡值等于出卡值,卡已经写上 { tradeserial.in_balance=rPack->damt1; amt_flag=1; } else { writelog(LOG_ERR,"In_balance abnormity,in_bala=[%f]",rPack->damt1); *pRetCode= E_ENTER_ACCOUNT; goto L_RETU; } } if(card_use_cnt>seri_use_cnt) { ret=Get_card_next_serial(tCard.card_id,tx_date,rPack->lvol6,&seri_in_bala_next,&seri_out_bala_next); if(ret) { writelog(LOG_ERR,"Get_card_next_serial error,errcode=[%d]",ret); writelog(LOG_ERR,"没有找到下一笔流水"); goto L_RETU; } if(seri_in_bala_next==seri_in_bala) tradeserial.in_balance=rPack->damt1; if(seri_in_bala_next==seri_out_bala) { tradeserial.in_balance=rPack->damt1; amt_flag=1; } else { writelog(LOG_ERR,"In_balance abnormity,in_bala=[%f]",rPack->damt1); *pRetCode= E_ENTER_ACCOUNT; goto L_RETU; } } else { writelog(LOG_ERR,"In_total_cnt abnormity,in_total_cnt=[%d]",card_use_cnt); *pRetCode= E_ENTER_ACCOUNT; goto L_RETU; } default: if(strcmp(old_physical_no,physical_no)!=0) { writelog(LOG_ERR,"db physical_no[%s],input physical_no[%s]",old_physical_no,physical_no); *pRetCode= E_CARD_PHYNO_DIFFER; goto L_RETU; } tradeserial.in_balance=rPack->damt1; //入卡值 break; } if(TYPE_CUR==flag) dAmt=D4U5(old_tradeserial.out_balance-old_tradeserial.in_balance,2); //发生额=出卡值-入卡值 else dAmt=D4U5(tradeserialhis.out_balance-tradeserialhis.in_balance,2); //发生额=出卡值-入卡值 //说明不需要写卡,则发生额置为0 if(amt_flag==1) { tradeserial.trade_fee=0; //补写卡值 } else { tradeserial.trade_fee=dAmt; //补写卡值 } tradeserial.out_balance=tradeserial.in_balance+dAmt; //出卡值 if(tradeserial.out_balance<0||tradeserial.out_balance>999) { writelog(LOG_ERR,"tradeserial.out_balance[%lf]",tradeserial.out_balance); *pRetCode= E_TX_SERIAL; goto L_RETU; } writelog(LOG_DEBUG,"写卡失败日期%s,补写流水号%d,交易码%d,卡号%d,补写金额%.2lf,入卡值%lf,出卡值%lf",operate_date,iSerialno,serial_type,card_id,dAmt,tradeserial.in_balance,tradeserial.out_balance); ret=DB_t_cif_customer_read_lock_by_cur_and_cut_id(tCard.cosumer_id, &tCustomer); if(ret) { writelog(LOG_ERR,"cut_id[%d]",tCard.cosumer_id); if(DB_NOTFOUND==ret) *pRetCode= E_CUSTOMER_NOT_EXIST; else *pRetCode= E_DB_CUSTOMER_R; goto L_RETU; } EncodePwd(seed_key,h_password,tCard.password,0); //卡密码 //得到收费类别 if(tCustomer.fee_type<1) { ret=DB_t_pif_spefee_read_by_dept_code_and_cut_type(tCustomer.classdept_no, tCustomer.cut_type,&tSpeFee); if(ret) { if(DB_NOTFOUND==ret) { tCustomer.fee_type=tCustomer.cut_type; } else { DB_t_cif_customer_free_lock_cur(); *pRetCode=E_DB_SPEFEE_R; goto L_RETU; } } else { tCustomer.fee_type=tSpeFee.fee_type; } //更新客户表的收费类别字段 ret=DB_t_cif_customer_update_lock_by_cur(&tCustomer); if(ret) { if(DB_NOTFOUND==ret) *pRetCode= E_CUSTOMER_NOT_EXIST; else *pRetCode= E_DB_CUSTOMER_U; goto L_RETU; } } DB_t_cif_customer_free_lock_cur(); ret = getNewUniqNo(KEYTYPE_TRADESERIAL,&dSerialno); //获得流水号 if(ret) { *pRetCode = ret; writelog(LOG_ERR,"ret [%d]",ret); goto L_RETU; } tradeserial.serial_no = (int)dSerialno; //流水号 tradeserial.other_seri_no = 0; //上传端流水号 tradeserial.serial_type = TXCODE_REWRITE_CARD; //交易代码;备注:发卡+充值 用一个交易码,即847101; 发卡(不充值)另用一个交易码,即新的发卡程序文件名,从而区分发卡充值与发卡不充值的卡操作信息。 tradeserial.serial_state = SERISTAT_DEBT; //流水状态 des2src(tradeserial.operate_date,sysdate); //发生日期 des2src(tradeserial.operate_time,systime); //发生时间 des2src(tradeserial.collect_date,sysdate); //采集日期 des2src(tradeserial.collect_time,systime); //采集时间 des2src(tradeserial.enteract_date,logicdate); //处理日期 des2src(tradeserial.enteract_time,systime); //处理时间 des2src(tradeserial.oper_code , rPack->scust_limit); tradeserial.maindevice_id = rPack->lvol6; //上传工作站标识 tradeserial.device_id = rPack->lvol7; //采集设备标识 tradeserial.card_id = tCard.card_id; //卡号 des2src(tradeserial.showid,tCard.showid); //显示卡号 tradeserial.purse_id = PURSE_NO_ONE; //钱包号 tradeserial.customer_id = tCard.cosumer_id; //客户标识 tradeserial.reviseserial_no=dSerialno; //原写卡失败流水号 // 插入交易流水表 ret = DB_t_tif_tradeserial_add(&tradeserial); if (ret) { writelog(LOG_ERR,"ret[%d]",ret); if(DB_REPEAT==ret) *pRetCode = E_DB_TRADESERIAL_E; else *pRetCode = E_DB_TRADESERIAL_I; goto L_RETU; } if(amtcmp(tradeserial.out_balance,0)<0) { *pRetCode=E_ENTER_ACCOUNT; goto L_RETU; } sprintf(out_pack->vsmess,"流水号:%d 补写金额:%.2lf元 补写前卡余额:%.2lf元 卡当前余额:%.2lf元",tradeserial.serial_no,tradeserial.trade_fee,tradeserial.in_balance,tradeserial.out_balance); writelog(LOG_DEBUG,out_pack->vsmess); out_pack->lvol0 = tCard.card_id; //交易卡号 out_pack->lvol1 = tCustomer.cut_type; //客户类别 out_pack->lvol5 = tCustomer.fee_type; //收费类别 des2src(out_pack->scust_no,tCard.showid); //显示卡号 des2src(out_pack->scust_no2,tCustomer.classdept_no); //部门号 des2src(out_pack->scust_auth,tCustomer.stuemp_no); //学号 des2src(out_pack->scust_auth2,tCustomer.man_id); //身份证号 des2src(out_pack->sname,tCustomer.cut_name); //客户姓名 des2src(out_pack->sname2,tCustomer.lib_cardid); //图书证号 des2src(out_pack->sstatus0,tCustomer.sex); //性别 des2src(out_pack->sopen_emp,h_password); //卡密码 des2src(out_pack->sdate0,tCard.end_time); //有效截至日期 out_pack->damt2=tradeserial.out_balance; //出卡值=入卡值+发生额 out_pack->lserial1=tradeserial.serial_no; //流水号 PutRow(handle,out_pack,pRetCode,szMsg); return 0; L_RETU: return -1; }
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; }
int F847104(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret =0; int len = 0; int i=0; int hi_cutid=0; char h_showcardid[11] = ""; //显示卡号 char h_password[7] = ""; //卡密码 double h_temp_Card_id = 0; //卡号 double dSerialNo=0; char seed_key[17] = ""; //种子密钥 char card_endtime[8 + 1] = ""; //卡的有效截至日期 char logicdate[11]=""; //业务日期 char sysdate[11]=""; char systime[9]=""; char sEndDate[9]=""; char sMsg[256]=""; char sMaxCardBalance[20]=""; char lost_date[11]=""; char buf[64] = ""; int write_failed = 0; double dMaxCardBalance=0; int lost_card_id=0; T_t_pif_card tCard; T_t_pif_card tOldCard; T_t_cif_customer tCustomer; T_t_pif_spefee tSpeFee; // T_t_pif_cardlossinfo tCardLossInfo; T_t_tif_tradeserial tradeserial; T_t_aif_account tAccount; InAcc IA; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LVOL0,F_LVOL1,F_LVOL5, F_SCUST_NO, F_SCUST_NO2,F_SCUST_AUTH,F_SCUST_AUTH2, F_SDATE0,F_SNAME,F_SNAME2, F_SOPEN_EMP,F_SSTATUS0, F_DAMT2,F_LSERIAL1,F_VSMESS,0); memset(&tCard,0,sizeof(tCard)); memset(&tOldCard,0,sizeof(tOldCard)); memset(&tCustomer,0,sizeof(tCustomer)); memset(&tSpeFee,0,sizeof(tSpeFee)); // memset(&tCardLossInfo,0,sizeof(tCardLossInfo)); memset(&tAccount,0,sizeof(tAccount)); memset(&tradeserial,0,sizeof(tradeserial)); memset(&IA,0,sizeof(IA)); getsysdate(sysdate); getsystime(systime); ret=GetLogicDate(logicdate); //业务日期 if(ret) { *pRetCode=ret; goto L_RETU; } //检查客户信息,判断是否可以发行卡 hi_cutid=rPack->lvol0; //客户号 des2src(tCard.physical_no, rPack->sbank_acc); //物理卡号 trim(h_showcardid); ret=IsExistFreezeCardByCustomId(hi_cutid); if(ret) { *pRetCode = ret; goto L_RETU; } ret=IsExistNoLostCardByCustomId(hi_cutid); if(ret) { *pRetCode = ret; goto L_RETU; } if(strlen(h_showcardid)) { ret=IsExistShowCardNo(h_showcardid); if(ret) { *pRetCode = ret; goto L_RETU; } } ret=IsExistCardByPhyCardNo(tCard.physical_no); if(ret) { *pRetCode = ret; goto L_RETU; } ret=GetLostCardIdByCustomId_TypeId(hi_cutid,CT_NORMAL,&lost_card_id); if(ret) { writelog(LOG_ERR,"customer[%d]tCard type_id[%d]",hi_cutid,CT_NORMAL); *pRetCode = ret; goto L_RETU; } /* ret=DB_t_pif_cardlossinfo_read_by_card_id_and_state_id(lost_card_id, STATE_VALID, &tCardLossInfo); if(ret) { writelog(LOG_ERR,"lost_card_id[%d]",lost_card_id); if(DB_NOTFOUND==ret) *pRetCode = E_CARDNO_NOT_EXIST; else *pRetCode = E_DB_CARD_R; goto L_RETU; } */ ret=get_latest_lost_date_by_card_no(lost_card_id,lost_date); if(ret) { writelog(LOG_ERR,"lost_card_id[%d]",lost_card_id); *pRetCode =ret; goto L_RETU; } //先检查客户的挂失的正式卡是否到了补办日期 ret=GetLostCardValiddate(lost_date,sEndDate); if(ret) { *pRetCode =ret; goto L_RETU; } if(strncmp(sEndDate,sysdate,8)>0) { writelog(LOG_ERR,"lost_normal_card_id[%d]lost_date[%s]end_date[%s]",lost_card_id,lost_date,sEndDate); *pRetCode = E_NORMALCARD_NOT_REACH_ENDDATE; goto L_RETU; } /* //更新卡挂失日期表中该卡状态为无效 ret=UpdateCardLossInfoState(lost_card_id,STATE_VALID,STATE_INVALID); if(ret) { *pRetCode = ret; goto L_RETU; } */ //注销原卡 ret=DB_t_pif_card_read_lock_by_cur_and_card_id(lost_card_id,&tOldCard); if(ret) { writelog(LOG_ERR,"lost_card_id[%d]",lost_card_id); if(DB_NOTFOUND==ret) *pRetCode = E_CARDNO_NOT_EXIST; else *pRetCode = E_DB_CARD_R; goto L_RETU; } if(tOldCard.state_id[CARDSTAT_TYPE_WFAIL] == STATE_TRUE && tOldCard.is_managefee[0] == CARDWFAIL_WATER ) { // 转账的时候写卡失败 write_failed = 1; } else { des2src(tCard.state_id,CARDSTAT_REG); //卡状态 } des2src(tOldCard.state_id,CARDSTAT_LOGOUT); //注销 des2src(tOldCard.end_time,sysdate); //注销日期 ret=DB_t_pif_card_update_lock_by_cur(&tOldCard); if(ret) { writelog(LOG_ERR,"lost_card_id[%d]",lost_card_id); if(DB_NOTFOUND==ret) *pRetCode = E_CARDNO_NOT_EXIST; else *pRetCode = E_DB_CARD_R; goto L_RETU; } DB_t_pif_card_free_lock_by_cur(); if(write_failed) { ret = GetXmlValue(tOldCard.comments,sizeof buf,XML_KEY_SERIALNO2,buf); if(ret) { *pRetCode = ret; goto L_RETU; } AddXmlItemStr(tCard.comments,XML_KEY_SERIALNO2,buf); ret = GetXmlValue(tOldCard.comments,sizeof buf,XML_KEY_OPERATEDATE2,buf); if(ret) { *pRetCode = ret; goto L_RETU; } AddXmlItemStr(tCard.comments,XML_KEY_OPERATEDATE2,buf); ret = GetXmlValue(tOldCard.comments,sizeof buf,XML_KEY_TRADECODE2,buf); if(ret) { *pRetCode = ret; goto L_RETU; } AddXmlItemStr(tCard.comments,XML_KEY_TRADECODE2,buf); tCard.is_managefee[0] = CARDWFAIL_WATER; } ret=DB_t_cif_customer_read_lock_by_cur_and_cut_id(hi_cutid, &tCustomer); if(ret) { writelog(LOG_ERR,"cut_id[%d]",hi_cutid); if(DB_NOTFOUND==ret) *pRetCode= E_CUSTOMER_NOT_EXIST; else *pRetCode= E_DB_CUSTOMER_R; goto L_RETU; } //得到收费类别 if(tCustomer.fee_type<1) { ret=DB_t_pif_spefee_read_by_dept_code_and_cut_type(tCustomer.classdept_no, tCustomer.cut_type,&tSpeFee); if(ret) { if(DB_NOTFOUND==ret) { tCustomer.fee_type=tCustomer.cut_type; } else { DB_t_cif_customer_free_lock_cur(); *pRetCode=E_DB_SPEFEE_R; goto L_RETU; } } else { tCustomer.fee_type=tSpeFee.fee_type; } //更新客户表的收费类别字段 ret=DB_t_cif_customer_update_lock_by_cur(&tCustomer); if(ret) { if(DB_NOTFOUND==ret) *pRetCode= E_CUSTOMER_NOT_EXIST; else *pRetCode= E_DB_CUSTOMER_U; goto L_RETU; } } DB_t_cif_customer_free_lock_cur(); tradeserial.trade_fee =D4U5(rPack->damt0,2); // 准备数据插入卡信息表 memcpy(seed_key,STATIC_SEED_KEY,16); //读种子密钥 if(strlen(tCustomer.can_time)==8) { ret=IsInvalidDateTime(tCustomer.can_time,"YYYYMMDD"); if(ret) { *pRetCode=E_TB_CUSTOMER_ENDTIME; goto L_RETU; } if(strncmp(tCustomer.can_time,sysdate,8)<=0) { *pRetCode=E_TB_CUSTOMER_ENDTIME; goto L_RETU; } des2src(card_endtime,tCustomer.can_time); } else if(strlen(rPack->sdate0)==0) { *pRetCode=E_TB_CUSTOMER_NO_ENDTIME; goto L_RETU; } else { ret=IsInvalidDateTime(rPack->sdate0,"YYYYMMDD"); if(ret) { *pRetCode = E_INPUT_DATE; goto L_RETU; } if(strncmp(rPack->sdate0,sysdate,8)<=0) { *pRetCode=E_INPUT_DATE; goto L_RETU; } des2src(card_endtime,rPack->sdate0); } tradeserial.trade_fee = rPack->damt0; //金额 tradeserial.other_seri_no = 0; //上传端流水号 tradeserial.serial_state = SERISTAT_DEBT; //流水状态 des2src(tradeserial.operate_date,sysdate); //发生日期 des2src(tradeserial.operate_time,systime); //发生时间 des2src(tradeserial.collect_date,sysdate); //采集日期 des2src(tradeserial.collect_time,systime); //采集时间 des2src(tradeserial.enteract_date,logicdate); //处理日期 des2src(tradeserial.enteract_time,systime); //处理时间 tradeserial.maindevice_id = rPack->lvol6; //上传工作站标识 tradeserial.device_id = rPack->lvol7; //采集设备标识 tradeserial.purse_id = PURSE_NO_ONE; //钱包号 tradeserial.customer_id = tCustomer.cut_id; //客户标识 tradeserial.sys_id = 0; //外部系统标识 des2src(tradeserial.oper_code, rPack->scust_limit); //操作员号 len=strlen(tCustomer.man_id) ; if (len >= 6) { strncpy(h_password,&(tCustomer.man_id[len-6]),6); if(h_password[5]>'9'||h_password[5]<'0') h_password[5]='0'; } else { strcpy(h_password,"666666"); } ret = getNewUniqNo(KEYTYPE_CARD_ID,&h_temp_Card_id); //获取最大卡号 if(ret) { *pRetCode = ret; goto L_RETU; } tCard.card_id = (int)h_temp_Card_id; //卡号 des2src(tCard.showid,h_showcardid); //显示卡号 des2src(tCard.is_main,TYPE_YES); //是否为主卡 tCard.type_id = CT_NORMAL; //卡类别 EncodePwd(seed_key,h_password,tCard.password,0); //卡密码 tCard.cosumer_id = hi_cutid; //客户标识 tCard.account_count = ACCOUNT_COUNT_ONE; //卡对应帐户个数 des2src(tCard.begin_time,sysdate); //注册时间 des2src(tCard.end_time, card_endtime); //截至时间 tCard.phytype = PHYTYPE_NO_ONE; //设备物理型号;默认为1 // 插入卡信息 ret = DB_t_pif_card_add(&tCard); if (ret) { if(DB_REPEAT==ret) *pRetCode = E_DB_CARD_E; else *pRetCode = E_DB_CARD_I; goto L_RETU; } //修改帐户表中对应的卡号,类型,状态 ret=DB_t_aif_account_read_lock_by_c0_and_card_id_and_purse_id(lost_card_id,PURSE_NO_ONE,&tAccount); if (ret) { writelog(LOG_ERR,"normalcard_account_id[%s]",lost_card_id); if(DB_NOTFOUND==ret) *pRetCode = E_ACTNO_NOT_EXIST; else *pRetCode = E_DB_ACCOUNT_R; } if(tAccount.current_state!=1) { *pRetCode=E_ACTNO_LOGOUT; goto L_RETU; } tAccount.card_id=tCard.card_id; tAccount.card_balance=tAccount.cur_freebala; //更新卡余额与库余额一致 tAccount.consume_count=0; ret=DB_t_aif_account_update_lock_by_c0(&tAccount); if (ret) { writelog(LOG_ERR,"DB_t_aif_account_update_lock_by_cur4 ret[%d]account_id[%s]",ret,tAccount.account_id); if(DB_NOTFOUND==ret) *pRetCode = E_ACTNO_EXIST; else *pRetCode = E_DB_ACCOUNT_U; } DB_t_aif_account_free_lock_c0(); ret = getNewUniqNo(KEYTYPE_TRADESERIAL,&dSerialNo); //获得最大流水号 if(ret) { *pRetCode=ret; goto L_RETU; } tradeserial.serial_no=(int)dSerialNo; tradeserial.serial_type=TXCODE_CHANGE_CARD; tradeserial.card_id=tCard.card_id; //新卡号 des2src(tradeserial.showid,tCard.showid); //显示卡号 strcpy(IA.sArrInActno[0],tAccount.account_id); //账号 IA.dArrInAmt[0]=tradeserial.trade_fee; //交易金额 IA.iUseCardFlag=USE_CARD_TYPE_ONLINE; //联机交易 IA.dInCardBala=tAccount.cur_freebala; //入卡值 IA.iTxCnt=1; IA.iCardNo=tCard.card_id; IA.iFeeType=tCustomer.fee_type; IA.iArrInFeeSwitch[0]=rPack->lvol0; IA.iArrInFeeSwitch[1]=rPack->lvol1; IA.iArrInFeeSwitch[2]=rPack->lvol2; IA.iArrInFeeSwitch[3]=rPack->lvol3; IA.iArrInFeeSwitch[4]=rPack->lvol4; IA.iArrInFeeSwitch[5]=rPack->lvol5; IA.iArrInFeeSwitch[6]=rPack->lvol6; IA.iArrInFeeSwitch[7]=rPack->lvol7; IA.iArrInFeeSwitch[8]=rPack->lvol8; IA.iArrInFeeSwitch[9]=rPack->lvol9; IA.iArrInFeeSwitch[10]=rPack->lvol10; ret=process(&IA,&tradeserial); if(ret) { writelog(LOG_ERR,"process ret[%d]",ret); *pRetCode=ret; goto L_RETU; } sprintf(out_pack->vsmess,"流水号:%d 卡号:%d ",IA.iSerialNo,IA.iCardNo); for(i=1;i<=IA.iOutTxTypeCnt;i++) { switch(IA.iArrOutTxType[i]) { case TXTYPE_TOLL_DEPOSIT: case TXTYPE_DEDUCT_DEPOSIT: case TXTYPE_RETURN_DEPOSIT: tradeserial.deposit_fee=IA.dArrOutAmt[i]; break; case TXTYPE_PRE_TOLL_BOARD: case TXTYPE_TOLL_BOARD: case TXTYPE_DEDUCT_BOARD: case TXTYPE_RETURN_BOARD: tradeserial.boardfee=IA.dArrOutAmt[i]; break; case TXTYPE_TOLL_CHARGE: tradeserial.in_fee=IA.dArrOutAmt[i]; break; case TXTYPE_TOLL_CARDCOST: tradeserial.cost_fee=IA.dArrOutAmt[i]; break; default: break; } if(amtcmp(IA.dArrOutAmt[i],0)!=0) { sprintf(sMsg,"%s:%.2lf元 ",IA.sArrOutTxName[i],IA.dArrOutAmt[i]); strcat(out_pack->vsmess,sMsg); } } sprintf(sMsg,"卡当前余额:%.2lf元",tradeserial.out_balance); strcat(out_pack->vsmess,sMsg); writelog(LOG_DEBUG,out_pack->vsmess); ret = DB_t_tif_tradeserial_add(&tradeserial); if (ret) { writelog(LOG_ERR,"ret[%d]",ret); if(DB_REPEAT==ret) *pRetCode = E_DB_TRADESERIAL_E; else *pRetCode = E_DB_TRADESERIAL_I; goto L_RETU; } if(amtcmp(tradeserial.out_balance,0)<0) { *pRetCode=E_ENTER_ACCOUNT; goto L_RETU; } //检查金额是否超过最大额度 ret=GetParameter(GLOBE_MAXCARDBALANCE,sMaxCardBalance); if(ret) { *pRetCode=ret; goto L_RETU; } dMaxCardBalance=atof(sMaxCardBalance); if(amtcmp(tradeserial.out_balance,dMaxCardBalance)>0) { writelog(LOG_ERR,"tradeserial.out_balance[%lf]",tradeserial.out_balance); *pRetCode=E_AMT_EXCEED_MAX; goto L_RETU; } // 增加发行新卡时的门禁名单表检查 ret = CheckNewCardHook(&tCustomer, tCard.card_id); if(ret) { *pRetCode = ret; goto L_RETU; } //返回卡号\密码\显示卡号\客户类型\图书证号\有效截至日期 out_pack->lvol0 = (int)h_temp_Card_id; //交易卡号 out_pack->lvol1 = tCustomer.cut_type; //客户类别 out_pack->lvol5 = tCustomer.fee_type; //收费类别 des2src(out_pack->scust_no,h_showcardid); //显示卡号 des2src(out_pack->scust_no2,tCustomer.classdept_no); //部门号 des2src(out_pack->scust_auth,tCustomer.stuemp_no); //学号 des2src(out_pack->scust_auth2,tCustomer.man_id); //身份证号 des2src(out_pack->sname,tCustomer.cut_name); //客户姓名 des2src(out_pack->sname2,tCustomer.lib_cardid); //图书证号 des2src(out_pack->sstatus0,tCustomer.sex); //性别 des2src(out_pack->sopen_emp,h_password); //卡密码 des2src(out_pack->sdate0,card_endtime); //有效截至日期 out_pack->damt2=tradeserial.out_balance; //出卡值 out_pack->lserial1=tradeserial.serial_no; //流水号 // add by 汤成 2005-8-8 // 增加向名单表写入记录 ret = InsertToBlkList((int)h_temp_Card_id,CHCARD_BLACKLIST); if(ret) { *pRetCode = ret; goto L_RETU; } PutRow(handle,out_pack,pRetCode,szMsg); return 0; L_RETU: return -1; }
int F847101(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int hi_cutid = 0; //客户ID int hi_cuttype = 0; //客户类型 int i=0; int ret = 0; int len = 0; char h_showcardid[11] = ""; //显示卡号 char h_password[7] = ""; //卡密码 double h_temp_Card_id = 0; //卡号 char seed_key[17] = ""; //种子密钥 char card_endtime[8 + 1] = ""; //卡的有效截至日期 char logicdate[11]=""; //业务日期 char sysdate[11]=""; char systime[9]=""; char sMsg[256]=""; char sMaxCardBalance[20]=""; double dMaxCardBalance=0; int type=0; //充值类型 T_t_cif_customer tCustomer; T_t_pif_card tCard; T_t_aif_account tAccount; T_t_tif_tradeserial tradeserial; T_t_tif_savdtl tSavdtl; T_t_pif_spefee tSpeFee; double dUniqNo = 0; InAcc IA; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); memset(&IA,0,sizeof(IA)); memset(&tCard, 0, sizeof(tCard)); memset(&tAccount,0,sizeof(tAccount)); memset(&tradeserial,0,sizeof(tradeserial)); memset(&tSpeFee,0,sizeof(tSpeFee)); memset(&tCustomer,0,sizeof(tCustomer)); memset(&tSavdtl,0,sizeof(tSavdtl)); #ifdef DEBUG writelog(LOG_DEBUG,"rPack->scust_auth2[%s]",rPack->scust_auth2); #endif ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LVOL0,F_LVOL1,F_LVOL5, F_SCUST_NO, F_SCUST_NO2,F_SCUST_AUTH,F_SCUST_AUTH2, F_SDATE0,F_SNAME,F_SNAME2, F_SOPEN_EMP,F_SSTATUS0, F_DAMT2,F_LSERIAL1,F_VSMESS,0); hi_cutid = rPack->lvol0; //客户ID hi_cuttype = rPack->lvol3; //客户类别 des2src(h_showcardid,rPack->scust_no); //显示卡号 getsysdate(sysdate); getsystime(systime); ret=GetLogicDate(logicdate); //业务日期 if(ret) { *pRetCode=ret; goto L_RETU; } //检查客户信息,判断是否可以发行卡 des2src(tCard.physical_no, rPack->sbank_acc); //物理卡号 trim(h_showcardid); if(strlen(h_showcardid)) { ret=IsExistShowCardNo(h_showcardid); if(ret) { *pRetCode = ret; goto L_RETU; } } ret=IsExistCardByPhyCardNo(tCard.physical_no); if(ret) { *pRetCode = ret; goto L_RETU; } ret=IsExistCardByCustomId(hi_cutid); if (ret) { *pRetCode = ret; goto L_RETU; } //ret = DB_t_cif_customer_read_by_cut_id(hi_cutid, &tCustomer); //得到收费类别 memset(&tCustomer,0,sizeof tCustomer); ret=DB_t_cif_customer_read_lock_by_cur_and_cut_id(hi_cutid, &tCustomer); if(ret) { writelog(LOG_ERR,"cut_id[%d]",hi_cutid); if(DB_NOTFOUND==ret) *pRetCode= E_CUSTOMER_NOT_EXIST; else *pRetCode= E_DB_CUSTOMER_R; goto L_RETU; } if(tCustomer.fee_type<1) { ret=DB_t_pif_spefee_read_by_dept_code_and_cut_type(tCustomer.classdept_no, tCustomer.cut_type,&tSpeFee); if(ret) { if(DB_NOTFOUND==ret) { tCustomer.fee_type=tCustomer.cut_type; } else { DB_t_cif_customer_free_lock_cur(); *pRetCode=E_DB_SPEFEE_R; goto L_RETU; } } else { tCustomer.fee_type=tSpeFee.fee_type; } //更新客户表的收费类别字段 ret=DB_t_cif_customer_update_lock_by_cur(&tCustomer); if(ret) { if(DB_NOTFOUND==ret) *pRetCode= E_CUSTOMER_NOT_EXIST; else *pRetCode= E_DB_CUSTOMER_U; goto L_RETU; } } DB_t_cif_customer_free_lock_cur(); tradeserial.trade_fee =D4U5(rPack->damt0,2); //检查金额是否超过最大额度 ret=GetParameter(GLOBE_MAXCARDBALANCE,sMaxCardBalance); if(ret) { *pRetCode=ret; goto L_RETU; } dMaxCardBalance=atof(sMaxCardBalance); if(amtcmp(tradeserial.trade_fee,dMaxCardBalance)>0) { writelog(LOG_ERR,"tradeserial.trade_fee[%lf]",tradeserial.trade_fee); *pRetCode=E_AMT_EXCEED_MAX; goto L_RETU; } // 准备数据插入卡信息表 memcpy(seed_key,STATIC_SEED_KEY,16); //读种子密钥 if(strlen(tCustomer.can_time)==8) { ret=IsInvalidDateTime(tCustomer.can_time,"YYYYMMDD"); if(ret) { *pRetCode=E_TB_CUSTOMER_ENDTIME; goto L_RETU; } if(strncmp(tCustomer.can_time,sysdate,8)<=0) { *pRetCode=E_TB_CUSTOMER_ENDTIME; goto L_RETU; } des2src(card_endtime,tCustomer.can_time); } else if(strlen(rPack->sdate0)==0) { *pRetCode=E_TB_CUSTOMER_NO_ENDTIME; goto L_RETU; } else { ret=IsInvalidDateTime(rPack->sdate0,"YYYYMMDD"); if(ret) { *pRetCode = E_INPUT_DATE; goto L_RETU; } if(strncmp(rPack->sdate0,sysdate,8)<=0) { *pRetCode=E_INPUT_DATE; goto L_RETU; } des2src(card_endtime,rPack->sdate0); } // 默认密码, 初始取身份证的后6位, 没有身份证号用666666. len=strlen(tCustomer.man_id) ; if (len >= 6) { strncpy(h_password,&(tCustomer.man_id[len-6]),6); if(h_password[5]>'9'||h_password[5]<'0') h_password[5]='0'; } else { strcpy(h_password,DEFAULT_CUST_PWD); } ret = getNewUniqNo(KEYTYPE_CARD_ID,&h_temp_Card_id); //获取最大卡号 if(ret) { *pRetCode = ret; goto L_RETU; } tCard.card_id = D2I(h_temp_Card_id); //卡号 des2src(tCard.showid,h_showcardid); //显示卡号 des2src(tCard.is_main,TYPE_YES); //是否为主卡 des2src(tCard.state_id,CARDSTAT_REG); //卡状态 tCard.type_id = CT_NORMAL; //卡类别 EncodePwd(seed_key,h_password,tCard.password,0); //卡密码 tCard.cosumer_id = hi_cutid; //客户标识 tCard.account_count = ACCOUNT_COUNT_ONE; //卡对应帐户个数 des2src(tCard.begin_time,sysdate); //注册时间 des2src(tCard.end_time, card_endtime); //截至时间 tCard.phytype = PHYTYPE_NO_ONE; //设备物理型号;默认为1 // 插入卡信息 ret = DB_t_pif_card_add(&tCard); if (ret) { if(DB_REPEAT==ret) *pRetCode = E_DB_CARD_E; else *pRetCode = E_DB_CARD_I; goto L_RETU; } // 准备数据插入帐户信息表 ret = getNewActno(tAccount.account_id); //获得最大帐号 if (ret) { *pRetCode = ret; goto L_RETU; } des2src(tAccount.open_date,sysdate); //开户时间 des2src(tAccount.open_time,systime); tAccount.current_state = ACCOUNTSTAT_REGIST; //当前状态 tAccount.act_type = ACCTYPE_PERMAIN; //帐号类别 tAccount.customer_id = tCustomer.cut_id; //客户号 des2src(tAccount.cut_name,tCustomer.cut_name); //客户名称 tAccount.cut_type = tCustomer.cut_type; //客户类别 des2src(tAccount.stuemp_no,tCustomer.stuemp_no); //客户学号或员工号 tAccount.card_id = tCard.card_id; //关联卡号 tAccount.purse_id = PURSE_NO_ONE; //关联卡钱包号 tAccount.card_type = CT_NORMAL; //卡类别 des2src(tAccount.subno,SUBJECT_INDIVIDUALSAVING); //所属科目 des2src(tAccount.isautotra,TYPE_NO); //是否自动转帐 // 插入帐户信息表 ret = DB_t_aif_account_add(&tAccount); if (ret) { writelog(LOG_ERR,"ret [%d]",ret); if(DB_REPEAT==ret) *pRetCode = E_DB_ACCOUNT_E; else *pRetCode = E_DB_ACCOUNT_I; goto L_RETU; } ret = getNewUniqNo(KEYTYPE_TRADESERIAL,&dUniqNo); //获得最大流水号 if(ret) { *pRetCode = ret; writelog(LOG_ERR,"ret [%d]",ret); goto L_RETU; } // add by 汤成2005-09-05 // 记录发行正式卡信息 ///////////////////////////////////////////////////////////////////////// ret = InsertToCutUpdList(tCard.card_id, CUTUPD_ADD,tCard.physical_no); if( ret ) { *pRetCode = ret; goto L_RETU; } ///////////////////////////////////////////////////////////////////////// tradeserial.serial_no = D2I(dUniqNo); //流水号 tradeserial.other_seri_no = 0; //上传端流水号 tradeserial.serial_state = SERISTAT_DEBT; //流水状态 tradeserial.serial_type =TXCODE_CARD_OPEN_CASH; des2src(tradeserial.operate_date,sysdate); //发生日期 des2src(tradeserial.operate_time,systime); //发生时间 des2src(tradeserial.collect_date,sysdate); //采集日期 des2src(tradeserial.collect_time,systime); //采集时间 des2src(tradeserial.enteract_date,logicdate); //处理日期 des2src(tradeserial.enteract_time,systime); //处理时间 tradeserial.maindevice_id = rPack->lvol6; //上传工作站标识 tradeserial.device_id = rPack->lvol7; //采集设备标识 tradeserial.card_id = tCard.card_id; //卡号 des2src(tradeserial.showid,tCard.showid); //显示卡号 tradeserial.purse_id = PURSE_NO_ONE; //钱包号 tradeserial.customer_id = hi_cutid; //客户标识 des2src(tradeserial.oper_code , rPack->scust_limit); //操作员代码 tradeserial.sys_id = 0; //外部系统标识 tradeserial.trade_count=1; //当前卡交易次数 type=rPack->lvol4; //交易类型 IA.dArrInAmt[0]=tradeserial.trade_fee; switch(type) { case TYPE_CASH: //现金 IA.iArrInFeeSwitch[1]=1; break; case TYPE_BILL: //支票 IA.iArrInFeeSwitch[2]=1; break; case TYPE_FUNDBOOK: //经费本 IA.iArrInFeeSwitch[3]=1; break; default: *pRetCode=E_INPUT_DEPOSIT_TYPE; goto L_RETU; } switch(type) { case TYPE_CASH: //现金 break; case TYPE_BILL: //支票 case TYPE_FUNDBOOK: //经费本 // case TYPE_OTHER: //其他 tSavdtl.amount=rPack->damt0; //发生额 if(amtcmp(tSavdtl.amount,0)<=0) break; des2src(tSavdtl.bill_no,rPack->sphone); //票据号码 if(strlen(tSavdtl.bill_no)<1) { *pRetCode=E_INPUT_BILLNO; goto L_RETU; } tSavdtl.card_no=tCard.card_id; //卡号 des2src(tSavdtl.oper_no,rPack->scust_limit); //操作员 tSavdtl.seqno=tradeserial.serial_no; //流水号 des2src(tSavdtl.tx_date,logicdate); //发生日期 des2src(tSavdtl.tx_time,systime); //发生时间 tSavdtl.cnt=1; //票据数量 tSavdtl.bill_type=type; //票据类型 tSavdtl.tx_code=tradeserial.serial_type; //交易码 ret=DB_t_tif_savdtl_add(&tSavdtl); if(ret) { if(DB_REPEAT==ret) *pRetCode = E_DB_SAVDTL_E; else *pRetCode = E_DB_SAVDTL_I; goto L_RETU; } break; default: *pRetCode=E_TXCODE_NOT_EXIST; goto L_RETU; } des2src(IA.sArrInActno[0],tAccount.account_id); //帐户 IA.iCardNo=tCard.card_id; IA.iFeeType=tCustomer.fee_type; IA.iArrInFeeSwitch[0]=rPack->lvol0; IA.iArrInFeeSwitch[5]=rPack->lvol5; IA.iArrInFeeSwitch[6]=rPack->lvol6; IA.iArrInFeeSwitch[7]=rPack->lvol7; IA.iArrInFeeSwitch[8]=rPack->lvol8; IA.iArrInFeeSwitch[9]=rPack->lvol9; IA.iArrInFeeSwitch[10]=rPack->lvol10; //调用入账子模块 ret=process(&IA,&tradeserial); if(ret) { *pRetCode=ret; writelog(LOG_ERR,"process ret[%d]",ret); goto L_RETU; } sprintf(out_pack->vsmess,"流水号:%d 卡号:%d ",IA.iSerialNo,IA.iCardNo); for(i=1;i<=IA.iOutTxTypeCnt;i++) { switch(IA.iArrOutTxType[i]) { case TXTYPE_TOLL_DEPOSIT: case TXTYPE_TOLL_DEPOSIT_BILL: case TXTYPE_TOLL_DEPOSIT_FUNDBOOK: case TXTYPE_DEDUCT_DEPOSIT: case TXTYPE_RETURN_DEPOSIT: tradeserial.deposit_fee=IA.dArrOutAmt[i]; break; case TXTYPE_PRE_TOLL_BOARD: case TXTYPE_PRE_TOLL_BOARD_BILL: case TXTYPE_PRE_TOLL_BOARD_FUNDBOOK: case TXTYPE_TOLL_BOARD: case TXTYPE_DEDUCT_BOARD: case TXTYPE_RETURN_BOARD: case TXTYPE_RETURN_BOARD_BILL: case TXTYPE_RETURN_BOARD_FUNDBOOK: tradeserial.boardfee=IA.dArrOutAmt[i]; break; case TXTYPE_TOLL_CHARGE: case TXTYPE_TOLL_CHARGE_BILL: case TXTYPE_TOLL_CHARGE_FUNDBOOK: tradeserial.in_fee=IA.dArrOutAmt[i]; break; case TXTYPE_TOLL_CARDCOST: case TXTYPE_TOLL_CARDCOST_BILL: case TXTYPE_TOLL_CARDCOST_FUNDBOOK: tradeserial.cost_fee=IA.dArrOutAmt[i]; break; default: break; } if(amtcmp(IA.dArrOutAmt[i],0)!=0) { sprintf(sMsg,"%s:%.2lf元 ",IA.sArrOutTxName[i],IA.dArrOutAmt[i]); strcat(out_pack->vsmess,sMsg); } } sprintf(sMsg,"卡当前余额:%.2lf元",tradeserial.out_balance); strcat(out_pack->vsmess,sMsg); writelog(LOG_DEBUG,out_pack->vsmess); // 插入交易流水表 ret = DB_t_tif_tradeserial_add(&tradeserial); if (ret) { writelog(LOG_ERR,"ret[%d]",ret); if(DB_REPEAT==ret) *pRetCode = E_DB_TRADESERIAL_E; else *pRetCode = E_DB_TRADESERIAL_I; goto L_RETU; } if(amtcmp(tradeserial.out_balance,0)<0) { *pRetCode=E_ENTER_ACCOUNT; goto L_RETU; } /* // 增加发行新卡时的门禁名单表检查 ret = CheckNewCardHook(&tCustomer, tCard.card_id); if(ret) { *pRetCode = ret; goto L_RETU; } */ // 返回卡号\密码\显示卡号\客户类型\图书证号\有效截至日期 out_pack->lvol0 = (int)h_temp_Card_id; //交易卡号 out_pack->lvol1 = tCustomer.cut_type; //客户类别 out_pack->lvol5 = tCustomer.fee_type; //收费类别 des2src(out_pack->scust_no,h_showcardid); //显示卡号 des2src(out_pack->scust_no2,tCustomer.classdept_no); //部门号 des2src(out_pack->scust_auth,tCustomer.stuemp_no); //学号 des2src(out_pack->scust_auth2,tCustomer.man_id); //身份证号 des2src(out_pack->sname,tCustomer.cut_name); //客户姓名 des2src(out_pack->sname2,tCustomer.lib_cardid); //图书证号 des2src(out_pack->sstatus0,tCustomer.sex); //性别 des2src(out_pack->sopen_emp,h_password); //卡密码 des2src(out_pack->sdate0,card_endtime); //有效截至日期 out_pack->damt2=tradeserial.out_balance; //出卡值 out_pack->lserial1=tradeserial.serial_no; //流水号 PutRow(handle,out_pack,pRetCode,szMsg); return 0; L_RETU: return -1; }
/** * \brief 处理网银转账入账业务 * \param in_pack 请求报文包 * \param out_pack 输出报文包 * \param online_tx 联机交易,当为1时,如果个人账户已注销,则不能交易, * 当为0时,如果个人账户已注销,则借记 现金,贷记 营业成本 */ int do_849009(ST_PACK *in_pack,char *szMsg,ST_PACK *out_pack,int online_tx) { int cust_id,card_id; int subsidy_no; int ret,count; char temp[64]; double max_subsidy_money = 0.0; double total_money,dSerial; T_t_tif_subsidy subsidy; T_t_tif_tradeserial tSerial; T_t_aif_account account; T_t_tif_meslist tMesList; InAcc IA; if(amtcmp(in_pack->damt0,0.0) <= 0) { writelog(LOG_DEBUG,"input money error!"); return E_INPUT_AMT; } memset(temp,0,sizeof temp); ret = GetParameter(GLOBAL_MAX_PER_SUBSIDY,temp); if(ret) { return ret; } max_subsidy_money = D4U5(atof(temp),2); // 流水号 ret = getNewUniqNo(KEYTYPE_TRADESERIAL,&dSerial); if(ret) { return ret; } // 查询卡信息 ret = do_849008_query(in_pack,&cust_id,&card_id); if(ret) { writelog(LOG_DEBUG,"query customer information error!,ret[%d]",ret); return ret; } // 账户信息 memset(&account,0,sizeof account); ret = DB_t_aif_account_read_by_card_id_and_purse_id(card_id,in_pack->lvol3,&account); if(ret) { // 账户表无信息 if(DB_NOTFOUND == ret) return E_DB_ACCOUNT_N; else return E_DB_ACCOUNT_R; } // 生成流水记录 memset(&tSerial,0,sizeof tSerial); writelog(LOG_DEBUG,"cust_id[%d],Serial_no[%d]]",cust_id,in_pack->lvol2); ret = do_849008_query_serial(cust_id,in_pack->lvol2,&tSerial); if(ret) { return ret; } // 认为已经入账成功,直接返回结果 if(tSerial.serial_no > 0) { out_pack->lvol0 = tSerial.card_id; out_pack->lvol1 = tSerial.serial_no; out_pack->lvol2 = tSerial.customer_id; out_pack->damt0 = tSerial.trade_fee; return 0; } memset(&IA,0,sizeof IA); tSerial.serial_no = D2I(dSerial); tSerial.serial_type = TXCODE_NETFEE_TRANS; // 网银转账 tSerial.serial_state = SERISTAT_DEBT; des2src(tSerial.oper_code,in_pack->scust_no2); des2src(tSerial.operate_date,in_pack->sdate0); des2src(tSerial.operate_time,in_pack->stime0); GetLogicDate(tSerial.enteract_date); getsystime(tSerial.enteract_time); getsysdate(tSerial.collect_date); des2src(tSerial.collect_time,tSerial.enteract_time); tSerial.customer_id = cust_id; tSerial.card_id = card_id; tSerial.in_balance = 0.0; tSerial.out_balance = 0.0; tSerial.trade_fee = in_pack->damt0; tSerial.other_seri_no = in_pack->lvol2; // 银行端流水号 if(account.current_state >= ACCOUNTSTAT_LOGOUT) { // 个人账户已经注销 if(online_tx) return E_ACTNO_LOGOUT; // 借记 银行存款 贷记 营业成本 des2src(IA.sArrInActno[3],"1021"); IA.dArrInAmt[1] = tSerial.trade_fee; } else { // 个人账户号 des2src(IA.sArrInActno[0],account.account_id); IA.dArrInAmt[0] = tSerial.trade_fee; } IA.iFeeType=1; ret = process(&IA,&tSerial); if(ret) { writelog(LOG_ERR,"入账失败,cust_id[%d],card_id[%d],ret[%d]" ,cust_id,card_id,ret); return ret; } ret = DB_t_tif_tradeserial_add(&tSerial); if(ret) { writelog(LOG_ERR,"记录流水失败"); return E_DB_TRADESERIAL_I; } // 先入账 total_money = 0.0; count = 0; memset(&subsidy,0,sizeof subsidy); subsidy.cust_no = cust_id; getsysdatetime(subsidy.batch_no); des2src(subsidy.oper_code,tSerial.oper_code); strcpy(subsidy.summary,"网银转账"); strcpy(subsidy.expire_date,"20500101"); subsidy.bill_type = TYPE_CASH; subsidy.card_no = card_id; des2src(subsidy.tx_date,tSerial.operate_date); des2src(subsidy.tx_time,tSerial.operate_time); subsidy.status[0] = SUBSIDY_STAT_NORMAL; strcpy(subsidy.subsidytype,"1"); subsidy.amount = D4U5(in_pack->damt0 - total_money,2); if(amtcmp(subsidy.amount,0.0) <= 0) { // 剩余金额为 0, 不可能出现小于 0 // break; ret=E_MOBILE_TRANS_ZERO; return ret; } else if(amtcmp(subsidy.amount,max_subsidy_money) > 0.0) { // 单笔金额不能大于最大值 //subsidy.amount = max_subsidy_money; ret=E_MOBILE_TRANS_MAX; return ret; } total_money = D4U5(total_money+subsidy.amount,2); ret = calc_card_max_subsidy_no(cust_id,card_id,&subsidy_no); if(ret) { writelog(LOG_DEBUG,"cannot calculate max subsidy NO,cust[%d],card[%d],ret[%d]", cust_id,card_id,ret); return ret; } subsidy.subsidy_no = subsidy_no; ret = DB_t_tif_subsidy_add(&subsidy); if(ret) { // 记录信息失败 if(DB_REPEAT == ret) return E_DB_SUBSIDY_E; else return E_DB_SUBSIDY_I; } out_pack->lvol0 = card_id; out_pack->lvol1 = tSerial.serial_no; out_pack->lvol2 = tSerial.customer_id; out_pack->damt0 = tSerial.trade_fee; 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 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 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 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; } // ret=UpdateCardBitmap(trans.cardno,trans.cardcnt,CARDBITMAPTYPE_DEC,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) { 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=tCardAccount.custid; des2src(transdtl.custname,tCardAccount.accname); des2src(transdtl.opercode,trans.opercode); transdtl.status[0]=DTLSTATUS_SUCCESS; transdtl.showcardno=atol(tCard.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; } 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 F847123(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; int card_id=0; char sSeedKey[17] = ""; //种子密钥 char sPwd[7] = ""; //卡密码 char logicdate[11]=""; char sysdate[11]=""; char systime[9]=""; double dSerialno=0; T_t_pif_card tCard; T_t_cif_customer tCustomer; T_t_pif_spefee tSpeFee; T_t_aif_account tAccount; T_t_tif_tradeserial tTradeserial; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); memset(&tCard,0,sizeof(tCard)); memset(&tCustomer,0,sizeof(tCustomer)); memset(&tSpeFee,0,sizeof(tSpeFee)); memset(&tAccount,0,sizeof(tAccount)); memset(&tTradeserial,0,sizeof(tTradeserial)); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LVOL0,F_LVOL1,F_LVOL10,F_LVOL5, F_SCUST_NO, F_SCUST_NO2,F_SCUST_AUTH,F_SCUST_AUTH2, F_SDATE0,F_SNAME,F_SNAME2, F_SOPEN_EMP,F_SSTATUS0, F_DAMT2,F_LSERIAL1,F_VSMESS,0); card_id=rPack->lvol0; if(card_id<1) { *pRetCode=E_INPUT_CARDNO; goto L_RETU; } getsysdate(sysdate); getsystime(systime); ret=GetLogicDate(logicdate); //业务日期 if(ret) { *pRetCode=ret; goto L_RETU; } //判断卡状态是否为写卡未成功状态 ret=DB_t_pif_card_read_lock_by_cur_and_card_id(card_id, &tCard); if(ret) { writelog(LOG_ERR,"card_id[%d]",card_id); if(DB_NOTFOUND==ret) *pRetCode= E_CARDNO_NOT_EXIST; else *pRetCode= E_DB_CARD_R; goto L_RETU; } if(card_id!=tCard.card_id) { writelog(LOG_ERR,"card_id[%d] db card_id[%d]",card_id,tCard.card_id); DB_t_pif_card_free_lock_by_cur(); *pRetCode=E_DB_CARD_R; goto L_RETU; } if('3'!=tCard.state_id[CARDSTAT_TYPE_REG]) { DB_t_pif_card_free_lock_by_cur(); if('2'==tCard.state_id[CARDSTAT_TYPE_REG]) *pRetCode=E_CARDNO_LOGOUT; else if(STATE_TRUE==tCard.state_id[CARDSTAT_TYPE_LOST]) *pRetCode=E_CARDNO_LOST; else if(STATE_TRUE==tCard.state_id[CARDSTAT_TYPE_FREEZE]) *pRetCode=E_CARDNO_FREEZE; else if(STATE_TRUE==tCard.state_id[CARDSTAT_TYPE_WFAIL]) *pRetCode=E_CARDNO_WFAIL; else if(STATE_TRUE==tCard.state_id[CARDSTAT_TYPE_REG]) *pRetCode=E_OLDCARDINFO_NOSAVE; goto L_RETU; } trim(rPack->sbank_acc); trim(rPack->scust_no); trim(rPack->sdate0); if(strlen(rPack->scust_no)) { ret=IsExistShowCardNo(rPack->scust_no); if(ret) { *pRetCode = ret; goto L_RETU; } } if(strcmp(tCard.physical_no,rPack->sbank_acc)!=0) { ret=IsExistCardByPhyCardNo(rPack->sbank_acc); if(ret) { *pRetCode = ret; goto L_RETU; } } ret=IsInvalidDateTime(rPack->sdate0,"YYYYMMDD"); if(ret) { *pRetCode=ret; goto L_RETU; } des2src(tCard.physical_no, rPack->sbank_acc); //物理卡号 des2src(tCard.showid,rPack->scust_no); //显示卡号 des2src(tCard.end_time,rPack->sdate0); //到期日期 ret=DB_t_pif_card_update_lock_by_cur(&tCard); if(ret) { writelog(LOG_ERR,"card_id[%d]",card_id); if(DB_NOTFOUND==ret) *pRetCode= E_CARDNO_NOT_EXIST; else *pRetCode= E_DB_CARD_U; goto L_RETU; } DB_t_pif_card_free_lock_by_cur(); memcpy(sSeedKey,STATIC_SEED_KEY,16); //读种子密钥 EncodePwd(sSeedKey,sPwd,tCard.password,1); //卡密码 //注销帐户 ret=DB_t_aif_account_read_by_card_id_and_purse_id(card_id,PURSE_NO_ONE, &tAccount); if(ret) { writelog(LOG_ERR,"DB_t_aif_account_read_by_card_id_and_purse_id ret[%d]card_id[%d]",ret,card_id); if(DB_NOTFOUND==ret) *pRetCode= E_ACTNO_NOT_EXIST; else *pRetCode= E_DB_ACCOUNT_R; goto L_RETU; } if(tAccount.consume_count<1) { *pRetCode=E_CARD_TXCNT; goto L_RETU; } if(amtcmp(tAccount.card_balance,0)<0) { *pRetCode=E_CARD_BALA; goto L_RETU; } ret=DB_t_cif_customer_read_lock_by_cur_and_cut_id(tCard.cosumer_id, &tCustomer); if(ret) { writelog(LOG_ERR,"cut_id[%d]",tCard.cosumer_id); if(DB_NOTFOUND==ret) *pRetCode= E_CUSTOMER_NOT_EXIST; else *pRetCode= E_DB_CUSTOMER_R; goto L_RETU; } //得到收费类别 if(tCustomer.fee_type<1) { ret=DB_t_pif_spefee_read_by_dept_code_and_cut_type(tCustomer.classdept_no, tCustomer.cut_type,&tSpeFee); if(ret) { if(DB_NOTFOUND==ret) { tCustomer.fee_type=tCustomer.cut_type; } else { DB_t_cif_customer_free_lock_cur(); *pRetCode=E_DB_SPEFEE_R; goto L_RETU; } } else { tCustomer.fee_type=tSpeFee.fee_type; } //更新客户表的收费类别字段 ret=DB_t_cif_customer_update_lock_by_cur(&tCustomer); if(ret) { if(DB_NOTFOUND==ret) *pRetCode= E_CUSTOMER_NOT_EXIST; else *pRetCode= E_DB_CUSTOMER_U; goto L_RETU; } } DB_t_cif_customer_free_lock_cur(); ret = getNewUniqNo(KEYTYPE_TRADESERIAL,&dSerialno); //获得流水号 if(ret) { *pRetCode = ret; writelog(LOG_ERR,"ret [%d]",ret); goto L_RETU; } tTradeserial.serial_no = (int)dSerialno; //流水号 tTradeserial.other_seri_no = 0; //上传端流水号 tTradeserial.serial_type = 847123; //交易代码;备注:发卡+充值 用一个交易码,即847101; 发卡(不充值)另用一个交易码,即新的发卡程序文件名,从而区分发卡充值与发卡不充值的卡操作信息。 tTradeserial.serial_state = SERISTAT_DEBT; //流水状态 des2src(tTradeserial.operate_date,sysdate); //发生日期 des2src(tTradeserial.operate_time,systime); //发生时间 des2src(tTradeserial.collect_date,sysdate); //采集日期 des2src(tTradeserial.collect_time,systime); //采集时间 des2src(tTradeserial.enteract_date,logicdate); //处理日期 des2src(tTradeserial.enteract_time,systime); //处理时间 des2src(tTradeserial.oper_code , rPack->scust_limit); tTradeserial.maindevice_id = rPack->lvol6; //上传工作站标识 tTradeserial.device_id = rPack->lvol7; //采集设备标识 tTradeserial.card_id = tCard.card_id; //卡号 des2src(tTradeserial.showid,tCard.showid); //显示卡号 tTradeserial.purse_id = PURSE_NO_ONE; //钱包号 tTradeserial.customer_id = tCard.cosumer_id; //客户标识 //插入交易流水表 ret = DB_t_tif_tradeserial_add(&tTradeserial); if (ret) { writelog(LOG_ERR,"ret[%d]",ret); if(DB_REPEAT==ret) *pRetCode = E_DB_TRADESERIAL_E; else *pRetCode = E_DB_TRADESERIAL_I; goto L_RETU; } out_pack->lvol0 = card_id; //交易卡号 out_pack->lvol1 = tCustomer.cut_type; //客户类别 out_pack->lvol5 = tCustomer.fee_type; //收费类别 des2src(out_pack->scust_no,tCard.showid); //显示卡号 des2src(out_pack->scust_no2,tCustomer.classdept_no); //部门号 des2src(out_pack->scust_auth,tCustomer.stuemp_no); //学号 des2src(out_pack->scust_auth2,tCustomer.man_id); //身份证号 des2src(out_pack->sname,tCustomer.cut_name); //客户姓名 des2src(out_pack->sname2,tCustomer.lib_cardid); //图书证号 des2src(out_pack->sstatus0,tCustomer.sex); //性别 des2src(out_pack->sopen_emp,sPwd); //卡密码 des2src(out_pack->sdate0,tCard.end_time); //有效截至日期 out_pack->damt2=D4U5(tAccount.card_balance,2); //卡余额 out_pack->lvol10=tAccount.consume_count; //消费次数 out_pack->lserial1=tTradeserial.serial_no; //流水号 sprintf(out_pack->vsmess,"流水号:%d 卡号:%d 学工号:%s 姓名:%s 卡余额:%.2lf元",tTradeserial.serial_no,card_id,tCustomer.stuemp_no,tCustomer.cut_name,tAccount.card_balance); writelog(LOG_DEBUG,out_pack->vsmess); // add by 汤成 2005-8-8 // 增加向名单表写入记录 ret = InsertToBlkList(card_id,CHCARD_BLACKLIST); if(ret) { *pRetCode = ret; goto L_RETU; } PutRow(handle,out_pack,pRetCode,szMsg); return 0; L_RETU: return -1; }
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;
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 D2I(double value) { return (int)D4U5(value,0); }
int F847183(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; char tx_date[8+1]=""; //发生日期 char tx_time[6+1]=""; //发生时间 int card_no=0; //卡号 char device_id[8+1]=""; //终端机ID int serial_no=0; //终端机流水号 double dUniqno=0; T_t_tif_tradeserial tTradeserial; //卡操作流水表 T_t_tif_rcvdtl tRcvdtl; char sysdate[11]=""; char systime[9]=""; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); memset(&tRcvdtl,0,sizeof(tRcvdtl)); memset(&tTradeserial,0,sizeof(tTradeserial)); getsysdate(sysdate); getsystime(systime); des2src(tTradeserial.enteract_time,systime); des2src(tx_date,rPack->sbank_pwd); des2src(tx_time,rPack->sbank_code); card_no=rPack->lvol0; des2src(device_id,rPack->sbank_pwd2); serial_no=rPack->lvol1; trim(rPack->scust_limit); trim(rPack->scust_limit2); trim(rPack->semp_pwd); if(strlen(rPack->scust_limit)==0) { *pRetCode=E_OPER_NOT_EXIST; goto L_RETU; } if(strlen(rPack->scust_limit2)==0) { *pRetCode=E_INPUT_AUTH_OPER_NULL; goto L_RETU; } if(strcmp(rPack->scust_limit,rPack->scust_limit2)==0) { writelog(LOG_ERR,"oper[%s]auth_oper[%s]",rPack->scust_limit,rPack->scust_limit2); *pRetCode=E_OPER_AND_AUTH_OPER_EQ; goto L_RETU; } ret=chk_oper_pwd(rPack->scust_limit2,rPack->semp_pwd); if(ret) { if(E_OPER_NOT_EXIST==ret) *pRetCode=E_AUTH_OPER_NOT_EXIST; else if(E_PASSWORD_WRONG==ret) *pRetCode=E_AUTH_OPER_PWD; else *pRetCode=ret; goto L_RETU; } ret=DB_t_tif_rcvdtl_read_lock_by_c0_and_tx_date_and_tx_time_and_card_no_and_device_id_and_serial_no(tx_date,tx_time,card_no,device_id,serial_no,&tRcvdtl); if(ret) { if(DB_NOTFOUND==ret) { writelog(LOG_ERR,"tx_date[%s],tx_time[%s],card_no[%d],device_id[%s],serial_no[%d]",tx_date,tx_time,card_no,device_id,serial_no); *pRetCode=E_SERIALNO_NOT_EXIST; } else { writelog(LOG_ERR,"read_lock t_tif_rcvdtl err ret[%d]",ret); *pRetCode=E_DB_RCVDTL_R; } goto L_RETU; } if(tRcvdtl.status[0]=='4') { *pRetCode=E_TX_SERIAL_CZ; DB_t_tif_rcvdtl_free_lock_c0(); goto L_RETU; } if(tRcvdtl.status[0]!='3') { *pRetCode=E_TX_SERIAL_CANNOT_CZ; DB_t_tif_rcvdtl_free_lock_c0(); goto L_RETU; } if(tRcvdtl.amount<0) { *pRetCode=E_TX_SERIAL_CANNOT_CZ; DB_t_tif_rcvdtl_free_lock_c0(); goto L_RETU; } tRcvdtl.status[0]='4'; //冲正 des2src(tRcvdtl.oper_no,rPack->scust_limit); des2src(tRcvdtl.deal_date,sysdate); des2src(tRcvdtl.deal_time,systime); ret=DB_t_tif_rcvdtl_update_lock_by_c0(&tRcvdtl); if(ret) { *pRetCode=E_DB_RCVDTL_U; writelog(LOG_ERR,"DB_t_tif_rcvdtl_update_lock_by_c0[%d]",ret); goto L_RETU; } DB_t_tif_rcvdtl_free_lock_c0(); //赋值 ret=getdata(&tTradeserial,&tRcvdtl); if(ret) { *pRetCode=ret; goto L_RETU; } des2src(tTradeserial.operate_date,sysdate); des2src(tTradeserial.operate_time,systime); des2src(tTradeserial.collect_date,sysdate); des2src(tTradeserial.collect_time,systime); ret=GetLogicDate(tTradeserial.enteract_date); //业务日期 if(ret) { *pRetCode=ret; writelog(LOG_ERR,"GetLogicDate err ret[%d]",ret); goto L_RETU; } des2src(tTradeserial.enteract_time,systime); tTradeserial.in_balance =rPack->damt1; tTradeserial.trade_fee = -1 * D4U5(tRcvdtl.amount/100.0,2); //本次消费金额 tTradeserial.boardfee = -1 * D4U5(tRcvdtl.manage_fee/100.0,2); //本次消费管理费 tTradeserial.out_balance=tTradeserial.in_balance-tTradeserial.trade_fee; tTradeserial.trade_count=rPack->lvol10; tTradeserial.maindevice_id=rPack->lvol6; // tTradeserial.sys_id=rPack->lvol6; des2src(tTradeserial.oper_code,rPack->scust_limit); tTradeserial.reviseserial_no=tTradeserial.other_seri_no; //取流水号,从帐处理 ret=getNewUniqNo(KEYTYPE_TRADESERIAL, &dUniqno); if(ret) { *pRetCode=ret; writelog(LOG_ERR,"getNewUniqNo err[%d]",ret); goto L_RETU; } tTradeserial.serial_no=(int)dUniqno; //###################################################### //入账处理 switch(tTradeserial.serial_type) { case 930031: // 交易冲正 if(0==tRcvdtl.amount) break; tTradeserial.serial_type=TXCODE_TX_REVEAL; ret=process930031(&tTradeserial); if(ret) { //业务处理失败处理 *pRetCode=ret; goto L_RETU; } break; case 930034: // 充值冲正 if(0==tRcvdtl.amount) break; tTradeserial.serial_type=TXCODE_TX_REVEAL; ret=process930034(&tTradeserial); if(ret) { //业务处理失败处理 *pRetCode=ret; goto L_RETU; } break; case 930036: // 搭伙费冲正 if(0==tRcvdtl.amount) break; tTradeserial.serial_type=TXCODE_TX_REVEAL; ret=process930036(&tTradeserial); if(ret) { //业务处理失败处理 *pRetCode=ret; goto L_RETU; } break; default: *pRetCode=E_TXCODE_NOT_EXIST; //交易码错误 goto L_RETU; } //###################################################### //添加交易流水 tTradeserial.serial_state=SERISTAT_DEBT; ret = DB_t_tif_tradeserial_add(&tTradeserial); if (ret) { writelog(LOG_ERR,"DB_t_tif_tradeserial_add ret[%d]",ret); if(DB_REPEAT==ret) *pRetCode= E_DB_TRADESERIAL_E; else *pRetCode= E_DB_TRADESERIAL_I; goto L_RETU; } if(amtcmp(tTradeserial.out_balance,0)<0) { *pRetCode=E_ENTER_ACCOUNT; goto L_RETU; } SetCol(handle,0); SetCol(handle,F_LSERIAL1,F_DAMT2,F_DAMT3,F_VSMESS,0); out_pack->lserial1=tTradeserial.serial_no; out_pack->damt2=tTradeserial.out_balance; out_pack->damt3=-tTradeserial.trade_fee; sprintf(out_pack->vsmess,"流水号:%d 冲正金额:%.2lf元 冲正前卡余额:%.2lf元 卡当前余额:%.2lf元",tTradeserial.serial_no,-tTradeserial.trade_fee,tTradeserial.in_balance,tTradeserial.out_balance); writelog(LOG_DEBUG,out_pack->vsmess); PutRow(handle,out_pack,pRetCode,szMsg); return 0; L_RETU: return -1; }
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 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 AccountProcess(InAcc *IA) { int ret=-1; int iTxType=0; //交易类型 char num_exp[256]=""; char sFee[256]=""; char sFormula[256]=""; char sIdxDbActNo[4]=""; char sIdxCrActNo[4]=""; char sVocNo[21] = ""; char cur_date[9]=""; char tradetime[15] = ""; double dExpCalAmt=0; int iVocType = VOCTYPE_DEFALUT; char * pMessage = (char*)IA->pVoidPointer; int i = 0; // int idx=0; int idxTxCfg=-1; int idxSubCfg=-1; int config_cnt=1; int db_amt_flag=0; int cr_amt_flag=0; double dInCardBala=0; double dCardBala=0; double dOutCardBala=0; T_t_pif_card tCard; T_t_aif_account tAccountDb; T_t_aif_account tAccountCr; T_t_tif_tradelog tTradelogDb; T_t_tif_tradelog tTradelogCr; getsysdate(cur_date); sprintf(tradetime,"%s%s",IA->sTxDate,IA->sTxTime); ret=InitTxFeeCfg(IA->iTradeNo); if(ret) return ret; ret=InitSplitCfg(); if(ret) return ret; ret=InitSubjectCfg(); if(ret) return ret; //根据交易码和客户收费类别读交易配置表 if(IA->iFeeType<1) { return E_CUSTOMER_NO_FEE_TYPE; } idxTxCfg=GetIndexTxFeeCfgByTxCode(IA->iTradeNo,IA->iFeeType); if(idxTxCfg<0) { //如果没有取默认值 idxTxCfg=GetIndexTxFeeCfgByTxCode(IA->iTradeNo,0); if(idxTxCfg<0) { writelog(LOG_ERR,"tx_code[%d]fee_type[%d]",IA->iTradeNo,IA->iFeeType); return E_CUSTOMER_NO_RIGHT; } } dInCardBala=IA->dInCardBala; dCardBala=IA->dInCardBala; dOutCardBala=IA->dOutCardBala; for(config_cnt=1; config_cnt<=MAXNUM_CFGSPLIT; config_cnt++) { //开始遍历收费集合 ret=GetValueFromFmtBuf(CfgFee.ArrCfgFee[idxTxCfg].fee_list,",",config_cnt,sFee); if(ret) { if(1==config_cnt) { writelog(LOG_ERR, "TxCode[%d]FeeType[%d]fee_list[%s]",IA->iTradeNo,IA->iFeeType,CfgFee.ArrCfgFee[idxTxCfg].fee_list); return E_TXCODE_NOT_CONFIG; //交易未配置 } //writelog(LOG_ERR,"GetValueFromFmtBuf return error [%d]",ret); break; } iTxType=atoi(sFee); if(iTxType<0) { writelog(LOG_ERR,"tx_code[%d]fee_type[%d]",IA->iTradeNo,IA->iFeeType); return E_CUSTOMER_NO_RIGHT; } // writelog(LOG_DEBUG,"fee_list[%s]sFee[%s]",CfgFee.ArrCfgFee[idxTxCfg].fee_list,sFee); ret=GetValueFromFmtBuf(CfgFee.ArrCfgFee[idxTxCfg].formula_list,",",config_cnt,sFormula); if(ret) { writelog(LOG_ERR, "TxCode[%d]FeeType[%d]formula_list[%s]",IA->iTradeNo,IA->iFeeType,CfgFee.ArrCfgFee[idxTxCfg].formula_list); return E_EXP_NOT_CFG; //交易未配置 } // writelog(LOG_DEBUG,"formula_list[%s]Formula[%s]",CfgFee.ArrCfgFee[idxTxCfg].formula_list,sFormula); //得到收费类型 /* switch(iTxType) { // case TXTYPE_TOLL_DEPOSIT: //收押金 case TXTYPE_RETURN_DEPOSIT: //退押金 case TXTYPE_DEDUCT_DEPOSIT: //扣押金 memset(&tCard,0,sizeof(tCard)); if(IA->iCardNo<1) { return E_INPUT_CARDNO_CANNOT_NULL; } ret=DB_t_pif_card_read_by_card_id(IA->iCardNo,&tCard); if(ret) { if(DB_NOTFOUND==ret) return E_CARDNO_NOT_EXIST; else return E_DB_CARD_R; } dExpCalAmt=tCard.deposit_fee; break; default: ret=VarExp2NumExp(IA->dArrInAmt,IA->iArrInFeeSwitch,sFormula,num_exp); if(ret) { writelog(LOG_ERR,"ret[%d]txcode[%d]txtype[%d]formula[%s]",ret,IA->iTradeNo, iTxType,sFormula); return E_EXP_CFG; } // writelog(LOG_ERR,"formula[%s]num_exp[%s]",sFormula,num_exp); ret=ExpCalAmt(num_exp, &dExpCalAmt); if(ret) { writelog(LOG_ERR,"formula[%s]num_exp[%s]",sFormula,num_exp); return E_EXP_CFG; } writelog(LOG_ERR,"formula[%s]num_exp[%s]amt[%lf]",sFormula,num_exp,dExpCalAmt); break; } */ //根据公式计算发生额 ret=VarExp2NumExp(IA->dArrInAmt,IA->iArrInFeeSwitch,sFormula,num_exp); if(ret) { writelog(LOG_ERR,"ret[%d]txcode[%d]txtype[%d]formula[%s]",ret,IA->iTradeNo, iTxType,sFormula); return E_EXP_CFG; } // writelog(LOG_DEBUG,"formula[%s]num_exp[%s]",sFormula,num_exp); ret=ExpCalAmt(num_exp, &dExpCalAmt); if(ret) { writelog(LOG_ERR,"formula[%s]num_exp[%s]",sFormula,num_exp); return E_EXP_CFG; } dExpCalAmt=D4U5(dExpCalAmt,2); // writelog(LOG_DEBUG,"formula[%s]num_exp[%s]amt[%.4lf]",sFormula,num_exp,dExpCalAmt); //如果金额为0则continue if(amtcmp(dExpCalAmt,0)==0) { continue; } else if(amtcmp(dExpCalAmt,0)<0) { //如果不是冲正交易则不允许金额小于0 if(ACC_TYPE_NORMAL == IA->iTxFlag) { writelog(LOG_DEBUG,"交易名称[%s]当前交易金额[%.4lf]",CfgSplit.ArrCfgsplit[iTxType].txname,dExpCalAmt); if(IA->pVoidPointer != NULL) { sprintf((char*)IA->pVoidPointer,"%.2lf",dExpCalAmt); } return E_AMT_LACK; } } else { //冲正交易不允许金额大于0 if(ACC_TYPE_RUSH == IA->iTxFlag) { writelog(LOG_DEBUG,"交易名称[%s]当前交易金额[%.4lf]",CfgSplit.ArrCfgsplit[iTxType].txname,dExpCalAmt); return E_INPUT_AMT; } } //类型为0的交易是用来检查输入金额是否有错误 if(0==iTxType) { writelog(LOG_DEBUG,"交易名称[%s]当前交易金额[%.4lf]",CfgSplit.ArrCfgsplit[iTxType].txname,dExpCalAmt); return E_INPUT_AMT; } memset(sIdxDbActNo,0,sizeof(sIdxDbActNo)); memset(sIdxCrActNo,0,sizeof(sIdxCrActNo)); memset(&tTradelogDb, 0, sizeof(tTradelogDb)); memset(&tTradelogCr, 0, sizeof(tTradelogCr)); switch (CfgSplit.ArrCfgsplit[iTxType].dbflag) { case TYPE_INPUT: /* ret=GetValueFromFmtBuf(CfgFee.ArrCfgFee[idxTxCfg].idxdbactno_list,",",config_cnt,sIdxDbActNo); if(ret) { writelog(LOG_ERR, "TxCode[%d]FeeType[%d]idxdbactno_list[%s]",IA->iTradeNo,IA->iFeeType,CfgFee.ArrCfgFee[idxTxCfg].idxdbactno_list); return E_ACTNO_IDX_NOT_CFG; //交易未配置 } idx=atoi(sIdxDbActNo); if(idx<0) return E_ACTNO_IDX_CFG; strcpy(tTradelogDb.act_id, IA->sArrInActno[idx]); //借方账号 */ if(TXCODE_CARD_DBCR!=IA->iTradeNo) { if(strcmp(CfgSplit.ArrCfgsplit[iTxType].dbsubno,CfgSplit.ArrCfgsplit[iTxType].crsubno)!=0) { if(strncmp(CfgSplit.ArrCfgsplit[iTxType].dbsubno,SUBJECT_INDIVIDUALSAVING,3)==0) strcpy(tTradelogDb.act_id, IA->sArrInActno[0]); //借方账号(person) else if(strncmp(CfgSplit.ArrCfgsplit[iTxType].dbsubno,SUBJECT_SHOPSAVING,3)==0) strcpy(tTradelogDb.act_id, IA->sArrInActno[1]); //借方账号(shop) else strcpy(tTradelogDb.act_id, IA->sArrInActno[2]); //借方账号 } else { strcpy(tTradelogDb.act_id, IA->sArrInActno[0]); //借方账号(person) } } else { strcpy(tTradelogDb.act_id, IA->sArrInActno[0]); //借方账号(person) } break; case TYPE_CONFIG: strcpy(tTradelogDb.act_id, CfgSplit.ArrCfgsplit[iTxType].dbactno); break; default: writelog(LOG_ERR, " TxType=[%d]",iTxType,CfgSplit.ArrCfgsplit[iTxType].dbflag); return E_DB_TRADEACT_R; } //修改借方帐户余额 tTradelogDb.op_fee = dExpCalAmt; //借方发生额 memset(&tAccountDb, 0, sizeof(tAccountDb)); ret = DB_t_aif_account_read_lock_by_cur_and_account_id(tTradelogDb.act_id, &tAccountDb); if (ret) { writelog(LOG_ERR, "read account err[%d]act_id[%s] ", ret, tTradelogDb.act_id); if (DB_NOTFOUND == ret) return E_ACTNO_NOT_EXIST; else return E_DB_ACCOUNT_R; } if(tAccountDb.current_state == ACCOUNTSTAT_LOGOUT) { DB_t_aif_account_free_lock_cur(); writelog(LOG_ERR, "read account err[%d]act_id[%s]", E_ACTNO_LOGOUT, tAccountDb.account_id); return E_ACTNO_LOGOUT; } if(CfgSplit.ArrCfgsplit[iTxType].dbsubno[0]!=0) { if(strcmp(tAccountDb.subno,CfgSplit.ArrCfgsplit[iTxType].dbsubno)!=0) { DB_t_aif_account_free_lock_cur(); writelog(LOG_ERR,"tradecode config_cnt[%d]TxType[%d]act_id[%s] tAccount.subno[%s]config dbsubno[%s]",config_cnt,iTxType,tAccountDb.account_id,tAccountDb.subno,CfgSplit.ArrCfgsplit[iTxType].dbsubno); return E_SPLIT_CFG; } } strcpy(tTradelogDb.subno,tAccountDb.subno); //借方科目号 // writelog(LOG_DEBUG,"debit No[%d]account[%s]account.cur_bala[%lf]cur_freebala[%lf]cur_frozebala[%lf]amt[%lf]",i,account.account_id,account.cur_bala,account.cur_freebala,account.cur_frozebala,tTradelogDb.op_fee); idxSubCfg=GetIndexSubjectCfgBySubNo(tAccountDb.subno); if(idxSubCfg<0) { writelog(LOG_ERR, "GetIndexSubjectCfgBySubNo[%d] ",tAccountDb.subno); DB_t_aif_account_free_lock_cur(); return E_DB_SUBJECT_N; } if (SUBTYPE_FUND== CfgSubject.ArrSubject[idxSubCfg].subtype|| SUBTYPE_COST== CfgSubject.ArrSubject[idxSubCfg].subtype ) { tAccountDb.cur_bala = D4U5(tAccountDb.cur_bala+ tTradelogDb.op_fee,6); tAccountDb.cur_freebala = D4U5(tAccountDb.cur_freebala+ tTradelogDb.op_fee,6); db_amt_flag=1; } else { db_amt_flag=-1; if(strncmp(tAccountDb.subno,"201",3)==0) { //消费时从冻结金额中扣除搭伙费 switch(CfgSplit.ArrCfgsplit[iTxType].fundtype) { case FUNDTYPE_BOARD://搭伙费 //如果搭伙费不足,则只扣账户上剩余的搭伙费 if(amtcmp(tAccountDb.cur_frozebala,0)<=0) { //如果搭伙费为负值或0,则不扣 DB_t_aif_account_free_lock_cur(); continue; } if(amtcmp(tAccountDb.cur_frozebala,tTradelogDb.op_fee)<0) { dExpCalAmt=tAccountDb.cur_frozebala; tTradelogDb.op_fee = dExpCalAmt; //借方发生额 } tAccountDb.cur_bala =D4U5(tAccountDb.cur_bala- tTradelogDb.op_fee,6); //总余额 tAccountDb.cur_frozebala = D4U5(tAccountDb.cur_frozebala - tTradelogDb.op_fee,6); break; default: tAccountDb.cur_bala =D4U5(tAccountDb.cur_bala- tTradelogDb.op_fee,6); //总余额 tAccountDb.cur_freebala =D4U5(tAccountDb.cur_freebala-tTradelogDb.op_fee,6); //可用余额 //更新卡余额 if(USE_CARD_TYPE_ONLINE==IA->iUseCardFlag) { //联机交易保留交易金额的交易时间 getsysdatetime(tAccountDb.reserve_1); if(amtcmp(dOutCardBala,0)>=0) { tAccountDb.card_balance=dOutCardBala; //卡余额 if(IA->iTxCnt>0) tAccountDb.consume_count=IA->iTxCnt; //消费次数增加 } else if(amtcmp(dInCardBala,0)>=0) { //有入卡值,没有出卡值,计算出卡值,卡余额 dCardBala = dCardBala - D4U5(tTradelogDb.op_fee,2); //卡余额 IA->dOutCardBala=D4U5(dCardBala,2); tAccountDb.card_balance=IA->dOutCardBala; //账户卡余额 if(IA->iTxCnt>0) tAccountDb.consume_count=IA->iTxCnt; } } else if(USE_CARD_TYPE_OFFLINE==IA->iUseCardFlag) { if((tAccountDb.consume_count<=IA->iTxCnt) ||((strncmp(cur_date,IA->sTxDate,8) == 0)&& (strncmp(tradetime,tAccountDb.reserve_1,14)>0))) { strcpy(tAccountDb.reserve_1,tradetime); if(amtcmp(dOutCardBala,0)>=0) { tAccountDb.card_balance=dOutCardBala; if(IA->iTxCnt>0) tAccountDb.consume_count=IA->iTxCnt; //消费次数增加 } else if(amtcmp(dInCardBala,0)>=0) { //有入卡值,没有出卡值,计算出卡值,卡余额 dCardBala = dCardBala - D4U5(tTradelogDb.op_fee,2); //卡余额 IA->dOutCardBala=D4U5(dCardBala,2); tAccountDb.card_balance=IA->dOutCardBala; //账户卡余额 if(IA->iTxCnt>0) tAccountDb.consume_count=IA->iTxCnt; } } //当前交易不是最近一次交易,有入卡值,只计算出卡值 else if((amtcmp(dInCardBala,0)>=0)&&(amtcmp(dOutCardBala,0)<0)) { //计算出卡值 dCardBala = dCardBala - D4U5(tTradelogDb.op_fee,2); //卡余额 IA->dOutCardBala=D4U5(dCardBala,2); } } break; } } else { /* //对押金单独处理 switch(iTxType) { case TXTYPE_RETURN_DEPOSIT: //退押金 case TXTYPE_DEDUCT_DEPOSIT: //扣押金 memset(&tCard,0,sizeof(tCard)); if(IA->iCardNo<1) { return E_INPUT_CARDNO_CANNOT_NULL; } ret=DB_t_pif_card_read_lock_by_cur_and_card_id(IA->iCardNo,&tCard); if(ret) { if(DB_NOTFOUND==ret) return E_CARDNO_NOT_EXIST; else return E_DB_CARD_R; } tCard.deposit_fee=0; ret=DB_t_pif_card_update_lock_by_cur(&tCard); if(ret) { if(DB_NOTFOUND==ret) return E_CARDNO_NOT_EXIST; else return E_DB_CARD_U; } DB_t_pif_card_free_lock_by_cur(); break; } */ tAccountDb.cur_bala =D4U5(tAccountDb.cur_bala - tTradelogDb.op_fee,6); tAccountDb.cur_freebala =D4U5(tAccountDb.cur_freebala- tTradelogDb.op_fee,6); } } //判断余额是否小于0,不允许透支,资产类帐户除外 //应该是负债类账户 if(strncmp(tAccountDb.subno,"2",1)==0) { if(amtcmp(tAccountDb.cur_bala,0)<0||amtcmp(tAccountDb.cur_freebala,0)<0) { writelog(LOG_ERR,"host serialno[%d]debit No[%d]account[%s]account.cur_bala[%lf]cur_freebala[%lf]cur_frozebala[%lf]amt[%lf]",IA->iSerialNo,i,tAccountDb.account_id,tAccountDb.cur_bala,tAccountDb.cur_freebala,tAccountDb.cur_frozebala,tTradelogDb.op_fee); DB_t_aif_account_free_lock_cur(); return E_BALANCE_SHORTAGE; } } tTradelogDb.new_fee = tAccountDb.cur_bala; //借方帐户总余额 tTradelogDb.cur_frozebala=tAccountDb.cur_frozebala; //冻结金额 ret = DB_t_aif_account_update_lock_by_cur(&tAccountDb); if (ret) { writelog(LOG_ERR, "update account err[%d] account[%s]", ret,tAccountDb.account_id); if (DB_NOTFOUND == ret) return E_ACTNO_NOT_EXIST; else return E_DB_ACCOUNT_U; } DB_t_aif_account_free_lock_cur(); //###################################################### //处理贷方账号1 switch (CfgSplit.ArrCfgsplit[iTxType].crflag) { case TYPE_INPUT: /* ret=GetValueFromFmtBuf(CfgFee.ArrCfgFee[idxTxCfg].idxcractno_list,",",config_cnt,sIdxCrActNo); if(ret) { writelog(LOG_ERR, "TxCode[%d]FeeType[%d]idxcractno_list[%s]",IA->iTradeNo,IA->iFeeType,CfgFee.ArrCfgFee[idxTxCfg].idxcractno_list); return E_ACTNO_IDX_NOT_CFG; //交易未配置 } idx=atoi(sIdxCrActNo); if(idx<0) return E_ACTNO_IDX_CFG; strcpy(tTradelogCr.act_id, IA->sArrInActno[idx]); //贷方账号 */ if(TXCODE_CARD_DBCR!=IA->iTradeNo) { if(strcmp(CfgSplit.ArrCfgsplit[iTxType].dbsubno,CfgSplit.ArrCfgsplit[iTxType].crsubno)!=0) { if(strncmp(CfgSplit.ArrCfgsplit[iTxType].crsubno,SUBJECT_INDIVIDUALSAVING,3)==0) strcpy(tTradelogCr.act_id, IA->sArrInActno[0]); //贷方账号(person) else if(strncmp(CfgSplit.ArrCfgsplit[iTxType].crsubno,SUBJECT_SHOPSAVING,3)==0) strcpy(tTradelogCr.act_id, IA->sArrInActno[1]); //贷方账号(shop) else strcpy(tTradelogDb.act_id, IA->sArrInActno[3]); //贷方账号 } else { strcpy(tTradelogCr.act_id, IA->sArrInActno[1]); //贷方账号(person) } } else { strcpy(tTradelogCr.act_id, IA->sArrInActno[1]); //贷方账号(person) } break; case TYPE_CONFIG: strcpy(tTradelogCr.act_id, CfgSplit.ArrCfgsplit[iTxType].cractno); break; default: writelog(LOG_ERR, " TxType=[%d]",iTxType,CfgSplit.ArrCfgsplit[iTxType].crflag); return E_DB_TRADEACT_R; } //修改贷方帐户余额 tTradelogCr.op_fee =dExpCalAmt; //贷方发生额 memset(&tAccountCr, 0, sizeof(tAccountCr)); ret = DB_t_aif_account_read_lock_by_cur_and_account_id(tTradelogCr.act_id, &tAccountCr); if (ret) { writelog(LOG_ERR, "read account err[%d]act_id[%s]", ret, tTradelogCr.act_id); if (DB_NOTFOUND == ret) return E_ACTNO_NOT_EXIST; else return E_DB_ACCOUNT_R; } if(tAccountCr.current_state == ACCOUNTSTAT_LOGOUT) { DB_t_aif_account_free_lock_cur(); writelog(LOG_ERR, "read account err[%d]act_id[%s]", E_ACTNO_LOGOUT, tAccountCr.account_id); return E_ACTNO_LOGOUT; } if(CfgSplit.ArrCfgsplit[iTxType].crsubno[0]!=0) { if(strcmp(tAccountCr.subno,CfgSplit.ArrCfgsplit[iTxType].crsubno)!=0) { writelog(LOG_ERR,"tradecode config_cnt[%d]TxType[%d]act_id[%s] tAccount.subno[%s]config dbsubno[%s]",config_cnt,iTxType,tAccountCr.account_id,tAccountCr.subno,CfgSplit.ArrCfgsplit[iTxType].crsubno); DB_t_aif_account_free_lock_cur(); return E_SPLIT_CFG; } } strcpy(tTradelogCr.subno, tAccountCr.subno); //贷方科目号 // writelog(LOG_DEBUG,"credit No[%d]tAccount[%s]account.cur_bala[%lf]cur_freebala[%lf]cur_frozebala[%lf]amt[%lf]",i,account.account_id,account.cur_bala,account.cur_freebala,account.cur_frozebala,ArrTradelog[i+1].op_fee); idxSubCfg=GetIndexSubjectCfgBySubNo(tAccountCr.subno); if(idxSubCfg<0) { writelog(LOG_ERR, "GetIndexSubjectCfgBySubNo[%d] ", tAccountCr.subno); DB_t_aif_account_free_lock_cur(); return E_DB_SUBJECT_N; } if (SUBTYPE_FUND== CfgSubject.ArrSubject[idxSubCfg].subtype|| SUBTYPE_COST== CfgSubject.ArrSubject[idxSubCfg].subtype ) { tAccountCr.cur_bala =D4U5(tAccountCr.cur_bala- tTradelogCr.op_fee,6); //当前总余额 tAccountCr.cur_freebala =D4U5(tAccountCr.cur_freebala-tTradelogCr.op_fee,6); //当前可用余额 cr_amt_flag=-1; } else { cr_amt_flag=1; //如果帐户类型为个人,则计算搭伙费,主要是充值使用 if(strncmp(tAccountCr.subno,"201",3)==0) { tAccountCr.cur_bala =D4U5(tAccountCr.cur_bala+ tTradelogCr.op_fee,6); //总余额 switch(CfgSplit.ArrCfgsplit[iTxType].fundtype) { case FUNDTYPE_BOARD: //搭伙费 tAccountCr.cur_frozebala =D4U5(tAccountCr.cur_frozebala+ tTradelogCr.op_fee,6); break; default: tAccountCr.cur_freebala =D4U5(tAccountCr.cur_freebala+ tTradelogCr.op_fee,6); //可用余额 //更新卡余额 if(USE_CARD_TYPE_ONLINE==IA->iUseCardFlag) { getsysdatetime(tAccountCr.reserve_1); if(IA->iTxCnt>0) tAccountCr.consume_count=IA->iTxCnt; //消费次数增加 else { DB_t_aif_account_free_lock_cur(); return E_INPUT_CARD_TXCNT; } if(amtcmp(dOutCardBala,0)>=0) { tAccountCr.card_balance=dOutCardBala; //卡余额 } else if(amtcmp(dInCardBala,0)>=0) { //有入卡值,没有出卡值,计算出卡值,卡余额 dCardBala = dCardBala + D4U5(tTradelogDb.op_fee,2); //卡余额 IA->dOutCardBala=D4U5(dCardBala,2); tAccountCr.card_balance=IA->dOutCardBala; //账户卡余额 } } else if(USE_CARD_TYPE_OFFLINE==IA->iUseCardFlag) { if((tAccountCr.consume_count<=IA->iTxCnt) ||((strncmp(cur_date,IA->sTxDate,8) == 0)&&(strncmp(tradetime,tAccountDb.reserve_1,14)>0))) { strcpy(tAccountCr.reserve_1,tradetime); if(IA->iTxCnt>0) tAccountCr.consume_count=IA->iTxCnt; //消费次数增加 if(amtcmp(dOutCardBala,0)>=0) { tAccountCr.card_balance=dOutCardBala; } else if(amtcmp(dInCardBala,0)>=0) { //有入卡值,没有出卡值,计算出卡值,卡余额 dCardBala = dCardBala + D4U5(tTradelogDb.op_fee,2); //卡余额 IA->dOutCardBala=D4U5(dCardBala,2); tAccountCr.card_balance=IA->dOutCardBala; //账户卡余额 } } //当前交易不是最近一次交易,有入卡值,只计算出卡值 else if((amtcmp(dInCardBala,0)>=0)&&(amtcmp(dOutCardBala,0)<0)) { //计算出卡值 dCardBala = dCardBala + D4U5(tTradelogDb.op_fee,2); //卡余额 IA->dOutCardBala=D4U5(dCardBala,2); } } break; } } else { //对押金单独处理 switch(iTxType) { case TXTYPE_TOLL_DEPOSIT: //收押金 case TXTYPE_TOLL_DEPOSIT_BILL: case TXTYPE_TOLL_DEPOSIT_FUNDBOOK: memset(&tCard,0,sizeof(tCard)); if(IA->iCardNo<1) { DB_t_aif_account_free_lock_cur(); return E_INPUT_CARDNO_CANNOT_NULL; } ret=DB_t_pif_card_read_lock_by_cur_and_card_id(IA->iCardNo,&tCard); if(ret) { DB_t_aif_account_free_lock_cur(); if(DB_NOTFOUND==ret) return E_CARDNO_NOT_EXIST; else return E_DB_CARD_R; } tCard.deposit_fee=tTradelogCr.op_fee; ret=DB_t_pif_card_update_lock_by_cur(&tCard); if(ret) { DB_t_aif_account_free_lock_cur(); if(DB_NOTFOUND==ret) return E_CARDNO_NOT_EXIST; else return E_DB_CARD_U; } DB_t_pif_card_free_lock_by_cur(); default: break; } tAccountCr.cur_bala =D4U5(tAccountCr.cur_bala+tTradelogCr.op_fee,6); //当前总余额 tAccountCr.cur_freebala=D4U5(tAccountCr.cur_freebala+tTradelogCr.op_fee,6) ; //当前可用余额 } } //判断余额是否小于0,不允许透支,资产类帐户除外 if(strncmp(tAccountCr.subno,"2",1)==0) { if(amtcmp(tAccountCr.cur_bala,0)<0||amtcmp(tAccountCr.cur_freebala,0)<0) { writelog(LOG_ERR,"host serialno[%d]credit No[%d+1]account[%s]account.cur_bala[%lf]cur_freebala[%lf]cur_frozebala[%lf]amt[%lf]",IA->iSerialNo,i,tAccountCr.account_id,tAccountCr.cur_bala,tAccountCr.cur_freebala,tAccountCr.cur_frozebala,tTradelogDb.op_fee); DB_t_aif_account_free_lock_cur(); return E_BALANCE_SHORTAGE; } } tTradelogCr.new_fee = tAccountCr.cur_bala; //贷方帐户余额 tTradelogCr.cur_frozebala=tAccountCr.cur_frozebala; //冻结金额 ret = DB_t_aif_account_update_lock_by_cur(&tAccountCr); if (ret) { writelog(LOG_ERR, "update account err[%d] account[%s]", ret,tAccountCr.account_id); if (DB_NOTFOUND == ret) return E_ACTNO_NOT_EXIST; else return E_DB_ACCOUNT_U; } DB_t_aif_account_free_lock_cur(); //增加借方分录流水 tTradelogDb.maindevice_id = IA->iMainDevId; //工作站标识 tTradelogDb.device_id= IA->iDevId; //终端设备ID tTradelogDb.serino = IA->iSerialNo; //流水号 tTradelogDb.seri_type= IA->iTradeNo; //交易码 tTradelogDb.fee_type=iTxType; //分录序号 tTradelogDb.warrant_type = iVocType; //凭证类型 strcpy(tTradelogDb.warrant_no, sVocNo); //凭证号 strcpy(tTradelogDb.comments, CfgSplit.ArrCfgsplit[iTxType].txname); //摘要 strcpy(tTradelogDb.operate_date, IA->sTxDate); //交易日期 strcpy(tTradelogDb.operate_time, IA->sTxTime); //交易时间 strcpy(tTradelogDb.collect_date,IA->sTxCollectDate); //采集日期 strcpy(tTradelogDb.collect_time,IA->sTxCollectTime); //采集时间 strcpy(tTradelogDb.enteract_date,IA->sTxAccDate); //记账日期 strcpy(tTradelogDb.enteract_time,IA->sTxAccTime); //记账时间 strcpy(tTradelogDb.record_oper, IA->sMdeOper); //录入操作员 strcpy(tTradelogDb.write_oper, IA->sChkOper); //复核记账员 tTradelogDb.outorin = DBCR_DEBIT; //借方标志 strcpy(tTradelogDb.other_actid, tTradelogCr.act_id); //对方账号 strcpy(tTradelogDb.other_subno, tTradelogCr.subno); //对方科目 ++IA->iSubIndex; tTradelogDb.annex = IA->iSubIndex; ret = DB_t_tif_tradelog_add(&tTradelogDb); if (ret) { writelog(LOG_ERR, "add ArrTradelog err[%d] ", ret); return E_DB_TRADELOG_I; } //增加贷方分录流水 tTradelogCr.maindevice_id = IA->iMainDevId; //工作站标识 tTradelogCr.device_id= IA->iDevId; //终端设备ID tTradelogCr.serino = IA->iSerialNo; //流水号 tTradelogCr.seri_type = IA->iTradeNo; //交易码 tTradelogCr.fee_type=iTxType; //分录序号 tTradelogCr.warrant_type = iVocType; //凭证类型 strcpy(tTradelogCr.warrant_no, sVocNo); //凭证号 strcpy(tTradelogCr.comments, CfgSplit.ArrCfgsplit[iTxType].txname);//摘要 strcpy(tTradelogCr.operate_date, IA->sTxDate); //交易日期 strcpy(tTradelogCr.operate_time, IA->sTxTime); //交易时间 strcpy(tTradelogCr.collect_date,IA->sTxCollectDate); //采集日期 strcpy(tTradelogCr.collect_time,IA->sTxCollectTime); //采集时间 strcpy(tTradelogCr.enteract_date,tTradelogDb.enteract_date);//记账日期 strcpy(tTradelogCr.enteract_time,tTradelogDb.enteract_time);//记账时间 strcpy(tTradelogCr.record_oper, IA->sMdeOper); //录入操作员 strcpy(tTradelogCr.write_oper, IA->sChkOper); //复核操作员 tTradelogCr.outorin = DBCR_CREDIT; //贷方标志 strcpy(tTradelogCr.other_actid, tTradelogDb.act_id); //对方账号 strcpy(tTradelogCr.other_subno, tTradelogDb.subno); //对方科目 tTradelogCr.annex = IA->iSubIndex; ret = DB_t_tif_tradelog_add(&tTradelogCr); if (ret) { writelog(LOG_ERR, "add ArrTradelog err[%d] ", ret); return E_DB_TRADELOG_I; } IA->dArrOutAmt[config_cnt]=dExpCalAmt; IA->iArrOutTxType[config_cnt]=iTxType; strcpy(IA->sArrOutTxName[config_cnt],CfgSplit.ArrCfgsplit[iTxType].txname); IA->iOutTxTypeCnt=config_cnt; //############################################################## if(IA->pVoidPointer!=NULL) { if(db_amt_flag>0) sprintf(pMessage+strlen(pMessage),"%s:余额增加%.2lf元", tAccountDb.cut_name,dExpCalAmt); else sprintf(pMessage+strlen(pMessage),"%s:余额减少%.2lf元", tAccountDb.cut_name,dExpCalAmt); if(cr_amt_flag>0) sprintf(pMessage+strlen(pMessage)," %s:余额增加%.2lf元",tAccountCr.cut_name,dExpCalAmt); else sprintf(pMessage+strlen(pMessage)," %s:余额减少%.2lf元", tAccountCr.cut_name,dExpCalAmt); } } //如果有入卡值但没有出卡值,则出卡值就是入卡值 if(amtcmp(IA->dOutCardBala,0)<0) { if(amtcmp(IA->dInCardBala,0)>=0) IA->dOutCardBala=IA->dInCardBala; } // writelog(LOG_DEBUG,"serino[%d]IA->dInCardBala[%lf]IA->dOutCardBala[%lf]IA->iTxCnt[%d]",IA->iSerialNo,IA->dInCardBala,IA->dOutCardBala,IA->iTxCnt); return 0; }
int do_reverse_balance(T_t_tif_tradelog *tTradelog,RevAcc *revacc) { int ret = -1; int idxSub=0; char sTxDateandtime[21]=""; T_t_aif_account tAccountDb; T_t_aif_account tAccountCr; T_t_tif_tradelog tTradelogDb; T_t_tif_tradelog tTradelogCr; T_t_tif_subject tSubject; T_t_tif_cfgsplit tCfgsplit; memset(&tAccountDb,0,sizeof tAccountDb); memset(&tAccountCr,0,sizeof tAccountCr); memset(&tSubject,0,sizeof tSubject); memset(&tCfgsplit,0,sizeof tCfgsplit); memset(&tTradelogDb,0,sizeof tTradelogDb); memset(&tTradelogCr,0,sizeof tTradelogCr); // 处理借方 memcpy(&tTradelogDb,tTradelog,sizeof tTradelogDb); tTradelogDb.seri_type = TXCODE_TX_REVEAL; // 交易代码记录为冲正 ret = DB_t_aif_account_read_lock_by_cur_and_account_id(tTradelog->act_id, &tAccountDb); if(ret) { if(DB_NOTFOUND==ret) return E_ACTNO_NOT_EXIST; else return E_DB_ACCOUNT_R; } if(tAccountDb.current_state == ACCOUNTSTAT_LOGOUT) { DB_t_aif_account_free_lock_cur(); writelog(LOG_ERR, "read account err[%d]act_id[%s]", E_ACTNO_LOGOUT, tAccountDb.account_id); return E_ACTNO_LOGOUT; } ret = DB_t_tif_subject_read_by_subno(tAccountDb.subno, &tSubject); if(ret) { DB_t_aif_account_free_lock_cur(); return ret; } if (SUBTYPE_FUND== tSubject.subtype|| SUBTYPE_COST== tSubject.subtype ) { tAccountDb.cur_bala = D4U5(tAccountDb.cur_bala- tTradelog->op_fee,6); tAccountDb.cur_freebala = D4U5(tAccountDb.cur_freebala- tTradelog->op_fee,6); //db_amt_flag=1; } else { //db_amt_flag=-1; if(strncmp(tAccountDb.subno,"201",3)==0) { //消费时从冻结金额中扣除搭伙费 ret = DB_t_tif_cfgsplit_read_by_txtype(tTradelog->fee_type, &tCfgsplit); if(ret) { DB_t_aif_account_free_lock_cur(); return ret; } switch(tCfgsplit.fundtype) { case FUNDTYPE_BOARD://搭伙费 tAccountDb.cur_bala =D4U5(tAccountDb.cur_bala+ tTradelog->op_fee,6); //总余额 tAccountDb.cur_frozebala = D4U5(tAccountDb.cur_frozebala + tTradelog->op_fee,6); break; default: tAccountDb.cur_bala =D4U5(tAccountDb.cur_bala+ tTradelog->op_fee,6); //总余额 tAccountDb.cur_freebala =D4U5(tAccountDb.cur_freebala+tTradelog->op_fee,6); //可用余额 //更新卡余额 if(USE_CARD_TYPE_ONLINE==revacc->iUseCardFlag) { //联机交易保留交易金额的交易时间 getsysdatetime(tAccountDb.reserve_1); if(amtcmp(revacc->dOutCardBala,0)>=0) { //把搭伙费,交易金额都加上 revacc->dOutCardBala=D4U5(revacc->dOutCardBala + tTradelog->op_fee,2); tAccountDb.card_balance=revacc->dOutCardBala; //账户卡余额 if(revacc->iTradeCnt>0) tAccountDb.consume_count=revacc->iTradeCnt; } } else if(USE_CARD_TYPE_NULL==revacc->iUseCardFlag) { strcpy(sTxDateandtime,revacc->sTxDate); strcat(sTxDateandtime,revacc->sTxTime); revacc->dOutCardBala=D4U5(revacc->dOutCardBala + tTradelog->op_fee,2); // if((tAccountDb.consume_count<=revacc->iTradeCnt)||(strncmp(sTxDateandtime,tAccountDb.reserve_1,14)>0)) if (tAccountDb.consume_count<=revacc->iTradeCnt) { // strcpy(tAccountDb.reserve_1,revacc->sTxDate); tAccountDb.card_balance=D4U5(revacc->dOutCardBala ,2); //账户卡余额 } } break; } } else { tAccountDb.cur_bala =D4U5(tAccountDb.cur_bala + tTradelog->op_fee,6); tAccountDb.cur_freebala =D4U5(tAccountDb.cur_freebala+ tTradelog->op_fee,6); } } tTradelogDb.new_fee = tAccountDb.cur_bala; //借方帐户总余额 tTradelogDb.cur_frozebala=tAccountDb.cur_frozebala; //冻结金额 ret = DB_t_aif_account_update_lock_by_cur(&tAccountDb); if (ret) { writelog(LOG_ERR, "update account err[%d] account[%s]", ret,tAccountDb.account_id); if (DB_NOTFOUND == ret) return E_ACTNO_NOT_EXIST; else return E_DB_ACCOUNT_U; } DB_t_aif_account_free_lock_cur(); // 处理贷方 ret = DB_t_aif_account_read_lock_by_cur_and_account_id(tTradelog->other_actid, &tAccountCr); if (ret) { writelog(LOG_ERR, "read account err[%d]act_id[%s]", ret, tTradelog->other_actid); if (DB_NOTFOUND == ret) return E_ACTNO_NOT_EXIST; else return E_DB_ACCOUNT_R; } if(tAccountCr.current_state == ACCOUNTSTAT_LOGOUT) { DB_t_aif_account_free_lock_cur(); writelog(LOG_ERR, "read account err[%d]act_id[%s]", E_ACTNO_LOGOUT, tAccountCr.account_id); return E_ACTNO_LOGOUT; } memset(&tSubject,0,sizeof tSubject); ret = DB_t_tif_subject_read_by_subno(tAccountCr.subno, &tSubject); if(ret) { DB_t_aif_account_free_lock_cur(); return ret; } if (SUBTYPE_FUND== tSubject.subtype|| SUBTYPE_COST== tSubject.subtype) { tAccountCr.cur_bala =D4U5(tAccountCr.cur_bala+ tTradelog->op_fee,6); //当前总余额 tAccountCr.cur_freebala =D4U5(tAccountCr.cur_freebala+tTradelog->op_fee,6); //当前可用余额 //cr_amt_flag=-1; } else { //cr_amt_flag=1; //如果帐户类型为个人,则计算搭伙费,主要是充值使用 if(strncmp(tAccountCr.subno,"201",3)==0) { tAccountCr.cur_bala =D4U5(tAccountCr.cur_bala- tTradelog->op_fee,6); //总余额 if(tCfgsplit.txtype ==0) //第一次读取 { ret = DB_t_tif_cfgsplit_read_by_txtype(tTradelog->fee_type, &tCfgsplit); if(ret) { DB_t_aif_account_free_lock_cur(); return ret; } } switch(tCfgsplit.fundtype) { case FUNDTYPE_BOARD: //搭伙费 tAccountCr.cur_frozebala =D4U5(tAccountCr.cur_frozebala- tTradelog->op_fee,6); break; default: tAccountCr.cur_freebala =D4U5(tAccountCr.cur_freebala- tTradelog->op_fee,6); //可用余额 //更新卡余额 if(USE_CARD_TYPE_ONLINE==revacc->iUseCardFlag) { getsysdatetime(tAccountCr.reserve_1); if(revacc->iTradeCnt>0) tAccountCr.consume_count=revacc->iTradeCnt; //消费次数增加 if(amtcmp(revacc->dOutCardBala,0)>=0) { revacc->dOutCardBala=D4U5(revacc->dOutCardBala -tTradelog->op_fee,2); tAccountCr.card_balance=revacc->dOutCardBala; //账户卡余额 } } else if(USE_CARD_TYPE_NULL==revacc->iUseCardFlag) { strcpy(sTxDateandtime,revacc->sTxDate); strcat(sTxDateandtime,revacc->sTxTime); revacc->dOutCardBala=D4U5(revacc->dOutCardBala - tTradelog->op_fee,2); if((tAccountCr.consume_count<=revacc->iTradeCnt)||(strncmp(sTxDateandtime,tAccountCr.reserve_1,14)>0)) { strcpy(tAccountCr.reserve_1,revacc->sTxDate); tAccountCr.card_balance=D4U5(revacc->dOutCardBala ,2); //账户卡余额 } } break; } } else { tAccountCr.cur_bala =D4U5(tAccountCr.cur_bala-tTradelog->op_fee,6); //当前总余额 tAccountCr.cur_freebala=D4U5(tAccountCr.cur_freebala-tTradelog->op_fee,6) ; //当前可用余额 } } ret = DB_t_aif_account_update_lock_by_cur(&tAccountCr); if (ret) { writelog(LOG_ERR, "update account err[%d] account[%s]", ret,tAccountCr.account_id); if (DB_NOTFOUND == ret) return E_ACTNO_NOT_EXIST; else return E_DB_ACCOUNT_U; } DB_t_aif_account_free_lock_cur(); des2src(tTradelogDb.operate_date,revacc->sTxDate); des2src(tTradelogDb.operate_time,revacc->sTxTime); des2src(tTradelogDb.collect_date,revacc->sTxDate); des2src(tTradelogDb.collect_time,revacc->sTxTime); des2src(tTradelogDb.enteract_date,revacc->sTxDate); des2src(tTradelogDb.enteract_time,revacc->sTxTime); des2src(tTradelogDb.check_oper,revacc->sChkOper); des2src(tTradelogDb.record_oper,revacc->sMdeOper); tTradelogDb.serino = revacc->iRevSeriNo; tTradelogDb.op_fee = -tTradelogDb.op_fee; tTradelogDb.maindevice_id = revacc->maindevice_id; tTradelogDb.device_id = 0; ret = DB_t_tif_tradelog_add(&tTradelogDb); if (ret) { writelog(LOG_ERR, "add ArrTradelog err[%d] seri_no[%d],seri_type[%d],fee_type[%d],act_id[%s]", ret,tTradelogDb.serino,tTradelogDb.seri_type, tTradelogDb.fee_type,tTradelogDb.act_id); return E_DB_TRADELOG_I; } memcpy(&tTradelogCr,&tTradelogDb,sizeof tTradelogCr); tTradelogCr.new_fee = tAccountCr.cur_bala; //贷方帐户余额 tTradelogCr.cur_frozebala=tAccountCr.cur_frozebala; //冻结金额 des2src(tTradelogCr.act_id,tTradelogDb.other_actid); des2src(tTradelogCr.subno,tTradelogDb.other_subno); des2src(tTradelogCr.other_actid,tTradelogDb.act_id); des2src(tTradelogCr.other_subno,tTradelogDb.subno); tTradelogCr.outorin = DBCR_CREDIT; ret = DB_t_tif_tradelog_add(&tTradelogCr); if (ret) { writelog(LOG_ERR, "add ArrTradelog err[%d] seri_no[%d],seri_type[%d],fee_type[%d],act_id[%s]", ret,tTradelogCr.serino,tTradelogCr.seri_type, tTradelogCr.fee_type,tTradelogCr.act_id); return E_DB_TRADELOG_I; } return 0; }