⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 0000thread.cpp

📁 关于联通的一个统一定制程序
💻 CPP
📖 第 1 页 / 共 2 页
字号:

	if(!Is1860Allowed(pInfo->szDestMobile))
	{
		theData.SetMsg2(&m_Db,pInfo,"00000_1860_operation_not_allowed", NULL, &m_Info);
		return;
	}

	strSubId.Replace("+"," ");
	// 获取用户手机号码
	strClientPhone=strSubId.Mid(4);
	strClientPhone.TrimLeft();strClientPhone.TrimRight();

/*	if(strClientPhone.GetLength()!=11)
	{
		// 手机号码长度不是11位
		strTemp.Format("您提供的手机号码%s不足11位,请确认以后重试。",strClientPhone);
		SetMsg(pInfo,strTemp,0);
		theData.AddOneSendMsg(pInfo);

		return;
	}*/
	vector<SUBSCRIBEITEM> items;
	vector<SUBSCRIBEITEM>::iterator it;
	list <pair<CString,CString> > ReplaceStrings ;
	pair<CString,CString> ReplaceString ;
		
	int iRet=m_Db.GetUserCustomList(strClientPhone,strList,strMsg);		
	switch(iRet)
	{
	case 0:
		if(ParseSubscribeItem(strList,items)>0)
		{
			//strMsg="回复Q+序号,取消相应的服务(如要取消第三项服务则只需直接回复:Q3):\n0 取消所有定制";
			for(it=items.begin();it!=items.end();it++)
			{
				if(strMsg.IsEmpty())
					strTemp.Format("%d %s",(*it).lIndex,(*it).pszColName);
				else
					strTemp.Format("\n%d %s",(*it).lIndex,(*it).pszColName);

				strMsg+=strTemp;
				if(strMsg.GetLength()>90)
				{
					strSrcTermId.Format("18180%s",strClientPhone);
					strcpy(pInfo->szSrcTermID,strSrcTermId);
					SetMsg(pInfo,strMsg,0);
					theData.AddOneSendMsg(pInfo);
					strMsg="";

					continue;
				}
			}
			if(!strMsg.IsEmpty())
			{
				strSrcTermId.Format("18180%s",strClientPhone);
				strcpy(pInfo->szSrcTermID,strSrcTermId);
				SetMsg(pInfo,strMsg,0);
				theData.AddOneSendMsg(pInfo);
			}
			theData.m_UserCustoms.AddOneInfo(strClientPhone,items);
		}
		else
		{
			ReplaceString.first = "{CLIENTPHONE}";
			ReplaceString.second= strClientPhone;
			ReplaceStrings.push_back(ReplaceString);
			theData.SetMsg2(&m_Db,pInfo,"0000_1860_user_have_no_subscribe",&ReplaceStrings, &m_Info);
		}
		break;
	case -7:
		{
			ReplaceString.first = "{CLIENTPHONE}";
			ReplaceString.second= strClientPhone;
			ReplaceStrings.push_back(ReplaceString);
			theData.SetMsg2(&m_Db,pInfo,"0000_1860_user_not_registered",&ReplaceStrings, &m_Info);
		}
		break;
	case -8:
		{
			ReplaceString.first = "{CLIENTPHONE}";
			ReplaceString.second= strClientPhone;
			ReplaceStrings.push_back(ReplaceString);
			theData.SetMsg2(&m_Db,pInfo,"0000_1860_user_unregistered_before",&ReplaceStrings, &m_Info);
		}
		break;
	default:
		{
			ReplaceString.first = "{CLIENTPHONE}";
			ReplaceString.second= strClientPhone;
			ReplaceStrings.push_back(ReplaceString);
			theData.SetMsg2(&m_Db,pInfo,"0000_1860_unable_get_users_config",&ReplaceStrings, &m_Info);
		}
		break;
	}
}

