예제 #1
0
int F950006(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg)
{
	int ret=0;
	ST_CPACK aPack;
	ST_PACK* out_pack = &(aPack.pack);

	char buf[256] = "";

	char static_key[17]="4343232323231111";
	if(0!=strncmp(static_key,rPack->scust_limit,sizeof(static_key)))
	{
	int sysid = rPack->lcert_code;
	ret = chk_dyn_key(sysid,rPack->scust_limit);
	if(ret)
	{
			writelog(LOG_ERR,"动态密钥错误");
		*pRetCode = ret;
		goto L_RETU;
		}
	}
	ret = GetSysParaVal(rPack->lvol0,buf);
	writelog(LOG_DEBUG,"请求参数parameter[%d]",rPack->lvol0);
	if(ret)
	{
		writelog(LOG_ERR,"获取参数失败[%d]",rPack->lvol0);
		*pRetCode = ret;
		goto L_RETU;
	}
	ResetNormalCPack(&aPack,0,1);
	SetCol(handle,0);
	SetCol(handle,F_SCARD0,0);
	des2src(out_pack->scard0,buf);
	PutRow(handle,out_pack,pRetCode,szMsg);
	return 0;
L_RETU:
	return -1;
}
예제 #2
0
int F950032(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg)
{
//	设备物理ID	char(20)	sphon3
//	机号			int lvol0
//	POS机日期	char(8) sdate0
//	POS机时间	char(6) stime0
//	子系统ID		int lcert_code
//	动态密钥	char(20)	scust_limit2
//			
//	参数	类型	CPACK字段
//	商户号		int lvol0
//	系统日期	char(8) sdate0
//	系统时间	char(6) stime0
//	POS机工作开始时间	char(6) stime1
//	POS机工作结束时间	char(6) stime2
//	设备类型	char(4) semp
//	设备工作密钥	char(16)	scert_addr
	int ret=0;
	ST_CPACK aPack;
	ST_PACK* out_pack = &(aPack.pack);
	ResetNormalCPack(&aPack,0,1);
	SetCol(handle,0);
	SetCol(handle,F_LVOL0,F_SDATE0,F_STIME0,F_STIME1,F_STIME2,F_SEMP,F_SCERT_ADDR,0);
	char devphyid[31]="";
	char sysdate[9]="";
	char systime[7]="";
	ret=db_getsysdatetime(sysdate,systime);
	if(ret)
	{
		writelog(LOG_ERR,"db_getsysdatetime err=%d",ret);
		return ERRIF_DATABASE_DIS;
	}
	int sysid = rPack->lcert_code;
	int deviceid = rPack->lwithdraw_flag;
	int db_deviceid=0;
	des2src(devphyid,rPack->sphone3);
	writelog(LOG_INFO,"devphyid %s login start",devphyid);	
	ret = ChkDynKey(sysid,rPack->scust_limit2);
	if(ret)
	{
		writelog(LOG_ERR,"chk_dyn_key sysid[%d] err=%d",sysid,ret);
		return ret;
	}	
	ret=GetDeviceidByDevphyid(devphyid,&db_deviceid);
	if(ret)
	{
		return ret;
	}
	if(deviceid!=db_deviceid)
	{
		return ERRIF_POS_TERMID;
	}
	char devstatus[2]="";
	devstatus[0]=DEVRUNSTATUS_ONLINE;
	ret=UpdDevRunstatusByDeviceid(deviceid,devstatus);
	if(ret)
		return ret;
	int shopid=0;
	ret=GetShopidByDeviceid(deviceid,sysdate,systime,&shopid);
	if(ret)
	{
		return ret;
	}
	ret=GetDevtypecodeByDeviceid(deviceid,out_pack->semp);
	if(ret)
		return ret;
	out_pack->lvol0=shopid;
	strcpy(out_pack->sdate0,sysdate+2);
	strcpy(out_pack->stime0,systime);
	
	ret=GetSysParaVal(GLOBLE_SYSPARA_STATIC_KEY,out_pack->scert_addr);
	if(ret)
	{
		writelog(LOG_ERR,"get static key err=%d",ret);
		return ERRIF_DATABASE_QRY;
	}
	//签到时查询流水号控制表,如果没有该设备则添加一条
	T_t_seqnoctl	tSeqnoctl;		
	memset(&tSeqnoctl,0,sizeof(tSeqnoctl));
	ret=DB_t_seqnoctl_read_by_termid(deviceid,&tSeqnoctl);
	if(ret)
	{
		if(DB_NOTFOUND==ret)
		{
			tSeqnoctl.termid=deviceid;
			tSeqnoctl.termseqno=0;
			tSeqnoctl.accdate=atoi(sysdate);
			ret=DB_t_seqnoctl_add(&tSeqnoctl);
			if(ret)
			{
				if(DB_REPEAT==ret)
					return E_DB_SEQNOCTL_E;
				else
					return E_DB_SEQNOCTL_I;
			}
			return 0;
		}
		else
			return E_DB_SEQNOCTL_R;
	}	
	PutRow(handle,out_pack,pRetCode,szMsg);
	writelog(LOG_INFO,"devphyid %s login success",devphyid);	
	return 0;
}
예제 #3
0
int F846332(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg)
{
	int ret=0;
	CAccTrans *pAccTrans=CAccTrans::getInstance();
	des2src(pAccTrans->trans.opercode,rPack->semp);
	pAccTrans->trans.transcode=TC_EACCCLOSE;
	ret=pAccTrans->InitTrans();
	if(ret)
		return ret;			
	TRANS& trans=pAccTrans->trans;

	ST_CPACK aPack;
	ST_PACK *outPack = &(aPack.pack);
	ResetNormalCPack(&aPack,0,1);
		
	SetCol(handle,0);

	des2src(trans.eaccno,rPack->sbank_acc);
	if(!strlen(trans.eaccno))
		return E_INPUTNULL_ACCNO;
	//去帐户信息
	T_t_netacc eaccount;	
	memset(&eaccount,0,sizeof(eaccount));
	ret=DB_t_netacc_read_by_accno(trans.eaccno,&eaccount);
	if(ret)
	{
		writelog(LOG_ERR,"accno[%s]",trans.eaccno);
		if(DB_NOTFOUND==ret)
			return E_NOTEXIST_EACCNO;
		else 
			return E_DB_ACCOUNT_R;
	}
	if(eaccount.status[0]!=STATUS_NORMAL)
	{
		return E_CARDACC_LOGOUT;
	}	
	char seedkey[33]="";
	char inpwd_crypt[65]="";
	char inpwd_plain[65]="";
	char dbpwd_plain[65]="";
	des2src(inpwd_crypt,rPack->snote2);
	if(!strlen(inpwd_crypt))
		return E_PWD_NULL;
	ret=GetSysParaVal(GLOBLE_SYSPARA_STATIC_KEY,seedkey);
	if(ret)
		return ret;
	ret=decrypt_elec_card_pwd(0,seedkey,inpwd_crypt,inpwd_plain);
	if(ret)
		return	E_EACCPWD;
	ret=decrypt_elec_card_pwd(0,seedkey,eaccount.accpwd,dbpwd_plain);
	if(ret)
		return E_PWD_DECRYPT;
	if(strcmp(inpwd_plain,dbpwd_plain)!=0)
		return E_EACCPWD;
		//检查客户
	T_t_customer tCustomer;
	memset(&tCustomer,0,sizeof(tCustomer));
	ret=doCustomer(eaccount.custid,tCustomer);
	if(ret)
		return ret;
	//	创建账号
	pAccTrans->trans.custid=eaccount.custid;
	pAccTrans->trans.inputamt=eaccount.balance;
	trans.unusedamt = trans.inputamt;
	strcpy(pAccTrans->trans.eaccno,eaccount.accno);
	ret=pAccTrans->doTrans();
	if(ret)
		return ret;	
	//注销帐户
	ret=doAccount(trans);
	if(ret)
		return ret;
	SetCol(handle,F_LVOL0,F_LVOL8,F_SDATE3,F_SEMP,F_LWITHDRAW_FLAG,F_LSERIAL1,F_VSMESS,0);	
	des2src(outPack->sdate3,pAccTrans->trans.accdate);
	des2src(outPack->semp,trans.opercode);
	outPack->lwithdraw_flag=trans.termid;
	outPack->lserial1=trans.termseqno;
	sprintf(outPack->vsmess,"客户[%s]电子钱包销户成功",eaccount.accname);
	strcat(outPack->vsmess,pAccTrans->remark.c_str());
	des2src(trans.remark,outPack->vsmess);
	PutRow(handle,outPack,pRetCode,szMsg);
	return 0;
}
예제 #4
0
int F847226(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg)
{
	int ret=0;
	CAccTrans *pAccTrans=CAccTrans::getInstance();
	des2src(pAccTrans->trans.opercode,rPack->semp);
	pAccTrans->trans.transcode=TC_AUTHCARDOPEN;
	ret=pAccTrans->InitTrans();
	if(ret)
		return ret;			
	TRANS& trans=pAccTrans->trans;
	
	char opercode[11] = "";
	char work_key[51] = "";

	T_t_operator tOper;
	T_t_authcard tAuthCard;
		
	ST_CPACK aPack;
	ST_PACK *out_pack = &(aPack.pack);

	memset(&tOper,0,sizeof tOper);
	memset(&tAuthCard,0,sizeof tAuthCard);
	memset(&aPack,0,sizeof aPack);

	ResetNormalCPack(&aPack,0,1);

	SetCol(handle,0);
	SetCol(handle,F_LVOL0,F_LVOL1,F_SCUST_LIMIT,F_SCUST_LIMIT2,F_SDATE2,F_SBANK_ACC,0);

	des2src(opercode,rPack->sname2);
	des2src(trans.cardphyid,rPack->sname);
	des2src(trans.showcardno,rPack->sorder0);
	if(strlen(opercode) == 0)
	{
		return E_NOTEXIST_OPER;
	}
	if(strlen(rPack->scust_limit) == 0)
	{
		return E_INPUT_OPER_NULL;
	}
	ret = IsInvalidDateTime(rPack->sdate2,"YYYYMMDD");
	if(ret)
	{
		return ret;
	}
	ret = DB_t_operator_read_by_opercode(opercode,&tOper);
	if(ret)
	{
		if(DB_NOTFOUND == ret)
			return E_NOTEXIST_OPER;
		else
			return E_DB_OPERATOR_R;
	}
	if(tOper.status[0]=='0')
	{
		DB_t_operator_free_lock_by_c0();
		return E_OPER_LOCK;
	}	
	if(tOper.status[0]==STATUS_DELETE)
	{
		DB_t_operator_free_lock_by_c0();
		return E_OPERLOGON_UNREG;
	}
	//todo:判断如果该操作员持有该卡已经发行过,那么系统允许重复发行,但是不计流水
	//todo:用于解决操作员发行卡失败后,必须回收卡才能继续处理的问题
	ret=DB_t_authcard_read_by_opercode_and_status(opercode,"1",&tAuthCard);
	if(ret!=DB_NOTFOUND)
	{
		if(0==ret)
		{
			if(strcmp(trans.cardphyid,tAuthCard.cardphyid)==0)
			{
				out_pack->lvol0 = tAuthCard.cardno;
				out_pack->lvol1 = tAuthCard.privilege;
				des2src(out_pack->sdate2,tAuthCard.expiredate);
				des2src(out_pack->scust_limit,tAuthCard.opercode);
				des2src(out_pack->sbank_acc,work_key);
				des2src(out_pack->scust_limit2,tOper.opername);
				PutRow(handle,out_pack,pRetCode,szMsg);
				return 0;
			}
			else
				return E_AUTHCARD_EXIST;
		}
		else
			return E_DB_AUTHCARD_R;
	}
//		//记录存在
//		if(tAuthCard.cardstatus[CARDSTAT_TYPE_LOST]=='1')
//		{
//			//修改原来卡为注销状态
//			tAuthCard.status[0]==STATUS_DELETE;
//			des2src(tAuthCard.closedate,pAccTrans->trans.transdate);
//			ret=DB_t_authcard_update_by_cardno(tAuthCard.cardno,&tAuthCard);
//			if(ret)
//			{
//					return E_DB_AUTHCARD_U;
//			}
//		}
		//return E_OPER_ALREADY_HAS_AUTHCARD;
//	}
	ret=GetSysParaVal(GLOBE_999_DEVAUTHKEY,work_key);
	if( ret)
	{
		return ret;
	}

	ret = getNewUniqNo(KEYTYPE_CARDNO,&(trans.cardno));
	if(ret)
	{
		return ret;
	}

	tAuthCard.cardno = trans.cardno;

	des2src(tAuthCard.opendate,pAccTrans->trans.transdate);
	des2src(tAuthCard.opercode,opercode);
	des2src(tAuthCard.cardphyid,trans.cardphyid);
	des2src(tAuthCard.showcardno,trans.showcardno);
	des2src(tAuthCard.expiredate,rPack->sdate2);
	tAuthCard.privilege = rPack->lvol0;
	tAuthCard.status[0]=STATUS_NORMAL;
	tAuthCard.lossflag[0]='0';
	// TODO : 检查物理卡号是否已经存在
	ret = DB_t_authcard_add(&tAuthCard);
	if(ret)
	{
		if(DB_REPEAT == ret)
			return E_DB_AUTHCARD_E;
		else
			return E_DB_AUTHCARD_I;
	}
	out_pack->lvol0 = tAuthCard.cardno;
	out_pack->lvol1 = tAuthCard.privilege;
	des2src(out_pack->sdate2,tAuthCard.expiredate);
	des2src(out_pack->scust_limit,tAuthCard.opercode);
	des2src(out_pack->sbank_acc,work_key);
	des2src(out_pack->scust_limit2,tOper.opername);
	PutRow(handle,out_pack,pRetCode,szMsg);
	ret = DB_t_operator_read_lock_by_c0_and_opercode(opercode,&tOper);
	if(ret)
	{
		if(DB_NOTFOUND == ret)
			return E_NOTEXIST_OPER;
		else
			return E_DB_OPERATOR_R;
	}
	tOper.cardno=tAuthCard.cardno;
	ret=DB_t_operator_update_lock_by_c0(&tOper);
	if(ret)
	{
		return E_DB_OPERATOR_U;
	}
	/*
	int cardtype=0;
	ret=UseShowCardNo(trans.opercode,tAuthCard.showcardno,cardtype);
	if(ret)
	{
		return ret;
	}
	if(cardtype!=CARDTYPE_AUTH)
	{	
		return E_CARDTYPE_NOT_AUTHCARD;
	}
	T_t_carddtl carddtl;
	memset(&carddtl,0,sizeof(carddtl));
	
	des2src(carddtl.accdate,pAccTrans->sysPara.sSettleDate);
	des2src(carddtl.acctime,trans.acctime);
	carddtl.termid=trans.termid;
	carddtl.termseqno=trans.termseqno;
	des2src(carddtl.opercode,trans.opercode);
	carddtl.cardtype=CARDTYPE_AUTH;
	carddtl.usetype=CARDUSETYPE_USE;
	carddtl.inoutflag=INOUTFLAG_OUT;
	carddtl.transcnt=1;
	strcpy(carddtl.summary,"发行授权卡");	
	des2src(carddtl.cardphyid,tAuthCard.cardphyid);
	des2src(carddtl.showcardno,tAuthCard.showcardno);
	ret=DB_t_carddtl_add(&carddtl);
	if(ret)
	{
		if(DB_REPEAT==ret)
			return E_DB_CARDDTL_E;
		else
			return E_DB_CARDDTL_I;
	}
	T_t_transdtl transdtl;
	memset(&transdtl,0,sizeof(transdtl));
	transdtl.status[0]=DTLSTATUS_SUCCESS;
	transdtl.revflag[0]='0';
	transdtl.errcode=0;
	transdtl.custid=trans.custid;
	strcpy(transdtl.custname,trans.custname);
	strcpy(transdtl.transdate,trans.transdate);
	strcpy(transdtl.transtime,trans.transtime);
	strcpy(transdtl.accdate,pAccTrans->sysPara.sSettleDate);
	strcpy(transdtl.acctime,trans.acctime);
	transdtl.termid=trans.termid;
	transdtl.termseqno=trans.termseqno;
	transdtl.transcode=trans.transcode;
	des2src(transdtl.opercode,trans.opercode);
	transdtl.cardno=trans.cardno;
	des2src(transdtl.custname,tOper.opername);
	ret=DB_t_transdtl_add(&transdtl);
	if(ret)
	{
	  if(DB_REPEAT==ret)
	    return E_DB_TRANSDTL_E;
	  else
	    return E_DB_TRANSDTL_I;
	}		
	*/
	return 0;
}
예제 #5
0
int F847301(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg)
{
    T_t_tif_tradeserial tSerial, tPacketSerial;
    T_t_aif_account tAccount;
    T_t_card tCard;
    T_t_customer tCustomer;
    T_t_tif_writefailed tWriteFailed;
    InAcc IA;

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

    int ret = 0;
    int TxTypeCount = 0;
    int hi_cardid = 0;             //交易卡号
    char buf[100 + 1] = "";
    char sysdate[11] = "";
    char systime[7] = "";
    char logicdate[11] = "";
    char sMsg[128] = "";
//    char temp_account_id[16 + 1] = "2081";             //个人临时帐户
    double dUniqNo = 0;                              //最大流水号
    double cardbefbal = 0;
    double small_packet_balance = 0;                    //小钱包中的余额
    double max_balance = 0;                           //小钱包余额上限  
    double transfer_price = 0;                          //转入金额

    memset(&tAccount, 0, sizeof tAccount);
    memset(&tCard, 0, sizeof tCard);
    memset(&tCustomer, 0, sizeof tCustomer);
    memset(&IA, 0, sizeof IA);
    memset(&tPacketSerial, 0, sizeof tPacketSerial);
    memset(&tWriteFailed, 0, sizeof tWriteFailed);

    memset(&aPack,0,sizeof aPack);
    ResetNormalCPack(&aPack, 0, 1);
    SetCol(handle,0);
    SetCol(handle,F_LVOL0,F_LVOL1,F_DAMT0,F_DAMT2,F_VSMESS,F_LVOL9,F_LVOL5,0);

    hi_cardid = rPack->lvol0;
    if (hi_cardid <= 0)
    {
        *pRetCode = E_INPUT_CARDNO;
        goto L_RETU;
    }

    //判断小钱包中的余额
    small_packet_balance = rPack->damt3;

    //读取小钱包余额上限
    ret = GetSysParaVal(GLB_PACKET_LIMITS,buf);
    if (ret)
    {
        *pRetCode = ret;
        goto L_RETU;
    }
    max_balance = atof(buf);
    if (amtcmp(max_balance,0) <= 0)
    {
        *pRetCode = E_GLOBAL_PARAM_ERROR;
        goto L_RETU;
    }

    //判断充值到小钱包的金额
    transfer_price = rPack->damt4;               //钱包转入金额

    writelog(LOG_DEBUG,"tranfser_price=[%d]",transfer_price);
    writelog(LOG_DEBUG,"small_packet_balance=[%d]",small_packet_balance);
    if (amtcmp(transfer_price, 0) <= 0 || amtcmp(small_packet_balance, 0) < 0)
    {
        *pRetCode = E_INPUT_DATA_INVAILD;
        goto L_RETU;
    }

    if (amtcmp(small_packet_balance + transfer_price,max_balance) > 0)
    {
        sprintf(sMsg, "钱包余额上限是%f吨", max_balance);
        *pRetCode = E_PACKET_LIMIT_EXCEED;
        goto L_RETU;
    }

    cardbefbal = rPack->damt1;
    if (amtcmp(cardbefbal,0.0) < 0)
    {
        *pRetCode = E_BALANCE_SHORTAGE;
        goto L_RETU;
    }
    
    ret = DB_t_card_read_by_cardno(hi_cardid,&tCard);
	if(ret)
	{
		if(DB_NOTFOUND == ret)
		{
		    *pRetCode = E_DB_CARD_N;
		}
		else
		{
		    *pRetCode = E_DB_CARD_R;
	    }
	    goto L_RETU;
	}
	
    //判断卡密码是否正确
    /*
    if (CheckUserPswd(rPack->semp_pwd,tCard.password))
    {
        writelog(LOG_ERR,"Card password error");
        *pRetCode = E_TRANS_SCHCARD_PWDERR;
        goto L_RETU;
    }
    */
    
    if (strncmp(tCard.cardstatus, TYPE_YES, 1) != 0)
    {
        writelog(LOG_ERR,"card_state=[%s]",tCard.cardstatus);
        *pRetCode = E_TRANS_SCHACC_DESTORY;
        goto L_RETU;
    }

    if (STATE_TRUE == tCard.cardstatus[CARDSTAT_TYPE_LOST])
    {
        writelog(LOG_ERR,"card_state=[%s]",tCard.cardstatus);
        *pRetCode = E_TRANS_SCHCARD_LOSTING;
        goto L_RETU;
    }

    if (STATE_TRUE == tCard.cardstatus[CARDSTAT_TYPE_FREEZE])
    {
        writelog(LOG_ERR,"card_state=[%s]",tCard.cardstatus);
        *pRetCode = E_TRANS_SCHCARD_FREEZE;
        goto L_RETU;
    }

    if (STATE_TRUE == tCard.cardstatus[CARDSTAT_TYPE_WFAIL])
    {
        *pRetCode = E_CARDNO_WFAIL;
        goto L_RETU;
    }

    ret = DB_t_customer_read_by_custid(tCard.custid,&tCustomer);
    if (ret)
    {
        if (DB_NOTFOUND == ret)
        {
            *pRetCode = E_DB_CUSTOMER_N;
        }
        else
        {
            *pRetCode = E_DB_CUSTOMER_R;
        }
        goto L_RETU;
    }

    //读取个人帐户
    ret = DB_t_aif_account_read_by_cardno_and_purseno(tCard.cardno,PURSE_NO_ONE,&tAccount);
    if (ret)
    {
        if (DB_NOTFOUND == ret)
        {
            *pRetCode = E_DB_ACCOUNT_N;
        }
        else
        {
            *pRetCode = E_DB_ACCOUNT_R;
        }
        goto L_RETU;
    }
    //个人临时帐户填死掉了, 不需要查询
    ret = getNewUniqNo(KEYTYPE_TRADESERIAL,&dUniqNo);              // 获得最大流水号
    if (ret)
    {
        writelog(LOG_ERR,"ret[%d]",ret);
        *pRetCode = ret;
		goto L_RETU;
    }

    getsysdate(sysdate);
    getsystime(systime);
    GetLogicDate(logicdate);
    memset(&tSerial, 0, sizeof tSerial);
    tSerial.serial_no = D2I(dUniqNo);
    tSerial.other_seri_no = 0;
    tSerial.serial_state = SERISTAT_DEBT;                           //流水状态
    tSerial.serial_type = TXCODE_CONSUME;                           //交易类型
    des2src(tSerial.operate_date,sysdate);                           //发生日期
    des2src(tSerial.operate_time,systime);                           //发生时间
    des2src(tSerial.collect_date,sysdate);                           //采集日期
    des2src(tSerial.collect_time,systime);                           //采集时间
    des2src(tSerial.enteract_date,logicdate);                        //处理日期
    des2src(tSerial.enteract_time,systime);                          //处理时间

//    tSerial.maindeviceid = rPack->lvol3;                            //上传工作站标识
    tSerial.deviceid = 0;                                          //采集设备标识 
    tSerial.cardno = hi_cardid;                                    //交易卡号
    des2src(tSerial.showid,tCard.showid);                           //显示卡号
    tSerial.purseno = PURSE_NO_ONE;                                //钱包号
    tSerial.custid = tCard.custid;                         //客户号
    des2src(tSerial.opercode, rPack->scust_no);                      //操作员代码
    tSerial.sysid = 0;
    tSerial.trade_count = rPack->lvol4 + 1;                          //卡交易次数
    tSerial.trade_fee = transfer_price;                             //转钱金额
    tSerial.cardbefbal = cardbefbal;                                //入卡值
    writelog(LOG_DEBUG,"水控转账入卡值[%.2lf]",cardbefbal);
    des2src(IA.sArrInActno[0],tAccount.account_id);                 //个人帐户
//  des2src(IA.sArrInActno[1],temp_account_id);                  //个人临时帐户
    IA.dArrInAmt[0] = tSerial.trade_fee;                            //交易金额
    IA.iCardNo = tCard.cardno;                                     //交易卡号
    IA.iFeeType = tCustomer.feetype;                               //客户收费类型

    //调用入帐子模块
    ret = process(&IA,&tSerial);
    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(TxTypeCount = 1; TxTypeCount <= IA.iOutTxTypeCnt; TxTypeCount++)
	{
		switch(IA.iArrOutTxType[TxTypeCount])
		{
			case TXTYPE_TOLL_DEPOSIT:
			case TXTYPE_TOLL_DEPOSIT_BILL:
			case TXTYPE_TOLL_DEPOSIT_FUNDBOOK:
			case TXTYPE_DEDUCT_DEPOSIT:
			case TXTYPE_RETURN_DEPOSIT:
				tSerial.depositfee = IA.dArrOutAmt[TxTypeCount];
				break;
			case TXTYPE_PRE_TOLL_BOARD:
			case TXTYPE_PRE_TOLL_BOARD_BILL:
			case TXTYPE_PRE_TOLL_BOARD_FUNDBOOK:
			case TXTYPE_TOLL_BOARD:
			case TXTYPE_DEDUCT_BOARD:
			case TXTYPE_RETURN_BOARD:
			case TXTYPE_RETURN_BOARD_BILL:
			case TXTYPE_RETURN_BOARD_FUNDBOOK:
				tSerial.managefee = IA.dArrOutAmt[TxTypeCount];
				break;
			case TXTYPE_TOLL_CHARGE:
			case TXTYPE_TOLL_CHARGE_BILL:
			case TXTYPE_TOLL_CHARGE_FUNDBOOK:
				tSerial.in_fee = IA.dArrOutAmt[TxTypeCount];
				break;
			case TXTYPE_TOLL_CARDCOST:
			case TXTYPE_TOLL_CARDCOST_BILL:
			case TXTYPE_TOLL_CARDCOST_FUNDBOOK:
				tSerial.cost_fee = IA.dArrOutAmt[TxTypeCount];
				break;
			default:
				break;
		}
		if (amtcmp(IA.dArrOutAmt[TxTypeCount], 0) != 0)
		{
		    sprintf(sMsg,"%s:%.2lf元 ", IA.sArrOutTxName[TxTypeCount], IA.dArrOutAmt[TxTypeCount]);
			strcat(out_pack->vsmess, sMsg);
		}
	}
	sprintf(sMsg, "卡当前余额:%.2lf元", tSerial.cardaftbal);
	strcat(out_pack->vsmess, sMsg);
	writelog(LOG_DEBUG,out_pack->vsmess);

	//插入交易流水表
	ret = DB_t_tif_tradeserial_add(&tSerial);
	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;
	}
	//保存充值流水
	memcpy(&tPacketSerial, &tSerial, sizeof tPacketSerial);
	ret = getNewUniqNo(KEYTYPE_TRADESERIAL,&dUniqNo);  						//获得最大流水号
	if(ret)
	{
		writelog(LOG_ERR,"ret [%d]",ret);
		*pRetCode = ret;
		goto L_RETU;
	}
	tPacketSerial.serial_no = D2I(dUniqNo);
	tPacketSerial.serial_state = SERISTAT_NONEEDDEBT;
	tPacketSerial.serial_type = TXCODE_SAVING_SMALL_PACKET;
	tPacketSerial.purseno = PURSE_NO_TWO;
	tPacketSerial.trade_count = rPack->lvol5 + 1;
    des2src(tPacketSerial.opercode, rPack->scust_no);
	tPacketSerial.cardbefbal = small_packet_balance;
	tPacketSerial.trade_fee = transfer_price;
	tPacketSerial.cardaftbal = small_packet_balance + tPacketSerial.trade_fee;
	
	ret = DB_t_tif_tradeserial_add(&tPacketSerial);
	if(ret)
	{
		if(DB_REPEAT == ret)
		{
	        *pRetCode = E_DB_TRADESERIAL_E;	
		}
		else
		{
		    *pRetCode = E_DB_TRADESERIAL_I;
		}
		goto L_RETU;
	}
	out_pack->lvol0 = tSerial.serial_no;
	out_pack->lvol1 = tPacketSerial.serial_no;
	out_pack->damt2 = tPacketSerial.cardaftbal;
	out_pack->damt0 = tSerial.cardaftbal;
	out_pack->lvol9 = tSerial.trade_count;
	out_pack->lvol5 = tPacketSerial.trade_count;
	writelog(LOG_DEBUG,"水控钱包金额[%.2lf], 出卡值[%.2lf]",out_pack->damt2,out_pack->damt0);
	
	PutRow(handle,out_pack,pRetCode,szMsg);
    return 0;
