Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
cloud-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
youjj
cloud-platform
Commits
08bd636b
Commit
08bd636b
authored
Jul 20, 2019
by
hezhen
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'base-modify' of
http://113.105.137.151:22280/youjj/cloud-platform
into base-modify
parents
adf8b28e
ebb24eac
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
248 additions
and
1 deletion
+248
-1
ReferralCodeUtil.java
...github/wxiaoqi/security/common/util/ReferralCodeUtil.java
+247
-0
ActivityPopularizeBiz.java
...com/xxfc/platform/activity/biz/ActivityPopularizeBiz.java
+1
-1
No files found.
ace-common/src/main/java/com/github/wxiaoqi/security/common/util/ReferralCodeUtil.java
0 → 100644
View file @
08bd636b
package
com
.
github
.
wxiaoqi
.
security
.
common
.
util
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Set
;
public
class
ReferralCodeUtil
{
//验证码长度
private
static
final
int
LEN
=
6
;
//验证码字符初始列表
private
static
final
char
STUFFS
[]
=
{
'E'
,
'5'
,
'F'
,
'C'
,
'D'
,
'G'
,
'3'
,
'H'
,
'Q'
,
'A'
,
'4'
,
'B'
,
'1'
,
'N'
,
'P'
,
'I'
,
'J'
,
'2'
,
'R'
,
'S'
,
'T'
,
'U'
,
'V'
,
'6'
,
'7'
,
'M'
,
'W'
,
'X'
,
'8'
,
'K'
,
'L'
,
'Y'
};
private
static
final
int
PERMUTATION
;
private
static
final
int
MAX_COMBINATION
;
private
static
char
[]
_stuffs
=
STUFFS
;
static
{
PERMUTATION
=
permutation
(
LEN
);
MAX_COMBINATION
=
combination
(
_stuffs
.
length
,
LEN
);
}
// public static void resetStuffs() {
// int length = STUFFS.length;
// char[] stuffs = new char[length];
// for (int i = 0; i < length; ++i) {
// stuffs[i] = STUFFS[i];
// }
// Random random = new Random();
// for (int i = 0; i < length; i++) {
// int p = random.nextInt(length);
// char tmp = stuffs[i];
// stuffs[i] = stuffs[p];
// stuffs[p] = tmp;
// }
// _stuffs = stuffs;
// }
private
static
int
combination
(
int
n
,
int
m
)
{
int
com
=
1
;
for
(
int
i
=
n
-
m
+
1
;
i
<=
n
;
++
i
)
{
com
*=
i
;
}
for
(
int
i
=
2
;
i
<=
m
;
++
i
)
{
com
/=
i
;
}
return
com
;
}
private
static
int
permutation
(
int
n
)
{
int
per
=
1
;
for
(
int
i
=
2
;
i
<=
n
;
++
i
)
{
per
*=
i
;
}
return
per
;
}
public
static
int
decode
(
String
code
)
{
if
(
code
.
length
()
!=
LEN
)
{
throw
new
RuntimeException
(
"invalid code"
);
}
char
[]
chars
=
new
char
[
LEN
];
for
(
int
i
=
0
;
i
<
LEN
;++
i
)
{
chars
[
i
]
=
code
.
charAt
(
i
);
}
int
com
=
combination
(
chars
);
int
per
=
permutation
(
chars
);
return
com
*
PERMUTATION
+
per
;
}
public
static
String
encode
(
int
val
)
{
int
com
=
val
/
PERMUTATION
;
if
(
com
>=
MAX_COMBINATION
)
{
throw
new
RuntimeException
(
"id can't be greater than 652458239"
);
}
int
per
=
val
%
PERMUTATION
;
char
[]
chars
=
combination
(
com
);
chars
=
permutation
(
chars
,
per
);
return
new
String
(
chars
);
}
private
static
char
[]
combination
(
int
com
){
char
[]
chars
=
new
char
[
LEN
];
int
start
=
0
;
int
index
=
0
;
while
(
index
<
LEN
)
{
for
(
int
s
=
start
;
s
<
_stuffs
.
length
;
++
s
)
{
int
c
=
combination
(
_stuffs
.
length
-
s
-
1
,
LEN
-
index
-
1
);
if
(
com
>=
c
)
{
com
-=
c
;
continue
;
}
chars
[
index
++]
=
_stuffs
[
s
];
start
=
s
+
1
;
break
;
}
}
return
chars
;
}
private
static
char
[]
sort
(
char
[]
src
)
{
char
[]
sort
=
new
char
[
src
.
length
];
int
index
=
0
;
for
(
int
i
=
0
;
i
<
_stuffs
.
length
;
++
i
)
{
if
(
find
(
src
,
_stuffs
[
i
])
!=
-
1
)
{
sort
[
index
++]
=
_stuffs
[
i
];
}
}
return
sort
;
}
private
static
int
combination
(
char
[]
chars
)
{
int
[]
offset
=
new
int
[
LEN
];
char
[]
sort
=
sort
(
chars
);
for
(
int
i
=
0
;
i
<
sort
.
length
;++
i
)
{
offset
[
i
]
=
find
(
_stuffs
,
sort
[
i
]);
if
(
offset
[
i
]
==
-
1
)
{
throw
new
RuntimeException
(
"invalid code"
);
}
}
int
com
=
0
;
for
(
int
i
=
0
;
i
<
offset
.
length
;++
i
)
{
if
(
i
==
0
)
{
if
(
offset
[
0
]
==
0
)
{
continue
;
}
for
(
int
n
=
0
;
n
<
offset
[
0
];++
n
)
{
com
+=
combination
(
_stuffs
.
length
-
n
-
1
,
LEN
-
1
);
}
continue
;
}
if
(
offset
[
i
]
-
offset
[
i
-
1
]
<=
1
)
{
continue
;
}
for
(
int
n
=
offset
[
i
-
1
]
+
1
;
n
<
offset
[
i
];++
n
)
{
com
+=
combination
(
_stuffs
.
length
-
n
-
1
,
LEN
-
i
-
1
);
}
}
return
com
;
}
private
static
char
[]
permutation
(
char
[]
chars
,
int
per
){
char
[]
tmpchars
=
new
char
[
chars
.
length
];
System
.
arraycopy
(
chars
,
0
,
tmpchars
,
0
,
chars
.
length
);
int
[]
offset
=
new
int
[
chars
.
length
];
int
step
=
chars
.
length
;
for
(
int
i
=
chars
.
length
-
1
;
i
>=
0
;--
i
)
{
offset
[
i
]
=
per
%
step
;
per
/=
step
;
step
--;
}
for
(
int
i
=
0
;
i
<
chars
.
length
;++
i
)
{
if
(
offset
[
i
]
==
0
)
continue
;
char
tmp
=
tmpchars
[
i
];
tmpchars
[
i
]
=
tmpchars
[
i
-
offset
[
i
]];
tmpchars
[
i
-
offset
[
i
]]
=
tmp
;
}
return
tmpchars
;
}
private
static
int
find
(
char
[]
chars
,
char
ch
)
{
for
(
int
i
=
0
;
i
<
chars
.
length
;++
i
)
{
if
(
chars
[
i
]
==
ch
)
{
return
i
;
}
}
return
-
1
;
}
private
static
int
permutation
(
char
[]
chars
){
char
[]
sort
=
sort
(
chars
);
int
[]
offset
=
new
int
[
chars
.
length
];
for
(
int
i
=
chars
.
length
-
1
;
i
>=
0
;--
i
)
{
int
f
=
find
(
chars
,
sort
[
i
]);
offset
[
i
]
=
i
-
f
;
char
tmp
=
chars
[
i
];
chars
[
i
]
=
chars
[
i
-
offset
[
i
]];
chars
[
i
-
offset
[
i
]]
=
tmp
;
}
int
per
=
0
;
int
step
=
1
;
for
(
int
i
=
0
;
i
<
offset
.
length
;++
i
)
{
per
=
per
*
step
+
offset
[
i
];
step
++;
}
return
per
;
}
public
static
void
main
(
String
[]
args
)
{
// try {
// List<String> lists = new ArrayList<>();
// Set<String> sets = new HashSet<>();
// File file = new File("./log2.txt");
// BufferedOutputStream buff = new BufferedOutputStream(new FileOutputStream(file));
// resetStuffs();
// for (int i = 1; i< 10000000; ++i) {
// String code = encode(i);
// int nid = decode(code);
// if (i != nid) {
// break;
// }
// String str = i + "->" + code + "->" + nid + "\n";
// buff.write(str.getBytes());
//
// lists.add(code);
// sets.add(code);
// }
// String result = "lists.size=" + lists.size() + ", sets.size=" + sets.size() + "\n";
// buff.write(result.getBytes());
// buff.flush();
// buff.close();
// } catch (Exception e) {
// e.printStackTrace();
// }
Map
<
String
,
Integer
>
map
=
new
HashMap
<
String
,
Integer
>();
for
(
int
i
=
0
;
i
<
10000
;
i
++)
{
String
key
=
encode
(
i
);
System
.
out
.
println
(
key
);
if
(
null
==
map
.
get
(
key
))
{
map
.
put
(
key
,
1
);
}
else
{
System
.
out
.
println
(
"重复"
+
key
+
":"
+
i
);
map
.
put
(
key
,
map
.
get
(
key
)
+
1
);
}
}
int
flag
=
0
;
Set
<
Map
.
Entry
<
String
,
Integer
>>
list
=
map
.
entrySet
();
for
(
Map
.
Entry
<
String
,
Integer
>
e
:
list
)
{
if
(
e
.
getValue
()
>
1
)
{
flag
++;
System
.
out
.
println
(
e
.
getKey
()+
":"
+
e
.
getValue
());
}
}
System
.
out
.
println
(
"flag : "
+
flag
);
}
}
\ No newline at end of file
xx-activity/xx-activity-server/src/main/java/com/xxfc/platform/activity/biz/ActivityPopularizeBiz.java
View file @
08bd636b
...
...
@@ -51,7 +51,7 @@ public class ActivityPopularizeBiz extends BaseBiz<ActivityPopularizeMapper,Acti
AppUserDTO
appUserDTO
=
userFeign
.
userDetailById
(
registerQueueDTO
.
getAppUserId
()).
getData
();
//获取活动code,并且注册来源是app 并且 非普通登录
if
(
POPULARIZE_0101
.
equals
(
registerQueueDTO
.
getInParamDTO
().
getActivityCode
()
)
if
(
POPULARIZE_0101
.
equals
(
activityCode
)
&&
!
RegisterQueueDTO
.
SIGN_LOGIN
.
equals
(
registerQueueDTO
.
getSign
()))
{
//查询出活动
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment