Example #1
0
int F930018(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg)
{
	int ret = 0;
       T_t_tif_meslist tMesList;

	memset(&tMesList,0,sizeof(tMesList));

	des2src(tMesList.devphy999_id, in_pack->sdate0);
	trim(tMesList.devphy999_id);
	if(strlen(tMesList.devphy999_id)==0)
	{
		*pRetCode=E_DEVPHYID_NULL;
		goto L_RETU;
	}

	AddXmlItemInt(tMesList.incontent,XML_KEY_FEETYPE, in_pack->lvol4);
	AddXmlItemInt(tMesList.incontent,XML_KEY_STARTNUM,in_pack->lvol5);
	AddXmlItemInt(tMesList.incontent,XML_KEY_ENDNUM,in_pack->lvol6);

	tMesList.funid = 930018;
	tMesList.level = 1;
	ret=AddMsgLst(&tMesList);
	if(ret)
	{
		*pRetCode=ret;
		writelog(LOG_ERR,"AddMsgLst err[%d]",ret);
		goto L_RETU;
	}
	return 0;
L_RETU:
	return  -1;	
}
Example #2
0
static void GenResMsgHead(char *msghead,char *refno,int errcode,char *errmsg)
{
	char buf[1024]="";
	char sysdate[9]="";
	char systime[7]="";
	getsysdate(sysdate);
	getsystime(systime);
	AddXmlItemStr(buf,"AreaNo","");								//地区代码
	AddXmlItemStr(buf,"ChanNo","");								//渠道代码
	if(refno != NULL)
		AddXmlItemStr(buf,"TransNo",refno);						//交易流水号
	else
		AddXmlItemStr(buf,"TransNo","");							
	AddXmlItemStr(buf,"TransDate",sysdate);						//交易日期
	AddXmlItemStr(buf,"TransTime",systime);						//交易时间
	AddXmlItemStr(buf,"BankNo","");								//机构代码
	AddXmlItemStr(buf,"TellerNo","");								//柜员代码
	AddXmlItemInt(buf, "FuncTionFlag", 1);							//处理标志
	if(errcode!=0)
		AddXmlItemInt(buf, "ResultCode", errcode);
	else
		AddXmlItemStr(buf, "ResultCode", "0000");
	AddXmlItemStr(buf, "Err_Info", errmsg);
	AddXmlItemStr(msghead, "MsgHead", buf);						// 全包含在MsgHead 中	
}
int F930022(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg) {
    int ret = 0;
    T_t_msglist tMsgList;
    T_t_device tDevice;
    memset(&tDevice,0,sizeof tDevice);

    memset(&tMsgList,0,sizeof(tMsgList));


    if(strlen(in_pack->sdate0)==0) {
        *pRetCode=E_DEVPHYID_NULL;
        goto L_RETU;
    }
    AddXmlItemInt(tMsgList.reqdata,XML_KEY_FEETYPE,in_pack->lvol4);
    AddXmlItemInt(tMsgList.reqdata,XML_KEY_STARTNUM,in_pack->lvol5);
    AddXmlItemInt(tMsgList.reqdata,XML_KEY_ENDNUM,in_pack->lvol6);

    if((ret = get_devinfo_by_phyid(in_pack->sdate0,&tDevice))) {
        *pRetCode = ret;
        goto L_RETU;
    }
    tMsgList.deviceid = tDevice.deviceid;
    tMsgList.funcno = 930022;
    tMsgList.msglevel = 3;
    ret=AddMsgLst(&tMsgList);
    if(ret) {
        *pRetCode=ret;
        writelog(LOG_ERR,"AddMsgLst err[%d]",ret);
        goto L_RETU;
    }
    return 0;
L_RETU:
    return  -1;
}
static void GenMsgHead(char *msghead,ST_PACK *rPack)
{
	char buf[1024]="";
	AddXmlItemStr(buf,"AreaNo","");								//地区代码
	AddXmlItemStr(buf,"ChanNo","");								//渠道代码
	AddXmlItemInt(buf, "TerminalNo", rPack->lvol6);					//终端编号
	AddXmlItemStr(buf,"TransNo",rPack->sholder_ac_no);			//交易流水号
	AddXmlItemStr(buf,"TransDate",rPack->sdate0);				//交易日期
	AddXmlItemStr(buf,"TransTime",rPack->stime0);					//交易时间
	AddXmlItemStr(buf,"BankNo","");								//机构代码
	AddXmlItemStr(buf,"TellerNo","");								//柜员代码
	AddXmlItemInt(buf, "FuncTionFlag", 1);							//处理标志
	AddXmlItemStr(msghead, "MsgHead", buf);						// 全包含在MsgHead 中	
	writelog(LOG_DEBUG,"msghead[%s] ",msghead);
}
Example #5
0
int F930018(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg)
{
	int ret = 0;
    T_t_tif_meslist tMesList;
	T_t_pif_device tDevice;

	memset(&tMesList,0,sizeof(tMesList));
	memset(&tDevice,0,sizeof tDevice);

	if(in_pack->lcert_code < 1)
	{
		*pRetCode = E_DEVICE_NOT_EXIST;
	}
	else if((ret = DB_t_pif_device_read_by_device_id(in_pack->lcert_code,&tDevice)))
	{
		*pRetCode = E_DB_DEVICE_N;
	}
	else
	{
		AddXmlItemInt(tMesList.incontent,XML_KEY_TIME, in_pack->lvol4);
		tMesList.devid = tDevice.device_id;
		tMesList.funid = 930018;
		tMesList.level = 1;
		ret=AddMsgLst(&tMesList);
		if(ret)
		{
			*pRetCode=ret;
			writelog(LOG_ERR,"AddMsgLst err[%d]",ret);
			goto L_RETU;
		}
		return 0;
	}
L_RETU:
	return  -1;		
}
static void GenMsgBodyQuery(char *msgbody,ST_PACK *rPack)
{
	char buf[1024]="";
	AddXmlItemStr(buf, "SchoolCode", SCHOOLCODE_AHUT);			//学校代码
	AddXmlItemStr(buf, "IcCard", rPack->sphone);					//校园卡卡号(使用学工号)
	AddXmlItemInt(buf, "SignFlag", 1);								//签约标志
	AddXmlItemStr(buf, "ActNo", rPack->scust_limit2);				// 银行卡号

	AddXmlItemStr(msgbody, "MsgBody", buf);						//全包含在MsgBody 中	
	writelog(LOG_DEBUG,"msgbody[%s] ",msgbody);
}
int F930018(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg)
{
	int ret = 0;
       T_t_msglist tMsgList;
//	T_t_device tDevice;
//	memset(&tDevice,0,sizeof tDevice);

	memset(&tMsgList,0,sizeof(tMsgList));

	tMsgList.deviceid = in_pack->lcert_code;
	if(!tMsgList.deviceid)
	{
		return E_INPUTNULL_DEVICE;
	}

	AddXmlItemInt(tMsgList.reqdata,XML_KEY_FEETYPE, in_pack->lvol4);
	AddXmlItemInt(tMsgList.reqdata,XML_KEY_STARTNUM,in_pack->lvol5);
	AddXmlItemInt(tMsgList.reqdata,XML_KEY_ENDNUM,in_pack->lvol6);

//	if((ret = get_devinfo_by_phyid(in_pack->sdate0,&tDevice)))
//	{
//		*pRetCode = ret;
//		goto L_RETU;
//	}
//	tMsgList.deviceid = tDevice.deviceid;
	tMsgList.funcno = 930018;
	tMsgList.msglevel = 1;
	ret=AddMsgLst(&tMsgList);
	if(ret)
	{
		*pRetCode=ret;
		writelog(LOG_ERR,"AddMsgLst err[%d]",ret);
		goto L_RETU;
	}
	return 0;
L_RETU:
	return  -1;	
}
Example #8
0
int F930103(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg)
{
	int ret = 0;
       T_t_tif_meslist tMesList;

	memset(&tMesList,0,sizeof(tMesList));

	des2src(tMesList.devphy999_id, in_pack->sdate0);
	trim(tMesList.devphy999_id);
	if(strlen(tMesList.devphy999_id)==0)
	{
		*pRetCode=E_DEVPHYID_NULL;
		goto L_RETU;
	}
	AddXmlItemStr(tMesList.incontent,XML_KEY_DEV999_ID,tMesList.devphy999_id);
	AddXmlItemInt(tMesList.incontent,XML_KEY_WORKMODE, in_pack->lvol3);
	AddXmlItemInt(tMesList.incontent,XML_KEY_LOCK1_TIME, in_pack->lvol5);
	AddXmlItemInt(tMesList.incontent,XML_KEY_LOCK2_TIME, in_pack->lvol6);
	AddXmlItemStr(tMesList.incontent,XML_KEY_IS_ALLEYWAY, in_pack->sstatus0);
	AddXmlItemStr(tMesList.incontent,XML_KEY_IS_SAVE, in_pack->sstatus1);
	AddXmlItemStr(tMesList.incontent,XML_KEY_IS_LCD, in_pack->sstatus2);
	AddXmlItemStr(tMesList.incontent,XML_KEY_SYSPWD, in_pack->semp_pwd);
	AddXmlItemInt(tMesList.incontent,XML_KEY_BAUDRATE, 0);
	AddXmlItemInt(tMesList.incontent,XML_KEY_CARDSTR, 100);
	tMesList.funid = iRequest;
	tMesList.level =1;
	ret=AddMsgLst(&tMesList);
	if(ret)
	{
		*pRetCode=ret;
		writelog(LOG_ERR,"AddMsgLst err[%d]",ret);
		goto L_RETU;
	}
	return 0;
L_RETU:
	return  -1;
}
Example #9
0
int F930109(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg)
{
	int ret = 0;
	T_t_tif_meslist tMesList;
	T_t_pif_device tDevice;
	memset(&tDevice,0,sizeof tDevice);

	memset(&tMesList,0,sizeof(tMesList));

	if(strlen(in_pack->sdate0)==0)
	{
		*pRetCode=E_DEVPHYID_NULL;
		goto L_RETU;
	}
	AddXmlItemInt(tMesList.incontent,XML_KEY_OUTNUM,in_pack->lvol5);		//条数
	AddXmlItemStr(tMesList.incontent,XML_KEY_HOLIDAY,in_pack->vsvarstr0);	//节假日
	//FIXME
	//需要查询节假日表下传
	//FIXME
	if((ret = get_devinfo_by_phyid(in_pack->sdate0,&tDevice)))
	{
		*pRetCode = ret;
		goto L_RETU;
	}
	tMesList.devid = tDevice.device_id;
	tMesList.funid = 930109;
	tMesList.level =1;
	tMesList.max_send_cnt = 10;
	ret = DB_t_tif_meslist_del_by_devid_and_funid(tMesList.devid,tMesList.funid);
	if(ret)
	{
		if(DB_NOTFOUND != ret)
		{
			return E_DB_MESLIST_D;
		}
	}
	ret=AddMsgLst(&tMesList);
	if(ret)
	{
		*pRetCode=ret;
		writelog(LOG_ERR,"AddMsgLst err[%d]",ret);
		goto L_RETU;
	}
	return 0;
L_RETU:
	return  -1;
}
Example #10
0
int F930011(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg)
{
	int ret = 0;
       T_t_tif_meslist tMesList;
	T_t_pif_device tDevice;

	memset(&tMesList,0,sizeof(tMesList));
	memset(&tDevice,0,sizeof(tDevice));

	if(strlen(in_pack->sdate0) == 0 )
	{
		*pRetCode = E_DEVPHYID_NULL;
		goto L_RETU;
	}

	AddXmlItemStr(tMesList.incontent, XML_KEY_CONCODEVER, in_pack->sserial2);
	AddXmlItemInt(tMesList.incontent, XML_KEY_CONCODE, 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 = 930011;
	tMesList.level = 2;
	ret=AddMsgLst(&tMesList);
	if(ret)
	{
		*pRetCode=ret;
		writelog(LOG_ERR,"AddMsgLst err[%d]",ret);
		goto L_RETU;
	}
	return 0;
L_RETU:
	return  -1;	
}
Example #11
0
int F930106(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg)
{
	int ret = 0;
       T_t_msglist tMsgList;
	T_t_device tDevice;
	memset(&tDevice,0,sizeof tDevice);

	memset(&tMsgList,0,sizeof(tMsgList));


	if(strlen(in_pack->sdate0)==0)
	{
		*pRetCode=E_DEVPHYID_NULL;
		goto L_RETU;
	}
	AddXmlItemInt(tMsgList.reqdata,XML_KEY_WEEKNO,in_pack->lvol3);		//星期
	if((ret = get_devinfo_by_phyid(in_pack->sdate0,&tDevice)))
	{
		*pRetCode = ret;
		goto L_RETU;
	}
	tMsgList.deviceid = tDevice.deviceid;
	tMsgList.funcno = 930106;
	tMsgList.pfuncno = 930105;
	tMsgList.msglevel = MESLIST_PRIORITY_REALTIME;
	ret=AddMsgLst(&tMsgList);
	if(ret)
	{
		*pRetCode=ret;
		writelog(LOG_ERR,"AddMsgLst err[%d]",ret);
		goto L_RETU;
	}
	return 0;
L_RETU:
	return  -1;
}
Example #12
0
int F930062(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_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_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 = 930062;
	tMesList.level = 2;
	ret=AddMsgLst(&tMesList);
	if(ret)
	{
		*pRetCode=ret;
		writelog(LOG_ERR,"AddMsgLst err[%d]",ret);
		goto L_RETU;
	}
	ret=db_commit();
	if(ret)
	{
		writelog(LOG_ERR,"db_commit ret[%d]",ret);
		*pRetCode=E_DB_COMMIT;
		goto  L_RETU;
	}
	if(iRequest!=tMesList.funid)
		return 0;	
	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,"成功");
			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;	
}
Example #13
0
int F950041(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg)
{
	int ret;
	T_t_pif_device tDevice;
	T_t_cif_shop_pos tShopPos;
	T_t_cif_shop tShop;
	T_t_tif_meslist tMsg;
	T_t_pif_feetype tFeeType;
	int rate = 0;
	int retries = 0;
	int msgid;
	unsigned char buf[32] = "";
	char cardlist[100] = "";
	int rows = 0;
	int i,j;

	memset(&tDevice,0,sizeof tDevice);
	memset(&tFeeType,0,sizeof tFeeType);
	
	ST_CPACK aPack;
	ST_PACK *out_pack = &(aPack.pack);
	memset(&aPack,0,sizeof aPack);

	ResetNormalCPack(&aPack,0,1);
	SetCol(handle,0);
	SetCol(handle,F_VSVARSTR0,F_VSMESS,0);
	
	if(rPack->lcert_code < 1)
	{
		*pRetCode = E_DEVICE_NOT_EXIST;
	}
	else if((ret = DB_t_pif_device_read_by_device_id(rPack->lcert_code,&tDevice)))
	{
		if(DB_NOTFOUND == ret)
			*pRetCode = E_DB_DEVICE_N;
		else
			*pRetCode = E_DB_DEVICE_R;

	}
	else if(tDevice.state_id == DEVISTAT_LOGOUT)
	{
		*pRetCode = E_DEVICE_NOT_EXIST;
	}
	// 如果是 39 的充值机
	else if(strcmp(tDevice.devtype,"0201") == 0 && tDevice.phytype == 1000)
	{
		des2src(rPack->sdate0,tDevice.devphy999_id);
		ret = F930006(handle,iRequest,rPack,pRetCode,szMsg);
		if(ret)	
		{
			goto LRet;
		}
		return 0;
	}
	else if((ret = DB_t_cif_shop_pos_open_select_by_c0_and_device_id(rPack->lcert_code)))
	{
		*pRetCode = E_DB_SHOP_POS_R;
	}
	else
	{
		
		while(1)
		{
			memset(&tShopPos,0,sizeof tShopPos);
			memset(&tShop,0,sizeof tShop);
			if((ret = DB_t_cif_shop_pos_fetch_select_by_c0(&tShopPos)))
			{
				if(ret == DB_NOTFOUND)
				{
					writelog(LOG_DEBUG,"shop doesn't find [%d]!");
					*pRetCode  = 0;
				}
				else
					*pRetCode = E_DB_SHOP_POS_R;
				break;
			}
			writelog(LOG_DEBUG,"find shop [%d]",tShopPos.shop_id);
			if((ret = DB_t_cif_shop_read_by_shop_id(tShopPos.shop_id,&tShop)))
			{
				*pRetCode = ret;
				break;
			}
			if('1' == tShop.is_leaf[0] && '1' == tShop.is_getfee[0]
				&& amtcmp(tShop.ratio,0.00)>0 )
			{
				writelog(LOG_DEBUG,"shop rate [%.02f]",tShop.ratio);
				int newrate = D2I(tShop.ratio * 100);
				if(newrate > rate)
					rate = newrate;
			}
		}
		
	}
	if(*pRetCode)
		return -1;
	
	ret = DB_t_pif_feetype_open_select_by_cur1();
	if(ret)
	{
		if(DB_NOTFOUND == ret)
			*pRetCode = E_DB_FEETYPE_N;
		else
			*pRetCode = E_DB_FEETYPE_R;
		return -1;
	}
	memset(buf,0,sizeof buf);
	while(1)
	{
		memset(&tFeeType,0,sizeof &tFeeType);
		ret = DB_t_pif_feetype_fetch_select_by_cur1(&tFeeType);
		if(ret)
		{
			if(DB_NOTFOUND == ret)
			{
				if(rows > 0)
					break;
				*pRetCode = E_DB_FEETYPE_N;
			}
			else
				*pRetCode = E_DB_FEETYPE_R;
		}
		rows++;
		if(tFeeType.fee_type < 0 || tFeeType.fee_type > 255
			|| tFeeType.is_outfee[0] != '1' )
			continue;
		writelog(LOG_DEBUG,"fee[%s][%d][%c]",tFeeType.fee_name,tFeeType.fee_type
			,tFeeType.is_outfee[0]);
		_SET_BIT(buf,tFeeType.fee_type-1);
		
	}
	//writelog(LOG_DEBUG,"bit length %d",BIT_LENGTH);
	memset(&tMsg,0,sizeof tMsg);
	tMsg.funid = 950041;
	tMsg.level = 1;
	tMsg.devid = tDevice.device_id;
	for(i = 0,j = 0;i < sizeof buf;++i)
	{
		j += sprintf(cardlist+j,"%02x",buf[i]);
	}
	AddXmlItemInt(tMsg.incontent,XML_KEY_FEE,rate);
	AddXmlItemStr(tMsg.incontent,XML_KEY_CARDRIGHTTYPE,cardlist);
	tMsg.max_send_cnt = 5;
	if((ret = AddMsgLst(&tMsg)))
	{
		*pRetCode = ret;
	}
	else
	{
		if(db_commit())
		{
			*pRetCode = E_DB_COMMIT;
			return -1;
		}
		retries = 10;
		msgid = tMsg.mesid;
		for(retries=0;(retries<10)&&(tMsg.ecode!=0);retries++)
		{
			memset(&tMsg,0,sizeof tMsg);
			ret = DB_t_tif_meslist_read_by_mesid(msgid,&tMsg);
			if(ret)
			{
				strcpy(out_pack->vsvarstr0,"读取指令失败");
				*pRetCode=E_DB_MESLIST_R;
				strcpy(szMsg,"读取指令失败");
				return -1;
			}
			// 等待1秒
			sleep(1);
		}
		switch(tMsg.ecode)
		{
			case 0:		//成功
				des2src(out_pack->vsmess,"成功");
				strcpy(szMsg,"成功");
				break;
			case 9999:		//交易未处理
				des2src(out_pack->vsmess,"前置机无应答");
				strcpy(szMsg,"前置机无应答");
				goto LRet;
			default:			//交易已经处理,但结果是失败
				des2src(out_pack->vsmess,tMsg.emsg);				
				goto LRet;
		}	

		PutRow(handle,out_pack,pRetCode,szMsg);
		AnswerData(handle,*pRetCode,szMsg);
		return 0;
		
	}
LRet:
	return -1;
}
Example #14
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;
}
Example #15
0
int F930007(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_pif_device tDevice;

	ST_CPACK aPack;
	ST_PACK *out_pack = &(aPack.pack);

	ResetNormalCPack(&aPack,0,1);
	SetCol(handle,0);
	SetCol(handle,F_VSVARSTR0,0);
	memset(&tMesList,0,sizeof(tMesList));
	memset(&tDevice,0,sizeof(tDevice));

	des2src(tMesList.devphy999_id, in_pack->sdate0);
	trim(tMesList.devphy999_id);
	if(strlen(tMesList.devphy999_id)==0)
	{
		*pRetCode=E_DEVPHYID_NULL;
		goto L_RETU;
	}
	ret=get_devinfo_by_phyid(tMesList.devphy999_id,&tDevice);
	if(ret)
	{
		*pRetCode=ret;
		writelog(LOG_ERR,"get_devinfo_by_phyid err[%d]",ret);
		goto L_RETU;
	}
	AddXmlItemInt(tMesList.incontent, XML_KEY_DEV999_NO, tDevice.dev999_no);		//机号
	AddXmlItemStr(tMesList.incontent, XML_KEY_DEV999_ID, tDevice.dev999_id);		//注册号	
	AddXmlItemInt(tMesList.incontent, XML_KEY_BAUDRATE, tDevice.baudrate);		//波特率
	AddXmlItemStr(tMesList.incontent, XML_KEY_SYSPWD, tDevice.syspwd);			//系统员密码	
	AddXmlItemStr(tMesList.incontent, XML_KEY_ADMPWD,tDevice.admpwd);			//管理员密码
	AddXmlItemInt(tMesList.incontent, XML_KEY_PWDONOFF,tDevice.pwdonoff);		//密码开关	
	AddXmlItemStr(tMesList.incontent, XML_KEY_CARDSTR, "100");					//卡片结构	
	AddXmlItemInt(tMesList.incontent, XML_KEY_CARDUSENUM,tDevice.cardusenum);	//卡的最大使用次数\允许最大消费次数	
	AddXmlItemInt(tMesList.incontent, XML_KEY_MAXDEPOSIT, tDevice.maxdeposit);	//钱包最高存款限额
	AddXmlItemInt(tMesList.incontent, XML_KEY_MINDEPOSIT, tDevice.mindeposit);		//钱包最低剩余款限额	
	AddXmlItemInt(tMesList.incontent, XML_KEY_RATION, tDevice.ration);				//定值收费方式使用的定值额\定值金额
	AddXmlItemStr(tMesList.incontent, XML_KEY_PUSERNO, tDevice.puserno);			//钱包代码\钱包号	
	AddXmlItemInt(tMesList.incontent, XML_KEY_MAXTRADE, tDevice.maxtrade);		//每次交易最高额\大额消费限额	
	AddXmlItemStr(tMesList.incontent, XML_KEY_VCARDSET, tDevice.cardtype);		//终端机适用用户卡类别	
	AddXmlItemStr(tMesList.incontent, XML_KEY_FUNONOFF, tDevice.funonoff);			//收费机增强功能开关	
	AddXmlItemInt(tMesList.incontent, XML_KEY_FEETYPE, tDevice.feetype);			//收费方式

	tMesList.funid = 930007;
	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,"成功");
			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;	
}
Example #16
0
int F930067(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg)
{
	int ret = 0;
	int cnt=0;
	int msgid=0;
	char sysdatetime[21]="";
       T_t_msglist tMsgList;
	T_t_device tDevice;

	ST_CPACK aPack;
	ST_PACK *out_pack = &(aPack.pack);
	ResetNormalCPack(&aPack,0,1);

	memset(&tMsgList,0,sizeof(tMsgList));
	memset(&tDevice,0,sizeof tDevice);
	
	if(strlen(in_pack->sdate0)==0)
	{
		if(in_pack->lcert_code <= 0)
		{
			*pRetCode=E_DEVPHYID_NULL;
			goto L_RETU;
		}
		tMsgList.deviceid = in_pack->lcert_code;
	}
	else
	{
		if((ret = get_devinfo_by_phyid(in_pack->sdate0,&tDevice)))
		{
			*pRetCode = ret;
			goto L_RETU;
		}
		tMsgList.deviceid = tDevice.deviceid;
	}
	
	des2src(sysdatetime,CAccTrans::getInstance()->trans.sysdatetime);
	AddXmlItemInt(tMsgList.reqdata,XML_KEY_FTFLAG,in_pack->lvol3);	

	tMsgList.funcno = 930067;
	tMsgList.msglevel = 2;
	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;
	for(cnt=0;(cnt<10)&&(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:		//成功
			des2src(out_pack->vsvarstr0,"成功");
			break;
		case 9999:		//交易未处理
			des2src(out_pack->vsvarstr0,"前置机无应答");
			break;
		default:			//交易已经处理,但结果是失败
			des2src(out_pack->vsvarstr0,tMsgList.errmsg);				
			break;
	}	
	SetCol(handle,0);
	SetCol(handle,F_VSVARSTR0,0);
	PutRow(handle,out_pack,pRetCode,szMsg);
	return 0;
L_RETU:
	return  -1;	
}
Example #17
0
int F847102(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg)
{
  	int ret = 0;
//	char logicdate[11] = "";
//	char enddate[10 + 1] = "";
	int	card_id = 0;
	char	Operator[33+1] = "";
//	int	Cut_id  = 0;
	int	maindevice_id = 0;
	int	device_id = 0;
	char logicdate[11]="";
	char sysdate[11]="";
	char systime[9]="";
	double	dUniqno = 0;
	T_t_pif_cardlossinfo cardlossinfo;
	T_t_tif_black_sheet black_sheet;
	T_t_tif_tradeserial  tradeserial;
       T_t_tif_meslist tMesList;
	T_t_pif_card	tCard;

	memset(&tradeserial,0,sizeof(tradeserial));
	memset(&cardlossinfo,0,sizeof(cardlossinfo));
	memset(&black_sheet,0,sizeof(black_sheet));
	memset(&tMesList,0,sizeof(tMesList));
	memset(&tCard,0,sizeof(tCard));

	getsysdate(sysdate);
	getsystime(systime);
	ret=GetLogicDate(logicdate);								//业务日期
	if(ret)
	{
		*pRetCode=ret;
		goto L_RETU;
	}
	card_id = rPack->lvol1;													//卡标识
//	Cut_id = rPack->lvol0;													//客户号
	des2src(Operator,rPack->scust_limit);									//操作员号
	maindevice_id = rPack->lvol6;											//上传工作站标识
	device_id = rPack->lvol7;												//采集设备标识

	//	检查客户信息,判断是否可以挂失
	//修改卡标志,置为正常状态
	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)
	{
		DB_t_pif_card_free_lock_by_cur();
		writelog(LOG_ERR,"card_id[%d] db card_id[%d]",card_id,tCard.card_id);
		*pRetCode=E_DB_CARD_R;
		goto L_RETU;
	}
	if('2'==tCard.state_id[CARDSTAT_TYPE_REG])
	{
		DB_t_pif_card_free_lock_by_cur();
		*pRetCode = E_CARDNO_LOGOUT;
		goto L_RETU;
	}
	if('3'==tCard.state_id[CARDSTAT_TYPE_REG])
	{
		DB_t_pif_card_free_lock_by_cur();
		*pRetCode = E_CARDNO_WFAIL;
		goto L_RETU;
	}	
	if(STATE_TRUE==tCard.state_id[CARDSTAT_TYPE_LOST])
	{
		DB_t_pif_card_free_lock_by_cur();
		*pRetCode = E_CARDNO_LOST;
		goto L_RETU;
	}
	tCard.state_id[CARDSTAT_TYPE_LOST]=STATE_TRUE;
	//	修改卡状态为挂失
	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();

	//	插入卡挂失有效期限表
/*
	ret=GetLostCardValiddate(sysdate,enddate);											//获得挂失有效期限
	if (ret)
	{
		*pRetCode = ret;
		goto L_RETU;
	}
	cardlossinfo.card_id = card_id;													//卡号
	des2src(cardlossinfo.begin_date,sysdate);											//起始日期
	des2src(cardlossinfo.end_date,enddate);											//截至日期
	des2src(cardlossinfo.operate_date,sysdate);										//操作日期
	des2src(cardlossinfo.operate_time,systime);										//操作时间
	cardlossinfo.state_id=STATE_VALID;												//有效
	ret = DB_t_pif_cardlossinfo_add(&cardlossinfo);
	if (ret)
	{
		*pRetCode = E_DB_CARDLOSSINFO_I;
		writelog(LOG_ERR,"errcode[%d] ",ret);
		goto L_RETU;
	}
*/
	//如果该卡号被冻结,则挂失时对黑名单不处理
	if(STATE_FALSE==tCard.state_id[CARDSTAT_TYPE_FREEZE])
	{
		//	插入黑名单表
		ret=DB_t_tif_black_sheet_del_by_card_id_and_is_ad(tCard.card_id,DELETE_BLACKLIST);
		if(ret)
		{
			if(ret!=DB_NOTFOUND)
			{
				*pRetCode=ret;
				goto L_RETU;
			}
		}
		ret=InsertToBlkList(tCard.card_id,ADD_BLACKLIST);
		if(ret)
		{
			*pRetCode=ret;
			writelog(LOG_ERR,"InsertToBlkList err[%d]",ret);
			goto L_RETU;
		}
		//广播黑名单
		AddXmlItemInt(tMesList.incontent, XML_KEY_CARDID,card_id);
		AddXmlItemInt(tMesList.incontent, XML_KEY_ADDDELSIGN,ADD_BLACKLIST);	//增删标志

		tMesList.funid = 930005;
		tMesList.pfunid = 930003;
		tMesList.max_send_cnt = 10;
		tMesList.level = MESLIST_PRIORITY_REALTIME;
		tMesList.msgtype = MESLIST_TYPE_ORDER;
		ret=AddMsgLst(&tMesList);
		if(ret)
		{
			*pRetCode=ret;
			writelog(LOG_ERR,"AddMsgLst err[%d]",ret);
			goto L_RETU;
		}
	}
	//	准备数据插入交易流水表
	ret = getNewUniqNo(KEYTYPE_TRADESERIAL,&dUniqno);  					//获得最大流水号
	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 = D2I(dUniqno);										//流水号
	tradeserial.serial_type = TXCODE_CARD_LOSS;								//挂失
	tradeserial.serial_state = SERISTAT_NONEEDDEBT;							//流水状态
	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);

	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;
	}
	return 0;
