SMSHandle.h 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. #ifndef _SMS_HANDLE_HEADER_
  2. #define _SMS_HANDLE_HEADER_
  3. #include "DBInterface.h"
  4. #include "CurlClient.h"
  5. #define MAX_NAME_LEN 64
  6. typedef struct _SEND_RESPONEINFO_
  7. {
  8. CString strSendStatus;
  9. CString strSendCount;
  10. CString strBalance;
  11. CString strErPhone;
  12. CString strSid;
  13. }ResponebySend, *pResponebySend;
  14. typedef struct _QUERYACCOUNTINFO_
  15. {
  16. CString strSendStatus;
  17. CString strAccount;
  18. CString strBalance;
  19. CString strSMSCharacterCount;
  20. CString strSignatures;
  21. CString strOwnedOperators;
  22. }QuerAccountInfo, *pQuerAccountInfo;
  23. #define VERIFYDATA(name,sex,birthday,today,lastfewdate,phone,check) \
  24. if(birthday.IsEmpty()) continue;\
  25. int nMonth = _ttoi(birthday.Mid(5,2));\
  26. int nDay = _ttoi(birthday.Mid(8,2));\
  27. if ( (nMonth >> 2) > 3 || (nDay >> 5) > 0 ) continue;\
  28. if(check == _T("1") )\
  29. birthday = LuanrToSolarDate(CTime::GetCurrentTime().GetYear(),_ttoi(birthday.Mid(5,2)), _ttoi(birthday.Mid(8,2)));\
  30. else\
  31. birthday.Format(_T("%04d-%02d-%02d"),CTime::GetCurrentTime().GetYear(),_ttoi(birthday.Mid(5,2)), _ttoi(birthday.Mid(8,2)));\
  32. COleDateTime Solar;\
  33. Solar.SetDateTime(_ttoi(birthday.Left(4)),_ttoi(birthday.Mid(5,2)),_ttoi(birthday.Mid(8,2)),0,0,0);\
  34. Solar -= Span;\
  35. lastfewdate.Format(_T("%04d-%02d-%02d"),Solar.GetYear(),Solar.GetMonth(),Solar.GetDay());\
  36. if ( today >= lastfewdate && today < birthday)\
  37. GenerateToSendreg(name,sex,phone,s_SMSInfo.msgContent1);
  38. #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));
  39. #pragma once
  40. class CSMSHandle
  41. {
  42. public:
  43. CSMSHandle();
  44. ~CSMSHandle();
  45. public:
  46. static SMSInfo s_SMSInfo; // 该成员应该受保存,防止意外修改;
  47. TCHAR m_szAccount[MAX_NAME_LEN]; // 短信账号;
  48. TCHAR m_szPassWord[MAX_NAME_LEN]; // 账号密码;
  49. DWORD m_dwblance; // 短信余额;
  50. ULONGLONG m_ulCountOfSended; // 已发送的短信条数;
  51. std::vector<SmsType> m_vtSMSTypeOfChild;
  52. std::vector<SmsType> m_vtSMSTypeOfWedding;
  53. CString CalculateFilter_Child();
  54. CString CalculateFilter_Wedding();
  55. CString GetHTTPErrorInf()
  56. {
  57. //return m_httpGet.GetErrorInfo();
  58. return _T("");
  59. }
  60. private:
  61. ThreadSection s_critSection;
  62. ThreadSection *ReturnSection() {
  63. return &s_critSection;
  64. }
  65. utilitySdk::CCurlClient m_url;
  66. INT_PTR SendSMS(LPCTSTR lpStringToSend, CONST INT &nIndex, CONST INT &nGroup, LPCTSTR lpAutoId);
  67. VOID QuerySMSStatus(LPCTSTR lpSid, LPCTSTR lpAutoId);
  68. void AnalyzeAccoutStatus(CString &strRespone); // 解析账号的返回状态值;
  69. INT AnalyzeSendStatus(LPBYTE lpRespone, ResponebySend &lRespone); // 解析发送的返回状态值;
  70. void AnalyzeQueryStatus(CString &strRespone); // 解析查询的返回状态值;
  71. // 应该非静态+const比较好,防止s_SMSInfo被意外修改;
  72. static void GenerateToSendreg( IN CONST CString &strName, IN CONST CString &strSex, IN CONST CString &strPhone, IN CString &strContent, IN CONST CString &strMsgtype);
  73. static BOOL IsValidDate(CONST CString &strDate, BOOL bThisyear = TRUE);
  74. public:
  75. void GetMainInfo(); // 获取主要信息;
  76. INT_PTR ReadySendSMS(CString& strPhones, CString& strContent, CString& strTime, CString& strAutoId);
  77. HANDLE m_hSendSMSThread;
  78. HANDLE m_hGenerateSMSThread;
  79. HANDLE m_hSendEvent;
  80. HANDLE m_hGenerateEvent;
  81. HANDLE m_hWaitableTime;
  82. static BOOL m_bGenerateEndof;
  83. static DWORD WINAPI SendSMSThread(LPVOID lpParam); // 发送短信的线程;
  84. static DWORD WINAPI GenerateSMSThread(LPVOID lpParam); // 生成短信线程;
  85. int StartThread();
  86. int EndofThread();
  87. BOOL GetSMSBlance(QuerAccountInfo &tAccountInfo);
  88. protected:
  89. // ---------------------------------------------------------------------------------------------------------------------------------------
  90. // 客户端有选择"一周"、"两周"、"三周"、"满月"至"十一月"、"一岁"至"三岁"。要在客户里自动将这些中文转为天数。
  91. // 短信类型msgtyped:
  92. // ==0,没有归类的短信;
  93. // == 1,生日短信;
  94. // == 2,百天或结婚纪念日短信;
  95. // == 15,结婚当天;
  96. // == 10000,儿童满n天;
  97. // == 20000,怀孕满n天;
  98. static BOOL VerifyCheck1(CONST CString &strMsgtype, CONST CString &strName, CONST CString &strSex, CONST CString &strPhone, CString strBirthday, CONST CString &strCheck);
  99. static BOOL VerifyCheck2(CONST CString &strMsgtype, CONST CString &strName, CONST CString &strSex, CONST CString &strPhone, CString strBirthday, CONST CString &strCheck);
  100. static BOOL VerifyCheck15(CONST CString &strMsgtype, CONST CString &strName, CONST CString &strSex, CONST CString &strPhone, CString strWiddingDay, CONST CString &strCheck);
  101. static BOOL VerifyHospitalCheck1(
  102. CONST CString &strMsgtype,
  103. CONST CString &strName,
  104. CONST CString &strDays, // 出生满_ttoi(strDays)天;
  105. CONST CString &strPhone,
  106. CString strContent,
  107. CString strBirthday,
  108. CONST CString &strCheck);
  109. static BOOL VerifyHospitalCheck2(
  110. CONST CString &strMsgtype,
  111. CONST CString &strName,
  112. CONST CString &strDays,
  113. CONST CString &strPhone,
  114. CString strContent,
  115. CString strOrderDate, // 订单日期;
  116. CString strPregnancyDate // 已怀孕天数;
  117. );
  118. public:
  119. // 儿童版本;
  120. static VOID CHandleDindanClient(CArray<CStringArray, CStringArray> *pArrayOfDindanClient, CArray<CStringArray, CStringArray> *pArrayOfChildMsg = NULL);
  121. static VOID CHandleClient2(CArray<CStringArray, CStringArray> *pArrayOfClien2, CArray<CStringArray, CStringArray> *pArrayOfChildMsg = NULL);
  122. static VOID CHandleClient3(CArray<CStringArray, CStringArray> *pArrayOfClien3, CArray<CStringArray, CStringArray> *pArrayOfChildMsg = NULL);
  123. static VOID CHandleHospitalClient(CArray<CStringArray, CStringArray> *pArrayOfHospitalClient, CArray<CStringArray, CStringArray> *pArrayOfChildMsg);
  124. // 婚纱版本;
  125. static VOID WHandleDindanClient(CArray<CStringArray, CStringArray> *pArrayOfDindanClient, CArray<CStringArray, CStringArray> *pArrayOfChildMsg = NULL);
  126. static VOID WHandleClient2(CArray<CStringArray, CStringArray> *pArrayOfClien2, CArray<CStringArray, CStringArray> *pArrayOfChildMsg = NULL);
  127. static VOID WHandleClient3(CArray<CStringArray, CStringArray> *pArrayOfClien3, CArray<CStringArray, CStringArray> *pArrayOfChildMsg = NULL);
  128. static VOID WHandleHospitalClient(CArray<CStringArray, CStringArray> *pArrayOfHospitalClient, CArray<CStringArray, CStringArray> *pArrayOfChildMsg);
  129. };
  130. #endif