void C0000Thread::H1860_00000(IOD_Info *pInfo)
{
	CString strMsg1,strMsg2,strTemp,strSubId(pInfo->szSubID),strClientPhone;

	if(!Is1860Allowed(pInfo->szDestMobile))
	{
		theData.SetMsg2(&m_Db,pInfo,"00000_1860_operation_not_allowed", NULL, &m_Info);				
		return;	
	}

	strSubId.Replace("+"," ");
	// 获取用户手机号码
	strClientPhone=strSubId.Mid(5);
	strClientPhone.TrimLeft();strClientPhone.TrimRight();

/*	if(strClientPhone.GetLength()!=11)
	{
		// 手机号码长度不是11位
		strTemp.Format("您提供的手机号码%s不足11位,请确认以后重试。",strClientPhone);
		SetMsg(pInfo,strTemp,0);
		theData.AddOneSendMsg(pInfo);

		return;
	}
	*/
	OUTPUTMSGLIST mmlist;		// misc msg
	list<OUTPUTMSG>::iterator mm;
	int iRet=m_Db.CancelAll(strClientPhone,&mmlist);
	
	list <pair<CString,CString> > ReplaceStrings ;
	pair<CString,CString> ReplaceString ;
	ReplaceString.first = "{CLIENTPHONE}" ;		
	ReplaceString.second= strClientPhone;			
	ReplaceStrings.push_back(ReplaceString);	
	switch(iRet)
	{
	case 0:	// 成功		
		theData.SetMsg2(&m_Db,pInfo,"00000_1860_succ_to_1860",&ReplaceStrings, &m_Info);				
		strcpy(pInfo->szDestMobile,strClientPhone);
		theData.SetMsg2(&m_Db,pInfo,"00000_1860_succ_to_user",&ReplaceStrings, &m_Info);						
		// MISC
		for (mm=mmlist.begin(); mm!=mmlist.end(); ++mm)
		{
		//	if ((*mm).szFeeType.CompareNoCase("09")==0)
			theData.SetMsg(pInfo, (*mm).szMsg, (*mm).szSendNo, (*mm).szSubID, (*mm).szFeeCode, (*mm).szFeeType, (*mm).nMsgType, &m_Info);
		}
		break;
	case -6:// 没有定制栏目
		theData.SetMsg2(&m_Db,pInfo,"00000_1860_user_have_no_subscribe",&ReplaceStrings, &m_Info);				
		break;
	case -7:// 该用户不存在
		theData.SetMsg2(&m_Db,pInfo,"00000_1860_user_not_registered",&ReplaceStrings, &m_Info);				
		break;
	case -8:// 已经取消过了
		theData.SetMsg2(&m_Db,pInfo,"00000_1860_user_unregistered_before",&ReplaceStrings, &m_Info);				
		break;
	default:
		theData.SetMsg2(&m_Db,pInfo,"00000_1860_failed",&ReplaceStrings, &m_Info);				
		break;
	}
}

void C0000Thread::H1860_00000(IOD_Info *pInfo, LPCTSTR pszClientPhone)
{
	CString strMsg1,strMsg2,strTemp,strSubId(pInfo->szSubID),strClientPhone(pszClientPhone);

	if(!Is1860Allowed(pInfo->szDestMobile))
	{
		theData.SetMsg2(&m_Db,pInfo,"00000_1860_operation_not_allowed", NULL, &m_Info);
		return;	
	}

	OUTPUTMSGLIST mmlist;		// misc msg
	list<OUTPUTMSG>::iterator mm;
	int iRet=m_Db.CancelAll(strClientPhone,&mmlist);
	
	list <pair<CString,CString> > ReplaceStrings ;
	pair<CString,CString> ReplaceString ;
	ReplaceString.first = "{CLIENTPHONE}" ;		
	ReplaceString.second= strClientPhone;			
	ReplaceStrings.push_back(ReplaceString);
	switch(iRet)
	{
	case 0:	// 成功						
		theData.SetMsg2(&m_Db,pInfo,"00000_1860_succ_to_1860",&ReplaceStrings, &m_Info);		
		strcpy(pInfo->szDestMobile,strClientPhone);
		theData.SetMsg2(&m_Db,pInfo,"00000_1860_succ_to_user",&ReplaceStrings, &m_Info);
		// MISC
		
		for (mm=mmlist.begin(); mm!=mmlist.end(); ++mm)
		{
		//	if ((*mm).szFeeType.CompareNoCase("09")==0)
				theData.SetMsg(pInfo, (*mm).szMsg, (*mm).szSendNo, (*mm).szSubID, (*mm).szFeeCode, (*mm).szFeeType, (*mm).nMsgType, &m_Info);
		}
		break;
	case -6:// 没有定制栏目
		theData.SetMsg2(&m_Db,pInfo,"00000_1860_user_have_no_subscribe",&ReplaceStrings, &m_Info);		
		break;
	case -7:// 该用户不存在
		theData.SetMsg2(&m_Db,pInfo,"00000_1860_user_not_registered",&ReplaceStrings, &m_Info);		
		break;
	case -8:// 已经取消过了
		theData.SetMsg2(&m_Db,pInfo,"00000_1860_user_unregistered_before",&ReplaceStrings, &m_Info);		
		break;
	default:
		theData.SetMsg2(&m_Db,pInfo,"00000_1860_failed",&ReplaceStrings, &m_Info);		
		break;
	}
}

