Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-activity-platform
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
李奇
6 years ago
Commit
4c69b20fdf30d3c0bfaf4e6454c3f28e2da000bf
1 parent
783ff2ab
大转盘活动ID加解密
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
18 deletions
apps/admin/controllers/wheel-surf.js
apps/admin/models/wheel-surf.js
public/vue/wheel-surf/list.vue
apps/admin/controllers/wheel-surf.js
View file @
4c69b20
...
...
@@ -82,7 +82,7 @@ const whSurfController = {
try
{
let
data
=
valid
(
req
.
body
,
{
id
:
{
type
:
'number'
,
empty
:
true
},
act_id
:
{
type
:
'
number
'
,
empty
:
false
},
act_id
:
{
type
:
'
string
'
,
empty
:
false
},
rule_btn_bg
:
{
type
:
'string'
,
empty
:
true
},
rule_url
:
{
type
:
'string'
,
empty
:
true
},
share_btn_bg
:
{
type
:
'string'
,
empty
:
true
},
...
...
@@ -168,7 +168,7 @@ const whSurfController = {
if
(
param
&&
param
.
length
&&
param
instanceof
Array
)
{
let
arr
=
param
.
map
((
value
)
=>
{
return
valid
(
value
,
{
act_id
:
{
type
:
'
number
'
,
empty
:
false
},
act_id
:
{
type
:
'
string
'
,
empty
:
false
},
name
:
{
type
:
'string'
,
empty
:
true
},
type
:
{
type
:
'number'
,
empty
:
true
},
value
:
{
type
:
'string'
,
empty
:
true
},
...
...
@@ -211,7 +211,7 @@ const whSurfController = {
let
arr
=
param
.
map
((
value
)
=>
{
return
valid
(
value
,
{
id
:
{
type
:
'number'
,
empty
:
true
},
act_id
:
{
type
:
'
number
'
,
empty
:
false
},
act_id
:
{
type
:
'
string
'
,
empty
:
false
},
name
:
{
type
:
'string'
,
empty
:
true
},
type
:
{
type
:
'number'
,
empty
:
true
},
value
:
{
type
:
'string'
,
empty
:
true
},
...
...
apps/admin/models/wheel-surf.js
View file @
4c69b20
const
_
=
require
(
'lodash'
);
const
{
Activity
}
=
require
(
'../../../db'
);
const
mysqlCli
=
global
.
yoho
.
utils
.
mysqlCli
;
const
aes
=
require
(
'../../../utils/aes'
);
class
ActWheelSurfModel
extends
global
.
yoho
.
BaseModel
{
constructor
(
ctx
)
{
...
...
@@ -9,29 +8,40 @@ class ActWheelSurfModel extends global.yoho.BaseModel {
this
.
client
=
this
.
redis
.
client
;
}
list
()
{
return
Activity
.
findAll
({
where
:
{
type
:
1
}});
async
list
()
{
let
len
=
await
this
.
client
.
llenAsync
(
'turntable:activity'
);
return
this
.
client
.
lrangeAsync
(
'turntable:activity'
,
0
,
len
-
1
).
then
(
acts
=>
{
return
acts
.
filter
(
act
=>
act
).
map
(
act
=>
{
return
JSON
.
parse
(
act
);
});
});
}
create
(
data
)
{
return
Activity
.
create
(
data
);
async
create
(
data
)
{
let
len
=
await
this
.
client
.
llenAsync
(
'turntable:activity'
);
data
.
id
=
len
+
1
;
data
.
encryptedId
=
aes
.
encryptUid
(
len
+
1
);
return
this
.
client
.
rpushAsync
(
'turntable:activity'
,
JSON
.
stringify
(
data
));
}
async
actDelete
(
id
)
{
await
Activity
.
destroy
({
where
:
{
id
}});
return
true
;
id
=
parseInt
(
aes
.
decryptUid
(
id
),
10
);
return
this
.
client
.
lsetAsync
(
'turntable:activity'
,
id
-
1
,
''
);
}
actInfo
(
act_id
)
{
return
Activity
.
findOne
({
where
:
{
id
:
act_id
}});
let
idx
=
parseInt
(
aes
.
decryptUid
(
act_id
),
10
)
-
1
;
return
this
.
client
.
lrangeAsync
(
'turntable:activity'
,
idx
,
idx
).
then
(
act
=>
{
return
JSON
.
parse
(
act
[
0
]
||
{});
});
}
async
userFind
(
obj
)
{
let
pageNo
=
obj
.
pageNo
||
1
;
let
pageSize
=
obj
.
pageSize
||
20
;
let
actId
=
obj
.
act_id
;
let
actId
=
parseInt
(
aes
.
decryptUid
(
obj
.
act_id
),
10
);
let
len
=
await
this
.
client
.
llenAsync
(
`
turntable
:
$
{
actId
}:
prize
:
users
`
);
return
this
.
client
.
lrangeAsync
(
`
turntable
:
$
{
actId
}:
prize
:
users
`
,
(
pageNo
-
1
)
*
pageSize
,
pageNo
*
pageSize
-
1
).
then
(
prizes
=>
{
let
afters
=
prizes
.
map
(
prize
=>
{
prize
=
prize
.
split
(
':::'
);
...
...
@@ -51,6 +61,7 @@ class ActWheelSurfModel extends global.yoho.BaseModel {
}
async
exportRecords
(
actId
)
{
actId
=
parseInt
(
aes
.
decryptUid
(
actId
),
10
);
let
len
=
await
this
.
client
.
llenAsync
(
`
turntable
:
$
{
actId
}:
prize
:
user
`
);
return
this
.
client
.
lrangeAsync
(
`
turntable
:
$
{
actId
}:
prize
:
users
`
,
0
,
len
-
1
).
then
(
prizes
=>
{
return
prizes
.
map
(
prize
=>
{
...
...
@@ -66,6 +77,7 @@ class ActWheelSurfModel extends global.yoho.BaseModel {
}
getActConf
(
actId
)
{
actId
=
parseInt
(
aes
.
decryptUid
(
actId
),
10
);
return
this
.
client
.
hgetallAsync
(
`
turntable
:
$
{
actId
}
`
).
then
(
conf
=>
{
conf
=
conf
||
{};
Object
.
keys
(
conf
).
forEach
(
key
=>
{
...
...
@@ -79,10 +91,12 @@ class ActWheelSurfModel extends global.yoho.BaseModel {
setActConf
(
actId
,
confObj
)
{
confObj
.
id
=
1
;
actId
=
parseInt
(
aes
.
decryptUid
(
actId
),
10
);
return
this
.
client
.
HMSET
(
`
turntable
:
$
{
actId
}
`
,
confObj
);
}
getActPrize
(
actId
,
len
=
7
)
{
actId
=
parseInt
(
aes
.
decryptUid
(
actId
),
10
);
return
this
.
client
.
lrangeAsync
(
`
turntable
:
$
{
actId
}:
prize
`
,
0
,
len
)
.
then
(
async
(
prizes
)
=>
{
let
left
=
0
;
...
...
@@ -97,6 +111,7 @@ class ActWheelSurfModel extends global.yoho.BaseModel {
createActPrize
(
actId
,
prizesList
)
{
prizesList
=
prizesList
||
[];
actId
=
parseInt
(
aes
.
decryptUid
(
actId
),
10
);
let
multi
=
this
.
client
.
multi
();
prizesList
.
map
((
prize
,
idx
)
=>
{
...
...
@@ -109,6 +124,7 @@ class ActWheelSurfModel extends global.yoho.BaseModel {
updateActPrize
(
actId
,
prizesList
)
{
prizesList
=
prizesList
||
[];
actId
=
parseInt
(
aes
.
decryptUid
(
actId
),
10
);
let
multi
=
this
.
client
.
multi
();
prizesList
.
map
((
prize
,
idx
)
=>
{
...
...
public/vue/wheel-surf/list.vue
View file @
4c69b20
...
...
@@ -13,7 +13,7 @@
columns1: [
{
title: '活动ID',
key: '
i
d'
key: '
encryptedI
d'
},
{
title: '活动标题',
...
...
@@ -47,7 +47,7 @@
},
on: {
click: () => {
this.conf(row.
i
d);
this.conf(row.
encryptedI
d);
}
}
}, '配置'),
...
...
@@ -61,7 +61,7 @@
},
on: {
click: () => {
this.prizeSent(row.
i
d);
this.prizeSent(row.
encryptedI
d);
}
}
}, '中奖一览'),
...
...
@@ -72,7 +72,7 @@
},
on: {
click: () => {
this.delete(row.
i
d);
this.delete(row.
encryptedI
d);
}
}
}, '删除')
...
...
Please
register
or
login
to post a comment