📄 send_all_mon.cpp
字号:
//本程序用于对所有包月用户进行包月扣费,参数有:号码文件名 业务代码 费用//发送格式:./send_all_mon 发送号码文件名 业务代码 费用(包月扣费,SEND表)#include <stdio.h>#include <string.h>#include <time.h>#include <stdlib.h>#include <sys/types.h>#include <sys/stat.h>#include <unistd.h>#include "../include/define.h"#include "../include/CMPPAPI.hpp"#include "mysql/mysql.h"#include "../include/sm_tools.h"#include "../include/sm_db.h"#define INIFILE "../config/sm.ini"char db_host[100],db_user[100],db_passwd[100],db_dbname[100];MYSQL *myconn;static int InitPara(){ myconn = NULL; GetProfileString(INIFILE,"DB_LOCAL","HOST","localhost",db_host); GetProfileString(INIFILE,"DB_LOCAL","LOGNAME","root",db_user); GetProfileString(INIFILE,"DB_LOCAL","LOGPASS","",db_passwd); GetProfileString(INIFILE,"DB_LOCAL","DBNAME","NW_SM",db_dbname); return 0;}int main(int argc,char *argv[]){ char *day; FILE *fp; char filename[100],sv_code[100]; double fee; char msisdn[30]; int i; SEND_STRUC sendstruc; InitPara(); puts(db_dbname); if(argc<4) { printf("格式:%s 发送号码文件名 业务代码 费用(包月扣费,SEND表)\n",argv[0]); return 0; } else { strcpy(filename,argv[1]); strcpy(sv_code,argv[2]); fee = atof(argv[3]); } memset(&sendstruc,0,sizeof(sendstruc)); sendstruc.nNeedReply = 2; sendstruc.nMsgLevel = 8; strcpy(sendstruc.sServiceID,sv_code); sendstruc.nMsgFormat = 15; strcpy(sendstruc.sFeeType,"03"); sendstruc.sFeeCode = fee; strcpy(sendstruc.sValidTime,""); strcpy(sendstruc.sAtTime,""); strcpy(sendstruc.sSrcTermID,"8566"); sendstruc.cFeeUserType=0; strcpy(sendstruc.sFeeTerminalID,""); sendstruc.cTpPid = 0; sendstruc.cTpUdhi = 0; strcpy(sendstruc.step,"0"); day = getnowdate(sendstruc.Send_Date); strcpy(sendstruc.sMsgContent,"aaaa"); fp = fopen(filename,"r"); if(fp == NULL) { puts("open file error!"); return 0; } myconn = dbconnect(db_host,db_user,db_passwd,db_dbname); if(myconn == NULL) { puts("连接数据库失败,请查看日志文件!"); return 0; } i=0; while(fgets(msisdn,30,fp)!=NULL) { msisdn[11] = '\0'; if(strncmp(msisdn,"13",2)!=0 || strlen(msisdn) != 11) continue; strcpy(sendstruc.sDesTermID,msisdn); SendMsg(&sendstruc,&myconn); i++; } fclose(fp); printf("you have send %d records\n",i); return 0; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -