-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgramForError.cs
136 lines (122 loc) · 4.92 KB
/
ProgramForError.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Models.WX.MessageModel.PreviewMessage;
using Models.WX.MessageModel.TemplateMessage;
using Models.ShortMessage;
namespace WXRobot
{
public partial class Program
{
/// <summary>
/// 判断是否为无效的推送号。
/// </summary>
/// <param name="sendWXPreviewMessageResponseModel"></param>
/// <returns></returns>
private static bool IsInvalidPushNo(SendWXPreviewMessageResponseModel sendWXPreviewMessageResponseModel)
{
var isInvalidPushNo = false;
if (sendWXPreviewMessageResponseModel == null ||
sendWXPreviewMessageResponseModel.Ret == 64501 ||
sendWXPreviewMessageResponseModel.Ret == 64502 ||
sendWXPreviewMessageResponseModel.Ret == 64503 ||
sendWXPreviewMessageResponseModel.Ret == 10703 ||
sendWXPreviewMessageResponseModel.Ret == -20000 ||
sendWXPreviewMessageResponseModel.Ret == -2 ||
sendWXPreviewMessageResponseModel.Ret == -1
)
{
isInvalidPushNo = true;
}
return isInvalidPushNo;
}
/// <summary>
/// 判断是否为无效的推送号(模板消息openID)。
/// </summary>
/// <param name="sendWXPreviewMessageResponseModel">
///40003:invalid openid
///40036:invalid template_id size
///40037:invalid template_id
///47001:data format error
///</param>
/// <returns></returns>
private static bool IsInvalidPushNoForOpenID(SendWXTemplateMessageResponseModel sendWXTemplateMessageResponseModel)
{
var isInvalidPushNo = false;
if (sendWXPreviewMessageResponseModel == null ||
sendWXTemplateMessageResponseModel.ErrCode == 40003 ||
sendWXTemplateMessageResponseModel.ErrCode == 40036 ||
sendWXTemplateMessageResponseModel.ErrCode == 40037 ||
sendWXTemplateMessageResponseModel.ErrCode == 47001 ||
sendWXTemplateMessageResponseModel.ErrCode == -1
)
{
isInvalidPushNo = true;
}
return isInvalidPushNo;
}
/// <summary>
/// 判断是否为无效的推送号(短信消息mobile)。
/// </summary>
/// <param name="returnCode">
/// 30:密码错误
///40:账号不存在
///41:余额不足
///42:帐号过期
///43:IP地址限制
///50:内容含有敏感词
///51:手机号码不正确
///</param>
/// <returns></returns>
private static bool IsInvalidPushNoForMobile(ShortMessageResponseModel shortMessageResponseModel)
{
var isInvalidPushNo = false;
if (shortMessageResponseModel == null ||
shortMessageResponseModel.ReturnCode == -1 ||
shortMessageResponseModel.ReturnCode == 30 ||
shortMessageResponseModel.ReturnCode == 40 ||
shortMessageResponseModel.ReturnCode == 42 ||
shortMessageResponseModel.ReturnCode == 50 ||
shortMessageResponseModel.ReturnCode == 51
)
{
isInvalidPushNo = true;
}
return isInvalidPushNo;
}
/// <summary>
/// 定制短信错误消息
/// </summary>
/// <param name="shortMessageResponseModel"></param>
/// <returns></returns>
private static ShortMessageResponseModel ErrorShorMessages(ShortMessageResponseModel shortMessageResponseModel)
{
ShortMessageResponseModel shorMessageModel = new ShortMessageResponseModel();
shorMessageModel.ReturnCode = shortMessageResponseModel.ReturnCode;
switch (shorMessageModel.ReturnCode)
{
case 30: shorMessageModel.ReturnMsg = "密码错误";
break;
case 40: shorMessageModel.ReturnMsg = "账号不存在";
break;
case 41: shorMessageModel.ReturnMsg = "余额不足";
break;
case 42: shorMessageModel.ReturnMsg = "帐号过期";
break;
case 43: shorMessageModel.ReturnMsg = "IP地址限制";
break;
case 50: shorMessageModel.ReturnMsg = "内容含有敏感词";
break;
case 51:
case -1: shorMessageModel.ReturnMsg = "手机号码不正确";
break;
default:
shorMessageModel.ReturnMsg = "其他情况错误";
break;
}
return shorMessageModel;
}
}
}