1
|
package com.yohoufo.order.common;
|
1
|
package com.yohoufo.order.common;
|
2
|
|
2
|
|
|
|
3
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
4
|
+
|
3
|
public enum InviterType {
|
5
|
public enum InviterType {
|
4
|
STORED_SELLER(1, "UFO", "入驻商家"),
|
6
|
STORED_SELLER(1, "UFO", "入驻商家"),
|
5
|
CLASS_B_AGENT(2, "NB", "一级代理");
|
7
|
CLASS_B_AGENT(2, "NB", "一级代理");
|
|
@@ -10,6 +12,13 @@ public enum InviterType { |
|
@@ -10,6 +12,13 @@ public enum InviterType { |
10
|
|
12
|
|
11
|
private String name;
|
13
|
private String name;
|
12
|
|
14
|
|
|
|
15
|
+ // 邀请码数字部分
|
|
|
16
|
+ private String value;
|
|
|
17
|
+
|
|
|
18
|
+ public void setValue(String value) {
|
|
|
19
|
+ this.value = value;
|
|
|
20
|
+ }
|
|
|
21
|
+
|
13
|
public int getType() {
|
22
|
public int getType() {
|
14
|
return type;
|
23
|
return type;
|
15
|
}
|
24
|
}
|
|
@@ -36,7 +45,7 @@ public enum InviterType { |
|
@@ -36,7 +45,7 @@ public enum InviterType { |
36
|
public static InviterType getInviteType(String inputInviteCode){
|
45
|
public static InviterType getInviteType(String inputInviteCode){
|
37
|
InviterType inviterType = null;
|
46
|
InviterType inviterType = null;
|
38
|
for (InviterType item : values()){
|
47
|
for (InviterType item : values()){
|
39
|
- if (inputInviteCode.startsWith(item.getAlphabet())){
|
48
|
+ if (StringUtils.startsWithIgnoreCase(inputInviteCode, item.getAlphabet())){
|
40
|
inviterType = item;
|
49
|
inviterType = item;
|
41
|
break;
|
50
|
break;
|
42
|
}
|
51
|
}
|
|
@@ -46,8 +55,9 @@ public enum InviterType { |
|
@@ -46,8 +55,9 @@ public enum InviterType { |
46
|
return null;
|
55
|
return null;
|
47
|
}
|
56
|
}
|
48
|
|
57
|
|
49
|
- String digit = inputInviteCode.replaceFirst(inviterType.getAlphabet(),"");
|
58
|
+ String digit = StringUtils.removeStartIgnoreCase(inputInviteCode, inviterType.getAlphabet());
|
50
|
if (digit.matches("\\d+")){
|
59
|
if (digit.matches("\\d+")){
|
|
|
60
|
+ inviterType.setValue(digit);
|
51
|
return inviterType;
|
61
|
return inviterType;
|
52
|
}
|
62
|
}
|
53
|
|
63
|
|