📄 tx_this.c
字号:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include <unistd.h>#include "apgloble.h"#include "apmicro.h"#include "bms_micro.h"#include "bms_strcdef.h"#include "etc.h"int DB_search_pin(char *sname, short *ictype,char *icno, char *pin, char *cid);static int SplitFile(int optcode, char *file, int pageno);/* * Routine : FILE TRANSFERING * Rewrite by : Tristan TANG * Rewrite on : August 2, 2004 * Objective : buffer size more than 256 */int b9613( TRADE_HEAD *tr_h, BIG_STRC *bs){ FILE *fp ; char filename[128], line[2048]; char optcode[4 + 1]; char *p ; int left = 0, line_len = 0; char line_left[2048]; dp.sn = 0 ; memset(filename, 0,sizeof(filename)); bms_trace("address[%s]",bs->address); switch ( bs->bill_flg ) { case 1: sprintf( filename, "%s/tmp/%s.ivr",getenv("HOME"),bs->address); break; case 2: sprintf( filename, "%s/tmp/%s.fax",getenv("HOME"),bs->address); break; case 3: sprintf( filename, "%s/tmp/%s", getenv("HOME"),bs->address) ; break; default: return( FAILURE) ; break; } if ( (fp=fopen( filename, "rb+")) == NULL ) { bs->result = FILE_OPEN_ERROR ; return( FAILURE) ; } while ( !feof( fp) ) { memset( line, 0, sizeof(line)) ; if ( fgets(line, 2048, fp) == NULL ) break ; p = (char *)line; dp.sb[dp.sn].buf_len = 0; while( *p != '\n' && *p != '\r') { dp.sb[dp.sn].buf[dp.sb[dp.sn].buf_len] = *p; dp.sb[dp.sn].buf_len++; p++; } dp.sb[dp.sn].buf[dp.sb[dp.sn].buf_len] = *p; dp.sb[dp.sn].buf_len++; dp.sn++;/*************** line_len = strlen(line); left = line_len; memset(line_left, 0, sizeof(line_left)); memcpy(line_left, line, left); dp.sb[ dp.sn].buf_len = 0 ; while( left > SND_LEN ) { memcpy(dp.sb[dp.sn].buf, line_left, SND_LEN); dp.sb[ dp.sn++].buf_len += SND_LEN; memset(line_left, 0, sizeof(line_left)); left = line_len - dp.sn*SND_LEN; memcpy(line_left, line + dp.sn*SND_LEN, left); } memcpy(dp.sb[dp.sn].buf, line_left, left); dp.sb[ dp.sn++].buf_len += left;*/ } fclose( fp) ; if ( dp.sn == 0 ) { bs->result =1006 ; return( FAILURE) ; } switch ( bs->bill_flg ) { case 1: case 2: sprintf( filename, "%s/tmp/%s.ivr",getenv("HOME"),bs->address); unlink( filename) ; sprintf( filename, "%s/tmp/%s.fax",getenv("HOME"),bs->address); unlink( filename) ; break; default: break; } return( SUCCESS) ;}/*判断Call是从外部进来还是从座席转回主流程*/int b9616( TRADE_HEAD *tr_h, BIG_STRC *bs){ char businessinfo[300+1]; char custinfo[300]; char tmp[50]; memset( businessinfo,'\0',sizeof( businessinfo )); memset( custinfo, '\0', sizeof(custinfo )); bms_trace("in[%s]",bs->pz_num ); if( DB_get_businessinfo_tbc( bs->pz_num, businessinfo, custinfo)!=SUCCESS ){ //bs->result = 1500 ; bs->result = 9999 ; return( FAILURE ); } bms_trace("busi[%s]", businessinfo ); pub_trim( businessinfo ); //pub_get_sub_str( businessinfo, bs->abstract, 1, '&'); GetField( businessinfo, '&', bs->abstract, 2 ); bms_trace("BMS abstract[%s]!", bs->abstract ) ; //pub_get_sub_str( businessinfo, bs->cid, 0, '|'); GetField( businessinfo, '|', bs->cid, 1 ); bms_trace("BMS cid[%s]!", bs->cid ) ; pub_get_sub_str( businessinfo, bs->debi_acct, 1, '|'); bms_trace("BMS acct[%s]!", bs->debi_acct ) ; //pub_get_sub_str( businessinfo, tmp, 2, '|'); GetField( businessinfo, '|', tmp, 3); bs->ctype = atoi( tmp ); bms_trace("BMS ctype[%d]!", bs->ctype ) ; pub_get_sub_str( businessinfo, bs->passwd1, 3, '|'); bms_trace("BMS passwd[%s]!", bs->passwd1 ) ; pub_get_sub_str( businessinfo, tmp, 4, '|'); bs->bill_flg = atoi( tmp ); bms_trace("BMS bill_flg[%d]!", bs->bill_flg ) ; pub_get_sub_str( businessinfo, tmp, 5, '|'); bs->debi_acct_type = atoi( tmp ); bms_trace("BMS acct_type[%d]!", bs->debi_acct_type ) ; pub_get_sub_str( businessinfo, bs->notes1, 6, '|'); bms_trace("BMS incall_num[%s]!", bs->notes1 ) ; pub_get_sub_str( businessinfo, bs->cred_acct, 7, '|'); bms_trace("BMS yzt_acct[%s]!", bs->cred_acct ) ; pub_get_sub_str( businessinfo, bs->cred_aid, 8, '|'); bms_trace("BMS yzt_type[%s]!", bs->cred_aid ) ; pub_get_sub_str( businessinfo, bs->passwd2, 9, '|'); bms_trace("BMS yzt_passwd[%s]!", bs->passwd2 ) ; pub_get_sub_str( businessinfo, tmp, 10, '|'); bs->bid = atoi( tmp ); memset(bs->address, 0, sizeof(bs->address)); pub_get_sub_str( businessinfo, bs->address, 11, '|'); pub_trim(custinfo); strcpy(bs->notes6, custinfo); bms_trace(bs->notes6); return( SUCCESS) ;}/* **************** 转坐席数据交换 ***************** */int b9617( TRADE_HEAD *tr_h, BIG_STRC *bs){ char businessinfo[300]; char custinfo[300]; long cur_min ; int flg = 1; memset( businessinfo,'\0',sizeof( businessinfo )); memset( custinfo, '\0', sizeof(custinfo )); /**查询黑名单客户**/ bms_trace("bs->incall_num[%s]", bs->incall_num); if( DB_search_blist(bs->incall_num, &flg) != 0) { bs->result = 1002; return FAILURE; } /*该客户在黑名单中*/ if(flg == 1){ bs->result = 1002; return FAILURE; } /*客户身份校验密码不送*/ sprintf( businessinfo,"%s|%s|%d||%d|%d|%s|%s|%s|%s|%d|%s|||&", bs->cid, bs->debi_acct, bs->ctype, bs->bill_flg, bs->debi_acct_type, bs->incall_num, bs->cred_acct, bs->cred_aid, bs->passwd2, bs->bid, bs->address); fprintf(stdout, "businessinfo=[%s]\n", businessinfo); strcpy(custinfo, bs->notes6); bms_trace("custinfo[%s]", custinfo); if(DB_put_businessinfo_tbc(bs->notes2,bs->cid,businessinfo, custinfo, bs->incall_num)!=SUCCESS ) { bs->result = 1416 ; return( FAILURE ); } return( SUCCESS) ;}/*****************坐席转流程输信息*****************/ int b9618( TRADE_HEAD *tr_h, BIG_STRC *bs){ bms_trace("tele[%s]", bs->pz_num ); if( DB_get_businessinfo_and_callid( bs->pz_num, bs->notes6, bs->notes7,bs->cred_aid)!=SUCCESS ){ //bs->result = 1500 ; bs->result = 9999 ; return( FAILURE ); } return( SUCCESS) ;}/* **************** 坐席轮询 ***************** */int b9619( TRADE_HEAD *tr_h, BIG_STRC *bs){ if( DB_agent_is_idle() == FAILURE ) { bs->result = 1005 ; return( FAILURE ); } if( DB_Get_CallId_FromTbctiexchange( bs->pz_num,bs->notes1)!=SUCCESS) { bs->result = 1002 ; return( FAILURE ); } return( SUCCESS) ;}/* **************** 坐席轮询 ***************** */int b9620( TRADE_HEAD *tr_h, BIG_STRC *bs){ if( DB_Insert_Param_Businessinfo( bs->notes8, bs->pz_num,bs->notes6)!=SUCCESS ){ bs->result = 1002 ; return( FAILURE ); } return( SUCCESS );}/*搜索空闲外拨记录*/int b9621( TRADE_HEAD *tr_h, BIG_STRC *bs){ int ret; if( ret=DB_search_outbound(bs, bs->bill_flg, bs->notes1,bs->notes2,bs->notes3,bs->buf, bs->notes4, bs->notes5 )!=SUCCESS ){ bms_trace("search outbound ret[%d]", ret ); bs->result = 1002 ; return( FAILURE ); } return( SUCCESS );}/*更新空闲外拨记录*/int b9622( TRADE_HEAD *tr_h, BIG_STRC *bs){ int ret; if( ret=DB_update_outbound(bs, bs->notes1, bs->bill_flg,bs->deduct_type)!=SUCCESS ){ bms_trace("search outbound ret[%d]", ret ); bs->result = 1002 ; return( FAILURE ); } return( SUCCESS );}int b9002( TRADE_HEAD *tr_h, BIG_STRC *bs){ bms_trace("9002 cid[%s], passwd[%s]", bs->sonsign_no, bs->passwd1); //if( bs->cid[3] =='9' ) return( check_bid_passwd(bs) ); if( bs->sonsign_no[3] =='9' ) return( check_bid_passwd(bs) ); else return(check_reg_ps_passwd(bs) );}int check_bid_passwd(BIG_STRC *bs){ char ori_passwd [16+1];//客户预留的加密后的密码 char inp_passwd [16+1];//客户输入的加密后的密码 int ret=0 ; int status=0; BROKER_INFO Broker_Info; bms_trace("cid = [%s]", bs->cid); bs->ctype = NOREG_CC_TYPE ; strcpy(bs->cid, bs->sonsign_no); ret = DB_check_broker(bs->cid, bs->bid, &status); if (ret != SUCCESS) { if ( ret != FAILURE ) { bms_trace("BMS[%d] DB_check_broker[%d]!",mypid,ret) ; bs->result = DATABASE_PROGRAM_ERROR ; } else { bs->result = INVALID_BCID ; } return( FAILURE) ; } if ( status == STATUS_ERR_HANG ) { bs->result = MUCH_ERR_HANG ; return( FAILURE) ; } if (status != STATUS_ACTIVE ) { if ( status == STATUS_HANG ) { bs->result = BCID_HANG ; return( FAILURE) ; } bs->result = BCID_DISABLE; return( FAILURE) ; } //获取经办人员密码 ret = DB_check_co_pwd (bs->cid,bs->bid,ori_passwd); if (ret != SUCCESS){ bms_trace("BMS[%d] DB_check_co_pwd[%d]!",mypid,ret) ; bs->result = DATABASE_PROGRAM_ERROR ; return( FAILURE) ; } /* DES*/ icbc_des(bs->passwd1, inp_passwd); if (strncmp(ori_passwd,inp_passwd,16) != 0) { bs->result = INVALID_CID_PWD ; DB_add_broker_err (bs->cid,bs->bid); return FAILURE; } DB_reset_broker_err(bs->cid,bs->bid); bs->ctype = REG_CC_TYPE ; return (SUCCESS);}int check_reg_ps_passwd(BIG_STRC *bs){ char inp_passwd [16+1]; int ret=0; int type; PS_ACCINFO Ps_Accinfo; PERSON_INFO Person_Info; bs->ctype = NOREG_PC_TYPE ; memset((char *)&Ps_Accinfo,'\0',sizeof(PS_ACCINFO)); memset((char *)&Person_Info, '\0', sizeof(PERSON_INFO)); ret=DB_search_person_info(bs->bill_flg, bs->sonsign_no,bs->cid) ; if (ret != SUCCESS) { bms_trace("BMS[%d] DB_search_ps_accinfo[%d]!",mypid,ret) ; if( ret==FAILURE ) bs->result=2058; else bs->result = DATABASE_PROGRAM_ERROR ; return( FAILURE) ; } strcpy(Ps_Accinfo.cid,bs->cid); /*****addbyzhong 20051107*********/ //strcpy(Ps_Accinfo.cid, bs->sonsign_no); /*************/ bms_trace("BMS[%d] 123DB_search_ps_accinfo[%s]!",mypid,Ps_Accinfo.cid) ; ret = DB_search_ps_acc_info (&Ps_Accinfo) ; if (ret != SUCCESS) { bms_trace("BMS[%d] DB_search_ps_accinfo[%d]!",mypid,ret) ; if( ret==FAILURE ) bs->result=2058; else bs->result = DATABASE_PROGRAM_ERROR ; return( FAILURE) ; } if ( Ps_Accinfo.status == STATUS_ERR_HANG ) { bs->result = MUCH_ERR_HANG ; return( FAILURE) ; } if (Ps_Accinfo.status != STATUS_ACTIVE ) { if ( Ps_Accinfo.status == STATUS_HANG ) { bs->result = CID_HANG ; return( FAILURE) ; } bs->result = CID_DISABLE; return( FAILURE) ; } icbc_des (bs->passwd1,inp_passwd); if (strncmp(Ps_Accinfo.ppasswd,inp_passwd,16) != 0) { bs->result = INVALID_CID_PWD ; DB_add_ps_err (bs->cid); bms_trace("BMS[%d] DB_update_ps_err[%d]!",mypid,ret) ; return FAILURE; } DB_reset_ps_err(bs->cid); bs->ctype = REG_PC_TYPE ; return (SUCCESS);}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -