/*
* 脚本编写信息描述:
* 项目名称:
* 脚本功能:
* 版 本 号:V1.00
* 交易路径:1.模拟外围系统发起→支付平台→ESB→D+
* 2.模拟外围系统发起→支付平台→支付网关→人行
* 编码语言:C
* 开发协议:SOCKET
* 作 者:余钱
* 时 间:2016-5-28
* 参数化字段:
* BIZ_SEQ_NO:业务流水号
* CHANNEL_SEQ_NO:渠道流水号
* DEDUCT_ACCT_NO:扣款账号
* COMMISSION_OUT_ACCT_NO:扣款账号
* PAYER_ACCT_NO:付款方账号号
*/
#include "lrs.h"
Action()
{
char msgBody[2500];
char strSend[2500];
char strSock[12];
char *strRecvBuf=NULL;
int intSendLenght;
int rc;
char sRecvLen[4];
memset( msgBody, 0, sizeof(msgBody) );
memset( strSend, 0, sizeof(strSend) );
memset( strSock, 0, sizeof(strSock) );
sprintf(msgBody,lr_eval_string(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
"<service version=\"2.0\">"
"<SYS_HEAD>"
"<SERVICE_CODE attr=\"s,30\">03001000005</SERVICE_CODE>"
"<SERVICE_SCENE attr=\"s,2\">01</SERVICE_SCENE>"
"<CONSUMER_ID attr=\"s,6\">804343</CONSUMER_ID>"
"<ESB_SEQ_NO attr=\"s,42\">20160419942958553</ESB_SEQ_NO>"
"<TRAN_TIMESTAMP attr=\"s,9\">172102620</TRAN_TIMESTAMP>"
"<CONSUMER_SEQ_NO attr=\"s,42\">8043431604196100038694</CONSUMER_SEQ_NO>"
"<TRAN_DATE attr=\"s,8\">20160419</TRAN_DATE>"
"<ORG_SYS_ID attr=\"s,6\">804343</ORG_SYS_ID>"
"</SYS_HEAD>"
"<APP_HEAD>"
"<BIZ_SEQ_NO attr=\"s,256\"><bizSeqNo1><bizSeqNo2></BIZ_SEQ_NO>"
"<USER_ID attr=\"s,30\">EB001</USER_ID>"
"<BRANCH_ID attr=\"s,9\">0800</BRANCH_ID>"
"</APP_HEAD>"
"<LOCAL_HEAD>"
"</LOCAL_HEAD>"
"<BODY>"
"<PRIORITY_LEVEL attr=\"s,1\">0</PRIORITY_LEVEL>"
"<CHANNEL_DATE attr=\"s,8\">20160419</CHANNEL_DATE>"
"<PAYEE_NAME attr=\"s,120\">zhyi</PAYEE_NAME>" //张一
"<PAYEE_ACCT_NO attr=\"s,35\">6230580000074005047</PAYEE_ACCT_NO>"
"<VALIDATION_FLAG attr=\"s,20\">1</VALIDATION_FLAG>"
"<PAYMENT_MODE attr=\"s,3\">002</PAYMENT_MODE>"
"<TRAN_AMT attr=\"d,15,2\">0.01</TRAN_AMT>"
"<CHANNEL_TIME attr=\"s,6\">172102</CHANNEL_TIME>"
"<DEDUCT_ACCOUNT_BRANCH_ID attr=\"s,6\">0800</DEDUCT_ACCOUNT_BRANCH_ID>"
"<CHARGE_TYPE attr=\"s,2\">01</CHARGE_TYPE>"
"<CCY attr=\"s,3\">RMB</CCY>"
"<CHANNEL_SEQ_NO attr=\"s,30\"><channelSeqNo1><channelSeqNo2></CHANNEL_SEQ_NO>"
"<CHANNEL_TYPE attr=\"s,3\">107</CHANNEL_TYPE>"
"<COMMISSION_CCY attr=\"s,3\">RMB</COMMISSION_CCY>"
"<DEDUCT_ACCT_NO attr=\"s,35\"><acctNo></DEDUCT_ACCT_NO>"
"<DISCOUNT_PERCENT_CHAR attr=\"s,5\">10000</DISCOUNT_PERCENT_CHAR>"
"<CORPUS_USAGE attr=\"s,15\">EBK</CORPUS_USAGE>"
"<FLAG attr=\"s,1\">1</FLAG>"
"<USAGE attr=\"s,1\">0</USAGE>"
"<COMMISSION_OUT_ACCT_NO attr=\"s,35\"><acctNo></COMMISSION_OUT_ACCT_NO>"
"<FEE_CODE attr=\"s,10\">244</FEE_CODE>"
"<COMMISSION attr=\"d,15,2\">4.00</COMMISSION>"
"<PAYER_ACCT_NO attr=\"s,35\"><acctNo></PAYER_ACCT_NO>"
"<TRAN_TYPE attr=\"s,10\">02102</TRAN_TYPE>"
"<PAYER_NAME attr=\"s,120\">pinganzhinengshk</PAYER_NAME>" //平安测试智能收款
"<COMMISSION_IN_BRANCH_ID attr=\"s,6\">0800</COMMISSION_IN_BRANCH_ID>"
"<COMMISSION_USAGE attr=\"s,15\">FEE</COMMISSION_USAGE>"
"<REMARK_CODE attr=\"s,3\">WEB</REMARK_CODE>"
"<BUSS_TYPE attr=\"s,6\">A100</BUSS_TYPE>"
"<PAYEE_ACCT_OPEN_BRANCH_ID attr=\"s,14\">102100000030</PAYEE_ACCT_OPEN_BRANCH_ID>"
"<COMMISSION_OUT_BRANCH_ID attr=\"s,6\">0800</COMMISSION_OUT_BRANCH_ID>"
"<RECEIVE_BRANCH_ID attr=\"s,14\">102100000030</RECEIVE_BRANCH_ID>"
"<FEE_MODE attr=\"s,1\">0</FEE_MODE>"
"<BUSS_TYPE1 attr=\"s,5\">P2100</BUSS_TYPE1>"
"<ADD_MSG attr=\"s,300\">zhubik1</ADD_MSG>" //逐笔扣1
"<FEE_CHARGE_TYPE attr=\"s,1\">1</FEE_CHARGE_TYPE>"
"</BODY>"
"</service>"));
lr_log_message("strSend\t:%s",msgBody);
intSendLenght = strlen(msgBody);
itoa(intSendLenght,sRecvLen,10);
lr_output_message( "intSendLenght[%04d],%s", intSendLenght,sRecvLen);
strcat(strSend,"0000");
strcat(strSend,sRecvLen);
strcat(strSend,msgBody);
intSendLenght=strlen(strSend);
lr_output_message("strSend=%s",strSend);
sprintf( strSock, lr_eval_string( "SOCK<scikid>" ) );
//lr_output_message( "---sockid[%s]---", strSock );
rc=lrs_create_socket( strSock, "TCP", "RemoteHost=10.14.208.199:9101",LrsLastArg ); // 建立socket连接
if(rc!=0){
lr_output_message("Create socket 10.14.208.199:9101 Error, Error Code:%d", rc);
lr_fail_trans_with_error("Not Create Socket!!!\n");
goto END_TRANSACTION;
}
lrs_set_send_timeout( 10, 0 );
lrs_set_send_buffer( strSock, strSend, intSendLenght);
lr_start_transaction( "04_小额往账_01_往账" );
lrs_send( strSock, "buf0", LrsLastArg );
lrs_set_recv_timeout(10, 0);
lrs_set_recv_timeout2(1,0);
lrs_receive( strSock, "buf1", LrsLastArg );
lrs_save_searched_string(strSock,LRS_LAST_RECEIVED,"response_code","LB=<UPP_RET_STATUS_CODE attr=\"s,10\">","RB=</UPP_RET_STATUS_CODE>",1,0,-1);
//lr_output_message("response_code:%s",lr_eval_string("<response_code>"));
if (strcmp(lr_eval_string("<response_code>"),"000000")!=0) {
lr_fail_trans_with_error("Response_Packet retcode:%s ",lr_eval_string("<response_code>"));
}
END_TRANSACTION:
lr_end_transaction("04_小额往账_01_往账", LR_AUTO);
lrs_close_socket(strSock);
return 0;
}