123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- #ifndef _SMS_HANDLE_HEADER_
- #define _SMS_HANDLE_HEADER_
- #include "DBInterface.h"
- #include "HttpTransByGet.h"
- typedef struct _SEND_RESPONEINFO_
- {
- CString strSendStatus;
- CString strSendCount;
- CString strBalance;
- CString strErPhone;
- CString strSid;
- }ResponebySend, *pResponebySend;
- typedef struct _QUERYACCOUNTINFO_
- {
- CString strSendStatus;
- CString strAccount;
- CString strBalance;
- CString strSMSCharacterCount;
- CString strSignatures;
- CString strOwnedOperators;
- }QuerAccountInfo, *pQuerAccountInfo;
- #define VERIFYDATA(name,sex,birthday,today,lastfewdate,phone,check) \
- if(birthday.IsEmpty()) continue;\
- int nMonth = _ttoi(birthday.Mid(5,2));\
- int nDay = _ttoi(birthday.Mid(8,2));\
- if ( (nMonth >> 2) > 3 || (nDay >> 5) > 0 ) continue;\
- if(check == _T("1") )\
- birthday = LuanrToSolarDate(CTime::GetCurrentTime().GetYear(),_ttoi(birthday.Mid(5,2)), _ttoi(birthday.Mid(8,2)));\
- else\
- birthday.Format(_T("%04d-%02d-%02d"),CTime::GetCurrentTime().GetYear(),_ttoi(birthday.Mid(5,2)), _ttoi(birthday.Mid(8,2)));\
- COleDateTime Solar;\
- Solar.SetDateTime(_ttoi(birthday.Left(4)),_ttoi(birthday.Mid(5,2)),_ttoi(birthday.Mid(8,2)),0,0,0);\
- Solar -= Span;\
- lastfewdate.Format(_T("%04d-%02d-%02d"),Solar.GetYear(),Solar.GetMonth(),Solar.GetDay());\
- if ( today >= lastfewdate && today < birthday)\
- GenerateToSendreg(name,sex,phone,s_SMSInfo.msgContent1);
- #define VERIFYHOSPITALCHECK1(strArray,strChildMsgArray,a,b,c,d,e,f) VerifyHospitalCheck1(strArray.ElementAt(a),strChildMsgArray.ElementAt(b),strArray.ElementAt(c),strChildMsgArray.ElementAt(d),strArray.ElementAt(e),strArray.ElementAt(f));
- #pragma once
- class CSMSHandle
- {
- public:
- CSMSHandle();
- ~CSMSHandle();
- public:
- static SMSInfo s_SMSInfo; // 该成员应该受保存,防止意外修改;
- TCHAR m_szAccount[MAX_NAME_LEN]; // 短信账号;
- TCHAR m_szPassWord[MAX_NAME_LEN]; // 账号密码;
- DWORD m_dwblance; // 短信余额;
- ULONGLONG m_ulCountOfSended; // 已发送的短信条数;
- std::vector<SmsType> m_vtSMSTypeOfChild;
- std::vector<SmsType> m_vtSMSTypeOfWedding;
- CString CalculateFilter_Child();
- CString CalculateFilter_Wedding();
- CString GetHTTPErrorInf()
- {
- return m_httpGet.GetErrorInfo();
- }
- private:
- ThreadSection s_critSection;
- ThreadSection *ReturnSection() {
- return &s_critSection;
- }
- CHttpTransByGet m_httpGet;
- INT_PTR SendSMS(LPCTSTR lpStringToSend, CONST INT &nIndex, CONST INT &nGroup, LPCTSTR lpAutoId);
- VOID QuerySMSStatus(LPCTSTR lpSid, LPCTSTR lpAutoId);
- void UTF8ToWideChar(LPBYTE lpRespone, CString &strRespone);
- void UrlUTF8Decode(LPBYTE lpRespone, CString &strRespone);
- void AnalyzeAccoutStatus(CString &strRespone); // 解析账号的返回状态值;
- INT AnalyzeSendStatus(LPBYTE lpRespone, ResponebySend &lRespone); // 解析发送的返回状态值;
- void AnalyzeQueryStatus(CString &strRespone); // 解析查询的返回状态值;
- // 应该非静态+const比较好,防止s_SMSInfo被意外修改;
- static void GenerateToSendreg( IN CONST CString &strName, IN CONST CString &strSex, IN CONST CString &strPhone, IN CString &strContent, IN CONST CString &strMsgtype);
- static BOOL IsValidDate(CONST CString &strDate, BOOL bThisyear = TRUE);
- public:
- void GetMainInfo(); // 获取主要信息;
- INT_PTR ReadySendSMS(CString& strPhones, CString& strContent, CString& strTime, CString& strAutoId);
- HANDLE m_hSendSMSThread;
- HANDLE m_hGenerateSMSThread;
- HANDLE m_hSendEvent;
- HANDLE m_hGenerateEvent;
- HANDLE m_hWaitableTime;
- static BOOL m_bGenerateEndof;
- static DWORD WINAPI SendSMSThread(LPVOID lpParam); // 发送短信的线程;
- static DWORD WINAPI GenerateSMSThread(LPVOID lpParam); // 生成短信线程;
- int StartThread();
- int EndofThread();
- BOOL GetSMSBlance(QuerAccountInfo &tAccountInfo);
- protected:
- // ---------------------------------------------------------------------------------------------------------------------------------------
- // 客户端有选择"一周"、"两周"、"三周"、"满月"至"十一月"、"一岁"至"三岁"。要在客户里自动将这些中文转为天数。
- // 短信类型msgtyped:
- // ==0,没有归类的短信;
- // == 1,生日短信;
- // == 2,百天或结婚纪念日短信;
- // == 15,结婚当天;
- // == 10000,儿童满n天;
- // == 20000,怀孕满n天;
- static BOOL VerifyCheck1(CONST CString &strMsgtype, CONST CString &strName, CONST CString &strSex, CONST CString &strPhone, CString strBirthday, CONST CString &strCheck);
- static BOOL VerifyCheck2(CONST CString &strMsgtype, CONST CString &strName, CONST CString &strSex, CONST CString &strPhone, CString strBirthday, CONST CString &strCheck);
- static BOOL VerifyCheck15(CONST CString &strMsgtype, CONST CString &strName, CONST CString &strSex, CONST CString &strPhone, CString strWiddingDay, CONST CString &strCheck);
- static BOOL VerifyHospitalCheck1(
- CONST CString &strMsgtype,
- CONST CString &strName,
- CONST CString &strDays, // 出生满_ttoi(strDays)天;
- CONST CString &strPhone,
- CString strContent,
- CString strBirthday,
- CONST CString &strCheck);
- static BOOL VerifyHospitalCheck2(
- CONST CString &strMsgtype,
- CONST CString &strName,
- CONST CString &strDays,
- CONST CString &strPhone,
- CString strContent,
- CString strOrderDate, // 订单日期;
- CString strPregnancyDate // 已怀孕天数;
- );
- public:
- // 儿童版本;
- static VOID CHandleDindanClient(CArray<CStringArray, CStringArray> *pArrayOfDindanClient, CArray<CStringArray, CStringArray> *pArrayOfChildMsg = NULL);
- static VOID CHandleClient2(CArray<CStringArray, CStringArray> *pArrayOfClien2, CArray<CStringArray, CStringArray> *pArrayOfChildMsg = NULL);
- static VOID CHandleClient3(CArray<CStringArray, CStringArray> *pArrayOfClien3, CArray<CStringArray, CStringArray> *pArrayOfChildMsg = NULL);
- static VOID CHandleHospitalClient(CArray<CStringArray, CStringArray> *pArrayOfHospitalClient, CArray<CStringArray, CStringArray> *pArrayOfChildMsg);
- // 婚纱版本;
- static VOID WHandleDindanClient(CArray<CStringArray, CStringArray> *pArrayOfDindanClient, CArray<CStringArray, CStringArray> *pArrayOfChildMsg = NULL);
- static VOID WHandleClient2(CArray<CStringArray, CStringArray> *pArrayOfClien2, CArray<CStringArray, CStringArray> *pArrayOfChildMsg = NULL);
- static VOID WHandleClient3(CArray<CStringArray, CStringArray> *pArrayOfClien3, CArray<CStringArray, CStringArray> *pArrayOfChildMsg = NULL);
- static VOID WHandleHospitalClient(CArray<CStringArray, CStringArray> *pArrayOfHospitalClient, CArray<CStringArray, CStringArray> *pArrayOfChildMsg);
- };
- #endif
|