L_RETU:
	return -1;
}
int F930105(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg)
{
	int ret = 0;
	T_t_device tDevice;
	memset(&tDevice,0,sizeof tDevice);
	
	T_t_msglist tMsgList;
	memset(&tMsgList,0,sizeof(tMsgList));

	if(strlen(in_pack->sdate0)==0)
	{
		*pRetCode=E_DEVPHYID_NULL;
		goto L_RETU;
	}
	if(in_pack->lvol3<1||in_pack->lvol3>8)
	{
		*pRetCode=E_INPUT_DATA_INVAILD;
		goto L_RETU;
	}

	if((ret = get_devinfo_by_phyid(in_pack->sdate0,&tDevice)))
	{
		*pRetCode = ret;
		goto L_RETU;
	}

	tMsgList.deviceid = tDevice.deviceid;
	ret = process930105(tDevice.deviceid,in_pack->lvol3);
	if(ret)
	{
		*pRetCode = ret;
		goto L_RETU;
	}

	AddXmlItemInt(tMsgList.reqdata,XML_KEY_WEEKNO,in_pack->lvol3);			//星期
	AddXmlItemInt(tMsgList.reqdata,XML_KEY_OUTNUM,in_pack->lvol5);			//记录数
	AddXmlItemStr(tMsgList.reqdata,XML_KEY_DOORTIME1,in_pack->saddr);		//时间段1
	AddXmlItemStr(tMsgList.reqdata,XML_KEY_DOORTIME2,in_pack->saddr2);		//时间段2
	AddXmlItemStr(tMsgList.reqdata,XML_KEY_DOORTIME3,in_pack->sall_name);	//时间段3
	AddXmlItemStr(tMsgList.reqdata,XML_KEY_DOORTIME4,in_pack->snote);		//时间段4
	AddXmlItemStr(tMsgList.reqdata,XML_KEY_DOORTIME5,in_pack->snote2);		//时间段5
	AddXmlItemStr(tMsgList.reqdata,XML_KEY_DOORTIME6,in_pack->scert_addr);	//时间段6
	AddXmlItemStr(tMsgList.reqdata,XML_KEY_DOORTIME7,in_pack->sbankname);	//时间段7
	AddXmlItemStr(tMsgList.reqdata,XML_KEY_DOORTIME8,in_pack->sbankname2);	//时间段8
	//FIXME
	//需要查询时间段表下传
	//FIXME
	//tMsgList.funcno = iRequest;
	tMsgList.funcno=930105;
	tMsgList.pfuncno = 930105;
	tMsgList.msglevel = MESLIST_PRIORITY_REALTIME;
	// 重试10次
	tMsgList.maxsendcnt = 10;

	ret=AddMsgLst(&tMsgList);
	if(ret)
	{
		*pRetCode=ret;
		writelog(LOG_ERR,"AddMsgLst err[%d]",ret);
		goto L_RETU;
	}
	return 0;
L_RETU:
	return  -1;
}
Example #19
0
int F930021(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_pif_device	tDevice;
	T_t_pif_device tPDev;

	ST_CPACK aPack;
	ST_PACK *out_pack = &(aPack.pack);

	ResetNormalCPack(&aPack,0,1);
	SetCol(handle,0);
	SetCol(handle,F_VSVARSTR0,0);
	memset(&tMesList,0,sizeof(tMesList));
	memset(&tDevice,0,sizeof(tDevice));
	memset(&tPDev,0,sizeof tPDev);


	if(strlen(in_pack->sdate0)==0)
	{
		*pRetCode=E_DEVPHYID_NULL;
		goto L_RETU;
	}
	ret=get_devinfo_by_phyid(in_pack->sdate0,&tDevice);
	if(ret)
	{
		*pRetCode=ret;
		writelog(LOG_ERR,"get_devinfo_by_phyid err[%d]",ret);
		goto L_RETU;
	}

	if((ret = get_devinfo_by_phyid(tDevice.fdev_id,&tPDev)))
	{
		*pRetCode = ret;
		goto L_RETU;
	}
	AddXmlItemStr(tMesList.incontent,XML_KEY_DEV999_ID, tDevice.dev999_id);
	AddXmlItemInt(tMesList.incontent,XML_KEY_DEV999_NO,  tDevice.dev999_no);
	AddXmlItemStr(tMesList.incontent,XML_KEY_DEVTYPE,tDevice.devtype);
	AddXmlItemStr(tMesList.incontent,XML_KEY_DEVVERSION, tDevice.devversion);
	AddXmlItemStr(tMesList.incontent,XML_KEY_CARDSTR, tDevice.cardstr);
	AddXmlItemStr(tMesList.incontent,XML_KEY_VCARDSET, tDevice.cardtype);
	AddXmlItemInt(tMesList.incontent, XML_KEY_PORTCOUNT, tDevice.portcount);
	AddXmlItemStr(tMesList.incontent, XML_KEY_FDEVPHY_ID, tPDev.dev999_id);
	AddXmlItemInt(tMesList.incontent, XML_KEY_PORTNO,tDevice.portno);
	AddXmlItemInt(tMesList.incontent, XML_KEY_STATE_ID, tDevice.state_id);
	AddXmlItemInt(tMesList.incontent,XML_KEY_JOINMODE,tDevice.joinmode);
	AddXmlItemStr(tMesList.incontent, XML_KEY_COMADD, tDevice.comadd);
	AddXmlItemStr(tMesList.incontent, XML_KEY_PORT,  tDevice.port);
	AddXmlItemInt(tMesList.incontent, XML_KEY_BAUDRATE, tDevice.baudrate);
	AddXmlItemInt(tMesList.incontent, XML_KEY_COMTYPE,tDevice.comtype);
	AddXmlItemStr(tMesList.incontent, XML_KEY_NOTVALIDITY, tDevice.bsheetvdate);
	AddXmlItemStr(tMesList.incontent, XML_KEY_VERNUM,tDevice.bsheetver);
	AddXmlItemInt(tMesList.incontent, XML_KEY_LASTTRASERNO, tDevice.lasttraserno);
	AddXmlItemStr(tMesList.incontent, XML_KEY_LASTTRADATE, tDevice.lasttradate);
	AddXmlItemInt(tMesList.incontent, XML_KEY_LASTSHUTSERNO, tDevice.lastshutserno);
	AddXmlItemStr(tMesList.incontent, XML_KEY_LASTSHUTDATE, tDevice.lastshutdate);
	tMesList.devid = tDevice.device_id;
	tMesList.funid = 930021;
	tMesList.level = 3;
	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,"成功");
			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;	
}
Example #20
0
int F930013(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;

	ST_CPACK aPack;
	ST_PACK *out_pack = &(aPack.pack);

	ResetNormalCPack(&aPack,0,1);
	SetCol(handle,0);
	SetCol(handle,F_VSVARSTR0,0);
	memset(&tMesList,0,sizeof(tMesList));

	des2src(tMesList.devphy999_id, in_pack->sdate0);
	trim(tMesList.devphy999_id);
	if(strlen(tMesList.devphy999_id)==0)
	{
		*pRetCode=E_DEVPHYID_NULL;
		goto L_RETU;
	}

	AddXmlItemStr(tMesList.incontent, XML_KEY_STARTDT, in_pack->sopen_emp);
	AddXmlItemStr(tMesList.incontent, XML_KEY_ENDDT, in_pack->sclose_emp);
	AddXmlItemInt(tMesList.incontent, XML_KEY_RATION, in_pack->lvol4);
	AddXmlItemInt(tMesList.incontent, XML_KEY_CARDUSENUM, in_pack->lvol5);
	AddXmlItemStr(tMesList.incontent, XML_KEY_VCARDSET, in_pack->snote2);

	tMesList.funid = 930013;
	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,"成功");
			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;	
}
Example #21
0
int DoFrozeCard(int cardno)
{
    int ret=0;
    CAccTrans *pAccTrans=CAccTrans::getInstance();
    TRANS& trans=pAccTrans->trans;

    T_t_card tCard;
    memset(&tCard,0,sizeof(tCard));
    ret=DB_t_card_read_lock_by_cur_and_cardno(cardno,&tCard);
    if(ret)
    {
        writelog(LOG_ERR,"cardno[%d]",cardno);
        if(DB_NOTFOUND==ret)
            return ERRINFO(E_NOTEXIST_CARDNO,cardno);
        else
            return E_DB_CARD_R;
    }
    des2src(trans.showcardno,tCard.showcardno);
    if(tCard.status[0]!=STATUS_NORMAL)
    {
        DB_t_card_free_lock_by_cur();
        return ERRINFO(E_CARD_LOGOUT,cardno);
    }
    if('1'==tCard.frozeflag[0])
    {
        DB_t_card_free_lock_by_cur();
        return ERRINFO(E_CARD_FREEZE,cardno);
    }
    tCard.frozeflag[0]='1';
    des2src(tCard.frozedate,trans.sysdate);
    ret=getCardVerNo(tCard.cardverno);
    if(ret)
    {
        DB_t_card_free_lock_by_cur();
        return ret;
    }
    getfmtsysdatetime(tCard.lastsaved);
    ret=DB_t_card_update_lock_by_cur(&tCard);
    if(ret)
    {
        writelog(LOG_ERR,"cardno[%d]",cardno);
        if(DB_NOTFOUND==ret)
            return E_NOTEXIST_CARDNO;
        else
            return E_DB_CARD_U;
    }
    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 E_NOTEXIST_CUSTOMER;
            else
                return E_DB_CUSTOMER_R;
        }
        trans.custid=tCard.custid;
        des2src(trans.custname,customer.custname);
    }
    //修改以前的解冻记录为删除状态
    UpdCardVerStatus(cardno,CARDVERTYPE_CARDUNFROZE);
    //更新系统黑名单最大版本号
    ret=SetSysParaVal(SYSPARA_MAXBLACKCARDVERNO,tCard.cardverno);
    if(ret)
    {
        return ret;
    }
    T_t_cardver cardver;
    memset(&cardver,0,sizeof(cardver));
    cardver.cardno=tCard.cardno;
    des2src(cardver.accdate,pAccTrans->trans.sysdate);
    cardver.termid=trans.termid;
    cardver.termseqno=trans.termseqno;
    cardver.cardno=tCard.cardno;
    des2src(cardver.cardphyid,tCard.cardphyid);
    des2src(cardver.stuempno,customer.stuempno);
    cardver.cardvertype=CARDVERTYPE_CARDFROZE;
    cardver.adddelflag[0]=ADDDELFLAG_ADD;
    cardver.status[0]=STATUS_NORMAL;
    des2src(cardver.cardverno,tCard.cardverno);
    ret=DB_t_cardver_add(&cardver);
    if(ret)
    {
        if(DB_REPEAT==ret)
            return E_DB_CARDVER_E;
        else
            return E_DB_CARDVER_I;
    }
    T_t_msglist tMsgList;
    memset(&tMsgList,0,sizeof(tMsgList));
    AddXmlItemInt(tMsgList.reqdata, XML_KEY_CARDID,tCard.cardno);
    AddXmlItemStr(tMsgList.reqdata, XML_KEY_VERNUM,tCard.cardverno);
    AddXmlItemInt(tMsgList.reqdata, XML_KEY_ADDDELSIGN,0);	//增删标志

    tMsgList.funcno = 930005;
    tMsgList.pfuncno = 846307;
    tMsgList.msglevel = MESLIST_PRIORITY_REALTIME;
    tMsgList.msgtype = MESLIST_TYPE_ORDER;
    ret=AddMsgLst(&tMsgList);
    if(ret)
    {
        writelog(LOG_ERR,"AddMsgLst err[%d]",ret);
        return ret;
    }
    des2src(trans.summary,cardver.cardverno);
    return 0;
}
int F930061(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;
	ST_CPACK aPack;
	ST_PACK *out_pack = &(aPack.pack);

	ResetNormalCPack(&aPack,0,1);
	SetCol(handle,0);
	SetCol(handle,F_VSVARSTR0,0);
	memset(&tMsgList,0,sizeof(tMsgList));
	if(strlen(in_pack->sdate0)==0)
	{
		return E_DEVPHYID_NULL;
	}
	ret=GetDeviceidByDevphyid(in_pack->sdate0,&(tMsgList.deviceid));
	if(ret)
	{
		return ret;
	}
	AddXmlItemInt(tMsgList.reqdata, XML_KEY_MAXTRADE, in_pack->lvol4);
	tMsgList.funcno = 930061;
	tMsgList.msglevel = 2;
	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<10)&&(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:		//成功
			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;	
}
Example #23
0
static int do_froze_onecard(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg)
{
	int  ret = 0;
	int	card_id = 0;
	char logicdate[11]="";
	char sysdate[11]="";
	char systime[9]="";
	char	oper[33+1] = "";
	int	cut_id  = 0;
	int	maindevice_id = 0;
	int	device_id = 0;
	double dSerial_no = 0;
	char sCardState[5] = "";
	T_t_tif_black_sheet black_sheet;
	T_t_tif_tradeserial  tradeserial;
    T_t_tif_meslist tMesList;

	memset(&black_sheet,0,sizeof(black_sheet));
	memset(&tradeserial,0,sizeof(tradeserial));
	memset(&tMesList,0,sizeof(tMesList));

	getsysdate(sysdate);
	getsystime(systime);
	ret=GetLogicDate(logicdate);								//业务日期
	if(ret)
	{
		return ret;
	}
	//	准备输入信息
	card_id = rPack->lvol1;												//卡标识
	cut_id = rPack->lvol0;												//客户号
	des2src(oper,rPack->scust_limit);									//操作员号
	maindevice_id = rPack->lvol6;											//上传工作站标识
	device_id = rPack->lvol7;												//采集设备标识

	//	检查客户信息,判断是否可以冻结
	ret = GetCardState(card_id,sCardState);
	if (ret)
	{
		writelog(LOG_ERR,"card_id[%d]",sCardState);
		return ret;
	}
	if('2'==sCardState[CARDSTAT_TYPE_REG])
	{
		ret = E_CARDNO_LOGOUT;
		return ret;
	}
	if(STATE_TRUE==sCardState[CARDSTAT_TYPE_FREEZE])
	{
		ret = E_CARDNO_FREEZE;
		return ret;
	}
	//	修改卡状态为冻结
	ret = UpdateCardState(card_id,CARDSTAT_TYPE_FREEZE,STATE_TRUE);
	if (ret)
	{
		writelog(LOG_ERR,"SQLCODE=[%d]",ret);
		return ret;
	}

	ret=InsertToBlkList(card_id,ADD_BLACKLIST);
	if (ret)
	{
		writelog(LOG_ERR,"InsertToBlkList err[%d]",ret);
		return ret;
	}
	
	//广播黑名单
	AddXmlItemInt(tMesList.incontent, XML_KEY_CARDID,card_id);
	AddXmlItemInt(tMesList.incontent, XML_KEY_ADDDELSIGN,ADD_BLACKLIST);	//增删标志

	tMesList.funid = 930005;
	tMesList.level = 1;
	ret=AddMsgLst(&tMesList);
	if(ret)
	{
		writelog(LOG_ERR,"AddMsgLst err[%d]",ret);
		return ret;
	}
	//	准备数据插入交易流水表
	ret = getNewUniqNo(KEYTYPE_TRADESERIAL,&dSerial_no);  					//获得最大流水号
	if(ret)
	{
		writelog(LOG_ERR,"ERRCODE = [%d]",ret);
		return ret;
	}
	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 = D2I(dSerial_no);									//流水号
	tradeserial.serial_type = TXCODE_FREEZE_CARD;								//挂失
	tradeserial.serial_state = SERISTAT_NONEEDDEBT;							//流水状态
	tradeserial.maindevice_id = maindevice_id;									//上传工作站标识
	tradeserial.device_id = device_id;											//采集设备标识
	tradeserial.card_id = card_id;												//交易卡号
	tradeserial.customer_id=cut_id;											//客户号
	des2src(tradeserial.oper_code,oper);
	//	插入交易流水表
	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;
	}
	return 0;
}
Example #24
0
int F930005(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg)
{
	int ret = 0;
	int cnt=0;
	int mesid=0;
	char sCardState[5]="";
       T_t_tif_meslist tMesList;
	ST_CPACK aPack;
	ST_PACK *out_pack = &(aPack.pack);

	ResetNormalCPack(&aPack,0,1);
	SetCol(handle,0);
	SetCol(handle,F_VSVARSTR0,0);

	memset(&tMesList,0,sizeof(tMesList));

//	des2src(tMesList.devphy999_id, in_pack->sdate0);

	ret=GetCardState(in_pack->lvol0,sCardState);
	if (ret)
	{
		*pRetCode = ret;
		goto L_RETU;
	}
	if('2'==sCardState[CARDSTAT_TYPE_REG])
	{
		*pRetCode = E_CARDNO_LOGOUT;
		goto L_RETU;
	}
	AddXmlItemInt(tMesList.incontent, XML_KEY_CARDID,in_pack->lvol0);
	AddXmlItemStr(tMesList.incontent, XML_KEY_VERNUM, in_pack->sserial0);
	AddXmlItemInt(tMesList.incontent, XML_KEY_ADDDELSIGN,in_pack->lvol4);	//增删标志

	tMesList.funid = 930005;
	tMesList.level = 0;
	ret=AddMsgLst(&tMesList);
	if(ret)
	{
		*pRetCode=ret;
		writelog(LOG_ERR,"AddMsgLst err[%d]",ret);
		goto L_RETU;
	}
	if(iRequest!=930005)
		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,"成功");
			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;
}
Example #25
0
//圈存机写卡失败冲正(实际并不冲正,只是改写卡状态)
int Pos_WriteErrCard(INNER_TRANS_REQUEST * pNode)
{

	int ret = 0;
	int card_id = 0;
	char logicdate[11]="";
	int serial_no=0;
	T_t_pif_card  card;
	T_t_tif_tradeserial tradeserial;

	INNER_TRANS_REQUEST from_pos;

	memset(&tradeserial,0,sizeof(tradeserial));
	memset(&from_pos,0,sizeof(from_pos));
	memset(&card,0,sizeof(card));

	memcpy(&from_pos,pNode,sizeof(from_pos));
	ret=GetLogicDate(logicdate);								//业务日期
	if(ret)
	{
		db_chk_err(__FILE__,__LINE__,&sqlca);
		writelog(LOG_ALERT,"GetLogicDate err,sqlcode[%d]",ret);
		return E_TRANS_UNKNOW_ERROR;
	}

	serial_no=from_pos.RecvNo;
	ret=DB_t_tif_tradeserial_read_by_serial_no(serial_no,&tradeserial);
	if(ret)
	{
		db_chk_err(__FILE__,__LINE__,&sqlca);
		writelog(LOG_ALERT,"DB_t_tif_tradeserial_read_by_serial_no err,sqlcode[%d]",ret);
		return E_TRANS_UNKNOW_ERROR;
	}
	//修改原卡状态为发卡写卡失败状态
	card_id = tradeserial.card_id;

	ret=DB_t_pif_card_read_lock_by_cur_and_card_id(card_id, &card);
	if(ret)
	{
		db_chk_err(__FILE__,__LINE__,&sqlca);
		writelog(LOG_ALERT,"DB_t_pif_card_read_lock_by_cur_and_card_id err,sqlcode[%d]",ret);
		return E_TRANS_UNKNOW_ERROR;
	}

	card.state_id[CARDSTAT_TYPE_WFAIL]=STATE_TRUE;
	memset(card.comments,0,sizeof(card.comments));
	AddXmlItemStr(card.comments, XML_KEY_OPERATEDATE,logicdate);
	AddXmlItemInt(card.comments,XML_KEY_SERIALNO,serial_no);
	AddXmlItemInt(card.comments,XML_KEY_TRADECODE,TRADE_INNER_TRANS);

	ret=DB_t_pif_card_update_lock_by_cur(&card);
	if(ret)
	{
		db_chk_err(__FILE__,__LINE__,&sqlca);
		writelog(LOG_ALERT,"DB_t_pif_card_update_lock_by_cur err,sqlcode[%d]",ret);
		return E_TRANS_UNKNOW_ERROR;
	}
	DB_t_pif_card_free_lock_by_cur();

	writelog(LOG_INFO,"update card status succeed!");

	return 0;

}
Example #26
0
int F930006(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg)
{
	int ret = 0;
	double dMaxFeeRatio=0;
	int iMaxFeeRatio=0;
	int iRow=0;
    	T_t_tif_meslist tMesList;
	T_t_pif_feetype tFeeType;
	T_t_pif_device tDevice;

	memset(&tMesList,0,sizeof(tMesList));
	memset(&tFeeType,0,sizeof(tFeeType));
	memset(&tDevice,0,sizeof tDevice);
//	memset(&tCuttypefee,0,sizeof(tCuttypefee));

	if(strlen( in_pack->sdate0)==0)
	{
		*pRetCode=E_DEVPHYID_NULL;
		goto L_RETU;
	}
	if((ret = get_devinfo_by_phyid( in_pack->sdate0,&tDevice)))
	{
		*pRetCode = ret;
		goto L_RETU;
	}
	tMesList.devid = tDevice.device_id;
	tMesList.funid = 930006;
	tMesList.level = 1;
	///////////////////////////////////////////////////
	// 修改为读取

	ret=GetMaxFeeRatioFromShop(&dMaxFeeRatio);
	if(ret)
	{
		*pRetCode=ret;
		goto L_RETU;
	}
	iMaxFeeRatio=dMaxFeeRatio*100;
	ret=DB_t_pif_feetype_open_select_by_cur1();
	if(ret)
	{
		*pRetCode=E_DB_FEETYPE_R;
		goto L_RETU;
	}
	while(1)
	{
		memset(&tFeeType,0,sizeof(tFeeType));
		memset(&tMesList.incontent,0,sizeof(tMesList.incontent));
		ret=DB_t_pif_feetype_fetch_select_by_cur1(&tFeeType);
		if(ret)
		{
			if(DB_NOTFOUND==ret)
			{
				if(iRow)
					break;
				else
				{
					*pRetCode= E_DB_FEETYPE_N;
					goto L_RETU;
				}
			}
			else
			{
				*pRetCode= E_DB_FEETYPE_R;
				goto L_RETU;
			}
		}
		iRow++;
		AddXmlItemInt(tMesList.incontent, XML_KEY_CARDTYPE,tFeeType.fee_type);	//卡类型
		if(strncmp(tFeeType.is_outfee,TYPE_YES,1)==0)
			AddXmlItemInt(tMesList.incontent, XML_KEY_FEE, iMaxFeeRatio);
		else
			AddXmlItemInt(tMesList.incontent, XML_KEY_FEE, 0);

		ret=AddMsgLst(&tMesList);
		if(ret)
		{
			*pRetCode=ret;
			writelog(LOG_ERR,"AddMsgLst err[%d]",ret);
			goto L_RETU;
		}
	}

///////////////////////////////////////////////////////////////////
/*
	//AddXmlItemInt(tMesList.incontent, XML_KEY_CARDTYPE,in_pack->lvol5);	//卡类型
	//AddXmlItemInt(tMesList.incontent, XML_KEY_FEE, in_pack->lvol6);		//费率
	ret=AddMsgLst(&tMesList);
	if(ret)
	{
		*pRetCode=ret;
		writelog(LOG_ERR,"AddMsgLst err[%d]",ret);
		goto L_RETU;
	}
*/
	return 0;
L_RETU:
	return  -1;
}
Example #27
0
int F950041(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg)
{
	int ret;
	T_t_pif_device tDevice;
	T_t_cif_shop_pos tShopPos;
	T_t_cif_shop tShop;
	T_t_tif_meslist tMsg;
	int rate = 0;
	int retries = 0;
	int msgid;

	memset(&tDevice,0,sizeof tDevice);
	
	ST_CPACK aPack;
	ST_PACK *out_pack = &(aPack.pack);

	ResetNormalCPack(&aPack,0,1);
	SetCol(handle,0);
	SetCol(handle,F_VSVARSTR0,0);
	
	if(rPack->lcert_code < 1)
	{
		*pRetCode = E_DEVICE_NOT_EXIST;
	}
	else if((ret = DB_t_pif_device_read_by_device_id(rPack->lcert_code,&tDevice)))
	{
		*pRetCode = ret;

	}
	else if(tDevice.state_id == DEVISTAT_LOGOUT)
	{
		*pRetCode = E_DEVICE_NOT_EXIST;
	}
	else if((ret = DB_t_cif_shop_pos_open_select_by_c0_and_device_id(rPack->lcert_code)))
	{
		*pRetCode = ret;
	}
	else
	{
		while(1)
		{
			memset(&tShopPos,0,sizeof tShopPos);
			memset(&tShop,0,sizeof tShop);
			if((ret = DB_t_cif_shop_pos_fetch_select_by_c0(&tShopPos)))
			{
				*pRetCode = ret;
				if(ret == DB_NOTFOUND)
					*pRetCode  = 0;
				break;
			}
			if((ret = DB_t_cif_shop_read_by_shop_id(tShopPos.shop_id,&tShop)))
			{
				*pRetCode = ret;
				break;
			}
			if('1' == tShop.is_leaf[0] && '1' == tShop.is_getfee[0]
				&& amtcmp(tShop.ratio,0.00)>0 )
			{
				int newrate = (int)tShop.ratio * 100;
				if(newrate > rate)
					rate = newrate;
			}
		}
		
	}
	if(*pRetCode)
		return -1;
	memset(&tMsg,0,sizeof tMsg);
	tMsg.funid = 950041;
	//des2src(tMsg.devphy999_id,tDevice.devphy999_id);
	tMsg.devid = tDevice.device_id;
	AddXmlItemInt(tMsg.incontent,XML_KEY_FEE,rate);
	tMsg.max_send_cnt = 5;
	if((ret = AddMsgLst(&tMsg)))
	{
		*pRetCode = ret;
	}
	else
	{
		if(db_commit())
		{
			*pRetCode = E_DB_COMMIT;
			return -1;
		}
		retries = 3;
		msgid = tMsg.mesid;
		while(retries-- > 0)
		{
			memset(&tMsg,0,sizeof tMsg);
			ret = DB_t_tif_meslist_read_by_mesid(msgid,&tMsg);
			des2src(out_pack->vsvarstr0,tMsg.emsg);
			if(!ret && !tMsg.ecode)
			{
				break;
			}
			// 等待1秒
			sleep(1);
		}
		PutRow(handle,out_pack,pRetCode,szMsg);
		AnswerData(handle,*pRetCode,szMsg);
		return 0;
		
	}
	return -1;
}
Example #28
0
int DoUnlossCard(int cardno)
{
    int ret=0;
    T_t_card tCard;
    CAccTrans *pAccTrans=CAccTrans::getInstance();
    TRANS& trans=pAccTrans->trans;
    trans.transcode=TC_CARDUNLOSS;

    memset(&tCard,0,sizeof(tCard));
    ret=DB_t_card_read_lock_by_cur_and_cardno(cardno,&tCard);
    if (ret)
    {
        writelog(LOG_ERR,"cardno[%d]",cardno);
        if (DB_NOTFOUND==ret)
            return ERRINFO(E_NOTEXIST_CARDNO,cardno);
        else
            return E_DB_CARD_R;
    }
	des2src(trans.showcardno,tCard.showcardno);
	if(tCard.status[0]!=STATUS_NORMAL)
	{
		DB_t_card_free_lock_by_cur();
		return ERRINFO(E_CARD_LOGOUT,trans.cardno);
	}	
//	if('1'!=tCard.lossflag[0])
//	{
//		DB_t_card_free_lock_by_cur();
//		return ERRINFO(E_CARDNO_NOLOST,trans.cardno);
//	}	
	if('1'==tCard.frozeflag[0])
	{
		DB_t_card_free_lock_by_cur();
		ERRTIP("请先解冻后再解挂");
		return ERRINFO(E_CARD_FREEZE,trans.cardno);
	}
	if('1'==tCard.badflag[0])
	{
		DB_t_card_free_lock_by_cur();
		return ERRINFO(E_CARD_BADRECORD,trans.cardno);
	}	
	//判断是否存在过渡临时卡
	if(CARDTYPE_TEMP!=tCard.cardtype)
	{
		ret=IsExistNormalTmpCardByCustid(tCard.custid);
		if(ret)
		{
			DB_t_card_free_lock_by_cur();
			if(DB_EXIST==ret)
			{
				//锁定该卡,该卡只能销户
				ERRTIP("该客户存在卡状态正常的过渡临时卡,请先退掉过卡状态正常的渡临时卡再解挂");
				return E_EXIST_NORMALCARD;
			}
			else
				return ret;
		}
	}
	else
	{
		//检查是否存在其他正常的卡
		ret=IsExistOtherNormalCardByCustid(tCard.custid,tCard.cardno);
		if(ret)
		{
			if(DB_EXIST==ret)
			{
				//锁定该卡,该卡只能销户
				TIPINFO("该客户存在卡状态正常的其他卡,该卡解挂后将不能再使用,请解挂后注销该卡!");
				tCard.lockflag[0]='1';		
				des2src(tCard.lockdate,trans.accdate);
			}
			else
			{	
				DB_t_card_free_lock_by_cur();
				return ret;
			}
		}
	}
	tCard.lossflag[0]='0';
    tCard.lossdate[0]=0;
    ret=getCardVerNo(tCard.cardverno);
    if (ret)
    {		
		DB_t_card_free_lock_by_cur();
        return ret;
    }
    des2src(tCard.lastsaved,trans.sysdatetime);
    ret=DB_t_card_update_lock_by_cur(&tCard);
    if (ret)
    {
        writelog(LOG_ERR,"cardno[%d]",tCard.cardno);
        if (DB_NOTFOUND==ret)
            return E_NOTEXIST_CARDNO;
        else
            return E_DB_CARD_U;
    }
	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 E_NOTEXIST_CUSTOMER;
            else
                return E_DB_CUSTOMER_R;
        }
        trans.custid=tCard.custid;
        des2src(trans.custname,customer.custname);
        des2src(trans.stuempno,customer.stuempno);
    }
    UpdCardVerStatus(cardno,CARDVERTYPE_CARDLOSS);
	if('1'==tCard.lockflag[0])
	{
		//不下发名单
		strcpy(trans.summary,"000101010101");
		return 0;
	}
	//更新系统黑名单最大版本号
	ret=SetSysParaVal(SYSPARA_MAXBLACKCARDVERNO,tCard.cardverno);
	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.cardno=tCard.cardno;
    des2src(cardver.cardphyid,tCard.cardphyid);
	des2src(cardver.stuempno,customer.stuempno);	
    cardver.cardvertype=CARDVERTYPE_CARDUNLOSS;
    cardver.adddelflag=ADDDELFLAG_DEL;
    cardver.status[0]=STATUS_NORMAL;
    des2src(cardver.cardverno,tCard.cardverno);
    ret=DB_t_cardver_add(&cardver);
    if (ret)
    {
        if (DB_REPEAT==ret)
            return E_DB_CARDVER_E;
        else
            return E_DB_CARDVER_I;
    }
    des2src(trans.summary,cardver.cardverno);
	char broadcastblkflag[20]={0};
	ret=GetSysParaVal(SYSPARA_BROADCASTBLKLIST,broadcastblkflag);
	if(ret)
	{
		if(DB_NOTFOUND==ret)
			return 0;
		else
			return E_DB_SYSKEY_R;
	}
	if(broadcastblkflag[0]!='1')
		return 0;
	T_t_msglist tMsgList;
	memset(&tMsgList,0,sizeof(tMsgList));
	AddXmlItemInt(tMsgList.reqdata, XML_KEY_CARDID,tCard.cardno);
	AddXmlItemStr(tMsgList.reqdata, XML_KEY_VERNUM,tCard.cardverno);
	AddXmlItemInt(tMsgList.reqdata, XML_KEY_ADDDELSIGN,1);	//增删标志

	tMsgList.funcno = 930005;
	tMsgList.pfuncno = 846307;
	tMsgList.msglevel = MESLIST_PRIORITY_REALTIME;
	tMsgList.msgtype = MESLIST_TYPE_ORDER;
	ret=AddMsgLst(&tMsgList);
	if(ret)
	{
		writelog(LOG_ERR,"AddMsgLst err[%d]",ret);
		return ret;
	}
    return 0;
}
Example #29
0
int F930006(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg)
{
	int ret = 0;
	double dMaxFeeRatio=0;
//	int iMaxFeeRatio=0;
	int iRow=0;
       T_t_tif_meslist tMesList;
//	T_t_cif_cuttypefee tCuttypefee;

	memset(&tMesList,0,sizeof(tMesList));
//	memset(&tCuttypefee,0,sizeof(tCuttypefee));

	des2src(tMesList.devphy999_id, in_pack->sdate0);
	trim(tMesList.devphy999_id);
	if(strlen(tMesList.devphy999_id)==0)
	{
		*pRetCode=E_DEVPHYID_NULL;
		goto L_RETU;
	}
	tMesList.funid = iRequest;
	tMesList.level = 1;
/*
	ret=GetMaxFeeRatioFromShop(&dMaxFeeRatio);
	if(ret)
	{
		*pRetCode=ret;
		goto L_RETU;
	}
	iMaxFeeRatio=dMaxFeeRatio*100;
	ret=DB_t_cif_cuttypefee_open_select_by_c0();
	if(ret)
	{
		*pRetCode=E_DB_CUTTYPEFEE_R;
		goto L_RETU;
	}
	while(1)
	{
		memset(&tCuttypefee,0,sizeof(tCuttypefee));
		memset(&tMesList.incontent,0,sizeof(tMesList.incontent));
		ret=DB_t_cif_cuttypefee_fetch_select_by_c0(&tCuttypefee);
		if(ret)
		{
			if(DB_NOTFOUND==ret)
			{
				if(iRow)
					break;
				else
				{
					*pRetCode= E_DB_CUTTYPEFEE_N;
					goto L_RETU;
				}
			}
			else
			{
				*pRetCode= E_DB_CUTTYPEFEE_R;
				goto L_RETU;
			}
		}
		iRow++;
		AddXmlItemInt(tMesList.incontent, XML_KEY_CARDTYPE,tCuttypefee.cut_type);	//卡类型
		if(strncmp(tCuttypefee.is_outfee,TYPE_YES,1)==0)
			AddXmlItemInt(tMesList.incontent, XML_KEY_FEE, iMaxFeeRatio);
		else
			AddXmlItemInt(tMesList.incontent, XML_KEY_FEE, 0);

		ret=AddMsgLst(&tMesList);
		if(ret)
		{
			*pRetCode=ret;
			writelog(LOG_ERR,"AddMsgLst err[%d]",ret);
			goto L_RETU;
		}
	}
*/
	AddXmlItemInt(tMesList.incontent, XML_KEY_CARDTYPE,in_pack->lvol5);	//卡类型
	AddXmlItemInt(tMesList.incontent, XML_KEY_FEE, in_pack->lvol6);		//费率
	ret=AddMsgLst(&tMesList);
	if(ret)
	{
		*pRetCode=ret;
		writelog(LOG_ERR,"AddMsgLst err[%d]",ret);
		goto L_RETU;
	}
	return 0;
L_RETU:
	return  -1;
}
Example #30
0
int F847108(TRUSERID *handle,int iRequest,ST_PACK *in_pack,int *pRetCode,char *szMsg)
{
	int ret = 0;
	int card_id = 0;
	char logicdate[11]="";
	T_t_pif_card  card;

	memset(&card,0,sizeof(card));

	ret=GetLogicDate(logicdate);								//业务日期
	if(ret)
	{
		*pRetCode=ret;
		goto L_RETU;
	}
	//修改原卡状态为发卡写卡失败状态
	card_id = in_pack->lvol0;

	if(in_pack->lvol0<1)
	{
		writelog(LOG_ERR,"in_pack->lserial1[%d]",in_pack->lvol0);
		*pRetCode=E_INPUT_CARDNO;
		goto L_RETU;
	}
	if(in_pack->lserial1<1)
	{
		writelog(LOG_ERR,"in_pack->lserial1[%d]",in_pack->lserial1);
		*pRetCode= E_INPUT_SERIALNO;
		goto L_RETU;
	}
	ret=DB_t_pif_card_read_lock_by_cur_and_card_id(card_id, &card);
	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;
	}
	card.state_id[CARDSTAT_TYPE_WFAIL]=STATE_TRUE;
	memset(card.comments,0,sizeof(card.comments));
	AddXmlItemStr(card.comments, XML_KEY_OPERATEDATE,logicdate);
	AddXmlItemInt(card.comments,XML_KEY_SERIALNO,in_pack->lserial1);
	AddXmlItemInt(card.comments,XML_KEY_TRADECODE,in_pack->lvol2);

	ret=DB_t_pif_card_update_lock_by_cur(&card);
	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();
	return 0;
L_RETU:
	return -1;
}