// 绑定关系修改 int doUpbing(KS_YKT_Clt &ykt_clt,INFO_BIND &info_bind,char *recv_buf) { int ret=0; char errmsg[256]=""; char stuemp_no[32]=""; //学工号 char bank_no[21]=""; // 银行卡号 char bankseri[21]=""; // 银行端流水号 ret = GetXmlValue(stuemp_no, 32, "IcCard", recv_buf); if(ret) { writelog(LOG_ERR,"获取IcCard 号错误"); return ret; } trim(stuemp_no); ret = GetXmlValue(bank_no, 21, "ActNo", recv_buf); if(ret) { writelog(LOG_ERR,"获取ActNo 号错误"); return ret; } trim(bank_no); ret = GetXmlValue(bankseri, 21, "TransNo", recv_buf); if(ret) { writelog(LOG_ERR,"获取TransNo 号错误"); return ret; } trim(bankseri); writelog(LOG_INFO,"绑定修改 stuempno[%s],bankno[%s]\n",stuemp_no,bank_no); ykt_clt.SetStringFieldByName("sstatus0", "U"); ykt_clt.SetStringFieldByName("scust_auth2", stuemp_no); ykt_clt.SetStringFieldByName("scard1", bank_no); ykt_clt.SetStringFieldByName("scust_no", bankseri); ykt_clt.SetStringFieldByName("sbank_code", BANKCODE); ykt_clt.SetIntFieldByName("lwithdraw_flag", g_para.term_id); if(!ykt_clt.SendRequest(841602, g_para.drtp_timeout)) { ykt_clt.GetStringFieldByName("vsmess",errmsg,sizeof errmsg); trim(errmsg); des2src(info_bind.ReMark,errmsg); writelog(LOG_ERR,"向后台发送请求失败[%s]\n",errmsg); return -1; } if(ret = ykt_clt.GetReturnCode()) { ykt_clt.GetStringFieldByName("vsmess",errmsg,sizeof errmsg); trim(errmsg); des2src(info_bind.ReMark,errmsg); writelog(LOG_ERR,"后台功能执行失败,retcode[%d],msg[%s]\n",ret,errmsg); return ret; } des2src(info_bind.TrType,"02"); des2src(info_bind.IcCard, stuemp_no); des2src(info_bind.SchoolCode,SCHOOLCODE_AHUT); des2src(info_bind.ReMark,"修改成功"); return 0; }
int COptions::GetOptionVal(unsigned int nID) { if (nID >= OPTIONS_NUM) return 0; if (options[nID].type != number) return 0; if (m_optionsCache[nID].cached) return m_optionsCache[nID].numValue; wxString value; long numValue = 0; if (options[nID].internal || !GetXmlValue(nID, value)) options[nID].defaultValue.ToLong(&numValue); else { value.ToLong(&numValue); numValue = Validate(nID, numValue); } m_optionsCache[nID].numValue = numValue; m_optionsCache[nID].cached = true; return numValue; }
void CSolarSystemDoc::LoadBodyXml(MSXML::IXMLDOMNodePtr& node, MolecularDynamics::Body& body, BodyProperties& props) { props.isSun = GetXmlBoolValue(node, L"IsSun", false); props.isMoon = GetXmlBoolValue(node, L"IsMoon", false); props.tilt = GetXmlDoubleValue(node, L"Tilt", 0); props.color = RGB(GetXmlIntValue(node,L"R",0), GetXmlIntValue(node, L"G", 0), GetXmlIntValue(node, L"B", 0)); props.imgFile = GetXmlValue(node, L"skin", L""); props.scale = GetXmlDoubleValue(node, L"Scale", 1.); props.scaleDistance = GetXmlDoubleValue(node, L"ScaleDistance", 1.); body.rotationPeriod = GetXmlDoubleValue(node, L"RotationPeriod", 1) * 24 * 3600; body.m_Mass = GetXmlDoubleValue(node, L"Mass", 0); body.m_Radius = GetXmlDoubleValue(node, L"Radius", 0); body.m_Position.X = GetXmlDoubleValue(node, L"XPosition", 0); body.m_Position.Y = GetXmlDoubleValue(node, L"YPosition", 0); body.m_Position.Z = GetXmlDoubleValue(node, L"ZPosition", 0); body.m_Velocity.X = GetXmlDoubleValue(node, L"XVelocity", 0); body.m_Velocity.Y = GetXmlDoubleValue(node, L"YVelocity", 0); body.m_Velocity.Z = GetXmlDoubleValue(node, L"ZVelocity", 0); }
bool CSolarSystemDoc::GetXmlBoolValue(MSXML::IXMLDOMNodePtr pNode, const bstr_t& name, bool def) { CString result = GetXmlValue(pNode, name); result = result.Trim().MakeLower(); if (result == L"1" || result == L"yes" || result == L"true") return true; return def; }
int CSolarSystemDoc::GetXmlIntValue(MSXML::IXMLDOMNodePtr pNode, const bstr_t& name, int def) { CString result = GetXmlValue(pNode, name); result = result.Trim(); if (result.IsEmpty()) return def; return _wtoi(result); }
void COptions::Import(TiXmlElement* pElement) { for (int i = 0; i < OPTIONS_NUM; i++) { if (options[i].internal) continue; wxString value; if (!GetXmlValue(i, value, pElement)) continue; SetOption(i, value); } }
int doCkbing(KS_YKT_Clt &ykt_clt,INFO_BIND &info_bind,char *recv_buf) { int ret=0; char errmsg[256]=""; char stuemp_no[32]=""; //学工号 ret = GetXmlValue(stuemp_no, 32, "IcCard", recv_buf); if(ret) { writelog(LOG_ERR,"获取IcCard 号错误"); return ret; } trim(stuemp_no); ykt_clt.SetStringFieldByName("sstatus0", "R"); ykt_clt.SetStringFieldByName("spager", stuemp_no); ykt_clt.SetStringFieldByName("sbank_code", BANKCODE); ykt_clt.SetStringFieldByName("sstatus1", "1"); ykt_clt.SetIntFieldByName("lwithdraw_flag", g_para.term_id); if(!ykt_clt.SendRequest(841602, g_para.drtp_timeout)) { ykt_clt.GetStringFieldByName("vsmess",errmsg,sizeof errmsg); trim(errmsg); des2src(info_bind.ReMark,errmsg); writelog(LOG_ERR,"向后台发送请求失败[%s]\n",errmsg); return -1; } if(ret = ykt_clt.GetReturnCode()) { ykt_clt.GetStringFieldByName("vsmess",errmsg,sizeof errmsg); trim(errmsg); des2src(info_bind.ReMark,errmsg); writelog(LOG_ERR,"后台功能执行失败,retcode[%d],msg[%s]\n",ret,errmsg); return ret; } else { ykt_clt.GetStringFieldByName("sall_name",info_bind.CusName, sizeof(info_bind.CusName)); des2src(info_bind.TrType,"04"); des2src(info_bind.IcCard, stuemp_no); des2src(info_bind.SchoolCode,SCHOOLCODE_AHUT); des2src(info_bind.ReMark,"查询成功"); return 0; } return 0; }
//无卡充值查询 int doCkbala(KS_YKT_Clt &ykt_clt,INFO_TRADE &info_trade,char *recv_buf) { int ret=0; char errmsg[256]=""; char stuemp_no[32]=""; //学工号 ret = GetXmlValue(stuemp_no, 32, "IcCard", recv_buf); if(ret) { writelog(LOG_ERR,"获取IcCard 号错误"); return ret; } trim(stuemp_no); ykt_clt.SetStringFieldByName("spager", stuemp_no); ykt_clt.SetStringFieldByName("sstatus1", "C"); // 交易标志 ykt_clt.SetIntFieldByName("lwithdraw_flag", g_para.term_id); if(!ykt_clt.SendRequest(847133, g_para.drtp_timeout)) { ykt_clt.GetStringFieldByName("vsmess",errmsg,sizeof errmsg); trim(errmsg); des2src(info_trade.ReMark,errmsg); writelog(LOG_ERR,"向后台发送请求失败[%s]\n",errmsg); return -1; } if(ret = ykt_clt.GetReturnCode()) { ykt_clt.GetStringFieldByName("vsmess",errmsg,sizeof errmsg); trim(errmsg); des2src(info_trade.ReMark,errmsg); writelog(LOG_ERR,"后台功能执行失败,retcode[%d],msg[%s]\n",ret,errmsg); return ret; } else { ykt_clt.GetStringFieldByName("sall_name",info_trade.CusName, sizeof(info_trade.CusName)); // 姓名 ykt_clt.GetDoubleFieldByName("damt0", &info_trade.ICCardNotWrt); //未充值金额 ykt_clt.GetDoubleFieldByName("damt1", &info_trade.IcCardBal); //帐户余额 } return 0; }
wxString COptions::GetOption(unsigned int nID) { if (nID >= OPTIONS_NUM) return _T(""); if (options[nID].type != string) return wxString::Format(_T("%d"), GetOptionVal(nID)); if (m_optionsCache[nID].cached) return m_optionsCache[nID].strValue; wxString value; if (options[nID].internal || !GetXmlValue(nID, value)) value = options[nID].defaultValue; else Validate(nID, value); m_optionsCache[nID].strValue = value; m_optionsCache[nID].cached = true; return value; }
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 F849014(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg) { int ret=0; int card_id = 0; T_t_pif_card tCard; char buf[64] = ""; char comments[256] = ""; char reqdata[1024] = ""; char temp[1024] = ""; ST_CPACK aPack; ST_PACK* out_pack = &(aPack.pack); char svr_ip[21 ] = ""; int svr_port = 0; CTcpSocket sock; KSG_GW_PACK_t * resp = NULL; if(strlen(in_pack->sname) < 1) { *pRetCode = E_INPUT_DORM_NO; goto L_RETU; } ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_VSMESS,0); ret = GetPowerServerInfo(svr_ip,&svr_port); if(ret) { *pRetCode = ret; goto L_RETU; } gw_server_info_t svrinfo; des2src(svrinfo.server_ip,svr_ip); svrinfo.server_port = svr_port; svrinfo.sock = &sock; AddXmlItemStr(temp,XML_KEY_DORM_NO,in_pack->sname); writelog(LOG_DEBUG,"xml[%s]",temp); sprintf(reqdata,"<YKT_DATA>%s</YKT_DATA>",temp); writelog(LOG_DEBUG,"xml[%s]",reqdata); ret = SendToServer(&svrinfo,QUERY_DORM_NAME,reqdata); if(ret) { writelog(LOG_DEBUG,"电控返回数据[%d]",ret); *pRetCode =ret; goto L_RETU; } ret = RecvFromServer(&svrinfo,&resp); if(ret) { writelog(LOG_DEBUG,"电控返回数据[%d]",ret); *pRetCode = ret; goto L_RETU; } else { if(resp->func_no != QUERY_DORM_NAME || resp->retcode != 0) { writelog(LOG_DEBUG,"funcno [%d] ret[%d]",resp->func_no,resp->retcode); *pRetCode = E_POWER_RECV_ERR; goto L_RETU; } des2src(reqdata,resp->data); ret = GetXmlValue(comments,sizeof comments,XML_KEY_DORM_NAME,reqdata); if(ret) { writelog(LOG_DEBUG,"无数据[%s][%d]",reqdata,ret); *pRetCode = ret; goto L_RETU; } des2src(out_pack->vsmess,comments); PutRow(handle,out_pack,pRetCode,szMsg); } if(resp) free(resp); return 0; L_RETU: if(resp) free(resp); return -1; }
int doResponse(char *recv_buf,int recv_len,char *send_buf,int &send_len) { int retcode = 0; char tradecode[8] = ""; char trtype[3]=""; INFO_BIND info_bind; INFO_TRADE info_trade; memset(&info_bind,0,sizeof info_bind); memset(&info_trade,0,sizeof info_trade); memcpy(tradecode,recv_buf,TRADECODE_LEN); KS_YKT_Clt ykt_clt; char msghead[1024]=""; char msgbody[1024]=""; ykt_clt.ResetHandler(); if(strncmp(tradecode,TRADE_BIND,TRADECODE_LEN) == 0) // 签约 { retcode= GetXmlValue(trtype, 3, "TrType", recv_buf); if(retcode) { writelog(LOG_INFO,"get TrType err,errcode[%d]",retcode); return retcode; } switch(atoi(trtype)) { case 1: // 签约 retcode = doBind(ykt_clt,info_bind,recv_buf); break; case 2: // 修改 retcode = doUpbing(ykt_clt,info_bind,recv_buf); break; case 3: // 撤约 retcode = doUnbind(ykt_clt,info_bind,recv_buf); break; case 4: // 查询 retcode = doCkbing(ykt_clt,info_bind,recv_buf); break; default: return E_TRANS_NONSUPPORT; } if(retcode) { if(retcode<0) retcode = 1111; } GenResMsgHead(msghead,NULL,retcode,info_bind.ReMark); // 生成msghead GenBindResMsgBody(msgbody,info_bind); GenTransResMSG(send_buf,"2140",msghead,msgbody); send_len = strlen(send_buf); } else { if(strncmp(tradecode,TRADE_PAY_NOCARD,TRADECODE_LEN) == 0) // 无卡充值 retcode = doTrade(ykt_clt, info_trade, recv_buf, false); else if(strncmp(tradecode,TRADE_REV_NOCARD,TRADECODE_LEN) == 0) retcode = doTrade(ykt_clt, info_trade, recv_buf, true); else if(strncmp(tradecode,TRADE_CHK_NOCARD,TRADECODE_LEN) == 0) retcode = doCkbala(ykt_clt, info_trade, recv_buf); else return E_TRANS_NONSUPPORT; if(retcode) { if(retcode<0) retcode = 1111; } writelog(LOG_DEBUG,"未写卡余额[%.2f]\n",info_trade.ICCardNotWrt); GenResMsgHead(msghead,info_trade.Refno,retcode,info_trade.ReMark); // 生成msghead GenTradeResMsgBody(msgbody,info_trade); tradecode[1]='1'; GenTransResMSG(send_buf,tradecode,msghead,msgbody); send_len = strlen(send_buf); } return 0; }
int F930002(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg) { int ret = 0; int cnt=0; int msgid=0; T_t_msglist tMsgList; // T_t_device tDevice; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LSERIAL1,F_SDATE0,F_SSERIAL0,F_VSVARSTR0,0); memset(&tMsgList,0,sizeof(tMsgList)); // memset(&tDevice,0,sizeof tDevice); tMsgList.deviceid = in_pack->lcert_code; if(!tMsgList.deviceid) { return E_INPUTNULL_DEVICE; } tMsgList.funcno = 930002; tMsgList.msglevel = MESLIST_PRIORITY_REALTIME; ret=AddMsgLst(&tMsgList); if(ret) { *pRetCode=ret; writelog(LOG_ERR,"AddMsgLst err[%d]",ret); goto L_RETU; } if(iRequest!=tMsgList.funcno) return 0; ret=db_commit(); if(ret) { writelog(LOG_ERR,"db_commit ret[%d]",ret); *pRetCode=E_DB_COMMIT; goto L_RETU; } msgid=tMsgList.msgid; des2src(out_pack->sdate0,in_pack->sdate0); for(cnt=0;(cnt<20)&&(tMsgList.errcode!=0);cnt++) { sleep(1); memset(&tMsgList,0,sizeof(tMsgList)); ret=DB_t_msglist_read_by_msgid(msgid, &tMsgList); if(ret) { writelog(LOG_ERR,"DB_t_msglist_read_by_msgid err[%d]",ret); *pRetCode=E_DB_MSGLIST_R; goto L_RETU; } } switch(tMsgList.errcode) { case 0: //成功 ret=GetXmlValue(out_pack->sserial0,sizeof(out_pack->sserial0),XML_KEY_CLOCK, tMsgList.respdata); if(ret) { *pRetCode=ret; goto L_RETU; } des2src(out_pack->vsvarstr0,"成功"); break; case 9999: //交易未处理 des2src(out_pack->vsvarstr0,"前置机无应答"); break; default: //交易已经处理,但结果是失败 des2src(out_pack->vsvarstr0,tMsgList.errmsg); break; } PutRow(handle,out_pack,pRetCode,szMsg); return 0; L_RETU: return -1; }
int F930002(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg) { int ret = 0; int cnt=0; int mesid=0; T_t_tif_meslist tMesList; T_t_device tDevice; ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_LSERIAL1,F_SDATE0,F_SSERIAL0,F_VSVARSTR0,0); memset(&tMesList,0,sizeof(tMesList)); memset(&tDevice,0,sizeof tDevice); if(strlen(in_pack->sdate0)==0) { if(in_pack->lcert_code <=0 ) { *pRetCode=E_DEVPHYID_NULL; goto L_RETU; } tMesList.devid = in_pack->lcert_code; } else { if((ret = get_devinfo_by_phyid(in_pack->sdate0,&tDevice))) { *pRetCode = ret; goto L_RETU; } tMesList.devid = tDevice.deviceid; } tMesList.funid = 930002; tMesList.level = MESLIST_PRIORITY_REALTIME; ret=AddMsgLst(&tMesList); if(ret) { *pRetCode=ret; writelog(LOG_ERR,"AddMsgLst err[%d]",ret); goto L_RETU; } if(iRequest!=tMesList.funid) return 0; ret=db_commit(); if(ret) { writelog(LOG_ERR,"db_commit ret[%d]",ret); *pRetCode=E_DB_COMMIT; goto L_RETU; } mesid=tMesList.mesid; des2src(out_pack->sdate0,in_pack->sdate0); for(cnt=0;(cnt<10)&&(tMesList.ecode!=0);cnt++) { sleep(1); memset(&tMesList,0,sizeof(tMesList)); ret=DB_t_tif_meslist_read_by_mesid(mesid, &tMesList); if(ret) { writelog(LOG_ERR,"DB_t_tif_meslist_read_by_mesid err[%d]",ret); *pRetCode=E_DB_MESLIST_R; goto L_RETU; } } switch(tMesList.ecode) { case 0: //成功 ret=GetXmlValue(out_pack->sserial0,sizeof(out_pack->sserial0),XML_KEY_CLOCK, tMesList.outcontent); if(ret) { *pRetCode=ret; goto L_RETU; } des2src(out_pack->vsvarstr0,"成功"); break; case 9999: //交易未处理 des2src(out_pack->vsvarstr0,"前置机无应答"); break; default: //交易已经处理,但结果是失败 des2src(out_pack->vsvarstr0,tMesList.emsg); break; } PutRow(handle,out_pack,pRetCode,szMsg); return 0; L_RETU: return -1; }
int F930064(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg) { int ret = 0; int cnt=0; int mesid=0; char dev999_no[20]=""; T_t_tif_meslist tMesList; T_t_pif_device tDevice; memset(&tDevice,0,sizeof tDevice); ST_CPACK aPack; ST_PACK *out_pack = &(aPack.pack); ResetNormalCPack(&aPack,0,1); SetCol(handle,0); SetCol(handle,F_SDATE0,F_SDATE2,F_SDATE3,F_LVOL3,F_VSVARSTR0,0); memset(&tMesList,0,sizeof(tMesList)); if(strlen(in_pack->sdate0)==0) { *pRetCode=E_DEVPHYID_NULL; goto L_RETU; } AddXmlItemInt(tMesList.incontent, XML_KEY_MAXTRADE, in_pack->lvol4); if((ret = get_devinfo_by_phyid(in_pack->sdate0,&tDevice))) { *pRetCode = ret; goto L_RETU; } tMesList.devid = tDevice.device_id; tMesList.funid = 930064; tMesList.level = 2; ret=AddMsgLst(&tMesList); if(ret) { *pRetCode=ret; writelog(LOG_ERR,"AddMsgLst err[%d]",ret); goto L_RETU; } if(iRequest!=tMesList.funid) return 0; ret=db_commit(); if(ret) { writelog(LOG_ERR,"db_commit ret[%d]",ret); *pRetCode=E_DB_COMMIT; goto L_RETU; } mesid=tMesList.mesid; des2src(out_pack->sdate0,in_pack->sdate0); for(cnt=0;(cnt<10)&&(tMesList.ecode!=0);cnt++) { sleep(1); memset(&tMesList,0,sizeof(tMesList)); ret=DB_t_tif_meslist_read_by_mesid(mesid, &tMesList); if(ret) { writelog(LOG_ERR,"DB_t_tif_meslist_read_by_mesid err[%d]",ret); *pRetCode=E_DB_MESLIST_R; goto L_RETU; } } switch(tMesList.ecode) { case 0: //成功 des2src(out_pack->vsvarstr0,"成功"); ret=GetXmlValue(out_pack->sdate0,sizeof(out_pack->sdate0),XML_KEY_DEVPHY999_NO, tMesList.outcontent); if(ret) { *pRetCode=ret; goto L_RETU; } ret=GetXmlValue(dev999_no,sizeof(dev999_no),XML_KEY_DEV999_NO, tMesList.outcontent); if(ret) { *pRetCode=ret; goto L_RETU; } out_pack->lvol3=atoi(dev999_no); ret=GetXmlValue(out_pack->sdate2,sizeof(out_pack->sdate2),XML_KEY_DEV999_ID, tMesList.outcontent); if(ret) { *pRetCode=ret; goto L_RETU; } ret=GetXmlValue(out_pack->semp,sizeof(out_pack->semp),XML_KEY_DEVTYPE, tMesList.outcontent); if(ret) { *pRetCode=ret; goto L_RETU; } ret=GetXmlValue(out_pack->sdate3,sizeof(out_pack->sdate3),XML_KEY_DEVVERSION, tMesList.outcontent); if(ret) { *pRetCode=ret; goto L_RETU; } break; case 9999: //交易未处理 des2src(out_pack->vsvarstr0,"前置机无应答"); break; default: //交易已经处理,但结果是失败 des2src(out_pack->vsvarstr0,tMesList.emsg); break; } PutRow(handle,out_pack,pRetCode,szMsg); return 0; L_RETU: return -1; }
bool ParseXmlFile( TCHAR* pszFileName ) { if( NULL == pszFileName ) { return false; } HRESULT hResult; // DOMドキュメントの作成 IXMLDOMDocumentPtr pXMLDOMDocument; hResult = pXMLDOMDocument.CreateInstance(CLSID_DOMDocument); if( FAILED(hResult) ) { assert( !"DOMドキュメントの作成に失敗" ); return false; } // XMLファイル読み込み pXMLDOMDocument->put_async( VARIANT_FALSE ); // load関数がロードを完了するまで待つようにする。 VARIANT_BOOL varbResult; hResult = pXMLDOMDocument->load( CComVariant(pszFileName), &varbResult ); if( FAILED(hResult) || !varbResult) { assert( !"XMLファイル読み込みに失敗" ); return false; } // std::vector<CComBSTR> vbstrValue; std::vector<CComBSTR> vbstrValueName; std::vector<CComBSTR> vbstrValueScreenName; std::vector<CComBSTR> vbstrValueText; std::vector<CComBSTR> vbstrValueDate; /* // author要素の値の取得 if( !GetXmlValue( pXMLDOMDocument, _T("author"), _T(""), vbstrValue ) ) { assert( !"author要素の値の取得に失敗" ); return false; } std::cout << "author要素の値" << std::endl; for( unsigned int ui = 0; ui < vbstrValue.size(); ++ui ) { std::cout << "\t" << _com_util::ConvertBSTRToString(vbstrValue[ui]) << std::endl; } */ /* // book要素のid属性の値の取得 if( !GetXmlValue( pXMLDOMDocument, _T("book"), _T("id"), vbstrValue ) ) { assert( !"book要素のid属性の値の取得に失敗" ); return false; } std::cout << "book要素のid属性の値" << std::endl; for( unsigned int ui = 0; ui < vbstrValue.size(); ++ui ) { std::cout << "\t" << _com_util::ConvertBSTRToString((TCHAR*)vbstrValue[ui]) << std::endl; } */ // name要素の値の取得 if( !GetXmlValue( pXMLDOMDocument, _T("name"), _T(""), vbstrValueName ) ) { assert( !"name要素の値の取得に失敗" ); return false; } // screen_name要素の値の取得 if( !GetXmlValue( pXMLDOMDocument, _T("screen_name"), _T(""), vbstrValueScreenName ) ) { assert( !"screen_name要素の値の取得に失敗" ); return false; } // created_at要素の値の取得 if( !GetXmlValue( pXMLDOMDocument, _T("created_at"), _T(""), vbstrValueDate ) ) { assert( !"created_at要素の値の取得に失敗" ); return false; } // text要素の値の取得 if( !GetXmlValue( pXMLDOMDocument, _T("text"), _T(""), vbstrValueText ) ) { assert( !"text要素の値の取得に失敗" ); return false; } std::cout << "つぶやきの表示テスト\n" << std::endl; for( unsigned int ui = 0; ui < vbstrValueName.size(); ++ui ) { std::cout << ui+1 << ")" << _com_util::ConvertBSTRToString(vbstrValueName[ui]) << " " << _com_util::ConvertBSTRToString(vbstrValueScreenName[ui]) << std::endl; std::cout << " " << _com_util::ConvertBSTRToString(vbstrValueText[ui]) << std::endl; std::cout << " " << _com_util::ConvertBSTRToString(vbstrValueDate[ui]) << "\n" << std::endl; } return true; }
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 doTrade(KS_YKT_Clt &ykt_clt,INFO_TRADE &info_trade,char *recv_buf,bool bRev) { int ret=0; char errmsg[256]=""; char stuemp_no[32]=""; //学工号 char samount[32]=""; //金额 double damount = 0; char RSeqNo[21]=""; // 冲正流水号 char TransNo[21]=""; char transflag[2]=""; ret = GetXmlValue(TransNo, 21, "TransNo", recv_buf); if(ret) { writelog(LOG_ERR,"获取TransNo 号错误"); return ret; } ret = GetXmlValue(stuemp_no, 32, "IcCard", recv_buf); if(ret) { writelog(LOG_ERR,"获取IcCard 号错误"); return ret; } ret = GetXmlValue(samount, 32, "Amount", recv_buf); if(ret) { writelog(LOG_ERR,"获取Amount 错误"); return ret; } transflag[0]='T'; // 充值 if(bRev) // 冲正 { ret = GetXmlValue(RSeqNo, 21, "RSeqNo", recv_buf); if(ret) { writelog(LOG_ERR,"获取RSeqNo 错误"); return ret; } trim(RSeqNo); transflag[0]='R'; // 冲正 ykt_clt.SetStringFieldByName("scust_auth", RSeqNo); // 冲正流水号 } trim(stuemp_no); trim(samount); damount = atof(samount); ykt_clt.SetStringFieldByName("sstatus1", transflag); // 交易标志 ykt_clt.SetStringFieldByName("scust_auth2", TransNo); ykt_clt.SetStringFieldByName("spager", stuemp_no); ykt_clt.SetDoubleFieldByName("damt0", damount); ykt_clt.SetIntFieldByName("lwithdraw_flag", g_para.term_id); if(!ykt_clt.SendRequest(847133, g_para.drtp_timeout)) { ykt_clt.GetStringFieldByName("vsmess",errmsg,sizeof errmsg); trim(errmsg); des2src(info_trade.ReMark,errmsg); writelog(LOG_ERR,"向后台发送请求失败[%s]\n",errmsg); return -1; } if(ret = ykt_clt.GetReturnCode()) { ykt_clt.GetStringFieldByName("vsmess",errmsg,sizeof errmsg); trim(errmsg); des2src(info_trade.ReMark,errmsg); writelog(LOG_ERR,"后台功能执行失败,retcode[%d],msg[%s]\n",ret,errmsg); return ret; } else { ykt_clt.GetStringFieldByName("sall_name",info_trade.CusName, sizeof(info_trade.CusName)); // 姓名 ykt_clt.GetDoubleFieldByName("damt0", &info_trade.ICCardNotWrt); //未充值金额 ykt_clt.GetStringFieldByName("sname2", info_trade.Refno, sizeof(info_trade.Refno)); // 流水号 } return 0; }