//系统正式入账 int enter_account(ST_PACK *in_pack,InAcc *IA,ST_PACK *out_pack){ int ret = 0; int i=0; int card_id = 0; char logicdate[11]=""; char sysdate[11]=""; char systime[9]=""; char sMsg[256]=""; T_t_tif_tradeserial tradeserial; T_t_cif_customer tCustomer; T_t_pif_spefee tSpeFee; T_t_aif_account tAccount; T_t_pif_card tCard; memset(&tCustomer,0,sizeof(tCustomer)); memset(&tSpeFee,0,sizeof(tSpeFee)); memset(&tAccount,0,sizeof(tAccount)); memset(&tCard,0,sizeof(tCard)); card_id=in_pack->lvol0; ret=get_datetime_from_db(sysdate,systime); if(ret) { writelog(LOG_ERR,"get_datetime_from_db error,error code=[%d]",ret); getsysdate(sysdate); getsystime(systime); return ret; } ret=GetLogicDate(logicdate); //业务日期 if(ret) { writelog(LOG_ERR,"GetLogicDate error,errcode=[%d]",ret); return ret; } ret=DB_t_pif_card_read_by_card_id(card_id, &tCard); if(ret) { if(DB_NOTFOUND==ret) ret=E_CARDNO_NOT_EXIST; else ret=E_DB_CARD_R; return ret; } if(strncmp(tCard.state_id,CARDSTAT_REG,4)!=0) { if('2'==tCard.state_id[CARDSTAT_TYPE_REG]) ret= E_CARDNO_LOGOUT; else if('3'==tCard.state_id[CARDSTAT_TYPE_REG]) ret = E_CARD_CHANGE; else if(tCard.state_id[CARDSTAT_TYPE_LOST]==STATE_TRUE) ret=E_CARDNO_LOST; else if(tCard.state_id[CARDSTAT_TYPE_FREEZE]==STATE_TRUE) ret=E_CARDNO_FREEZE; else if(tCard.state_id[CARDSTAT_TYPE_WFAIL]==STATE_TRUE) ret=E_CARDNO_WFAIL; return ret; } //根据卡号和钱包号得到消费者账号(借方) 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) ret=E_ACTNO_NOT_EXIST; else ret=E_DB_ACCOUNT_R; return ret; } ret=DB_t_cif_customer_read_lock_by_cur_and_cut_id(tCard.cosumer_id, &tCustomer); if(ret) { writelog(LOG_ERR,"cut_id[%d]",tCard.cosumer_id); if(DB_NOTFOUND==ret) ret= E_CUSTOMER_NOT_EXIST; else ret= E_DB_CUSTOMER_R; return ret; } //得到收费类别 if(0==tCustomer.fee_type) { 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(); return E_DB_SPEFEE_R; } } else { tCustomer.fee_type=tSpeFee.fee_type; } //更新客户表的收费类别字段 ret=DB_t_cif_customer_update_lock_by_cur(&tCustomer); if(ret) { if(DB_NOTFOUND==ret) ret= E_CUSTOMER_NOT_EXIST; else ret= E_DB_CUSTOMER_U; return ret; } } DB_t_cif_customer_free_lock_cur(); ret = DB_t_tif_tradeserial_read_lock_by_cur_and_serial_no(in_pack->lvol6,&tradeserial); if(ret) { if(DB_NOTFOUND == ret){ ret = E_DB_TRADESERIAL_N; }else{ ret = E_DB_TRADESERIAL_R; } } IA->iCardNo=tCard.card_id; IA->iFeeType=tCustomer.fee_type; IA->dArrInAmt[0]=tradeserial.trade_fee; IA->iMainDevId=tradeserial.maindevice_id; //工作站标识 IA->iDevId=tradeserial.device_id; //设备ID IA->iSerialNo=tradeserial.serial_no; //流水号 IA->iTradeNo=tradeserial.serial_type; //交易码 strcpy(IA->sTxDate,tradeserial.operate_date); //交易日期 strcpy(IA->sTxTime,tradeserial.operate_time); //交易时间 strcpy(IA->sTxCollectDate,tradeserial.collect_date); //采集日期 strcpy(IA->sTxCollectTime,tradeserial.collect_time); //采集时间 strcpy(IA->sTxAccDate,tradeserial.enteract_date); //记账日期 strcpy(IA->sTxAccTime,tradeserial.enteract_time); //记账时间 strcpy(IA->sMdeOper,tradeserial.oper_code); //操作员 strcpy(IA->sChkOper,tradeserial.reserve_1); //复核操作员 IA->iUseCardFlag=USE_CARD_TYPE_ONLINE; //联机交易 IA->iTxCnt=tradeserial.trade_count; //交易次数 IA->dInCardBala=tradeserial.in_balance; //入卡值 IA->dOutCardBala=-1; //出卡值 //修改借方和贷方帐户余额,记会计分录帐 ret=AccountProcess(IA); if(ret) { writelog(LOG_ERR,"AccountProcess ret[%d]",ret); return ret; } tradeserial.out_balance=IA->dOutCardBala; //出卡值 if(amtcmp(tradeserial.out_balance,0)<0) { return E_ENTER_ACCOUNT; } 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_BANK_PRE_TOLL_BOARD: case TXTYPE_PRE_TOLL_BOARD_FUNDBOOK: case TXTYPE_SUBSIDY_PRE_TOLL_BOARD_CASH: case TXTYPE_SUBSIDY_PRE_TOLL_BOARD_BILL: case TXTYPE_SUBSIDY_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]); } } tradeserial.serial_state=SERISTAT_DEBT; ret = DB_t_tif_tradeserial_update_lock_by_cur(&tradeserial); if(ret) { writelog(LOG_ERR,"db update t_tif_tradeserial error,errcode=[%d]",ret); return E_DB_TRADESERIAL_U; } DB_t_tif_tradeserial_free_lock_cur(); out_pack->damt0=tradeserial.out_balance; //出卡值 out_pack->damt1=tradeserial.trade_fee; //交易金额 out_pack->lvol0 = tradeserial.serial_no; //流水号 sprintf(sMsg,"交易前卡余额:%.2lf元 卡当前余额:%.2lf元",tradeserial.in_balance,tradeserial.out_balance); strcat(out_pack->vsmess,sMsg); writelog(LOG_DEBUG,out_pack->vsmess); 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 tend_to_enter_account(ST_PACK *in_pack,InAcc *IA,int trade_code,T_t_tif_tradeserial *tradeserial){ int ret = 0; int i=0; int card_id = 0; char Operator[33+1] = ""; int maindevice_id = 0; int device_id = 0; char logicdate[11]=""; char sysdate[11]=""; char systime[9]=""; double dUniqno = 0; char sMsg[256]=""; T_t_cif_customer tCustomer; T_t_pif_spefee tSpeFee; T_t_aif_account tAccount; T_t_pif_card tCard; memset(&tCustomer,0,sizeof(tCustomer)); memset(&tSpeFee,0,sizeof(tSpeFee)); memset(&tAccount,0,sizeof(tAccount)); memset(&tCard,0,sizeof(tCard)); card_id=in_pack->lvol0; ret=get_datetime_from_db(sysdate,systime); if(ret) { writelog(LOG_ERR,"get_datetime_from_db error,error code=[%d]",ret); getsysdate(sysdate); getsystime(systime); return ret; } ret=GetLogicDate(logicdate); //业务日期 if(ret) { writelog(LOG_ERR,"GetLogicDate error,errcode=[%d]",ret); return ret; } ret=DB_t_pif_card_read_by_card_id(card_id, &tCard); if(ret) { if(DB_NOTFOUND==ret) ret=E_CARDNO_NOT_EXIST; else ret=E_DB_CARD_R; return ret; } if(strncmp(tCard.state_id,CARDSTAT_REG,4)!=0) { if('2'==tCard.state_id[CARDSTAT_TYPE_REG]) ret= E_CARDNO_LOGOUT; else if('3'==tCard.state_id[CARDSTAT_TYPE_REG]) ret = E_CARD_CHANGE; else if(tCard.state_id[CARDSTAT_TYPE_LOST]==STATE_TRUE) ret=E_CARDNO_LOST; else if(tCard.state_id[CARDSTAT_TYPE_FREEZE]==STATE_TRUE) ret=E_CARDNO_FREEZE; else if(tCard.state_id[CARDSTAT_TYPE_WFAIL]==STATE_TRUE) ret=E_CARDNO_WFAIL; return ret; } //根据卡号和钱包号得到消费者账号(借方) 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) ret=E_ACTNO_NOT_EXIST; else ret=E_DB_ACCOUNT_R; return ret; } ret=DB_t_cif_customer_read_lock_by_cur_and_cut_id(tCard.cosumer_id, &tCustomer); if(ret) { writelog(LOG_ERR,"cut_id[%d]",tCard.cosumer_id); if(DB_NOTFOUND==ret) ret= E_CUSTOMER_NOT_EXIST; else ret= E_DB_CUSTOMER_R; return ret; } //得到收费类别 if(0==tCustomer.fee_type) { 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(); return E_DB_SPEFEE_R; } } else { tCustomer.fee_type=tSpeFee.fee_type; } //更新客户表的收费类别字段 ret=DB_t_cif_customer_update_lock_by_cur(&tCustomer); if(ret) { if(DB_NOTFOUND==ret) ret= E_CUSTOMER_NOT_EXIST; else ret= E_DB_CUSTOMER_U; return ret; } } DB_t_cif_customer_free_lock_cur(); des2src(Operator,in_pack->scust_no); //操作员号 //采集设备标识 // 准备数据插入交易流水表 ret = getNewUniqNo(KEYTYPE_TRADESERIAL,&dUniqno); //获得最大流水号 if(ret) { writelog(LOG_ERR,"getNewUniqNo error,errcode=[%d]",ret); return ret; } strncpy(tradeserial->operate_date,sysdate,sizeof(sysdate)-1); //发生日期 strncpy(tradeserial->operate_time,systime,sizeof(systime)-1); des2src(tradeserial->collect_date,tradeserial->operate_date); //采集日期 des2src(tradeserial->collect_time,tradeserial->operate_time); //采集时间 des2src(tradeserial->enteract_date,logicdate); //处理日期 des2src(tradeserial->enteract_time,tradeserial->operate_time); //处理时间 tradeserial->serial_no = D2I(dUniqno); //流水号 tradeserial->serial_type = trade_code; //流水类型 tradeserial->purse_id = PURSE_NO_ONE; //钱包号 tradeserial->serial_state = SERISTAT_NODEBT; //流水状态 tradeserial->maindevice_id = maindevice_id; //上传工作站标识 tradeserial->device_id = device_id; //采集设备标识 tradeserial->card_id = card_id; //交易卡号 tradeserial->customer_id=tCard.cosumer_id; //客户号 des2src(tradeserial->oper_code,Operator); tradeserial->trade_count=in_pack->lvol1+1; //交易次数 tradeserial->in_balance=in_pack->damt0; //入卡值 tradeserial->trade_fee=in_pack->damt1; //交易金额 strncpy(tradeserial->reserve_2,in_pack->vsmess,sizeof(tradeserial->reserve_2)-1); IA->iCardNo=tCard.card_id; IA->iFeeType=tCustomer.fee_type; IA->dArrInAmt[0]=tradeserial->trade_fee; IA->iMainDevId=tradeserial->maindevice_id; //工作站标识 IA->iDevId=tradeserial->device_id; //设备ID IA->iSerialNo=tradeserial->serial_no; //流水号 IA->iTradeNo=tradeserial->serial_type; //交易码 strcpy(IA->sTxDate,tradeserial->operate_date); //交易日期 strcpy(IA->sTxTime,tradeserial->operate_time); //交易时间 strcpy(IA->sTxCollectDate,tradeserial->collect_date); //采集日期 strcpy(IA->sTxCollectTime,tradeserial->collect_time); //采集时间 strcpy(IA->sTxAccDate,tradeserial->enteract_date); //记账日期 strcpy(IA->sTxAccTime,tradeserial->enteract_time); //记账时间 strcpy(IA->sMdeOper,tradeserial->oper_code); //操作员 strcpy(IA->sChkOper,tradeserial->reserve_1); //复核操作员 IA->iUseCardFlag=USE_CARD_TYPE_ONLINE; //联机交易 IA->iTxCnt=tradeserial->trade_count; //交易次数 IA->dInCardBala=tradeserial->in_balance; //入卡值 IA->dOutCardBala=-1; //出卡值 //修改借方和贷方帐户余额,记会计分录帐 ret=AccountProcess(IA); if(ret) { writelog(LOG_ERR,"AccountProcess ret[%d]",ret); return ret; } tradeserial->out_balance=IA->dOutCardBala; //出卡值 if(amtcmp(tradeserial->out_balance,0)<0) { return E_ENTER_ACCOUNT; } 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_BANK_PRE_TOLL_BOARD: case TXTYPE_PRE_TOLL_BOARD_FUNDBOOK: case TXTYPE_SUBSIDY_PRE_TOLL_BOARD_CASH: case TXTYPE_SUBSIDY_PRE_TOLL_BOARD_BILL: case TXTYPE_SUBSIDY_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]); } } ret = db_rollback(); if(ret) { writelog(LOG_ERR,"db_roll_back error,errcode=[%d]",ret); return E_DB_ROLLBACK; } 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; }
int F847103(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret = 0; int hi_cardid = 0; char hi_Operator[33+1] = ""; int hi_Cut_id = 0; int hi_maindevice_id = 0; int hi_device_id = 0; double h_temp_Serial_no = 0; char logicdate[11]=""; char sysdate[11]=""; char systime[8]=""; char dbdate[9]=""; char dbtime[7]=""; char volume[13]=""; T_t_tif_tradeserial tradeserial; T_t_pif_card tCard; T_t_tif_meslist tMesList; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); //用于根据请求包整理本CPACK包的头清空包头位图和包体中的数据 memset(&tradeserial,0,sizeof(tradeserial)); memset(&tCard,0,sizeof(tCard)); memset(&tMesList,0,sizeof(tMesList)); hi_cardid = rPack->lvol1; //卡标识 hi_Cut_id = rPack->lvol2; //客户号 des2src(hi_Operator,rPack->scust_limit); //操作员号 hi_maindevice_id = rPack->lvol6; //上传工作站标识 hi_device_id = rPack->lvol7; //采集设备标识 getsysdate(sysdate); getsystime(systime); ret=GetLogicDate(logicdate); //业务日期 if(ret) { *pRetCode=ret; goto L_RETU; } // 检查卡状态是否为挂失 ret = DB_t_pif_card_read_by_card_id(hi_cardid,&tCard); if (ret) { writelog(LOG_ERR,"card_id[%d]",hi_cardid); if(DB_NOTFOUND==ret) *pRetCode = E_CARDNO_NOT_EXIST; else *pRetCode=E_DB_CARD_R; goto L_RETU; } if(hi_cardid!=tCard.card_id) { writelog(LOG_ERR,"card_id[%d] db card_id[%d]",hi_cardid,tCard.card_id); *pRetCode=E_DB_CARD_R; goto L_RETU; } if('2'==tCard.state_id[CARDSTAT_TYPE_REG]) { *pRetCode = E_CARDNO_LOGOUT; goto L_RETU; } if(STATE_TRUE==tCard.state_id[CARDSTAT_TYPE_FREEZE]) { *pRetCode = E_CARDNO_FREEZE; goto L_RETU; } ret = getNewUniqNo(KEYTYPE_TRADESERIAL,&h_temp_Serial_no); //获得最大流水号 if(ret) { *pRetCode = ret; writelog(LOG_ERR,"ERRCODE = [%d]",ret); goto L_RETU; } 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.serial_no = (int)h_temp_Serial_no; //流水号 tradeserial.serial_type = TXCODE_CARD_COMEBACK_LOSS; //解挂 tradeserial.serial_state = SERISTAT_NONEEDDEBT; //流水状态 tradeserial.maindevice_id = hi_maindevice_id; //上传工作站标识 tradeserial.device_id = hi_device_id; //采集设备标识 tradeserial.card_id = hi_cardid; //交易卡号 tradeserial.customer_id = hi_Cut_id; des2src(tradeserial.oper_code, hi_Operator); if(STATE_FALSE==tCard.state_id[CARDSTAT_TYPE_LOST]) { //允许重复解挂 //再下传白名单 // 插入黑名单表 ret=InsertToBlkList(hi_cardid,DELETE_BLACKLIST); if(ret) { *pRetCode=ret; writelog(LOG_ERR,"InsertToBlkList err[%d]",ret); goto L_RETU; } //广播黑名单 AddXmlItemInt(tMesList.incontent, XML_KEY_CARDID,hi_cardid); AddXmlItemInt(tMesList.incontent, XML_KEY_ADDDELSIGN,DELETE_BLACKLIST); //增删标志 tMesList.pfunid=847103; tMesList.funid = 930005; tMesList.level = 1; ret=AddMsgLst(&tMesList); if(ret) { *pRetCode=ret; writelog(LOG_ERR,"AddMsgLst err[%d]",ret); goto L_RETU; } ret=get_datetime_from_db(dbdate,dbtime); if(ret) { *pRetCode = ret; writelog(LOG_ERR,"ret [%d]",ret); goto L_RETU; } ret = SaveCancelLossSerial(&tradeserial); if(ret) { *pRetCode = ret; writelog(LOG_ERR,"ret [%d]",ret); goto L_RETU; } SetCol(handle,0); SetCol(handle,F_SSERIAL0,0); memset(volume,0,sizeof(volume)); memcpy(volume,dbdate+2,6); memcpy(volume+6,dbtime,6); des2src(out_pack->sserial0,volume); //卡版本号 PutRow(handle,out_pack,pRetCode,szMsg); return 0; } ret=IsExistNoLostCardByCustomId(hi_Cut_id); if(ret) { if(E_NORMALCARD_NOLOST==ret) { *pRetCode = E_BACK_CARD_FOR_NORCARD2; } else if( E_TEMPCARD_NOLOST==ret) { //如果存在正常使用的临时卡,则提示请退掉此卡,不能解挂 if(tCard.type_id==CT_NORMAL) *pRetCode =E_BACK_CARD_FOR_NORCARD; else *pRetCode =E_BACK_CARD_FOR_TMPCARD; } else { *pRetCode = ret; } goto L_RETU; } if(STATE_FALSE==tCard.state_id[CARDSTAT_TYPE_FREEZE]) { //插入黑名单表 ret=InsertToBlkList(hi_cardid,DELETE_BLACKLIST); if(ret) { *pRetCode=ret; writelog(LOG_ERR,"InsertToBlkList err[%d]",ret); goto L_RETU; } //广播黑名单 AddXmlItemInt(tMesList.incontent, XML_KEY_CARDID,hi_cardid); AddXmlItemInt(tMesList.incontent, XML_KEY_ADDDELSIGN,DELETE_BLACKLIST); //增删标志 tMesList.pfunid=847103; tMesList.funid = 930005; tMesList.level = 1; ret=AddMsgLst(&tMesList); if(ret) { *pRetCode=ret; writelog(LOG_ERR,"AddMsgLst err[%d]",ret); goto L_RETU; } } // 修改卡状态为解挂状态 ret = UpdateCardState(hi_cardid,CARDSTAT_TYPE_LOST,STATE_FALSE); if (ret) { *pRetCode = ret; goto L_RETU; } // 准备数据插入交易流水表 ///////////////// ret = SaveCancelLossSerial(&tradeserial); if(ret) { *pRetCode = ret; goto L_RETU; } ret=get_datetime_from_db(dbdate,dbtime); if(ret) { *pRetCode = ret; writelog(LOG_ERR,"ERRCODE = [%d]",ret); goto L_RETU; } SetCol(handle,0); SetCol(handle,F_SSERIAL0,0); memset(volume,0,sizeof(volume)); memcpy(volume,dbdate+2,6); memcpy(volume+6,dbtime,6); des2src(out_pack->sserial0,volume); //卡版本号 PutRow(handle,out_pack,pRetCode,szMsg); return 0; L_RETU: return -1; }
int F240002(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; double unique=0; int temp_serial_no=0; char logicdate[11]=""; char buffer[16]=""; int i=0; double trans_amt=0.0; char sMsg[255]=""; char sDebugMsg[255]=""; char sMaxCardBalance[20]=""; double dMaxCardBalance=0; T_t_aif_account tAccount; //帐户表 T_t_cif_customer tCustomer; T_t_pif_spefee tSpeFee; T_t_tif_tradeserial tradeserial; //卡操作流水表 T_t_pif_card card; InAcc IA; memset(&tSpeFee,0,sizeof(tSpeFee)); memset(&tCustomer,0,sizeof(tCustomer)); memset(&tAccount,0,sizeof(tAccount)); memset(&IA,0,sizeof(IA)); memset(&tradeserial,0,sizeof(tradeserial)); memset(&card,0,sizeof(card)); ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_DAMT0,F_DAMT1,F_DAMT2,F_LVOL1,F_LVOL2,F_SBANK_CODE,F_SEMP_NO,0); //memset(&tradeserial_bak,0,sizeof(tradeserial_bak)); ret=GetLogicDate(logicdate); //业务日期 if(ret) { *pRetCode=E_TRANS_UNKNOW_ERROR; writelog(LOG_ERR,"GetLogicDate error,errcode=[%d]",ret); goto L_RETU; } //判断设备是否登陆 if(0!=device_login_yes_or_no(atoi(rPack->sorder2))) { *pRetCode=E_TRANS_TERM_NOLOGIN; writelog(LOG_ERR,"Device don't login"); goto L_RETU; } //判断是否处于日终结算状态 ret=GetParameter(GLOBE_FLAG_BALANCE,buffer); if(ret) { *pRetCode=E_TRANS_UNKNOW_ERROR; writelog(LOG_ERR,"GetParameter error,errcode=[%d]",ret); goto L_RETU; } else if(strncmp(buffer,"0",1)!=0) { *pRetCode=E_TRANS_BANK_SERVICE_NOEXIT; writelog(LOG_ERR,"System is balance now!"); goto L_RETU; } ret=DB_t_pif_card_read_by_card_id(atoi(rPack->sserial0),&card); if(ret) { *pRetCode=E_TRANS_SCHACC_NOEXIT; writelog(LOG_ERR,"Create serial_no error,error code=[%d]",ret); goto L_RETU; } if(strncmp(card.state_id,CARDSTAT_LOGOUT,4)==0) { *pRetCode=E_TRANS_SCHACC_DESTORY; writelog(LOG_ERR,"card.state_id=[%d]",card.card_id); goto L_RETU; } if(STATE_TRUE==card.state_id[CARDSTAT_TYPE_LOST]) { DB_t_pif_card_free_lock_by_cur(); *pRetCode=E_TRANS_SCHCARD_LOSTING; writelog(LOG_ERR,"card_state=[%s]",card.state_id); goto L_RETU; } if(STATE_TRUE==card.state_id[CARDSTAT_TYPE_FREEZE]) { DB_t_pif_card_free_lock_by_cur(); *pRetCode=E_TRANS_SCHCARD_FREEZE; writelog(LOG_ERR,"card_state=[%s]",card.state_id); goto L_RETU; } if(STATE_TRUE==card.state_id[CARDSTAT_TYPE_WFAIL]) { DB_t_pif_card_free_lock_by_cur(); *pRetCode=E_TRANS_SCHCARD_WFAIL; writelog(LOG_ERR,"card_state=[%s]",card.state_id); goto L_RETU; } //转账不允许转小数金额 if((rPack->lvol5)%100>0) { *pRetCode=E_TRANS_TRANSMONEY_OUTRANGE; writelog(LOG_ERR,"Trans money is not a integer!,transmoney=[%f]",rPack->lvol5/100.0); goto L_RETU; } //开始填充流水数据 //流水号 ret=getNewUniqNo(KEYTYPE_TRADESERIAL, &unique); if(ret) { *pRetCode=E_TRANS_UNKNOW_ERROR; writelog(LOG_ERR,"Create serial_no error,error code=[%d]",ret); goto L_RETU; } tradeserial.serial_no=D2I(unique); //记录流水号,作为冲正使用 temp_serial_no=tradeserial.serial_no; tradeserial.other_seri_no=rPack->lvol0; //上传端流水号 tradeserial.serial_type=TXCODE_BANK_SCHOOL; //交易代码 tradeserial.serial_state=SERISTAT_NODEBT; //流水状态 tradeserial.card_id=atoi(rPack->sserial0); tradeserial.purse_id=0; tradeserial.in_balance=double((rPack->lvol6)/100.00); //入卡金额 tradeserial.out_balance=tradeserial.in_balance; //出卡金额 tradeserial.trade_count=rPack->lvol1+1; //当前卡中交易次数 ret=get_datetime_from_db(tradeserial.operate_date,tradeserial.operate_time); if(ret) { writelog(LOG_ERR,"get_datetime_from_db error,error code=[%d]",ret); getsysdate(tradeserial.operate_date); getsystime(tradeserial.operate_time); } Strncpy_t(tradeserial.collect_date,tradeserial.operate_date,sizeof(tradeserial.collect_date)); //采集日期 Strncpy_t(tradeserial.collect_time,tradeserial.operate_time,sizeof(tradeserial.collect_time)); //采集时间 Strncpy_t(tradeserial.enteract_date,logicdate,sizeof(tradeserial.enteract_date)); //入帐日期 Strncpy_t(tradeserial.enteract_time,tradeserial.operate_time,sizeof(tradeserial.enteract_time)); //入帐时间 tradeserial.maindevice_id=GetTransferSystemId(); //子系统号码 tradeserial.device_id=atoi(rPack->sorder2); //终端ID tradeserial.trade_fee=(rPack->lvol5)/100.0; //转帐金额 Strncpy_t(tradeserial.b_act_id,rPack->scust_auth,sizeof(tradeserial.b_act_id)); tradeserial.sys_id=rPack->lvol2; //表示银行 tradeserial.condition_id=SELF_TRANS; //自动/自助转帐标识 tradeserial.customer_id=card.cosumer_id; Strncpy_t(tradeserial.oper_code,OPER_SYSTEM_KEY,sizeof(tradeserial.oper_code)); //操作员代码 //判断转帐金额是否超出钱包最大限额 ret=DB_t_aif_account_read_by_card_id_and_purse_id(card.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.card_id); if(DB_NOTFOUND==ret) { *pRetCode=E_TRANS_SCHACC_NOEXIT; goto L_RETU; } else { *pRetCode=E_TRANS_UNKNOW_ERROR; goto L_RETU; } } ret=GetParameter(GLOBE_MAXCARDBALANCE,sMaxCardBalance); if(ret) { writelog(LOG_ERR,"GetParameter GLOBE_MAXCARDBALANCE error,errcode=[%d]",ret); *pRetCode=E_TRANS_UNKNOW_ERROR; goto L_RETU; } dMaxCardBalance=atof(sMaxCardBalance); if(amtcmp(tAccount.cur_bala+tradeserial.trade_fee,dMaxCardBalance)>0) { *pRetCode=E_TRANS_TRANSMONEY_OUTRANGE; goto L_RETU; } //读取客户收费类别字段 ret=DB_t_cif_customer_read_lock_by_cur_and_cut_id(card.cosumer_id, &tCustomer); if(ret) { writelog(LOG_ERR,"cut_id[%d]",card.cosumer_id); if(DB_NOTFOUND==ret) { *pRetCode=E_TRANS_UNKNOW_ERROR; goto L_RETU; } else { *pRetCode=E_TRANS_UNKNOW_ERROR; goto L_RETU; } } if(0==tCustomer.fee_type) { 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(); writelog(LOG_ERR,"DB_t_pif_spefee_read_by_dept_code_and_cut_type error,errcode=[%d]",ret); *pRetCode=E_TRANS_UNKNOW_ERROR; goto L_RETU; } } else { tCustomer.fee_type=tSpeFee.fee_type; } } DB_t_cif_customer_free_lock_cur(); //记录流水数据,用于提供正确的流水号,以及银行业务不成功供查询 ret=DB_t_tif_tradeserial_add(&tradeserial); if(ret) { *pRetCode=E_TRANS_UNKNOW_ERROR; writelog(LOG_ERR,"Insert t_tif_tradeserial table error,error code=[%d]",ret); goto L_RETU; } ret=db_commit(); if(ret) { *pRetCode=E_DB_COMMIT; writelog(LOG_ERR,"db_commit error,error code=[%d]",ret); goto L_RETU; } //填写入账结构,问问闻剑 memset(&IA,0,sizeof(IA)); des2src(IA.sArrInActno[0],tAccount.account_id); //贷方帐户,持卡人账户 des2src(IA.sArrInActno[2],rPack->sstation0); //借方帐号,由前置机上传 switch (rPack->lvol3) { case 4: IA.iArrInFeeSwitch[1] = 1; break; case 5: IA.iArrInFeeSwitch[1] = 0; break; default: break; } IA.iCardNo=card.card_id; IA.iFeeType=tCustomer.fee_type; IA.dArrInAmt[0]=tradeserial.trade_fee; writelog(LOG_ERR,"借方帐号=[%d]",atoi(rPack->sstation0)); ret=process(&IA,&tradeserial); if(ret) { writelog(LOG_ERR,"process err,errcode[%d]",ret); *pRetCode=E_TRANS_UNKNOW_ERROR; goto L_RETU; } sprintf(sDebugMsg,"流水号:%d ",IA.iSerialNo); for(i=1;i<=IA.iOutTxTypeCnt;i++) { switch(IA.iArrOutTxType[i]) { case TXTYPE_TOLL_DEPOSIT: case TXTYPE_DEDUCT_DEPOSIT: case TXTYPE_RETURN_DEPOSIT: tradeserial.deposit_fee=IA.dArrOutAmt[i]; break; case TXTYPE_PRE_TOLL_BOARD: case TXTYPE_TOLL_BOARD: case TXTYPE_DEDUCT_BOARD: case TXTYPE_RETURN_BOARD: case TXTYPE_BANK_PRE_TOLL_BOARD: tradeserial.boardfee=IA.dArrOutAmt[i]; break; case TXTYPE_TOLL_CHARGE: tradeserial.in_fee=IA.dArrOutAmt[i]; break; case TXTYPE_BANK_TRANSFER: trans_amt=IA.dArrOutAmt[i]; break; default: break; } if(amtcmp(IA.dArrOutAmt[i],0)!=0) { sprintf(sMsg,"%s:%.2lf元 ",IA.sArrOutTxName[i],IA.dArrOutAmt[i]); strcat(sDebugMsg,sMsg); } } sprintf(sMsg,"充值前卡余额:%.2lf 转帐后卡余额:%.2lf ",IA.dInCardBala,IA.dOutCardBala); strcat(sDebugMsg,sMsg); writelog(LOG_DEBUG,sDebugMsg); out_pack->damt0=tradeserial.out_balance; out_pack->damt1=tradeserial.trade_fee; out_pack->damt2=tradeserial.boardfee; out_pack->lvol1=tradeserial.serial_no; out_pack->lvol2=D2I(tradeserial.out_balance*100.0); des2src(out_pack->semp_no, tradeserial.operate_date); des2src(out_pack->sbank_code, tradeserial.operate_time); PutRow(handle,out_pack,pRetCode,szMsg); //业务结束后,回滚事务 ret=db_rollback(); if(ret) { *pRetCode=E_DB_ROLLBACK; writelog(LOG_ERR,"db_rollback error,error code=[%d]",ret); goto L_RETU; } return 0; L_RETU: return -1; }
int F847230(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret; char sysdate[9] = ""; char systime[7] = ""; char db_date[9] = ""; char db_time[7] = ""; char volume[13] = ""; int auth_card_id = 0; T_t_pif_oper_authcard tAuthCard; T_t_tif_tradeserial tSerial; T_t_pif_operator tOper; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); double uni_no = 0.0; memset(&tAuthCard,0,sizeof tAuthCard); memset(&tSerial,0,sizeof tSerial); memset(&aPack,0,sizeof aPack); ResetNormalCPack(&aPack,0,1); auth_card_id = rPack->lvol0; if(auth_card_id <= 0) { *pRetCode = E_INPUT_CARDNO; goto L_RETU; } if(strlen(rPack->scust_limit) == 0) { *pRetCode = E_INPUT_OPER_NULL; goto L_RETU; } ret = DB_t_pif_oper_authcard_read_by_card_id(auth_card_id,&tAuthCard); if(ret) { if(DB_NOTFOUND == ret) *pRetCode = E_AUTHCARD_NOT_EXISTS; else *pRetCode = E_DB_OPER_AUTHCARD_R; goto L_RETU; } if(tAuthCard.status == AUTHCARD_STATUS_CANCEL) { writelog(LOG_ERR,"auth card has been cancel ,card id[%d]",tAuthCard.card_id); *pRetCode = E_AUTHCARD_HAS_CANCEL; goto L_RETU; } memset(&tOper,0,sizeof tOper); ret = DB_t_pif_operator_read_by_oper_code(tAuthCard.oper_code,&tOper); if(ret) { if(DB_NOTFOUND == ret) { writelog(LOG_ERR,"operator does not exists, oper [%s]",tAuthCard.oper_code); *pRetCode = E_DB_OPERATOR_N; } else *pRetCode = E_DB_OPERATOR_R; goto L_RETU; } if(strcmp(tOper.status,OPERATOR_LOGOUT) == 0) { writelog(LOG_ERR,"operator [%s] has been logout ",tAuthCard.oper_code); *pRetCode = E_OPERLOGON_UNREG; goto L_RETU; } ret=chk_oper_pwd(tAuthCard.oper_code,rPack->semp_pwd); if(ret) { writelog(LOG_ERR,"operator password error, operator [%s]",tAuthCard.oper_code); 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; } tAuthCard.status = AUTHCARD_STATUS_NORMAL; ret = DB_t_pif_oper_authcard_update_by_card_id(tAuthCard.card_id,&tAuthCard); if(ret) { writelog(LOG_ERR,"update operator auth card information error, card id[%d]",tAuthCard.card_id); *pRetCode = E_DB_OPER_AUTHCARD_U; goto L_RETU; } // 插入黑名单表 ret = InsertToBlkList(auth_card_id,DELETE_BLACKLIST); if(ret) { writelog(LOG_ERR,"insert into black list error, card id[%d]",auth_card_id); *pRetCode = ret; goto L_RETU; } // 生成流水 ret = getNewUniqNo(KEYTYPE_TRADESERIAL,&uni_no); if(ret) { *pRetCode = ret; goto L_RETU; } tSerial.serial_no = D2I(uni_no); getsysdate(sysdate); getsystime(systime); tSerial.card_id = tAuthCard.card_id; tSerial.serial_state = SERISTAT_NONEEDDEBT; tSerial.serial_type = TXCODE_UNLOSS_AUTHCARD; des2src(tSerial.operate_date,sysdate); des2src(tSerial.operate_time,systime); des2src(tSerial.enteract_date,sysdate); des2src(tSerial.enteract_time,systime); des2src(tSerial.collect_date,sysdate); des2src(tSerial.collect_time,systime); des2src(tSerial.oper_code,rPack->scust_limit); ret = DB_t_tif_tradeserial_add(&tSerial); if(ret) { if(DB_REPEAT == ret) { writelog(LOG_ERR,"记录流水表失败!"); *pRetCode = E_DB_TRADESERIAL_E; } else *pRetCode = E_DB_TRADESERIAL_I; goto L_RETU; } writelog(LOG_DEBUG,"解挂授权卡成功,操作员[%s]交易卡号[%d]流水号[%d]" ,tAuthCard.oper_code,tAuthCard.card_id,tSerial.serial_no); SetCol(handle,0); SetCol(handle,F_LVOL0,F_SSERIAL0,0); get_datetime_from_db(db_date,db_time); out_pack->lvol0 = auth_card_id; memcpy(volume,db_date+2,6); memcpy(volume+6,db_time,6); des2src(out_pack->sserial0,volume); PutRow(handle,out_pack,pRetCode,szMsg); return 0; L_RETU: return -1; }
int F240003(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg) { int ret=0; #if 0 T_t_tif_tradeserial tradeserial; T_t_card card; int iSeqno=0; memset(&tradeserial,0,sizeof(T_t_tif_tradeserial)); //清空流水结构体 memset(&card,0,sizeof card); ret=getNewUniqNo(KEYTYPE_TRADESERIAL, &iSeqno); //流水号 if(ret) { writelog(LOG_ERR,"Create serial_no error,error code=[%d]",ret); *pRetCode=E_TRANS_UNKNOW_ERROR; goto L_RETU; } ret=DB_t_card_read_by_cardno(atoi(rPack->sserial0),&card); if(ret) { *pRetCode=E_TRANS_SCHACC_NOEXIT; writelog(LOG_ERR,"Create serial_no error,error code=[%d]",ret); goto L_RETU; } tradeserial.cardno=atoi(rPack->sserial0); tradeserial.custid=card.custid; tradeserial.purseno=0; tradeserial.serial_no=iSeqno; tradeserial.serial_type=TXCODE_BANK_DETRANS; //交易代码 tradeserial.serial_state=SERISTAT_NONEEDDEBT; //流水状态 ret=get_datetime_from_db(tradeserial.operate_date,tradeserial.operate_time); if(ret) { writelog(LOG_ERR,"get_datetime_from_db error,error code=[%d]",ret); des2src(tradeserial.operate_date,getsysdate(NULL)); //交易日期 des2src(tradeserial.operate_time,getsystime(NULL)); //交易时间 } des2src(tradeserial.collect_date,tradeserial.operate_date);//采集日期 des2src(tradeserial.collect_time,tradeserial.operate_time);//采集时间 tradeserial.maindeviceid=GetTransferSystemId(); //子系统号码 tradeserial.deviceid=atoi(rPack->sorder2); //终端ID tradeserial.trade_fee=rPack->lvol5/100.0; //转帐金额 tradeserial.cardbefbal=rPack->lvol6/100.0; //入卡金额 tradeserial.cardaftbal=tradeserial.cardbefbal; //出卡金额 des2src(tradeserial.b_act_id,rPack->scust_auth); //银行卡号 tradeserial.sysid=rPack->lvol2; //外部系统标识,此处为配置文件中读取参数 tradeserial.condition_id=SELF_TRANS; //自动/自助转帐标识 des2src(tradeserial.opercode,OPER_SYSTEM_KEY); //操作员代码 tradeserial.reviseserial_no=rPack->lvol0; //原始流水号 tradeserial.trade_count=rPack->lvol1+1; //交易次数 tradeserial.tmark=0; ret=DB_t_tif_tradeserial_add(&tradeserial); if(ret) { writelog(LOG_ERR,"Insert t_tif_tradeserial table error,error code=[%d]",ret); *pRetCode=E_TRANS_UNKNOW_ERROR; goto L_RETU; } #endif return 0; }
int record_serial(ST_PACK *in_pack,T_t_tif_tradeserial *tradeserial,ST_PACK *out_pack){ int ret =0; int card_id= 0; double dUniqno = 0; char logicdate[11]=""; char sysdate[11]=""; char systime[9]=""; char Operator[33+1] = ""; int maindevice_id = 0; T_t_pif_card tCard; card_id=in_pack->lvol0; memset(&tCard,0,sizeof(tCard)); 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); return ret; } ret=GetLogicDate(logicdate); //业务日期 if(ret) { writelog(LOG_ERR,"GetLogicDate error,errcode=[%d]",ret); return ret; } ret=DB_t_pif_card_read_by_card_id(card_id, &tCard); if(ret) { if(DB_NOTFOUND==ret) ret=E_CARDNO_NOT_EXIST; else ret=E_DB_CARD_R; return ret; } if(strncmp(tCard.state_id,CARDSTAT_REG,4)!=0) { if('2'==tCard.state_id[CARDSTAT_TYPE_REG]) ret= E_CARDNO_LOGOUT; else if('3'==tCard.state_id[CARDSTAT_TYPE_REG]) ret = E_CARD_CHANGE; else if(tCard.state_id[CARDSTAT_TYPE_LOST]==STATE_TRUE) ret=E_CARDNO_LOST; else if(tCard.state_id[CARDSTAT_TYPE_FREEZE]==STATE_TRUE) ret=E_CARDNO_FREEZE; else if(tCard.state_id[CARDSTAT_TYPE_WFAIL]==STATE_TRUE) ret=E_CARDNO_WFAIL; return ret; } // 准备数据插入交易流水表 ret = getNewUniqNo(KEYTYPE_TRADESERIAL,&dUniqno); //获得最大流水号 if(ret) { writelog(LOG_ERR,"getNewUniqNo error,errcode=[%d]",ret); return ret; } tradeserial->serial_no = D2I(dUniqno); //流水号 if(strlen(in_pack->scust_no) ==0) return E_INPUT_OPER_NULL; des2src(Operator,in_pack->scust_no); //操作员号 //采集设备标识 strncpy(tradeserial->operate_date,sysdate,sizeof(sysdate)-1); //发生日期 strncpy(tradeserial->operate_time,systime,sizeof(systime)-1); des2src(tradeserial->collect_date,tradeserial->operate_date); //采集日期 des2src(tradeserial->collect_time,tradeserial->operate_time); //采集时间 des2src(tradeserial->enteract_date,logicdate); //处理日期 des2src(tradeserial->enteract_time,tradeserial->operate_time); //处理时间 tradeserial->serial_no = D2I(dUniqno); //流水号 tradeserial->purse_id = PURSE_NO_ONE; //钱包号 tradeserial->serial_state = SERISTAT_NODEBT; //流水状态 tradeserial->maindevice_id = maindevice_id; //上传工作站标识 tradeserial->device_id = in_pack->lvol4; //采集设备标识 tradeserial->card_id = card_id; //交易卡号 tradeserial->customer_id=tCard.cosumer_id; //客户号 des2src(tradeserial->oper_code,Operator); tradeserial->trade_count=in_pack->lvol1+1; //交易次数 tradeserial->in_balance=in_pack->damt0; //入卡值 //除了海事的考试报名,别的交易金额不能小于0 if(amtcmp(in_pack->damt1, 0) <= 0) { if(tradeserial->serial_type != 847233) return E_INPUT_AMT_NULL; } tradeserial->trade_fee=in_pack->damt1; //交易金额 strncpy(tradeserial->reserve_2,in_pack->vsmess,sizeof(tradeserial->reserve_2)-1); ret = DB_t_tif_tradeserial_add(tradeserial); if (ret) { writelog(LOG_ERR,"ret[%d]",ret); if(DB_REPEAT==ret) ret = E_DB_TRADESERIAL_E; else ret = E_DB_TRADESERIAL_I; return ret; } ret=db_commit(); if(ret) { writelog(LOG_ERR,"db_commit error,errcode=[%d]",ret); return E_DB_COMMIT; } return 0; }