123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- #include "stdafx.h"
- #include "mainCtrl.h"
- #include "mysqldata.h"
- #include "LYFZSendMsg.h"
- extern CString g_mainpath;
- extern CDatabase g_db;
- CStringArray g_baduserarray;
- int CheckPhoneType(CString phoneno)
- {
- int i;
- if(phoneno.IsEmpty ())return -1;
- for( i=0; i<phoneno.GetLength (); i++)
- {
- if(phoneno.GetAt (i)<'0'||phoneno.GetAt (i)>'9')return -1;
- }
- if(phoneno.GetAt (0)=='1')
- {
- if(phoneno.GetLength ()!=11)
- return -1;
- int mobile[]={139,138,137,136,135,134,159,158,152,151,150,157,188,187,144,182,147,183,184,178};
- int unicom[]={130,131,132,155,156,186,185,176};
- int telecom[]={133,153,189,180,181,177};
- for(i=0; i<sizeof(mobile)/sizeof(int); i++)
- {
- if(mobile[i]==atoi(phoneno.Left (3)))
- {
- return 0;
- }
- }
- for(i=0; i<sizeof(unicom)/sizeof(int); i++)
- {
- if(unicom[i]==atoi(phoneno.Left (3)))
- {
- return 1;
- }
- }
- for(i=0; i<sizeof(telecom)/sizeof(int); i++)
- {
- if(telecom[i]==atoi(phoneno.Left (3)))
- {
- return 2;
- }
- }
- return -1;
- }
-
- return -1;
- }
- int GetCount(CString phones, CString content)
- {
-
- int nNumberOfTextMsg = 0;
- int nWCharLen = ::MultiByteToWideChar(CP_ACP,0,content,-1,NULL,0);
-
-
-
-
-
- nNumberOfTextMsg = nWCharLen / 67;
- if (nWCharLen % 67 > 2 ) ++nNumberOfTextMsg;
-
- int nCountOfMobile = 0;
- int nIndex = 0;
- do
- {
- nIndex = phones.Find(",");
- if (nIndex != -1)
- {
- if ( nIndex == 11 && CheckPhoneType(phones.Left(nIndex)) != -1)
- ++nCountOfMobile;
- phones = phones.Mid(nIndex+1);
- }
- else
- {
- if ( phones.GetLength() == 11 && CheckPhoneType(phones) != -1)
- ++nCountOfMobile;
- }
- } while (nIndex != -1);
- return nNumberOfTextMsg *= nCountOfMobile;
- }
- int GetBalance(CString account)
- {
- CString count1="";
- CString count2="";
- CString count3="";
- try
- {
- CRecordset myset(&g_db);
- #ifdef SQLSERVER_VERSION
- CString sql="select sum(cast([count] as float)) as cot from recharge where account='"+account+"'";
- #else
- CString sql="select sum([count]) as cot from recharge where account='"+account+"'";
- #endif
- myset.Open (CRecordset::forwardOnly, sql);
- if(!myset.IsEOF())
- myset.GetFieldValue ("cot", count1);
- myset.Close();
- #ifdef SQLSERVER_VERSION
- sql="select sum(cast([msgcount] as float)) as cot from sendreg where account='"+account+"'";
- #else
- sql="select sum([msgcount]) as cot from sendreg where account='"+account+"'";
- #endif
- myset.Open (CRecordset::forwardOnly, sql);
- if(!myset.IsEOF())
- myset.GetFieldValue ("cot", count2);
- myset.Close();
- #ifdef SQLSERVER_VERSION
- sql="select sum(cast([msgcount2] as float)) as cot from sendreg where account='"+account+"'";
- #else
- sql="select sum([msgcount2]) as cot from sendreg where account='"+account+"'";
- #endif
- myset.Open (CRecordset::forwardOnly, sql);
- if(!myset.IsEOF())
- myset.GetFieldValue ("cot", count3);
- myset.Close();
- return atoi(count1)-atoi(count2);
- }
- catch(...)
- {
- return -1;
- }
- }
- BOOL g_bWork=0;
|