void C0000Thread::H1860_571_0000(IOD_Info *pInfo)
{
	// 返回1860用户定制列表,系根据浙江移动要求提供,
	// 返回不带数字编码的菜单
	CString strList,strClientPhone,strSubId(pInfo->szSubID),strTemp,strSrcTermId,strMsg;
	
	if(!Is1860Allowed(pInfo->szDestMobile))
	{
		theData.SetMsg2(&m_Db,pInfo,"00000_1860_operation_not_allowed", NULL, &m_Info);		
		return;	
	}

	strSubId.Replace("+"," ");
	// 获取用户手机号码
	strClientPhone=strSubId.Mid(4);
	strClientPhone.TrimLeft();strClientPhone.TrimRight();

//	if(strClientPhone.GetLength()!=11)
//	{
//		// 手机号码长度不是11位
//		strTemp.Format("您提供的手机号码%s不足11位,请确认以后重试。",strClientPhone);
//		SetMsg(pInfo,strTemp,0);
//		theData.AddOneSendMsg(pInfo);
//
//		return;
//	}
	vector<SUBSCRIBEITEM> items;
	vector<SUBSCRIBEITEM>::iterator it;
	CString stTemp;
	int iRet=m_Db.GetUserCustomList(strClientPhone,strList,stTemp);
	list <pair<CString,CString> > ReplaceStrings ;
	pair<CString,CString> ReplaceString ;
	ReplaceString.first = "{CLIENTPHONE}" ;		
	ReplaceString.second= strClientPhone;			
	ReplaceStrings.push_back(ReplaceString);
	switch(iRet)
	{
	case 0:
		if(ParseSubscribeItem(strList,items)>0)
		{
			strMsg.Format("回复 QX+序号+%s,将代用户%s取消所定购的服务:\n0 取消所有定制",strClientPhone,strClientPhone);			
			for(it=items.begin();it!=items.end();it++)
			{					
				if(strMsg.IsEmpty())
					strTemp.Format("%d %s",(*it).lIndex,(*it).pszColName);
				else
					strTemp.Format("\n%d %s",(*it).lIndex,(*it).pszColName);
				
				strMsg+=strTemp;
				if(strMsg.GetLength()>90)
				{	
					strcpy(pInfo->szSrcTermID,"1818");					
					SetMsg(pInfo,strMsg,0);
					theData.AddOneSendMsg(pInfo);
					strMsg="";

					continue;
				}
			}
			if(!strMsg.IsEmpty())
			{				
				strcpy(pInfo->szSrcTermID,"1818");					
				SetMsg(pInfo,strMsg,0);
				theData.AddOneSendMsg(pInfo);
			}
			theData.m_UserCustoms.AddOneInfo(strClientPhone,items);
		}			
		else
			theData.SetMsg2(&m_Db,pInfo,"0000_1860_user_have_no_subscribe",&ReplaceStrings, &m_Info);
		break;
	case -7:
		theData.SetMsg2(&m_Db,pInfo,"0000_1860_user_not_registered",&ReplaceStrings, &m_Info);		
		break;
	case -8:
		theData.SetMsg2(&m_Db,pInfo,"0000_1860_user_unregistered_before",&ReplaceStrings, &m_Info);		
		break;
	default:
		theData.SetMsg2(&m_Db,pInfo,"0000_1860_unable_get_users_config",&ReplaceStrings, &m_Info);				
		break;
	}
}

void C0000Thread::H1860_QX(IOD_Info *pInfo, LPCTSTR pszClientPhone, UINT uId)
{
	CString strMsg,strTemp;

	if(!Is1860Allowed(pInfo->szDestMobile))
	{
		theData.SetMsg2(&m_Db,pInfo,"00000_1860_operation_not_allowed", NULL, &m_Info);
		return;	
	}

	//取消指定定制
	SUBSCRIBEITEM item;
	int iRet;
	OUTPUTMSGLIST mmlist;		// misc msg
	list<OUTPUTMSG>::iterator mm;
	if(theData.m_UserCustoms.GetMyCustomItemByIndex(pszClientPhone,uId,item)>0)		
		iRet=m_Db.CancelOneSubscribeByCode(pszClientPhone,item.pszPushType,item.lCustomNo,item.pszColName,item.pszTypeCode,item.lType,&mmlist);
	else 
		iRet=-9;
	list <pair<CString,CString> > ReplaceStrings ;
	pair<CString,CString> ReplaceString ;
	ReplaceString.first = "{CLIENTPHONE}" ;		
	ReplaceString.second= pszClientPhone;			
	ReplaceStrings.push_back(ReplaceString);
	ReplaceString.first = "{ITEMNAME}" ;		
	ReplaceString.second= item.pszColName;			
	ReplaceStrings.push_back(ReplaceString);
	ReplaceString.first = "{MCCPHONE}" ;		
	ReplaceString.second= "1818";			
	ReplaceStrings.push_back(ReplaceString);
	switch(iRet)
	{
	case 0:	// 成功				
		theData.SetMsg2(&m_Db,pInfo,"00000_1860_qx_succ_to_1860",&ReplaceStrings, &m_Info);
		strcpy(pInfo->szDestMobile,pszClientPhone);
		theData.SetMsg2(&m_Db,pInfo,"00000_1860_qx_succ_to_user",&ReplaceStrings, &m_Info);		
		theData.m_UserCustoms.RemoveOneItem(pszClientPhone,uId);
		// MISC
		
		for (mm=mmlist.begin(); mm!=mmlist.end(); ++mm)
		{
		//	if ((*mm).szFeeType.CompareNoCase("09")==0)
				theData.SetMsg(pInfo, (*mm).szMsg, (*mm).szSendNo, (*mm).szSubID, (*mm).szFeeCode, (*mm).szFeeType, (*mm).nMsgType, &m_Info);
		}
		break;			
	case -6:
	case -3:// 已经取消过了
		theData.SetMsg2(&m_Db,pInfo,"00000_qx_canceled_before",&ReplaceStrings, &m_Info);		
		break;
	case -4:
	case -9:
		theData.SetMsg2(&m_Db,pInfo,"00000_qx_wrong_index", NULL, &m_Info);		
		break;
	default:
		theData.SetMsg2(&m_Db,pInfo,"00000_qx_failed", NULL, &m_Info);		
		break;
	}
}