L_RETU:
	return -1;	
}
예제 #6
0
int F846336(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg)
{
	int ret=0;
	CAccTrans *pAccTrans=CAccTrans::getInstance();
	des2src(pAccTrans->trans.opercode,rPack->semp);
	int transflag=rPack->lvol3;;
	if(transflag)
	{
		pAccTrans->trans.transcode=TC_EACC2CARD;
	}
	else
	{
		pAccTrans->trans.transcode=TC_CARD2EACC;
	}	
	
	ret=pAccTrans->InitTrans();
	if(ret)
		return ret;			
	TRANS& trans=pAccTrans->trans;

	ST_CPACK aPack;
	ST_PACK *outPack = &(aPack.pack);
	ResetNormalCPack(&aPack,0,1);
	SetCol(handle,0);
	char key[17]="";
	char pwd_plain[33]="";
	char pwd_crypt[33]="";
	strcpy(key,STATIC_SEED_KEY);
	des2src(pwd_plain,rPack->scust_limit);
	EncodePwd(key,pwd_plain,pwd_crypt, 0);
	
	trans.cardflag=1;
	pAccTrans->trans.usecardflag=1;	
	trans.cardno=rPack->lvol0;
	trans.purseno=PURSE_NO_ONE;
	trans.cardcnt=rPack->lvol6+1;
	trans.cardbefbal=rPack->lvol7/100.0;
	trans.cardaftbal=trans.cardbefbal;
	trans.inputamt=D4U5(rPack->damt0,2);
	
//	transdtl.cardaftbal=rPack->lvol8;
//	transdtl.siteno=rPack->lcert_code;
//	transdtl.frontno=0;
	//des2src(transdtl.devphyid,rPack->sname);
	//transdtl.devseqno=rPack->lserial0;
	//des2src(transdtl.bankcode,rPack->sbank_code);
	//des2src(transdtl.bankcardno,rPack->scard0);
	//des2src(transdtl.mobile,rPack->sphone2);
//	des2src(transdtl.remark,rPack->ssectypes);
	
	//检查客户
	des2src(trans.cardphyid,rPack->sstation0);
	T_t_card tCard;
	
	memset(&tCard,0,sizeof(tCard));
	ret=doCard(tCard);
	if(ret)
	{
		return ret;
	}
	//查询卡帐户
	T_t_account tCardAccount;	
	memset(&tCardAccount,0,sizeof(tCardAccount));
	ret=DB_t_account_read_by_cardno_and_purseno(trans.cardno,trans.purseno,&tCardAccount);
	if(ret)
	{
		if(DB_NOTFOUND==ret)
			return ERRINFO(E_CARDNO_PURSENO_NOACCNO,trans.cardno,trans.purseno);
		else 
			return E_DB_ACCOUNT_R;
	}
	if(tCardAccount.status[0]!=STATUS_NORMAL)
	{
		return ERRINFO(E_CARDACC_LOGOUT,tCardAccount.accno);
	}
	//根据客户号查询电子钱包帐户
	T_t_netacc tNetAccount;	
	memset(&tNetAccount,0,sizeof(tNetAccount));
	ret=DB_t_netacc_read_by_custid(tCardAccount.custid,&tNetAccount);
	if(ret)
	{
		if(DB_NOTFOUND==ret)
			return ERRINFO(E_NOTEXIST_EACCNO,tCardAccount.custid);
		else 
			return E_DB_ACCOUNT_R;
	}
	if(tNetAccount.status[0]!=STATUS_NORMAL)
		return ERRINFO(E_EACCNO_LOGOUT,tNetAccount.accno);
	strcpy(trans.cardaccno,tCardAccount.accno);
	
	pAccTrans->trans.feetype=tCard.feetype;
	pAccTrans->trans.custid=tCard.custid;
	strcpy(pAccTrans->trans.cardaccno,tCardAccount.accno);
	strcpy(pAccTrans->trans.eaccno,tNetAccount.accno); 	
	if(TC_CARD2EACC==trans.transcode)
	{
		//检查卡密码
		if(strcmp(tCard.cardpwd,pwd_crypt)!=0)
		{
			return E_CARDPWD;
		}
		if(amtcmp(pAccTrans->trans.inputamt,trans.cardbefbal)>0)
			return ERRINFO(E_CARD_BALANCE_SHORTAGE,trans.cardbefbal-pAccTrans->trans.inputamt);
		strcpy(pAccTrans->trans.draccno,tCardAccount.accno);
		strcpy(pAccTrans->trans.craccno,tNetAccount.accno);		
	}
	else
	{
		char inpwd_crypt[65]="";
		char seedkey[33]="";
		char inpwd_plain[65]="";
		char dbpwd_plain[65]="";
		//检查电子钱包密码
		des2src(inpwd_crypt,rPack->snote2);
		if(!strlen(inpwd_crypt))
			return E_PWD_NULL;
		ret=GetSysParaVal(GLOBLE_SYSPARA_STATIC_KEY,seedkey);
		if(ret)
			return ret;
		ret=decrypt_elec_card_pwd(0,seedkey,inpwd_crypt,inpwd_plain);
		if(ret)
			return E_EACCPWD;
		ret=decrypt_elec_card_pwd(0,seedkey,tNetAccount.accpwd,dbpwd_plain);
		if(ret)
			return E_PWD_DECRYPT;
		if(strcmp(inpwd_plain,dbpwd_plain)!=0)
			return E_EACCPWD;

		if(tNetAccount.stoppayflag[0]=='1')
			return ERRINFO(E_EACC_STOPPAY,tNetAccount.accno);
		if(amtcmp(pAccTrans->trans.inputamt,tNetAccount.balance)>0)
			return ERRINFO(E_EACC_BALANCE_SHORTAGE,pAccTrans->trans.inputamt-tNetAccount.balance);
		if(amtcmp(pAccTrans->trans.inputamt+trans.cardbefbal,tCardAccount.cardmaxbal)>0)
			return ERRINFO(E_AMT_EXCEED_MAX,tCardAccount.cardmaxbal);	
		strcpy(pAccTrans->trans.draccno,tNetAccount.accno);		
		strcpy(pAccTrans->trans.craccno,tCardAccount.accno);
	}
	pAccTrans->trans.feetype=0;
	pAccTrans->trans.usecardflag=1;	
	pAccTrans->trans.custid=tCard.custid;
	ret=pAccTrans->doTrans();
	if(ret)
		return ret;
	T_t_transdtl transdtl;
	memset(&transdtl,0,sizeof(transdtl));

	des2src(transdtl.transdate,trans.sysdate);
	des2src(transdtl.transtime,trans.systime);
	strcpy(transdtl.accdate,trans.sysdate);
	strcpy(transdtl.acctime,trans.systime);
	transdtl.termid=trans.termid;
	transdtl.termseqno=trans.termseqno;
	transdtl.transcode=trans.transcode;
	transdtl.cardno=trans.cardno;
	transdtl.purseno=trans.purseno;
	transdtl.cardcnt=trans.cardcnt;
	transdtl.cardbefbal=trans.cardbefbal;
	transdtl.cardaftbal=pAccTrans->trans.cardaftbal;
	transdtl.managefee=trans.totalfeeamt;
	transdtl.amount=trans.totalfeeamt;
	des2src(transdtl.opercode,trans.opercode);
	transdtl.status[0]=DTLSTATUS_SUCCESS;
	transdtl.revflag[0]='0';
	transdtl.showcardno=atol(tCard.showcardno);
	ret=DB_t_transdtl_add(&transdtl);
	if(ret)
	{
	  if(DB_REPEAT==ret)
	    return E_DB_TRANSDTL_E;
	  else
	    return E_DB_TRANSDTL_I;
	}		
	SetCol(handle,F_LVOL0,F_LVOL8,F_SDATE0,
		F_SDATE3,F_SEMP,F_LWITHDRAW_FLAG,F_LSERIAL1,F_VSMESS,0);	
	outPack->lvol0=tCard.cardno;
	outPack->lvol8=D4U5(pAccTrans->trans.cardaftbal*100,0);
	des2src(outPack->sdate3,pAccTrans->trans.sysdate);
	des2src(outPack->semp,trans.opercode);
	outPack->lwithdraw_flag=trans.termid;
	outPack->lserial1=trans.termseqno;
	char temp[128]="";
	sprintf(temp,"卡余额:%.2f",pAccTrans->trans.cardaftbal);
	pAccTrans->remark+=temp;
	strcpy(outPack->vsmess,pAccTrans->remark.c_str());
	des2src(trans.remark,outPack->vsmess);
	PutRow(handle,outPack,pRetCode,szMsg);
	return 0;
}
예제 #7
0
int F950070(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg)
{
	T_t_device tDevice;
	T_t_card tCard;
	T_t_dpsopercard tDpsCard;
	T_t_dpsoper tOperator;
	int ret;
	char temp[64] = {0};
	ST_CPACK aPack;
	ST_PACK *out_pack = &(aPack.pack);

	memset(&tDevice,0,sizeof tDevice);
	memset(&tCard,0,sizeof tCard);
	memset(&tDpsCard,0,sizeof tDpsCard);
	memset(&tOperator,0,sizeof tOperator);

	

	ResetNormalCPack(&aPack,0,1);
	SetCol(handle,0);
	SetCol(handle,F_LCERT_CODE,F_SPHONE3,F_LSAFE_LEVEL,F_LWITHDRAW_FLAG,F_LVOL0,F_SEMP_NO,
		F_SNAME,F_LVOL1,F_LVOL2,F_LVOL3,F_LVOL4,F_SDATE3,F_STIME3,F_SHOLDER_AC_NO,F_LVOL5,0);

	out_pack->lcert_code = ERRIF_SYSTEM;
	ret = do950070(tDevice,tCard,tDpsCard,tOperator,rPack);
	if(ret)
	{
		out_pack->lcert_code = ret;
		writelog(LOG_ERR,"do950070 error ,ret[%d]",ret);
	
	}
	else
	{
		des2src(out_pack->sphone3,tDevice.devphyid);
		out_pack->lcert_code = 0;  //
		// TODO : 增加批次号
		ret = GetSysParaVal(SYSPARA_CMCCENTERPRICECODE,temp);
		if(ret)
		{
			writelog(LOG_ERR,"GetSysPara[%d] error",SYSPARA_CMCCENTERPRICECODE);
			out_pack->lcert_code = ERRIF_SYSTEM;
		}
		des2src(out_pack->sholder_ac_no,temp);
		ret = GetSysParaVal(SYSPARA_CMCCSUBAPPID,temp);
		if(ret)
		{
			writelog(LOG_ERR,"GetSysPara[%d] error",SYSPARA_CMCCSUBAPPID);
			out_pack->lcert_code = ERRIF_SYSTEM;
		}
		out_pack->lvol5 = atoi(temp);

		ret = DB_t_dpsoper_read_lock_by_c0_and_opercode(tDpsCard.opercode,&tOperator);
		if(ret)
		{
			writelog(LOG_ERR,"deposit operator not exists[%s]",tDpsCard.opercode);
			out_pack->lcert_code = ERRIF_SYSTEM;
		}
		
		
		if(out_pack->lcert_code == 0)
		{
			tOperator.batchno++;
			tOperator.authcode = get_int_random();
			des2src(tOperator.devphyid,tDevice.devphyid);
			ret = DB_t_dpsoper_update_lock_by_c0(&tOperator);
			if(ret)
			{
				writelog(LOG_ERR,"DB_t_dpsoper_update_lock_by_c0 error");
				out_pack->lvol0 = ERRIF_SYSTEM;
			}				
			out_pack->lwithdraw_flag = tDevice.deviceid;
			out_pack->lvol0 = tCard.cardno;
			out_pack->lvol1 = tOperator.batchno; // 充值批次号
			out_pack->lvol2 = tOperator.authcode; // 充值授权码
			out_pack->lvol3 = 1000000; // 充值授权金额
			out_pack->lvol4 = 0; //是否根据主机校对时钟
			getsysdate(out_pack->sdate3);
			getsystime(out_pack->stime3);
			out_pack->lsafe_level = 0; // 是否收取手续费
			memset(out_pack->sname,0,sizeof (out_pack->sname)); // 操作员姓名
			des2src(out_pack->semp_no,tOperator.opercode);
		}
		
	}

	PutRow(handle,out_pack,pRetCode,szMsg);
	return 0;
	
}
예제 #8
0
int F846334(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg)
{
	int ret=0;
	CAccTrans *pAccTrans=CAccTrans::getInstance();
	des2src(pAccTrans->trans.opercode,rPack->semp);
	pAccTrans->trans.transcode=TC_EACCDRAW;
	ret=pAccTrans->InitTrans();
	if(ret)
		return ret;			
	TRANS& trans=pAccTrans->trans;

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

	SetCol(handle,0);

	des2src(trans.eaccno,rPack->sbank_acc);
	if(!strlen(trans.eaccno))
		return E_INPUTNULL_ACCNO;
	//去帐户信息
	T_t_netacc eaccount;	
	memset(&eaccount,0,sizeof(eaccount));
	ret=DB_t_netacc_read_by_accno(trans.eaccno,&eaccount);
	if(ret)
	{
		writelog(LOG_ERR,"accno[%s]",trans.eaccno);
		if(DB_NOTFOUND==ret)
			return E_NOTEXIST_EACCNO;
		else 
			return E_DB_ACCOUNT_R;
	}
	if(eaccount.status[0]!=STATUS_NORMAL)
	{
		return E_EACCNO_LOGOUT;
	}	
	char seedkey[33]="";
	char inpwd_crypt[65]="";
	char inpwd_plain[65]="";
	char dbpwd_plain[65]="";
	des2src(inpwd_crypt,rPack->snote2);
	if(!strlen(inpwd_crypt))
		return E_PWD_NULL;
	ret=GetSysParaVal(GLOBLE_SYSPARA_STATIC_KEY,seedkey);
	if(ret)
		return ret;
	ret=decrypt_elec_card_pwd(0,seedkey,inpwd_crypt,inpwd_plain);
	if(ret)
		return	E_EACCPWD;
	ret=decrypt_elec_card_pwd(0,seedkey,eaccount.accpwd,dbpwd_plain);
	if(ret)
		return E_PWD_DECRYPT;
	if(strcmp(inpwd_plain,dbpwd_plain)!=0)
		return E_EACCPWD;
	if(eaccount.stoppayflag[0]=='1')
		return E_EACC_STOPPAY;
	pAccTrans->trans.inputamt=rPack->damt0;
	pAccTrans->trans.unusedamt = trans.inputamt;	
	if(amtcmp(pAccTrans->trans.inputamt,0)==0)
		return E_INPUT_AMT_NULL;
	if(amtcmp(pAccTrans->trans.inputamt,eaccount.balance)>0)
		return E_BALANCE_SHORTAGE;
	//	创建账号
	pAccTrans->trans.custid=eaccount.custid;
	pAccTrans->trans.fundtype=0;
	ret=pAccTrans->doTrans();
	if(ret)
		return ret;	
	SetCol(handle,F_LVOL0,F_LVOL8,F_SDATE3,F_SEMP,F_LWITHDRAW_FLAG,F_LSERIAL1,F_VSMESS,0);	
	des2src(outPack->sdate3,pAccTrans->trans.accdate);
	des2src(outPack->semp,trans.opercode);
	outPack->lwithdraw_flag=trans.termid;
	outPack->lserial1=trans.termseqno;
	sprintf(outPack->vsmess,"%s %s 帐户余额:%.2f元",eaccount.accname,pAccTrans->remark.c_str(),pAccTrans->trans.draccaftbal);
	des2src(trans.remark,outPack->vsmess);
	PutRow(handle,outPack,pRetCode,szMsg);
	return 0;
}
예제 #9
0
int F846331(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg)
{

	int ret=0;
	CAccTrans *pAccTrans=CAccTrans::getInstance();
	des2src(pAccTrans->trans.opercode,rPack->semp);
	pAccTrans->trans.transcode=TC_EACCOPEN;
	ret=pAccTrans->InitTrans();
	if(ret)
		return ret;			
	TRANS& trans=pAccTrans->trans;

	char accpwd_crypt[65]="";
	char seedkey[65]="";
	char inpwd_plain[65]="";
	
	ST_CPACK aPack;
	ST_PACK *outPack = &(aPack.pack);
	memset(&aPack,0,sizeof(aPack));
	
	ResetNormalCPack(&aPack,0,1);
		
	SetCol(handle,0);
	
	des2src(accpwd_crypt,rPack->snote2);
	if(!strlen(accpwd_crypt))
		return E_PWD_NULL;

	ret=GetSysParaVal(GLOBLE_SYSPARA_STATIC_KEY,seedkey);
	if(ret)
		return ret;
	ret=decrypt_elec_card_pwd(0,seedkey,accpwd_crypt,inpwd_plain);
	if(ret)
	{
		writelog(LOG_ERR,"oldpwd[%s]",accpwd_crypt);
		return E_PWD_DECRYPT;	//去帐户信息
	}
	//检查客户
	T_t_customer tCustomer;
	
	memset(&tCustomer,0,sizeof(tCustomer));
	tCustomer.custid=rPack->lvol1;
	if(!tCustomer.custid)
		return E_INPUTNULL_CUSTID;	
	ret=doCustomer(tCustomer.custid,tCustomer);
	if(ret)
		return ret;

	char key[17]="";
//	get_init_passwd_by_man_id(tCustomer.idno,accpwd);
//	strcpy(key,STATIC_SEED_KEY);
//	EncodePwd(key,accpwd_plain,accpwd_crypt, 0);

	//先查找该客户是否存在电子钱包帐户,如果存在,直接修改状态.
//	创建账号
	T_t_netacc tEAccount;
	memset(&tEAccount,0,sizeof(tEAccount));

	ret=DB_t_netacc_read_by_custid(tCustomer.custid,&tEAccount);
	if(ret)
	{
		if(DB_NOTFOUND!=ret)
			return E_DB_ACCOUNT_R;	
		ret = GetNewNetAccno(tEAccount.accno);												//获得最大帐号
		if (ret)
		{
			return ret;
		}
		des2src(tEAccount.accname,tCustomer.custname);
		des2src(tEAccount.subjno,SUBJECT_ESAVING);
		des2src(tEAccount.accpwd,accpwd_crypt);
		tEAccount.custid=tCustomer.custid;
		tEAccount.status[0]=STATUS_NORMAL;
		getsysdate(tEAccount.lasttransdate);
		getsysdate(tEAccount.opendate);
		tEAccount.stoppayflag[0]='0';
//		tEAccount.acctype=ACCTYPE_EACC;		
		ret=DB_t_netacc_add(&tEAccount);
		if(ret)
		{
			if(DB_REPEAT==ret)
				return E_DB_ACCOUNT_E;
			else
				return E_DB_ACCOUNT_I;
		}	
	}
	else
	{
		if(tEAccount.status[0]!=STATUS_DELETE)
			return E_CUST_EACC_OPENED;
		tEAccount.stoppayflag[0]='0';		
		tEAccount.status[0]=STATUS_NORMAL;
		getsysdate(tEAccount.opendate);
		tEAccount.closedate[0]=0;
		ret=DB_t_netacc_update_by_accno(tEAccount.accno,&tEAccount);
		if(ret)
		{
			return E_DB_ACCOUNT_U;
		}
	}
	SetCol(handle,F_SDATE3,F_LWITHDRAW_FLAG,F_LSERIAL1,F_SEMP,F_VSMESS,0);	
	outPack->lvol1=tCustomer.custid;
	des2src(outPack->sdate3,pAccTrans->trans.sysdate);
	des2src(outPack->semp,trans.opercode);
	outPack->lwithdraw_flag=trans.termid;
	outPack->lserial1=trans.termseqno;
	sprintf(outPack->vsmess,"客户[%s]电子钱包开户成功",tEAccount.accname);
	des2src(trans.remark,outPack->vsmess);
	PutRow(handle,outPack,pRetCode,szMsg);
	return 0;
예제 #10
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.accdate);
	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]",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_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.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_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;
	}
	char broadcastblkflag[20]={0};
	ret=GetSysParaVal(SYSPARA_BROADCASTBLKLIST,broadcastblkflag);
	if(ret)
	{
		if(DB_NOTFOUND==ret)
			return 0;
		else
			return E_DB_SYSKEY_R;
	}
	des2src(trans.summary,cardver.cardverno);
	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,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;
	}
	return 0;
}
예제 #11
0
int F950998(TRUSERID *handle, int iRequest, ST_PACK *rpack, int *pRetCode, char *szMsg)
{
	char szfile[256];
	char full_path[512] = "";
	int maxlen,ret,is_del;
	FILE *fp;
	ST_SDPACK *psd;
	char *pend;
	struct stat fst;
	memset(&fst,0,sizeof fst);

	is_del = rpack->lvol0;
	// 获取文件名, 去掉路径
	pend = strrchr(rpack->vsmess,'/');
	if(pend)
	{
		if(pend >= strlen(rpack->vsmess) + rpack->vsmess)
		{
			*pRetCode = E_INPUT_DATA_INVAILD;
			return -1;
		}
		strcpy(szfile,pend+1);
	}
	else
		strcpy(szfile, rpack->vsmess);
	maxlen = sizeof(ST_PACK) - 4;
	if (maxlen > 4096)
		maxlen = 4096;
	// 获取文件存放路径
	ret = GetSysParaVal(GLOBAL_DOWNLOAD_PATH,full_path);
	if(ret)
	{
		*pRetCode = ret;
		return -1;
	}
	strcat(full_path,"/");
	strcat(full_path,szfile);
	// 以二进制打开文件
	fp = fopen(full_path, "rb");
	if (fp == NULL)
	{
		sprintf(szMsg, "Cannot open the file:<%s>!", full_path);
		writelog(LOG_ERR,szMsg);
		*pRetCode = 9980;
	}
	else
	{
		psd = (ST_SDPACK *)rpack;
		while (!feof(fp))
		{
			psd->usDataLength = fread(psd->data, 1, maxlen, fp);
			PutRowData(rpack);
		}
		fclose(fp);
		stat(full_path, &fst);
		sprintf(szMsg, "%ld", fst.st_mtime);
		if(is_del == 1)
		{
			// 删除原始文件
			unlink(full_path);
		}
		*pRetCode = 0;
	}
	SetCol(handle,F_LVOL0, F_VSMESS, 0);
	// 文件大小
	rpack->lvol0 = fst.st_size;
	des2src(rpack->vsmess, szMsg);
	PutRow(handle, rpack, pRetCode, szMsg);
	return 0;
}
예제 #12
0
int F950999(TRUSERID *handle, int iRequest, ST_PACK *rpack, int *pRetCode, char *szMsg)
{
	char szfile[256];
	char full_path[512] = "";
	char temp_path[512] = "";
	int maxlen,ret,head_len;
	char temp[5] = "";
	int file_len,flag;
	FILE *fp;
	ST_SDPACK *psd;
	char *pend;
	struct stat fst;
	memset(&fst,0,sizeof fst);

	maxlen = 4096;
	
	//writelog(LOG_DEBUG,"orign file[%s]total[%d]",rpack->vsmess,rpack->lvol0);
	
	// 获取文件存放路径
	ret = GetSysParaVal(GLOBAL_UPLOAD_PATH,full_path);
	if(ret)
	{
		*pRetCode = ret;
		return -1;
	}
	// 认为是第一个请求包与最后一个请求包
	if(do_get_packtype() == 0)
	{
		// 获取文件名, 去掉路径
		file_len = rpack->lvol0;
		pend = strrchr(rpack->vsmess,'/');
		if(pend)
		{
			if(pend >= strlen(rpack->vsmess) + rpack->vsmess)
			{
				*pRetCode = E_INPUT_DATA_INVAILD;
				return -1;
			}
			strcpy(szfile,pend+1);
		}
		else
			strcpy(szfile, rpack->vsmess);
		strcat(full_path,"/");
		strcpy(temp_path,full_path);
		strcat(full_path,szfile);
		
		SetCol(handle,F_LVOL0,F_SCUST_LIMIT, F_VSMESS, 0);
		
		if(rpack->lvol1 == 0xFF)
		{
			strcat(temp_path,rpack->scust_limit);
			// 文件结束,判断文件大小
			stat(temp_path, &fst);
			if(fst.st_size != file_len)
			{
				*pRetCode = E_UPLOAD_FILE_CRC;
				writelog(LOG_DEBUG,"upload file[%s] length error,orign[%d],[%d]!"
					,full_path,file_len,fst.st_size);
				return -1;
			}
			// 重命名文件
			
			if(rename(temp_path,full_path))
			{
				*pRetCode = E_UPLOAD_CONFLICT;
				return -1;
			}
			writelog(LOG_DEBUG,"upload file[%s] success!",full_path);
		}
		else
		{
			// 第一个包删除原始文件
			unlink(full_path);
			writelog(LOG_DEBUG,"begin upload file[%s]!",full_path);
			// 生成session id
			gen_session_id(rpack->scust_limit,10);
		}
		// 返回文件名
		rpack->lvol0 = file_len;
		des2src(rpack->vsmess,szfile);
		PutRow(handle, rpack, pRetCode, szMsg);
		return 0;
	}
	// 认为是后续包
	psd = (ST_SDPACK *)rpack;
	// 取包头长度
	strncpy(temp,psd->data,4);
	temp[4] = '\0';
	head_len = strtoul(temp,NULL,16);
	if(head_len > psd->usDataLength)
	{
		*pRetCode = E_INPUT_DATA_INVAILD;
		return -1;
	}
	// 文件名
	strncpy(szfile,psd->data+4,head_len-5);
	szfile[head_len-5] = '\0';
	// 包的标志
	flag = psd->data[head_len-1];
	// 文件全路径
	strcat(full_path,"/");
	strcat(full_path,szfile);
	//writelog(LOG_DEBUG,"write file[%s]",full_path);
	
	if(flag != 0xFF)
	{
		// 以二进制打开文件
		fp = fopen(full_path, "a+b");
		if (fp == NULL)
		{
			sprintf(szMsg, "Cannot open the file:<%s>!", szfile);
			*pRetCode = 9980;
		}
		else
		{
			fwrite(psd->data+head_len,psd->usDataLength-head_len,1,fp);
			fclose(fp);
			stat(full_path, &fst);
			sprintf(szMsg, "%ld", fst.st_mtime);
			if(flag == 0xFF)
			{
				// 文件上传完成,校验文件
			}
			*pRetCode = 0;
		}
	}
	SetCol(handle,F_LVOL0, F_VSMESS, 0);
	// 文件大小
	rpack->lvol0 = fst.st_size;
	des2src(rpack->vsmess, szMsg);
	PutRow(handle, rpack, pRetCode, szMsg);
	return 0;

}
예제 #13
0
int F841609(TRUSERID *handle,int iRequest,ST_PACK *rPack,int *pRetCode,char *szMsg)
{
	int ret=0;
	int CustomerCount=0;
	int start_no=0;
	char temp[256] ="";
    CAccTrans *pAccTrans=CAccTrans::getInstance();
	
	ST_CPACK aPack;
	ST_PACK *out_pack = &(aPack.pack);

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

	CustomerCount=rPack->lvol0;//	数量

	T_t_customer  tCustomer;
	memset(&tCustomer,0,sizeof tCustomer);

//先增加客户
	ret = GetSysParaVal(GLOBE_FLAG_TEMPCARD_CUTTYPE,temp);
	if(ret)
	{
		ERRTIP("系统参数表没有配置参数标识为14的临时卡的客户类别");
		return ret;
	}	
	tCustomer.custtype=atoi(temp);

	T_t_custtype tCustType;
	memset(&tCustType,0,sizeof(tCustType));

	ret=DB_t_custtype_read_by_custtype(tCustomer.custtype,&tCustType);
	if(ret)
	{
		if(DB_NOTFOUND==ret)
			return ERRINFO(E_NOTEXIST_CUSTTYPE,tCustomer.custtype);
		else
			return E_DB_CUSTTYPE_R;
	}
	if(tCustType.feetype < 1)
	{
		ERRTIP("客户类别[%d]类别名称[%s]没有设置收费类别",tCustType.custtype,tCustType.custtypename);
		return E_COMMON_ERR;
	}
	tCustomer.feetype=tCustType.feetype;
	
	T_t_feetype tFeetype;
	memset(&tFeetype,0,sizeof tFeetype);
	ret = DB_t_feetype_read_by_feetype(tCustomer.feetype,&tFeetype);
	if(ret)
	{
		if(DB_NOTFOUND == ret)
		{
			return ERRINFO(E_NOTEXIST_FEETYPE,tCustomer.feetype);
		}
		else
			return E_DB_FEETYPE_R;
	}
	tCustomer.status[0]=STATUS_NORMAL;
	strcpy(tCustomer.custname,"临时人员");	//客户名称
	tCustomer.custattr[0]='2';				//身份禁用标志1-禁用2-启用
	tCustomer.useflag[0]='0';
	strcpy(tCustomer.areacode,rPack->sbranch_code0);	//校区
	strcpy(tCustomer.batchno,pAccTrans->trans.sysdatetime);
	strcpy(tCustomer.opendate,pAccTrans->trans.accdate);
	
	for(int i=0;i<CustomerCount;i++)
	{
		ret=GetNewCustIDByShoolCode(rPack->sbranch_code0,tCustomer.custid);
		if(ret)
		{
			writelog(LOG_ERR,"school_code[%s]",rPack->sbranch_code0);
			return ret;
		}
		ret=DB_t_customer_add(&tCustomer);
		if(ret)
		{
			writelog(LOG_ERR,"DB_t_customer_add ret[%d]",ret);
			if(DB_REPEAT==ret)
				return  ERRINFO(E_DB_CUSTOMER_E,tCustomer.custid);
			else
				return  E_DB_CUSTOMER_I;
		}
		if(0==i)
			start_no=tCustomer.custid;
	}
	sprintf(out_pack->vsmess,"生成批次号%s,客户号从%d到%d共%d个客户自动生成完成",tCustomer.batchno,start_no,tCustomer.custid,CustomerCount);
	PutRow(handle,out_pack,pRetCode,szMsg);
	//writelog(LOG_DEBUG,out_pack->vsmess);
	return 0;
}
예제 #14
0
/* ****** Updated by CHENYH at 2004-4-9 10:06:44 ******
   增加pArrays: 为了能够接收处理多请求记录的情况
*/
int CallBDFunc(int fno,TRUSERID *handle,ST_CPACK *rpack,ST_PACK *pArrays,int *iRetCode, char *szMsg)
{
   int r=0;
   int rtn=0;
   int sendtype=0;
   char param[101]="";
#ifdef _DEBUG1
CMemoryState cm1, cm2, cm3;
#endif
   APPFUNC pFunc = g_BDefines[fno].pFunc;

#ifdef _DEBUG1
	cm1.Checkpoint();
#endif
	*iRetCode=0;
	*szMsg=0;
	//判断是否是结帐时刻,如果是则等待处理
	sendtype=rpack->head.RequestType/10000;
	switch(sendtype)
       {
		case 93:
		case 95:
			rtn = (*pFunc)(handle,rpack->head.RequestType,&rpack->pack,iRetCode,szMsg);
			break;
		default:
		 	rtn=GetSysParaVal(GLOBE_FLAG_BALANCE,param);
			if(rtn)
			{
				*iRetCode=rtn;
				break;
			}
			else if(strncmp(param,"0",1)!=0)
			{
				rtn=E_DAYEND_STATUS;
				*iRetCode=rtn;
				break;
			}
			rtn = (*pFunc)(handle,rpack->head.RequestType,&rpack->pack,iRetCode,szMsg);
	              break;
       }
	if(rtn)
	{
	   	char sErrMsg[101]="";
		char sRetMsg[256]="";
		if(*szMsg)
			snprintf(sRetMsg,256," %s",szMsg);
		r=get_errcode_msg(*iRetCode, sErrMsg);
		db_rollback();
		snprintf(szMsg,256,"%s%s",sErrMsg,sRetMsg);
		writelog(LOG_ERR,"Func[%d]ecode[%d]msg[%s]",rpack->head.RequestType,*iRetCode,szMsg);
		ERR_DEAL(szMsg,*iRetCode);
		if(r)
		{
			AnswerData(handle,*iRetCode,szMsg);
			db_disconnect();
			writelog(LOG_ERR,"数据库错误,系统退出");
			exit(1);
		}
	}
	else
	{
		r=db_commit();
		if(r)
		{
			*iRetCode=E_DB_COMMIT;
			strcpy(szMsg,"数据库事务提交失败");
			writelog(LOG_ERR,"Func[%d]Msg[%s]",rpack->head.RequestType,szMsg);
			db_rollback();
			ERR_DEAL( szMsg,*iRetCode);
		}
	}
#ifdef _DEBUG1
	cm2.Checkpoint();
	if (cm3.Difference(cm1, cm2))
   {
      BCCMsgLogOut(14444,"在执行功能号:%u时候,经检查,内存出现错误!",rpack->head.RequestType);
      g_LogFile.WriteLogEx(14444,"在执行功能号:%u时候,经检查,内存出现错误!",rpack->head.RequestType);
		cm3.DumpStatistics();
   }
#endif

   if (g_BUnit.m_SqlDB.lErrorCode<=-10000)  // 出现SQL比较严重的错误
   {
      if (SQLIsConnectOK()==0)
      {
         SQLDisconnect();
      }
      g_BUnit.m_SqlDB.lErrorCode = 0;
   }
   return(rtn);
}
예제 #15
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;
}