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
b1a7147f
Commit
b1a7147f
authored
Jun 09, 2020
by
任国军
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix redeemCode
parent
a72c4a07
Pipeline
#24692
passed with stage
in 6 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
53 additions
and
8 deletions
+53
-8
user.js
app/controller/course/v5/user.js
+4
-4
courseRedeemCode.js
app/model/class/v5/courseRedeemCode.js
+8
-0
course_v5.js
app/router/course_v5.js
+1
-1
back.js
app/service/course/back.js
+20
-0
user.js
app/service/course/v5/user.js
+20
-3
No files found.
app/controller/course/v5/user.js
View file @
b1a7147f
...
@@ -123,13 +123,13 @@ class UserController extends Controller {
...
@@ -123,13 +123,13 @@ class UserController extends Controller {
// 兑换课程
// 兑换课程
async
redeemClass
()
{
async
redeemClass
()
{
const
{
ctx
,
service
}
=
this
;
const
{
ctx
,
service
}
=
this
;
const
params
=
ctx
.
params
;
const
params
=
ctx
.
request
.
body
;
if
(
ctx
.
isEmpty
(
params
)
||
ctx
.
isEmpty
(
params
.
redeem_
code
))
{
if
(
ctx
.
isEmpty
(
params
)
||
ctx
.
isEmpty
(
params
.
code
))
{
ctx
.
failed
(
'
redeem_
code is failed'
);
ctx
.
failed
(
'code is failed'
);
}
}
const
ret
=
await
service
.
course
.
v5
.
user
.
redeemClass
(
params
.
redeem_code
);
const
ret
=
await
service
.
course
.
v5
.
user
.
redeemClass
(
params
);
ctx
.
success
(
ret
);
ctx
.
success
(
ret
);
}
}
}
}
...
...
app/model/class/v5/courseRedeemCode.js
View file @
b1a7147f
...
@@ -18,6 +18,14 @@ module.exports = app => {
...
@@ -18,6 +18,14 @@ module.exports = app => {
is_used
:
INTEGER
,
is_used
:
INTEGER
,
status
:
INTEGER
,
status
:
INTEGER
,
is_deleted
:
INTEGER
,
is_deleted
:
INTEGER
,
used_time
:
{
type
:
DATE
,
allowNull
:
true
,
get
()
{
const
date
=
this
.
getDataValue
(
'used_time'
);
return
date
?
moment
(
date
).
format
(
'YYYY-MM-DD HH:mm:ss'
)
:
undefined
;
},
},
created_time
:
{
created_time
:
{
type
:
DATE
,
type
:
DATE
,
allowNull
:
true
,
allowNull
:
true
,
...
...
app/router/course_v5.js
View file @
b1a7147f
...
@@ -15,7 +15,7 @@ module.exports = app => {
...
@@ -15,7 +15,7 @@ module.exports = app => {
router
.
post
(
'third'
,
'/user/address'
,
auth
({
is_force
:
1
}),
'course.v5.user.addUserAddress'
);
// 新增用户收货地址
router
.
post
(
'third'
,
'/user/address'
,
auth
({
is_force
:
1
}),
'course.v5.user.addUserAddress'
);
// 新增用户收货地址
router
.
get
(
'third'
,
'/user/address'
,
auth
({
is_force
:
1
}),
'course.v5.user.getUserAddress'
);
// 获取用户收货地址
router
.
get
(
'third'
,
'/user/address'
,
auth
({
is_force
:
1
}),
'course.v5.user.getUserAddress'
);
// 获取用户收货地址
router
.
get
(
'third'
,
'/user/order/all'
,
auth
({
is_force
:
1
}),
'course.v5.user.getUserOrderList'
);
// 获取订单列表
router
.
get
(
'third'
,
'/user/order/all'
,
auth
({
is_force
:
1
}),
'course.v5.user.getUserOrderList'
);
// 获取订单列表
router
.
post
(
'third'
,
'/user/redeem/class
/:redeem_code
'
,
auth
({
is_force
:
1
}),
'course.v5.user.redeemClass'
);
// 兑换课程
router
.
post
(
'third'
,
'/user/redeem/class'
,
auth
({
is_force
:
1
}),
'course.v5.user.redeemClass'
);
// 兑换课程
router
.
get
(
'third'
,
'/category/all'
,
auth
({
is_force
:
0
}),
'course.v5.option.getCategoryList'
);
// 获取分类列表
router
.
get
(
'third'
,
'/category/all'
,
auth
({
is_force
:
0
}),
'course.v5.option.getCategoryList'
);
// 获取分类列表
router
.
get
(
'third'
,
'/banner/all'
,
'course.v5.option.getBannerList'
);
// 获取banner列表
router
.
get
(
'third'
,
'/banner/all'
,
'course.v5.option.getBannerList'
);
// 获取banner列表
...
...
app/service/course/back.js
View file @
b1a7147f
...
@@ -65,6 +65,26 @@ class BackService extends Service {
...
@@ -65,6 +65,26 @@ class BackService extends Service {
return
{
list
:
results
};
return
{
list
:
results
};
}
}
// 订单列表
async
getOrderList
(
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
:
{
status
:
1
,
is_deleted
:
0
},
limit
,
offset
,
attributes
:
[
'id'
,
'order_no'
,
'class_id'
,
'pay'
,
'pay_time'
,
'type'
,
'redeem'
,
'address'
]
};
if
(
userInfo
.
is_admin
===
0
)
{
const
classList
=
await
ctx
.
classModel
.
V5
.
CourseClass
.
findAll
({
where
:
{
institution_id
:
{
$in
:
userInfo
.
institution_id
}
},
attributes
:
[
'id'
]
});
}
}
}
}
module
.
exports
=
BackService
;
module
.
exports
=
BackService
;
app/service/course/v5/user.js
View file @
b1a7147f
...
@@ -459,9 +459,11 @@ class UserService extends Service {
...
@@ -459,9 +459,11 @@ class UserService extends Service {
// 兑换课程
// 兑换课程
async
redeemClass
(
redeemCode
)
{
async
redeemClass
(
input
)
{
const
{
ctx
}
=
this
;
const
{
ctx
}
=
this
;
const
userUuid
=
ctx
.
userUuid
;
const
userUuid
=
ctx
.
userUuid
;
const
redeemCode
=
input
.
code
;
const
classId
=
Number
(
input
.
class_id
)
||
0
;
if
(
ctx
.
isEmpty
(
userUuid
))
{
if
(
ctx
.
isEmpty
(
userUuid
))
{
ctx
.
failed
(
'用户异常'
);
ctx
.
failed
(
'用户异常'
);
}
}
...
@@ -483,6 +485,21 @@ class UserService extends Service {
...
@@ -483,6 +485,21 @@ class UserService extends Service {
ctx
.
failed
(
'地址不能为空'
);
ctx
.
failed
(
'地址不能为空'
);
}
}
const
classInfo
=
await
ctx
.
classModel
.
V5
.
CourseV5Class
.
findOne
({
where
:
{
id
:
codeInfo
.
class_id
,
status
:
1
,
is_deleted
:
0
},
attributes
:
[
'id'
,
'institution_id'
,
'name'
,
'button_url'
]
});
if
(
ctx
.
isEmpty
(
classInfo
))
{
ctx
.
failed
(
'课程不存在'
);
}
// 判断是否是同一个课程
if
(
classId
>
0
&&
classId
!==
codeInfo
.
class_id
)
{
const
institution
=
await
ctx
.
classModel
.
V5
.
CourseV5Institution
.
findOne
({
where
:
{
id
:
classInfo
.
institution_id
}
});
return
{
class_id
:
codeInfo
.
class_id
,
result
:
false
,
text
:
`您输入的兑换码只可兑换【
${
institution
.
name
}
】的【
${
classInfo
.
name
}
】 是否需要兑换`
,
};
}
// 订单处理
// 订单处理
const
orderInfo
=
await
ctx
.
classModel
.
V5
.
CourseUserOrder
.
findOne
({
where
:
{
user_uuid
:
userUuid
,
class_id
:
codeInfo
.
class_id
,
is_deleted
:
0
}
});
const
orderInfo
=
await
ctx
.
classModel
.
V5
.
CourseUserOrder
.
findOne
({
where
:
{
user_uuid
:
userUuid
,
class_id
:
codeInfo
.
class_id
,
is_deleted
:
0
}
});
if
(
ctx
.
isEmpty
(
orderInfo
))
{
if
(
ctx
.
isEmpty
(
orderInfo
))
{
...
@@ -496,9 +513,9 @@ class UserService extends Service {
...
@@ -496,9 +513,9 @@ class UserService extends Service {
}
}
}
}
await
ctx
.
classModel
.
V5
.
CourseRedeemCode
.
update
({
user_uuid
:
userUuid
,
is_used
:
1
},
{
where
:
{
id
:
codeInfo
.
id
}
});
await
ctx
.
classModel
.
V5
.
CourseRedeemCode
.
update
({
user_uuid
:
userUuid
,
is_used
:
1
,
used_time
:
moment
().
format
(
'YYYY-MM-DD HH:mm:ss'
)
},
{
where
:
{
id
:
codeInfo
.
id
}
});
return
{
class_id
:
codeInfo
.
class_id
};
return
{
class_id
:
codeInfo
.
class_id
,
result
:
true
,
url
:
classInfo
.
button_url
};
}
}
}
}
...
...
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