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
Plain Diff
Browse Files
Authored by
陈峰
7 years ago
Commit
4e9d5fbd0fa4f6a2fa30bfbcca9b674ce67244ea
2 parents
c2a5b5d5
9ae4a720
Merge branch 'feature/yohood' into 'master'
Feature/yohood See merge request
!45
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
11 deletions
apps/admin/controllers/coupon.js
apps/admin/models/coupon.js
apps/api/models/coupon.js
apps/passport/controllers/user.js
apps/admin/controllers/coupon.js
View file @
4e9d5fb
...
...
@@ -32,10 +32,12 @@ const timeFormat = (time) => {
};
const
couponController
=
{
async
loadCouponNoList
(
req
,
res
,
next
)
{
loadCouponNoList
:
async
function
(
req
,
res
,
next
)
{
let
file
=
req
.
files
.
up_excel
;
let
id
=
req
.
body
.
id
;
res
.
setTimeout
(
1000
*
60
*
3
+
1000
);
let
data
=
await
loadExcel
(
file
.
path
);
if
(
!
data
.
length
)
{
...
...
@@ -76,11 +78,8 @@ const couponController = {
}
}
for
(
let
item
of
data
)
{
let
param
=
{
couponId
:
id
,
couponNo
:
item
.
couponNo
};
await
req
.
ctx
(
CouponModel
).
couponNoAdd
(
param
);
}
await
req
.
ctx
(
CouponModel
).
couponNoAdd
({
couponId
:
id
,
couponNos
:
data
});
return
res
.
json
({
code
:
200
,
result
:
true
,
...
...
@@ -168,6 +167,8 @@ const couponController = {
downloadNoList
(
req
,
res
,
next
)
{
const
couponId
=
req
.
query
.
id
;
res
.
setTimeout
(
1000
*
60
*
3
+
1000
);
if
(
!
couponId
)
{
return
res
.
json
({
code
:
400
,
...
...
apps/admin/models/coupon.js
View file @
4e9d5fb
...
...
@@ -44,8 +44,17 @@ class CouponModel extends global.yoho.BaseModel {
}
}
couponNoAdd
(
arr
)
{
return
mysqlCli
.
insert
(
`
insert
into
$
{
TABLE_COUPON_NO
}
(
coupon_id
,
coupon_no
)
values
(
:
couponId
,
:
couponNo
)
`
,
arr
);
couponNoAdd
(
obj
)
{
let
sql
=
`
insert
into
$
{
TABLE_COUPON_NO
}
(
coupon_id
,
coupon_no
)
values
`
;
let
arr
=
obj
.
couponNos
;
arr
.
map
((
value
,
index
)
=>
{
sql
+=
'('
+
obj
.
couponId
+
',"'
+
value
.
couponNo
+
'")'
;
if
(
index
!==
(
arr
.
length
-
1
))
{
sql
+=
','
;
}
});
return
mysqlCli
.
insert
(
sql
);
}
async
couponModify
(
obj
)
{
...
...
@@ -120,7 +129,7 @@ class CouponModel extends global.yoho.BaseModel {
return
mysqlCli
.
query
(
`
select
cn
.
coupon_id
couponId
,
cn
.
coupon_no
couponNo
,
cn
.
send_flag
sendFlag
,
cu
.
user_id
userId
,
cu
.
create_time
createTime
from
$
{
TABLE_COUPON_NO
}
as
cn
left
join
$
{
TABLE_COUPON_USER
}
as
cu
on
cu
.
coupon_
id
=
cn
.
coupon_
id
where
cn
.
coupon_id
=
:
couponId
`
,
{
couponId
});
on
cu
.
coupon_
no_id
=
cn
.
id
where
cn
.
coupon_id
=
:
couponId
`
,
{
couponId
});
}
couponUserListByCId
(
couponId
)
{
...
...
apps/api/models/coupon.js
View file @
4e9d5fb
...
...
@@ -25,7 +25,7 @@ class CouponModel extends global.yoho.BaseModel {
return
mysqlCli
.
query
(
`
select
c
.
id
,
c
.
coupon_name
couponName
,
c
.
coupon_desc
couponDesc
,
c
.
shop_logo_url
shopLogoUrl
,
cn
.
coupon_no
couponNo
from
$
{
TABLE_COUPON
}
c
,
$
{
TABLE_COUPON_NO
}
cn
,
$
{
TABLE_COUPON_USER
}
cu
where
cu
.
user_id
=
:
userId
and
cu
.
coupon_no_id
=
cn
.
id
and
c
.
id
=
cn
.
coupon_id
order
by
c
.
sort
desc
,
c
.
create_time
desc
`
,
{
userId
});
order
by
c
u
.
create_time
desc
`
,
{
userId
});
}
async
coouponUserGet
(
obj
)
{
...
...
apps/passport/controllers/user.js
View file @
4e9d5fb
...
...
@@ -269,7 +269,14 @@ const userController = {
* @param res
*/
wechatUserCallback
(
req
,
res
,
next
)
{
let
wechatUserInfo
=
JSON
.
parse
(
req
.
query
.
wechatUserInfo
);
let
wechatUserInfo
;
try
{
wechatUserInfo
=
JSON
.
parse
(
req
.
query
.
wechatUserInfo
);
}
catch
(
err
)
{
wechatUserInfo
=
{};
}
console
.
log
(
'wechatUserCallBack:'
,
wechatUserInfo
);
let
user_name
=
''
,
...
...
@@ -277,7 +284,7 @@ const userController = {
union_id
=
''
;
if
(
wechatUserInfo
)
{
if
(
wechatUserInfo
&&
wechatUserInfo
.
nickname
)
{
user_name
=
wechatUserInfo
.
nickname
;
head_img
=
wechatUserInfo
.
headimgurl
;
union_id
=
wechatUserInfo
.
unionid
||
wechatUserInfo
.
openid
;
...
...
Please
register
or
login
to post a comment