Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
5
51business
Project
Project
Details
Activity
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
方斌
51business
Commits
094839d4
Commit
094839d4
authored
Jun 23, 2020
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add menu sort & getUsedRedeemCodeList
parent
b6acc0f5
Pipeline
#25480
passed with stage
in 4 seconds
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
5 deletions
+87
-5
back.js
app/controller/course/back.js
+10
-0
courseBackMenu.js
app/model/class/courseBackMenu.js
+1
-0
course.js
app/router/course.js
+1
-0
back.js
app/service/course/back.js
+75
-5
No files found.
app/controller/course/back.js
View file @
094839d4
...
@@ -95,6 +95,16 @@ class BackController extends Controller {
...
@@ -95,6 +95,16 @@ class BackController extends Controller {
await
service
.
course
.
back
.
exportRedeemCode
(
queryParams
);
await
service
.
course
.
back
.
exportRedeemCode
(
queryParams
);
}
}
// 已用兑换码列表
async
getUsedRedeemCodeList
()
{
const
{
ctx
,
service
}
=
this
;
const
queryParams
=
ctx
.
request
.
query
;
const
ret
=
await
service
.
course
.
back
.
getUsedRedeemCodeList
(
queryParams
);
ctx
.
success
(
ret
);
}
}
}
module
.
exports
=
BackController
;
module
.
exports
=
BackController
;
app/model/class/courseBackMenu.js
View file @
094839d4
...
@@ -16,6 +16,7 @@ module.exports = app => {
...
@@ -16,6 +16,7 @@ module.exports = app => {
path
:
STRING
,
path
:
STRING
,
icon
:
STRING
,
icon
:
STRING
,
parent_id
:
INTEGER
,
parent_id
:
INTEGER
,
sort
:
INTEGER
,
is_deleted
:
INTEGER
,
is_deleted
:
INTEGER
,
created_time
:
{
created_time
:
{
type
:
DATE
,
type
:
DATE
,
...
...
app/router/course.js
View file @
094839d4
...
@@ -12,4 +12,5 @@ module.exports = app => {
...
@@ -12,4 +12,5 @@ module.exports = app => {
router
.
get
(
'third'
,
'/class'
,
auth
,
'course.back.getClassList'
);
router
.
get
(
'third'
,
'/class'
,
auth
,
'course.back.getClassList'
);
router
.
get
(
'third'
,
'/export/order'
,
auth
,
'course.back.exportOrder'
);
router
.
get
(
'third'
,
'/export/order'
,
auth
,
'course.back.exportOrder'
);
router
.
get
(
'third'
,
'/export/redeem'
,
auth
,
'course.back.exportRedeemCode'
);
router
.
get
(
'third'
,
'/export/redeem'
,
auth
,
'course.back.exportRedeemCode'
);
router
.
get
(
'third'
,
'/redeem/used'
,
auth
,
'course.back.getUsedRedeemCodeList'
);
};
};
app/service/course/back.js
View file @
094839d4
...
@@ -47,10 +47,10 @@ class BackService extends Service {
...
@@ -47,10 +47,10 @@ class BackService extends Service {
let
menuList
=
[];
let
menuList
=
[];
if
(
userInfo
.
is_admin
>
0
)
{
if
(
userInfo
.
is_admin
>
0
)
{
menuList
=
await
ctx
.
classModel
.
CourseBackMenu
.
findAll
({
where
:
{
is_deleted
:
0
},
attributes
:
[
'id'
,
'title'
,
'path'
,
'icon'
,
'parent_id'
],
raw
:
true
});
menuList
=
await
ctx
.
classModel
.
CourseBackMenu
.
findAll
({
where
:
{
is_deleted
:
0
},
attributes
:
[
'id'
,
'title'
,
'path'
,
'icon'
,
'parent_id'
],
order
:
[[
'sort'
,
'asc'
]],
raw
:
true
});
}
else
{
}
else
{
const
userToMenuList
=
await
ctx
.
classModel
.
CourseBackUserToMenu
.
findAll
({
where
:
{
user_uuid
:
userUuid
,
is_deleted
:
0
}
});
const
userToMenuList
=
await
ctx
.
classModel
.
CourseBackUserToMenu
.
findAll
({
where
:
{
user_uuid
:
userUuid
,
is_deleted
:
0
}
});
menuList
=
await
ctx
.
classModel
.
CourseBackMenu
.
findAll
({
where
:
{
id
:
{
$in
:
R
.
pluck
(
'menu_id'
,
userToMenuList
)
},
is_deleted
:
0
},
attributes
:
[
'id'
,
'title'
,
'path'
,
'icon'
,
'parent_id'
],
raw
:
true
});
menuList
=
await
ctx
.
classModel
.
CourseBackMenu
.
findAll
({
where
:
{
id
:
{
$in
:
R
.
pluck
(
'menu_id'
,
userToMenuList
)
},
is_deleted
:
0
},
attributes
:
[
'id'
,
'title'
,
'path'
,
'icon'
,
'parent_id'
],
order
:
[[
'sort'
,
'asc'
]],
raw
:
true
});
}
}
for
(
const
i
in
menuList
)
{
for
(
const
i
in
menuList
)
{
...
@@ -88,7 +88,7 @@ class BackService extends Service {
...
@@ -88,7 +88,7 @@ class BackService extends Service {
ctx
.
failed
(
'用户异常'
);
ctx
.
failed
(
'用户异常'
);
}
}
const
filter
=
{
where
:
{
status
:
1
,
is_deleted
:
0
},
limit
,
offset
,
attributes
:
[
'id'
,
'order_no'
,
'class_id'
,
'pay'
,
'pay_time'
,
'type'
,
'redeem
'
,
'address'
],
order
:
[[
'pay_time'
,
'desc'
]]
};
const
filter
=
{
where
:
{
type
:
1
,
status
:
1
,
is_deleted
:
0
},
limit
,
offset
,
attributes
:
[
'id'
,
'order_no'
,
'class_id'
,
'pay'
,
'pay_time
'
,
'address'
],
order
:
[[
'pay_time'
,
'desc'
]]
};
let
filterClassIds
=
[];
let
filterClassIds
=
[];
if
(
!
ctx
.
isEmpty
(
input
.
class_name
))
{
if
(
!
ctx
.
isEmpty
(
input
.
class_name
))
{
const
classList
=
await
ctx
.
classModel
.
V5
.
CourseV5Class
.
findAll
({
where
:
{
name
:
{
$like
:
`%
${
input
.
class_name
}
%`
}
},
attributes
:
[
'id'
]
});
const
classList
=
await
ctx
.
classModel
.
V5
.
CourseV5Class
.
findAll
({
where
:
{
name
:
{
$like
:
`%
${
input
.
class_name
}
%`
}
},
attributes
:
[
'id'
]
});
...
@@ -138,8 +138,6 @@ class BackService extends Service {
...
@@ -138,8 +138,6 @@ class BackService extends Service {
class_name
:
ctx
.
isEmpty
(
classList
[
v
.
class_id
])
?
''
:
classList
[
v
.
class_id
][
0
].
name
,
class_name
:
ctx
.
isEmpty
(
classList
[
v
.
class_id
])
?
''
:
classList
[
v
.
class_id
][
0
].
name
,
pay
:
v
.
pay
,
pay
:
v
.
pay
,
pay_time
:
v
.
pay_time
,
pay_time
:
v
.
pay_time
,
type
:
v
.
type
,
redeem
:
v
.
redeem
,
address
:
ctx
.
isEmpty
(
v
.
address
)
?
{}
:
JSON
.
parse
(
v
.
address
),
address
:
ctx
.
isEmpty
(
v
.
address
)
?
{}
:
JSON
.
parse
(
v
.
address
),
});
});
}
}
...
@@ -220,6 +218,78 @@ class BackService extends Service {
...
@@ -220,6 +218,78 @@ class BackService extends Service {
}
}
// 获取已使用兑换码列表
async
getUsedRedeemCodeList
(
input
)
{
const
{
ctx
}
=
this
;
const
userUuid
=
ctx
.
userUuid
;
const
page
=
Number
(
input
.
page
)
||
1
;
const
limit
=
Number
(
input
.
limit
)
||
10
;
const
offset
=
(
page
-
1
)
*
limit
;
const
userInfo
=
await
ctx
.
classModel
.
CourseBackUser
.
findOne
({
where
:
{
id
:
userUuid
,
is_deleted
:
0
}
});
if
(
ctx
.
isEmpty
(
userInfo
))
{
ctx
.
failed
(
'用户异常'
);
}
const
filter
=
{
where
:
{
is_used
:
1
,
status
:
1
,
is_deleted
:
0
},
limit
,
offset
,
order
:
[[
'used_time'
,
'desc'
]]
};
let
filterClassIds
=
[];
if
(
!
ctx
.
isEmpty
(
input
.
class_name
))
{
const
classList
=
await
ctx
.
classModel
.
V5
.
CourseV5Class
.
findAll
({
where
:
{
name
:
{
$like
:
`%
${
input
.
class_name
}
%`
}
},
attributes
:
[
'id'
]
});
filterClassIds
=
R
.
pluck
(
'id'
,
classList
);
filter
.
where
.
class_id
=
{
$in
:
filterClassIds
};
}
if
(
!
ctx
.
isEmpty
(
userInfo
.
institution_id
)
&&
userInfo
.
institution_id
>
0
)
{
const
classList
=
await
ctx
.
classModel
.
V5
.
CourseV5Class
.
findAll
({
where
:
{
institution_id
:
userInfo
.
institution_id
},
attributes
:
[
'id'
]
});
filterClassIds
=
ctx
.
isEmpty
(
input
.
class_name
)
?
R
.
pluck
(
'id'
,
classList
)
:
_
.
intersection
(
filterClassIds
,
R
.
pluck
(
'id'
,
classList
));
filter
.
where
.
class_id
=
{
$in
:
filterClassIds
};
}
const
redeemCodeList
=
await
ctx
.
classModel
.
V5
.
CourseRedeemCode
.
findAndCountAll
(
filter
);
if
(
ctx
.
isEmpty
(
redeemCodeList
.
rows
))
{
return
{
list
:
[],
page_size
:
limit
,
total_count
:
redeemCodeList
.
count
,
page
,
};
}
let
classList
=
await
ctx
.
classModel
.
V5
.
CourseV5Class
.
findAll
({
where
:
{
id
:
{
$in
:
_
.
uniq
(
R
.
pluck
(
'class_id'
,
redeemCodeList
.
rows
))
}
},
attributes
:
[
'id'
,
'name'
],
raw
:
true
});
classList
=
_
.
groupBy
(
classList
,
'id'
);
let
userList
=
await
ctx
.
classModel
.
V5
.
CourseUser
.
findAll
({
where
:
{
uuid
:
{
$in
:
_
.
uniq
(
R
.
pluck
(
'user_uuid'
,
redeemCodeList
.
rows
))
}
},
attributes
:
[
'uuid'
,
'phone'
],
raw
:
true
});
userList
=
_
.
groupBy
(
userList
,
'uuid'
);
let
orderList
=
await
ctx
.
classModel
.
V5
.
CourseUserOrder
.
findAll
({
where
:
{
redeem
:
{
$in
:
_
.
uniq
(
R
.
pluck
(
'code'
,
redeemCodeList
.
rows
))
},
type
:
2
,
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'redeem'
,
'order_no'
],
raw
:
true
});
orderList
=
_
.
groupBy
(
orderList
,
'redeem'
);
const
results
=
[];
for
(
const
v
of
redeemCodeList
.
rows
)
{
results
.
push
({
id
:
v
.
id
,
class_id
:
v
.
class_id
,
class_name
:
ctx
.
isEmpty
(
classList
[
v
.
class_id
])
?
''
:
classList
[
v
.
class_id
][
0
].
name
,
code
:
v
.
code
,
channel
:
v
.
channel
,
phone
:
ctx
.
isEmpty
(
userList
[
v
.
user_uuid
])
?
''
:
userList
[
v
.
user_uuid
][
0
].
phone
,
order_no
:
ctx
.
isEmpty
(
orderList
[
v
.
code
])
?
''
:
orderList
[
v
.
code
][
0
].
order_no
,
used_time
:
v
.
used_time
,
created_time
:
v
.
created_time
,
});
}
const
ret
=
{
list
:
results
,
page_size
:
limit
,
total_count
:
redeemCodeList
.
count
,
page
,
};
return
ret
;
}
// 生成兑换码
// 生成兑换码
async
addRedeemCode
(
input
)
{
async
addRedeemCode
(
input
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
...
...
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