void C0000Thread::H_QX(IOD_Info *pInfo, UINT uId/*取消定制的索引编号*/)
{
	//取消指定定制
	int iRet;
	SUBSCRIBEITEM item;
	OUTPUTMSGLIST mmlist;		// misc msg
	list<OUTPUTMSG>::iterator mm;
	if(theData.m_UserCustoms.GetMyCustomItemByIndex(pInfo->szDestMobile,uId,item)>0)
		iRet=m_Db.CancelOneSubscribeByCode(pInfo->szDestMobile,item.pszPushType,item.lCustomNo,item.pszColName,item.pszTypeCode,item.lType,&mmlist);
	else 
		iRet=-9;
	list <pair<CString,CString> > ReplaceStrings;
	pair<CString,CString> ReplaceString;
	ReplaceString.first = "{ITEMNAME}";
	ReplaceString.second= item.pszColName;
	ReplaceStrings.push_back(ReplaceString);
	ReplaceString.first = "{MCCPHONE}";	
	ReplaceString.second= "1818";		
	ReplaceStrings.push_back(ReplaceString);
	switch (iRet)
	{
	case 0:	// 成功		
		theData.SetMsg2(&m_Db,pInfo,"00000_qx_succ",&ReplaceStrings, &m_Info);
		theData.m_UserCustoms.RemoveOneItem(pInfo->szDestMobile,uId);
		// MISC
		for (mm=mmlist.begin(); mm!=mmlist.end(); ++mm)
		{
		//	if ((*mm).szFeeType.CompareNoCase("09")==0)
			theData.SetMsg(pInfo, (*mm).szMsg, (*mm).szSendNo, (*mm).szSubID, (*mm).szFeeCode, (*mm).szFeeType, (*mm).nMsgType, &m_Info);
		}
		break;
	case -6:
	case -3:// 已经取消过了
		theData.SetMsg2(&m_Db,pInfo,"00000_qx_canceled_before",&ReplaceStrings, &m_Info);
		break;
	case -4:
	case -9:
		theData.SetMsg2(&m_Db,pInfo,"00000_qx_wrong_index", NULL, &m_Info);
		break;
	default:
		theData.SetMsg2(&m_Db,pInfo,"00000_qx_failed", NULL, &m_Info);
		break;
	}
}

void C0000Thread::SetMsg(IOD_Info* pInfo, LPCTSTR pszContent, int nType)
{
	CString strLog;
	// 提取数据库中定义的计费信息
 	pInfo->lMsgFmt = 15;
 	lstrcpy(pInfo->szContent, pszContent); // 返回信息
 	pInfo->lMsgLen = lstrlen(pInfo->szContent); //信息程度

	CServiceInfo::SERVICEINFO si;
	si.szGWID=pInfo->szSrcGWID;
	si.nType=5;//iod
	si.szService="CWXXI00000";
	si.szFeeCode="0";
	si.szFeeType="00";
	if (0!=g_ServiceInfo.GetServiceInfo(&si))
	{
		si.szGWID.Empty();
		g_ServiceInfo.GetServiceInfo(&si);
	}
	lstrcpy(pInfo->szSubID, si.szService);
	lstrcpy(pInfo->szFeeType, si.szFeeType);
	lstrcpy(pInfo->szFeeCode, si.szFeeCode);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -